From 6c8d4944ee09759483f1f6c8419f6efb50544213 Mon Sep 17 00:00:00 2001 From: Sqoops Date: Mon, 26 Jun 2017 15:02:20 +0200 Subject: [PATCH] panel: add bagspace calculation --- env/translations_deDE.lua | 1 + env/translations_enGB.lua | 1 + env/translations_frFR.lua | 1 + env/translations_koKR.lua | 1 + env/translations_ruRU.lua | 1 + env/translations_zhCN.lua | 1 + env/translations_zhTW.lua | 3 ++- modules/gui.lua | 3 ++- modules/panel.lua | 23 ++++++++++++++++++++++- 9 files changed, 32 insertions(+), 3 deletions(-) diff --git a/env/translations_deDE.lua b/env/translations_deDE.lua index bf276660..caa51c16 100644 --- a/env/translations_deDE.lua +++ b/env/translations_deDE.lua @@ -17,6 +17,7 @@ pfUI_translation["deDE"] = { ["Background Color"] = nil, ["Bags & Bank"] = nil, ["Bags Border Size"] = nil, + ["Bagspace"] = nil, ["Border Color"] = nil, ["Bottom"] = nil, ["Buff Limit"] = nil, diff --git a/env/translations_enGB.lua b/env/translations_enGB.lua index 9eddd17b..5b304a19 100644 --- a/env/translations_enGB.lua +++ b/env/translations_enGB.lua @@ -17,6 +17,7 @@ pfUI_translation["enGB"] = { ["Background Color"] = nil, ["Bags & Bank"] = nil, ["Bags Border Size"] = nil, + ["Bagspace"] = nil, ["Border Color"] = nil, ["Bottom"] = nil, ["Buff Limit"] = nil, diff --git a/env/translations_frFR.lua b/env/translations_frFR.lua index 80052d32..c8ebf31d 100644 --- a/env/translations_frFR.lua +++ b/env/translations_frFR.lua @@ -17,6 +17,7 @@ pfUI_translation["frFR"] = { ["Background Color"] = "Couleur de l'arrière-plan", ["Bags & Bank"] = "Sacs et Banque", ["Bags Border Size"] = "Taille de la bordure des Sacs", + ["Bagspace"] = nil, ["Border Color"] = "Couleur de la bordure", ["Bottom"] = "Bas", ["Buff Limit"] = "Limite des améliorations", diff --git a/env/translations_koKR.lua b/env/translations_koKR.lua index 2db6b3e8..30fd470e 100644 --- a/env/translations_koKR.lua +++ b/env/translations_koKR.lua @@ -17,6 +17,7 @@ pfUI_translation["koKR"] = { ["Background Color"] = "백그라운드 색상", ["Bags & Bank"] = "가방&은행", ["Bags Border Size"] = "가방 테두리 크기", + ["Bagspace"] = nil, ["Border Color"] = "테두리 색상", ["Bottom"] = "아래", ["Buff Limit"] = "버프 한도", diff --git a/env/translations_ruRU.lua b/env/translations_ruRU.lua index 910d2b59..aaa92a16 100644 --- a/env/translations_ruRU.lua +++ b/env/translations_ruRU.lua @@ -17,6 +17,7 @@ pfUI_translation["ruRU"] = { ["Background Color"] = nil, ["Bags & Bank"] = nil, ["Bags Border Size"] = nil, + ["Bagspace"] = nil, ["Border Color"] = nil, ["Bottom"] = nil, ["Buff Limit"] = nil, diff --git a/env/translations_zhCN.lua b/env/translations_zhCN.lua index c0be7a27..620a79ea 100644 --- a/env/translations_zhCN.lua +++ b/env/translations_zhCN.lua @@ -17,6 +17,7 @@ pfUI_translation["zhCN"] = { ["Background Color"] = "聊天窗口背景颜色", ["Bags & Bank"] = "背包和银行", ["Bags Border Size"] = "背包边框大小", + ["Bagspace"] = nil, ["Border Color"] = "边框颜色", ["Bottom"] = "底部", ["Buff Limit"] = "Buff总数量", diff --git a/env/translations_zhTW.lua b/env/translations_zhTW.lua index 3fa0fb4d..c0f9c738 100644 --- a/env/translations_zhTW.lua +++ b/env/translations_zhTW.lua @@ -17,6 +17,7 @@ pfUI_translation["zhTW"] = { ["Background Color"] = "聊天窗口背景顏色", ["Bags & Bank"] = "背包和銀行", ["Bags Border Size"] = "背包邊框大小", + ["Bagspace"] = nil, ["Border Color"] = "邊框顏色", ["Bottom"] = "底部", ["Buff Limit"] = "Buff總數量", @@ -280,4 +281,4 @@ pfUI_translation["zhTW"] = { ["WIM"] = "WIM", ["XP Percentage"] = "經驗百分比", ["Zone Name"] = "區域名稱", -} \ No newline at end of file +} diff --git a/modules/gui.lua b/modules/gui.lua index e6125ee7..08408356 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -634,7 +634,8 @@ pfUI:RegisterModule("gui", function () "zone:" .. T["Zone Name"], "combat:" .. T["Combat Timer"], "ammo:" .. T["Ammo Counter"], - "soulshard:" .. T["Soulshard Counter"] + "soulshard:" .. T["Soulshard Counter"], + "bagspace:" .. T["Bagspace"] } local dropdown_unitframes_portrait_position = { diff --git a/modules/panel.lua b/modules/panel.lua index d6446de0..3a5c9b49 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -25,7 +25,7 @@ pfUI:RegisterModule("panel", function () -- list of available panel fields pfUI.panel.options = { "time", "fps", "exp", "gold", "friends", - "guild", "durability", "zone", "ammo" } + "guild", "durability", "zone", "ammo", "bagspace" } pfUI.panel:SetScript("OnEvent", function() if event == "PLAYER_ENTERING_WORLD" then @@ -38,11 +38,13 @@ pfUI:RegisterModule("panel", function () pfUI.panel:UpdateZone() pfUI.panel:UpdateAmmo() pfUI.panel:UpdateSoulshard() + pfUI.panel:UpdateBagspace() elseif event == "PLAYER_MONEY" then pfUI.panel:UpdateGold() pfUI.panel:UpdateRepair() elseif event == "BAG_UPDATE" then pfUI.panel:UpdateSoulshard() + pfUI.panel:UpdateBagspace() elseif event == "UNIT_INVENTORY_CHANGED" then pfUI.panel:UpdateAmmo() elseif event == "PLAYER_XP_UPDATE" then @@ -229,6 +231,25 @@ pfUI:RegisterModule("panel", function () end end + -- Update "bagspace" + function pfUI.panel:UpdateBagspace () + local maxslots = 0 + local usedslots = 0 + + for bag = 0,4 do + local bagsize = GetContainerNumSlots(bag) + maxslots = maxslots + bagsize + for j = 1,bagsize do + link = GetContainerItemLink(bag,j) + if link then + usedslots = usedslots + 1 + end + end + end + local freeslots = maxslots - usedslots + pfUI.panel:OutputPanel("bagspace", freeslots .. " (" .. usedslots .. "/" .. maxslots .. ")") + end + -- Update "gold" function pfUI.panel:UpdateGold () local gold = floor(GetMoney()/ 100 / 100)