Allow for theme to be toggleable in-game
Refactored UI code to run after variables are loaded so that this information can be retrieved before the UI is constructed
This commit is contained in:
+12
-7
@@ -2,8 +2,7 @@ module 'aux'
|
|||||||
|
|
||||||
local T = require 'T'
|
local T = require 'T'
|
||||||
local post = require 'aux.tabs.post'
|
local post = require 'aux.tabs.post'
|
||||||
|
local gui = require 'aux.gui'
|
||||||
M.USE_BLIZZARD_THEME = true
|
|
||||||
|
|
||||||
M.print = T.vararg-function(arg)
|
M.print = T.vararg-function(arg)
|
||||||
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '<aux> ' .. join(map(arg, tostring), ' '))
|
DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '<aux> ' .. join(map(arg, tostring), ' '))
|
||||||
@@ -24,12 +23,15 @@ local set_handler = {}
|
|||||||
M.handle = setmetatable({}, {__metatable=false, __newindex=function(_, k, v) set_handler[k](v) end})
|
M.handle = setmetatable({}, {__metatable=false, __newindex=function(_, k, v) set_handler[k](v) end})
|
||||||
|
|
||||||
do
|
do
|
||||||
local handlers, handlers2 = {}, {}
|
local handlers_INIT_UI, handlers_LOAD, handlers_LOAD2 = {}, {}, {}
|
||||||
|
function set_handler.INIT_UI(f)
|
||||||
|
tinsert(handlers_INIT_UI, f)
|
||||||
|
end
|
||||||
function set_handler.LOAD(f)
|
function set_handler.LOAD(f)
|
||||||
tinsert(handlers, f)
|
tinsert(handlers_LOAD, f)
|
||||||
end
|
end
|
||||||
function set_handler.LOAD2(f)
|
function set_handler.LOAD2(f)
|
||||||
tinsert(handlers2, f)
|
tinsert(handlers_LOAD2, f)
|
||||||
end
|
end
|
||||||
event_frame:SetScript('OnEvent', function()
|
event_frame:SetScript('OnEvent', function()
|
||||||
if event == 'ADDON_LOADED' then
|
if event == 'ADDON_LOADED' then
|
||||||
@@ -37,9 +39,11 @@ do
|
|||||||
auction_ui_loaded()
|
auction_ui_loaded()
|
||||||
end
|
end
|
||||||
elseif event == 'VARIABLES_LOADED' then
|
elseif event == 'VARIABLES_LOADED' then
|
||||||
for _, f in handlers do f() end
|
gui.set_global_theme(aux and aux.account.theme)
|
||||||
|
for _, f in handlers_INIT_UI do f() end
|
||||||
|
for _, f in handlers_LOAD do f() end
|
||||||
elseif event == 'PLAYER_LOGIN' then
|
elseif event == 'PLAYER_LOGIN' then
|
||||||
for _, f in handlers2 do f() end
|
for _, f in handlers_LOAD2 do f() end
|
||||||
print('loaded - /aux')
|
print('loaded - /aux')
|
||||||
else
|
else
|
||||||
_M[event]()
|
_M[event]()
|
||||||
@@ -68,6 +72,7 @@ function handle.LOAD()
|
|||||||
merchant_buy = {},
|
merchant_buy = {},
|
||||||
merchant_sell = {},
|
merchant_sell = {},
|
||||||
sharing = true,
|
sharing = true,
|
||||||
|
theme = 'blizzard',
|
||||||
})
|
})
|
||||||
do
|
do
|
||||||
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
|
local key = format('%s|%s', GetCVar'realmName', UnitName'player')
|
||||||
|
|||||||
@@ -4,11 +4,16 @@ local T = require 'T'
|
|||||||
local aux = require 'aux'
|
local aux = require 'aux'
|
||||||
local info = require 'aux.util.info'
|
local info = require 'aux.util.info'
|
||||||
local post = require 'aux.tabs.post'
|
local post = require 'aux.tabs.post'
|
||||||
|
local gui = require 'aux.gui'
|
||||||
|
|
||||||
function status(enabled)
|
function status(enabled)
|
||||||
return (enabled and aux.color.green'on' or aux.color.red'off')
|
return (enabled and aux.color.green'on' or aux.color.red'off')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function warn_reload()
|
||||||
|
aux.print(aux.color.orange('A relog or reload is required for this change to take effect.'))
|
||||||
|
end
|
||||||
|
|
||||||
_G.SLASH_AUX1 = '/aux'
|
_G.SLASH_AUX1 = '/aux'
|
||||||
function SlashCmdList.AUX(command)
|
function SlashCmdList.AUX(command)
|
||||||
if not command then return end
|
if not command then return end
|
||||||
@@ -27,6 +32,7 @@ function SlashCmdList.AUX(command)
|
|||||||
elseif arguments[1] == 'post' and arguments[2] == 'bid' then
|
elseif arguments[1] == 'post' and arguments[2] == 'bid' then
|
||||||
aux.account_data.post_bid = not aux.account_data.post_bid
|
aux.account_data.post_bid = not aux.account_data.post_bid
|
||||||
aux.print('post bid ' .. status(aux.account_data.post_bid))
|
aux.print('post bid ' .. status(aux.account_data.post_bid))
|
||||||
|
warn_reload()
|
||||||
elseif arguments[1] == 'post' and arguments[2] == 'duration' and T.map('6', post.DURATION_2, '24', post.DURATION_8, '72', post.DURATION_24)[arguments[3]] then
|
elseif arguments[1] == 'post' and arguments[2] == 'duration' and T.map('6', post.DURATION_2, '24', post.DURATION_8, '72', post.DURATION_24)[arguments[3]] then
|
||||||
aux.account_data.post_duration = T.map('6', post.DURATION_2, '24', post.DURATION_8, '72', post.DURATION_24)[arguments[3]]
|
aux.account_data.post_duration = T.map('6', post.DURATION_2, '24', post.DURATION_8, '72', post.DURATION_24)[arguments[3]]
|
||||||
aux.print('post duration ' .. aux.color.blue(aux.account_data.post_duration / 60 * 3 .. 'h'))
|
aux.print('post duration ' .. aux.color.blue(aux.account_data.post_duration / 60 * 3 .. 'h'))
|
||||||
@@ -61,6 +67,10 @@ function SlashCmdList.AUX(command)
|
|||||||
elseif arguments[1] == 'sharing' then
|
elseif arguments[1] == 'sharing' then
|
||||||
aux.account_data.sharing = not aux.account_data.sharing
|
aux.account_data.sharing = not aux.account_data.sharing
|
||||||
aux.print('sharing ' .. status(aux.account_data.sharing))
|
aux.print('sharing ' .. status(aux.account_data.sharing))
|
||||||
|
elseif arguments[1] == 'theme' and (arguments[2] == 'default' or arguments[2] == 'blizzard') then
|
||||||
|
aux.account_data.theme = arguments[2]
|
||||||
|
aux.print('theme ' .. aux.color.blue(aux.account_data.theme))
|
||||||
|
warn_reload()
|
||||||
elseif arguments[1] == 'show' and arguments[2] == 'hidden' then
|
elseif arguments[1] == 'show' and arguments[2] == 'hidden' then
|
||||||
aux.account_data.showhidden = not aux.account_data.showhidden
|
aux.account_data.showhidden = not aux.account_data.showhidden
|
||||||
aux.print('show hidden ' .. status(aux.account_data.showhidden))
|
aux.print('show hidden ' .. status(aux.account_data.showhidden))
|
||||||
@@ -81,6 +91,8 @@ function SlashCmdList.AUX(command)
|
|||||||
aux.print('- clear item cache')
|
aux.print('- clear item cache')
|
||||||
aux.print('- populate wdb')
|
aux.print('- populate wdb')
|
||||||
aux.print('- sharing [' .. status(aux.account_data.sharing) .. ']')
|
aux.print('- sharing [' .. status(aux.account_data.sharing) .. ']')
|
||||||
|
aux.print('- theme [' .. aux.color[gui.is_blizzard() and 'red' or 'green']('default') .. ' | ' ..
|
||||||
|
aux.color[gui.is_blizzard() and 'green' or 'red']('blizzard') .. ']')
|
||||||
aux.print('- show hidden [' .. status(aux.account_data.showhidden) .. ']')
|
aux.print('- show hidden [' .. status(aux.account_data.showhidden) .. ']')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -8,6 +8,7 @@ function handle.LOAD()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function handle.INIT_UI()
|
||||||
do
|
do
|
||||||
local frame = CreateFrame('Frame', 'aux_frame', UIParent)
|
local frame = CreateFrame('Frame', 'aux_frame', UIParent)
|
||||||
tinsert(UISpecialFrames, 'aux_frame')
|
tinsert(UISpecialFrames, 'aux_frame')
|
||||||
@@ -63,3 +64,4 @@ do
|
|||||||
if AuctionFrame:IsVisible() then HideUIPanel(AuctionFrame) else ShowUIPanel(AuctionFrame) end
|
if AuctionFrame:IsVisible() then HideUIPanel(AuctionFrame) else ShowUIPanel(AuctionFrame) end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
+7
-1
@@ -107,8 +107,14 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local using_blizzard_theme = false
|
||||||
|
|
||||||
|
function M.set_global_theme(theme)
|
||||||
|
using_blizzard_theme = theme == 'blizzard'
|
||||||
|
end
|
||||||
|
|
||||||
function M.is_blizzard()
|
function M.is_blizzard()
|
||||||
return aux.USE_BLIZZARD_THEME
|
return using_blizzard_theme
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.set_size(frame, width, height)
|
function M.set_size(frame, width, height)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local gui = require 'aux.gui'
|
|||||||
local auction_listing = require 'aux.gui.auction_listing'
|
local auction_listing = require 'aux.gui.auction_listing'
|
||||||
local search_tab = require 'aux.tabs.search'
|
local search_tab = require 'aux.tabs.search'
|
||||||
|
|
||||||
|
function aux.handle.INIT_UI()
|
||||||
frame = CreateFrame('Frame', nil, aux.frame)
|
frame = CreateFrame('Frame', nil, aux.frame)
|
||||||
frame:SetAllPoints()
|
frame:SetAllPoints()
|
||||||
frame:SetScript('OnUpdate', on_update)
|
frame:SetScript('OnUpdate', on_update)
|
||||||
@@ -60,3 +61,4 @@ do
|
|||||||
scan_auctions()
|
scan_auctions()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@@ -6,6 +6,7 @@ local gui = require 'aux.gui'
|
|||||||
local auction_listing = require 'aux.gui.auction_listing'
|
local auction_listing = require 'aux.gui.auction_listing'
|
||||||
local search_tab = require 'aux.tabs.search'
|
local search_tab = require 'aux.tabs.search'
|
||||||
|
|
||||||
|
function aux.handle.INIT_UI()
|
||||||
frame = CreateFrame('Frame', nil, aux.frame)
|
frame = CreateFrame('Frame', nil, aux.frame)
|
||||||
frame:SetAllPoints()
|
frame:SetAllPoints()
|
||||||
frame:SetScript('OnUpdate', on_update)
|
frame:SetScript('OnUpdate', on_update)
|
||||||
@@ -69,3 +70,4 @@ do
|
|||||||
scan_bids()
|
scan_bids()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@@ -8,6 +8,7 @@ local listing = require 'aux.gui.listing'
|
|||||||
local item_listing = require 'aux.gui.item_listing'
|
local item_listing = require 'aux.gui.item_listing'
|
||||||
local search_tab = require 'aux.tabs.search'
|
local search_tab = require 'aux.tabs.search'
|
||||||
|
|
||||||
|
function aux.handle.INIT_UI()
|
||||||
local THEME_PADDING = gui.is_blizzard() and 6.5 or 2.5
|
local THEME_PADDING = gui.is_blizzard() and 6.5 or 2.5
|
||||||
|
|
||||||
frame = CreateFrame('Frame', nil, aux.frame)
|
frame = CreateFrame('Frame', nil, aux.frame)
|
||||||
@@ -337,3 +338,4 @@ function aux.handle.LOAD()
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@@ -10,6 +10,7 @@ local gui = require 'aux.gui'
|
|||||||
local listing = require 'aux.gui.listing'
|
local listing = require 'aux.gui.listing'
|
||||||
local auction_listing = require 'aux.gui.auction_listing'
|
local auction_listing = require 'aux.gui.auction_listing'
|
||||||
|
|
||||||
|
function aux.handle.INIT_UI()
|
||||||
local FILTER_SPACING = 28.5
|
local FILTER_SPACING = 28.5
|
||||||
local THEME_PADDING = gui.is_blizzard() and 4 or 0
|
local THEME_PADDING = gui.is_blizzard() and 4 or 0
|
||||||
|
|
||||||
@@ -569,3 +570,4 @@ for listing in T.temp-T.set(favorite_searches_listing, recent_searches_listing)
|
|||||||
listing:SetHandler(k, v)
|
listing:SetHandler(k, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user