WoWInterface SVN ColoredTooltips

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

ColoredTooltips/ColoredTooltips.xml New file
0,0 → 1,187
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="localization.lua"/>
<Script file="ColoredTooltips.lua"/>
<Frame name="ColoredTooltips">
<Scripts>
<OnLoad function="ColoredTooltips_OnLoad"/>
<OnEvent function="ColoredTooltips_OnEvent"/>
</Scripts>
</Frame>
 
<CheckButton name="ColoredTooltipsCheckTemplate" inherits="OptionsCheckButtonTemplate" virtual="true">
<HitRectInsets>
<AbsInset left="0" right="-100" top="0" bottom="0"/>
</HitRectInsets>
<Scripts>
<OnClick>
if ( self:GetChecked() ) then
PlaySound("igMainMenuOptionCheckBoxOff");
else
PlaySound("igMainMenuOptionCheckBoxOn");
end
ColoredTooltips_OptionsCheckButtonOnClick(self);
</OnClick>
<OnEnter>
if ( self.tooltipText ) then
GameTooltip:SetOwner(self, "ANCHOR_LEFT");
GameTooltip:SetBackdropColor(0.0, 0.0, 0.0);
GameTooltip:SetText(self.tooltipText, 1.0, 1.0, 1.0);
end
</OnEnter>
<OnLeave>
GameTooltip:Hide();
</OnLeave>
</Scripts>
</CheckButton>
 
<Frame name="ColoredTooltipsOptions" toplevel="true" frameStrata="MEDIUM" movable="true" enableMouse="true" hidden="true" parent="UIParent">
<Size>
<AbsDimension x="300" y="370" />
</Size>
<Anchors>
<Anchor point="CENTER" />
</Anchors>
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border"
tile="true">
<BackgroundInsets>
<AbsInset left="11" right="12" top="12" bottom="11" />
<Size>
<AbsDimension x="128" y="17" />
</Size>
</BackgroundInsets>
<TileSize>
<AbsValue val="32" />
</TileSize>
<EdgeSize>
<AbsValue val="32" />
</EdgeSize>
</Backdrop>
<Layers>
<Layer level="ARTWORK">
<Texture name="ColoredTooltipsTitle" file="Interface\DialogFrame\UI-DialogBox-Header">
<Size>
<AbsDimension x="400" y="64" />
</Size>
<Anchors>
<Anchor point="TOP">
<Offset>
<AbsDimension x="0" y="12" />
</Offset>
</Anchor>
</Anchors>
</Texture>
<FontString inherits="GameFontNormal" text="Colored Tooltips Options">
<Anchors>
<Anchor point="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="0" y="-3" />
</Offset>
</Anchor>
</Anchors>
</FontString>
 
</Layer>
</Layers>
<Frames>
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton1" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-50" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton2" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-90" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton3" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-130" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton4" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-170" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton5" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-210" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton6" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-250" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<CheckButton name="ColoredTooltipsOptionsFrame_CheckButton7" inherits="ColoredTooltipsCheckTemplate">
<Anchors>
<Anchor point="LEFT" relativePoint="TOP" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="-120" y="-290" />
</Offset>
</Anchor>
</Anchors>
</CheckButton>
 
<Button name="ColoredTooltipsOptionsSave" inherits="OptionsButtonTemplate" text="COLORTOOL_CLOSE_BUTTON">
<Anchors>
<Anchor point="CENTER" relativePoint="BOTTOM" relativeTo="ColoredTooltipsOptions">
<Offset>
<AbsDimension x="0" y="30" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
HideUIPanel(ColoredTooltipsOptions);
</OnClick>
</Scripts>
</Button>
 
</Frames>
<Scripts>
<OnLoad>
ColoredTooltipsOptions_OnLoad();
</OnLoad>
<OnShow>
ColoredTooltipsOptions_OnShow();
PlaySound("igCharacterInfoOpen");
</OnShow>
<OnHide>
ColoredTooltipsOptions_OnHide(self);
PlaySound("igCharacterInfoClose");
</OnHide>
</Scripts>
</Frame>
</Ui>
Property changes : Added: svn:executable +
ColoredTooltips/ColoredTooltips.lua New file
0,0 → 1,267
--[[
Colored Tooltips by Kharthus
Simple tooltip addon to set background colors based on targeted unit
 
v1.2
- Updated VARIABLES_LOADED to ADDON_LOADED
v1.1
- Fixed double <guild> tags
- Added global enable/disable setting
v1.0
- Initial Release
]]
 
-- Global Variables
ColoredTooltips_Config = {};
 
local default_config = {
["ENABLE"] = 1,
["COLOR"] = 1,
["GUILD"] = 1,
["PARTY"] = 1,
["GUILDLABEL"] = 1,
["PLAYERLABEL"] = 1,
["PVPLABEL"] = 1,
};
 
function ColoredTooltips_OnLoad(self)
self:RegisterEvent("UPDATE_MOUSEOVER_UNIT");
self:RegisterEvent("ADDON_LOADED");
 
ColoredTooltips_Config = {};
 
GameTooltip:HookScript("OnTooltipSetUnit", ColoredTooltips_SetBackground);
 
tinsert(UISpecialFrames,"ColoredTooltipsOptions");
 
-- Set slash command
SlashCmdList["COLOREDTOOLTIPS"] = function (msg)
ColoredTooltips_Command(msg);
end
SLASH_COLOREDTOOLTIPS1 = "/coloredtooltips";
SLASH_COLOREDTOOLTIPS2 = "/colortool";
end
 
function ColoredTooltips_Command(msg)
ColoredTooltipsOptions:Show();
end
 
function ColoredTooltips_OnEvent(self,event,...)
local arg1 = ...;
if (event == "UPDATE_MOUSEOVER_UNIT") then
ColoredTooltips_SetBackground()
elseif (event == "ADDON_LOADED" and arg1 == "ColoredTooltips") then
if( not ColoredTooltips_Config ) then
ColoredTooltips_Config = {};
end
for k in pairs(default_config) do
if (ColoredTooltips_Config[k] == nil) then
ColoredTooltips_Config[k] = default_config[k];
end
end
end
end
 
function ColoredTooltips_SetBackground()
local __, unit = GameTooltip:GetUnit();
 
if(UnitExists(unit) and ColoredTooltips_Config["ENABLE"] == 1) then
local r, g, b = GameTooltip_UnitColor(unit);
local changed = false;
GameTooltipTextLeft1:SetTextColor(1,1,1);
if (ColoredTooltips_Config["COLOR"] == 1) then
-- Set tooltip bg to blue for players
if(r == 1 and g == 1 and b == 1) then
r = 0;
g = 0;
end
changed = true;
end
if (ColoredTooltips_Config["GUILD"] == 1) then
-- set tooltip bg to a diffrent color for guild members
local playerGuild = GetGuildInfo("Player");
-- if the player is in a guild, and the 'type' is in the same guild
if (playerGuild and playerGuild ~= "" and GetGuildInfo(unit) == playerGuild) then
r = 0.4;
g = 1.0;
b = 1.0;
changed = true;
end
end
 
if (ColoredTooltips_Config["PARTY"] == 1) then
-- set tooltip bg to a diffrent color for party members
if (UnitInParty(unit) ) then
r = 0.8;
g = 0.4;
b = 1.0;
changed = true;
end
end
 
if (changed) then
GameTooltip:SetBackdropColor(r, g, b);
end
 
if (ColoredTooltips_Config["GUILDLABEL"] == 1) then
local guild = GetGuildInfo(unit);
if (guild) then
if (GameTooltipTextLeft2:GetText() == guild and GameTooltipTextLeft2:IsVisible()) then
GameTooltipTextLeft2:Hide();
GameTooltip:AddLine(string.format("<%s>", guild));
end
end
end
 
