fix: show money for all characters

This commit is contained in:
Salikh Gurgenidze
2025-11-16 15:41:03 +04:00
parent af2483ff05
commit 12e55039f3
9 changed files with 66 additions and 91 deletions
+12 -4
View File
@@ -33,9 +33,11 @@ function DB:Initialize()
showBankInBags = true,
showOtherChars = true,
bagColumns = 10,
bankColumns = 15,
bankBagColumns = 8,
bankColumns = 10,
sortMethod = "quality", -- quality, name, type
iconSize = addon.Constants and addon.Constants.BUTTON_SIZE or 37,
iconSize = 40,
iconSpacing = 0,
iconFontSize = 12,
},
}
@@ -45,11 +47,17 @@ function DB:Initialize()
if not Guda_CharDB.settings.bagColumns then
Guda_CharDB.settings.bagColumns = 10
end
if not Guda_CharDB.settings.bankBagColumns then
Guda_CharDB.settings.bankBagColumns = 8
end
if not Guda_CharDB.settings.bankColumns then
Guda_CharDB.settings.bankColumns = 15
Guda_CharDB.settings.bankColumns = 10
end
if not Guda_CharDB.settings.iconSize then
Guda_CharDB.settings.iconSize = addon.Constants and addon.Constants.BUTTON_SIZE or 37
Guda_CharDB.settings.iconSize = 40
end
if not Guda_CharDB.settings.iconSpacing then
Guda_CharDB.settings.iconSpacing = 0
end
if not Guda_CharDB.settings.iconFontSize then
Guda_CharDB.settings.iconFontSize = 12
+5 -3
View File
@@ -47,9 +47,11 @@ addon.Constants = {
SAVE_INTERVAL = 1800, -- 30 minutes in seconds
-- UI Constants
BUTTON_SIZE = 37,
BUTTON_SPACING = 4,
BUTTONS_PER_ROW = 8,
BUTTON_SIZE = 40,
BUTTON_SPACING = 0,
BUTTONS_PER_ROW = 10,
MIN_ICON_SIZE = 30,
MAX_ICON_SIZE = 64,
}
-- Initialize modules storage
+6 -38
View File
@@ -6,24 +6,9 @@ local addon = Guda
local Main = {}
addon.Modules.Main = Main
-- Auto-save timer
local autoSaveFrame = CreateFrame("Frame")
local timeSinceLastSave = 0
local SAVE_INTERVAL = addon.Constants.SAVE_INTERVAL
-- Auto-save update
autoSaveFrame:SetScript("OnUpdate", function()
timeSinceLastSave = timeSinceLastSave + arg1
if timeSinceLastSave >= SAVE_INTERVAL then
Main:AutoSave()
timeSinceLastSave = 0
end
end)
-- Perform auto-save
function Main:AutoSave()
addon:Debug("Auto-saving data...")
-- Manual save function (for slash command)
function Main:SaveData()
addon:Debug("Saving data...")
-- Save bags
addon.Modules.BagScanner:SaveToDatabase()
@@ -36,7 +21,7 @@ function Main:AutoSave()
-- Save money
addon.Modules.MoneyTracker:Update()
addon:Debug("Auto-save complete")
addon:Debug("Save complete")
end
-- Initialize addon
@@ -58,28 +43,11 @@ function Main:Initialize()
addon.Modules.BankFrame:Initialize()
addon.Modules.SettingsPopup:Initialize()
-- Save on logout
addon.Modules.Events:OnPlayerLogout(function()
addon:Print("Saving data on logout...")
Main:AutoSave()
end, "Main")
-- Setup slash commands
Main:SetupSlashCommands()
addon:Debug("Initialization complete")
-- Delay initial save to ensure everything is loaded
local frame = CreateFrame("Frame")
local elapsed = 0
frame:SetScript("OnUpdate", function()
elapsed = elapsed + arg1
if elapsed >= 5 then
frame:SetScript("OnUpdate", nil)
Main:AutoSave()
addon:Print("Ready! Type /guda to open bags")
end
end)
addon:Print("Ready! Type /guda to open bags")
end, "Main")
end
@@ -114,7 +82,7 @@ function Main:SetupSlashCommands()
elseif msg == "save" then
-- Manual save
Main:AutoSave()
Main:SaveData()
addon:Print("Data saved manually")
elseif msg == "debug" then
+2 -19
View File
@@ -78,24 +78,7 @@ function BagScanner:SaveToDatabase()
addon.Modules.DB:SaveBags(bagData)
end
-- Auto-scan on bag updates
-- Initialize (no auto-save, only save when bags are opened)
function BagScanner:Initialize()
addon.Modules.Events:OnBagUpdate(function()
BagScanner:SaveToDatabase()
end, "BagScanner")
-- Initial scan on login
addon.Modules.Events:OnPlayerLogin(function()
-- Delay to ensure bags are loaded
local frame = CreateFrame("Frame")
local elapsed = 0
frame:SetScript("OnUpdate", function()
elapsed = elapsed + arg1
if elapsed >= 1 then
frame:SetScript("OnUpdate", nil)
BagScanner:SaveToDatabase()
addon:Debug("Initial bag scan complete")
end
end)
end, "BagScanner")
addon:Debug("Bag scanner initialized")
end
+1 -8
View File
@@ -61,7 +61,7 @@ end
-- Initialize bank scanner
function BankScanner:Initialize()
-- Bank opened
-- Bank opened - save bank data
addon.Modules.Events:OnBankOpen(function()
bankOpen = true
addon:Debug("Bank opened")
@@ -83,13 +83,6 @@ function BankScanner:Initialize()
bankOpen = false
addon:Debug("Bank closed")
end, "BankScanner")
-- Update on bag changes while bank is open
addon.Modules.Events:OnBagUpdate(function()
if bankOpen then
BankScanner:SaveToDatabase()
end
end, "BankScanner")
end
-- Check if bank is currently open
+3 -7
View File
@@ -31,12 +31,12 @@ end
-- Initialize money tracker
function MoneyTracker:Initialize()
-- Track money changes
-- Track money changes and save immediately
addon.Modules.Events:OnMoneyChanged(function()
MoneyTracker:Update()
end, "MoneyTracker")
-- Initial update on login
-- Initial update and save on login
addon.Modules.Events:OnPlayerLogin(function()
local frame = CreateFrame("Frame")
local elapsed = 0
@@ -45,12 +45,8 @@ function MoneyTracker:Initialize()
if elapsed >= 1 then
frame:SetScript("OnUpdate", nil)
MoneyTracker:Update()
addon:Debug("Initial money saved")
end
end)
end, "MoneyTracker")
-- Save on logout
addon.Modules.Events:OnPlayerLogout(function()
MoneyTracker:Update()
end, "MoneyTracker")
end
+5 -1
View File
@@ -44,6 +44,10 @@ end
-- OnShow
function Guda_BagFrame_OnShow(self)
-- Save bag data when opening bags
addon.Modules.BagScanner:SaveToDatabase()
addon.Modules.MoneyTracker:Update()
-- Restore saved position if it exists (only if saved as BOTTOMRIGHT)
if addon and addon.Modules and addon.Modules.DB then
local pos = addon.Modules.DB:GetSetting("bagFramePosition")
@@ -340,7 +344,7 @@ end
-- Money tooltip handler
function Guda_BagFrame_MoneyOnEnter(self)
GameTooltip:SetOwner(self, "ANCHOR_TOP")
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM")
GameTooltip:ClearLines()
-- Get all characters and total
+25 -4
View File
@@ -59,8 +59,10 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
-- Resize empty slot background to match icon size (slightly larger to ensure coverage)
if emptySlotBg then
emptySlotBg:ClearAllPoints()
emptySlotBg:SetPoint("TOPLEFT", self, "TOPLEFT", -2, 2)
emptySlotBg:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, -2)
-- Use smaller padding for small icons
local bgPadding = iconSize < 44 and 1 or 2
emptySlotBg:SetPoint("TOPLEFT", self, "TOPLEFT", -bgPadding, bgPadding)
emptySlotBg:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", bgPadding, -bgPadding)
-- Crop texture edges slightly to remove any built-in padding
emptySlotBg:SetTexCoord(0.1, 0.9, 0.1, 0.9)
end
@@ -114,6 +116,16 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
local font, _, flags = countText:GetFont()
local fontSize = Guda.Modules.DB:GetSetting("iconFontSize") or 12
countText:SetFont(font, fontSize, flags)
-- Adjust count text position based on icon size for better alignment
countText:ClearAllPoints()
if iconSize < 44 then
-- Smaller offset for small icons
countText:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -3, 3)
else
-- Standard offset for larger icons
countText:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -8, 8)
end
end
if itemData then
@@ -204,8 +216,17 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
if iconTexture then
if self.hasItem then
-- Make icon 3px smaller than slot for nice inset effect
local iconDisplaySize = iconSize - 15
-- Scale icon proportionally based on button size
-- For icons < 44: use smaller inset (4px) for better fit
-- For icons >= 44: use larger inset (15px) for classic look
local iconInset
if iconSize < 44 then
iconInset = 10 -- Small inset for small icons
else
iconInset = 15 -- Larger inset for larger icons
end
local iconDisplaySize = iconSize - iconInset
iconTexture:ClearAllPoints()
iconTexture:SetPoint("CENTER", self, "CENTER", 0, 0)
iconTexture:SetWidth(iconDisplaySize)
+7 -7
View File
@@ -30,10 +30,10 @@ end
function Guda_SettingsPopup_OnShow(self)
-- Load current settings
local bagColumns = Guda.Modules.DB:GetSetting("bagColumns") or 10
local bankColumns = Guda.Modules.DB:GetSetting("bankColumns") or 15
local iconSize = Guda.Modules.DB:GetSetting("iconSize") or addon.Constants.BUTTON_SIZE
local bankColumns = Guda.Modules.DB:GetSetting("bankColumns") or 10
local iconSize = Guda.Modules.DB:GetSetting("iconSize") or 40
local iconFontSize = Guda.Modules.DB:GetSetting("iconFontSize") or 12
local iconSpacing = Guda.Modules.DB:GetSetting("iconSpacing") or 4
local iconSpacing = Guda.Modules.DB:GetSetting("iconSpacing") or 0
local lockBags = Guda.Modules.DB:GetSetting("lockBags")
if lockBags == nil then
lockBags = false
@@ -139,7 +139,7 @@ function Guda_SettingsPopup_BankColumnsSlider_OnLoad(self)
self:SetMinMaxValues(5, 20)
self:SetValueStep(1)
local currentValue = Guda.Modules.DB:GetSetting("bankColumns") or 15
local currentValue = Guda.Modules.DB:GetSetting("bankColumns") or 10
self:SetValue(currentValue)
end
@@ -162,7 +162,7 @@ end
-- Icon Size Slider OnLoad
function Guda_SettingsPopup_IconSizeSlider_OnLoad(self)
getglobal(self:GetName().."Low"):SetText("24px")
getglobal(self:GetName().."Low"):SetText("30px")
getglobal(self:GetName().."High"):SetText("64px")
local text = getglobal(self:GetName().."Text")
@@ -174,7 +174,7 @@ function Guda_SettingsPopup_IconSizeSlider_OnLoad(self)
text:SetFont(font, 12, flags)
end
self:SetMinMaxValues(24, 64)
self:SetMinMaxValues(30, 64)
self:SetValueStep(1)
local currentValue = Guda.Modules.DB:GetSetting("iconSize") or addon.Constants.BUTTON_SIZE
@@ -257,7 +257,7 @@ function Guda_SettingsPopup_IconSpacingSlider_OnLoad(self)
self:SetMinMaxValues(-5, 10)
self:SetValueStep(1)
local currentValue = Guda.Modules.DB:GetSetting("iconSpacing") or 4
local currentValue = Guda.Modules.DB:GetSetting("iconSpacing") or 0
self:SetValue(currentValue)
end