Commit 12fb063d authored by Rob Nelson's avatar Rob Nelson
Browse files

Update EvoGUI and RSO.

parent 6b38841f
EvoGUI is released under the MIT license. Informally, this means you can
do basically whatever with it you like, as long as you leave this file intact.
The full legalese is below.
EvoGUI is Copyright (c) 2015 Octav "narc" Sandulescu
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
This is a [Factorio](http://www.factorio.com/) mod. It adds a small UI frame
that informs you of the current biter evolution level, as well as your play
time.
## Many thanks for ##
* The many downloads so far! Glad you guys are liking it.
* Continuous Integration by CircleCI: [![Circle CI](https://circleci.com/gh/narc0tiq/evoGUI.svg?style=svg)](https://circleci.com/gh/narc0tiq/evoGUI)
* Many, many improvements made by Afforess! Thanks so much, you're the best!
* The wonderful translations contributed by these awesome people:
JoCKeRiL (Hebrew), Rikkilook (Russian), theRustyKnife (Czech),
thomaskneisel and BenediktMagnus (German), diilmac (Polish).
## License ##
The source of **EvoGUI** is Copyright 2015 Octav "narc" Sandulescu. It
is licensed under the [MIT license][mit], available in this package in the file
[LICENSE.md](LICENSE.md).
[mit]: http://opensource.org/licenses/mit-license.html
## Statistics ##
78 exceptions were caught during the creation of this mod.
require "evoGUI"
if not evogui then evogui = {} end
function evogui.log(message)
if game then
for i, p in pairs(game.players) do
p.print(message)
end
else
error(serpent.dump(message, {compact = false, nocode = true, indent = ' '}))
end
end
function evogui.format_number(n) -- credit http://richard.warburton.it
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
end
function string.starts_with(haystack, needle)
return string.sub(haystack, 1, string.len(needle)) == needle
end
local octant_names = {
[0] = {"direction.east"},
[1] = {"direction.southeast"},
[2] = {"direction.south"},
[3] = {"direction.southwest"},
[4] = {"direction.west"},
[5] = {"direction.northwest"},
[6] = {"direction.north"},
[7] = {"direction.northeast"},
}
function evogui.get_octant_name(vector)
local radians = math.atan2(vector.y, vector.x)
local octant = math.floor( 8 * radians / (2*math.pi) + 8.5 ) % 8
return octant_names[octant]
end
script.on_init(evogui.mod_init)
script.on_configuration_changed(evogui.mod_update)
script.on_event(defines.events.on_player_created, function(event)
local status, err = pcall(evogui.new_player, event)
if err then evogui.log({"err_generic", "on_player_created", err}) end
end)
script.on_event(defines.events.on_tick, function(event)
local status, err = pcall(RemoteSensor.initialize)
if err then evogui.log({"err_generic", "on_tick:remote_initialize", err}) end
local status, err = pcall(evogui.update_gui, 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 status, err = pcall(evogui.on_gui_click, event)
if err then
if event.element.valid then
evogui.log({"err_specific", "on_gui_click", event.element.name, err})
else
evogui.log({"err_generic", "on_gui_click", err})
end
end
end)
require "prototypes.styles"
require "value_sensors.day_time"
require "value_sensors.evolution_factor"
require "value_sensors.kill_count"
require "value_sensors.play_time"
require "value_sensors.player_locations"
require "value_sensors.pollution_around_player"
require "value_sensors.remote_sensor"
require "settingsGUI"
require "remote"
if not evogui then evogui = {} end
function evogui.mod_init()
if not global.settings then global.settings = {} end
if not global.settings.update_delay then global.settings.update_delay = 60 end
for _, player in pairs(game.players) do
evogui.create_player_globals(player)
evogui.create_sensor_display(player)
end
end
function evogui.mod_update(data)
if data.mod_changes then
if data.mod_changes["EvoGUI"] then
-- TODO: If a more major migration ever needs doing, do that here.
-- Otherwise, just falling back to mod_init should work fine.
evogui.mod_init()
end
evogui.validate_sensors(data.mod_changes)
end
end
function evogui.on_gui_click(event)
if string.starts_with(event.element.name, "evogui_settings_gui_") then
evogui.on_settings_click(event)
elseif event.element.name == "evoGUI_toggle_popup" then
evogui.evoGUI_toggle_popup(event)
elseif string.starts_with(event.element.name, "evogui_sensor_") then
for _, sensor in pairs(evogui.value_sensors) do
-- if the gui element name matches 'evogui_sensor_' + sensor_name, send it the on_click event.
if string.starts_with(event.element.name, "evogui_sensor_" .. sensor.name) then
sensor:on_click(event)
break
end
end
end
end
-- Iterate through all value_sensors, if any are associated with a mod_name that
-- has been removed, remove the sensor from the list of value_sensors.
function evogui.validate_sensors(mod_changes)
for i = #evogui.value_sensors, 1, -1 do
local sensor = evogui.value_sensors[i]
if sensor.mod_name and mod_changes[sensor.mod_name] then
-- mod removed, remove sensor from ui
if mod_changes[sensor.mod_name].new_version == nil then
evogui.hide_sensor(sensor)
table.remove(evogui.value_sensors, i)
end
end
end
end
function evogui.hide_sensor(sensor)
for player_name, data in pairs(global.evogui) do
if data.always_visible then
data.always_visible[sensor["name"]] = false
end
end
for _, player in pairs(game.players) do
local player_settings = global.evogui[player.name]
local sensor_flow = player.gui.top.evoGUI.sensor_flow
evogui.update_av(player, sensor_flow.always_visible)
end
end
function evogui.new_player(event)
local player = game.players[event.player_index]
evogui.create_player_globals(player)
evogui.create_sensor_display(player)
end
function evogui.update_gui(event)
if (event.tick % global.settings.update_delay) ~= 0 then return end
for player_index, player in pairs(game.players) do
local player_settings = global.evogui[player.name]
-- saves converted from SP with no username to MP won't raise evogui.new_player
-- so we have to check here, as well.
if not player_settings then
evogui.new_player({player_index = player_index})
player_settings = global.evogui[player.name]
end
local sensor_flow = player.gui.top.evoGUI.sensor_flow
evogui.update_av(player, sensor_flow.always_visible)
if player_settings.popup_open then
evogui.update_ip(player, sensor_flow.in_popup)
end
end
end
function evogui.create_player_globals(player)
if not global.evogui then global.evogui = {} end
if not global.evogui[player.name] then global.evogui[player.name] = {} end
local player_settings = global.evogui[player.name]
if not player_settings.version then player_settings.version = "" end
if not player_settings.always_visible then
player_settings.always_visible = {
["evolution_factor"] = true,
["play_time"] = true,
}
end
if not player_settings.in_popup then
player_settings.in_popup = {
["day_time"] = true,
}
end
if not player_settings.popup_open then player_settings.popup_open = false end
if not player_settings.sensor_settings then
player_settings.sensor_settings = {}
end
if not player_settings.sensor_settings['player_locations'] then
player_settings.sensor_settings['player_locations'] = {
['show_player_index'] = false,
['show_position'] = false,
['show_surface'] = false,
['show_direction'] = true,
['show_offline'] = false,
}
elseif player_settings.sensor_settings['player_locations'].show_offline == nil then
-- 0.4.3 new feature (783e3d68)
player_settings.sensor_settings['player_locations'].show_offline = false
end
if not player_settings.sensor_settings['day_time'] then
player_settings.sensor_settings['day_time'] = {
['show_day_number'] = false,
['minute_rounding'] = true,
}
end
if not player_settings.sensor_settings['evolution_factor'] then
player_settings.sensor_settings['evolution_factor'] = {
['extra_precision'] = false,
}
end
if not player_settings.sensor_settings['play_time'] then
player_settings.sensor_settings['play_time'] = {
['show_days'] = true,
['show_seconds'] = true,
}
end
end
function evogui.create_sensor_display(player)
local root = player.gui.top.evoGUI
local destroyed = false
if root then
player.gui.top.evoGUI.destroy()
destroyed = true
end
if not root or destroyed then
local root = player.gui.top.add{type="frame",
name="evoGUI",
direction="horizontal",
style="outer_frame_style"}
local action_buttons = root.add{type="flow",
name="action_buttons",
direction="vertical",
style="description_flow_style"}
action_buttons.add{type="button",
name="evoGUI_toggle_popup",
style="EvoGUI_expando_closed"}
if global.evogui[player.name].popup_open then
action_buttons.evoGUI_toggle_popup.style = "EvoGUI_expando_open"
end
action_buttons.add{type="button",
name="evogui_settings_gui_settings_open",
style="EvoGUI_settings"}
local sensor_flow = root.add{type="flow",
name="sensor_flow",
direction="vertical",
style="description_flow_style"}
sensor_flow.add{type="flow",
name="always_visible",
direction="vertical",
style="description_flow_style"}
sensor_flow.add{type="flow",
name="in_popup",
direction="vertical",
style="description_flow_style"}
end
end
local function update_sensors(element, sensor_list, active_sensors)
for _, sensor in ipairs(sensor_list) do
if active_sensors[sensor.name] then
local status, err = pcall(sensor.create_ui, sensor, element)
if err then error({"err_specific", sensor.name, "create_ui", err}) end
status, err = pcall(sensor.update_ui, sensor, element)
if err then error({"err_specific", sensor.name, "update_ui", err}) end
else
local status, err = pcall(sensor.delete_ui, sensor, element)
if err then error({"err_specific", sensor.name, "delete_ui", err}) end
end
end
end
function evogui.update_av(player, element)
local always_visible = global.evogui[player.name].always_visible
update_sensors(element, evogui.value_sensors, always_visible)
end
function evogui.update_ip(player, element)
if not global.evogui[player.name].popup_open then return end
local in_popup = global.evogui[player.name].in_popup
update_sensors(element, evogui.value_sensors, in_popup)
end
function evogui.evoGUI_toggle_popup(event)
local player = game.players[event.player_index]
local player_settings = global.evogui[player.name]
local root = player.gui.top.evoGUI
if player_settings.popup_open then
-- close it
player_settings.popup_open = false
for _, childname in ipairs(root.sensor_flow.in_popup.children_names) do
root.sensor_flow.in_popup[childname].destroy()
end
root.action_buttons.evoGUI_toggle_popup.style = "EvoGUI_expando_closed"
else
-- open it
player_settings.popup_open = true
evogui.update_ip(player, root.sensor_flow.in_popup)
root.action_buttons.evoGUI_toggle_popup.style = "EvoGUI_expando_open"
end
end
{
"name": "EvoGUI",
"version": "0.4.202",
"factorio_version": "0.15",
"title": "EvoGUI - Evolution Factor Indicator and more",
"author": "Octav \"narc\" Sandulescu",
"contact": "factorio-mods@narc.ro",
"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"]
}
sensor.day_time.name=Aktuální čas/intenzita světla
sensor.day_time.format=Je __1__. Světlo: __2__.
sensor.day_time.day_format=Je __1__, __2__. dne. Světlo: __3__
sensor.day_time.settings.title=Nastavení času
sensor.day_time.settings.show_day_number=Zobrazit aktuální planetární den od přistání.
sensor.day_time.settings.minute_rounding=Zaokrouhlit minuty na čtvrthodiny (xx:15, xx:30, atd).
sensor.evolution_factor.name=Evoluční faktor
sensor.evolution_factor.format=Vývoj kousačů: __1__.
sensor.evolution_factor.settings.title=Nastavení zobrazení evolučního faktoru
sensor.evolution_factor.settings.extra_precision=Zobrazit čtyři desetinná místa (x.1234%) místo jednoho (x.1%).
sensor.play_time.name=Doba hraní
sensor.play_time.format=Doba hraní: __1__.
sensor.play_time.single_day_fragment=1 den,
sensor.play_time.multi_day_fragment=__1__ dní,
sensor.play_time.settings.title=Playing time settings
sensor.play_time.settings.show_days=Zobrazit dny ("2 dny, 01:00" místo "49:00")
sensor.play_time.settings.show_seconds=Zobrazit sekundy ("hh:mm:ss" místo of "hh:mm").
sensor.player_locations.name=Umístění hráčů
sensor.player_locations.format=Hráči:
sensor.player_locations.err_no_name=Nemáš žádné jméno pro multiplayer, seznam hráčů vypnut.
sensor.player_locations.surface_fragment=na __1__
sensor.player_locations.offline_fragment=[Offline]
sensor.player_locations.settings.title=Nastavení zobrazení umístění hráčů
sensor.player_locations.settings.show_player_index=Zobrazit index hráče
sensor.player_locations.settings.show_position=Zobrazit souřadnice
sensor.player_locations.settings.show_surface=Zobrazit povrch (surface) na kterém hráč je
sensor.player_locations.settings.show_direction=Zobrazit směr k hráči
sensor.player_locations.settings.show_offline=Zobrazit hráče, kteří jsou offline
sensor.pollution_around_player.name=Úroveň znečištění v okolí
sensor.pollution_around_player.format=Znečištění: __1__ PU.
sensor.kill_count.name=Počet zabití (pro tvůj tým)
sensor.kill_count.format=Počet zabití: __1__, __2__, __3__.
sensor.kill_count.biter_fragment_single=1 kousač
sensor.kill_count.biter_fragment_multiple=__1__ kousačů
sensor.kill_count.spawner_fragment_single=1 líheň
sensor.kill_count.spawner_fragment_multiple=__1__ líhní
sensor.kill_count.other_fragment_single=1 jiný
sensor.kill_count.other_fragment_multiple=__1__ jiných
settings_title=Nastavení EvoGUI
settings.core_settings.title=Základní nastavení (sdílené)
settings.core_settings.update_freq_left=Aktualizovat EvoGUI každých
settings.core_settings.update_freq_right=ticků (1 sekunda má 60 ticků)
settings.sensors_frame.title=Nastavení senzorů
settings_always_visible=Vždy viditelné
settings_in_popup=Viditelné po rozkliknutí
settings_close=Zavřít
direction.north=S
direction.south=J
direction.east=V
direction.west=Z
direction.northeast=SV
direction.northwest=SZ
direction.southeast=JV
direction.southwest=JZ
direction.unknown=?
err_generic=[EvoGUI|__1__] Error: __2__
err_specific=[EvoGUI|__1__|__2__] Error: __3__
err_settings_badcall=__1__ called on the wrong thing!
err_settings_whatsensor=__1__ can't find sensor!
err_settings_whatsettings=__1__ called for settings-less sensor!
err_needplayername=[EvoGUI] Je potřeba jméno hráče!
err_nosuchplayer=[EvoGUI] Hráč __1__ neexistuje!
err_noplayerdata=[EvoGUI] Žádná data pro hráče __1__!
err_nosensorname=[EvoGUI] Missing a sensor name!
err_no_sensor_data=[EvoGUI] Missing remote sensor data!
err_sensor_missing_field=[EvoGUI] Remote sensor __1__ is missing a required field __2__!
err_nosensortext=[EvoGUI] Missing sensor text for __1__!
err_nosensorcaption=[EvoGUI] Missing caption text for __1__!
err_nosensorfound=[EvoGUI] No sensor matching the name __1__! Create a sensor first.
sensor.day_time.name=Tageszeit/Sonnenlicht
sensor.day_time.format=Es ist __1__ Uhr. Helligkeit: __2__.
sensor.day_time.day_format=Es ist __1__ Uhr am Tag __2__. Helligkeit: __3__
sensor.day_time.settings.title=Einstellungen Tageszeit
sensor.day_time.settings.show_day_number=Tage seit der Landung auf dem Planeten anzeigen.
sensor.day_time.settings.minute_rounding=Angezeigte Minuten werden auf Viertelstunden gerundet (xx:15, xx:30, etc).
sensor.evolution_factor.name=Evolutionsfaktor
sensor.evolution_factor.format=Beißerevolution: __1__.
sensor.evolution_factor.settings.title=Einstellungen Evolutonsfaktoranzeige
sensor.evolution_factor.settings.extra_precision=Zeige vier Nachkommastellen (x.1234%) anstatt einer (x.1%).
sensor.play_time.name=Gesamte Spielzeit
sensor.play_time.format=Spielzeit: __1__.
sensor.play_time.single_day_fragment=1 Tag,
sensor.play_time.multi_day_fragment=__1__ Tage,
sensor.play_time.settings.title=Einstellungen Spielzeit
sensor.play_time.settings.show_days=Tage anzeigen("2 Tage, 01:00" anstatt "49:00")
sensor.play_time.settings.show_seconds=Sekunden anzeigen("hh:mm:ss" anstatt "hh:mm").
sensor.player_locations.name=Spielerpositionen
sensor.player_locations.format=Spieler:
sensor.player_locations.err_no_name=Solange du keinen Mehspielerbenutzernamen angegeben hast, ist die Spielerliste deaktiviert.
sensor.player_locations.local_player=Lokaler Spieler
sensor.player_locations.surface_fragment=Auf __1__
sensor.player_locations.offline_fragment=[Offline]
sensor.player_locations.settings.title=Einstellungen Spielerposition
sensor.player_locations.settings.show_player_index=Spielerindex anzeigen
sensor.player_locations.settings.show_position=Koordinaten anzeigen
sensor.player_locations.settings.show_surface=Zeige Spielfläche des Spielers an
sensor.player_locations.settings.show_direction=Bewegungsrichtung zum Spieler anzeigen
sensor.player_locations.settings.show_offline=Abwesende Spieler anzeigen
sensor.pollution_around_player.name=Verschmutzung in der Nähe
sensor.pollution_around_player.format=Verschmutzung: __1__ PU.
sensor.kill_count.name=Abschusszähler (für dein Team)
sensor.kill_count.format=Abschüsse: __1__, __2__, __3__.
sensor.kill_count.biter_fragment_single=1 Beißer
sensor.kill_count.biter_fragment_multiple=__1__ Beißer
sensor.kill_count.spawner_fragment_single=1 Nest
sensor.kill_count.spawner_fragment_multiple=__1__ Nester
sensor.kill_count.other_fragment_single=1 anderes
sensor.kill_count.other_fragment_multiple=__1__ andere
settings_title=Einstellungen EvoGUI
settings.core_settings.title=Basiseinstellungen (geteilt)
settings.core_settings.update_freq_left=Aktualisiere EvoGUI alle
settings.core_settings.update_freq_right=Ticks (es gibt 60 Ticks pro Sekunde)
settings.sensors_frame.title=Einstellungen Sensoren
settings_always_visible=immer sichbar
settings_in_popup=im Popup sichbar
settings_close=Schließen
direction.north=N
direction.south=S
direction.east=O
direction.west=W
direction.northeast=NO
direction.northwest=NW
direction.southeast=SO
direction.southwest=SW
direction.unknown=?
err_generic=[EvoGUI|__1__] Fehler: __2__
err_specific=[EvoGUI|__1__|__2__] Fehler: __3__
err_settings_badcall=__1__ wurde auf dem falschen Ding aufgerufen!
err_settings_whatsensor=__1__ kann Sensor nicht finden!
err_settings_whatsettings=__1__ wurde für einen nicht einstellbaren Sensor aufgerufen!
err_needplayername=[EvoGUI] Benötige Spielernamen!
err_nosuchplayer=[EvoGUI] Spieler nicht gefunden: __1__!
err_noplayerdata=[EvoGUI] Keine Spieldaten für __1__!
err_nosensorname=[EvoGUI] Fehlender Sensorname!
err_no_sensor_data=[EvoGUI] Fehlende Sensordaten (remote)!
err_sensor_missing_field=[EvoGUI] Sensor (remote) __1__ fehlt ein benötigtes Feld __2__!
err_nosensortext=[EvoGUI] Sensortext für __1__ fehlt!
err_nosensorcaption=[EvoGUI] Beschreibungstext für __1__ fehlt!
err_nosensorfound=[EvoGUI] Kein Sensor mit dem Namen __1__ gefunden! Bitte erstelle erst einen Sensor.
sensor.day_time.name=Time of day/sunlight
sensor.day_time.format=It's __1__. Brightness: __2__.
sensor.day_time.day_format=It's __1__ on day __2__. Brightness: __3__
sensor.day_time.settings.title=Time of day settings
sensor.day_time.settings.show_day_number=Show the current planetary day since landing.
sensor.day_time.settings.minute_rounding=Round displayed minutes to a quarter hour (xx:15, xx:30, etc).
sensor.evolution_factor.name=Evolution factor
sensor.evolution_factor.format=Biter evolution: __1__.
sensor.evolution_factor.settings.title=Evolution factor display settings
sensor.evolution_factor.settings.extra_precision=Show four decimals (x.1234%) instead of one (x.1%).
sensor.play_time.name=Time played
sensor.play_time.format=Play time: __1__.
sensor.play_time.single_day_fragment=1 day,
sensor.play_time.multi_day_fragment=__1__ days,
sensor.play_time.settings.title=Playing time settings
sensor.play_time.settings.show_days=Show days ("2 days, 01:00" instead of "49:00")
sensor.play_time.settings.show_seconds=Show seconds ("hh:mm:ss" instead of "hh:mm").
sensor.player_locations.name=Player locations
sensor.player_locations.format=Players:
sensor.player_locations.err_no_name=You have no multiplayer username, player list disabled.
sensor.player_locations.local_player=Local player