From 458bc52f3ce0e32207ab4245d4764fd974c0d8af Mon Sep 17 00:00:00 2001 From: Christopher Tse Date: Mon, 15 Jun 2020 20:18:03 +1000 Subject: [PATCH] Added a settings button and a hide button and added a few settings --- BlizzChatIntegration.lua | 9 ++++- MainFrame.lua | 63 ++++++++++++++++++++++++++--- MainFrame.xml | 60 ++++++++++++++++++++++++---- RoleplayChatBubbles.toc | 2 + TotalRP3.lua | 100 ++++++++++++++++++++++++++-------------------- button/UI-HideButton.blp | Bin 0 -> 1556 bytes button/UI-HideButton.png | Bin 0 -> 2963 bytes button/UI-ShowButton.blp | Bin 0 -> 1556 bytes button/UI-ShowButton.png | Bin 0 -> 3054 bytes 9 files changed, 175 insertions(+), 59 deletions(-) create mode 100644 button/UI-HideButton.blp create mode 100644 button/UI-HideButton.png create mode 100644 button/UI-ShowButton.blp create mode 100644 button/UI-ShowButton.png diff --git a/BlizzChatIntegration.lua b/BlizzChatIntegration.lua index 154e76e..af1b211 100644 --- a/BlizzChatIntegration.lua +++ b/BlizzChatIntegration.lua @@ -3,6 +3,8 @@ local ADDON_NAME, Import = ... +local settings; + --This is an invisible frame that is created to receive OnUpdate calls --Attached to the WorldFrame so it receives events even when the UI is hidden local Timer = CreateFrame("Frame","RPChatBubble-Timer",WorldFrame) @@ -179,8 +181,11 @@ end --end local function onStart(self) - for _, channel in pairs(MANAGED_CHANNELS) do - ChatFrame_AddMessageEventFilter(channel, onChatMessage); + settings = Import.settings; + if settings.dressBlizzBubbles then + for _, channel in pairs(MANAGED_CHANNELS) do + ChatFrame_AddMessageEventFilter(channel, onChatMessage); + end end end diff --git a/MainFrame.lua b/MainFrame.lua index 68547f9..b856f32 100644 --- a/MainFrame.lua +++ b/MainFrame.lua @@ -3,12 +3,8 @@ local ADDON_NAME, Import = ...; -local mainFrame; local ChatBubblePool = Import.ChatBubblePool - -function RPChatBubbles_createChatBubble() - return ChatBubblePool.getChatBubble() -end +local settings; function RPChatBubbles_OnLoad(self, event,...) self:SetClampedToScreen(true); @@ -17,6 +13,8 @@ end function RPChatBubbles_OnEvent(self, event, ...) if event == "ADDON_LOADED" and ... == ADDON_NAME then + Import:initSettings(); + settings = Import.settings; self:RegisterForDrag("LeftButton"); self:SetScript("OnDragStart", function(self) self:StartMoving(); @@ -27,7 +25,62 @@ function RPChatBubbles_OnEvent(self, event, ...) for moduleName, moduleStructure in pairs(Import.modules) do moduleStructure:OnStart(); end + SetVisibility(self, settings.isFrameVisible); end end +function RPChatBubbles_createChatBubble() + return ChatBubblePool.getChatBubble() +end + +function RPChatBubbles_toggleVisibility() + if settings.isFrameVisible then + settings.isFrameVisible = false; + else + settings.isFrameVisible = true + end + SetVisibility(MainFrame, settings.isFrameVisible); +end + +function RPChatBubbles_showSettingsPanel(self, event, ...) + Import.ShowSettingsPanel(); +end + +function SetVisibility(self, visible) + if visible then + self:SetAlpha(1.0); + removeVisibilityScripts(MainFrame); + removeVisibilityScripts(CreateButton); + removeVisibilityScripts(SettingsButton); + removeVisibilityScripts(HideButton); + HideButtonTexture:SetTexture("Interface/Addons/RoleplayChatBubbles/button/UI-hideButton"); + else + self:SetAlpha(0.5); + addVisibilityScripts(MainFrame); + addVisibilityScripts(CreateButton); + addVisibilityScripts(SettingsButton); + addVisibilityScripts(HideButton); + HideButtonTexture:SetTexture("Interface/Addons/RoleplayChatBubbles/button/UI-showButton"); + end +end + +function removeVisibilityScripts(frame) + frame:SetScript("OnEnter",nil); + frame:SetScript("OnLeave",nil); +end + +function addVisibilityScripts(frame) + frame:SetScript("OnEnter",ShowRPCMainFrame); + frame:SetScript("OnLeave",HideRPCMainFrame); +end + + +function ShowRPCMainFrame(self, event, ...) + MainFrame:SetAlpha(0.5); +end + +function HideRPCMainFrame(self, event, ...) + MainFrame:SetAlpha(0); +end + Import.modules = {}; \ No newline at end of file diff --git a/MainFrame.xml b/MainFrame.xml index 45e7653..62dc5cb 100644 --- a/MainFrame.xml +++ b/MainFrame.xml @@ -3,9 +3,9 @@