From a83616b67e6a7c4eba7bfa8dd30536b2b1dcdb9c Mon Sep 17 00:00:00 2001 From: zontreck Date: Sun, 4 Aug 2024 17:12:34 -0700 Subject: [PATCH] Adds an ability to replace buttons --- Next Engine.lsl | 13 ++++++++++++ includes/header.lsl | 48 +++------------------------------------------ 2 files changed, 16 insertions(+), 45 deletions(-) diff --git a/Next Engine.lsl b/Next Engine.lsl index 36fee9b..1c705c5 100644 --- a/Next Engine.lsl +++ b/Next Engine.lsl @@ -6,6 +6,7 @@ 08-2024 INITIAL RELEASE * Finished hooking up listener and timer + * Add ability to replace menu buttons (Toggles) 06-2024 INITIAL VERSION * Manage memory more efficiently than all other current systems @@ -33,6 +34,7 @@ integer LINK_SIGNAL_REGISTER_MENU = 0602242; integer LINK_SIGNAL_RESET = 0602243; integer LINK_SIGNAL_MENU_DATA = 0602244; integer LINK_SIGNAL_MENU_BACK = 0801241; +integer LINK_SIGNAL_REPLACE_BUTTON = 0804241; @@ -595,6 +597,17 @@ default } llLinksetDataWrite("menus." + (string)i, sJson); + } else if(n == LINK_SIGNAL_REPLACE_BUTTON) { + string jsMenu = readMenu(llJsonGetValue(m, ["menu"])); + list lButtons = llJson2List(llJsonGetValue(jsMenu, ["buttons"])); + + integer iIndex = llListFindList(lButtons, [llJsonGetValue(m,["btn"])]); + if(iIndex != -1) { + lButtons = llListReplaceList(lButtons, [llJsonGetValue(m, ["newBtn"])], iIndex, iIndex); + jsMenu = llJsonSetValue(jsMenu, ["buttons"], llList2Json(JSON_ARRAY, lButtons)); + updateMenu(llJsonGetValue(m,["menu"]), jsMenu); + + } } } diff --git a/includes/header.lsl b/includes/header.lsl index ac8a49c..83d15f3 100644 --- a/includes/header.lsl +++ b/includes/header.lsl @@ -8,6 +8,7 @@ integer LINK_SIGNAL_REGISTER_MENU = 0602242; integer LINK_SIGNAL_RESET = 0602243; integer LINK_SIGNAL_MENU_DATA = 0602244; integer LINK_SIGNAL_MENU_BACK = 0801241; +integer LINK_SIGNAL_REPLACE_BUTTON = 0804241; string PREVIOUS_MENU = "<--"; @@ -69,49 +70,6 @@ returnMenu(key kID, string sMenu, integer iPage, string sReply) { llMessageLinked(LINK_SET, LINK_SIGNAL_MENU_BACK, llList2Json(JSON_OBJECT, ["menu", sMenu, "page", iPage, "reply", sReply]), kID); } -integer g_iDebugIndent=0; -integer DEBUG_ENABLED() { - return FALSE; +replaceMenuButton(string sMenu, string sButton, string sNewButton) { + llMessageLinked(LINK_SET, LINK_SIGNAL_REPLACE_BUTTON, llList2Json(JSON_OBJECT, ["menu", sMenu, "btn", sButton, "newBtn", sNewButton]), ""); } - -DEBUG_FUNC(integer iEnter, string sLabel, list lParams) { - if(!DEBUG_ENABLED()) return; - if(iEnter){ - llOwnerSay(MakeIndent() + "ENTER " + sLabel + " [" + llList2CSV(lParams) + "]"); - g_iDebugIndent++; - } else { - g_iDebugIndent --; - if(g_iDebugIndent<0)g_iDebugIndent=0; - - llOwnerSay(MakeIndent() + "LEAVE " + sLabel + " [" + llList2CSV(lParams) + "]"); - } -} - -DEBUG_STMT(integer iEnter, string sLabel) { - if(!DEBUG_ENABLED()) return; - if(iEnter) { - llOwnerSay(MakeIndent() + "STMT " + sLabel); - g_iDebugIndent ++; - }else { - g_iDebugIndent--; - if(g_iDebugIndent<0)g_iDebugIndent=0; - - llOwnerSay(MakeIndent() + "RET " + sLabel); - } -} - -DEBUG(string sMsg) { - if(!DEBUG_ENABLED()) return; - llOwnerSay(MakeIndent() + " > " + sMsg); -} - -string MakeIndent() -{ - integer i = 0; - string sIndent = ""; - for(i = 0;i