From e62e1e396c787c847658d48b3da296e921a2d732 Mon Sep 17 00:00:00 2001 From: Zoryn Date: Tue, 22 Oct 2024 14:58:06 -0400 Subject: [PATCH] initial updates to the LTN GUI for 2.0 --- cybersyn/graphics/shortcut/shortcut_icon.png | Bin 0 -> 430 bytes .../graphics/shortcut/shortcut_icon_small.png | Bin 0 -> 497 bytes cybersyn/prototypes/gui-style.lua | 12 ++++++++---- cybersyn/scripts/gui/actions.lua | 4 ++-- cybersyn/scripts/gui/inventory.lua | 6 +++--- cybersyn/scripts/gui/main.lua | 2 +- cybersyn/scripts/gui/manager.lua | 4 ++-- cybersyn/scripts/gui/templates.lua | 6 +++--- cybersyn/scripts/gui/util.lua | 18 +++++++++--------- 9 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 cybersyn/graphics/shortcut/shortcut_icon.png create mode 100644 cybersyn/graphics/shortcut/shortcut_icon_small.png diff --git a/cybersyn/graphics/shortcut/shortcut_icon.png b/cybersyn/graphics/shortcut/shortcut_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f59251d582a10cb82ffa1981aa7a52ef4fef3d54 GIT binary patch literal 430 zcmV;f0a5;mP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0YgbdK~z{r?Ulb$ z0x=NA6SQC)w4>vIiWv)AD=S`rMxRo70}I~3hK9yJcNUI?g*ap3Fz5Frdoeg1as>$p zznQ)LvdJYoN%l_d*?BY{Nh`U8yQU7vRrZ|SXe{1Ey!gOIekgmVph^O_uy-0Jbaw^%0M5i=L&ggHKK~t`tvZ6rpb};xsr`y_ z{O=uDh0+AH*5<>MW+^Yv+7ex9;35jHU0_FfQ8%%u5~19?}>?0 Y-%I^drXMr*{{R3007*qoM6N<$f^#ypZ2$lO literal 0 HcmV?d00001 diff --git a/cybersyn/graphics/shortcut/shortcut_icon_small.png b/cybersyn/graphics/shortcut/shortcut_icon_small.png new file mode 100644 index 0000000000000000000000000000000000000000..985c886afbb094c64bd888dccdbfe756f83b4d06 GIT binary patch literal 497 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0ftFLK~zXf?UlhR zL{SvR-^?(Yl8GY9L=p=NODkopu$G05r0gjRD+^_5%|_VTTUcP>438z6l%T zzZ76kmgNK{x&Cg+P+Xg4IhK!lMS4h<8*2OT`cWBdtIN3Vl=JqzhHGSjDcFJ~Zngv( z0Cl!)5mHeW<%-@uQ&fRbSOvXnJw)n*b%~uaZ5YA~00000NkvXXu0mjf-W1ll literal 0 HcmV?d00001 diff --git a/cybersyn/prototypes/gui-style.lua b/cybersyn/prototypes/gui-style.lua index a4e717d..c7c2492 100644 --- a/cybersyn/prototypes/gui-style.lua +++ b/cybersyn/prototypes/gui-style.lua @@ -389,10 +389,14 @@ if settings.startup["cybersyn-manager-enabled"].value then { type = "shortcut", name = "cybersyn-toggle-gui", - icon = data_util.build_sprite(nil, { 0, 0 }, util.paths.shortcut_icons, 32, 2), - disabled_icon = data_util.build_sprite(nil, { 48, 0 }, util.paths.shortcut_icons, 32, 2), - small_icon = data_util.build_sprite(nil, { 0, 32 }, util.paths.shortcut_icons, 24, 2), - disabled_small_icon = data_util.build_sprite(nil, { 36, 32 }, util.paths.shortcut_icons, 24, 2), + icon = "__cybersyn__/graphics/shortcut/shortcut_icon.png", + icon_size = 32, + small_icon = "__cybersyn__/graphics/shortcut/shortcut_icon.png", + small_icon_size = 24, + --icon = data_util.build_sprite("nil", { 0, 0 }, util.paths.shortcut_icons, 32, 2), + --disabled_icon = data_util.build_sprite(nil, { 48, 0 }, util.paths.shortcut_icons, 32, 2), + --small_icon = data_util.build_sprite(nil, { 0, 32 }, util.paths.shortcut_icons, 24, 2), + --disabled_small_icon = data_util.build_sprite(nil, { 36, 32 }, util.paths.shortcut_icons, 24, 2), toggleable = true, action = "lua", associated_control_input = "cybersyn-toggle-gui", diff --git a/cybersyn/scripts/gui/actions.lua b/cybersyn/scripts/gui/actions.lua index 0adb6fd..f1a6222 100644 --- a/cybersyn/scripts/gui/actions.lua +++ b/cybersyn/scripts/gui/actions.lua @@ -9,10 +9,10 @@ local actions = {} local function toggle_fab(elem, sprite, state) if state then elem.style = "flib_selected_frame_action_button" - elem.sprite = sprite .. "_black" + elem.sprite = sprite .. "" else elem.style = "frame_action_button" - elem.sprite = sprite .. "_white" + elem.sprite = sprite .. "" end end diff --git a/cybersyn/scripts/gui/inventory.lua b/cybersyn/scripts/gui/inventory.lua index 5d00166..88653fb 100644 --- a/cybersyn/scripts/gui/inventory.lua +++ b/cybersyn/scripts/gui/inventory.lua @@ -171,7 +171,7 @@ function inventory_tab.build(map_data, player_data) for item, count in pairs(inventory_provided) do i = i + 1 local sprite, img_path, item_string = util.generate_item_references(item) - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then provided_children[#provided_children+1] = { type = "sprite-button", style = "flib_slot_button_green", @@ -195,7 +195,7 @@ function inventory_tab.build(map_data, player_data) for item, count in pairs(inventory_requested) do i = i + 1 local sprite, img_path, item_string = util.generate_item_references(item) - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then requested_children[#requested_children+1] = { type = "sprite-button", style = "flib_slot_button_red", @@ -219,7 +219,7 @@ function inventory_tab.build(map_data, player_data) for item, count in pairs(inventory_in_transit) do i = i + 1 local sprite, img_path, item_string = util.generate_item_references(item) - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then in_transit_children[#in_transit_children+1] = { type = "sprite-button", style = "flib_slot_button_blue", diff --git a/cybersyn/scripts/gui/main.lua b/cybersyn/scripts/gui/main.lua index 5edcdb7..db8411b 100644 --- a/cybersyn/scripts/gui/main.lua +++ b/cybersyn/scripts/gui/main.lua @@ -135,7 +135,7 @@ local function init_items(manager) manager.item_order = item_order local i = 1 - for _, protos in pairs{prototypes.item, game.fluid_prototypes} do + for _, protos in pairs{prototypes.item, prototypes.fluid} do --- @type (LuaItemPrototype|LuaFluidPrototype)[] local all_items = {} for _, proto in pairs(protos) do diff --git a/cybersyn/scripts/gui/manager.lua b/cybersyn/scripts/gui/manager.lua index 09fd41e..9c52ca3 100644 --- a/cybersyn/scripts/gui/manager.lua +++ b/cybersyn/scripts/gui/manager.lua @@ -180,10 +180,10 @@ end local function toggle_fab(elem, sprite, state) if state then elem.style = "flib_selected_frame_action_button" - elem.sprite = sprite .. "_black" + elem.sprite = sprite .. "" else elem.style = "frame_action_button" - elem.sprite = sprite .. "_white" + elem.sprite = sprite .. "" end end diff --git a/cybersyn/scripts/gui/templates.lua b/cybersyn/scripts/gui/templates.lua index 3490c32..138adfc 100644 --- a/cybersyn/scripts/gui/templates.lua +++ b/cybersyn/scripts/gui/templates.lua @@ -13,9 +13,9 @@ function templates.frame_action_button(name, sprite, tooltip, handler, tags) type = "sprite-button", name = name, style = "frame_action_button", - sprite = sprite .. "_white", - hovered_sprite = sprite .. "_black", - clicked_sprite = sprite .. "_black", + sprite = sprite .. "", + hovered_sprite = sprite .. "", + clicked_sprite = sprite .. "", mouse_button_filter = { "left" }, tooltip = tooltip, handler = handler, diff --git a/cybersyn/scripts/gui/util.lua b/cybersyn/scripts/gui/util.lua index e75ed0f..5533797 100644 --- a/cybersyn/scripts/gui/util.lua +++ b/cybersyn/scripts/gui/util.lua @@ -40,15 +40,15 @@ function util.generate_item_references(item) local sprite = nil local image_path = "" local item_name - if game.is_valid_sprite_path("item/" .. item) then + if helpers.is_valid_sprite_path("item/" .. item) then sprite = "item/" .. item image_path = "[img=item." .. item .. "]" item_name = {"?", { "item-name." .. item }, { "entity-name." .. item }, "LocalizedString failure: " .. item } - elseif game.is_valid_sprite_path("fluid/" .. item) then + elseif helpers.is_valid_sprite_path("fluid/" .. item) then sprite = "fluid/" .. item image_path = "[img=fluid." .. item .. "]" item_name = {"?", { "fluid-name." .. item }, "LocalizedString failure: " .. item } - elseif game.is_valid_sprite_path("virtual-signal/" .. item) then + elseif helpers.is_valid_sprite_path("virtual-signal/" .. item) then sprite = "virtual-signal/" .. item image_path = "[img=virtual-signal." .. item .. "]" item_name = {"?", { "virtual-signal." .. item }, "LocalizedString failure: " .. item } @@ -69,7 +69,7 @@ function util.slot_table_build_from_manifest(manifest, color) local name = item.name local count = item.count local sprite, img_path, item_string = util.generate_item_references(name) - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then children[#children + 1] = { type = "sprite-button", enabled = false, @@ -112,7 +112,7 @@ function util.slot_table_build_from_station(station) else color = "red" end - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then children[#children + 1] = { type = "sprite-button", enabled = false, @@ -149,7 +149,7 @@ function util.slot_table_build_from_deliveries(station) else color = "blue" end - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then children[#children + 1] = { type = "sprite-button", enabled = false, @@ -188,7 +188,7 @@ function util.slot_table_build_from_control_signals(station, map_data) else sprite = "virtual-signal" .. "/" .. name end - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then children[#children + 1] = { type = "sprite-button", enabled = false, @@ -230,7 +230,7 @@ function util.slot_table_build_from_control_signals(station, map_data) count = count * get_stack_size(map_data, name) end - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then children[#children + 1] = { type = "sprite-button", enabled = false, @@ -248,7 +248,7 @@ function util.slot_table_build_from_control_signals(station, map_data) elseif item.type == "virtual" then sprite = "virtual-signal" .. "/" .. name - if game.is_valid_sprite_path(sprite) then + if helpers.is_valid_sprite_path(sprite) then children[#children + 1] = { type = "sprite-button", enabled = false,