Skip to content

Commit

Permalink
Added simple stats panel
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Feb 10, 2020
1 parent 423accf commit 409b788
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
globals = {'LibStub', 'RECrystallize_PriceCheck', 'RECrystallize_PriceCheckItemID', 'BUTTON_LAG_AUCTIONHOUSE', 'LANDING_PAGE_REPORT', 'COPPER_PER_SILVER', 'SILVER_PER_GOLD', 'GOLD_AMOUNT_TEXTURE_STRING', 'SILVER_AMOUNT_TEXTURE', 'LE_ITEM_CLASS_RECIPE', 'LE_ITEM_RECIPE_BOOK'}
globals = {'LibStub', 'RECrystallize_PriceCheck', 'RECrystallize_PriceCheckItemID', 'STATISTICS', 'BUTTON_LAG_AUCTIONHOUSE', 'LANDING_PAGE_REPORT', 'COPPER_PER_SILVER', 'SILVER_PER_GOLD', 'GOLD_AMOUNT_TEXTURE_STRING', 'SILVER_AMOUNT_TEXTURE', 'LE_ITEM_CLASS_RECIPE', 'LE_ITEM_RECIPE_BOOK'}
ignore = {'self'}
max_line_length = false
self = false
6 changes: 5 additions & 1 deletion Locale/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ L["Enable this option if scanning is causing disconnects."] = true
L["Data freshness"] = true
L["The number of days after which old data will be deleted."] = true
L["Purge this server database"] = true
L["WARNING! This operation is not reversible!"] = true
L["WARNING! This operation is not reversible!"] = true
L["Previous scan"] = true
L["Next scan available in"] = true
L["Now"] = true
L["Items in database"] = true
116 changes: 69 additions & 47 deletions RECrystallize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ local L = LibStub("AceLocale-3.0"):GetLocale("RECrystallize")
local GUI = LibStub("AceGUI-3.0")
_G.RECrystallize = RE

local time, collectgarbage, hooksecurefunc, strsplit, next, select, pairs, tonumber, floor, print = _G.time, _G.collectgarbage, _G.hooksecurefunc, _G.strsplit, _G.next, _G.select, _G.pairs, _G.tonumber, _G.floor, _G.print
local time, collectgarbage, hooksecurefunc, strsplit, next, select, pairs, tonumber, floor, print, date = _G.time, _G.collectgarbage, _G.hooksecurefunc, _G.strsplit, _G.next, _G.select, _G.pairs, _G.tonumber, _G.floor, _G.print, _G.date
local sMatch, sFormat = _G.string.match, _G.string.format
local tConcat = _G.table.concat
local Round = _G.Round
local PlaySound = _G.PlaySound
local GetCVar = _G.GetCVar
local GetItemInfo = _G.GetItemInfo
local GetItemCount = _G.GetItemCount
local GetRealmName = _G.GetRealmName
Expand Down Expand Up @@ -43,51 +44,6 @@ RE.TooltipItemID = 0
RE.TooltipCount = 0
RE.TooltipCustomCount = -1

RE.AceConfig = {
type = "group",
args = {
minimap = {
name = L["Always display the price of the entire stock"],
desc = L["When enabled the functionality of the SHIFT button will be swapped."],
type = "toggle",
width = "full",
order = 1,
set = function(_, val) RE.Config.AlwaysShowAll = val end,
get = function(_) return RE.Config.AlwaysShowAll end
},
slowscan = {
name = L["Enable slow scanning"],
desc = L["Enable this option if scanning is causing disconnects."],
type = "toggle",
width = "full",
order = 2,
set = function(_, val) RE.Config.SlowScan = val end,
get = function(_) return RE.Config.SlowScan end
},
dbcleanup = {
name = L["Data freshness"],
desc = L["The number of days after which old data will be deleted."],
type = "range",
width = "double",
order = 3,
min = 1,
max = 14,
step = 1,
set = function(_, val) RE.Config.DatabaseCleanup = val * 86400 end,
get = function(_) return RE.Config.DatabaseCleanup / 86400 end
},
dbpurge = {
name = L["Purge this server database"],
desc = L["WARNING! This operation is not reversible!"],
type = "execute",
width = "double",
order = 4,
confirm = true,
func = function() RE.DB[RE.RealmString] = {}; collectgarbage("collect") end
},
}
}

local function ElvUISwag(sender)
if sender == "Livarax-BurningLegion" then
return [[|TInterface\PvPRankBadges\PvPRank09:0|t ]]
Expand Down Expand Up @@ -231,7 +187,73 @@ function RE:OnEvent(self, event, ...)
if RE.DB[RE.RealmString] == nil then
RE.DB[RE.RealmString] = {}
end
_G.LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("RECrystallize", RE.AceConfig)

local AceConfig = {
type = "group",
args = {
minimap = {
name = L["Always display the price of the entire stock"],
desc = L["When enabled the functionality of the SHIFT button will be swapped."],
type = "toggle",
width = "full",
order = 1,
set = function(_, val) RE.Config.AlwaysShowAll = val end,
get = function(_) return RE.Config.AlwaysShowAll end
},
slowscan = {
name = L["Enable slow scanning"],
desc = L["Enable this option if scanning is causing disconnects."],
type = "toggle",
width = "full",
order = 2,
set = function(_, val) RE.Config.SlowScan = val end,
get = function(_) return RE.Config.SlowScan end
},
dbcleanup = {
name = L["Data freshness"],
desc = L["The number of days after which old data will be deleted."],
type = "range",
width = "double",
order = 3,
min = 1,
max = 14,
step = 1,
set = function(_, val) RE.Config.DatabaseCleanup = val * 86400 end,
get = function(_) return RE.Config.DatabaseCleanup / 86400 end
},
dbpurge = {
name = L["Purge this server database"],
desc = L["WARNING! This operation is not reversible!"],
type = "execute",
width = "double",
order = 4,
confirm = true,
func = function() RE.DB[RE.RealmString] = {}; collectgarbage("collect") end
},
separator = {
type = "header",
name = STATISTICS,
order = 5
},
description = {
type = "description",
name = function(_)
local timeLeft = 1200 - (time() - RE.Config.LastScan)
local timeString = timeLeft > 0 and SecondsToTime(timeLeft) or L["Now"]
local timeLast = GetCVar("portal") == "US" and date("%I:%M %p %m/%d/%y", RE.Config.LastScan) or date("%H:%M %d.%m.%y", RE.Config.LastScan)
local s = L["Previous scan"]..": "..timeLast.."\n"..L["Next scan available in"]..": "..timeString.."\n\n"..L["Items in database"]..":\n"

for server, data in pairs(RE.DB) do
s = s..server.." - "..tCount(data).."\n"
end

return s
end,
order = 6
}
}
}
_G.LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("RECrystallize", AceConfig)
_G.LibStub("AceConfigDialog-3.0"):AddToBlizOptions("RECrystallize", "RECrystallize")

if RE.Config.GuildChatPC then
Expand Down

0 comments on commit 409b788

Please sign in to comment.