From 2fcd5592618ef62e325a5b39b8f63fd70639fb35 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Tue, 7 Dec 2021 01:27:43 +0100 Subject: [PATCH] Some cleanup --- src/common.lua | 1 - src/gui.lua | 29 ++++++++++++++++++++--------- src/styles.lua | 2 ++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/common.lua b/src/common.lua index ab2572f..5536fdd 100644 --- a/src/common.lua +++ b/src/common.lua @@ -352,7 +352,6 @@ local function get_recipes(player, item) local no_recipes = not recipes or #recipes == 0 if no_recipes and not usages then return end usages = apply_recipe_filters(usages, player) - local no_usages = not usages or #usages == 0 return not no_recipes and recipes or nil, diff --git a/src/gui.lua b/src/gui.lua index ca3dd2d..8ee0c88 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -760,27 +760,38 @@ end local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_size, _btn_size) local custom_recipe = i3.craft_types[rcp.type] + local cooking = rcp.type == "cooking" + local fuel = rcp.type == "fuel" - if custom_recipe or shapeless or rcp.type == "cooking" then - local icon = custom_recipe and custom_recipe.icon or shapeless and "shapeless" or "furnace" + if custom_recipe or shapeless or cooking then + local icon, tooltip = PNG.blank - if not custom_recipe then - icon = fmt("i3_%s.png^\\[resize:16x16", icon) + if custom_recipe and true_str(custom_recipe.icon) then + icon = fmt("%s^\\[resize:16x16", custom_recipe.icon) + elseif shapeless then + icon = PNG.shapeless end local pos_x = right + btn_size + 0.42 local pos_y = data.yoffset + 0.9 - if sub(icon, 1, 10) == "i3_furnace" then + if cooking then fs("animated_image", pos_x, pos_y, 0.5, 0.5, PNG.furnace_anim, 8, 180) else fs("image", pos_x, pos_y, 0.5, 0.5, icon) end - local tooltip = custom_recipe and custom_recipe.description or - shapeless and S"Shapeless" or S"Cooking" + if custom_recipe and true_str(custom_recipe.description) then + tooltip = custom_recipe.description + elseif shapeless then + tooltip = S"Shapeless" + elseif cooking then + tooltip = S"Cooking" + end - fs("tooltip", pos_x, pos_y, 0.5, 0.5, ESC(tooltip)) + if tooltip then + fs("tooltip", pos_x, pos_y, 0.5, 0.5, ESC(tooltip)) + end end local arrow_X = right + 0.2 + (_btn_size or i3.ITEM_BTN_SIZE) @@ -789,7 +800,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz fs("image", arrow_X, Y + 0.06, 1, 1, PNG.arrow) - if rcp.type == "fuel" then + if fuel then fs("animated_image", X + 0.05, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, PNG.fire_anim, 8, 180) return end diff --git a/src/styles.lua b/src/styles.lua index 56796cf..8108052 100644 --- a/src/styles.lua +++ b/src/styles.lua @@ -1,4 +1,5 @@ local PNG = { + blank = "i3_blank.png", bg = "i3_bg.png", bg_full = "i3_bg_full.png", bg_content = "i3_bg_content.png", @@ -27,6 +28,7 @@ local PNG = { tab_small = "i3_tab_small.png", tab_top = "i3_tab.png^\\[transformFY", furnace_anim = "i3_furnace_anim.png", + shapeless = "i3_shapeless.png", bag = "i3_bag.png", armor = "i3_armor.png", awards = "i3_award.png",