1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-18 03:21:36 +02:00

Change comfy panel to allow multiple admin tabs

This commit is contained in:
hanakocz 2020-03-17 04:07:33 +01:00
parent 1e9b923b69
commit 771e5e7aeb
9 changed files with 12 additions and 10 deletions

View File

@ -390,7 +390,7 @@ local function on_gui_selection_state_changed(event)
end
end
comfy_panel_tabs["Admin"] = create_admin_panel
comfy_panel_tabs["Admin"] = {gui = create_admin_panel, admin = true}

View File

@ -82,7 +82,7 @@ local function on_gui_click(event)
end
end
comfy_panel_tabs["Config"] = build_config_gui
comfy_panel_tabs["Config"] = {gui = build_config_gui, admin = false}
local event = require 'utils.event'

View File

@ -214,7 +214,7 @@ local function on_gui_click(event)
end
end
comfy_panel_tabs["Groups"] = build_group_gui
comfy_panel_tabs["Groups"] = {gui = build_group_gui, admin = false}
local event = require 'utils.event'

View File

@ -3,7 +3,8 @@ Comfy Panel
To add a tab, insert into the "comfy_panel_tabs" table.
Example: comfy_panel_tabs["mapscores"] = draw_map_scores
Example: comfy_panel_tabs["mapscores"] = {gui = draw_map_scores, admin = false}
if admin = true, then tab is visible only for admins (usable for map-specific settings)
draw_map_scores would be a function with the player and the frame as arguments
@ -62,7 +63,7 @@ local function main_frame(player)
local tabbed_pane = frame.add({type = "tabbed-pane", name = "tabbed_pane"})
for name, func in pairs(tabs) do
if name == "Admin" then
if func.admin == true then
if player.admin then
local tab = tabbed_pane.add({type = "tab", caption = name})
local frame = tabbed_pane.add({type = "frame", name = name, direction = "vertical"})
@ -142,4 +143,4 @@ end
event.add(defines.events.on_player_joined_game, on_player_joined_game)
event.add(defines.events.on_gui_click, on_gui_click)
return Public
return Public

View File

@ -388,7 +388,7 @@ local on_init = function()
global.player_list.sorting_method = {}
end
comfy_panel_tabs["Players"] = player_list_show
comfy_panel_tabs["Players"] = {gui = player_list_show, admin = false}
event.on_init(on_init)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -1297,6 +1297,6 @@ function Class.send_poll_result_to_discord(id)
Server.to_discord_embed(message)
end
comfy_panel_tabs["Polls"] = draw_main_frame
comfy_panel_tabs["Polls"] = {gui = draw_main_frame, admin = false}
return Class

View File

@ -358,7 +358,7 @@ local function tick(event)
refresh_score_full()
end
]]
comfy_panel_tabs["Scoreboard"] = show_score
comfy_panel_tabs["Scoreboard"] = {gui = show_score, admin = false}
--event.on_nth_tick(300, tick)
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)

View File

@ -30,6 +30,7 @@ global.objective.config = {}
global.flame_boots = {}
global.comfylatron = nil
global.lab_cells = {}
require "maps.chronosphere.config_tab"
local starting_items = {['pistol'] = 1, ['firearm-magazine'] = 32, ['grenade'] = 4, ['raw-fish'] = 4, ['rail'] = 16, ['wood'] = 16}

View File

@ -104,7 +104,7 @@ local function on_gui_click(event)
if event.element.name == "close_map_intro" then game.players[event.player_index].gui.left.comfy_panel.destroy() return end
end
comfy_panel_tabs["Map Info"] = create_map_intro
comfy_panel_tabs["Map Info"] = {gui = create_map_intro, admin = false}
local event = require 'utils.event'
event.add(defines.events.on_player_joined_game, on_player_joined_game)