Verified Commit 54ec75c9 authored by Repooc's avatar Repooc
Browse files

fix exp some more and clean it up a bit

parent 8ba89a95
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local SLE, T, E = unpack(select(2, ...))
local DB = SLE:GetModule("DataBars")
local EDB = E:GetModule('DataBars')
--GLOBALS: unpack, select, hooksecurefunc
local UnitLevel = UnitLevel
local COMBATLOG_XPGAIN_FIRSTPERSON, COMBATLOG_XPGAIN_FIRSTPERSON_UNNAMED = COMBATLOG_XPGAIN_FIRSTPERSON, COMBATLOG_XPGAIN_FIRSTPERSON_UNNAMED
local COMBATLOG_XPGAIN_EXHAUSTION1, COMBATLOG_XPGAIN_EXHAUSTION2, COMBATLOG_XPGAIN_EXHAUSTION4, COMBATLOG_XPGAIN_EXHAUSTION5 = COMBATLOG_XPGAIN_EXHAUSTION1, COMBATLOG_XPGAIN_EXHAUSTION2, COMBATLOG_XPGAIN_EXHAUSTION4, COMBATLOG_XPGAIN_EXHAUSTION5
local COMBATLOG_XPGAIN_EXHAUSTION1_GROUP, COMBATLOG_XPGAIN_EXHAUSTION2_GROUP, COMBATLOG_XPGAIN_EXHAUSTION4_GROUP, COMBATLOG_XPGAIN_EXHAUSTION5_GROUP = COMBATLOG_XPGAIN_EXHAUSTION1_GROUP, COMBATLOG_XPGAIN_EXHAUSTION2_GROUP, COMBATLOG_XPGAIN_EXHAUSTION4_GROUP, COMBATLOG_XPGAIN_EXHAUSTION5_GROUP
local COMBATLOG_XPGAIN_EXHAUSTION1_RAID, COMBATLOG_XPGAIN_EXHAUSTION2_RAID, COMBATLOG_XPGAIN_EXHAUSTION4_RAID, COMBATLOG_XPGAIN_EXHAUSTION5_RAID = COMBATLOG_XPGAIN_EXHAUSTION1_RAID, COMBATLOG_XPGAIN_EXHAUSTION2_RAID, COMBATLOG_XPGAIN_EXHAUSTION4_RAID, COMBATLOG_XPGAIN_EXHAUSTION5_RAID
local COMBATLOG_XPGAIN_FIRSTPERSON_GROUP, COMBATLOG_XPGAIN_FIRSTPERSON_RAID = COMBATLOG_XPGAIN_FIRSTPERSON_GROUP, COMBATLOG_XPGAIN_FIRSTPERSON_RAID
local MAX_PLAYER_LEVEL = MAX_PLAYER_LEVEL
local GetXPExhaustion = GetXPExhaustion
local UnitXP, UnitXPMax = UnitXP, UnitXPMax
DB.Exp = {
Strings = {
......@@ -52,47 +53,46 @@ DB.Exp = {
}
}
local function UpdateExperience(self, event)
local function UpdateExperience()
if not E.db.sle.databars.experience.longtext then return end
local bar = self.expBar
local bar = EDB.StatusBars.Experience
if not UnitLevel('player') == MAX_PLAYER_LEVEL or not IsXPUserDisabled() then
local cur, max = self:GetXP('player')
local rested = GetXPExhaustion()
local text = ''
if EDB:ExperienceBar_ShouldBeVisible() then
local CurrentXP, XPToLevel, RestedXP = UnitXP('player'), UnitXPMax('player'), GetXPExhaustion()
local textFormat = E.db.databars.experience.textFormat
local text = ''
if rested and rested > 0 then
if RestedXP and RestedXP > 0 then
if textFormat == 'PERCENT' then
text = format('%d%% R:%d%%', cur / max * 100, rested / max * 100)
text = format('%d%% R:%d%%', CurrentXP / XPToLevel * 100, RestedXP / XPToLevel * 100)
elseif textFormat == 'CURMAX' then
text = format('%s - %s R:%s', cur, max, rested)
text = format('%s - %s R:%s', CurrentXP, XPToLevel, RestedXP)
elseif textFormat == 'CURPERC' then
text = format('%s - %d%% R:%s [%d%%]', cur, cur / max * 100, rested, rested / max * 100)
text = format('%s - %d%% R:%s [%d%%]', CurrentXP, CurrentXP / XPToLevel * 100, RestedXP, RestedXP / XPToLevel * 100)
elseif textFormat == 'CUR' then
text = format('%s R:%s', cur, rested)
text = format('%s R:%s', CurrentXP, RestedXP)
elseif textFormat == 'REM' then
text = format('%s R:%s', max - cur, rested)
text = format('%s R:%s', XPToLevel - CurrentXP, RestedXP)
elseif textFormat == 'CURREM' then
text = format('%s - %s R:%s', cur, max - cur, rested)
text = format('%s - %s R:%s', CurrentXP, XPToLevel - CurrentXP, RestedXP)
elseif textFormat == 'CURPERCREM' then
text = format('%s - %d%% (%s) R:%s', cur, cur / max * 100, max - cur, rested)
text = format('%s - %d%% (%s) R:%s', CurrentXP, CurrentXP / XPToLevel * 100, XPToLevel - CurrentXP, RestedXP)
end
else
if textFormat == 'PERCENT' then
text = format('%d%%', cur / max * 100)
text = format('%d%%', CurrentXP / XPToLevel * 100)
elseif textFormat == 'CURMAX' then
text = format('%s - %s', cur, max)
text = format('%s - %s', CurrentXP, XPToLevel)
elseif textFormat == 'CURPERC' then
text = format('%s - %d%%', cur, cur / max * 100)
text = format('%s - %d%%', CurrentXP, CurrentXP / XPToLevel * 100)
elseif textFormat == 'CUR' then
text = format('%s', cur)
text = format('%s', CurrentXP)
elseif textFormat == 'REM' then
text = format('%s', max - cur)
text = format('%s', XPToLevel - CurrentXP)
elseif textFormat == 'CURREM' then
text = format('%s - %s', cur, max - cur)
text = format('%s - %s', CurrentXP, XPToLevel - CurrentXP)
elseif textFormat == 'CURPERCREM' then
text = format('%s - %d%% (%s)', cur, cur / max * 100, max - cur)
text = format('%s - %d%% (%s)', CurrentXP, CurrentXP / XPToLevel * 100, XPToLevel - CurrentXP)
end
end
......@@ -152,7 +152,7 @@ function DB:PopulateExpPatterns()
tinsert(DB.Exp.Strings.FirstPenalty, pattern)
end
function DB:FilterExperience(event, message, ...)
function DB:FilterExperience(_, message, ...)
local name, exp, bonus, reason, addbonus
if DB.db.experience.chatfilter.enable then
for type, patterns in pairs(DB.Exp.Strings) do
......@@ -174,4 +174,4 @@ end
function DB:ExpInit()
DB:PopulateExpPatterns()
hooksecurefunc(EDB, "ExperienceBar_Update", UpdateExperience)
end
\ No newline at end of file
end
......@@ -19,7 +19,7 @@ local function configTable()
exp = {
order = 1,
type = "group",
name = XP,
name = L["Experience"],
args = {
goElv = {
order = 1,
......@@ -31,36 +31,36 @@ local function configTable()
order = 2,
type = "toggle",
name = L["Full value on Exp Bar"],
get = function() return E.db.sle.databars.exp.longtext end,
set = function(_, value) E.db.sle.databars.exp.longtext = value; EDB:ExperienceBar_Update() end,
get = function() return E.db.sle.databars.experience.longtext end,
set = function(_, value) E.db.sle.databars.experience.longtext = value; EDB:ExperienceBar_Update() end,
},
chatfilters = {
order = 3,
type = "group",
guiInline = true,
name = L["Chat Filters"],
get = function(info) return E.db.sle.databars.exp.chatfilter[ info[#info] ] end,
set = function(info, value) E.db.sle.databars.exp.chatfilter[ info[#info] ] = value; end,
get = function(info) return E.db.sle.databars.experience.chatfilter[ info[#info] ] end,
set = function(info, value) E.db.sle.databars.experience.chatfilter[ info[#info] ] = value; end,
args = {
enable = {
order = 1,
type = "toggle",
name = L["Enable"],
desc = L["Change the message style."],
set = function(info, value) E.db.sle.databars.exp.chatfilter[ info[#info] ] = value; DB:RegisterFilters() end,
set = function(info, value) E.db.sle.databars.experience.chatfilter[ info[#info] ] = value; DB:RegisterFilters() end,
},
iconsize = {
order = 2,
type = "range",
name = L["Icon Size"],
disabled = function() return not E.db.sle.databars.exp.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.experience.chatfilter.enable end,
min = 8, max = 32, step = 1,
},
style = {
order = 3,
type = "select",
name = L["Experience Style"],
disabled = function() return not E.db.sle.databars.exp.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.experience.chatfilter.enable end,
values = {
["STYLE1"] = format(DB.Exp.Styles["STYLE1"]["Bonus"], 12, E.myname, 300, 150, SCENARIO_BONUS_LABEL),
["STYLE2"] = format(DB.Exp.Styles["STYLE2"]["Bonus"], 12, E.myname, 300, 150, SCENARIO_BONUS_LABEL),
......@@ -71,50 +71,50 @@ local function configTable()
},
},
rep = {
order = 2,
order = 1,
type = "group",
name = REPUTATION,
name = L["Reputation"],
args = {
goElv = {
order = 1,
type = 'execute',
name = "ElvUI: "..REPUTATION,
name = "ElvUI: "..L["Reputation"],
func = function() E.Libs["AceConfigDialog"]:SelectGroup("ElvUI", "databars", "reputation") end,
},
longtext = {
order = 2,
type = "toggle",
name = L["Full value on Rep Bar"],
get = function() return E.db.sle.databars.rep.longtext end,
set = function(_, value) E.db.sle.databars.rep.longtext = value; EDB:ReputationBar_Update() end,
get = function() return E.db.sle.databars.reputation.longtext end,
set = function(_, value) E.db.sle.databars.reputation.longtext = value; EDB:ReputationBar_Update() end,
},
chatfilters = {
order = 5,
type = "group",
guiInline = true,
name = L["Chat Filters"],
get = function(info) return E.db.sle.databars.rep.chatfilter[ info[#info] ] end,
set = function(info, value) E.db.sle.databars.rep.chatfilter[ info[#info] ] = value; end,
get = function(info) return E.db.sle.databars.reputation.chatfilter[ info[#info] ] end,
set = function(info, value) E.db.sle.databars.reputation.chatfilter[ info[#info] ] = value; end,
args = {
enable = {
order = 1,
type = "toggle",
name = L["Enable"],
desc = L["Change the message style."],
set = function(info, value) E.db.sle.databars.rep.chatfilter[ info[#info] ] = value; DB:RegisterFilters() end,
set = function(info, value) E.db.sle.databars.reputation.chatfilter[ info[#info] ] = value; DB:RegisterFilters() end,
},
iconsize = {
order = 2,
type = "range",
name = L["Icon Size"],
disabled = function() return not E.db.sle.databars.rep.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.reputation.chatfilter.enable end,
min = 8, max = 32, step = 1,
},
style = {
order = 3,
type = "select",
name = L["Reputation increase Style"],
disabled = function() return not E.db.sle.databars.rep.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.reputation.chatfilter.enable end,
values = {
["STYLE1"] = format(DB.RepIncreaseStyles["STYLE1"], 12, FACTION, 300),
["STYLE2"] = format(DB.RepIncreaseStyles["STYLE2"], 12, FACTION, 300),
......@@ -124,7 +124,7 @@ local function configTable()
order = 4,
type = "select",
name = L["Reputation decrease Style"],
disabled = function() return not E.db.sle.databars.rep.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.reputation.chatfilter.enable end,
values = {
["STYLE1"] = format(DB.RepDecreaseStyles["STYLE1"], 12, FACTION, 300),
["STYLE2"] = format(DB.RepDecreaseStyles["STYLE2"], 12, FACTION, 300),
......@@ -135,14 +135,14 @@ local function configTable()
type = "toggle",
name = L["Full List"],
desc = L["Show all factions affected by the latest reputation change. When disabled only first (in alphabetical order) affected faction will be shown."],
disabled = function() return not E.db.sle.databars.rep.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.reputation.chatfilter.enable end,
},
chatframe = {
order = 6,
type = "select",
name = L["Output"],
desc = L["Determines in which frame reputation messages will be shown. Auto is for whatever frame has reputation messages enabled via Blizzard options."],
disabled = function() return not E.db.sle.databars.rep.chatfilter.enable end,
disabled = function() return not E.db.sle.databars.reputation.chatfilter.enable end,
values = {
["AUTO"] = L["Auto"],
["ChatFrame1"] = L["Frame 1"],
......@@ -162,7 +162,7 @@ local function configTable()
},
},
honor = {
order = 3,
order = 1,
type = "group",
name = HONOR,
args = {
......@@ -239,9 +239,9 @@ local function configTable()
},
},
azerite = {
order = 4,
order = 1,
type = "group",
name = L["Azerite Bar"],
name = L["Azerite"],
args = {
goElv = {
order = 1,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment