From 783e3d6862df9ae9e5f5dbdc438663bf050b32c1 Mon Sep 17 00:00:00 2001 From: Octav Sandulescu Date: Wed, 30 Sep 2015 12:38:06 +0000 Subject: [PATCH] Remove offline players by default, configurable. Closes #32. Attn. #23 (new locale added) --- evoGUI.lua | 3 +++ locale/en/locale.cfg | 1 + value_sensors/player_locations.lua | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/evoGUI.lua b/evoGUI.lua index d2e4856..d36f8a3 100644 --- a/evoGUI.lua +++ b/evoGUI.lua @@ -73,7 +73,10 @@ function evogui.create_player_globals(player) ['show_position'] = false, ['show_surface'] = false, ['show_direction'] = true, + ['show_offline'] = false, } + elseif player_settings.sensor_settings['player_locations'].show_offline == nil then + player_settings.sensor_settings['player_locations'].show_offline = false end if not player_settings.sensor_settings['day_time'] then diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 199de50..1c30c09 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -28,6 +28,7 @@ sensor.player_locations.settings.show_player_index=Show player index sensor.player_locations.settings.show_position=Show coordinates sensor.player_locations.settings.show_surface=Show surface the player is on sensor.player_locations.settings.show_direction=Show direction to walk to reach the player +sensor.player_locations.settings.show_offline=Show offline players sensor.pollution_around_player.name=Nearby pollution level sensor.pollution_around_player.format=Pollution: __1__ PU. diff --git a/value_sensors/player_locations.lua b/value_sensors/player_locations.lua index ef5e37f..0c95fca 100644 --- a/value_sensors/player_locations.lua +++ b/value_sensors/player_locations.lua @@ -46,6 +46,11 @@ function sensor:settings_gui(player_index) state=sensor_settings.show_direction} evogui.on_click.evogui_show_direction = self:make_on_click_checkbox_handler("show_direction") + root.add{type="checkbox", name="evogui_show_offline", + caption={"sensor.player_locations.settings.show_offline"}, + state=sensor_settings.show_offline} + evogui.on_click.evogui_show_offline = self:make_on_click_checkbox_handler("show_offline") + local btn_close = root.add{type="button", name="evogui_custom_sensor_close", caption={"settings_close"}} evogui.on_click[btn_close.name] = function(event) self:close_settings_gui(player_index) end end @@ -93,6 +98,13 @@ function sensor:update_ui(owner) if gui_list.error ~= nil then gui_list.error.destroy() end + if p.connected == false and not sensor_settings.show_offline then + if gui_list[p.name] and gui_list[p.name].valid then + gui_list[p.name].destroy() + end + goto next_player + end + if gui_list[p.name] == nil then gui_list.add{type="label", name=p.name} end @@ -132,10 +144,12 @@ function sensor:update_ui(owner) end if sensor_settings.show_direction then - table.insert(desc, ' ' .. direction) + table.insert(desc, ' ') + table.insert(desc, direction) end gui_list[p.name].caption = desc + ::next_player:: end end