if (ColoredTooltips_Config["PLAYERLABEL"] == 1) then
local originalText = GameTooltipTextLeft2:GetText();
if (originalText ~= nil) then
local newText = string.gsub(originalText, " [(]Player[)]", "");
GameTooltipTextLeft2:SetText(newText);
end
local originalText = GameTooltipTextLeft3:GetText();
if (originalText ~= nil) then
local newText = string.gsub(originalText, " [(]Player[)]", "");
GameTooltipTextLeft3:SetText(newText);
end
end
 
if (ColoredTooltips_Config["PVPLABEL"] == 1) then
for i = 3, 5 do
local tooltipTextLeft = _G["GameTooltipTextLeft"..i];
local originalText = tooltipTextLeft:GetText();
if (originalText ~= nil) then
local newText = string.gsub(originalText, "PvP", "");
if (newText == "") then
tooltipTextLeft:SetText(nil);
tooltipTextLeft:Hide();
-- removes the right line too, which should provide alignment.
local tooltipTextRight = _G["GameTooltipTextRight"..i];
if ( tooltipTextRight ) then
tooltipTextRight:SetText(nil);
tooltipTextRight:Hide();
end
end
end
end
end
 
ColoredTooltips_MouseOverFixSize();
end
end
 
-- fix the size and remove blank lines
-- note that blank lines can still be created by setting the string to ""
function ColoredTooltips_MouseOverFixSize()
local tooltipName = "GameTooltip";
local lastValid = 0;
for i = 1, 20 do
local checkLeftText = _G[tooltipName.."TextLeft"..i];
local checkRightText = _G[tooltipName.."TextRight"..i];
local width = ColoredTooltips_GetTooltipLineWidth(checkLeftText, checkRightText);
if (width) then
lastValid = lastValid + 1;
if (lastValid ~= i) then
local moveLeftText = _G[tooltipName.."TextLeft"..lastValid];
local moveRightText = _G[tooltipName.."TextRight"..lastValid];
if (moveLeftText ~= nil and checkLeftText ~= nil) then
moveLeftText:SetText(checkLeftText:GetText());
moveLeftText:SetTextColor(checkLeftText:GetTextColor());
if (checkLeftText:IsVisible()) then
moveLeftText:Show();
end
checkLeftText:SetText("");
checkLeftText:Hide();
end
if (moveRightText ~= nil and checkRightText~=nil) then
moveRightText:SetText(checkRightText:GetText());
moveRightText:SetTextColor(checkRightText:GetTextColor());
if (checkRightText:IsVisible()) then
moveRightText:Show();
end
checkRightText:SetText("");
checkRightText:Hide();
end
end
end
end
 
GameTooltip:Show();
end
 
function ColoredTooltips_GetTooltipLineWidth(leftText, rightText)
if ((not leftText or not leftText:IsVisible()) and (not rightText or not rightText:IsVisible())) then
return;
end;
local result = 0;
if (leftText and leftText:IsVisible()) then
result = result + leftText:GetWidth() + 24;
end
if (rightText and rightText:IsVisible()) then
result = result + rightText:GetWidth() + 24;
end
if (leftText and leftText:IsVisible() and rightText and rightText:IsVisible()) then
result = result + 10;
end;
 
return result;
end
 
function ColoredTooltipsOptions_OnShow()
ColoredTooltipsOptionsFrameEventFrames = { };
ColoredTooltipsOptionsFrameEventFrames [1] = { text = COLORTOOL_CHECK_TEXT1, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT1, ColoredTooltipsVar = "ENABLE"};
ColoredTooltipsOptionsFrameEventFrames [2] = { text = COLORTOOL_CHECK_TEXT2, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT2, ColoredTooltipsVar = "COLOR"};
ColoredTooltipsOptionsFrameEventFrames [3] = { text = COLORTOOL_CHECK_TEXT3, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT3, ColoredTooltipsVar = "GUILD"};
ColoredTooltipsOptionsFrameEventFrames [4] = { text = COLORTOOL_CHECK_TEXT4, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT4, ColoredTooltipsVar = "PARTY"};
ColoredTooltipsOptionsFrameEventFrames [5] = { text = COLORTOOL_CHECK_TEXT5, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT5, ColoredTooltipsVar = "GUILDLABEL"};
ColoredTooltipsOptionsFrameEventFrames [6] = { text = COLORTOOL_CHECK_TEXT6, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT6, ColoredTooltipsVar = "PLAYERLABEL"};
ColoredTooltipsOptionsFrameEventFrames [7] = { text = COLORTOOL_CHECK_TEXT7, tooltipText = COLORTOOL_CHECK_TOOLTIPTEXT7, ColoredTooltipsVar = "PVPLABEL"};
 
