Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surveillance #321

Merged
merged 7 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions locale/en/gui.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ control-type-storage-output=Storage Output
[module]
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]
main-caption=Toolbox
main-tooltip=Toolbox Settings\nUse the checkboxs to select facourites
Expand Down
9 changes: 9 additions & 0 deletions locale/zh-CN/gui.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ control-type-storage-output=提取箱
[module]
main-tooltip=模組介面

[surveillance]
main-tooltip=監控介面
status-enable=啟用
status-disable=停用
func-set=設
type-player=用戶
type-static=靜態
type-player-loop=用戶循環

[toolbar]
main-caption=工具箱
main-tooltip=工具箱設定\n選上來設定喜好
Expand Down
9 changes: 9 additions & 0 deletions locale/zh-TW/gui.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ control-type-storage-output=提取箱
[module]
main-tooltip=模組介面

[surveillance]
main-tooltip=監控介面
status-enable=啟用
status-disable=停用
func-set=設
type-player=用戶
type-static=靜態
type-player-loop=用戶循環

[toolbar]
main-caption=工具箱
main-tooltip=工具箱設定\n選上來設定喜好
Expand Down
37 changes: 30 additions & 7 deletions modules/gui/surveillance.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end)
local cctv_status =
Gui.element{
type = 'drop-down',
items = {'Enable', 'Disable'},
items = {{'surveillance.status-enable'}, {'surveillance.status-disable'}},
selected_index = 2
}:style{
width = 96
Expand All @@ -38,7 +38,7 @@ local cctv_type =
Gui.element{
type = 'drop-down',
name = Gui.unique_static_name,
items = {'Player', 'Static'},
items = {{'surveillance.type-player'}, {'surveillance.type-static'}, {'surveillance.type-player-loop'}},
selected_index = 1
}:style{
width = 96
Expand All @@ -48,7 +48,7 @@ local cctv_location =
Gui.element{
type = 'button',
name = Gui.unique_static_name,
caption = 'set'
caption = {'surveillance.func-set'}
}:style{
width = 48
}:on_click(function(player, element, _)
Expand Down Expand Up @@ -104,8 +104,8 @@ Gui.element(function(_, parent, name, player_list)
}

camera.visible = false
camera.style.minimal_width = 400
camera.style.minimal_height = 300
camera.style.minimal_width = 480
camera.style.minimal_height = 290
return camera_set
end)

Expand All @@ -128,7 +128,7 @@ end)
:static_name(Gui.unique_static_name)
: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')
end)

Expand Down Expand Up @@ -158,7 +158,7 @@ Event.add(defines.events.on_tick, function(_)
local current_camera_set = frame.container.scroll[scroll_table_name]
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

if selected_index ~= 0 then
Expand All @@ -174,3 +174,26 @@ Event.add(defines.events.on_tick, function(_)
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)
Loading