From 3a2018ddda6feb1aaa023106f95de6d8e0a0b507 Mon Sep 17 00:00:00 2001 From: nat-goodspeed Date: Thu, 20 Jun 2024 12:56:35 -0400 Subject: Revert LLLuaFloater "idle" events in favor of Lua timers.Timer(). --- indra/llui/llluafloater.cpp | 16 ++-------------- indra/llui/llluafloater.h | 2 -- .../newview/scripts/lua/test_luafloater_speedometer.lua | 16 +++++++++++----- 3 files changed, 13 insertions(+), 21 deletions(-) (limited to 'indra') diff --git a/indra/llui/llluafloater.cpp b/indra/llui/llluafloater.cpp index 62e77fd556..e584a67a00 100644 --- a/indra/llui/llluafloater.cpp +++ b/indra/llui/llluafloater.cpp @@ -35,7 +35,6 @@ #include "lltexteditor.h" const std::string LISTENER_NAME("LLLuaFloater"); -const F32 IDLE_INTERVAL = 0.5; std::set EVENT_LIST = { "commit", @@ -48,16 +47,14 @@ std::set EVENT_LIST = { "right_mouse_up", "post_build", "floater_close", - "keystroke", - "idle" + "keystroke" }; LLLuaFloater::LLLuaFloater(const LLSD &key) : LLFloater(key), mDispatchListener(LLUUID::generateNewID().asString(), "action"), mReplyPumpName(key["reply"].asString()), - mReqID(key), - mIdleTimer(new LLTimer()) + mReqID(key) { auto ctrl_lookup = [this](const LLSD &event, std::function cb) { @@ -169,15 +166,6 @@ BOOL LLLuaFloater::postBuild() return true; } -void LLLuaFloater::draw() -{ - if (mIdleTimer->checkExpirationAndReset(IDLE_INTERVAL)) - { - postEvent(LLSD(), "idle"); - } - LLFloater::draw(); -} - void LLLuaFloater::onClose(bool app_quitting) { postEvent(llsd::map("app_quitting", app_quitting), "floater_close"); diff --git a/indra/llui/llluafloater.h b/indra/llui/llluafloater.h index 36e65ac7fc..ccc3ccb39b 100644 --- a/indra/llui/llluafloater.h +++ b/indra/llui/llluafloater.h @@ -36,7 +36,6 @@ public: LLLuaFloater(const LLSD &key); BOOL postBuild(); virtual ~LLLuaFloater(); - void draw(); void registerCallback(const std::string &ctrl_name, const std::string &event); void onClose(bool app_quitting); @@ -49,7 +48,6 @@ public: private: LLReqID mReqID; LLDispatchListener mDispatchListener; - std::unique_ptr mIdleTimer; std::string mReplyPumpName; }; diff --git a/indra/newview/scripts/lua/test_luafloater_speedometer.lua b/indra/newview/scripts/lua/test_luafloater_speedometer.lua index 610401ae44..a9d3a70330 100644 --- a/indra/newview/scripts/lua/test_luafloater_speedometer.lua +++ b/indra/newview/scripts/lua/test_luafloater_speedometer.lua @@ -1,18 +1,23 @@ local Floater = require 'Floater' +local leap = require 'leap' +local LLNotification = require 'LLNotification' local startup = require 'startup' -inspect = require 'inspect' -leap = require 'leap' -LLNotification = require 'LLNotification' +local Timer = (require 'timers').Timer local max_speed = 0 local flt = Floater:new("luafloater_speedometer.xml") startup.wait('STATE_STARTED') +local timer + function flt:floater_close(event_data) + if timer then + timer:cancel() + end msg = "Registered max speed: " .. string.format("%.2f", max_speed) .. " m/s"; LLNotification.add('SystemMessageTip', {MESSAGE = msg}) end -function flt:idle(event_data) +local function idle(event_data) local speed = leap.request('LLVOAvatar', {op='getSpeed'})['value'] flt:post({action="set_value", ctrl_name="speed_lbl", value = string.format("%.2f", speed)}) max_speed=math.max(max_speed, speed) @@ -22,5 +27,6 @@ msg = 'Are you sure you want to run this "speedometer" script?' response = LLNotification.requestAdd('GenericAlertYesCancel', {MESSAGE = msg}) if response.OK_okcancelbuttons then - flt:show() + flt:show() + timer = Timer:new(1, idle, true) -- iterate end -- cgit v1.2.3