Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Update to Factorio 0.16
Browse files Browse the repository at this point in the history
- simple stuff:
    - most styles named `XXX_style` now named `XXX`
    - `description_flow_style` seems to have disappeared, but I
    should've made my own in the first place regardless.
        - replaced with `EvoGUI_cramped_flow_v` and `*_h`
            - for some reason, I can't just use a single `flow_style`,
            but have to specify `horizontal_*` or `vertical_*`?
    - table `colspan` now named `column_count`
- less simple: settings page doesn't work anymore, wtf?
    - checkboxes don't generate `on_gui_click` anymore?
    - added a handler for `on_gui_checked_state_changed` that calls
    `evogui.on_gui_click`
        - while also ensuring the event is only raised once if, in
        future, both of them start happening again
  • Loading branch information
narc0tiq committed Dec 14, 2017
1 parent 5878a77 commit fffc928
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.207
0.4.301
25 changes: 24 additions & 1 deletion control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ script.on_event(defines.events.on_tick, function(event)
if err then evogui.log({"err_generic", "on_tick:update_gui", err}) end
end)

script.on_event(defines.events.on_gui_click, function(event)
local last_clicked = nil
local last_checked = nil

local function raise_on_click(event)
local status, err = pcall(evogui.on_gui_click, event)

if err then
Expand All @@ -67,4 +70,24 @@ script.on_event(defines.events.on_gui_click, function(event)
evogui.log({"err_generic", "on_gui_click", err})
end
end
end

script.on_event(defines.events.on_gui_checked_state_changed, function(event)
-- prevent raising on_click twice for the same element
if last_clicked ~= nil and last_clicked == event.element.name then
return
end
last_checked = event.element.name

raise_on_click(event)
end)

script.on_event(defines.events.on_gui_click, function(event)
-- prevent raising on_click twice for the same element
if last_checked ~= nil and last_checked == event.element.name then
return
end
last_clicked = event.element.name

raise_on_click(event)
end)
10 changes: 5 additions & 5 deletions evoGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ function evogui.create_sensor_display(player)
local root = player.gui.top.add{type="frame",
name="evogui_root",
direction="horizontal",
style="outer_frame_style"}
style="outer_frame"}

local action_buttons = root.add{type="flow",
name="action_buttons",
direction="vertical",
style="description_flow_style"}
style="EvoGUI_cramped_flow_v"}
action_buttons.add{type="button",
name="evoGUI_toggle_popup",
style="EvoGUI_expando_closed"}
Expand All @@ -221,15 +221,15 @@ function evogui.create_sensor_display(player)
local sensor_flow = root.add{type="flow",
name="sensor_flow",
direction="vertical",
style="description_flow_style"}
style="EvoGUI_cramped_flow_v"}
sensor_flow.add{type="flow",
name="always_visible",
direction="vertical",
style="description_flow_style"}
style="EvoGUI_cramped_flow_v"}
sensor_flow.add{type="flow",
name="in_popup",
direction="vertical",
style="description_flow_style"}
style="EvoGUI_cramped_flow_v"}
end
end

Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "{{MOD_NAME}}",
"version": "{{VERSION}}",
"factorio_version": "0.15",
"factorio_version": "0.16",
"title": "EvoGUI - Evolution Factor Indicator and more",
"author": "Octav \"narc\" Sandulescu",
"contact": "[email protected]",
"homepage": "https://github.com/narc0tiq/evoGUI/",
"description": "Places some indicators on your UI for various little statistics that are nice to have.",
"dependencies": ["base >= 0.15.0", "? moweather"]
"dependencies": ["base >= 0.16.1", "? moweather"]
}
14 changes: 13 additions & 1 deletion prototypes/styles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end

default_gui.EvoGUI_button_with_icon = {
type = "button_style",
parent = "slot_button_style",
parent = "slot_button",

scalable = true,

Expand Down Expand Up @@ -69,3 +69,15 @@ default_gui.EvoGUI_settings = {
hovered_graphical_set = button_graphics(16, 48),
clicked_graphical_set = button_graphics(32, 48),
}

default_gui.EvoGUI_cramped_flow_v = {
type = "vertical_flow_style",
vertical_spacing = 1,
horizontal_spacing = 1,
}

default_gui.EvoGUI_cramped_flow_h = {
type = "horizontal_flow_style",
vertical_spacing = 1,
horizontal_spacing = 1,
}
8 changes: 4 additions & 4 deletions settingsGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ function evogui.evoGUI_settings(event)
name="core_settings",
caption={"settings.core_settings.title"},
direction="vertical",
style="naked_frame_style"}
style="naked_frame"}

local update_freq_flow = core_settings.add{type="flow", name="update_freq_flow", direction="horizontal"}
update_freq_flow.add{type="label", caption={"settings.core_settings.update_freq_left"}}
local textfield = update_freq_flow.add{type="textfield", name="textfield", style="number_textfield_style"}
local textfield = update_freq_flow.add{type="textfield", name="textfield", style="number_textfield"}
textfield.text=tostring(global.settings.update_delay)
update_freq_flow.add{type="label", caption={"settings.core_settings.update_freq_right"}}

local sensors_frame = root.add{type="frame",
name="sensors_frame",
caption={"settings.sensors_frame.title"},
direction="vertical",
style="naked_frame_style"}
style="naked_frame"}

local table = sensors_frame.add{type="table", name="table", colspan=4}
local table = sensors_frame.add{type="table", name="table", column_count=4}

for _, sensor in ipairs(evogui.value_sensors) do
add_sensor_table_row(table, sensor, player_data.always_visible, player_data.in_popup)
Expand Down
4 changes: 2 additions & 2 deletions value_sensors/player_locations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function sensor:create_ui(owner)
local root = owner.add{type="flow",
name=self.name,
direction="horizontal",
style="description_flow_style"}
style="EvoGUI_cramped_flow_h"}

root.add{type="label", caption={self.format_key}}
root.add{type="table", name="player_list", colspan=1}
root.add{type="table", name="player_list", column_count=1}
end
end

Expand Down

0 comments on commit fffc928

Please sign in to comment.