diff --git a/BlizzChatIntegration.lua b/BlizzChatIntegration.lua
index af1b211..75108a2 100644
--- a/BlizzChatIntegration.lua
+++ b/BlizzChatIntegration.lua
@@ -182,7 +182,7 @@ end
local function onStart(self)
settings = Import.settings;
- if settings.dressBlizzBubbles then
+ if settings.get("DRESS_BLIZZ_BUBBLE") then
for _, channel in pairs(MANAGED_CHANNELS) do
ChatFrame_AddMessageEventFilter(channel, onChatMessage);
end
diff --git a/ChatBubblePool.lua b/ChatBubblePool.lua
index 77c85d3..c2f5224 100644
--- a/ChatBubblePool.lua
+++ b/ChatBubblePool.lua
@@ -240,7 +240,7 @@ function ChatBubblePool.getChatBubble()
newChatBubble:SetWidth(300)
newChatBubble:SetHeight(300)
newChatBubble:SetMovable(true)
- newChatBubble:SetFrameStrata("LOW")
+ newChatBubble:SetFrameStrata("LOW");
newChatBubble.isAvailable = false
table.insert(pool, newChatBubble);
@@ -324,8 +324,8 @@ function ChatBubblePool.getChatBubble()
nameBox:SetScript("OnTabPressed",function(self) editBox:SetFocus() end);
nameBox:SetScript("OnEscapePressed",clearFocusAndSelection);
nameBox:SetAlpha(0);
- nameBox:SetScript("OnEditFocusGained", function(self) self:SetAlpha(1) end);
- nameBox:SetScript("OnEditFocusLost", function(self) if self:GetText() == "" then self:SetAlpha(0.01) end end);
+ nameBox:SetScript("OnEditFocusGained", function(self) self:SetAlpha(1); nameBox:SetPropagateKeyboardInput(false); end);
+ nameBox:SetScript("OnEditFocusLost", function(self) if self:GetText() == "" then self:SetAlpha(0.01); end; nameBox:SetPropagateKeyboardInput(true); end);
--nameBox:SetScript("OnClick", function(self) nameBox:SetFocus() end);
nameBox:SetScript("OnEnter", function(self) if nameBox:GetText() == "" and not nameBox:HasFocus() then nameBox:SetAlpha(0.5) end end);
nameBox:SetScript("OnLeave", function(self) if nameBox:GetText() == "" and not nameBox:HasFocus() then nameBox:SetAlpha(0) end end);
diff --git a/MainFrame.lua b/MainFrame.lua
index e781820..35248d8 100644
--- a/MainFrame.lua
+++ b/MainFrame.lua
@@ -3,64 +3,157 @@
local ADDON_NAME, Import = ...;
-local ChatBubblePool = Import.ChatBubblePool
+local ChatBubblePool = Import.ChatBubblePool;
local settings;
+local smartTargetColoringActive = false;
+local savedColor;
+local savedRGB;
+
+Import.SharedFunctions = {};
+
function RPChatBubbles_OnLoad(self, event,...)
self:SetClampedToScreen(true);
self:RegisterEvent("ADDON_LOADED");
+ self:RegisterEvent("MODIFIER_STATE_CHANGED");
+ self:RegisterEvent("PLAYER_TARGET_CHANGED");
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();
- end);
- self:SetScript("OnDragStop", function(self)
- self:StopMovingOrSizing();
- end);
+ sharedFunctions = Import.SharedFunctions;
+ initMainFrame(self);
for moduleName, moduleStructure in pairs(Import.modules) do
moduleStructure:OnStart();
end
- SetVisibility(self, settings.isFrameVisible);
initColorDropdown();
+ elseif event == "MODIFIER_STATE_CHANGED" then
+ handleKeyPress();
+ elseif event == "PLAYER_TARGET_CHANGED" then
+ checkSmartTargetColoring();
end
end
function RPChatBubbles_createChatBubble()
local bubble = ChatBubblePool.getChatBubble();
- local textColor = settings.textColor;
- local selectedColor = settings.selectedColor;
+ local textColor = settings.get("SELECTED_COLOR_RGB");
+ local selectedColor = settings.get("SELECTED_COLOR");
+ local GetUnitNameAndColor = Import.SharedFunctions.GetUnitNameAndColor;
+
+
+ local unitID = nil;
+
+ if IsShiftKeyDown() then
+ unitID = "player";
+ elseif IsControlKeyDown() then
+ unitID = "target";
+ end
+
bubble:SetTextColor(textColor.r,textColor.g,textColor.b);
+
+ --If we are trying to populate the name field using shift or control, then enter this block.
+ --The method used will depend on whether TotalRP3 is installed or not
+ if unitID then
+ name, color = GetUnitNameAndColor(unitID);
+ if name then
+ bubble:SetName(name);
+ -- The Color will only be populated if TotalRP3 is enabled.
+ -- The variable type is the Ellyb Color() class.
+ if color then
+ bubble:SetNameColor(color:GetRGB());
+ end
+ end
+ end
end
function RPChatBubbles_toggleVisibility()
- if settings.isFrameVisible then
- settings.isFrameVisible = false;
+ if settings.get("IS_FRAME_VISIBLE") then
+ settings.set("IS_FRAME_VISIBLE", false);
else
- settings.isFrameVisible = true
+ settings.set("IS_FRAME_VISIBLE", true);
end
- SetVisibility(MainFrame, settings.isFrameVisible);
+ SetVisibility(MainFrame, settings.get("IS_FRAME_VISIBLE"));
end
function RPChatBubbles_showSettingsPanel(self, event, ...)
Import.ShowSettingsPanel();
end
+function Import.SharedFunctions.GetUnitNameAndColor(unitID)
+ return UnitName(unitID), nil;
+end
+
+----------------------------------------------------------
+
+function initMainFrame(self)
+ self:RegisterForDrag("LeftButton");
+ self:SetScript("OnDragStart", function(self)
+ self:StartMoving();
+ end);
+ self:SetScript("OnDragStop", function(self)
+ self:StopMovingOrSizing();
+ end);
+ SetVisibility(self, settings.get("IS_FRAME_VISIBLE"));
+end
+
+function handleKeyPress()
+ if settings.get("CREATE_BUTTON_EXTRA_TEXT") then
+ if IsShiftKeyDown() then
+ CreateButton:SetText("Create (Self)");
+ elseif IsControlKeyDown() then
+ CreateButton:SetText("Create (Target)");
+ else
+ CreateButton:SetText("Create");
+ end
+ end
+ checkSmartTargetColoring();
+end
+
+function checkSmartTargetColoring()
+ if not settings.get("SMART_COLORING") then
+ return
+ end
+ if IsControlKeyDown() and SayColorSelected() then
+ if not smartTargetColoringActive then
+ smartTargetColoringActive = true;
+ savedColor = settings.get("SELECTED_COLOR");
+ savedRGB = settings.get("SELECTED_COLOR_RGB");
+ end
+
+ if UnitExists("target") then
+ if UnitIsPlayer("target") then
+ selectColor(nil,"Say",ChatTypeInfo["SAY"],nil);
+ else
+ selectColor(nil,"Say (NPC)",ChatTypeInfo["MONSTER_SAY"],nil);
+ end
+ else
+ selectColor(nil,savedColor,savedRGB,nil);
+ end
+ elseif smartTargetColoringActive and not IsControlKeyDown() then
+ smartTargetColoringActive = false;
+ selectColor(nil,savedColor,savedRGB,nil);
+ end
+end
+
+function SayColorSelected()
+ selectedColor = settings.get("SELECTED_COLOR");
+ return selectedColor == "Say" or selectedColor == "Say (NPC)";
+end
+
function initColorDropdown()
local dropdown = ColorDropdownButton;
UIDropDownMenu_SetWidth(dropdown, 28);
UIDropDownMenu_Initialize(dropdown, function(self, menu, level)
addMenuItem("Say",ChatTypeInfo["SAY"]);
addMenuItem("Say (NPC)",ChatTypeInfo["MONSTER_SAY"]);
+ addMenuItem("Emote",ChatTypeInfo["EMOTE"]);
addMenuItem("Yell",ChatTypeInfo["YELL"]);
addMenuItem("Whisper",ChatTypeInfo["WHISPER"]);
addMenuItem("Custom",nil,true);
end)
- local rgb = settings.textColor;
+ local rgb = settings.get("SELECTED_COLOR_RGB");
if rgb then
ColorSwatchTex:SetColorTexture(rgb.r,rgb.g,rgb.b);
end
@@ -71,7 +164,7 @@ function addMenuItem(text, color, custom)
info.text, info.arg1, info.arg2 = text, text, color;
if custom then
info.hasColorSwatch = true;
- local rgb = settings.customColor;
+ local rgb = settings.get("CUSTOM_COLOR");
info.r, info.g, info.b = rgb.r, rgb.g, rgb.b;
info.swatchFunc = setCustomColor;
info.cancelFunc = cancelCustomColor;
@@ -80,7 +173,7 @@ function addMenuItem(text, color, custom)
info.colorCode = "|cFF" .. rgbToHex(color);
info.func = selectColor
end
- if settings.selectedColor == text then
+ if settings.get("SELECTED_COLOR") == text then
info.checked = true;
end
UIDropDownMenu_AddButton(info);
@@ -91,14 +184,14 @@ function rgbToHex(color)
end
function selectColor(self,channelColor,rgb,checked)
- settings.selectedColor = channelColor;
- settings.textColor = rgb;
+ settings.set("SELECTED_COLOR", channelColor);
+ settings.set("SELECTED_COLOR_RGB", rgb);
ColorSwatchTex:SetColorTexture(rgb.r,rgb.g,rgb.b);
end
function startCustomColorPicking(self)
- previousSelection = settings.selectedColor;
- previousColor = settings.textColor;
+ previousSelection = settings.get("SELECTED_COLOR");
+ previousColor = settings.get("SELECTED_COLOR_RGB");
UIDropDownMenuButton_OpenColorPicker(self);
end
@@ -110,12 +203,12 @@ function setCustomColor(previousSelection)
rgb.r, rgb.g, rgb.b = ColorPickerFrame:GetColorRGB()
end
selectColor(nil,"Custom",rgb);
- settings.customColor = rgb;
+ settings.set("CUSTOM_COLOR", rgb);
end
function cancelCustomColor()
- settings.selectedColor = previousSelection;
- settings.textColor = previousColor;
+ settings.set("SELECTED_COLOR", previousSelection);
+ settings.set("SELECTED_COLOR_RGB", previousColor);
end
function SetVisibility(self, visible)
diff --git a/Settings.lua b/Settings.lua
index 036d1bc..ac12893 100644
--- a/Settings.lua
+++ b/Settings.lua
@@ -3,25 +3,38 @@
local ADDON_NAME, Import = ...;
+defaultValue = {
+ IS_FRAME_VISIBLE = true,
+ DRESS_BLIZZ_BUBBLE = true,
+ SMART_COLORING = true,
+ CREATE_BUTTON_EXTRA_TEXT = true,
+
+ SELECTED_COLOR_RGB = { r = 1.0, g = 1.0, b = 1.0 },
+ SELECTED_COLOR = "Say",
+ CUSTOM_COLOR = { r = 1.0, g = 1.0, b = 1.0 },
+
+ GENERATE_TOTAL_RP3_BUBBLES = true,
+ GENERATE_TOTAL_RP3_BUBBLES_FOR_OTHER_PLAYERS = true
+}
+
function initSettings()
if settings == nil then
settings = {}
- settings.isFrameVisible = true;
- settings.dressBlizzBubbles = true;
- settings.generateTotalRP3Bubbles = true;
- settings.generateTotalRP3BubblesForOtherPlayers = true;
end
- if settings.selectedColor == nil then
- c = {};
- c.r, c.g, c.b = 1.0, 1.0, 1.0
- settings.textColor = c;
- settings.selectedColor = "Say"
- settings.customColor = c;
+ settings.get = function(key)
+ if settings[key] == nil then
+ settings[key] = defaultValue[key];
+ end
+ return settings[key];
+ end
+ settings.set = function(key, value)
+ settings[key] = value;
end
Import.settings = settings;
end
function ConfigureFrameOnRuntime(self, event, ...)
+ --Check if TRP3 is installed and turn off the TRP3 options if it's not there.
if TRP3_API == nil then
totalRP3Header:SetFontObject("GameFontDisableLarge");
totalRP3GenerateOptionLabel:SetFontObject("GameFontDisable");
@@ -39,9 +52,12 @@ function ShowSettingsPanel()
if not SettingsPanel:IsVisible() then
SettingsPanel:Show()
- DressBlizzBubbleCheck:SetChecked(settings.dressBlizzBubbles);
- totalRP3GenerateCheck:SetChecked(settings.generateTotalRP3Bubbles);
- totalRP3GenerateOtherCheck:SetChecked(settings.generateTotalRP3BubblesForOtherPlayers);
+ DressBlizzBubbleCheck:SetChecked(settings.get("DRESS_BLIZZ_BUBBLE"));
+ ExtraTextCheck:SetChecked(settings.get("CREATE_BUTTON_EXTRA_TEXT"));
+ SmartColoringCheck:SetChecked(settings.get("SMART_COLORING"));
+ totalRP3GenerateCheck:SetChecked(settings.get("GENERATE_TOTAL_RP3_BUBBLES"));
+ totalRP3GenerateOtherCheck:SetChecked(settings.get("GENERATE_TOTAL_RP3_BUBBLES_FOR_OTHER_PLAYERS"));
+
TotalRP3_onStart();
else
CancelSettings();
@@ -49,7 +65,8 @@ function ShowSettingsPanel()
end
function ToggleReloadWarning(self, event, ...)
- if settings.dressBlizzBubbles ~= DressBlizzBubbleCheck:GetChecked() then
+ --This function detects if the user has changed the Dress Blizz Bubble setting, which will show a reload required message on changed.
+ if settings.DRESS_BLIZZ_BUBBLE ~= DressBlizzBubbleCheck:GetChecked() then
if not UIReloadWarningLabel:IsVisible() then
UIReloadWarningLabel:Show();
SettingsPanel:SetSize(SettingsPanel:GetWidth(),SettingsPanel:GetHeight()+UIReloadWarningLabel:GetHeight()+5);
@@ -63,12 +80,14 @@ function ToggleReloadWarning(self, event, ...)
end
function SaveSettings(self, event, ...)
- local reloadRequired = settings.dressBlizzBubbles ~= DressBlizzBubbleCheck:GetChecked()
+ local reloadRequired = settings.DRESS_BLIZZ_BUBBLE ~= DressBlizzBubbleCheck:GetChecked()
- settings.dressBlizzBubbles = DressBlizzBubbleCheck:GetChecked();
- settings.generateTotalRP3Bubbles = totalRP3GenerateCheck:GetChecked();
- settings.generateTotalRP3BubblesForOtherPlayers = totalRP3GenerateOtherCheck:GetChecked();
-
+ settings.DRESS_BLIZZ_BUBBLE = DressBlizzBubbleCheck:GetChecked();
+ settings.GENERATE_TOTAL_RP3_BUBBLES = totalRP3GenerateCheck:GetChecked();
+ settings.GENERATE_TOTAL_RP3_BUBBLES_FOR_OTHER_PLAYERS = totalRP3GenerateOtherCheck:GetChecked();
+ settings.SMART_COLORING = SmartColoringCheck:GetChecked();
+ settings.CREATE_BUTTON_EXTRA_TEXT = ExtraTextCheck:GetChecked();
+
SettingsPanel:Hide();
if reloadRequired then
ReloadUI()
diff --git a/Settings.xml b/Settings.xml
index 41aa1e9..de4ab98 100644
--- a/Settings.xml
+++ b/Settings.xml
@@ -2,10 +2,10 @@
<Script file="Settings.lua" />
<Frame name="SettingsPanel" hidden="true" parent="UIParent" toplevel="true" movable="true" enableMouse="true">
<Size>
- <AbsDimension x="503" y="222" />
+ <AbsDimension x="546" y="270" />
</Size>
<Anchors>
- <Anchor point="CENTER" />
+ <Anchor point="CENTER" x="22" y="-24" />
</Anchors>
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
<BackgroundInsets>
@@ -41,19 +41,19 @@
<FontString name="totalRP3Header" inherits="GameFontNormalLarge" text="TotalRP3" justifyH="LEFT">
<Size x="80" y="20" />
<Anchors>
- <Anchor point="TOPLEFT" x="25" y="-99" />
+ <Anchor point="TOPLEFT" x="25" y="-145" />
</Anchors>
</FontString>
<FontString name="totalRP3GenerateOptionLabel" inherits="GameFontHighlight" text="Generate chat bubbles for NPC Speeches?" justifyH="LEFT">
<Size x="419" y="20" />
<Anchors>
- <Anchor point="TOPLEFT" x="25" y="-126" />
+ <Anchor point="TOPLEFT" x="25" y="-172" />
</Anchors>
</FontString>
<FontString name="totalRP3GenerateOtherPlayerLabel" inherits="GameFontHighlight" text="Generate chat bubbles for NPC Speeches by other players?" justifyH="LEFT">
<Size x="436" y="20" />
<Anchors>
- <Anchor point="TOPLEFT" x="25" y="-153" />
+ <Anchor point="TOPLEFT" x="25" y="-194" />
</Anchors>
</FontString>
<FontString name="NotInstalledLabel" inherits="GameFontRed" hidden="true" text="(Not Installed)" justifyH="LEFT">
@@ -66,30 +66,32 @@
<FontString name="UIReloadWarningLabel" inherits="GameFontRed" hidden="true" text="UI Reload Required." justifyH="LEFT">
<Size x="299" y="20" />
<Anchors>
- <Anchor point="TOPLEFT" x="25" y="-178" />
+ <Anchor point="TOPLEFT" x="25" y="-224" />
+ </Anchors>
+ </FontString>
+ <FontString name="ExtraTextLabel" inherits="GameFontHighlightLeft" text="Add "Target/Self" to the create button's text when holding ctrl/shift">
+ <Size x="462" y="20" />
+ <Anchors>
+ <Anchor point="TOPLEFT" x="25" y="-94" />
+ </Anchors>
+ </FontString>
+ <FontString name="SmartColoringLabel" inherits="GameFontHighlightLeft" text="Automatically switch between player and npc colours for Create (Target)">
+ <Size x="462" y="20" />
+ <Anchors>
+ <Anchor point="TOPLEFT" x="25" y="-118" />
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
- <CheckButton name="DressBlizzBubbleCheck" inherits="UICheckButtonTemplate" text="CheckButton1">
- <Anchors>
- <Anchor point="TOPLEFT" x="450" y="-62" />
- </Anchors>
- <Scripts>
- <OnClick function="ToggleReloadWarning">
-
- </OnClick>
- </Scripts>
- </CheckButton>
<CheckButton name="totalRP3GenerateCheck" inherits="UICheckButtonTemplate" text="CheckButton1">
<Anchors>
- <Anchor point="TOPLEFT" x="450" y="-118" />
+ <Anchor point="TOPLEFT" x="493" y="-164" />
</Anchors>
</CheckButton>
<CheckButton name="totalRP3GenerateOtherCheck" inherits="UICheckButtonTemplate" text="CheckButton2">
<Anchors>
- <Anchor point="TOPLEFT" x="450" y="-145" />
+ <Anchor point="TOPLEFT" x="493" y="-188" />
</Anchors>
</CheckButton>
<Button name="OkayButton" inherits="UIPanelButtonTemplate" text="Okay">
@@ -114,6 +116,26 @@
</OnClick>
</Scripts>
</Button>
+ <CheckButton name="SmartColoringCheck" inherits="UICheckButtonTemplate" text="CheckButton1">
+ <Anchors>
+ <Anchor point="TOPLEFT" x="493" y="-113" />
+ </Anchors>
+ </CheckButton>
+ <CheckButton name="DressBlizzBubbleCheck" inherits="UICheckButtonTemplate" text="CheckButton1">
+ <Anchors>
+ <Anchor point="TOPLEFT" x="493" y="-65" />
+ </Anchors>
+ <Scripts>
+ <OnClick function="ToggleReloadWarning">
+
+ </OnClick>
+ </Scripts>
+ </CheckButton>
+ <CheckButton name="ExtraTextCheck" inherits="UICheckButtonTemplate" text="CheckButton1">
+ <Anchors>
+ <Anchor point="TOPLEFT" x="493" y="-89" />
+ </Anchors>
+ </CheckButton>
</Frames>
<Scripts>
<OnLoad function="ConfigureFrameOnRuntime">
diff --git a/TotalRP3.lua b/TotalRP3.lua
index 5636b94..b15e413 100644
--- a/TotalRP3.lua
+++ b/TotalRP3.lua
@@ -14,8 +14,8 @@ local function makeBubbleForNPCChat(_, event, message, ...)
local senderGUID = select(11, ...);
local playerGUID = UnitGUID("player");
local npcName = TRP3_API.chat.getNPCMessageName()
- if senderGUID == playerGUID or settings.generateTotalRP3BubblesForOtherPlayers then
- if npcName then
+ if senderGUID == playerGUID or settings.get("GENERATE_TOTAL_RP3_BUBBLES_FOR_OTHER_PLAYERS") then
+ if npcName then
for talkType, talkChannel in pairs(NPC_TALK_PATTERNS) do
if message:find(talkType) then
local color;
@@ -73,6 +73,7 @@ function initTRP3Vars(self)
loc = TRP3_API.loc;
Color = ellyb.Color;
ColorManager = ellyb.ColorManager;
+
NPC_TALK_PATTERNS = {
[loc.NPC_TALK_SAY_PATTERN] = "MONSTER_SAY",
[loc.NPC_TALK_YELL_PATTERN] = "MONSTER_YELL",
@@ -84,9 +85,10 @@ function TotalRP3_onStart()
settings = Import.settings;
if TRP3_API then
initTRP3Vars();
+ Import.SharedFunctions.GetUnitNameAndColor = GetNameAndColorFromTotalRP3;
for _, channel in pairs(POSSIBLE_CHANNELS) do
ChatFrame_RemoveMessageEventFilter(channel, makeBubbleForNPCChat);
- if settings.generateTotalRP3Bubbles then
+ if settings.get("GENERATE_TOTAL_RP3_BUBBLES") then
ChatFrame_AddMessageEventFilter(channel, makeBubbleForNPCChat);
end
end
@@ -99,6 +101,118 @@ function TotalRP3_onStart()
end
end
+function GetNameAndColorFromTotalRP3(unitId)
+ if unitId == "player" then
+ trp3Name, color = getPlayerTRP3NameAndColor();
+ elseif unitId == "target" then
+ trp3Name, color = getTargetTRP3NameAndColor();
+ end
+ if trp3Name ~= nil then
+ return trp3Name, color;
+ end
+ --Fallback to UnitName
+ return UnitName(unitId), nil;
+end
+
+function getPlayerTRP3NameAndColor()
+ local getTRP3Data = TRP3_API.profile.getData
+ local getFullnameUsingChatMethod = TRP3_API.chat.getFullnameUsingChatMethod;
+ local playerData = getTRP3Data("player");
+ local trp3Name = getFullnameUsingChatMethod(playerData);
+ local unitId = "player";
+ local nameColor = getPlayerNameColor(trp3Name);
+ return trp3Name, nameColor;
+end
+
+function getPlayerNameColor()
+ local GetClassColorByGUID = TRP3_API.utils.color.GetClassColorByGUID;
+ local configShowNameCustomColors = TRP3_API.chat.configShowNameCustomColors;
+ local guid = UnitGUID("player");
+ local player = AddOn_TotalRP3.Player.static.CreateFromGUID(guid)
+
+ if GetCVar("chatClassColorOverride") ~= "1" then
+ characterColor = GetClassColorByGUID(guid);
+ end
+
+ if configShowNameCustomColors() then
+ characterColor = player:GetCustomColorForDisplay() or characterColor;
+ end
+
+ return characterColor;
+end
+
+
+function getTargetTRP3NameAndColor()
+ local getUnitID = TRP3_API.utils.str.getUnitID;
+ local companionIDToInfo = TRP3_API.utils.str.companionIDToInfo;
+ local unitIDToInfo = TRP3_API.utils.str.unitIDToInfo;
+ local configShowNameCustomColors = TRP3_API.chat.configShowNameCustomColors;
+
+ local targetID = getTargetId("target");
+ if targetID == nil then
+ return nil;
+ end
+ local owner, companionID = companionIDToInfo(targetID);
+ local profile = getCompanionInfo(owner, companionID, targetID);
+
+ if profile and profile.data then
+ local targetName = profile.data.NA or companionID;
+ local customColor = nil;
+ if configShowNameCustomColors() then
+ customColor = getTargetsNameColor(profile);
+ end
+ return targetName, customColor;
+ end
+ return nil;
+end
+
+--Straight port of TRP3's target_frame.lua:getCompanionInfo()
+function getCompanionInfo(owner, companionID, currentTargetId)
+ local profile;
+ local Globals = TRP3_API.globals;
+ local getCompanionProfile = TRP3_API.companions.player.getCompanionProfile;
+ local getCompanionRegisterProfile = TRP3_API.companions.register.getCompanionProfile;
+ if owner == Globals.player_id then
+ profile = getCompanionProfile(companionID) or EMPTY;
+ else
+ profile = getCompanionRegisterProfile(currentTargetId);
+ end
+ return profile;
+end
+
+function getTargetsNameColor(profile)
+ local Color = TRP3_API.Ellyb.Color;
+ local customColor = profile.data.NH;
+
+ if customColor then
+ customColor = Color(profile.data.NH);
+
+ if AddOn_TotalRP3.Configuration.shouldDisplayIncreasedColorContrast() then
+ customColor:LightenColorUntilItIsReadableOnDarkBackgrounds();
+ end
+ end
+ return customColor;
+end
+
+--Basically a straight port of target_frame.lua's onTargetChanged()
+function getTargetId()
+ local getTargetType, getCompanionFullID = TRP3_API.ui.misc.getTargetType, TRP3_API.ui.misc.getCompanionFullID;
+ local TYPE_CHARACTER = TRP3_API.ui.misc.TYPE_CHARACTER;
+ local TYPE_PET = TRP3_API.ui.misc.TYPE_PET;
+ local TYPE_BATTLE_PET = TRP3_API.ui.misc.TYPE_BATTLE_PET;
+ local TYPE_NPC = TRP3_API.ui.misc.TYPE_NPC;
+
+ currentTargetType = getTargetType("target");
+ if currentTargetType == TYPE_CHARACTER then
+ return getUnitID("target");
+ elseif currentTargetType == TYPE_NPC then
+ return TRP3_API.utils.str.getUnitNPCID("target");
+ end
+
+ return getCompanionFullID("target", currentTargetType);
+end
+
+
--Import.modules["TotalRP3"] = {
-- name="TotalRP3",
-- onStart = TotalRP3_onStart;