local button, string, checked;
 
for key, value in pairs(ColoredTooltipsOptionsFrameEventFrames) do
local string = getglobal("ColoredTooltipsOptionsFrame_CheckButton"..key.."Text");
local button = getglobal("ColoredTooltipsOptionsFrame_CheckButton"..key);
 
if ( value.ColoredTooltipsVar ) then
if ( ColoredTooltips_Config[value.ColoredTooltipsVar] == 1 ) then
checked = 1;
else
checked = 0;
end
else
checked = 0;
end
button:SetChecked(checked);
string:SetText(value.text);
button.tooltipText = value.tooltipText;
end
 
end
 
function ColoredTooltips_OptionsCheckButtonOnClick(self)
local button;
 
--loop thru checkbox array to find current one, then update its value
for key, value in pairs(ColoredTooltipsOptionsFrameEventFrames) do
if (self:GetName() == "ColoredTooltipsOptionsFrame_CheckButton"..key) then
button = getglobal("ColoredTooltipsOptionsFrame_CheckButton"..key);
if ( button:GetChecked() ) then
value.value = 1;
else
value.value = 0;
end
if ( ColoredTooltips_Config[value.ColoredTooltipsVar] ) then
ColoredTooltips_Config[value.ColoredTooltipsVar] = value.value;
end
end
end
end
 
function ColoredTooltipsOptions_OnLoad()
UIPanelWindows["ColoredTooltipsOptions"] = {area = "center", pushable = 0};
end
 
function ColoredTooltipsOptions_OnHide(self)
 
end
Property changes : Added: svn:executable +
ColoredTooltips/localization.lua New file
0,0 → 1,15
COLORTOOL_CHECK_TEXT1 = "Enable colored tooltips";
COLORTOOL_CHECK_TEXT2 = "Color player tooltips";
COLORTOOL_CHECK_TEXT3 = "Color guild member tooltips";
COLORTOOL_CHECK_TEXT4 = "Color party member tooltips";
COLORTOOL_CHECK_TEXT5 = "Reformat guild tag";
COLORTOOL_CHECK_TEXT6 = "Remove (Player) tag";
COLORTOOL_CHECK_TEXT7 = "Remove PvP tag";
COLORTOOL_CHECK_TOOLTIPTEXT1 = "Enable or Disable colored tooltips addon";
COLORTOOL_CHECK_TOOLTIPTEXT2 = "Enable or Disable colored player tooltips";
COLORTOOL_CHECK_TOOLTIPTEXT3 = "Enable or Disable colored guild member tooltips";
COLORTOOL_CHECK_TOOLTIPTEXT4 = "Enable or Disable colored party member tooltips";
COLORTOOL_CHECK_TOOLTIPTEXT5 = "Enable or Disable reformatted guild tag";
COLORTOOL_CHECK_TOOLTIPTEXT6 = "Enable or Disable removing (Player) tag";
COLORTOOL_CHECK_TOOLTIPTEXT7 = "Enable or Disable removing PvP tag";
COLORTOOL_CLOSE_BUTTON = "Close";
Property changes : Added: svn:executable +
ColoredTooltips/ColoredTooltips.toc New file
0,0 → 1,7
## Interface: 40000
## Title: Colored Tooltips
## Notes: Sets tooltip background colors based on targeted unit
## Version: 1.2
## Author: Kharthus
## SavedVariables: ColoredTooltips_Config
ColoredTooltips.xml
Property changes : Added: svn:executable +