Surveillance Player Loop (#321)

* Update surveillance.lua

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update surveillance.lua

* Update surveillance.lua
This commit is contained in:
2024-09-02 06:17:03 +09:00
committed by GitHub
parent e8f2c53fca
commit b308b0020c
4 changed files with 57 additions and 7 deletions

View File

@@ -288,6 +288,15 @@ control-type-storage-output=Storage Output
[module] [module]
main-tooltip=Module GUI main-tooltip=Module GUI
[surveillance]
main-tooltip=Surveillance GUI
status-enable=Enable
status-disable=Disable
func-set=Set
type-player=Player
type-static=Static
type-player-loop=Player loop
[toolbar] [toolbar]
main-caption=Toolbox main-caption=Toolbox
main-tooltip=Toolbox Settings\nUse the checkboxs to select facourites main-tooltip=Toolbox Settings\nUse the checkboxs to select facourites

View File

@@ -288,6 +288,15 @@ control-type-storage-output=提取箱
[module] [module]
main-tooltip=模組介面 main-tooltip=模組介面
[surveillance]
main-tooltip=監控介面
status-enable=啟用
status-disable=停用
func-set=
type-player=用戶
type-static=靜態
type-player-loop=用戶循環
[toolbar] [toolbar]
main-caption=工具箱 main-caption=工具箱
main-tooltip=工具箱設定\n選上來設定喜好 main-tooltip=工具箱設定\n選上來設定喜好

View File

@@ -288,6 +288,15 @@ control-type-storage-output=提取箱
[module] [module]
main-tooltip=模組介面 main-tooltip=模組介面
[surveillance]
main-tooltip=監控介面
status-enable=啟用
status-disable=停用
func-set=
type-player=用戶
type-static=靜態
type-player-loop=用戶循環
[toolbar] [toolbar]
main-caption=工具箱 main-caption=工具箱
main-tooltip=工具箱設定\n選上來設定喜好 main-tooltip=工具箱設定\n選上來設定喜好

View File

@@ -22,7 +22,7 @@ end)
local cctv_status = local cctv_status =
Gui.element{ Gui.element{
type = 'drop-down', type = 'drop-down',
items = {'Enable', 'Disable'}, items = {{'surveillance.status-enable'}, {'surveillance.status-disable'}},
selected_index = 2 selected_index = 2
}:style{ }:style{
width = 96 width = 96
@@ -38,7 +38,7 @@ local cctv_type =
Gui.element{ Gui.element{
type = 'drop-down', type = 'drop-down',
name = Gui.unique_static_name, name = Gui.unique_static_name,
items = {'Player', 'Static'}, items = {{'surveillance.type-player'}, {'surveillance.type-static'}, {'surveillance.type-player-loop'}},
selected_index = 1 selected_index = 1
}:style{ }:style{
width = 96 width = 96
@@ -48,7 +48,7 @@ local cctv_location =
Gui.element{ Gui.element{
type = 'button', type = 'button',
name = Gui.unique_static_name, name = Gui.unique_static_name,
caption = 'set' caption = {'surveillance.func-set'}
}:style{ }:style{
width = 48 width = 48
}:on_click(function(player, element, _) }:on_click(function(player, element, _)
@@ -104,8 +104,8 @@ Gui.element(function(_, parent, name, player_list)
} }
camera.visible = false camera.visible = false
camera.style.minimal_width = 400 camera.style.minimal_width = 480
camera.style.minimal_height = 300 camera.style.minimal_height = 290
return camera_set return camera_set
end) end)
@@ -128,7 +128,7 @@ end)
:static_name(Gui.unique_static_name) :static_name(Gui.unique_static_name)
:add_to_left_flow() :add_to_left_flow()
Gui.left_toolbar_button('entity/radar', 'Surveillance GUI', cctv_container, function(player) Gui.left_toolbar_button('entity/radar', {'surveillance.main-tooltip'}, cctv_container, function(player)
return Roles.player_allowed(player, 'gui/surveillance') return Roles.player_allowed(player, 'gui/surveillance')
end) end)
@@ -158,7 +158,7 @@ Event.add(defines.events.on_tick, function(_)
local current_camera_set = frame.container.scroll[scroll_table_name] local current_camera_set = frame.container.scroll[scroll_table_name]
local switch_index = current_camera_set.buttons.table[cctv_type.name].selected_index local switch_index = current_camera_set.buttons.table[cctv_type.name].selected_index
if switch_index == 1 then if (switch_index == 1) or (switch_index == 3) then
local selected_index = current_camera_set.buttons.table[cctv_player.name].selected_index local selected_index = current_camera_set.buttons.table[cctv_player.name].selected_index
if selected_index ~= 0 then if selected_index ~= 0 then
@@ -174,3 +174,26 @@ Event.add(defines.events.on_tick, function(_)
end end
end end
end) end)
Event.on_nth_tick(600, function(_)
for _, player in pairs(game.connected_players) do
local frame = Gui.get_left_element(player, cctv_container)
for i=1, 2 do
local current_camera_set = frame.container.scroll['cctv_st_' .. i]
if current_camera_set.buttons.table[cctv_type.name].selected_index == 3 then
local item_n = #current_camera_set.buttons.table[cctv_player.name].items
if item_n ~= 0 then
if current_camera_set.buttons.table[cctv_player.name].selected_index < item_n then
current_camera_set.buttons.table[cctv_player.name].selected_index = current_camera_set.buttons.table[cctv_player.name].selected_index + 1
else
current_camera_set.buttons.table[cctv_player.name].selected_index = 1
end
end
end
end
end
end)