1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-06 00:23:49 +02:00

enable feature on /debug command

This commit is contained in:
Gerkiz 2021-03-28 17:01:39 +02:00
parent 8920aff657
commit d12b4423db
4 changed files with 36 additions and 72 deletions

View File

@ -13,6 +13,7 @@ commands.add_command(
player.print('Only admins can use this command.')
return
end
DebugView.open_debug(player)
end
)

View File

@ -5,16 +5,13 @@ local Public = {}
local pages = {
require 'utils.debug.public_global_view',
require 'utils.debug.global_view'
require 'utils.debug.global_view',
require 'utils.debug.gui_data_view',
require 'utils.debug.package_view',
require 'utils.debug._g_view',
require 'utils.debug.event_view'
}
if _DEBUG then
pages[#pages + 1] = require 'utils.debug.gui_data_view'
pages[#pages + 1] = require 'utils.debug.package_view'
pages[#pages + 1] = require 'utils.debug._g_view'
pages[#pages + 1] = require 'utils.debug.event_view'
end
local main_frame_name = Gui.uid_name()
local close_name = Gui.uid_name()
local tab_name = Gui.uid_name()

View File

@ -1,12 +1,11 @@
local Event = require 'utils.event_core'
local Token = require 'utils.token'
local Global = {}
local Global = {
names = {}
}
local concat = table.concat
local names = {}
Global.names = names
function Global.register(tbl, callback)
if _LIFECYCLE ~= _STAGE.control then
error('can only be called during the control stage', 2)
@ -15,7 +14,7 @@ function Global.register(tbl, callback)
local filepath = debug.getinfo(2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
local token = Token.register_global(tbl)
names[token] = concat {token, ' - ', filepath}
Global.names[token] = concat {token, ' - ', filepath}
Event.on_load(
function()
@ -33,7 +32,7 @@ function Global.register_init(tbl, init_handler, callback)
local filepath = debug.getinfo(2, 'S').source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
local token = Token.register_global(tbl)
names[token] = concat {token, ' - ', filepath}
Global.names[token] = concat {token, ' - ', filepath}
Event.on_init(
function()

View File

@ -5,12 +5,16 @@ local SpamProtection = require 'utils.spam_protection'
local tostring = tostring
local next = next
local concat = table.concat
local Gui = {}
local data = {}
local element_map = {}
local names = {}
Gui.names = names
Gui.token =
Global.register(
{data = data, element_map = element_map},
@ -24,7 +28,16 @@ local on_visible_handlers = {}
local on_pre_hidden_handlers = {}
function Gui.uid_name()
return tostring(Token.uid())
local info = debug.getinfo(2, 'Sl')
local filepath = info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
local line = info.currentline
local token = tostring(Token.uid())
local name = concat {token, ' - ', filepath, ':line:', line}
names[token] = name
return token
end
function Gui.uid()
@ -41,7 +54,9 @@ function Gui.set_data(element, value)
return
end
values[element.index] = nil
local index = element.index
values[index] = nil
element_map[index] = nil
if next(values) == nil then
data[player_index] = nil
@ -52,7 +67,9 @@ function Gui.set_data(element, value)
data[player_index] = values
end
values[element.index] = value
local index = element.index
values[index] = value
element_map[index] = element
end
end
local set_data = Gui.set_data
@ -249,61 +266,11 @@ Gui.on_player_show_top = custom_handler_factory(on_visible_handlers)
-- Adds a player field to the event table.
Gui.on_pre_player_hide_top = custom_handler_factory(on_pre_hidden_handlers)
if _DEBUG then
local concat = table.concat
local names = {}
Gui.names = names
function Gui.uid_name()
local info = debug.getinfo(2, 'Sl')
local filepath = info.source:match('^.+/currently%-playing/(.+)$'):sub(1, -5)
local line = info.currentline
local token = tostring(Token.uid())
local name = concat {token, ' - ', filepath, ':line:', line}
names[token] = name
return token
end
function Gui.set_data(element, value)
local player_index = element.player_index
local values = data[player_index]
if value == nil then
if not values then
return
end
local index = element.index
values[index] = nil
element_map[index] = nil
if next(values) == nil then
data[player_index] = nil
end
else
if not values then
values = {}
data[player_index] = values
end
local index = element.index
values[index] = value
element_map[index] = element
end
end
set_data = Gui.set_data
function Gui.data()
return data
end
function Gui.element_map()
return element_map
end
function Gui.data()
return data
end
function Gui.element_map()
return element_map
end
return Gui