From 8b717ee1a5817a1b5319c2cb0055914fd519b582 Mon Sep 17 00:00:00 2001 From: bbassie Date: Sun, 24 Jan 2021 01:58:30 +0100 Subject: [PATCH] Warp improvements * Fixed that it clears table every warp update. * Dirty fix unknown signal icon, it gets replaced by the old icon --- modules/control/warps.lua | 5 +++++ modules/gui/warp-list.lua | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/control/warps.lua b/modules/control/warps.lua index 5c797805..e66d3998 100644 --- a/modules/control/warps.lua +++ b/modules/control/warps.lua @@ -359,6 +359,11 @@ Warps.update_warp(warp_id, 'My Warp', 'iron-plate', game.player.name) ]] function Warps.update_warp(warp_id, new_name, new_icon, player_name) WrapData:update(warp_id, function(_, warp) + -- If the icon is not valid then replace with the old icon + if new_icon and not new_icon.name or not new_icon.type then + new_icon = warp.icon + end + warp.last_edit_name = player_name or '' warp.last_edit_time = game.tick warp.name = new_name or warp.name diff --git a/modules/gui/warp-list.lua b/modules/gui/warp-list.lua index 09651779..95059507 100644 --- a/modules/gui/warp-list.lua +++ b/modules/gui/warp-list.lua @@ -550,9 +550,18 @@ local function update_warp(player, warp_table, warp_id) else -- Set the icon elements visibility warp_icon_element.visible = true + -- The SpritePath type is not the same as the SignalID type + local sprite = warp.icon.type .. '/' ..warp.icon.name + if warp.icon.type == 'virtual' then + sprite = 'virtual-signal/' ..warp.icon.name + end + warp_icon_element.sprite = sprite + -- Set icon edit to the warps icon + warp_icon_edit_element.elem_value = warp.icon warp_icon_edit_element.visible = false -- Set the name elements visibility label_element.visible = true + label_element.caption = warp.name textfield_element.visible = false -- Set the edit buttons cancel_edit_element.visible = false @@ -585,7 +594,6 @@ local function update_all_warp_force(force) local frame = Gui.get_left_element(player, warp_list_container) local warp_table = frame.container.scroll.table - warp_table.clear() for _, warp_id in ipairs(warp_ids) do update_warp(player, warp_table, warp_id) end