diff --git a/localization.de.lua b/localization.de.lua deleted file mode 100755 index 537a9d2..0000000 --- a/localization.de.lua +++ /dev/null @@ -1,46 +0,0 @@ --------------------------------------------------------------------------------------------------- --- Localized messages and options in German --------------------------------------------------------------------------------------------------- - -if ( GetLocale() == "deDE" ) then - ---Slash Commands -MYREP_CMD_STATUS = "status"; -MYREP_CMD_DEBUG = "debug"; - ---Messages -MYREP_MSG_ON = "An"; -MYREP_MSG_OFF = "Aus"; -MYREP_MSG_MORE = "Zusatzinfos"; -MYREP_MSG_BLIZZ = "Blizzard-Meldungen"; -MYREP_MSG_SPLASH = "Splash-Meldung"; -MYREP_MSG_PERCENT = "Prozent"; -MYREP_MSG_FRAME = "Chatfenster"; -MYREP_MSG_TPL = "Ansicht"; -MYREP_MSG_DEBUG = "Debug"; - -MYREP_INFO = "Standard-Anzeige"; -MYREP_TOOLTIP = "Tooltip-Anzeige"; - -MYREP_INFO_TEXT = "Stufe"; -MYREP_INFO_PERCENT = "Prozent"; -MYREP_INFO_ABSOLUTE = "Absolut"; -MYREP_INFO_DIFFERENCE = "Session"; - -MYREP_MSG_NOTIFY = "Reputations-Meldungen erscheinen nun in diesem Chatfenster."; -MYREP_MSG_INVALID_FRAME = MYREP_MSG_FRAME.." ist ung\195\188ltig. G\195\188ltige Werte: 1-%d."; - ---Tooltips -MYREP_TOOLTIP_ENABLED = "Aktiviert/deaktiviert myReputation."; -MYREP_TOOLTIP_SPLASH = "Aktiviert/deaktiviert die Splash-Meldung bei Stufenwechsel."; -MYREP_TOOLTIP_BLIZZ = "Aktiviert/deaktiviert Blizzards Reputationsmeldungen."; -MYREP_TOOLTIP_MORE = "Aktiviert/deaktiviert zus\195\164tzliche Chatmeldungen."; - ---Notifications -MYREP_NOTIFICATION_GAINED = "Euer Ruf bei %s ist um %d (%d/%d) gestiegen."; -MYREP_NOTIFICATION_LOST = "Euer Ruf bei %s ist um %d (%d/%d) gesunken."; -MYREP_NOTIFICATION_NEEDED = "Noch %d Ruf (%d Wiederholungen) f\195\188r %s ben\195\182tigt."; -MYREP_NOTIFICATION_LEFT = "Noch %d Ruf (%d Wiederholungen) \195\188brig bevor %s erreicht wird."; -MYREP_NOTIFICATION_REACHED = "%s bei %s erreicht."; - -end \ No newline at end of file diff --git a/localization.lua b/localization.lua deleted file mode 100755 index 8f86cf0..0000000 --- a/localization.lua +++ /dev/null @@ -1,42 +0,0 @@ --------------------------------------------------------------------------------------------------- --- Localized messages and options in English --------------------------------------------------------------------------------------------------- - ---Slash Commands -MYREP_CMD_STATUS = "status"; -MYREP_CMD_DEBUG = "debug"; - ---Messages -MYREP_MSG_ON = "On"; -MYREP_MSG_OFF = "Off"; -MYREP_MSG_MORE = "Additional infos"; -MYREP_MSG_BLIZZ = "Blizzard messages"; -MYREP_MSG_SPLASH = "Splash screen"; -MYREP_MSG_PERCENT = "Percent"; -MYREP_MSG_FRAME = "Chatframe"; -MYREP_MSG_TPL = "Template"; -MYREP_MSG_DEBUG = "Debug"; - -MYREP_INFO = "Standard View"; -MYREP_TOOLTIP = "Tooltip View"; - -MYREP_INFO_TEXT = "Rank"; -MYREP_INFO_PERCENT = "Percent"; -MYREP_INFO_ABSOLUTE = "Absolute"; -MYREP_INFO_DIFFERENCE = "Session"; - -MYREP_MSG_NOTIFY = "Reputation notification now set to this frame."; -MYREP_MSG_INVALID_FRAME = MYREP_MSG_FRAME.." is invalid. Valid values: 1-%d."; - ---Tooltips -MYREP_TOOLTIP_ENABLED = "Enables/disables myReputation."; -MYREP_TOOLTIP_SPLASH = "Toggles the splash screen on reaching next standing."; -MYREP_TOOLTIP_BLIZZ = "Toggles blizzards reputation messages."; -MYREP_TOOLTIP_MORE = "Toggles additional chat messages."; - ---Notifications -MYREP_NOTIFICATION_GAINED = "Your reputation with %s has increased by %d (%d/%d)."; -MYREP_NOTIFICATION_LOST = "Your reputation with %s has decreased by %d (%d/%d)."; -MYREP_NOTIFICATION_NEEDED = "%d reputation (%d repetitions) needed until %s."; -MYREP_NOTIFICATION_LEFT = "%d reputation (%d repetitions) left until %s."; -MYREP_NOTIFICATION_REACHED = "%s reputation reached with %s."; \ No newline at end of file diff --git a/myReputationClassic.lua b/myReputationClassic.lua deleted file mode 100755 index 4279dba..0000000 --- a/myReputationClassic.lua +++ /dev/null @@ -1,635 +0,0 @@ ----------------------------------------------------------------------- --- Variables ----------------------------------------------------------------------- - --- Basic Addon Variables -MYREP_NAME = "myReputationClassic"; -MYREP_VERSION = GetAddOnMetadata("myReputation", "Version") or "N/A"; -MYREP_VERSION_STRING = "|cffffd700myReputation Classic "..GREEN_FONT_COLOR_CODE..MYREP_VERSION.."|cffffd700 by |cffff8c00HonorGoG"; -MYREP_MSG_FORMAT = "%s |cffffff00%s|r"; -MYREP_REGEXP_CHANGED = string.gsub( FACTION_STANDING_CHANGED, "'?%%[1|2]$s'?", "%(.+)" ); -MYREP_REGEXP_DECREASED = string.gsub( FACTION_STANDING_DECREASED, "'?%%[s|d]'?", "%(.+)" ); -MYREP_REGEXP_DECREASED_GENERIC = string.gsub( FACTION_STANDING_DECREASED_GENERIC, "'?%%[s|d]'?", "%(.+)" ); -MYREP_REGEXP_INCREASED = string.gsub( FACTION_STANDING_INCREASED, "'?%%[s|d]'?", "%(.+)" ); -MYREP_REGEXP_INCREASED_GENERIC = string.gsub( FACTION_STANDING_INCREASED_GENERIC, "'?%%[s|d]'?", "%(.+)" ); - --- Configuration Variables and their Standard Values -myReputation_Config = { }; -myReputation_DefaultConfig = { }; -myReputation_DefaultConfig.Enabled = true; -myReputation_DefaultConfig.More = true; -myReputation_DefaultConfig.Blizz = false; -myReputation_DefaultConfig.Splash = true; -myReputation_DefaultConfig.Debug = false; -myReputation_DefaultConfig.Frame = 1; -myReputation_DefaultConfig.Info = 'Text'; -myReputation_DefaultConfig.Tooltip = 'Absolute'; - --- Temp Variables and Arrays -myReputations = { }; -mySessionReputations = { }; -myReputation_Var = { }; -myReputation_Var.InWorld = false; - --- Function Hooks -local lOriginal_ReputationFrame_Update; -local lOriginal_ReputationBar_OnClick; -local lOriginal_CFAddMessage_General; -local lOriginal_CFAddMessage_Combat; - -local _G = getfenv(0); - ----------------------------------------------------------------------- --- OnFoo ----------------------------------------------------------------------- - -function myReputation_OnLoad(this) - --Slash command - SlashCmdList["MYREPCOMMAND"] = myReputation_SlashHandler; - SLASH_MYREPCOMMAND1 = "/myreputation"; - SLASH_MYREPCOMMAND2 = "/myrep"; - - -- Register Default Events - this:RegisterEvent("ADDON_LOADED"); - this:RegisterEvent("PLAYER_LOGIN"); - this:RegisterEvent("PLAYER_ENTERING_WORLD"); - this:RegisterEvent("UNIT_AURA"); - this:RegisterEvent("PLAYER_TARGET_CHANGED"); - this:RegisterEvent("PLAYER_LEAVING_WORLD"); - - if (DEFAULT_CHAT_FRAME) then - myReputation_ChatMsg(MYREP_VERSION); - end -end - -function myReputation_OnEvent(this, event, arg1) - if (event == "ADDON_LOADED") then - myReputation_AddOptionMt(myReputation_Config, myReputation_DefaultConfig); - - -- Delete Unused Config Values - for i,v in pairs(myReputation_Config) do - if (myReputation_DefaultConfig[i] == nil) then - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('Clean Up Config '..i); - end - myReputation_Config[i] = nil; - end - end - end - - -- Fired just before PLAYER_ENTERING_WORLD on login and UI Reload - if (event == "PLAYER_LOGIN") then - if ( - (myReputation_Config.Frame > 0) and - (myReputation_Config.Frame <= FCF_GetNumActiveChatFrames()) - ) then - REPUTATIONS_CHAT_FRAME = _G["ChatFrame"..myReputation_Config.Frame]; - else - REPUTATIONS_CHAT_FRAME = DEFAULT_CHAT_FRAME; - end - myReputation_Toggle(myReputation_Config.Enabled,true); - end - - -- Register Ingame Events - if (event == "PLAYER_ENTERING_WORLD") then - this:RegisterEvent("UPDATE_FACTION"); - end - - -- Unregister Ingame Events - if (event == "PLAYER_LEAVING_WORLD") then - this:UnregisterEvent("UPDATE_FACTION"); - end - - -- Event UPDATE_FACTION - if ( - (event == "UPDATE_FACTION") and - (myReputation_Config.Enabled == true) - ) then - myReputation_Factions_Update(); - end - - -- Events which are usable to get numFactions > 0 - if ((event == "UNIT_AURA") or (event == "PLAYER_TARGET_CHANGED")) then - -- Save Session StartRep - if (not mySessionReputations["Darnassus"]) then - - local numFactions = GetNumFactions(); - local factionIndex; - local name, standingID, barMin, barMax, barValue, isHeader, hasRep; - - for factionIndex=1, numFactions, 1 do - name, _, standingID, barMin, barMax, barValue, _, _, isHeader, _, hasRep = GetFactionInfo(factionIndex); - - if (not isHeader or hasRep) then - barMax = barMax - barMin; - barValue = barValue - barMin; - barMin = 0; - mySessionReputations[name] = { }; - mySessionReputations[name].standingID = standingID; - mySessionReputations[name].barValue = barValue; - mySessionReputations[name].barMax = barMax; - - end - end - end - - this:UnregisterEvent("UNIT_AURA"); - this:UnregisterEvent("PLAYER_TARGET_CHANGED"); - end -end - ----------------------------------------------------------------------- --- Metatable Functions ----------------------------------------------------------------------- - -function myReputation_AddOptionMt(options, defaults) - setmetatable(options, { __index = defaults }); -end - ----------------------------------------------------------------------- --- Other Functions ----------------------------------------------------------------------- - --- Send Message to Chat Frame -function myReputation_ChatMsg(message) - DEFAULT_CHAT_FRAME:AddMessage(message); -end - --- Send Message to Reputation Chat Frame -function myReputation_RepMsg(message,r,g,b) - REPUTATIONS_CHAT_FRAME:AddMessage(message,r,g,b); -end - --- Send Message to Splash Frame -function myReputation_SplashMessage(message,r,g,b) - myReputation_SplashFrame:AddMessage(message, r,g,b, 1.0, UIERRORS_HOLD_TIME); -end - --- SlashHandler -function myReputation_SlashHandler(msg) - if (msg == MYREP_CMD_STATUS) then - myReputation_DisplayStatus(); - elseif (msg == MYREP_CMD_DEBUG) then - myReputation_Toggle_Options("Debug"); - else - InterfaceOptionsFrame_OpenToCategory(MYREP_NAME); - end; -end - -function myReputation_DisplayStatus() - if (myReputation_Config.Enabled == true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_ON)); - else - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_OFF)); - end - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_DEBUG,MYREP_MSG_ON)); - end - if (myReputation_Config.Blizz == true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_BLIZZ,MYREP_MSG_ON)); - else - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_BLIZZ,MYREP_MSG_OFF)); - end - if (myReputation_Config.More == true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_MORE,MYREP_MSG_ON)); - else - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_MORE,MYREP_MSG_OFF)); - end - if (myReputation_Config.Splash == true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_SPLASH,MYREP_MSG_ON)); - else - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_SPLASH,MYREP_MSG_OFF)); - end - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_FRAME,myReputation_Config.Frame)); - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,'Info',myReputation_Config.Info)); - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,'Tooltip',myReputation_Config.Tooltip)); -end - --- Toggles -function myReputation_Toggle(toggle,init) - myReputation_Config.Enabled = toggle; - - if (toggle == true) then - --Hook - if (not lOriginal_ReputationFrame_Update) then - if (init ~= true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_ON,".")); - end - lOriginal_ReputationFrame_Update = ReputationFrame_Update; - ReputationFrame_Update = myReputation_Frame_Update_New; - end - if (not lOriginal_ReputationBar_OnClick) then - lOriginal_ReputationBar_OnClick = ReputationBar_OnClick; - ReputationBar_OnClick = myReputation_ReputationBar_OnClick; - end - if (not lOriginal_CFAddMessage_General) then - lOriginal_CFAddMessage_General = _G["ChatFrame1"].AddMessage; - _G["ChatFrame1"].AddMessage = myReputation_CFAddMessage_Allgemein; - end - if (not lOriginal_CFAddMessage_Combat) then - lOriginal_CFAddMessage_Combat = _G["ChatFrame2"].AddMessage; - _G["ChatFrame2"].AddMessage = myReputation_CFAddMessage_Kampflog; - end - - if (ReputationDetailFrame:GetScript("OnShow") == nil) then - ReputationDetailFrame:HookScript("OnShow", function(self, event) - if (myReputation_Config.Enabled) then - myReputation_ReputationDetailFrame:Show(); - end - end) - end - if (ReputationDetailFrame:GetScript("OnHide") == nil) then - ReputationDetailFrame:HookScript("OnHide", function(self, event) - myReputation_ReputationDetailFrame:Hide(); - end) - end - else - --Unhook - if (lOriginal_ReputationFrame_Update) then - if (init ~= true) then - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_OFF,".")); - end - ReputationFrame_Update = lOriginal_ReputationFrame_Update; - lOriginal_ReputationFrame_Update = nil; - end - if (lOriginal_CFAddMessage_General) then - _G["ChatFrame1"].AddMessage = lOriginal_CFAddMessage_General; - lOriginal_CFAddMessage_General = nil; - end - if (lOriginal_CFAddMessage_Combat) then - _G["ChatFrame2"].AddMessage = lOriginal_CFAddMessage_Combat; - lOriginal_CFAddMessage_Combat = nil; - end - end -end - -function myReputation_Toggle_Options(option) - if (myReputation_Config[option] == true) then - myReputation_Config[option] = false; - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,_G["MYREP_MSG_"..string.upper(option)],MYREP_MSG_OFF,".")); - else - myReputation_Config[option] = true; - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,_G["MYREP_MSG_"..string.upper(option)],MYREP_MSG_ON,".")); - end -end - -function myReputation_ChatFrame_Change(checked,value) --Checked will always be 0 - local number = tonumber(value); - if ( - (value ~= nil) and - (number > 0) and - (number ~= 2) and - (number <= FCF_GetNumActiveChatFrames()) - ) then - myReputation_Config.Frame = number; - myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_FRAME,myReputation_Config.Frame,".")); - REPUTATIONS_CHAT_FRAME = _G["ChatFrame"..myReputation_Config.Frame]; - myReputation_RepMsg(MYREP_MSG_NOTIFY,1.0,1.0,0.0); - else - myReputation_ChatMsg(format(MYREP_MSG_INVALID_FRAME,FCF_GetNumActiveChatFrames())); - end -end - --- Hooked Functions -function myReputation_CFAddMessage_Allgemein(self, msg, ...) - if ( - (myReputation_Config.Blizz == false) and - (msg ~= nil) and - ( - string.find(msg, MYREP_REGEXP_CHANGED) or - string.find(msg, MYREP_REGEXP_DECREASED) or - string.find(msg, MYREP_REGEXP_DECREASED_GENERIC) or - string.find(msg, MYREP_REGEXP_INCREASED) or - string.find(msg, MYREP_REGEXP_INCREASED_GENERIC) - ) - ) then - if (myReputation_Config.Debug == true) then - myReputation_RepMsg("Blizzard Meldung in Frame 1 abgefangen"); - end - else - lOriginal_CFAddMessage_General(self, msg, ...); - end -end - -function myReputation_CFAddMessage_Kampflog(self, msg, ...) - if ( - (myReputation_Config.Blizz == false) and - (msg ~= nil) and - ( - string.find(msg, MYREP_REGEXP_CHANGED) or - string.find(msg, MYREP_REGEXP_DECREASED) or - string.find(msg, MYREP_REGEXP_DECREASED_GENERIC) or - string.find(msg, MYREP_REGEXP_INCREASED) or - string.find(msg, MYREP_REGEXP_INCREASED_GENERIC) - ) - ) then - if (myReputation_Config.Debug == true) then - myReputation_RepMsg("Blizzard Meldung in Frame 2 abgefangen"); - end - else - lOriginal_CFAddMessage_Combat(self, msg, ...); - end -end - -function myReputation_ReputationBar_OnClick(self) - lOriginal_ReputationBar_OnClick(self); - - if (myReputation_Config.Debug == true) then - myReputation_RepMsg("ReputationBar_OnClick Faction "..self.index); - end - - if (ReputationDetailFrame:IsVisible()) then - local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(self.index); - local color = FACTION_BAR_COLORS[standingID]; - - --Normalize Values - barMax = barMax - barMin; - barValue = barValue - barMin; - barMin = 0; - - local text = GetText("FACTION_STANDING_LABEL"..standingID, gender); - local absolute = barValue.."/"..barMax; - local percent = format("%.1f%%", barValue / barMax * 100); - local difference = 0; - - if (mySessionReputations[name]) then - -- No change in standing - if (mySessionReputations[name].standingID == standingID) then - difference = barValue - mySessionReputations[name].barValue; - - -- Reputation went up and reached next standing - elseif (mySessionReputations[name].standingID < standingID) then - difference = barValue + mySessionReputations[name].barMax - mySessionReputations[name].barValue; - - -- Reputation went down and reached next standing - else - difference = barMax - barValue + mySessionReputations[name].barValue; - end - end - - myReputation_ReputationDetailFrameDetails:SetTextColor(color.r, color.g, color.b); - myReputation_ReputationDetailFrameText:SetText( - format(MYREP_MSG_FORMAT, MYREP_INFO_TEXT..":", text) - ); - myReputation_ReputationDetailFrameAbsolute:SetText( - format(MYREP_MSG_FORMAT, MYREP_INFO_ABSOLUTE..":", absolute) - ); - myReputation_ReputationDetailFramePercent:SetText( - format(MYREP_MSG_FORMAT, MYREP_INFO_PERCENT..":", percent) - ); - myReputation_ReputationDetailFrameDifference:SetText( - format(MYREP_MSG_FORMAT, MYREP_INFO_DIFFERENCE..":", difference) - ); - end -end - -function myReputation_Frame_Update_New() - lOriginal_ReputationFrame_Update(); - - local info = myReputation_Explode(myReputation_Config.Info, ','); - local tooltip = myReputation_Explode(myReputation_Config.Tooltip, ','); - - local numFactions = GetNumFactions(); - local factionIndex, factionRow, factionTitle, factionStanding, factionBar, factionButton, factionLeftLine, factionBottomLine, factionBackground, color, tooltipStanding; - local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild; - local atWarIndicator, rightBarTexture; - local factionCompleteInfo, factionTooltip, difference; - - local factionOffset = FauxScrollFrame_GetOffset(ReputationListScrollFrame); - - local gender = UnitSex("player"); - local guildName = GetGuildInfo("player"); - - local i; - - for i=1, NUM_FACTIONS_DISPLAYED, 1 do - factionIndex = factionOffset + i; - factionRow = _G["ReputationBar"..i]; - factionBar = _G["ReputationBar"..i.."ReputationBar"]; - factionTitle = _G["ReputationBar"..i.."FactionName"]; - factionButton = _G["ReputationBar"..i.."ExpandOrCollapseButton"]; - factionLeftLine = _G["ReputationBar"..i.."LeftLine"]; - factionBottomLine = _G["ReputationBar"..i.."BottomLine"]; - factionStanding = _G["ReputationBar"..i.."ReputationBarFactionStanding"]; - factionBackground = _G["ReputationBar"..i.."Background"]; - - if (factionIndex <= numFactions) then - name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(factionIndex); - factionTitle:SetText(name); - - local factionStandingtext = GetText("FACTION_STANDING_LABEL"..standingID, gender); - - --Normalize Values - barMax = barMax - barMin; - barValue = barValue - barMin; - barMin = 0; - - if ( - (not isHeader or hasRep) and - (factionStanding:GetText() ~= nil) - ) then - local difference = 0; - - -- guild name was not available on login - if (mySessionReputations[name] == nil and guildName ~= nil and name == guildName) then - bakName = name; - name = GUILD_REPUTATION; - end - - if (mySessionReputations[name]) then - -- No change in standing - if (mySessionReputations[name].standingID == standingID) then - difference = barValue - mySessionReputations[name].barValue; - - -- Reputation went up and reached next standing - elseif (mySessionReputations[name].standingID < standingID) then - difference = barValue + mySessionReputations[name].barMax - mySessionReputations[name].barValue; - - -- Reputation went down and reached next standing - else - difference = barMax - barValue + mySessionReputations[name].barValue; - end - end - - local join; - - -- guild name should be displayed - if (bakName ~= nil) then - name = bakName; - end - - factionCompleteInfo = factionStandingtext; - if (type(info) == 'table') then - factionCompleteInfo = ''; - join = ''; - - for i,v in ipairs(info) do - if (v == 'Text') then - factionCompleteInfo = factionCompleteInfo..join..factionStandingtext; - end - if (v == 'Percent') then - factionCompleteInfo = factionCompleteInfo..join..format("%.1f%%", barValue / barMax * 100); - end - if (v == 'Absolute') then - factionCompleteInfo = factionCompleteInfo..join..barValue.."/"..barMax; - end - if (v == 'Difference') then - if (join ~= '') then - factionCompleteInfo = factionCompleteInfo..join..'('..difference..')'; - else - factionCompleteInfo = factionCompleteInfo..join..difference; - end - end - join = ' '; - end - end - - factionTooltip = barValue.."/"..barMax; - if (type(tooltip) == 'table') then - factionTooltip = ''; - join = ''; - - for i,v in ipairs(tooltip) do - if (v == 'Text') then - factionTooltip = factionTooltip..join..factionStandingtext; - end - if (v == 'Percent') then - factionTooltip = factionTooltip..join..format("%.1f%%", barValue / barMax * 100); - end - if (v == 'Absolute') then - factionTooltip = factionTooltip..join..barValue.."/"..barMax; - end - if (v == 'Difference') then - if (join ~= '') then - factionTooltip = factionTooltip..join..'('..difference..')'; - else - factionTooltip = factionTooltip..join..difference; - end - end - join = ' '; - end - end - - factionStanding:SetText(factionCompleteInfo); - factionRow.standingText = factionCompleteInfo; - factionRow.tooltip = HIGHLIGHT_FONT_COLOR_CODE..factionTooltip..FONT_COLOR_CODE_CLOSE; - end - end - end -end - --- Event UPDATE_FACTION -function myReputation_Factions_Update() - local numFactions = GetNumFactions(); - local factionIndex, factionStanding, factionBar, factionHeader, color; - local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild; - local barMax, barMin, barValue; - local RepRemains, RepRepeats, RepBefore, RepActual, RepNext; - - for factionIndex=1, numFactions, 1 do - name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(factionIndex); - - if (not isHeader or hasRep) then - barMax = barMax - barMin; - barValue = barValue - barMin; - barMin = 0; - - if (myReputations[name]) then - if (standingID ~= 1) then - RepBefore = _G["FACTION_STANDING_LABEL"..standingID-1]; - end - - RepActual = _G["FACTION_STANDING_LABEL"..standingID]; - - if (standingID ~= 8) then - RepNext = _G["FACTION_STANDING_LABEL"..standingID+1]; - end - - local RawTotal = 0; - - -- No change in standing - if (myReputations[name].standingID == standingID) then - local difference = barValue - myReputations[name].barValue; - - -- Reputation went up - if ((difference > 0) and (myReputations[name].standingID == standingID)) then - myReputation_RepMsg(format(MYREP_NOTIFICATION_GAINED,name,difference,barValue,barMax), 0.5, 0.5, 1.0); - if (standingID ~= 8) then - RepRemains = barMax - barValue; - RepRepeats = RepRemains / difference; - if (RepRepeats > floor(RepRepeats)) then - RepRepeats = ceil(RepRepeats); - end - if (myReputation_Config.More == true) then - myReputation_RepMsg(format(MYREP_NOTIFICATION_NEEDED,RepRemains,RepRepeats,RepNext), 1.0, 1.0, 0.0); - end - end - - -- Reputation went down - elseif ((difference < 0) and (myReputations[name].standingID == standingID)) then - difference = abs(difference); - myReputation_RepMsg(format(MYREP_NOTIFICATION_LOST,name,difference,barValue,barMax), 0.5, 0.5, 1.0); - if (standingID ~= 1) then - RepRemains = barValue; - RepRepeats = RepRemains / difference; - if (RepRepeats > floor(RepRepeats)) then - RepRepeats = ceil(RepRepeats); - end - if (myReputation_Config.More == true) then - myReputation_RepMsg(format(MYREP_NOTIFICATION_LEFT,RepRemains,RepRepeats,RepBefore), 1.0, 1.0, 0.0); - end - end - end - - -- Reputation went up and reached next standing - elseif (myReputations[name].standingID < standingID) then - RepRemains = barMax - barValue; - RawTotal = barValue + myReputations[name].barMax - myReputations[name].barValue; - myReputation_RepMsg(format(MYREP_NOTIFICATION_GAINED,name,RawTotal,barValue,barMax), 0.5, 0.5, 1.0); - myReputation_RepMsg(format(MYREP_NOTIFICATION_REACHED,RepActual,name), 1.0, 1.0, 0.0); - if (standingID ~= 8) then - RepRepeats = RepRemains / RawTotal; - if (RepRepeats > floor(RepRepeats)) then - RepRepeats = ceil(RepRepeats); - end - if (myReputation_Config.More == true) then - myReputation_RepMsg(format(MYREP_NOTIFICATION_NEEDED,RepRemains,RepRepeats,RepNext), 1.0, 1.0, 0.0); - end - end - - if (myReputation_Config.Splash == true) then - myReputation_SplashMessage(name.." - "..RepActual.."!", 1.0, 1.0, 0.0); - end - - -- Reputation went down and reached next standing - else - RepRemains = barValue; - RawTotal = barMax - barValue + myReputations[name].barValue; - myReputation_RepMsg(format(MYREP_NOTIFICATION_LOST,name,RawTotal,barValue,barMax), 0.5, 0.5, 1.0); - myReputation_RepMsg(format(MYREP_NOTIFICATION_REACHED,RepActual,name), 1.0, 1.0, 0.0); - if (standingID ~= 1) then - RepRepeats = RepRemains / RawTotal; - if (RepRepeats > floor(RepRepeats)) then - RepRepeats = ceil(RepRepeats); - end - if (myReputation_Config.More == true) then - myReputation_RepMsg(format(MYREP_NOTIFICATION_LEFT,RepRemains,RepRepeats,RepBefore), 1.0, 1.0, 0.0); - end - end - - if (myReputation_Config.Splash == true) then - myReputation_SplashMessage(name.." - "..RepActual.."!", 1.0, 1.0, 0.0); - end - end - - else - myReputations[name] = { }; - end - - myReputations[name].standingID = standingID; - myReputations[name].barValue = barValue; - myReputations[name].barMax = barMax; - myReputations[name].atWarWith = atWarWith; - end - end -end \ No newline at end of file diff --git a/myReputationClassic.toc b/myReputationClassic.toc deleted file mode 100755 index 9e622b7..0000000 --- a/myReputationClassic.toc +++ /dev/null @@ -1,15 +0,0 @@ -## Interface: 11304 -## Title: myReputation Classic |cff00aa001.0.0.11304|r -## Author: HonorGoG of the Titan Panel Development Team -## Version: 1.0.0.11304 -## SavedVariables: myReputation_Config -## Notes: Changed display of reputation window and chat messages -## X-Credits: Egris, Karmond and Larry @ Baelgun. -## X-Category: Interface Enhancements -## X-Email: honorgog@gmail.com -## X-Localizations: enUS, deDE -## X-License: All rights reserved -## X-WoWI-ID: - -myReputationClassic.xml -myReputationOptions.xml diff --git a/myReputationClassic.xml b/myReputationClassic.xml deleted file mode 100755 index 8c82539..0000000 --- a/myReputationClassic.xml +++ /dev/null @@ -1,134 +0,0 @@ -<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="localization.de.lua"/> - <Script file="myReputationClassic.lua"/> - - <Frame name="myReputation_Frame" hidden="false" parent="UIParent"> - <Scripts> - <OnLoad> - myReputation_OnLoad(self); - </OnLoad> - <OnEvent> - myReputation_OnEvent(self, event, arg1); - </OnEvent> - </Scripts> - <Frames> - <MessageFrame name="myReputation_SplashFrame" frameStrata="LOW" insertMode="TOP" parent="UIParent" toplevel="true"> - <Size> - <AbsDimension x="512" y="100"></AbsDimension> - </Size> - <Anchors> - <Anchor point="CENTER"> - <Offset> - <AbsDimension x="0" y="100"></AbsDimension> - </Offset> - </Anchor> - </Anchors> - <FontString inherits="NumberFontNormalHuge" justifyH="CENTER"></FontString> - </MessageFrame> - </Frames> - </Frame> - - <Frame name="myReputation_ReputationDetailFrame" enableMouse="true" hidden="true"> - <Size> - <AbsDimension x="172" y="143"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="ReputationFrame" relativePoint="TOPRIGHT"> - <Offset> - <AbsDimension x="0" y="-188"/> - </Offset> - </Anchor> - </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"/> - </BackgroundInsets> - <TileSize> - <AbsValue val="32"/> - </TileSize> - <EdgeSize> - <AbsValue val="32"/> - </EdgeSize> - </Backdrop> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentDetails" inherits="GameFontHighlight" justifyH="LEFT" text="MYREP_MSG_MORE"> - <Size> - <AbsDimension x="140" y="0"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT"> - <Offset> - <AbsDimension x="20" y="-21"/> - </Offset> - </Anchor> - </Anchors> - </FontString> - <FontString name="$parentText" inherits="GameFontHighlightSmall" justifyH="LEFT"> - <Size> - <AbsDimension x="140" y="0"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentDetails" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-8"/> - </Offset> - </Anchor> - </Anchors> - </FontString> - <FontString name="$parentAbsolute" inherits="GameFontHighlightSmall" justifyH="LEFT"> - <Size> - <AbsDimension x="140" y="0"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentText" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-6"/> - </Offset> - </Anchor> - </Anchors> - </FontString> - <FontString name="$parentPercent" inherits="GameFontHighlightSmall" justifyH="LEFT"> - <Size> - <AbsDimension x="140" y="0"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentAbsolute" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-6"/> - </Offset> - </Anchor> - </Anchors> - </FontString> - <FontString name="$parentDifference" inherits="GameFontHighlightSmall" justifyH="LEFT"> - <Size> - <AbsDimension x="140" y="0"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentPercent" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-6"/> - </Offset> - </Anchor> - </Anchors> - </FontString> - <Texture file="Interface\PaperDollInfoFrame\UI-Character-Reputation-DetailBackground"> - <Size> - <AbsDimension x="211" y="128"/> - </Size> - <Anchors> - <Anchor point="TOPLEFT"> - <Offset> - <AbsDimension x="11" y="-11"/> - </Offset> - </Anchor> - </Anchors> - </Texture> - </Layer> - </Layers> - </Frame> - -</Ui> \ No newline at end of file diff --git a/myReputationClassic/localization.de.lua b/myReputationClassic/localization.de.lua new file mode 100755 index 0000000..537a9d2 --- /dev/null +++ b/myReputationClassic/localization.de.lua @@ -0,0 +1,46 @@ +-------------------------------------------------------------------------------------------------- +-- Localized messages and options in German +-------------------------------------------------------------------------------------------------- + +if ( GetLocale() == "deDE" ) then + +--Slash Commands +MYREP_CMD_STATUS = "status"; +MYREP_CMD_DEBUG = "debug"; + +--Messages +MYREP_MSG_ON = "An"; +MYREP_MSG_OFF = "Aus"; +MYREP_MSG_MORE = "Zusatzinfos"; +MYREP_MSG_BLIZZ = "Blizzard-Meldungen"; +MYREP_MSG_SPLASH = "Splash-Meldung"; +MYREP_MSG_PERCENT = "Prozent"; +MYREP_MSG_FRAME = "Chatfenster"; +MYREP_MSG_TPL = "Ansicht"; +MYREP_MSG_DEBUG = "Debug"; + +MYREP_INFO = "Standard-Anzeige"; +MYREP_TOOLTIP = "Tooltip-Anzeige"; + +MYREP_INFO_TEXT = "Stufe"; +MYREP_INFO_PERCENT = "Prozent"; +MYREP_INFO_ABSOLUTE = "Absolut"; +MYREP_INFO_DIFFERENCE = "Session"; + +MYREP_MSG_NOTIFY = "Reputations-Meldungen erscheinen nun in diesem Chatfenster."; +MYREP_MSG_INVALID_FRAME = MYREP_MSG_FRAME.." ist ung\195\188ltig. G\195\188ltige Werte: 1-%d."; + +--Tooltips +MYREP_TOOLTIP_ENABLED = "Aktiviert/deaktiviert myReputation."; +MYREP_TOOLTIP_SPLASH = "Aktiviert/deaktiviert die Splash-Meldung bei Stufenwechsel."; +MYREP_TOOLTIP_BLIZZ = "Aktiviert/deaktiviert Blizzards Reputationsmeldungen."; +MYREP_TOOLTIP_MORE = "Aktiviert/deaktiviert zus\195\164tzliche Chatmeldungen."; + +--Notifications +MYREP_NOTIFICATION_GAINED = "Euer Ruf bei %s ist um %d (%d/%d) gestiegen."; +MYREP_NOTIFICATION_LOST = "Euer Ruf bei %s ist um %d (%d/%d) gesunken."; +MYREP_NOTIFICATION_NEEDED = "Noch %d Ruf (%d Wiederholungen) f\195\188r %s ben\195\182tigt."; +MYREP_NOTIFICATION_LEFT = "Noch %d Ruf (%d Wiederholungen) \195\188brig bevor %s erreicht wird."; +MYREP_NOTIFICATION_REACHED = "%s bei %s erreicht."; + +end \ No newline at end of file diff --git a/myReputationClassic/localization.lua b/myReputationClassic/localization.lua new file mode 100755 index 0000000..8f86cf0 --- /dev/null +++ b/myReputationClassic/localization.lua @@ -0,0 +1,42 @@ +-------------------------------------------------------------------------------------------------- +-- Localized messages and options in English +-------------------------------------------------------------------------------------------------- + +--Slash Commands +MYREP_CMD_STATUS = "status"; +MYREP_CMD_DEBUG = "debug"; + +--Messages +MYREP_MSG_ON = "On"; +MYREP_MSG_OFF = "Off"; +MYREP_MSG_MORE = "Additional infos"; +MYREP_MSG_BLIZZ = "Blizzard messages"; +MYREP_MSG_SPLASH = "Splash screen"; +MYREP_MSG_PERCENT = "Percent"; +MYREP_MSG_FRAME = "Chatframe"; +MYREP_MSG_TPL = "Template"; +MYREP_MSG_DEBUG = "Debug"; + +MYREP_INFO = "Standard View"; +MYREP_TOOLTIP = "Tooltip View"; + +MYREP_INFO_TEXT = "Rank"; +MYREP_INFO_PERCENT = "Percent"; +MYREP_INFO_ABSOLUTE = "Absolute"; +MYREP_INFO_DIFFERENCE = "Session"; + +MYREP_MSG_NOTIFY = "Reputation notification now set to this frame."; +MYREP_MSG_INVALID_FRAME = MYREP_MSG_FRAME.." is invalid. Valid values: 1-%d."; + +--Tooltips +MYREP_TOOLTIP_ENABLED = "Enables/disables myReputation."; +MYREP_TOOLTIP_SPLASH = "Toggles the splash screen on reaching next standing."; +MYREP_TOOLTIP_BLIZZ = "Toggles blizzards reputation messages."; +MYREP_TOOLTIP_MORE = "Toggles additional chat messages."; + +--Notifications +MYREP_NOTIFICATION_GAINED = "Your reputation with %s has increased by %d (%d/%d)."; +MYREP_NOTIFICATION_LOST = "Your reputation with %s has decreased by %d (%d/%d)."; +MYREP_NOTIFICATION_NEEDED = "%d reputation (%d repetitions) needed until %s."; +MYREP_NOTIFICATION_LEFT = "%d reputation (%d repetitions) left until %s."; +MYREP_NOTIFICATION_REACHED = "%s reputation reached with %s."; \ No newline at end of file diff --git a/myReputationClassic/myReputationClassic.lua b/myReputationClassic/myReputationClassic.lua new file mode 100755 index 0000000..4279dba --- /dev/null +++ b/myReputationClassic/myReputationClassic.lua @@ -0,0 +1,635 @@ +---------------------------------------------------------------------- +-- Variables +---------------------------------------------------------------------- + +-- Basic Addon Variables +MYREP_NAME = "myReputationClassic"; +MYREP_VERSION = GetAddOnMetadata("myReputation", "Version") or "N/A"; +MYREP_VERSION_STRING = "|cffffd700myReputation Classic "..GREEN_FONT_COLOR_CODE..MYREP_VERSION.."|cffffd700 by |cffff8c00HonorGoG"; +MYREP_MSG_FORMAT = "%s |cffffff00%s|r"; +MYREP_REGEXP_CHANGED = string.gsub( FACTION_STANDING_CHANGED, "'?%%[1|2]$s'?", "%(.+)" ); +MYREP_REGEXP_DECREASED = string.gsub( FACTION_STANDING_DECREASED, "'?%%[s|d]'?", "%(.+)" ); +MYREP_REGEXP_DECREASED_GENERIC = string.gsub( FACTION_STANDING_DECREASED_GENERIC, "'?%%[s|d]'?", "%(.+)" ); +MYREP_REGEXP_INCREASED = string.gsub( FACTION_STANDING_INCREASED, "'?%%[s|d]'?", "%(.+)" ); +MYREP_REGEXP_INCREASED_GENERIC = string.gsub( FACTION_STANDING_INCREASED_GENERIC, "'?%%[s|d]'?", "%(.+)" ); + +-- Configuration Variables and their Standard Values +myReputation_Config = { }; +myReputation_DefaultConfig = { }; +myReputation_DefaultConfig.Enabled = true; +myReputation_DefaultConfig.More = true; +myReputation_DefaultConfig.Blizz = false; +myReputation_DefaultConfig.Splash = true; +myReputation_DefaultConfig.Debug = false; +myReputation_DefaultConfig.Frame = 1; +myReputation_DefaultConfig.Info = 'Text'; +myReputation_DefaultConfig.Tooltip = 'Absolute'; + +-- Temp Variables and Arrays +myReputations = { }; +mySessionReputations = { }; +myReputation_Var = { }; +myReputation_Var.InWorld = false; + +-- Function Hooks +local lOriginal_ReputationFrame_Update; +local lOriginal_ReputationBar_OnClick; +local lOriginal_CFAddMessage_General; +local lOriginal_CFAddMessage_Combat; + +local _G = getfenv(0); + +---------------------------------------------------------------------- +-- OnFoo +---------------------------------------------------------------------- + +function myReputation_OnLoad(this) + --Slash command + SlashCmdList["MYREPCOMMAND"] = myReputation_SlashHandler; + SLASH_MYREPCOMMAND1 = "/myreputation"; + SLASH_MYREPCOMMAND2 = "/myrep"; + + -- Register Default Events + this:RegisterEvent("ADDON_LOADED"); + this:RegisterEvent("PLAYER_LOGIN"); + this:RegisterEvent("PLAYER_ENTERING_WORLD"); + this:RegisterEvent("UNIT_AURA"); + this:RegisterEvent("PLAYER_TARGET_CHANGED"); + this:RegisterEvent("PLAYER_LEAVING_WORLD"); + + if (DEFAULT_CHAT_FRAME) then + myReputation_ChatMsg(MYREP_VERSION); + end +end + +function myReputation_OnEvent(this, event, arg1) + if (event == "ADDON_LOADED") then + myReputation_AddOptionMt(myReputation_Config, myReputation_DefaultConfig); + + -- Delete Unused Config Values + for i,v in pairs(myReputation_Config) do + if (myReputation_DefaultConfig[i] == nil) then + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('Clean Up Config '..i); + end + myReputation_Config[i] = nil; + end + end + end + + -- Fired just before PLAYER_ENTERING_WORLD on login and UI Reload + if (event == "PLAYER_LOGIN") then + if ( + (myReputation_Config.Frame > 0) and + (myReputation_Config.Frame <= FCF_GetNumActiveChatFrames()) + ) then + REPUTATIONS_CHAT_FRAME = _G["ChatFrame"..myReputation_Config.Frame]; + else + REPUTATIONS_CHAT_FRAME = DEFAULT_CHAT_FRAME; + end + myReputation_Toggle(myReputation_Config.Enabled,true); + end + + -- Register Ingame Events + if (event == "PLAYER_ENTERING_WORLD") then + this:RegisterEvent("UPDATE_FACTION"); + end + + -- Unregister Ingame Events + if (event == "PLAYER_LEAVING_WORLD") then + this:UnregisterEvent("UPDATE_FACTION"); + end + + -- Event UPDATE_FACTION + if ( + (event == "UPDATE_FACTION") and + (myReputation_Config.Enabled == true) + ) then + myReputation_Factions_Update(); + end + + -- Events which are usable to get numFactions > 0 + if ((event == "UNIT_AURA") or (event == "PLAYER_TARGET_CHANGED")) then + -- Save Session StartRep + if (not mySessionReputations["Darnassus"]) then + + local numFactions = GetNumFactions(); + local factionIndex; + local name, standingID, barMin, barMax, barValue, isHeader, hasRep; + + for factionIndex=1, numFactions, 1 do + name, _, standingID, barMin, barMax, barValue, _, _, isHeader, _, hasRep = GetFactionInfo(factionIndex); + + if (not isHeader or hasRep) then + barMax = barMax - barMin; + barValue = barValue - barMin; + barMin = 0; + mySessionReputations[name] = { }; + mySessionReputations[name].standingID = standingID; + mySessionReputations[name].barValue = barValue; + mySessionReputations[name].barMax = barMax; + + end + end + end + + this:UnregisterEvent("UNIT_AURA"); + this:UnregisterEvent("PLAYER_TARGET_CHANGED"); + end +end + +---------------------------------------------------------------------- +-- Metatable Functions +---------------------------------------------------------------------- + +function myReputation_AddOptionMt(options, defaults) + setmetatable(options, { __index = defaults }); +end + +---------------------------------------------------------------------- +-- Other Functions +---------------------------------------------------------------------- + +-- Send Message to Chat Frame +function myReputation_ChatMsg(message) + DEFAULT_CHAT_FRAME:AddMessage(message); +end + +-- Send Message to Reputation Chat Frame +function myReputation_RepMsg(message,r,g,b) + REPUTATIONS_CHAT_FRAME:AddMessage(message,r,g,b); +end + +-- Send Message to Splash Frame +function myReputation_SplashMessage(message,r,g,b) + myReputation_SplashFrame:AddMessage(message, r,g,b, 1.0, UIERRORS_HOLD_TIME); +end + +-- SlashHandler +function myReputation_SlashHandler(msg) + if (msg == MYREP_CMD_STATUS) then + myReputation_DisplayStatus(); + elseif (msg == MYREP_CMD_DEBUG) then + myReputation_Toggle_Options("Debug"); + else + InterfaceOptionsFrame_OpenToCategory(MYREP_NAME); + end; +end + +function myReputation_DisplayStatus() + if (myReputation_Config.Enabled == true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_ON)); + else + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_OFF)); + end + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_DEBUG,MYREP_MSG_ON)); + end + if (myReputation_Config.Blizz == true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_BLIZZ,MYREP_MSG_ON)); + else + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_BLIZZ,MYREP_MSG_OFF)); + end + if (myReputation_Config.More == true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_MORE,MYREP_MSG_ON)); + else + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_MORE,MYREP_MSG_OFF)); + end + if (myReputation_Config.Splash == true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_SPLASH,MYREP_MSG_ON)); + else + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_SPLASH,MYREP_MSG_OFF)); + end + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_FRAME,myReputation_Config.Frame)); + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,'Info',myReputation_Config.Info)); + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,'Tooltip',myReputation_Config.Tooltip)); +end + +-- Toggles +function myReputation_Toggle(toggle,init) + myReputation_Config.Enabled = toggle; + + if (toggle == true) then + --Hook + if (not lOriginal_ReputationFrame_Update) then + if (init ~= true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_ON,".")); + end + lOriginal_ReputationFrame_Update = ReputationFrame_Update; + ReputationFrame_Update = myReputation_Frame_Update_New; + end + if (not lOriginal_ReputationBar_OnClick) then + lOriginal_ReputationBar_OnClick = ReputationBar_OnClick; + ReputationBar_OnClick = myReputation_ReputationBar_OnClick; + end + if (not lOriginal_CFAddMessage_General) then + lOriginal_CFAddMessage_General = _G["ChatFrame1"].AddMessage; + _G["ChatFrame1"].AddMessage = myReputation_CFAddMessage_Allgemein; + end + if (not lOriginal_CFAddMessage_Combat) then + lOriginal_CFAddMessage_Combat = _G["ChatFrame2"].AddMessage; + _G["ChatFrame2"].AddMessage = myReputation_CFAddMessage_Kampflog; + end + + if (ReputationDetailFrame:GetScript("OnShow") == nil) then + ReputationDetailFrame:HookScript("OnShow", function(self, event) + if (myReputation_Config.Enabled) then + myReputation_ReputationDetailFrame:Show(); + end + end) + end + if (ReputationDetailFrame:GetScript("OnHide") == nil) then + ReputationDetailFrame:HookScript("OnHide", function(self, event) + myReputation_ReputationDetailFrame:Hide(); + end) + end + else + --Unhook + if (lOriginal_ReputationFrame_Update) then + if (init ~= true) then + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_MSG_OFF,".")); + end + ReputationFrame_Update = lOriginal_ReputationFrame_Update; + lOriginal_ReputationFrame_Update = nil; + end + if (lOriginal_CFAddMessage_General) then + _G["ChatFrame1"].AddMessage = lOriginal_CFAddMessage_General; + lOriginal_CFAddMessage_General = nil; + end + if (lOriginal_CFAddMessage_Combat) then + _G["ChatFrame2"].AddMessage = lOriginal_CFAddMessage_Combat; + lOriginal_CFAddMessage_Combat = nil; + end + end +end + +function myReputation_Toggle_Options(option) + if (myReputation_Config[option] == true) then + myReputation_Config[option] = false; + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,_G["MYREP_MSG_"..string.upper(option)],MYREP_MSG_OFF,".")); + else + myReputation_Config[option] = true; + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,_G["MYREP_MSG_"..string.upper(option)],MYREP_MSG_ON,".")); + end +end + +function myReputation_ChatFrame_Change(checked,value) --Checked will always be 0 + local number = tonumber(value); + if ( + (value ~= nil) and + (number > 0) and + (number ~= 2) and + (number <= FCF_GetNumActiveChatFrames()) + ) then + myReputation_Config.Frame = number; + myReputation_ChatMsg(format(MYREP_MSG_FORMAT,MYREP_MSG_FRAME,myReputation_Config.Frame,".")); + REPUTATIONS_CHAT_FRAME = _G["ChatFrame"..myReputation_Config.Frame]; + myReputation_RepMsg(MYREP_MSG_NOTIFY,1.0,1.0,0.0); + else + myReputation_ChatMsg(format(MYREP_MSG_INVALID_FRAME,FCF_GetNumActiveChatFrames())); + end +end + +-- Hooked Functions +function myReputation_CFAddMessage_Allgemein(self, msg, ...) + if ( + (myReputation_Config.Blizz == false) and + (msg ~= nil) and + ( + string.find(msg, MYREP_REGEXP_CHANGED) or + string.find(msg, MYREP_REGEXP_DECREASED) or + string.find(msg, MYREP_REGEXP_DECREASED_GENERIC) or + string.find(msg, MYREP_REGEXP_INCREASED) or + string.find(msg, MYREP_REGEXP_INCREASED_GENERIC) + ) + ) then + if (myReputation_Config.Debug == true) then + myReputation_RepMsg("Blizzard Meldung in Frame 1 abgefangen"); + end + else + lOriginal_CFAddMessage_General(self, msg, ...); + end +end + +function myReputation_CFAddMessage_Kampflog(self, msg, ...) + if ( + (myReputation_Config.Blizz == false) and + (msg ~= nil) and + ( + string.find(msg, MYREP_REGEXP_CHANGED) or + string.find(msg, MYREP_REGEXP_DECREASED) or + string.find(msg, MYREP_REGEXP_DECREASED_GENERIC) or + string.find(msg, MYREP_REGEXP_INCREASED) or + string.find(msg, MYREP_REGEXP_INCREASED_GENERIC) + ) + ) then + if (myReputation_Config.Debug == true) then + myReputation_RepMsg("Blizzard Meldung in Frame 2 abgefangen"); + end + else + lOriginal_CFAddMessage_Combat(self, msg, ...); + end +end + +function myReputation_ReputationBar_OnClick(self) + lOriginal_ReputationBar_OnClick(self); + + if (myReputation_Config.Debug == true) then + myReputation_RepMsg("ReputationBar_OnClick Faction "..self.index); + end + + if (ReputationDetailFrame:IsVisible()) then + local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(self.index); + local color = FACTION_BAR_COLORS[standingID]; + + --Normalize Values + barMax = barMax - barMin; + barValue = barValue - barMin; + barMin = 0; + + local text = GetText("FACTION_STANDING_LABEL"..standingID, gender); + local absolute = barValue.."/"..barMax; + local percent = format("%.1f%%", barValue / barMax * 100); + local difference = 0; + + if (mySessionReputations[name]) then + -- No change in standing + if (mySessionReputations[name].standingID == standingID) then + difference = barValue - mySessionReputations[name].barValue; + + -- Reputation went up and reached next standing + elseif (mySessionReputations[name].standingID < standingID) then + difference = barValue + mySessionReputations[name].barMax - mySessionReputations[name].barValue; + + -- Reputation went down and reached next standing + else + difference = barMax - barValue + mySessionReputations[name].barValue; + end + end + + myReputation_ReputationDetailFrameDetails:SetTextColor(color.r, color.g, color.b); + myReputation_ReputationDetailFrameText:SetText( + format(MYREP_MSG_FORMAT, MYREP_INFO_TEXT..":", text) + ); + myReputation_ReputationDetailFrameAbsolute:SetText( + format(MYREP_MSG_FORMAT, MYREP_INFO_ABSOLUTE..":", absolute) + ); + myReputation_ReputationDetailFramePercent:SetText( + format(MYREP_MSG_FORMAT, MYREP_INFO_PERCENT..":", percent) + ); + myReputation_ReputationDetailFrameDifference:SetText( + format(MYREP_MSG_FORMAT, MYREP_INFO_DIFFERENCE..":", difference) + ); + end +end + +function myReputation_Frame_Update_New() + lOriginal_ReputationFrame_Update(); + + local info = myReputation_Explode(myReputation_Config.Info, ','); + local tooltip = myReputation_Explode(myReputation_Config.Tooltip, ','); + + local numFactions = GetNumFactions(); + local factionIndex, factionRow, factionTitle, factionStanding, factionBar, factionButton, factionLeftLine, factionBottomLine, factionBackground, color, tooltipStanding; + local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild; + local atWarIndicator, rightBarTexture; + local factionCompleteInfo, factionTooltip, difference; + + local factionOffset = FauxScrollFrame_GetOffset(ReputationListScrollFrame); + + local gender = UnitSex("player"); + local guildName = GetGuildInfo("player"); + + local i; + + for i=1, NUM_FACTIONS_DISPLAYED, 1 do + factionIndex = factionOffset + i; + factionRow = _G["ReputationBar"..i]; + factionBar = _G["ReputationBar"..i.."ReputationBar"]; + factionTitle = _G["ReputationBar"..i.."FactionName"]; + factionButton = _G["ReputationBar"..i.."ExpandOrCollapseButton"]; + factionLeftLine = _G["ReputationBar"..i.."LeftLine"]; + factionBottomLine = _G["ReputationBar"..i.."BottomLine"]; + factionStanding = _G["ReputationBar"..i.."ReputationBarFactionStanding"]; + factionBackground = _G["ReputationBar"..i.."Background"]; + + if (factionIndex <= numFactions) then + name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(factionIndex); + factionTitle:SetText(name); + + local factionStandingtext = GetText("FACTION_STANDING_LABEL"..standingID, gender); + + --Normalize Values + barMax = barMax - barMin; + barValue = barValue - barMin; + barMin = 0; + + if ( + (not isHeader or hasRep) and + (factionStanding:GetText() ~= nil) + ) then + local difference = 0; + + -- guild name was not available on login + if (mySessionReputations[name] == nil and guildName ~= nil and name == guildName) then + bakName = name; + name = GUILD_REPUTATION; + end + + if (mySessionReputations[name]) then + -- No change in standing + if (mySessionReputations[name].standingID == standingID) then + difference = barValue - mySessionReputations[name].barValue; + + -- Reputation went up and reached next standing + elseif (mySessionReputations[name].standingID < standingID) then + difference = barValue + mySessionReputations[name].barMax - mySessionReputations[name].barValue; + + -- Reputation went down and reached next standing + else + difference = barMax - barValue + mySessionReputations[name].barValue; + end + end + + local join; + + -- guild name should be displayed + if (bakName ~= nil) then + name = bakName; + end + + factionCompleteInfo = factionStandingtext; + if (type(info) == 'table') then + factionCompleteInfo = ''; + join = ''; + + for i,v in ipairs(info) do + if (v == 'Text') then + factionCompleteInfo = factionCompleteInfo..join..factionStandingtext; + end + if (v == 'Percent') then + factionCompleteInfo = factionCompleteInfo..join..format("%.1f%%", barValue / barMax * 100); + end + if (v == 'Absolute') then + factionCompleteInfo = factionCompleteInfo..join..barValue.."/"..barMax; + end + if (v == 'Difference') then + if (join ~= '') then + factionCompleteInfo = factionCompleteInfo..join..'('..difference..')'; + else + factionCompleteInfo = factionCompleteInfo..join..difference; + end + end + join = ' '; + end + end + + factionTooltip = barValue.."/"..barMax; + if (type(tooltip) == 'table') then + factionTooltip = ''; + join = ''; + + for i,v in ipairs(tooltip) do + if (v == 'Text') then + factionTooltip = factionTooltip..join..factionStandingtext; + end + if (v == 'Percent') then + factionTooltip = factionTooltip..join..format("%.1f%%", barValue / barMax * 100); + end + if (v == 'Absolute') then + factionTooltip = factionTooltip..join..barValue.."/"..barMax; + end + if (v == 'Difference') then + if (join ~= '') then + factionTooltip = factionTooltip..join..'('..difference..')'; + else + factionTooltip = factionTooltip..join..difference; + end + end + join = ' '; + end + end + + factionStanding:SetText(factionCompleteInfo); + factionRow.standingText = factionCompleteInfo; + factionRow.tooltip = HIGHLIGHT_FONT_COLOR_CODE..factionTooltip..FONT_COLOR_CODE_CLOSE; + end + end + end +end + +-- Event UPDATE_FACTION +function myReputation_Factions_Update() + local numFactions = GetNumFactions(); + local factionIndex, factionStanding, factionBar, factionHeader, color; + local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild; + local barMax, barMin, barValue; + local RepRemains, RepRepeats, RepBefore, RepActual, RepNext; + + for factionIndex=1, numFactions, 1 do + name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(factionIndex); + + if (not isHeader or hasRep) then + barMax = barMax - barMin; + barValue = barValue - barMin; + barMin = 0; + + if (myReputations[name]) then + if (standingID ~= 1) then + RepBefore = _G["FACTION_STANDING_LABEL"..standingID-1]; + end + + RepActual = _G["FACTION_STANDING_LABEL"..standingID]; + + if (standingID ~= 8) then + RepNext = _G["FACTION_STANDING_LABEL"..standingID+1]; + end + + local RawTotal = 0; + + -- No change in standing + if (myReputations[name].standingID == standingID) then + local difference = barValue - myReputations[name].barValue; + + -- Reputation went up + if ((difference > 0) and (myReputations[name].standingID == standingID)) then + myReputation_RepMsg(format(MYREP_NOTIFICATION_GAINED,name,difference,barValue,barMax), 0.5, 0.5, 1.0); + if (standingID ~= 8) then + RepRemains = barMax - barValue; + RepRepeats = RepRemains / difference; + if (RepRepeats > floor(RepRepeats)) then + RepRepeats = ceil(RepRepeats); + end + if (myReputation_Config.More == true) then + myReputation_RepMsg(format(MYREP_NOTIFICATION_NEEDED,RepRemains,RepRepeats,RepNext), 1.0, 1.0, 0.0); + end + end + + -- Reputation went down + elseif ((difference < 0) and (myReputations[name].standingID == standingID)) then + difference = abs(difference); + myReputation_RepMsg(format(MYREP_NOTIFICATION_LOST,name,difference,barValue,barMax), 0.5, 0.5, 1.0); + if (standingID ~= 1) then + RepRemains = barValue; + RepRepeats = RepRemains / difference; + if (RepRepeats > floor(RepRepeats)) then + RepRepeats = ceil(RepRepeats); + end + if (myReputation_Config.More == true) then + myReputation_RepMsg(format(MYREP_NOTIFICATION_LEFT,RepRemains,RepRepeats,RepBefore), 1.0, 1.0, 0.0); + end + end + end + + -- Reputation went up and reached next standing + elseif (myReputations[name].standingID < standingID) then + RepRemains = barMax - barValue; + RawTotal = barValue + myReputations[name].barMax - myReputations[name].barValue; + myReputation_RepMsg(format(MYREP_NOTIFICATION_GAINED,name,RawTotal,barValue,barMax), 0.5, 0.5, 1.0); + myReputation_RepMsg(format(MYREP_NOTIFICATION_REACHED,RepActual,name), 1.0, 1.0, 0.0); + if (standingID ~= 8) then + RepRepeats = RepRemains / RawTotal; + if (RepRepeats > floor(RepRepeats)) then + RepRepeats = ceil(RepRepeats); + end + if (myReputation_Config.More == true) then + myReputation_RepMsg(format(MYREP_NOTIFICATION_NEEDED,RepRemains,RepRepeats,RepNext), 1.0, 1.0, 0.0); + end + end + + if (myReputation_Config.Splash == true) then + myReputation_SplashMessage(name.." - "..RepActual.."!", 1.0, 1.0, 0.0); + end + + -- Reputation went down and reached next standing + else + RepRemains = barValue; + RawTotal = barMax - barValue + myReputations[name].barValue; + myReputation_RepMsg(format(MYREP_NOTIFICATION_LOST,name,RawTotal,barValue,barMax), 0.5, 0.5, 1.0); + myReputation_RepMsg(format(MYREP_NOTIFICATION_REACHED,RepActual,name), 1.0, 1.0, 0.0); + if (standingID ~= 1) then + RepRepeats = RepRemains / RawTotal; + if (RepRepeats > floor(RepRepeats)) then + RepRepeats = ceil(RepRepeats); + end + if (myReputation_Config.More == true) then + myReputation_RepMsg(format(MYREP_NOTIFICATION_LEFT,RepRemains,RepRepeats,RepBefore), 1.0, 1.0, 0.0); + end + end + + if (myReputation_Config.Splash == true) then + myReputation_SplashMessage(name.." - "..RepActual.."!", 1.0, 1.0, 0.0); + end + end + + else + myReputations[name] = { }; + end + + myReputations[name].standingID = standingID; + myReputations[name].barValue = barValue; + myReputations[name].barMax = barMax; + myReputations[name].atWarWith = atWarWith; + end + end +end \ No newline at end of file diff --git a/myReputationClassic/myReputationClassic.toc b/myReputationClassic/myReputationClassic.toc new file mode 100755 index 0000000..9e622b7 --- /dev/null +++ b/myReputationClassic/myReputationClassic.toc @@ -0,0 +1,15 @@ +## Interface: 11304 +## Title: myReputation Classic |cff00aa001.0.0.11304|r +## Author: HonorGoG of the Titan Panel Development Team +## Version: 1.0.0.11304 +## SavedVariables: myReputation_Config +## Notes: Changed display of reputation window and chat messages +## X-Credits: Egris, Karmond and Larry @ Baelgun. +## X-Category: Interface Enhancements +## X-Email: honorgog@gmail.com +## X-Localizations: enUS, deDE +## X-License: All rights reserved +## X-WoWI-ID: + +myReputationClassic.xml +myReputationOptions.xml diff --git a/myReputationClassic/myReputationClassic.xml b/myReputationClassic/myReputationClassic.xml new file mode 100755 index 0000000..8c82539 --- /dev/null +++ b/myReputationClassic/myReputationClassic.xml @@ -0,0 +1,134 @@ +<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="localization.de.lua"/> + <Script file="myReputationClassic.lua"/> + + <Frame name="myReputation_Frame" hidden="false" parent="UIParent"> + <Scripts> + <OnLoad> + myReputation_OnLoad(self); + </OnLoad> + <OnEvent> + myReputation_OnEvent(self, event, arg1); + </OnEvent> + </Scripts> + <Frames> + <MessageFrame name="myReputation_SplashFrame" frameStrata="LOW" insertMode="TOP" parent="UIParent" toplevel="true"> + <Size> + <AbsDimension x="512" y="100"></AbsDimension> + </Size> + <Anchors> + <Anchor point="CENTER"> + <Offset> + <AbsDimension x="0" y="100"></AbsDimension> + </Offset> + </Anchor> + </Anchors> + <FontString inherits="NumberFontNormalHuge" justifyH="CENTER"></FontString> + </MessageFrame> + </Frames> + </Frame> + + <Frame name="myReputation_ReputationDetailFrame" enableMouse="true" hidden="true"> + <Size> + <AbsDimension x="172" y="143"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="ReputationFrame" relativePoint="TOPRIGHT"> + <Offset> + <AbsDimension x="0" y="-188"/> + </Offset> + </Anchor> + </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"/> + </BackgroundInsets> + <TileSize> + <AbsValue val="32"/> + </TileSize> + <EdgeSize> + <AbsValue val="32"/> + </EdgeSize> + </Backdrop> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentDetails" inherits="GameFontHighlight" justifyH="LEFT" text="MYREP_MSG_MORE"> + <Size> + <AbsDimension x="140" y="0"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="20" y="-21"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentText" inherits="GameFontHighlightSmall" justifyH="LEFT"> + <Size> + <AbsDimension x="140" y="0"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentDetails" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-8"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentAbsolute" inherits="GameFontHighlightSmall" justifyH="LEFT"> + <Size> + <AbsDimension x="140" y="0"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentText" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-6"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentPercent" inherits="GameFontHighlightSmall" justifyH="LEFT"> + <Size> + <AbsDimension x="140" y="0"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentAbsolute" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-6"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentDifference" inherits="GameFontHighlightSmall" justifyH="LEFT"> + <Size> + <AbsDimension x="140" y="0"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentPercent" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-6"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <Texture file="Interface\PaperDollInfoFrame\UI-Character-Reputation-DetailBackground"> + <Size> + <AbsDimension x="211" y="128"/> + </Size> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="11" y="-11"/> + </Offset> + </Anchor> + </Anchors> + </Texture> + </Layer> + </Layers> + </Frame> + +</Ui> \ No newline at end of file diff --git a/myReputationClassic/myReputationOptions.lua b/myReputationClassic/myReputationOptions.lua new file mode 100755 index 0000000..4962592 --- /dev/null +++ b/myReputationClassic/myReputationOptions.lua @@ -0,0 +1,318 @@ +-- Temporary Configuration Variable +local myReputation_TmpInWorld = false; +local myReputation_TmpInit = false; +local myReputation_TmpOptions = { }; + +---------------------------------------------------------------------- +-- OnFoo +---------------------------------------------------------------------- + +function myReputation_OptionsOnLoad(this) + this:RegisterEvent("PLAYER_ENTERING_WORLD"); + + this.name = MYREP_NAME; + this.refresh = myReputation_OptionsRefresh; + this.okay = myReputation_OptionsOkay; + InterfaceOptions_AddCategory(this); + + myReputation_OptionsPanelTitle:SetText(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_VERSION)); +end + +function myReputation_OptionsOnEvent(event, arg1) + if (event == "PLAYER_ENTERING_WORLD") then + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('OnEvent'); + end + myReputation_TmpInWorld = true; + end +end + +function myReputation_OptionsOnShow() + -- Copy the values to the temporary options + if (myReputation_TmpInWorld == true) then + myReputation_TmpInit = true; + myReputation_TmpOptions.Info = myReputation_Explode(myReputation_Config.Info, ','); + myReputation_TmpOptions.Tooltip = myReputation_Explode(myReputation_Config.Tooltip, ','); + myReputation_OptionsPanelFrame:SetValue(myReputation_Config.Frame); + end + + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('OnShow'); + myReputation_DisplayStatus(); + myReputation_ChatMsg(format( + MYREP_MSG_FORMAT, + 'tmpInfo', + myReputation_TableImplode(myReputation_TmpOptions.Info, ',') + )); + myReputation_ChatMsg(format( + MYREP_MSG_FORMAT, + 'tmpTooltip', + myReputation_TableImplode(myReputation_TmpOptions.Tooltip, ',') + )); + end +end + +function myReputation_OptionsOnHide() + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('OnHide'); + myReputation_DisplayStatus(); + myReputation_ChatMsg(format( + MYREP_MSG_FORMAT, + 'tmpInfo', + myReputation_TableImplode(myReputation_TmpOptions.Info, ',') + )); + myReputation_ChatMsg(format( + MYREP_MSG_FORMAT, + 'tmpTooltip', + myReputation_TableImplode(myReputation_TmpOptions.Tooltip, ',') + )); + end +end + +---------------------------------------------------------------------- +-- Config Functions +---------------------------------------------------------------------- + +function myReputation_OptionsInitSlider(slider, low, high, step) + local lowText = getglobal(slider:GetName().."Low"); + local highText = getglobal(slider:GetName().."High"); + + lowText:SetText(low); + highText:SetText(high); + slider:SetMinMaxValues(low, high); + slider:SetValueStep(step); +end + +function myReputation_OptionsUpdateSlider(slider, text) + local val = math.floor(slider:GetValue()); + getglobal(slider:GetName().."Text"):SetText("|cffffd200"..text.." ("..val..")"); +end + +function myReputation_OptionsChangeText(option) + local parent = option:GetParent():GetParent(); + local name = string.gsub( option:GetName(), parent:GetName(), '' ); + local bar, setting = myReputation_Strip(name, "_"); + local status = (option:GetChecked() and true) or false; + + -- Only change the temporary options + if (status) then + myReputation_TableAddVal( + myReputation_TmpOptions[bar], setting + ); + else + myReputation_TableRemoveVal( + myReputation_TmpOptions[bar], setting + ); + end + + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg(format( + MYREP_MSG_FORMAT, + 'tmp'..bar, + myReputation_TableImplode(myReputation_TmpOptions[bar], ',') + )); + end +end + +---------------------------------------------------------------------- +-- Other Functions +---------------------------------------------------------------------- + +function myReputation_Strip(text, delimiter) + if text then + local a, b = strfind(text, delimiter); + if a then + return strsub(text, 1, a - 1), strsub(text, b + 1); + else + return text, ''; + end + end +end + +function myReputation_Explode(text, delimiter) + local result = { }; + if (type(text) == 'string' and text ~= '' and text ~= nil) then + local from = 1; + local delim_from, delim_to = string.find(text, delimiter, from); + while delim_from do + table.insert(result, string.sub(text, from , delim_from - 1)); + from = delim_to + 1; + delim_from, delim_to = string.find(text, delimiter, from); + end + if (string.sub(text, from) ~= '') then + table.insert(result, string.sub(text, from)); + end + end + return result; +end + +function myReputation_TableImplode(t, delimiter) + local text = ''; + if (type(t) == 'table') then + text = table.concat(t, delimiter); + end + return text; +end + +function myReputation_TableSearchVal(t, val) + local found = false; + + if (t == nil) then + t = { }; + end + + for i,v in ipairs(t) do + if (v == val) then + found = i; + end + end + + return found; +end + +function myReputation_TableAddVal(t, val) + if (t == nil) then + t = { }; + end + + local found = myReputation_TableSearchVal(t, val); + + if (found == false) then + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('add '..val); + end + table.insert(t, val); + end +end + +function myReputation_TableReplacePos(t, pos, val) + if (t == nil) then + t = { }; + end + + local found = myReputation_TableSearchVal(t, val); + + if (found == false) then + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('replace '..pos..' '..val); + end + if (pos > 0) then + table.insert(t, tonumber(pos), val); + end + end +end + +function myReputation_TableMoveVal(t, val) + myReputation_TableRemoveVal(t, val); + myReputation_TableAddVal(t, val); +end + +function myReputation_TableRemoveVal(t, val) + if (t == nil) then + t = { }; + end + + local found = myReputation_TableSearchVal(t, val); + + if (found ~= false) then + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('remove '..val); + end + table.remove(t, found); + end +end + +---------------------------------------------------------------------- +-- Panel Functions +---------------------------------------------------------------------- + +function myReputation_OptionsRefresh(self) + local name = self:GetName(); + local info = myReputation_Explode(myReputation_Config.Info, ','); + local tooltip = myReputation_Explode(myReputation_Config.Tooltip, ','); + + getglobal(name..'Enabled'):SetChecked(myReputation_Config.Enabled == true); + getglobal(name..'Splash'):SetChecked(myReputation_Config.Splash == true); + getglobal(name..'Blizz'):SetChecked(myReputation_Config.Blizz == true); + getglobal(name..'More'):SetChecked(myReputation_Config.More == true); + getglobal(name..'Frame'):SetValue(myReputation_Config.Frame); + + getglobal(name..'Info_Text'):SetChecked( + myReputation_TableSearchVal(info, 'Text') ~= false + ); + getglobal(name..'Info_Percent'):SetChecked( + myReputation_TableSearchVal(info, 'Percent') ~= false + ); + getglobal(name..'Info_Absolute'):SetChecked( + myReputation_TableSearchVal(info, 'Absolute') ~= false + ); + getglobal(name..'Info_Difference'):SetChecked( + myReputation_TableSearchVal(info, 'Difference') ~= false + ); + + getglobal(name..'Tooltip_Text'):SetChecked( + myReputation_TableSearchVal(tooltip, 'Text') ~= false + ); + getglobal(name..'Tooltip_Percent'):SetChecked( + myReputation_TableSearchVal(tooltip, 'Percent') ~= false + ); + getglobal(name..'Tooltip_Absolute'):SetChecked( + myReputation_TableSearchVal(tooltip, 'Absolute') ~= false + ); + getglobal(name..'Tooltip_Difference'):SetChecked( + myReputation_TableSearchVal(tooltip, 'Difference') ~= false + ); +end + +function myReputation_OptionsOkay(self) + -- Fired for all options not only of this addon + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg('Okay clicked'); + end + + if (myReputation_TmpInWorld == true and myReputation_TmpInit == true) then + local name = self:GetName(); + + myReputation_Toggle((getglobal(name..'Enabled'):GetChecked() and true) or false); + myReputation_Config.Splash = ((getglobal(name..'Splash'):GetChecked() and true) or false); + myReputation_Config.Blizz = ((getglobal(name..'Blizz'):GetChecked() and true) or false); + myReputation_Config.More = ((getglobal(name..'More'):GetChecked() and true) or false); + + local frame = getglobal(name..'Frame'):GetValue(); + if (myReputation_Config.Frame ~= frame and frame > 0) then + myReputation_ChatMsg(frame); + myReputation_ChatFrame_Change(0, frame); + end + + -- Save the temporary options + local option, status; + + local info = { }; + for i,v in ipairs(myReputation_TmpOptions.Info) do + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg(name..'Info_'..v); + end + + option = getglobal(name..'Info_'..v); + status = (option:GetChecked() and true) or false; + if (status) then + myReputation_TableReplacePos(info, i, v); + end + end + myReputation_Config.Info = myReputation_TableImplode(info, ','); + + local tooltip = { }; + for i,v in ipairs(myReputation_TmpOptions.Tooltip) do + if (myReputation_Config.Debug == true) then + myReputation_ChatMsg(name..'Tooltip_'..v); + end + + option = getglobal(name..'Tooltip_'..v); + status = (option:GetChecked() and true) or false; + if (status) then + myReputation_TableReplacePos(tooltip, i, v); + end + end + myReputation_Config.Tooltip = myReputation_TableImplode(tooltip, ','); + end +end \ No newline at end of file diff --git a/myReputationClassic/myReputationOptions.xml b/myReputationClassic/myReputationOptions.xml new file mode 100755 index 0000000..b924ee1 --- /dev/null +++ b/myReputationClassic/myReputationOptions.xml @@ -0,0 +1,463 @@ +<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="myReputationOptions.lua" /> + + <Frame name="myReputation_OptionsPanel" hidden="false"> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentTitle" inherits="GameFontNormalLarge" justifyH="LEFT" justifyV="TOP"> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="16" y="-16" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Frames> + <CheckButton name="$parentEnabled" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentTitle" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="-2" y="-16" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_MSG_ON" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_TOOLTIP_ENABLED; + </OnLoad> + </Scripts> + </CheckButton> + <CheckButton name="$parentSplash" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentEnabled" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_MSG_SPLASH" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_TOOLTIP_SPLASH; + </OnLoad> + </Scripts> + </CheckButton> + <CheckButton name="$parentBlizz" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentSplash" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_MSG_BLIZZ" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_TOOLTIP_BLIZZ; + </OnLoad> + </Scripts> + </CheckButton> + <CheckButton name="$parentMore" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentBlizz" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_MSG_MORE" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_TOOLTIP_MORE; + </OnLoad> + </Scripts> + </CheckButton> + <Slider name="$parentFrame" inherits="OptionsSliderTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentMore" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="28" y="-14" /> + </Offset> + </Anchor> + </Anchors> + <Scripts> + <OnShow> + myReputation_OptionsInitSlider(self, 1, FCF_GetNumActiveChatFrames(), 1); + </OnShow> + <OnValueChanged> + myReputation_OptionsUpdateSlider(self, MYREP_MSG_FRAME); + </OnValueChanged> + </Scripts> + </Slider> + <Frame name="$parentInfo" movable="false" virtual="true"> + <size x="135" y="125" /> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentMore" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="2" y="-80" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="OVERLAY"> + <FontString name="$parentTitle" inherits="GameFontNormal" parentKey="title" text="MYREP_INFO"> + <Anchors> + <Anchor point="BOTTOM" relativePoint="TOP" relativeTo="$parent"> + <Offset> + <AbsDimension x="0" y="0" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> + <EdgeSize> + <AbsValue val="16" /> + </EdgeSize> + </Backdrop> + <Frames> + <CheckButton name="$parent_Text" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"> + <Offset> + <AbsDimension x="5" y="-5" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_TEXT" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_TEXT; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + <CheckButton name="$parent_Percent" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent_Text" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_PERCENT" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_PERCENT; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + <CheckButton name="$parent_Absolute" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent_Percent" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_ABSOLUTE" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_ABSOLUTE; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + <CheckButton name="$parent_Difference" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent_Absolute" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_DIFFERENCE" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_DIFFERENCE; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + </Frames> + </Frame> + <Frame name="$parentTooltip" movable="false" virtual="true"> + <size x="135" y="125" /> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parentInfo" relativePoint="TOPLEFT"> + <Offset> + <AbsDimension x="200" y="0" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="OVERLAY"> + <FontString name="$parentTitle" inherits="GameFontNormal" parentKey="title" text="MYREP_TOOLTIP"> + <Anchors> + <Anchor point="BOTTOM" relativePoint="TOP" relativeTo="$parent"> + <Offset> + <AbsDimension x="0" y="0" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> + <EdgeSize> + <AbsValue val="16" /> + </EdgeSize> + </Backdrop> + <Frames> + <CheckButton name="$parent_Text" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"> + <Offset> + <AbsDimension x="5" y="-5" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_TEXT" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_TEXT; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + <CheckButton name="$parent_Percent" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent_Text" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_PERCENT" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_PERCENT; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + <CheckButton name="$parent_Absolute" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent_Percent" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_ABSOLUTE" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_ABSOLUTE; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + <CheckButton name="$parent_Difference" inherits="InterfaceOptionsBaseCheckButtonTemplate"> + <Anchors> + <Anchor point="TOPLEFT" relativeTo="$parent_Absolute" relativePoint="BOTTOMLEFT"> + <Offset> + <AbsDimension x="0" y="-4" /> + </Offset> + </Anchor> + </Anchors> + <Layers> + <Layer level="ARTWORK"> + <FontString name="$parentText" text="MYREP_INFO_DIFFERENCE" inherits="GameFontHighlight"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT"> + <Offset> + <AbsDimension x="0" y="1" /> + </Offset> + </Anchor> + </Anchors> + </FontString> + </Layer> + </Layers> + <Scripts> + <OnLoad> + self.tooltipText = MYREP_INFO_DIFFERENCE; + </OnLoad> + <OnClick> + myReputation_OptionsChangeText(self); + </OnClick> + </Scripts> + </CheckButton> + </Frames> + </Frame> + </Frames> + <Scripts> + <OnLoad> + myReputation_OptionsOnLoad(self); + </OnLoad> + <OnEvent> + myReputation_OptionsOnEvent(event, arg1); + </OnEvent> + <OnShow> + myReputation_OptionsOnShow(self); + </OnShow> + <OnHide> + myReputation_OptionsOnHide(self); + </OnHide> + </Scripts> + </Frame> + +</Ui> \ No newline at end of file diff --git a/myReputationOptions.lua b/myReputationOptions.lua deleted file mode 100755 index 4962592..0000000 --- a/myReputationOptions.lua +++ /dev/null @@ -1,318 +0,0 @@ --- Temporary Configuration Variable -local myReputation_TmpInWorld = false; -local myReputation_TmpInit = false; -local myReputation_TmpOptions = { }; - ----------------------------------------------------------------------- --- OnFoo ----------------------------------------------------------------------- - -function myReputation_OptionsOnLoad(this) - this:RegisterEvent("PLAYER_ENTERING_WORLD"); - - this.name = MYREP_NAME; - this.refresh = myReputation_OptionsRefresh; - this.okay = myReputation_OptionsOkay; - InterfaceOptions_AddCategory(this); - - myReputation_OptionsPanelTitle:SetText(format(MYREP_MSG_FORMAT,MYREP_NAME,MYREP_VERSION)); -end - -function myReputation_OptionsOnEvent(event, arg1) - if (event == "PLAYER_ENTERING_WORLD") then - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('OnEvent'); - end - myReputation_TmpInWorld = true; - end -end - -function myReputation_OptionsOnShow() - -- Copy the values to the temporary options - if (myReputation_TmpInWorld == true) then - myReputation_TmpInit = true; - myReputation_TmpOptions.Info = myReputation_Explode(myReputation_Config.Info, ','); - myReputation_TmpOptions.Tooltip = myReputation_Explode(myReputation_Config.Tooltip, ','); - myReputation_OptionsPanelFrame:SetValue(myReputation_Config.Frame); - end - - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('OnShow'); - myReputation_DisplayStatus(); - myReputation_ChatMsg(format( - MYREP_MSG_FORMAT, - 'tmpInfo', - myReputation_TableImplode(myReputation_TmpOptions.Info, ',') - )); - myReputation_ChatMsg(format( - MYREP_MSG_FORMAT, - 'tmpTooltip', - myReputation_TableImplode(myReputation_TmpOptions.Tooltip, ',') - )); - end -end - -function myReputation_OptionsOnHide() - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('OnHide'); - myReputation_DisplayStatus(); - myReputation_ChatMsg(format( - MYREP_MSG_FORMAT, - 'tmpInfo', - myReputation_TableImplode(myReputation_TmpOptions.Info, ',') - )); - myReputation_ChatMsg(format( - MYREP_MSG_FORMAT, - 'tmpTooltip', - myReputation_TableImplode(myReputation_TmpOptions.Tooltip, ',') - )); - end -end - ----------------------------------------------------------------------- --- Config Functions ----------------------------------------------------------------------- - -function myReputation_OptionsInitSlider(slider, low, high, step) - local lowText = getglobal(slider:GetName().."Low"); - local highText = getglobal(slider:GetName().."High"); - - lowText:SetText(low); - highText:SetText(high); - slider:SetMinMaxValues(low, high); - slider:SetValueStep(step); -end - -function myReputation_OptionsUpdateSlider(slider, text) - local val = math.floor(slider:GetValue()); - getglobal(slider:GetName().."Text"):SetText("|cffffd200"..text.." ("..val..")"); -end - -function myReputation_OptionsChangeText(option) - local parent = option:GetParent():GetParent(); - local name = string.gsub( option:GetName(), parent:GetName(), '' ); - local bar, setting = myReputation_Strip(name, "_"); - local status = (option:GetChecked() and true) or false; - - -- Only change the temporary options - if (status) then - myReputation_TableAddVal( - myReputation_TmpOptions[bar], setting - ); - else - myReputation_TableRemoveVal( - myReputation_TmpOptions[bar], setting - ); - end - - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg(format( - MYREP_MSG_FORMAT, - 'tmp'..bar, - myReputation_TableImplode(myReputation_TmpOptions[bar], ',') - )); - end -end - ----------------------------------------------------------------------- --- Other Functions ----------------------------------------------------------------------- - -function myReputation_Strip(text, delimiter) - if text then - local a, b = strfind(text, delimiter); - if a then - return strsub(text, 1, a - 1), strsub(text, b + 1); - else - return text, ''; - end - end -end - -function myReputation_Explode(text, delimiter) - local result = { }; - if (type(text) == 'string' and text ~= '' and text ~= nil) then - local from = 1; - local delim_from, delim_to = string.find(text, delimiter, from); - while delim_from do - table.insert(result, string.sub(text, from , delim_from - 1)); - from = delim_to + 1; - delim_from, delim_to = string.find(text, delimiter, from); - end - if (string.sub(text, from) ~= '') then - table.insert(result, string.sub(text, from)); - end - end - return result; -end - -function myReputation_TableImplode(t, delimiter) - local text = ''; - if (type(t) == 'table') then - text = table.concat(t, delimiter); - end - return text; -end - -function myReputation_TableSearchVal(t, val) - local found = false; - - if (t == nil) then - t = { }; - end - - for i,v in ipairs(t) do - if (v == val) then - found = i; - end - end - - return found; -end - -function myReputation_TableAddVal(t, val) - if (t == nil) then - t = { }; - end - - local found = myReputation_TableSearchVal(t, val); - - if (found == false) then - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('add '..val); - end - table.insert(t, val); - end -end - -function myReputation_TableReplacePos(t, pos, val) - if (t == nil) then - t = { }; - end - - local found = myReputation_TableSearchVal(t, val); - - if (found == false) then - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('replace '..pos..' '..val); - end - if (pos > 0) then - table.insert(t, tonumber(pos), val); - end - end -end - -function myReputation_TableMoveVal(t, val) - myReputation_TableRemoveVal(t, val); - myReputation_TableAddVal(t, val); -end - -function myReputation_TableRemoveVal(t, val) - if (t == nil) then - t = { }; - end - - local found = myReputation_TableSearchVal(t, val); - - if (found ~= false) then - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('remove '..val); - end - table.remove(t, found); - end -end - ----------------------------------------------------------------------- --- Panel Functions ----------------------------------------------------------------------- - -function myReputation_OptionsRefresh(self) - local name = self:GetName(); - local info = myReputation_Explode(myReputation_Config.Info, ','); - local tooltip = myReputation_Explode(myReputation_Config.Tooltip, ','); - - getglobal(name..'Enabled'):SetChecked(myReputation_Config.Enabled == true); - getglobal(name..'Splash'):SetChecked(myReputation_Config.Splash == true); - getglobal(name..'Blizz'):SetChecked(myReputation_Config.Blizz == true); - getglobal(name..'More'):SetChecked(myReputation_Config.More == true); - getglobal(name..'Frame'):SetValue(myReputation_Config.Frame); - - getglobal(name..'Info_Text'):SetChecked( - myReputation_TableSearchVal(info, 'Text') ~= false - ); - getglobal(name..'Info_Percent'):SetChecked( - myReputation_TableSearchVal(info, 'Percent') ~= false - ); - getglobal(name..'Info_Absolute'):SetChecked( - myReputation_TableSearchVal(info, 'Absolute') ~= false - ); - getglobal(name..'Info_Difference'):SetChecked( - myReputation_TableSearchVal(info, 'Difference') ~= false - ); - - getglobal(name..'Tooltip_Text'):SetChecked( - myReputation_TableSearchVal(tooltip, 'Text') ~= false - ); - getglobal(name..'Tooltip_Percent'):SetChecked( - myReputation_TableSearchVal(tooltip, 'Percent') ~= false - ); - getglobal(name..'Tooltip_Absolute'):SetChecked( - myReputation_TableSearchVal(tooltip, 'Absolute') ~= false - ); - getglobal(name..'Tooltip_Difference'):SetChecked( - myReputation_TableSearchVal(tooltip, 'Difference') ~= false - ); -end - -function myReputation_OptionsOkay(self) - -- Fired for all options not only of this addon - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg('Okay clicked'); - end - - if (myReputation_TmpInWorld == true and myReputation_TmpInit == true) then - local name = self:GetName(); - - myReputation_Toggle((getglobal(name..'Enabled'):GetChecked() and true) or false); - myReputation_Config.Splash = ((getglobal(name..'Splash'):GetChecked() and true) or false); - myReputation_Config.Blizz = ((getglobal(name..'Blizz'):GetChecked() and true) or false); - myReputation_Config.More = ((getglobal(name..'More'):GetChecked() and true) or false); - - local frame = getglobal(name..'Frame'):GetValue(); - if (myReputation_Config.Frame ~= frame and frame > 0) then - myReputation_ChatMsg(frame); - myReputation_ChatFrame_Change(0, frame); - end - - -- Save the temporary options - local option, status; - - local info = { }; - for i,v in ipairs(myReputation_TmpOptions.Info) do - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg(name..'Info_'..v); - end - - option = getglobal(name..'Info_'..v); - status = (option:GetChecked() and true) or false; - if (status) then - myReputation_TableReplacePos(info, i, v); - end - end - myReputation_Config.Info = myReputation_TableImplode(info, ','); - - local tooltip = { }; - for i,v in ipairs(myReputation_TmpOptions.Tooltip) do - if (myReputation_Config.Debug == true) then - myReputation_ChatMsg(name..'Tooltip_'..v); - end - - option = getglobal(name..'Tooltip_'..v); - status = (option:GetChecked() and true) or false; - if (status) then - myReputation_TableReplacePos(tooltip, i, v); - end - end - myReputation_Config.Tooltip = myReputation_TableImplode(tooltip, ','); - end -end \ No newline at end of file diff --git a/myReputationOptions.xml b/myReputationOptions.xml deleted file mode 100755 index b924ee1..0000000 --- a/myReputationOptions.xml +++ /dev/null @@ -1,463 +0,0 @@ -<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="myReputationOptions.lua" /> - - <Frame name="myReputation_OptionsPanel" hidden="false"> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentTitle" inherits="GameFontNormalLarge" justifyH="LEFT" justifyV="TOP"> - <Anchors> - <Anchor point="TOPLEFT"> - <Offset> - <AbsDimension x="16" y="-16" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Frames> - <CheckButton name="$parentEnabled" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentTitle" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="-2" y="-16" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_MSG_ON" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_TOOLTIP_ENABLED; - </OnLoad> - </Scripts> - </CheckButton> - <CheckButton name="$parentSplash" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentEnabled" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_MSG_SPLASH" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_TOOLTIP_SPLASH; - </OnLoad> - </Scripts> - </CheckButton> - <CheckButton name="$parentBlizz" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentSplash" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_MSG_BLIZZ" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_TOOLTIP_BLIZZ; - </OnLoad> - </Scripts> - </CheckButton> - <CheckButton name="$parentMore" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentBlizz" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_MSG_MORE" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_TOOLTIP_MORE; - </OnLoad> - </Scripts> - </CheckButton> - <Slider name="$parentFrame" inherits="OptionsSliderTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentMore" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="28" y="-14" /> - </Offset> - </Anchor> - </Anchors> - <Scripts> - <OnShow> - myReputation_OptionsInitSlider(self, 1, FCF_GetNumActiveChatFrames(), 1); - </OnShow> - <OnValueChanged> - myReputation_OptionsUpdateSlider(self, MYREP_MSG_FRAME); - </OnValueChanged> - </Scripts> - </Slider> - <Frame name="$parentInfo" movable="false" virtual="true"> - <size x="135" y="125" /> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentMore" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="2" y="-80" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="OVERLAY"> - <FontString name="$parentTitle" inherits="GameFontNormal" parentKey="title" text="MYREP_INFO"> - <Anchors> - <Anchor point="BOTTOM" relativePoint="TOP" relativeTo="$parent"> - <Offset> - <AbsDimension x="0" y="0" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> - <EdgeSize> - <AbsValue val="16" /> - </EdgeSize> - </Backdrop> - <Frames> - <CheckButton name="$parent_Text" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"> - <Offset> - <AbsDimension x="5" y="-5" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_TEXT" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_TEXT; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - <CheckButton name="$parent_Percent" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent_Text" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_PERCENT" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_PERCENT; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - <CheckButton name="$parent_Absolute" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent_Percent" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_ABSOLUTE" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_ABSOLUTE; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - <CheckButton name="$parent_Difference" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent_Absolute" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_DIFFERENCE" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_DIFFERENCE; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - </Frames> - </Frame> - <Frame name="$parentTooltip" movable="false" virtual="true"> - <size x="135" y="125" /> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parentInfo" relativePoint="TOPLEFT"> - <Offset> - <AbsDimension x="200" y="0" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="OVERLAY"> - <FontString name="$parentTitle" inherits="GameFontNormal" parentKey="title" text="MYREP_TOOLTIP"> - <Anchors> - <Anchor point="BOTTOM" relativePoint="TOP" relativeTo="$parent"> - <Offset> - <AbsDimension x="0" y="0" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> - <EdgeSize> - <AbsValue val="16" /> - </EdgeSize> - </Backdrop> - <Frames> - <CheckButton name="$parent_Text" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"> - <Offset> - <AbsDimension x="5" y="-5" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_TEXT" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_TEXT; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - <CheckButton name="$parent_Percent" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent_Text" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_PERCENT" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_PERCENT; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - <CheckButton name="$parent_Absolute" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent_Percent" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_ABSOLUTE" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_ABSOLUTE; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - <CheckButton name="$parent_Difference" inherits="InterfaceOptionsBaseCheckButtonTemplate"> - <Anchors> - <Anchor point="TOPLEFT" relativeTo="$parent_Absolute" relativePoint="BOTTOMLEFT"> - <Offset> - <AbsDimension x="0" y="-4" /> - </Offset> - </Anchor> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <FontString name="$parentText" text="MYREP_INFO_DIFFERENCE" inherits="GameFontHighlight"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT"> - <Offset> - <AbsDimension x="0" y="1" /> - </Offset> - </Anchor> - </Anchors> - </FontString> - </Layer> - </Layers> - <Scripts> - <OnLoad> - self.tooltipText = MYREP_INFO_DIFFERENCE; - </OnLoad> - <OnClick> - myReputation_OptionsChangeText(self); - </OnClick> - </Scripts> - </CheckButton> - </Frames> - </Frame> - </Frames> - <Scripts> - <OnLoad> - myReputation_OptionsOnLoad(self); - </OnLoad> - <OnEvent> - myReputation_OptionsOnEvent(event, arg1); - </OnEvent> - <OnShow> - myReputation_OptionsOnShow(self); - </OnShow> - <OnHide> - myReputation_OptionsOnHide(self); - </OnHide> - </Scripts> - </Frame> - -</Ui> \ No newline at end of file