From 4e780e143cb8357cd873f92ce384bfd2377248ac Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 1 Mar 2024 02:41:03 -0300 Subject: [PATCH 1/2] refactor: modal window helper to core --- .../others/modal_window_helper.lua | 35 ------------------- .../others}/modal_window_helper.lua | 0 2 files changed, 35 deletions(-) delete mode 100644 data-otservbr-global/scripts/creaturescripts/others/modal_window_helper.lua rename {data-canary/scripts/creaturescripts => data/scripts/creaturescripts/others}/modal_window_helper.lua (100%) diff --git a/data-otservbr-global/scripts/creaturescripts/others/modal_window_helper.lua b/data-otservbr-global/scripts/creaturescripts/others/modal_window_helper.lua deleted file mode 100644 index d2651af1e69..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/others/modal_window_helper.lua +++ /dev/null @@ -1,35 +0,0 @@ -local creatureEvent = CreatureEvent("modalWindowHelper") - -function creatureEvent.onModalWindow(player, modalWindowId, buttonId, choiceId) - local playerId = player:getId() - local modalWindows = ModalWindows[playerId] - if not modalWindows then - return true - end - - local modalWindow = modalWindows[modalWindowId] - if not modalWindow then - return true - end - - local button = modalWindow.buttons[buttonId] or {} - local choice = modalWindow.choices[choiceId] or {} - if button.callback then - button.callback(player, button, choice) - elseif choice.callback then - choice.callback(player, button, choice) - elseif modalWindow.defaultCallback then - modalWindow.defaultCallback(player, button, choice) - end - - modalWindow.using = modalWindow.using - 1 - if modalWindow.using == 0 then - modalWindows[modalWindowId] = nil - if not next(modalWindows) then - ModalWindows[playerId] = nil - end - end - return true -end - -creatureEvent:register() diff --git a/data-canary/scripts/creaturescripts/modal_window_helper.lua b/data/scripts/creaturescripts/others/modal_window_helper.lua similarity index 100% rename from data-canary/scripts/creaturescripts/modal_window_helper.lua rename to data/scripts/creaturescripts/others/modal_window_helper.lua From 75fab0e7921a01b736e40815bdd1221a0551b719 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 1 Mar 2024 12:51:30 -0300 Subject: [PATCH 2/2] change script name --- data/scripts/creaturescripts/others/modal_window_helper.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/scripts/creaturescripts/others/modal_window_helper.lua b/data/scripts/creaturescripts/others/modal_window_helper.lua index d2651af1e69..a3a33b3d274 100644 --- a/data/scripts/creaturescripts/others/modal_window_helper.lua +++ b/data/scripts/creaturescripts/others/modal_window_helper.lua @@ -1,4 +1,4 @@ -local creatureEvent = CreatureEvent("modalWindowHelper") +local creatureEvent = CreatureEvent("ModalWindowHelper") function creatureEvent.onModalWindow(player, modalWindowId, buttonId, choiceId) local playerId = player:getId()