Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit bf28a48

Browse files
committed
Code cleaning
1 parent bd5c5fc commit bf28a48

File tree

1 file changed

+29
-38
lines changed

1 file changed

+29
-38
lines changed

init.lua

+29-38
Original file line numberDiff line numberDiff line change
@@ -779,46 +779,40 @@ local function get_output_fs(data, fs, L)
779779
end
780780

781781
local pos_x = L.rightest + L.btn_size + 0.1
782-
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45)
782+
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45) + L.spacing
783783

784784
if sub(icon, 1, 18) == "craftguide_furnace" then
785785
fs[#fs + 1] = fmt(FMT.animated_image,
786-
pos_x, pos_y + L.spacing, 0.5, 0.5, PNG.furnace_anim, 8, 180)
786+
pos_x, pos_y, 0.5, 0.5, PNG.furnace_anim, 8, 180)
787787
else
788-
fs[#fs + 1] = fmt(FMT.image, pos_x, pos_y + L.spacing, 0.5, 0.5, icon)
788+
fs[#fs + 1] = fmt(FMT.image, pos_x, pos_y, 0.5, 0.5, icon)
789789
end
790790

791791
local tooltip = custom_recipe and custom_recipe.description or
792792
L.shapeless and S"Shapeless" or S"Cooking"
793793

794-
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y + L.spacing, 0.5, 0.5, ESC(tooltip))
794+
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
795795
end
796796

797797
local arrow_X = L.rightest + (L._btn_size or 1.1)
798798
local output_X = arrow_X + 0.9
799+
local Y = YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing
799800

800-
fs[#fs + 1] = fmt(FMT.image,
801-
arrow_X, YOFFSET + (sfinv_only and 0.9 or 0.2) + L.spacing,
802-
0.9, 0.7, PNG.arrow)
801+
fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
803802

804803
if L.recipe.type == "fuel" then
805-
fs[#fs + 1] = fmt(FMT.animated_image,
806-
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
807-
1.1, 1.1, PNG.fire_anim, 8, 180)
804+
fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y, 1.1, 1.1, PNG.fire_anim, 8, 180)
808805
else
809806
local item = L.recipe.output
810807
item = clean_name(item)
811808
local name = match(item, "%S*")
812809

813-
fs[#fs + 1] = fmt(FMT.image,
814-
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
815-
1.1, 1.1, PNG.selected)
810+
fs[#fs + 1] = fmt(FMT.image, output_X, Y, 1.1, 1.1, PNG.selected)
816811

817812
local _name = sfinv_only and name or fmt("_%s", name)
818813

819814
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
820-
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
821-
1.1, 1.1, item, _name, "")
815+
output_X, Y, 1.1, 1.1, item, _name, "")
822816

823817
local infos = {
824818
unknown = not reg_items[name] or nil,
@@ -922,14 +916,14 @@ local function get_grid_fs(data, fs, rcp, spacing)
922916
end
923917
end
924918

919+
Y = Y + (sfinv_only and 0.7 or 0)
920+
925921
if not large_recipe then
926-
fs[#fs + 1] = fmt(FMT.image,
927-
X, Y + (sfinv_only and 0.7 or 0), btn_size, btn_size, PNG.selected)
922+
fs[#fs + 1] = fmt(FMT.image, X, Y, btn_size, btn_size, PNG.selected)
928923
end
929924

930925
fs[#fs + 1] = fmt(FMT.item_image_button,
931-
X, Y + (sfinv_only and 0.7 or 0),
932-
btn_size, btn_size, item, item, ESC(label))
926+
X, Y, btn_size, btn_size, item, item, label)
933927

934928
local infos = {
935929
unknown = not reg_items[name] or nil,
@@ -1012,12 +1006,13 @@ local function get_panels(data, fs)
10121006
local lbl = ""
10131007

10141008
if not sfinv_only and rn == 0 then
1015-
fs[#fs + 1] = fmt(FMT.image,
1016-
XOFFSET - 0.7, YOFFSET - 0.4 + spacing, 2, 2, PNG.nothing)
1009+
local X = XOFFSET - 0.7
1010+
local Y = YOFFSET - 0.4 + spacing
1011+
1012+
fs[#fs + 1] = fmt(FMT.image, X, Y, 2, 2, PNG.nothing)
10171013

10181014
fs[#fs + 1] = fmt(FMT.tooltip,
1019-
XOFFSET - 0.7, YOFFSET - 0.4 + spacing, 2, 2,
1020-
is_recipe and ES"No recipes" or ES"No usages")
1015+
X, Y, 2, 2, is_recipe and ES"No recipes" or ES"No usages")
10211016

10221017
elseif (not sfinv_only and is_recipe) or
10231018
(sfinv_only and not data.show_usages) then
@@ -1059,16 +1054,15 @@ local function get_panels(data, fs)
10591054

10601055
for i = 1, #data.favs do
10611056
local item = data.favs[i]
1057+
local X = 7.85 + (i - 0.5)
1058+
local Y = spacing + 0.45
10621059

10631060
if data.query_item == item then
1064-
fs[#fs + 1] = fmt(FMT.image,
1065-
7.85 + (i - 0.5), spacing + 0.45,
1066-
1.1, 1.1, PNG.selected)
1061+
fs[#fs + 1] = fmt(FMT.image, X, Y, 1.1, 1.1, PNG.selected)
10671062
end
10681063

10691064
fs[#fs + 1] = fmt(FMT.item_image_button,
1070-
7.85 + (i - 0.5), spacing + 0.45,
1071-
1.1, 1.1, item, item, "")
1065+
X, Y, 1.1, 1.1, item, item, "")
10721066
end
10731067
end
10741068
end
@@ -1124,15 +1118,15 @@ local function make_fs(data)
11241118
0.06, clr("#ff0", data.pagenum), data.pagemax)
11251119

11261120
if #data.items == 0 then
1127-
local no_item = S"No item to show"
1121+
local no_item = ES"No item to show"
11281122
local pos = 3
11291123

11301124
if next(recipe_filters) and #init_items > 0 and data.filter == "" then
1131-
no_item = S"Collect items to reveal more recipes"
1125+
no_item = ES"Collect items to reveal more recipes"
11321126
pos = pos - 1
11331127
end
11341128

1135-
fs[#fs + 1] = fmt(FMT.label, pos, 2, ESC(no_item))
1129+
fs[#fs + 1] = fmt(FMT.label, pos, 2, no_item)
11361130
end
11371131

11381132
local first_item = (data.pagenum - 1) * IPP
@@ -1143,18 +1137,15 @@ local function make_fs(data)
11431137

11441138
local X = i % ROWS
11451139
local Y = (i % IPP - X) / ROWS + 1
1140+
X = X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05
1141+
Y = Y - (Y * 0.1) - 0.1
11461142

11471143
if data.query_item == item then
1148-
fs[#fs + 1] = fmt(FMT.image,
1149-
X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05,
1150-
Y - (Y * 0.1) - 0.1,
1151-
1, 1, PNG.selected)
1144+
fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
11521145
end
11531146

11541147
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s_inv;]",
1155-
X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05,
1156-
Y - (Y * 0.1) - 0.1,
1157-
1, 1, item, item)
1148+
X, Y, 1, 1, item, item)
11581149
end
11591150

11601151
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then

0 commit comments

Comments
 (0)