Skip to content

Commit

Permalink
added button to reload stations
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxfighter committed Jul 13, 2019
1 parent 4f87e0d commit fdc94a0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)

Expand Down
7 changes: 7 additions & 0 deletions data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions locale/en/main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fdc94a0

Please sign in to comment.