From 82936fa495626b31808d05f77deb2b2ad8160db7 Mon Sep 17 00:00:00 2001 From: Cogwheel-17646 Date: Wed, 30 Apr 2008 03:16:23 +0000 Subject: [PATCH] Close button now shows unsaved dialog No longer auto-saves on run (should we add an auto save check box?) --- Localization.enUS.lua | 24 ++++++++++++------------ WowLua.lua | 14 +++++++++++++- WowLua.xml | 13 ++++++++++++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Localization.enUS.lua b/Localization.enUS.lua index 151297d..2fd0e54 100644 --- a/Localization.enUS.lua +++ b/Localization.enUS.lua @@ -8,18 +8,18 @@ L.NEW_PAGE_TITLE = "Untitled %d" L.RELOAD_COMMAND = "/reload" L.RESET_COMMAND = "/reset" -L.TOOLTIPS = { - ["New"] = { name = "New", text = "Create a new script page" }, - ["Open"] = { name = "Open", text = "Open an existing script page" }, - ["Save"] = { name = "Save", text = "Save the current page\n\nHint: You can shift-click this button to rename a page" }, - ["Undo"] = { name = "Undo", text = "Revert to the last saved version" }, - ["Delete"] = { name = "Delete", text = "Delete the current page" }, - ["Lock"] = { name = "Lock", text = "This page is unlocked to allow changes. Click to lock." }, - ["Unlock"] = { name = "Unlock", text = "This page is locked to prevent changes. Click to unlock." }, - ["Previous"] = { name = "Previous", text = "Navigate back one page" }, - ["Next"] = { name = "Next", text = "Navigate forward one page" }, - ["Run"] = { name = "Run", text = "Run the current script" }, -} +L.TOOLTIPS = {} +L.TOOLTIPS["New"] = { name = "New", text = "Create a new script page" } +L.TOOLTIPS["Open"] = { name = "Open", text = "Open an existing script page" } +L.TOOLTIPS["Save"] = { name = "Save", text = "Save the current page\n\nHint: You can shift-click this button to rename a page" } +L.TOOLTIPS["Undo"] = { name = "Undo", text = "Revert to the last saved version" } +L.TOOLTIPS["Delete"] = { name = "Delete", text = "Delete the current page" } +L.TOOLTIPS["Lock"] = { name = "Lock", text = "This page is unlocked to allow changes. Click to lock." } +L.TOOLTIPS["Unlock"] = { name = "Unlock", text = "This page is locked to prevent changes. Click to unlock." } +L.TOOLTIPS["Previous"] = { name = "Previous", text = "Navigate back one page" } +L.TOOLTIPS["Next"] = { name = "Next", text = "Navigate forward one page" } +L.TOOLTIPS["Run"] = { name = "Run", text = "Run the current script" } +L.TOOLTIPS["Close"] = { name = "Close" } L.OPEN_MENU_TITLE = "Select a Script" L.SAVE_AS_TEXT = "Save %s with the following name:" diff --git a/WowLua.lua b/WowLua.lua index e76337b..306c678 100644 --- a/WowLua.lua +++ b/WowLua.lua @@ -270,6 +270,8 @@ function WowLua:Button_OnClick(button) WowLua:Button_Next(button) elseif operation == "Run" then WowLua:Button_Run(button) + elseif operation == "Close" then + WowLua:Button_Close(button) end end @@ -517,7 +519,6 @@ function WowLua.lockedTextChanged(box) end function WowLua:Button_Run() - self:Button_Save() local text = WowLuaFrameEditBox:GetText() -- Run the script, if there is an error then highlight it @@ -546,6 +547,17 @@ function WowLua:Button_Run() end end +function WowLua:Button_Close() + if self:IsModified() then + -- Display the unsaved changes dialog + local dialog = StaticPopup_Show("WOWLUA_UNSAVED") + dialog.data = "Button_Close" + return + end + + HideUIPanel(WowLuaFrame) +end + function WowLua:IsModified() local page,entry = self:GetCurrentPage() local orig = entry.content diff --git a/WowLua.xml b/WowLua.xml index b80c3a1..c046e2d 100644 --- a/WowLua.xml +++ b/WowLua.xml @@ -159,12 +159,23 @@ -