Skip to content

Commit c719e8c

Browse files
committed
More refactoring
1 parent ab55266 commit c719e8c

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

addons/tooltiphelper/tooltiphelper.lua

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ TTH.config = (
3535
end
3636
)()
3737

38-
TTH.indexTbl = {
39-
Recipe = { types = {"Recipe", "Recipe_ItemCraft", "ItemTradeShop"} },
40-
Drops = {},
41-
Premium = {},
42-
Collection = {},
43-
44-
};
38+
TTH.indexTbl = {};
4539

4640
local TooltipHelper = TTH
4741

@@ -52,34 +46,35 @@ local function MAGNUM_OPUS_RECIPE_LOADER()
5246
return
5347
end
5448

55-
local recipeXml = xml.newParser():loadFile(TooltipHelper.recipeFile);
49+
local recipeXml = xml.newParser():loadFile(TTH.recipeFile);
5650

5751
if recipeXml == nil then
5852
acutil.log("Magnum Opus recipe file not found");
5953
return
6054
end
6155

62-
TooltipHelper.magnumOpusRecipes = {};
56+
TTH.magnumOpusRecipes = {};
6357
local recipes = recipeXml["Recipe_Puzzle"]:children();
6458

6559
for i=1,#recipes do
6660
local recipe = recipes[i];
6761
local targetItemClassName = recipe["@TargetItem"];
6862
local ingredients = recipe:children();
69-
TooltipHelper.magnumOpusRecipes[targetItemClassName] = {};
63+
TTH.magnumOpusRecipes[targetItemClassName] = {};
7064
for j=1,#ingredients do
7165
local ingredient = ingredients[j];
7266
local ingredientItemClassName = ingredient["@Name"];
7367
local row = ingredient["@Row"];
7468
local column = ingredient["@Col"];
75-
table.insert(TooltipHelper.magnumOpusRecipes[targetItemClassName], {name = ingredientItemClassName,
69+
table.insert(TTH.magnumOpusRecipes[targetItemClassName], {name = ingredientItemClassName,
7670
row = tonumber(row),
7771
col = tonumber(column)});
7872
end
7973
end
74+
TooltipHelper.magnumOpusRecipes = TTH.magnumOpusRecipes
8075
end
8176

82-
if not TooltipHelper.magnumOpusRecipes then
77+
if not TTH.magnumOpusRecipes then
8378
MAGNUM_OPUS_RECIPE_LOADER();
8479
end
8580

@@ -195,8 +190,8 @@ function _CUSTOM_TOOLTIP_PROPS(tooltipFrame, mainFrameName, invItem, strArg, use
195190
end
196191

197192
local function TOOLTIPHELPER_BUILD_COLLECTION_LIST()
198-
-- TooltipHelper.indexTbl["Collection"] = {};
199-
local typeTbl = TooltipHelper.indexTbl["Collection"];
193+
TTH.indexTbl["Collection"] = {};
194+
local typeTbl = TTH.indexTbl["Collection"];
200195
local clsList, cnt = GetClassList("Collection");
201196
for i = 0 , cnt - 1 do
202197
local cls = GetClassByIndexFromList(clsList, i);
@@ -220,11 +215,13 @@ local function TOOLTIPHELPER_BUILD_COLLECTION_LIST()
220215
end
221216
end
222217
end
218+
TooltipHelper.indexTbl["Collection"] = typeTbl
223219
end
224220

225221
local function TOOLTIPHELPER_BUILD_RECIPE_LIST()
226-
-- TooltipHelper.indexTbl["Recipe"] = {types = {"Recipe", "Recipe_ItemCraft", "ItemTradeShop"}};
227-
local typeTbl = TooltipHelper.indexTbl["Recipe"];
222+
TTH.indexTbl["Recipe"] = {types = {"Recipe", "Recipe_ItemCraft", "ItemTradeShop"}};
223+
224+
local typeTbl = TTH.indexTbl["Recipe"];
228225
for _, classType in ipairs(typeTbl["types"]) do
229226
local clsList, cnt = GetClassList(classType);
230227
for i = 0 , cnt - 1 do repeat
@@ -267,6 +264,7 @@ local function TOOLTIPHELPER_BUILD_RECIPE_LIST()
267264
table.sort(t, compare);
268265
end
269266
end
267+
TooltipHelper.indexTbl["Recipe"] = typeTbl
270268
end
271269

272270
local function TOOLTIPHELPER_BUILD_DROP_LIST()
@@ -278,7 +276,8 @@ local function TOOLTIPHELPER_BUILD_DROP_LIST()
278276
end
279277
end
280278

281-
-- TooltipHelper.indexTbl["Drops"] = {};
279+
TTH.indexTbl["Drops"] = {};
280+
282281
local typeTbl = TooltipHelper.indexTbl["Drops"];
283282
local clsList, cnt = GetClassList("Monster");
284283
for i = 0 , cnt - 1 do repeat
@@ -326,11 +325,12 @@ local function TOOLTIPHELPER_BUILD_DROP_LIST()
326325
for _, t in pairs(typeTbl) do
327326
table.sort(t, chanceCompare);
328327
end
328+
TooltipHelper.indexTbl["Drops"] = typeTbl
329329
end
330330

331331
local function TOOLTIPHELPER_BUILD_MEDAL_EXCHANGE_LIST()
332-
-- TooltipHelper.indexTbl["Premium"] = {};
333-
local typeTbl = TooltipHelper.indexTbl["Premium"];
332+
TTH.indexTbl["Premium"] = {};
333+
local typeTbl = TTH.indexTbl["Premium"];
334334
local clsList, cnt = GetClassList("recycle_shop");
335335
for i = 0 , cnt - 1 do repeat
336336
local cls = GetClassByIndexFromList(clsList, i);
@@ -347,6 +347,7 @@ local function TOOLTIPHELPER_BUILD_MEDAL_EXCHANGE_LIST()
347347
table.insert(countingTbl, itemName);
348348
table.insert(typeTbl[itemName], {idx = i, name = itemName, sellPrice = sellPrice} );
349349
until true end
350+
TooltipHelper.indexTbl["Premium"] = typeTbl
350351
end
351352

352353
function JOURNAL_STATS_CUSTOM_TOOLTIP_TEXT(invItem)
@@ -374,7 +375,7 @@ function JOURNAL_STATS_CUSTOM_TOOLTIP_TEXT(invItem)
374375
end
375376

376377
function COLLECTION_ADD_CUSTOM_TOOLTIP_TEXT(invItem)
377-
if TooltipHelper.indexTbl["Collection"] == nil then
378+
if TTH.indexTbl["Collection"] == nil then
378379
TOOLTIPHELPER_BUILD_COLLECTION_LIST();
379380
end
380381

@@ -437,7 +438,7 @@ function COLLECTION_ADD_CUSTOM_TOOLTIP_TEXT(invItem)
437438
end
438439

439440
function RECIPE_ADD_CUSTOM_TOOLTIP_TEXT(invItem)
440-
if TooltipHelper.indexTbl["Recipe"] == nil then
441+
if TTH.indexTbl["Recipe"] == nil then
441442
TOOLTIPHELPER_BUILD_RECIPE_LIST()
442443
end
443444

@@ -638,7 +639,7 @@ function RENDER_MAGNUM_OPUS_SECTION(invItem)
638639
end
639640

640641
function RENDER_ITEM_DROP_SECTION(invItem)
641-
if TooltipHelper.indexTbl["Drops"] == nil then
642+
if TTH.indexTbl["Drops"] == nil then
642643
TOOLTIPHELPER_BUILD_DROP_LIST();
643644
end
644645

@@ -790,7 +791,11 @@ function TRANSCENDENCE(invItem)
790791
end
791792

792793
function AWAKENING(invItem)
793-
if invItem.ItemType ~= "Equip" or invItem.EqpType == "WING" or invItem.EqpType == "SPECIALCOSTUME" then return "" end
794+
if invItem.ItemType ~= "Equip"
795+
or invItem.EqpType == "WING"
796+
or invItem.EqpType == "SPECIALCOSTUME"
797+
then return ""
798+
end
794799

795800
local needItem, needCount = GET_ITEM_AWAKENING_PRICE(invItem)
796801
local itemCls = GetClass('Item', needItem);
@@ -925,7 +930,7 @@ function CUSTOM_TOOLTIP_PROPS(tooltipFrame, mainFrameName, invItem, strArg, useS
925930
end
926931

927932
function TOOLTIPHELPER_INIT()
928-
if not TooltipHelper.isLoaded then
933+
if not TTH.isLoaded then
929934
TOOLTIPHELPER_BUILD_COLLECTION_LIST();
930935
TOOLTIPHELPER_BUILD_RECIPE_LIST();
931936
TOOLTIPHELPER_BUILD_DROP_LIST();
@@ -935,7 +940,7 @@ function TOOLTIPHELPER_INIT()
935940
acutil.setupHook(ITEM_TOOLTIP_BOSSCARD_HOOKED, "ITEM_TOOLTIP_BOSSCARD");
936941
acutil.setupHook(ITEM_TOOLTIP_GEM_HOOKED, "ITEM_TOOLTIP_GEM");
937942

938-
TooltipHelper.isLoaded = true
943+
TTH.isLoaded = true
939944

940945
acutil.log("Tooltip helper loaded!")
941946
end

0 commit comments

Comments
 (0)