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 @@
<Script file="BlizzChatIntegration.lua" />
<Script file="TotalRP3.lua" />
<Frame name="MainFrame" parent="UIParent" toplevel="true" movable="true" enableMouse="true">
- <Size x="145" y="76" />
+ <Size x="183" y="76" />
<Anchors>
- <Anchor point="CENTER" x="-28" y="29" />
+ <Anchor point="CENTER" x="-9" y="29" />
</Anchors>
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
<BackgroundInsets>
@@ -21,22 +21,66 @@
<Layers>
<Layer level="OVERLAY">
<FontString inherits="GameFontNormal" text="RP Chat Bubbles">
- <Size x="112" y="20" />
+ <Size x="103" y="20" />
<Anchors>
- <Anchor point="TOPLEFT" x="18" y="-14" />
+ <Anchor point="TOPLEFT" x="25" y="-14" />
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
- <Button inherits="UIPanelButtonTemplate" text="Create">
+ <Button name="CreateButton" inherits="UIPanelButtonTemplate" text="Create">
+ <Size x="152" y="23" />
+ <Anchors>
+ <Anchor point="TOPLEFT" x="15" y="-35" />
+ </Anchors>
<Scripts>
- <onClick function="RPChatBubbles_createChatBubble" />
+ <OnClick function="RPChatBubbles_createChatBubble">
+
+ </OnClick>
</Scripts>
- <Size x="115" y="23" />
+ </Button>
+ <Button name="HideButton" inherits="UIPanelButtonTemplate" text="">
+ <Size x="20" y="20" />
<Anchors>
- <Anchor point="TOPLEFT" x="15" y="-35" />
+ <Anchor point="TOPLEFT" x="149" y="-14" />
</Anchors>
+ <Layers>
+ <Layer>
+ <Texture name="HideButtonTexture" file="interface\Addons\RoleplayChatBubbles\button\UI-hideButton.blp">
+ <Size x="12" y="12" />
+ <Anchors>
+ <Anchor point="CENTER" />
+ </Anchors>
+ </Texture>
+ </Layer>
+ </Layers>
+ <Scripts>
+ <OnClick function="RPChatBubbles_toggleVisibility">
+
+ </OnClick>
+ </Scripts>
+ </Button>
+ <Button name="SettingsButton" inherits="UIPanelButtonTemplate" text="">
+ <Size x="20" y="20" />
+ <Anchors>
+ <Anchor point="TOPLEFT" x="127" y="-14" />
+ </Anchors>
+ <Layers>
+ <Layer>
+ <Texture setAllPoints="true" file="interface\Buttons\UI-OptionsButton">
+ <Size x="12" y="12" />
+ <Anchors>
+ <Anchor point="CENTER" />
+ </Anchors>
+ </Texture>
+ </Layer>
+ </Layers>
+ <Scripts>
+ <OnClick function="RPChatBubbles_showSettingsPanel">
+
+ </OnClick>
+ </Scripts>
</Button>
</Frames>
<Scripts>
diff --git a/RoleplayChatBubbles.toc b/RoleplayChatBubbles.toc
index 6d40004..e3fad26 100644
--- a/RoleplayChatBubbles.toc
+++ b/RoleplayChatBubbles.toc
@@ -3,6 +3,8 @@
## Author: Christopher Tse
## Interface: 80300
## OptionalDeps: totalRP3
+## SavedVariablesPerCharacter: settings
+Settings.xml
ChatBubblePool.lua
MainFrame.xml
diff --git a/TotalRP3.lua b/TotalRP3.lua
index 186e4dd..0217c60 100644
--- a/TotalRP3.lua
+++ b/TotalRP3.lua
@@ -6,54 +6,63 @@ local _, Import = ...;
local ellyb, loc, Color, ColorManager;
local NPC_TALK_PATTERNS;
+local settings;
local function makeBubbleForNPCChat(_, event, message, ...)
if event == "CHAT_MSG_EMOTE" then
+ local senderGUID = select(11, ...);
+ local playerGUID = UnitGUID("player");
local npcName = TRP3_API.chat.getNPCMessageName()
+ if senderGUID == playerGUID or settings.generateTotalRP3BubblesForOtherPlayers then
if npcName then
- for talkType, talkChannel in pairs(NPC_TALK_PATTERNS) do
- if message:find(talkType) then
- local color;
- local myMessage = message;
- local normalColor = ColorManager.getChatColorForChannel(talkChannel);
- local normalColorAsString = normalColor:GetColorCodeStartSequence();
- local nameColor;
-
- --Detect colour alterations
- if myMessage:sub(1,2) == "|c" then
- color = myMessage:sub(1,10); --Save this to prepend back later
- myMessage = myMessage:sub(11);
- end
-
- --If the name is in the default color scheme, remove it for titling emphasis
- if npcName:sub(1,10) ~= normalColorAsString then
- nameColor = Color.static.CreateFromHexa(npcName:sub(1,10));
- end
- npcName = npcName:sub(11);
-
- local len = talkType:len();
- --Remove the "says:" from the beginning of the message.
- if myMessage:sub(1, len) == talkType then
- local actualMessage = myMessage:sub(len+1);
-
- --Remove leading spaces if any
- if actualMessage:sub(1,1) == " " then
- actualMessage = actualMessage:sub(2);
- end
-
- actualMessage = color .. actualMessage;
- local chatBubble = RPChatBubbles_createChatBubble()
- chatBubble:SetName(npcName);
- chatBubble:SetMessage(actualMessage);
- if nameColor then
- chatBubble:SetNameColor(nameColor:GetRGBA())
+ for talkType, talkChannel in pairs(NPC_TALK_PATTERNS) do
+ if message:find(talkType) then
+ local color;
+ local myMessage = message;
+ local normalColor = ColorManager.getChatColorForChannel(talkChannel);
+ local normalColorAsString = normalColor:GetColorCodeStartSequence();
+ local nameColor;
+
+ --Detect colour alterations. We need to remove it temporarily to remove the start.
+ if myMessage:sub(1,2) == "|c" then
+ color = myMessage:sub(1,10); --Save this to prepend back later
+ myMessage = myMessage:sub(11);
end
- end
- break;
- end
- end
- end
+
+ --If the name is not in the default color scheme, save it to be set later
+ --Otherwise, we'll highlight it with ChatBubble's default name colour.
+ if npcName:sub(1,10) ~= normalColorAsString and npcName:sub(-2) == "|r" then
+ nameColor = Color.static.CreateFromHexa(npcName:sub(1,10));
+ else
+ --Strip out the |c and |r tags so they don't get in the way of SetName()
+ npcName = npcName:sub(11);
+ npcName = npcName:sub(1,-3);
+ end
+ local len = talkType:len();
+ --Remove the "says:" from the beginning of the message.
+ if myMessage:sub(1, len) == talkType then
+ local actualMessage = myMessage:sub(len+1);
+
+ --Remove leading spaces if any
+ if actualMessage:sub(1,1) == " " then
+ actualMessage = actualMessage:sub(2);
+ end
+
+ actualMessage = color .. actualMessage;
+ local chatBubble = RPChatBubbles_createChatBubble()
+ print(string.gsub(npcName,"|","||"));
+ chatBubble:SetName(npcName);
+ chatBubble:SetMessage(actualMessage);
+ if nameColor then
+ chatBubble:SetNameColor(nameColor:GetRGBA())
+ end
+ end
+ break;
+ end
+ end
+ end
+ end
end
return false, message, ...
end
@@ -70,14 +79,17 @@ function initTRP3Vars(self)
};
end
-function TotalRP3_onStart(self)
+function TotalRP3_onStart()
+ settings = Import.settings;
if TRP3_API then
initTRP3Vars();
for _, channel in pairs(POSSIBLE_CHANNELS) do
ChatFrame_RemoveMessageEventFilter(channel, makeBubbleForNPCChat);
- ChatFrame_AddMessageEventFilter(channel, makeBubbleForNPCChat);
+ if settings.generateTotalRP3Bubbles then
+ ChatFrame_AddMessageEventFilter(channel, makeBubbleForNPCChat);
+ end
end
- --Don't re-order BCI's chat handler. It's important for BCI's handler to go first before
+ --Don't re-queue BCI's chat handler. It's important for BCI's handler to go first before
-- TotalRP3 as TotalRP3's modifications to the chat message (e.g. colouring)
-- are not propagated to the chat bubble, and BlizzChatIntegration.lua relies on
-- using the message as a common key between the chat message and chat bubble
diff --git a/button/UI-HideButton.blp b/button/UI-HideButton.blp
new file mode 100644
index 0000000..4dc142d
Binary files /dev/null and b/button/UI-HideButton.blp differ
diff --git a/button/UI-HideButton.png b/button/UI-HideButton.png
new file mode 100644
index 0000000..1fb7aa7
Binary files /dev/null and b/button/UI-HideButton.png differ
diff --git a/button/UI-ShowButton.blp b/button/UI-ShowButton.blp
new file mode 100644
index 0000000..39cadd6
Binary files /dev/null and b/button/UI-ShowButton.blp differ
diff --git a/button/UI-ShowButton.png b/button/UI-ShowButton.png
new file mode 100644
index 0000000..02a99a6
Binary files /dev/null and b/button/UI-ShowButton.png differ