diff --git a/changelog.txt b/changelog.txt index 389695f..6c51e6e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Date: xx.xx.2019 Features: - added support for all modded train station (prototype type "train-stop") - added sanity-checks, so crashes not occur anymore + - added refresh button, that rescans the stations --------------------------------------------------------------------------------------------------- Version: 1.1.0 Date: 16.06.2019 diff --git a/control.lua b/control.lua index d338fe7..9f01108 100644 --- a/control.lua +++ b/control.lua @@ -16,6 +16,8 @@ local search_boxes = {} local search_text_fields = {} -- search_text[player.index] = text local search_text = {} +-- reload_buttons[player.index] = reload_button +local reload_buttons = {} function check_station(station) if station then @@ -96,10 +98,13 @@ function create_gui(player_index) -- search local search_text_field = titleFlow.add{ type = "textfield", visible = search_text[player_index] ~= nil, text = search_text[player_index]} - local search_button = titleFlow.add{ type = "sprite-button", style = "tool_button", sprite = "utility/search_icon", tooltip = { "gui.search-with-focus", { "search"}}} + local search_button = titleFlow.add{ type = "sprite-button", style = "tool_button", sprite = "utility/search_icon", tooltip = { "gui.search"}} search_boxes[search_button.index] = search_text_field search_text_fields[search_text_field.index] = search_text_field + local reload_button = titleFlow.add{type = "sprite-button", style = "tool_button", sprite = "train-station-overview-refresh-sprite", tooltip = {"refresh-stations"}} + reload_buttons[player.index] = reload_button + if #global.train_stops < 1 then frame.add{type = "label", caption = {"no-train-stops"}} return @@ -384,6 +389,12 @@ script.on_event(defines.events.on_gui_click, close_gui_clear(e.player_index) end end + + -- reload train stops + if reload_buttons[player.index] and reload_buttons[player.index].valid and reload_buttons[player.index].index == e.element.index then + on_load() + refresh_all_guis() + end end ) diff --git a/data.lua b/data.lua index 0777094..6c14f8d 100644 --- a/data.lua +++ b/data.lua @@ -8,5 +8,12 @@ data:extend{ priority = "extra-high", width = 32, height = 32 + }, + { + type = "sprite", + name = "train-station-overview-refresh-sprite", + filename = "__core__/graphics/icons/refresh.png", + width = 32, + height = 32 } } diff --git a/locale/en/main.cfg b/locale/en/main.cfg index 4322eab..9e5c630 100644 --- a/locale/en/main.cfg +++ b/locale/en/main.cfg @@ -5,6 +5,7 @@ station-name=Station __1__ no-train-stops=No train stations found :( open-on-map-tooltip=Open on map station-button-tooltip=Open station +refresh-stations=Refresh train stations [controls] open-train-stop-overview=Open train station overview