feat: bank item view counter
This commit is contained in:
+65
-44
@@ -14,8 +14,9 @@ end
|
|||||||
|
|
||||||
-- Count items for a specific character
|
-- Count items for a specific character
|
||||||
local function CountItemsForCharacter(itemID, characterData)
|
local function CountItemsForCharacter(itemID, characterData)
|
||||||
local total = 0
|
local bagCount = 0
|
||||||
|
local bankCount = 0
|
||||||
|
|
||||||
-- Count bags
|
-- Count bags
|
||||||
if characterData.bags then
|
if characterData.bags then
|
||||||
for bagID, bagData in pairs(characterData.bags) do
|
for bagID, bagData in pairs(characterData.bags) do
|
||||||
@@ -24,15 +25,31 @@ local function CountItemsForCharacter(itemID, characterData)
|
|||||||
if itemData and itemData.link then
|
if itemData and itemData.link then
|
||||||
local slotItemID = GetItemIDFromLink(itemData.link)
|
local slotItemID = GetItemIDFromLink(itemData.link)
|
||||||
if slotItemID == itemID then
|
if slotItemID == itemID then
|
||||||
total = total + (itemData.count or 1)
|
bagCount = bagCount + (itemData.count or 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return total
|
-- Count bank
|
||||||
|
if characterData.bank then
|
||||||
|
for bagID, bagData in pairs(characterData.bank) do
|
||||||
|
if bagData and bagData.slots then
|
||||||
|
for slotID, itemData in pairs(bagData.slots) do
|
||||||
|
if itemData and itemData.link then
|
||||||
|
local slotItemID = GetItemIDFromLink(itemData.link)
|
||||||
|
if slotItemID == itemID then
|
||||||
|
bankCount = bankCount + (itemData.count or 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return bagCount, bankCount
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get class color
|
-- Get class color
|
||||||
@@ -58,42 +75,55 @@ function Tooltip:AddInventoryInfo(tooltip, link)
|
|||||||
|
|
||||||
addon:Debug("Processing item ID: " .. itemID)
|
addon:Debug("Processing item ID: " .. itemID)
|
||||||
|
|
||||||
local totalCount = 0
|
local totalBags = 0
|
||||||
|
local totalBank = 0
|
||||||
local characterCounts = {}
|
local characterCounts = {}
|
||||||
|
|
||||||
-- Count items across all characters
|
-- Count items across all characters
|
||||||
for charName, charData in pairs(Guda_DB.characters) do
|
for charName, charData in pairs(Guda_DB.characters) do
|
||||||
local count = CountItemsForCharacter(itemID, charData)
|
local bagCount, bankCount = CountItemsForCharacter(itemID, charData)
|
||||||
if count > 0 then
|
if bagCount > 0 or bankCount > 0 then
|
||||||
totalCount = totalCount + count
|
totalBags = totalBags + bagCount
|
||||||
|
totalBank = totalBank + bankCount
|
||||||
table.insert(characterCounts, {
|
table.insert(characterCounts, {
|
||||||
name = charData.name or charName,
|
name = charData.name or charName,
|
||||||
classToken = charData.classToken,
|
classToken = charData.classToken,
|
||||||
count = count
|
bagCount = bagCount,
|
||||||
|
bankCount = bankCount
|
||||||
})
|
})
|
||||||
addon:Debug("Found " .. count .. " items on " .. charName)
|
addon:Debug("Found " .. (bagCount + bankCount) .. " items on " .. charName .. " (Bags: " .. bagCount .. ", Bank: " .. bankCount .. ")")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local totalCount = totalBags + totalBank
|
||||||
|
|
||||||
-- Only add to tooltip if we found items
|
-- Only add to tooltip if we found items
|
||||||
if totalCount > 0 then
|
if totalCount > 0 then
|
||||||
addon:Debug("Adding inventory info - Total: " .. totalCount)
|
addon:Debug("Adding inventory info - Total: " .. totalCount)
|
||||||
|
|
||||||
tooltip:AddLine(" ")
|
tooltip:AddLine(" ")
|
||||||
tooltip:AddLine("Inventory", 0.7, 0.7, 0.7)
|
tooltip:AddLine("Inventory", 0.7, 0.7, 0.7)
|
||||||
tooltip:AddDoubleLine("Total: " .. totalCount, "", 1, 1, 1)
|
tooltip:AddDoubleLine("Total: " .. totalCount, "(Bags: " .. totalBags .. " | Bank: " .. totalBank .. ")", 1, 1, 1, 0.7, 0.7, 0.7)
|
||||||
|
|
||||||
-- Sort characters by name
|
-- Sort characters by name
|
||||||
table.sort(characterCounts, function(a, b)
|
table.sort(characterCounts, function(a, b)
|
||||||
return a.name < b.name
|
return a.name < b.name
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Add character lines
|
-- Add character lines with bag and bank breakdown
|
||||||
for _, charInfo in ipairs(characterCounts) do
|
for _, charInfo in ipairs(characterCounts) do
|
||||||
local r, g, b = GetClassColor(charInfo.classToken)
|
local r, g, b = GetClassColor(charInfo.classToken)
|
||||||
tooltip:AddDoubleLine(charInfo.name, "Bags: " .. charInfo.count, r, g, b, 0.7, 0.7, 0.7)
|
local countText = ""
|
||||||
|
if charInfo.bagCount > 0 and charInfo.bankCount > 0 then
|
||||||
|
countText = "Bags: " .. charInfo.bagCount .. " | Bank: " .. charInfo.bankCount
|
||||||
|
elseif charInfo.bagCount > 0 then
|
||||||
|
countText = "Bags: " .. charInfo.bagCount
|
||||||
|
else
|
||||||
|
countText = "Bank: " .. charInfo.bankCount
|
||||||
|
end
|
||||||
|
tooltip:AddDoubleLine(charInfo.name, countText, r, g, b, 0.7, 0.7, 0.7)
|
||||||
end
|
end
|
||||||
|
|
||||||
tooltip:Show()
|
tooltip:Show()
|
||||||
else
|
else
|
||||||
addon:Debug("No items found for ID: " .. itemID)
|
addon:Debug("No items found for ID: " .. itemID)
|
||||||
@@ -102,7 +132,7 @@ end
|
|||||||
|
|
||||||
function Tooltip:Initialize()
|
function Tooltip:Initialize()
|
||||||
addon:Print("Initializing tooltip module...")
|
addon:Print("Initializing tooltip module...")
|
||||||
|
|
||||||
-- Hook SetBagItem
|
-- Hook SetBagItem
|
||||||
local oldSetBagItem = GameTooltip.SetBagItem
|
local oldSetBagItem = GameTooltip.SetBagItem
|
||||||
function GameTooltip:SetBagItem(bag, slot)
|
function GameTooltip:SetBagItem(bag, slot)
|
||||||
@@ -112,7 +142,7 @@ function Tooltip:Initialize()
|
|||||||
Tooltip:AddInventoryInfo(self, link)
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetHyperlink for chat links
|
-- Hook SetHyperlink for chat links
|
||||||
local oldSetHyperlink = GameTooltip.SetHyperlink
|
local oldSetHyperlink = GameTooltip.SetHyperlink
|
||||||
function GameTooltip:SetHyperlink(link)
|
function GameTooltip:SetHyperlink(link)
|
||||||
@@ -121,7 +151,7 @@ function Tooltip:Initialize()
|
|||||||
Tooltip:AddInventoryInfo(self, link)
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook SetInventoryItem for character paperdoll
|
-- Hook SetInventoryItem for character paperdoll
|
||||||
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
local oldSetInventoryItem = GameTooltip.SetInventoryItem
|
||||||
function GameTooltip:SetInventoryItem(unit, slot)
|
function GameTooltip:SetInventoryItem(unit, slot)
|
||||||
@@ -131,7 +161,7 @@ function Tooltip:Initialize()
|
|||||||
Tooltip:AddInventoryInfo(self, link)
|
Tooltip:AddInventoryInfo(self, link)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Also hook ItemRefTooltip for chat links
|
-- Also hook ItemRefTooltip for chat links
|
||||||
if ItemRefTooltip then
|
if ItemRefTooltip then
|
||||||
local oldItemRefSetHyperlink = ItemRefTooltip.SetHyperlink
|
local oldItemRefSetHyperlink = ItemRefTooltip.SetHyperlink
|
||||||
@@ -148,23 +178,14 @@ function Tooltip:Initialize()
|
|||||||
addon:Debug("Tooltip cache cleared")
|
addon:Debug("Tooltip cache cleared")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register for bag updates in Initialize
|
-- Clear cache on bag updates
|
||||||
function Tooltip:Initialize()
|
local frame = CreateFrame("Frame")
|
||||||
addon:Print("Initializing tooltip module...")
|
frame:RegisterEvent("BAG_UPDATE")
|
||||||
|
frame:SetScript("OnEvent", function()
|
||||||
-- Your existing hook code...
|
if event == "BAG_UPDATE" then
|
||||||
|
Tooltip:ClearCache()
|
||||||
-- Clear cache on bag updates
|
end
|
||||||
local frame = CreateFrame("Frame")
|
end)
|
||||||
frame:RegisterEvent("BAG_UPDATE")
|
|
||||||
frame:SetScript("OnEvent", function()
|
|
||||||
if event == "BAG_UPDATE" then
|
|
||||||
Tooltip:ClearCache()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
addon:Print("Tooltip item-count integration enabled")
|
|
||||||
end
|
|
||||||
|
|
||||||
addon:Print("Tooltip item-count integration enabled")
|
addon:Print("Tooltip item-count integration enabled")
|
||||||
end
|
end
|
||||||
@@ -5,32 +5,31 @@ A comprehensive bag and bank management addon for Turtle WoW (1.12.1).
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
### 🎒 Bag Management
|
### 🎒 Bag Management
|
||||||
|
|
||||||
- **Unified Bag View**: All your bags in one window
|
- **Unified Bag View**: All your bags in one window
|
||||||
- **Smart Sorting**: Sort by quality, name, or item type
|
- **Smart Sorting**: Sort by quality, name, or item type
|
||||||
- **Search Functionality**: Quickly find items with the search box
|
- **Search Functionality**: Quickly find items with the search box
|
||||||
- **Quality Borders**: Visual quality indicators on items
|
- **Quality Borders**: Visual quality indicators on items
|
||||||
|
|
||||||
### 🏦 Bank Management
|
### 🏦 Bank Management
|
||||||
|
|
||||||
- **Bank Viewing**: View your bank from anywhere (cached data)
|
- **Bank Viewing**: View your bank from anywhere (cached data)
|
||||||
- **Bank Sorting**: Organize your bank with one click
|
- **Bank Sorting**: Organize your bank with one click
|
||||||
- **Persistent Storage**: Bank contents saved and viewable offline
|
- **Persistent Storage**: Bank contents saved and viewable offline
|
||||||
|
|
||||||
### 👥 Multi-Character Support
|
### 👥 Multi-Character Support
|
||||||
|
|
||||||
- **Cross-Character Viewing**: View any character's bags and bank
|
- **Cross-Character Viewing**: View any character's bags and bank
|
||||||
- **Money Tracking**: See total gold across all characters
|
- **Money Tracking**: See total gold across all characters
|
||||||
- **Character Selector**: Easy switching between characters
|
- **Character Selector**: Easy switching between characters
|
||||||
- **Faction Filtering**: Only shows characters of the same faction
|
- **Faction Filtering**: Only shows characters of the same faction
|
||||||
|
|
||||||
### 💰 Money Display
|
### 💰 Money Display
|
||||||
|
|
||||||
- **Current Character**: Shows your current gold/silver/copper
|
- **Current Character**: Shows your current gold/silver/copper
|
||||||
- **Total Money**: Displays combined wealth across all characters
|
- **Total Money**: Displays combined wealth across all characters
|
||||||
- **Per-Character**: View each character's money in the selector
|
- **Per-Character**: View each character's money in the selector
|
||||||
|
|
||||||
### 💾 Auto-Save System
|
|
||||||
- **Auto-Save**: Automatically saves every 30 minutes
|
|
||||||
- **Logout Save**: Saves all data when you log out
|
|
||||||
- **Manual Save**: `/guda save` to save anytime
|
|
||||||
|
|
||||||
## Slash Commands
|
## Slash Commands
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -50,18 +49,21 @@ A comprehensive bag and bank management addon for Turtle WoW (1.12.1).
|
|||||||
## How to Use
|
## How to Use
|
||||||
|
|
||||||
### Basic Usage
|
### Basic Usage
|
||||||
|
|
||||||
1. Press **B** or type `/guda` to open your bags
|
1. Press **B** or type `/guda` to open your bags
|
||||||
2. Click **Characters** button to view other characters
|
2. Click **Characters** button to view other characters
|
||||||
3. Click **Bank** button to view your bank (cached)
|
3. Click **Bank** button to view your bank (cached)
|
||||||
4. Click **Sort** to organize your bags
|
4. Click **Sort** to organize your bags
|
||||||
|
|
||||||
### Viewing Other Characters
|
### Viewing Other Characters
|
||||||
|
|
||||||
1. Type `/guda chars` or click the **Characters** button
|
1. Type `/guda chars` or click the **Characters** button
|
||||||
2. Select a character from the list
|
2. Select a character from the list
|
||||||
3. View their bags and bank contents
|
3. View their bags and bank contents
|
||||||
4. Click **Current Character** to return to your bags
|
4. Click **Current Character** to return to your bags
|
||||||
|
|
||||||
### Sorting
|
### Sorting
|
||||||
|
|
||||||
- **Sort Bags**: Click the **Sort** button or `/guda sort`
|
- **Sort Bags**: Click the **Sort** button or `/guda sort`
|
||||||
- **Sort Bank**: Click **Sort Bank** button (must be at bank) or `/guda sortbank`
|
- **Sort Bank**: Click **Sort Bank** button (must be at bank) or `/guda sortbank`
|
||||||
- **Sort Methods**: Quality (default), Name, or Type
|
- **Sort Methods**: Quality (default), Name, or Type
|
||||||
@@ -72,22 +74,26 @@ A comprehensive bag and bank management addon for Turtle WoW (1.12.1).
|
|||||||
## Features in Detail
|
## Features in Detail
|
||||||
|
|
||||||
### Bag Scanner
|
### Bag Scanner
|
||||||
|
|
||||||
- Automatically scans bags on login and updates
|
- Automatically scans bags on login and updates
|
||||||
- Tracks all items with full details (name, quality, count, etc.)
|
- Tracks all items with full details (name, quality, count, etc.)
|
||||||
- Updates in real-time as you loot/move items
|
- Updates in real-time as you loot/move items
|
||||||
|
|
||||||
### Bank Scanner
|
### Bank Scanner
|
||||||
|
|
||||||
- Scans bank when you open it
|
- Scans bank when you open it
|
||||||
- Saves bank contents for offline viewing
|
- Saves bank contents for offline viewing
|
||||||
- Updates automatically while bank is open
|
- Updates automatically while bank is open
|
||||||
|
|
||||||
### Money Tracker
|
### Money Tracker
|
||||||
|
|
||||||
- Tracks money changes in real-time
|
- Tracks money changes in real-time
|
||||||
- Shows current character money
|
- Shows current character money
|
||||||
- Calculates total across all characters
|
- Calculates total across all characters
|
||||||
- Per-character money in character selector
|
- Per-character money in character selector
|
||||||
|
|
||||||
### Data Storage
|
### Data Storage
|
||||||
|
|
||||||
- Saves to `Guda_DB` (global)
|
- Saves to `Guda_DB` (global)
|
||||||
- Character settings in `Guda_CharDB`
|
- Character settings in `Guda_CharDB`
|
||||||
- Persistent across sessions
|
- Persistent across sessions
|
||||||
@@ -96,6 +102,7 @@ A comprehensive bag and bank management addon for Turtle WoW (1.12.1).
|
|||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Currently all configuration is automatic. Future versions may include:
|
Currently all configuration is automatic. Future versions may include:
|
||||||
|
|
||||||
- Customizable sort methods
|
- Customizable sort methods
|
||||||
- Buttons per row
|
- Buttons per row
|
||||||
- Filter options
|
- Filter options
|
||||||
@@ -114,6 +121,7 @@ Currently all configuration is automatic. Future versions may include:
|
|||||||
## Technical Details
|
## Technical Details
|
||||||
|
|
||||||
### Saved Variables
|
### Saved Variables
|
||||||
|
|
||||||
- `Guda_DB`: Global database (all characters)
|
- `Guda_DB`: Global database (all characters)
|
||||||
- Character data (bags, bank, money)
|
- Character data (bags, bank, money)
|
||||||
- Last update timestamps
|
- Last update timestamps
|
||||||
@@ -122,11 +130,13 @@ Currently all configuration is automatic. Future versions may include:
|
|||||||
- Sort method
|
- Sort method
|
||||||
|
|
||||||
### Auto-Save Schedule
|
### Auto-Save Schedule
|
||||||
|
|
||||||
- Every 30 minutes while playing
|
- Every 30 minutes while playing
|
||||||
- On player logout
|
- On player logout
|
||||||
- Manual: `/guda save`
|
- Manual: `/guda save`
|
||||||
|
|
||||||
### Events Monitored
|
### Events Monitored
|
||||||
|
|
||||||
- `BAG_UPDATE`: Bag content changes
|
- `BAG_UPDATE`: Bag content changes
|
||||||
- `BANKFRAME_OPENED`: Bank opened
|
- `BANKFRAME_OPENED`: Bank opened
|
||||||
- `BANKFRAME_CLOSED`: Bank closed
|
- `BANKFRAME_CLOSED`: Bank closed
|
||||||
@@ -146,6 +156,7 @@ For bugs or feature requests, please report them in-game or on the forums.
|
|||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### Version 1.0.0
|
### Version 1.0.0
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
||||||
- Bag viewing and sorting
|
- Bag viewing and sorting
|
||||||
- Bank viewing and sorting
|
- Bank viewing and sorting
|
||||||
|
|||||||
+46
-30
@@ -86,8 +86,17 @@ end
|
|||||||
|
|
||||||
-- OnHide
|
-- OnHide
|
||||||
function Guda_BagFrame_OnHide(self)
|
function Guda_BagFrame_OnHide(self)
|
||||||
-- Release buttons
|
-- Only release buttons that belong to this frame
|
||||||
Guda_ReleaseAllButtons()
|
local itemContainer = getglobal("Guda_BagFrame_ItemContainer")
|
||||||
|
if itemContainer then
|
||||||
|
local children = { itemContainer:GetChildren() }
|
||||||
|
for _, child in ipairs(children) do
|
||||||
|
if child.hasItem ~= nil then -- It's an item button
|
||||||
|
child:Hide()
|
||||||
|
child:ClearAllPoints()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Toggle visibility
|
-- Toggle visibility
|
||||||
@@ -117,8 +126,17 @@ function BagFrame:Update()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clear existing buttons
|
-- Only release buttons that belong to this frame
|
||||||
Guda_ReleaseAllButtons()
|
local itemContainer = getglobal("Guda_BagFrame_ItemContainer")
|
||||||
|
if itemContainer then
|
||||||
|
local children = { itemContainer:GetChildren() }
|
||||||
|
for _, child in ipairs(children) do
|
||||||
|
if child.hasItem ~= nil then -- It's an item button
|
||||||
|
child:Hide()
|
||||||
|
child:ClearAllPoints()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local bagData
|
local bagData
|
||||||
local isOtherChar = false
|
local isOtherChar = false
|
||||||
@@ -441,10 +459,8 @@ function BagFrame:UpdateBagSlotsInfo(bagData, isOtherChar)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local freeSlots = totalSlots - usedSlots
|
-- Format: "24 / 80" (used / total)
|
||||||
|
infoText:SetText(string.format("%d / %d", usedSlots, totalSlots))
|
||||||
-- Format: "56 / 80" (free / total)
|
|
||||||
infoText:SetText(string.format("%d / %d", freeSlots, totalSlots))
|
|
||||||
infoText:SetTextColor(0.7, 0.7, 0.7)
|
infoText:SetTextColor(0.7, 0.7, 0.7)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -489,6 +505,28 @@ function BagFrame:SetupToolbarTooltip()
|
|||||||
addon:Debug("Toolbar tooltip handlers set up")
|
addon:Debug("Toolbar tooltip handlers set up")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Save bag frame position (always as BOTTOMRIGHT)
|
||||||
|
local function SaveBagFramePosition()
|
||||||
|
local frame = getglobal("Guda_BagFrame")
|
||||||
|
if not frame or not addon or not addon.Modules or not addon.Modules.DB then return end
|
||||||
|
|
||||||
|
-- Always save as BOTTOMRIGHT coordinates
|
||||||
|
local right = frame:GetRight()
|
||||||
|
local bottom = frame:GetBottom()
|
||||||
|
local screenWidth = GetScreenWidth()
|
||||||
|
|
||||||
|
if right and bottom and screenWidth then
|
||||||
|
local xOffset = right - screenWidth
|
||||||
|
local yOffset = bottom
|
||||||
|
|
||||||
|
addon.Modules.DB:SetSetting("bagFramePosition", {
|
||||||
|
point = "BOTTOMRIGHT",
|
||||||
|
x = xOffset,
|
||||||
|
y = yOffset
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Create transparent overlay for money tooltip
|
-- Create transparent overlay for money tooltip
|
||||||
function BagFrame:EnsureMoneyTooltipOverlay()
|
function BagFrame:EnsureMoneyTooltipOverlay()
|
||||||
local overlayName = "Guda_BagFrame_MoneyTooltipOverlay"
|
local overlayName = "Guda_BagFrame_MoneyTooltipOverlay"
|
||||||
@@ -1006,28 +1044,6 @@ local function HookDefaultBags()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Save bag frame position (always as BOTTOMRIGHT)
|
|
||||||
local function SaveBagFramePosition()
|
|
||||||
local frame = getglobal("Guda_BagFrame")
|
|
||||||
if not frame or not addon or not addon.Modules or not addon.Modules.DB then return end
|
|
||||||
|
|
||||||
-- Always save as BOTTOMRIGHT coordinates
|
|
||||||
local right = frame:GetRight()
|
|
||||||
local bottom = frame:GetBottom()
|
|
||||||
local screenWidth = GetScreenWidth()
|
|
||||||
|
|
||||||
if right and bottom and screenWidth then
|
|
||||||
local xOffset = right - screenWidth
|
|
||||||
local yOffset = bottom
|
|
||||||
|
|
||||||
addon.Modules.DB:SetSetting("bagFramePosition", {
|
|
||||||
point = "BOTTOMRIGHT",
|
|
||||||
x = xOffset,
|
|
||||||
y = yOffset
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update lock state (controls whether frame is draggable)
|
-- Update lock state (controls whether frame is draggable)
|
||||||
function BagFrame:UpdateLockState()
|
function BagFrame:UpdateLockState()
|
||||||
-- Safety check: ensure addon and modules exist
|
-- Safety check: ensure addon and modules exist
|
||||||
|
|||||||
+307
-17
@@ -8,6 +8,7 @@ addon.Modules.BankFrame = BankFrame
|
|||||||
|
|
||||||
local currentViewChar = nil
|
local currentViewChar = nil
|
||||||
local searchText = ""
|
local searchText = ""
|
||||||
|
local isReadOnlyMode = false -- Track if viewing saved bank (read-only) or live bank (interactive)
|
||||||
|
|
||||||
-- OnLoad
|
-- OnLoad
|
||||||
function Guda_BankFrame_OnLoad(self)
|
function Guda_BankFrame_OnLoad(self)
|
||||||
@@ -51,15 +52,17 @@ function BankFrame:Toggle()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Show specific character's bank
|
-- Show specific character's bank (read-only mode)
|
||||||
function BankFrame:ShowCharacter(fullName)
|
function BankFrame:ShowCharacter(fullName)
|
||||||
currentViewChar = fullName
|
currentViewChar = fullName
|
||||||
|
isReadOnlyMode = true -- Viewing saved bank data (read-only)
|
||||||
self:Update()
|
self:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Show current character's bank
|
-- Show current character's bank (interactive mode)
|
||||||
function BankFrame:ShowCurrentCharacter()
|
function BankFrame:ShowCurrentCharacter()
|
||||||
currentViewChar = nil
|
currentViewChar = nil
|
||||||
|
isReadOnlyMode = false -- Viewing live bank (interactive)
|
||||||
self:Update()
|
self:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,27 +84,42 @@ function BankFrame:Update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Determine if we're in read-only mode:
|
||||||
|
-- - If viewing another character → read-only
|
||||||
|
-- - If bank is actually open → interactive (live)
|
||||||
|
-- - Otherwise → read-only (viewing saved data)
|
||||||
|
local bankIsOpen = addon.Modules.BankScanner:IsBankOpen()
|
||||||
|
isReadOnlyMode = currentViewChar ~= nil or not bankIsOpen
|
||||||
|
|
||||||
local bankData
|
local bankData
|
||||||
local isOtherChar = false
|
local isOtherChar = false
|
||||||
local charName = ""
|
local charName = ""
|
||||||
|
|
||||||
if currentViewChar then
|
if currentViewChar then
|
||||||
|
-- Viewing another character's saved bank
|
||||||
bankData = addon.Modules.DB:GetCharacterBank(currentViewChar)
|
bankData = addon.Modules.DB:GetCharacterBank(currentViewChar)
|
||||||
isOtherChar = true
|
isOtherChar = true
|
||||||
charName = currentViewChar
|
charName = currentViewChar
|
||||||
getglobal("Guda_BankFrame_Title"):SetText("Bank - " .. currentViewChar)
|
getglobal("Guda_BankFrame_Title"):SetText("Bank - " .. currentViewChar)
|
||||||
else
|
else
|
||||||
bankData = addon.Modules.DB:GetCharacterBank(addon.Modules.DB:GetPlayerFullName())
|
-- Viewing current character's bank
|
||||||
if not bankData or not next(bankData) then
|
if bankIsOpen then
|
||||||
-- No saved bank data, use live scan if bank is open
|
-- Bank is actually open - use live data (interactive mode)
|
||||||
if addon.Modules.BankScanner:IsBankOpen() then
|
bankData = addon.Modules.BankScanner:ScanBank()
|
||||||
bankData = addon.Modules.BankScanner:ScanBank()
|
else
|
||||||
end
|
-- Bank is closed - use saved data (read-only mode)
|
||||||
|
bankData = addon.Modules.DB:GetCharacterBank(addon.Modules.DB:GetPlayerFullName())
|
||||||
end
|
end
|
||||||
getglobal("Guda_BankFrame_Title"):SetText("Guda Bank")
|
getglobal("Guda_BankFrame_Title"):SetText("Guda Bank")
|
||||||
end
|
end
|
||||||
|
|
||||||
self:DisplayItems(bankData, isOtherChar, charName)
|
self:DisplayItems(bankData, isOtherChar, charName)
|
||||||
|
|
||||||
|
-- Update money
|
||||||
|
self:UpdateMoney()
|
||||||
|
|
||||||
|
-- Update bank slots info
|
||||||
|
self:UpdateBankSlotsInfo(bankData, isOtherChar)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Display items
|
-- Display items
|
||||||
@@ -146,7 +164,8 @@ function BankFrame:DisplayItems(bankData, isOtherChar, charName)
|
|||||||
button:SetPoint("TOPLEFT", itemContainer, "TOPLEFT", xPos, yPos)
|
button:SetPoint("TOPLEFT", itemContainer, "TOPLEFT", xPos, yPos)
|
||||||
|
|
||||||
-- Set item data with filter match info
|
-- Set item data with filter match info
|
||||||
Guda_ItemButton_SetItem(button, bagID, slot, itemData, true, isOtherChar and charName or nil, matchesFilter)
|
-- Pass isReadOnlyMode to disable interaction for saved banks
|
||||||
|
Guda_ItemButton_SetItem(button, bagID, slot, itemData, true, isOtherChar and charName or nil, matchesFilter, isReadOnlyMode)
|
||||||
|
|
||||||
-- Advance position
|
-- Advance position
|
||||||
col = col + 1
|
col = col + 1
|
||||||
@@ -222,22 +241,226 @@ function BankFrame:ResizeFrame(currentRow, currentCol, columns)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if item passes search filter
|
-- Update bank slots info text
|
||||||
|
function BankFrame:UpdateBankSlotsInfo(bankData, isOtherChar)
|
||||||
|
local infoText = getglobal("Guda_BankFrame_Toolbar_BankSlotsInfo_Text")
|
||||||
|
if not infoText then return end
|
||||||
|
|
||||||
|
local totalSlots = 0
|
||||||
|
local usedSlots = 0
|
||||||
|
|
||||||
|
-- Count slots in bank bags
|
||||||
|
for _, bagID in ipairs(addon.Constants.BANK_BAGS) do
|
||||||
|
local bag = bankData[bagID]
|
||||||
|
|
||||||
|
-- Get slot count for this bag
|
||||||
|
local numSlots
|
||||||
|
if isOtherChar and bag and bag.numSlots then
|
||||||
|
numSlots = bag.numSlots
|
||||||
|
else
|
||||||
|
numSlots = addon.Modules.Utils:GetBagSlotCount(bagID)
|
||||||
|
end
|
||||||
|
|
||||||
|
if numSlots and numSlots > 0 then
|
||||||
|
totalSlots = totalSlots + numSlots
|
||||||
|
|
||||||
|
-- Count used slots
|
||||||
|
if bag and bag.slots then
|
||||||
|
for slot = 1, numSlots do
|
||||||
|
if bag.slots[slot] then
|
||||||
|
usedSlots = usedSlots + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Format: "24 / 80" (used / total)
|
||||||
|
infoText:SetText(string.format("%d / %d", usedSlots, totalSlots))
|
||||||
|
infoText:SetTextColor(0.7, 0.7, 0.7)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update money display
|
||||||
|
function BankFrame:UpdateMoney()
|
||||||
|
local moneyFrame = getglobal("Guda_BankFrame_MoneyFrame")
|
||||||
|
|
||||||
|
if not moneyFrame then
|
||||||
|
addon:Debug("Bank MoneyFrame not found! Checking parent...")
|
||||||
|
addon:Debug("Guda_BankFrame exists: " .. tostring(getglobal("Guda_BankFrame") ~= nil))
|
||||||
|
|
||||||
|
-- Try to create it manually
|
||||||
|
self:CreateMoneyFrame()
|
||||||
|
moneyFrame = getglobal("Guda_BankFrame_MoneyFrame")
|
||||||
|
end
|
||||||
|
|
||||||
|
if moneyFrame then
|
||||||
|
MoneyFrame_Update("Guda_BankFrame_MoneyFrame", GetMoney())
|
||||||
|
moneyFrame:Show()
|
||||||
|
|
||||||
|
-- Ensure tooltip overlay exists
|
||||||
|
self:EnsureMoneyTooltipOverlay()
|
||||||
|
else
|
||||||
|
addon:Debug("Still couldn't find or create Bank MoneyFrame!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create MoneyFrame if it doesn't exist
|
||||||
|
function BankFrame:CreateMoneyFrame()
|
||||||
|
local moneyFrame = CreateFrame("Frame", "Guda_BankFrame_MoneyFrame", Guda_BankFrame, "SmallMoneyFrameTemplate")
|
||||||
|
moneyFrame:SetPoint("BOTTOMRIGHT", Guda_BankFrame, "BOTTOMRIGHT", -15, 5)
|
||||||
|
moneyFrame:SetWidth(180)
|
||||||
|
moneyFrame:SetHeight(35)
|
||||||
|
|
||||||
|
-- Set up OnLoad handler
|
||||||
|
Guda_BankFrame_MoneyFrame_OnLoad(moneyFrame)
|
||||||
|
|
||||||
|
addon:Debug("Bank MoneyFrame created via CreateMoneyFrame")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Money frame OnLoad handler
|
||||||
|
function Guda_BankFrame_MoneyFrame_OnLoad(self)
|
||||||
|
addon:Debug("Bank MoneyFrame OnLoad called for: " .. self:GetName())
|
||||||
|
|
||||||
|
-- Set tooltip handlers on money denomination buttons
|
||||||
|
local buttons = {"GoldButton", "SilverButton", "CopperButton"}
|
||||||
|
|
||||||
|
for _, buttonName in ipairs(buttons) do
|
||||||
|
local fullName = self:GetName() .. buttonName
|
||||||
|
local button = getglobal(fullName)
|
||||||
|
if button then
|
||||||
|
button:SetScript("OnEnter", function()
|
||||||
|
Guda_BankFrame_MoneyOnEnter(this:GetParent())
|
||||||
|
end)
|
||||||
|
button:SetScript("OnLeave", function()
|
||||||
|
GameTooltip:Hide()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Also set handlers on parent frame
|
||||||
|
self:EnableMouse(true)
|
||||||
|
self:SetScript("OnEnter", function()
|
||||||
|
Guda_BankFrame_MoneyOnEnter(this)
|
||||||
|
end)
|
||||||
|
self:SetScript("OnLeave", function()
|
||||||
|
GameTooltip:Hide()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Money tooltip handler
|
||||||
|
function Guda_BankFrame_MoneyOnEnter(self)
|
||||||
|
if not self then return end
|
||||||
|
|
||||||
|
-- Anchor tooltip to TOPRIGHT
|
||||||
|
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 0)
|
||||||
|
GameTooltip:ClearLines()
|
||||||
|
|
||||||
|
-- Get all characters and total
|
||||||
|
local chars = addon.Modules.DB:GetAllCharacters(true)
|
||||||
|
local totalMoney = addon.Modules.DB:GetTotalMoney(true)
|
||||||
|
|
||||||
|
-- Header with faction/realm total - use colored money
|
||||||
|
GameTooltip:AddLine(
|
||||||
|
"Faction/realm-wide gold: " .. addon.Modules.Utils:FormatMoney(totalMoney, false, true),
|
||||||
|
1, 0.82, 0
|
||||||
|
)
|
||||||
|
GameTooltip:AddLine(" ")
|
||||||
|
|
||||||
|
-- List each character with class-colored names
|
||||||
|
for _, char in ipairs(chars) do
|
||||||
|
local classToken = char.classToken
|
||||||
|
local classColor = classToken and (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[classToken]
|
||||||
|
local colorR, colorG, colorB = 0.7, 0.7, 0.7
|
||||||
|
|
||||||
|
if classColor then
|
||||||
|
colorR, colorG, colorB = classColor.r, classColor.g, classColor.b
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create colored name
|
||||||
|
local coloredName = addon.Modules.Utils:ColorText(char.name, colorR, colorG, colorB)
|
||||||
|
|
||||||
|
GameTooltip:AddLine(
|
||||||
|
coloredName .. ": " .. addon.Modules.Utils:FormatMoney(char.money or 0, false, true)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
GameTooltip:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create transparent overlay for money tooltip
|
||||||
|
function BankFrame:EnsureMoneyTooltipOverlay()
|
||||||
|
local overlayName = "Guda_BankFrame_MoneyTooltipOverlay"
|
||||||
|
local overlay = getglobal(overlayName)
|
||||||
|
|
||||||
|
if not overlay then
|
||||||
|
local moneyFrame = getglobal("Guda_BankFrame_MoneyFrame")
|
||||||
|
if not moneyFrame then return end
|
||||||
|
|
||||||
|
-- Create transparent overlay frame
|
||||||
|
overlay = CreateFrame("Frame", overlayName, moneyFrame)
|
||||||
|
overlay:SetAllPoints(moneyFrame)
|
||||||
|
overlay:SetFrameLevel(moneyFrame:GetFrameLevel() + 1)
|
||||||
|
overlay:EnableMouse(true)
|
||||||
|
|
||||||
|
-- Set tooltip handlers on overlay
|
||||||
|
overlay:SetScript("OnEnter", function()
|
||||||
|
Guda_BankFrame_MoneyOnEnter(moneyFrame)
|
||||||
|
end)
|
||||||
|
|
||||||
|
overlay:SetScript("OnLeave", function()
|
||||||
|
GameTooltip:Hide()
|
||||||
|
end)
|
||||||
|
|
||||||
|
addon:Debug("Bank money tooltip overlay created")
|
||||||
|
end
|
||||||
|
|
||||||
|
overlay:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if search is currently active
|
||||||
|
function BankFrame:IsSearchActive()
|
||||||
|
return searchText and searchText ~= "" and searchText ~= "Search bank..."
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if item passes search filter (pfUI style)
|
||||||
function BankFrame:PassesSearchFilter(itemData)
|
function BankFrame:PassesSearchFilter(itemData)
|
||||||
if searchText == "" or searchText == "Search..." then
|
-- If no search text, everything matches
|
||||||
|
if not self:IsSearchActive() then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
if not itemData or not itemData.name then
|
-- Empty slots don't match when searching (pfUI style - they get dimmed)
|
||||||
|
if not itemData then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return string.find(string.lower(itemData.name), string.lower(searchText)) ~= nil
|
-- Get item name from itemData.name or parse from link
|
||||||
|
local itemName = itemData.name
|
||||||
|
if not itemName and itemData.link then
|
||||||
|
-- Parse name from item link: |cffffffff|Hitem:...|h[Item Name]|h|r
|
||||||
|
local _, _, name = string.find(itemData.link, "%[(.+)%]")
|
||||||
|
itemName = name
|
||||||
|
end
|
||||||
|
|
||||||
|
if not itemName then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Case-insensitive search in item name
|
||||||
|
itemName = string.lower(itemName)
|
||||||
|
local search = string.lower(searchText)
|
||||||
|
|
||||||
|
-- Check if item name contains search text
|
||||||
|
return string.find(itemName, search, 1, true) ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Search changed handler
|
-- Search changed handler
|
||||||
function Guda_BankFrame_OnSearchChanged(self)
|
function Guda_BankFrame_OnSearchChanged(self)
|
||||||
local text = self:GetText()
|
local text = self:GetText()
|
||||||
|
-- Ignore placeholder text
|
||||||
|
if text == "Search bank..." then
|
||||||
|
text = ""
|
||||||
|
end
|
||||||
if text ~= searchText then
|
if text ~= searchText then
|
||||||
searchText = text
|
searchText = text
|
||||||
BankFrame:Update()
|
BankFrame:Update()
|
||||||
@@ -246,8 +469,8 @@ end
|
|||||||
|
|
||||||
-- Sort button handler
|
-- Sort button handler
|
||||||
function Guda_BankFrame_Sort()
|
function Guda_BankFrame_Sort()
|
||||||
if currentViewChar then
|
if isReadOnlyMode or currentViewChar then
|
||||||
addon:Print("Cannot sort another character's bank!")
|
addon:Print("Cannot sort in read-only mode!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -264,19 +487,86 @@ function Guda_BankFrame_Sort()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Switch to Blizzard bank UI
|
||||||
|
function Guda_BankFrame_SwitchToBlizzardUI()
|
||||||
|
-- Hide custom bank frame
|
||||||
|
local customBankFrame = getglobal("Guda_BankFrame")
|
||||||
|
if customBankFrame then
|
||||||
|
customBankFrame:Hide()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Restore Blizzard bank frame
|
||||||
|
local blizzardBankFrame = getglobal("BankFrame")
|
||||||
|
if blizzardBankFrame then
|
||||||
|
blizzardBankFrame:SetScale(1.0)
|
||||||
|
blizzardBankFrame:SetAlpha(1.0)
|
||||||
|
blizzardBankFrame:ClearAllPoints()
|
||||||
|
blizzardBankFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, -104)
|
||||||
|
blizzardBankFrame:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
addon:Print("Switched to Blizzard bank UI. Close and reopen bank to use custom UI again.")
|
||||||
|
end
|
||||||
|
|
||||||
-- Initialize
|
-- Initialize
|
||||||
function BankFrame:Initialize()
|
function BankFrame:Initialize()
|
||||||
|
-- Hide Blizzard bank frame on load (pfUI style)
|
||||||
|
local blizzardBankFrame = getglobal("BankFrame")
|
||||||
|
if blizzardBankFrame then
|
||||||
|
blizzardBankFrame:SetScale(0.001)
|
||||||
|
blizzardBankFrame:SetPoint("TOPLEFT", 0, 0)
|
||||||
|
blizzardBankFrame:SetAlpha(0)
|
||||||
|
end
|
||||||
|
|
||||||
-- Update when bank is opened
|
-- Update when bank is opened
|
||||||
addon.Modules.Events:OnBankOpen(function()
|
addon.Modules.Events:OnBankOpen(function()
|
||||||
BankFrame:Update()
|
-- Delay showing custom bank to let TransmogUI finish processing
|
||||||
|
local frame = CreateFrame("Frame")
|
||||||
|
local elapsed = 0
|
||||||
|
frame:SetScript("OnUpdate", function()
|
||||||
|
elapsed = elapsed + arg1
|
||||||
|
if elapsed >= 0.2 then
|
||||||
|
frame:SetScript("OnUpdate", nil)
|
||||||
|
|
||||||
|
-- Show current character's bank in interactive mode
|
||||||
|
currentViewChar = nil
|
||||||
|
|
||||||
|
-- Show and update custom bank frame
|
||||||
|
local customBankFrame = getglobal("Guda_BankFrame")
|
||||||
|
if customBankFrame then
|
||||||
|
customBankFrame:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
addon.Modules.BankFrame:Update()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, "BankFrameUI")
|
||||||
|
|
||||||
|
-- Hide custom bank when bank is closed
|
||||||
|
addon.Modules.Events:OnBankClose(function()
|
||||||
|
local customBankFrame = getglobal("Guda_BankFrame")
|
||||||
|
if customBankFrame and customBankFrame:IsShown() and not currentViewChar then
|
||||||
|
-- Only auto-close if viewing current character's bank (not saved banks)
|
||||||
|
customBankFrame:Hide()
|
||||||
|
end
|
||||||
end, "BankFrameUI")
|
end, "BankFrameUI")
|
||||||
|
|
||||||
-- Update on bag changes while bank is open
|
-- Update on bag changes while bank is open
|
||||||
addon.Modules.Events:OnBagUpdate(function()
|
addon.Modules.Events:OnBagUpdate(function()
|
||||||
if addon.Modules.BankScanner:IsBankOpen() and not currentViewChar then
|
if addon.Modules.BankScanner:IsBankOpen() and not currentViewChar then
|
||||||
BankFrame:Update()
|
addon.Modules.BankFrame:Update()
|
||||||
end
|
end
|
||||||
end, "BankFrameUI")
|
end, "BankFrameUI")
|
||||||
|
|
||||||
|
-- Register bank-specific update events (pfUI style)
|
||||||
|
local updateFrame = CreateFrame("Frame")
|
||||||
|
updateFrame:RegisterEvent("PLAYERBANKSLOTS_CHANGED")
|
||||||
|
updateFrame:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED")
|
||||||
|
updateFrame:SetScript("OnEvent", function()
|
||||||
|
if addon.Modules.BankScanner:IsBankOpen() and not currentViewChar then
|
||||||
|
addon.Modules.BankFrame:Update()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
addon:Debug("Bank frame initialized")
|
addon:Debug("Bank frame initialized")
|
||||||
end
|
end
|
||||||
|
|||||||
+126
-1
@@ -1,4 +1,5 @@
|
|||||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
<Ui xmlns="http://www.blizzard.com/wow/ui/"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
|
||||||
|
|
||||||
<!-- Bank Frame -->
|
<!-- Bank Frame -->
|
||||||
<Frame name="Guda_BankFrame" toplevel="true" movable="true" enableMouse="true" hidden="true" parent="UIParent">
|
<Frame name="Guda_BankFrame" toplevel="true" movable="true" enableMouse="true" hidden="true" parent="UIParent">
|
||||||
@@ -106,6 +107,53 @@
|
|||||||
</Scripts>
|
</Scripts>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<!-- Blizzard UI Button (header left) -->
|
||||||
|
<Button name="$parent_BlizzardUIButton">
|
||||||
|
<Size>
|
||||||
|
<AbsDimension x="24" y="24"/>
|
||||||
|
</Size>
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="TOPLEFT">
|
||||||
|
<Offset>
|
||||||
|
<AbsDimension x="18" y="-15"/>
|
||||||
|
</Offset>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
<Layers>
|
||||||
|
<Layer level="ARTWORK">
|
||||||
|
<Texture name="$parent_Icon">
|
||||||
|
<Size>
|
||||||
|
<AbsDimension x="20" y="20"/>
|
||||||
|
</Size>
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="CENTER"/>
|
||||||
|
</Anchors>
|
||||||
|
<Color r="0.8" g="0.8" b="0.8"/>
|
||||||
|
</Texture>
|
||||||
|
</Layer>
|
||||||
|
</Layers>
|
||||||
|
<Scripts>
|
||||||
|
<OnLoad>
|
||||||
|
local icon = getglobal(this:GetName().."_Icon")
|
||||||
|
if icon then
|
||||||
|
icon:SetTexture("Interface\\Icons\\INV_Misc_Note_02")
|
||||||
|
icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
|
||||||
|
end
|
||||||
|
</OnLoad>
|
||||||
|
<OnClick>
|
||||||
|
Guda_BankFrame_SwitchToBlizzardUI()
|
||||||
|
</OnClick>
|
||||||
|
<OnEnter>
|
||||||
|
GameTooltip:SetOwner(this, "ANCHOR_TOP")
|
||||||
|
GameTooltip:SetText("Use Blizzard Bank UI")
|
||||||
|
GameTooltip:Show()
|
||||||
|
</OnEnter>
|
||||||
|
<OnLeave>
|
||||||
|
GameTooltip:Hide()
|
||||||
|
</OnLeave>
|
||||||
|
</Scripts>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- Search Bar (below title) -->
|
<!-- Search Bar (below title) -->
|
||||||
<Frame name="$parent_SearchBar">
|
<Frame name="$parent_SearchBar">
|
||||||
<Size>
|
<Size>
|
||||||
@@ -165,6 +213,83 @@
|
|||||||
</Frames>
|
</Frames>
|
||||||
</Frame>
|
</Frame>
|
||||||
|
|
||||||
|
<!-- Toolbar Container (for bank slots info) -->
|
||||||
|
<Frame name="$parent_Toolbar" enableMouse="true">
|
||||||
|
<Size>
|
||||||
|
<AbsDimension x="200" y="30"/>
|
||||||
|
</Size>
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="BOTTOMLEFT">
|
||||||
|
<Offset>
|
||||||
|
<AbsDimension x="10" y="5"/>
|
||||||
|
</Offset>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
<Scripts>
|
||||||
|
<OnMouseDown>
|
||||||
|
-- Clear search focus when clicking toolbar
|
||||||
|
local searchBox = getglobal("Guda_BankFrame_SearchBar_SearchBox")
|
||||||
|
if searchBox then
|
||||||
|
searchBox:ClearFocus()
|
||||||
|
end
|
||||||
|
</OnMouseDown>
|
||||||
|
</Scripts>
|
||||||
|
|
||||||
|
<Frames>
|
||||||
|
<!-- Bank Slots Info Text -->
|
||||||
|
<Frame name="$parent_BankSlotsInfo">
|
||||||
|
<Size>
|
||||||
|
<AbsDimension x="100" y="24"/>
|
||||||
|
</Size>
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="LEFT">
|
||||||
|
<Offset>
|
||||||
|
<AbsDimension x="13" y="3"/>
|
||||||
|
</Offset>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
<Layers>
|
||||||
|
<Layer level="OVERLAY">
|
||||||
|
<FontString name="$parent_Text" inherits="GameFontNormal">
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="LEFT">
|
||||||
|
<Offset>
|
||||||
|
<AbsDimension x="0" y="0"/>
|
||||||
|
</Offset>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
</FontString>
|
||||||
|
</Layer>
|
||||||
|
</Layers>
|
||||||
|
<Scripts>
|
||||||
|
<OnLoad>
|
||||||
|
local text = getglobal(this:GetName().."_Text")
|
||||||
|
if text then
|
||||||
|
text:SetText("0 / 0")
|
||||||
|
text:SetTextColor(0.8, 0.8, 0.8)
|
||||||
|
end
|
||||||
|
</OnLoad>
|
||||||
|
</Scripts>
|
||||||
|
</Frame>
|
||||||
|
</Frames>
|
||||||
|
</Frame>
|
||||||
|
|
||||||
|
<!-- Money Display Frame (bottom right) -->
|
||||||
|
<MoneyFrame name="$parent_MoneyFrame" inherits="SmallMoneyFrameTemplate">
|
||||||
|
<Size x="180" y="35"/>
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="BOTTOMRIGHT" relativeTo="Guda_BankFrame" relativePoint="BOTTOMRIGHT">
|
||||||
|
<Offset x="-15" y="5"/>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
<Scripts>
|
||||||
|
<OnLoad>
|
||||||
|
-- Set tooltip handlers on money button children
|
||||||
|
Guda_BankFrame_MoneyFrame_OnLoad(this)
|
||||||
|
</OnLoad>
|
||||||
|
</Scripts>
|
||||||
|
</MoneyFrame>
|
||||||
|
|
||||||
<!-- Container for item buttons -->
|
<!-- Container for item buttons -->
|
||||||
<Frame name="$parent_ItemContainer" enableMouse="true">
|
<Frame name="$parent_ItemContainer" enableMouse="true">
|
||||||
<Size>
|
<Size>
|
||||||
|
|||||||
+18
-40
@@ -35,12 +35,13 @@ function Guda_ItemButton_OnLoad(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Set item data
|
-- Set item data
|
||||||
function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCharName, matchesFilter)
|
function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCharName, matchesFilter, isReadOnly)
|
||||||
self.bagID = bagID
|
self.bagID = bagID
|
||||||
self.slotID = slotID
|
self.slotID = slotID
|
||||||
self.itemData = itemData
|
self.itemData = itemData
|
||||||
self.isBank = isBank or false
|
self.isBank = isBank or false
|
||||||
self.otherChar = otherCharName
|
self.otherChar = otherCharName
|
||||||
|
self.isReadOnly = isReadOnly or false -- Track if this is read-only mode
|
||||||
|
|
||||||
-- Default to true if not specified (for non-filtered displays)
|
-- Default to true if not specified (for non-filtered displays)
|
||||||
if matchesFilter == nil then
|
if matchesFilter == nil then
|
||||||
@@ -261,42 +262,19 @@ function Guda_ItemButton_OnEnter(self)
|
|||||||
|
|
||||||
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
|
||||||
|
|
||||||
if self.otherChar then
|
-- For bank items, use the item link directly since SetBagItem might not work for bank bags
|
||||||
-- Viewing another character's item - show full tooltip like the original
|
if self.isBank and self.itemData.link then
|
||||||
if self.itemData.link then
|
-- Extract hyperlink from item link: |cFFFFFFFF|Hitem:1234:0:0:0|h[Name]|h|r -> item:1234:0:0:0
|
||||||
-- Extract the hyperlink from the full item link
|
local _, _, hyperlink = strfind(self.itemData.link, "|H(.+)|h")
|
||||||
-- Item links are in format: |cFFFFFFFF|Hitem:1234:0:0:0|h[Item Name]|h|r
|
if hyperlink then
|
||||||
-- SetHyperlink needs just: item:1234:0:0:0
|
GameTooltip:SetHyperlink(hyperlink)
|
||||||
local _, _, hyperlink = strfind(self.itemData.link, "|H(.+)|h")
|
|
||||||
|
|
||||||
if hyperlink then
|
|
||||||
GameTooltip:SetHyperlink(hyperlink)
|
|
||||||
-- Add "Owned by" line after the original tooltip
|
|
||||||
GameTooltip:AddLine(" ")
|
|
||||||
GameTooltip:AddLine("|cFFFFFFFFOwned by: |cFF00FF96" .. self.otherChar .. "|r", 1, 1, 1)
|
|
||||||
else
|
|
||||||
-- Fallback: try the full link
|
|
||||||
local success, err = pcall(function()
|
|
||||||
GameTooltip:SetHyperlink(self.itemData.link)
|
|
||||||
end)
|
|
||||||
|
|
||||||
if success then
|
|
||||||
GameTooltip:AddLine(" ")
|
|
||||||
GameTooltip:AddLine("|cFFFFFFFFOwned by: |cFF00FF96" .. self.otherChar .. "|r", 1, 1, 1)
|
|
||||||
else
|
|
||||||
-- Last resort: show item name
|
|
||||||
GameTooltip:AddLine(self.itemData.name or "Unknown Item", 1, 1, 1)
|
|
||||||
GameTooltip:AddLine("|cFFFFFFFFOwned by: |cFF00FF96" .. self.otherChar .. "|r", 1, 1, 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
-- Current character's item
|
|
||||||
if self.isBank then
|
|
||||||
GameTooltip:SetInventoryItem("player", BankButtonIDToInvSlotID(self.slotID, self.bagID))
|
|
||||||
else
|
else
|
||||||
|
-- Fallback to SetBagItem
|
||||||
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- For regular bags, use SetBagItem as normal
|
||||||
|
GameTooltip:SetBagItem(self.bagID, self.slotID)
|
||||||
end
|
end
|
||||||
|
|
||||||
GameTooltip:Show()
|
GameTooltip:Show()
|
||||||
@@ -309,8 +287,8 @@ end
|
|||||||
|
|
||||||
-- OnDragStart handler
|
-- OnDragStart handler
|
||||||
function Guda_ItemButton_OnDragStart(self, button)
|
function Guda_ItemButton_OnDragStart(self, button)
|
||||||
-- Don't allow dragging other characters' items
|
-- Don't allow dragging other characters' items or in read-only mode
|
||||||
if self.otherChar then
|
if self.otherChar or self.isReadOnly then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -322,8 +300,8 @@ end
|
|||||||
|
|
||||||
-- OnReceiveDrag handler
|
-- OnReceiveDrag handler
|
||||||
function Guda_ItemButton_OnReceiveDrag(self)
|
function Guda_ItemButton_OnReceiveDrag(self)
|
||||||
-- Don't allow dragging to other characters' items
|
-- Don't allow dragging to other characters' items or in read-only mode
|
||||||
if self.otherChar then
|
if self.otherChar or self.isReadOnly then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -333,8 +311,8 @@ end
|
|||||||
|
|
||||||
-- OnClick handler
|
-- OnClick handler
|
||||||
function Guda_ItemButton_OnClick(self, button)
|
function Guda_ItemButton_OnClick(self, button)
|
||||||
-- Don't allow interaction with other characters' items
|
-- Don't allow interaction with other characters' items or in read-only mode
|
||||||
if self.otherChar then
|
if self.otherChar or self.isReadOnly then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user