Skip to content

Commit

Permalink
Fix rep gains and autowatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonaza committed Jul 24, 2016
1 parent ba8c404 commit 4d1fa2a
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Experiencer also adds a DataBroker module that displays current text if you wish

Experiencer options can be accessed by right clicking the bar or the DataBroker module. In order to make things smoother there are a few useful shortcuts.

* Shift left-click pastes current statistics to chat editbox. Shift control left-click for quick paste.
* Control left-click toggles bar visiblity. There will always be a slightly translucent black bar where the bar is anchored.
* Middle click toggles text visibility.
* Middle click toggles text visibility if text is not set to be always hidden.
* Holding control while scrolling with mouse wheel lets you browse through available bars in following order: experience, reputation, artifact power and honor.
* Shift left-click pastes current statistics to chat editbox. Shift control left-click for quick paste.

## Dependencies
Experiencer uses Ace3 and LibDataBroker which are included in the /libs directory.
72 changes: 54 additions & 18 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ _G[ADDON_NAME] = Addon;

local AceDB = LibStub("AceDB-3.0");

local TEXT_VISIBILITY_HIDE = 1;
local TEXT_VISIBILITY_HOVER = 2;
local TEXT_VISIBILITY_ALWAYS = 3;

function Addon:OnInitialize()
local defaults = {
char = {
Visible = true,
StickyText = false,
TextVisibility = TEXT_VISIBILITY_ALWAYS,
ActiveModule = "experience",
},

Expand Down Expand Up @@ -221,7 +225,7 @@ end
function Addon:ShowBar()
ExperiencerFrameBars:Show();

if(Addon.db.char.StickyText) then
if(Addon.db.char.TextVisibility == TEXT_VISIBILITY_ALWAYS) then
ExperiencerBarTextFrame:Show();
end
end
Expand Down Expand Up @@ -375,7 +379,7 @@ function Addon:UpdateText()
local text = module:GetText() or "<Error: no module text>";
ExperiencerBarText:SetText(text);

Addon:UpdateDataBroker();
Addon:UpdateDataBrokerText(text);
end

local function roundnum(num, idp)
Expand Down Expand Up @@ -413,6 +417,26 @@ function Addon:SendModuleChatMessage()
end
end

function Addon:ToggleTextVisilibity(visibility, noAnimation)
if(visibility) then
self.db.char.TextVisibility = visibility;
elseif(self.db.char.TextVisibility == TEXT_VISIBILITY_HOVER) then
self.db.char.TextVisibility = TEXT_VISIBILITY_ALWAYS;
elseif(self.db.char.TextVisibility == TEXT_VISIBILITY_ALWAYS) then
self.db.char.TextVisibility = TEXT_VISIBILITY_HOVER;
end

if(not noAnimation) then
if(self.db.char.TextVisibility == TEXT_VISIBILITY_ALWAYS) then
ExperiencerBarTextFrame.fadeout:Stop();
ExperiencerBarTextFrame.fadein:Play();
else
ExperiencerBarTextFrame.fadein:Stop();
ExperiencerBarTextFrame.fadeout:Play();
end
end
end

function Experiencer_OnMouseDown(self, button)
CloseMenus();

Expand All @@ -424,8 +448,8 @@ function Experiencer_OnMouseDown(self, button)
end
end

if(button == "MiddleButton") then
Addon.db.char.StickyText = not Addon.db.char.StickyText;
if(button == "MiddleButton" and Addon.db.char.TextVisibility ~= TEXT_VISIBILITY_HIDE) then
Addon:ToggleTextVisilibity(nil, true);
end

if(button == "RightButton") then
Expand Down Expand Up @@ -481,6 +505,7 @@ end

function Addon:OpenContextMenu(anchorFrame)
if(InCombatLockdown()) then return end
anchorFrame = anchorFrame or ExperiencerFrameBars.main;

if(not Addon.ContextMenu) then
Addon.ContextMenu = CreateFrame("Frame", "ExperiencerContextMenuFrame", UIParent, "UIDropDownMenuTemplate");
Expand Down Expand Up @@ -535,22 +560,33 @@ function Addon:OpenContextMenu(anchorFrame)
end,
checked = function() return self.db.char.FlashLevelUp; end,
isNotRadio = true,
tooltipTitle = "Flash when able to level up",
tooltipText = "Used for Artifact and Honor",
tooltipOnButton = 1,
},
{
text = "Keep text visible",
text = "Always show text",
func = function()
self.db.char.StickyText = not self.db.char.StickyText;
if(self.db.char.StickyText) then
ExperiencerBarTextFrame.fadeout:Stop();
ExperiencerBarTextFrame.fadein:Play();
else
ExperiencerBarTextFrame.fadein:Stop();
ExperiencerBarTextFrame.fadeout:Play();
end
Addon:ToggleTextVisilibity(TEXT_VISIBILITY_ALWAYS);
Addon:OpenContextMenu();
end,
checked = function() return self.db.char.StickyText; end,
isNotRadio = true,
checked = function() return self.db.char.TextVisibility == TEXT_VISIBILITY_ALWAYS; end,
},
{
text = "Show text on hover",
func = function()
Addon:ToggleTextVisilibity(TEXT_VISIBILITY_HOVER);
Addon:OpenContextMenu();
end,
checked = function() return self.db.char.TextVisibility == TEXT_VISIBILITY_HOVER; end,
},
{
text = "Always hide text",
func = function()
Addon:ToggleTextVisilibity(TEXT_VISIBILITY_HIDE);
Addon:OpenContextMenu();
end,
checked = function() return self.db.char.TextVisibility == TEXT_VISIBILITY_HIDE; end,
},
{
text = " ", isTitle = true, notCheckable = true,
Expand Down Expand Up @@ -692,14 +728,14 @@ function Addon:OpenContextMenu(anchorFrame)
end

function Experiencer_OnEnter(self)
if(not Addon.db.char.StickyText) then
if(Addon.db.char.TextVisibility == TEXT_VISIBILITY_HOVER) then
ExperiencerBarTextFrame.fadeout:Stop();
ExperiencerBarTextFrame.fadein:Play();
end
end

function Experiencer_OnLeave(self)
if(not Addon.db.char.StickyText) then
if(Addon.db.char.TextVisibility == TEXT_VISIBILITY_HOVER) then
ExperiencerBarTextFrame.fadein:Stop();
ExperiencerBarTextFrame.fadeout:Play();
end
Expand Down
9 changes: 3 additions & 6 deletions databroker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local LibDataBroker = LibStub("LibDataBroker-1.1");
local settings = {
type = "data source",
label = "Experiencer",
text = "",
text = "Experiencer Text Display",
icon = "Interface\\Icons\\Ability_Paladin_EmpoweredSealsRighteous",
OnClick = function(frame, button)
if(button == "RightButton") then
Expand All @@ -25,9 +25,6 @@ function Addon:InitializeDataBroker()
Addon.BrokerModule = LibDataBroker:NewDataObject("Experiencer", settings);
end

function Addon:UpdateDataBroker()
local module = Addon:GetActiveModule();
if(not module) then return end

Addon.BrokerModule.text = module:GetText();
function Addon:UpdateDataBrokerText(text)
Addon.BrokerModule.text = text;
end
10 changes: 6 additions & 4 deletions modules/reputation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ function module:GetOptionsMenu()
},
{
text = "Auto watch most recent reputation",
func = function() self.db.global.AutoWatch.Visible = not self.db.global.AutoWatch.Visible; end,
checked = function() return self.db.global.AutoWatch.Visible; end,
func = function() self.db.global.AutoWatch.Enabled = not self.db.global.AutoWatch.Enabled; end,
checked = function() return self.db.global.AutoWatch.Enabled; end,
hasArrow = true,
isNotRadio = true,
menuList = {
Expand Down Expand Up @@ -211,6 +211,7 @@ function module:GetOptionsMenu()
tinsert(menudata, data);
end

tinsert(menudata, { text = "", isTitle = true, notCheckable = true, });
tinsert(menudata, {
text = "Open reputations panel",
func = function() ToggleCharacter("ReputationFrame"); end,
Expand Down Expand Up @@ -415,7 +416,7 @@ function module:UPDATE_FACTION(event, ...)
module:Refresh(instant);
end

local reputationPattern = FACTION_STANDING_INCREASED:gsub("%%s", "(.-)"):gsub("%%d", "(%d*)%");
local reputationPattern = FACTION_STANDING_INCREASED:gsub("%%s", "(.-)"):gsub("%%d", "(%%d*)%%");

function module:CHAT_MSG_COMBAT_FACTION_CHANGE(event, message, ...)
local reputation, amount = message:match(reputationPattern);
Expand All @@ -432,7 +433,8 @@ function module:CHAT_MSG_COMBAT_FACTION_CHANGE(event, message, ...)
module.recentReputations[reputation].amount = module.recentReputations[reputation].amount + amount;

if(self.db.global.AutoWatch.Enabled) then
if(module.Tracked ~= reputation) then
local name = GetWatchedFactionInfo();
if(name ~= reputation) then
module:UpdateAutoWatch(reputation);
end
end
Expand Down

0 comments on commit 4d1fa2a

Please sign in to comment.