mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Fixed Task list and Admin Commands
This commit is contained in:
@@ -10,6 +10,7 @@ local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
|||||||
local Role = require('ExpGamingCore.Role@^4.0.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
local playerInfo -- ExpGamingPlayer@^4.0.0
|
local playerInfo -- ExpGamingPlayer@^4.0.0
|
||||||
|
local mod_gui = require('mod-gui')
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
@@ -137,7 +138,7 @@ Admin.center = Gui.center.add{
|
|||||||
open=function(event,pre_select_player,pre_select_action)
|
open=function(event,pre_select_player,pre_select_action)
|
||||||
local _player = Game.get_player(pre_select_player)
|
local _player = Game.get_player(pre_select_player)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local _center = Gui._get_data('center')['admin-commands']
|
local _center = Gui.data.center['admin-commands']
|
||||||
local center_flow = Gui.center.get_flow(player)
|
local center_flow = Gui.center.get_flow(player)
|
||||||
if center_flow[_center.name] then Gui.center.clear(player) return end
|
if center_flow[_center.name] then Gui.center.clear(player) return end
|
||||||
local center_frame = center_flow.add{
|
local center_frame = center_flow.add{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
-- @function _comment
|
-- @function _comment
|
||||||
|
|
||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
|
local Server = require('ExpGamingCore.Server')
|
||||||
local Color = require('FactorioStdLib.Color')
|
local Color = require('FactorioStdLib.Color')
|
||||||
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
local Role -- this is optional and is hanndled by it being present, it is loaded on init
|
||||||
local mod_gui = require("mod-gui")
|
local mod_gui = require("mod-gui")
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ end
|
|||||||
--[[ cant be used V
|
--[[ cant be used V
|
||||||
--- Adds a event handler to tell threads about events
|
--- Adds a event handler to tell threads about events
|
||||||
-- @usage Server.add_thread_handler(defines.event)
|
-- @usage Server.add_thread_handler(defines.event)
|
||||||
-- @tparam number event the event to run the thread handler on
|
-- @tparam number event the event to run the thread handler on`
|
||||||
-- @treturn bolean if the handler was added
|
-- @treturn bolean if the handler was added
|
||||||
function Server.add_thread_handler(event)
|
function Server.add_thread_handler(event)
|
||||||
if not is_type(event,'number') then return false end
|
if not is_type(event,'number') then return false end
|
||||||
@@ -458,7 +458,6 @@ script.on_event(defines.events.on_tick,function(event)
|
|||||||
if #global.timeout > 0 then Server.check_timeouts() end -- timeout checks
|
if #global.timeout > 0 then Server.check_timeouts() end -- timeout checks
|
||||||
if #global.queue > 0 then -- resolve one thread
|
if #global.queue > 0 then -- resolve one thread
|
||||||
local current_thread = global.all[global.queue[1]]
|
local current_thread = global.all[global.queue[1]]
|
||||||
game.print(current_thread.uuid)
|
|
||||||
if current_thread and current_thread:valid() then current_thread:resolve() end
|
if current_thread and current_thread:valid() then current_thread:resolve() end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||||
local Game = require('FactoiorStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||||
local Game = require('FactoiorStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||||
local Game = require('FactoiorStdLib.Game@^0.8.0')
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
|
|
||||||
-- Local Varibles
|
-- Local Varibles
|
||||||
local science_packs = {
|
local science_packs = {
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
-- @alais ThisModule
|
-- @alais ThisModule
|
||||||
|
|
||||||
-- Module Require
|
-- Module Require
|
||||||
local Gui = require('ExpGamingCore.Role@^4.0.0')
|
local Gui = require('ExpGamingCore.Gui@^4.0.0')
|
||||||
local Game = require('FactoiorStdLib.Game@^0.8.0')
|
local Role = require('ExpGamingCore.Role@^4.0.0')
|
||||||
|
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
@@ -31,7 +32,7 @@ local edit = Gui.inputs.add{
|
|||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local text_flow = event.element.parent.parent.text_flow
|
local text_flow = event.element.parent.parent.text_flow
|
||||||
local data = global._edit[event.player_index]
|
local data = global._edit[event.player_index]
|
||||||
if not data._edit then data._tasks = table.deepcopy(_global().tasks) end
|
if not data._edit then data._tasks = table.deepcopy(global.tasks) end
|
||||||
if text_flow.input.type == 'label' then
|
if text_flow.input.type == 'label' then
|
||||||
data._editing[tonumber(text_flow.parent.name)]=true
|
data._editing[tonumber(text_flow.parent.name)]=true
|
||||||
Gui.left.update('tasklist',event.player_index)
|
Gui.left.update('tasklist',event.player_index)
|
||||||
@@ -71,12 +72,12 @@ local remove = Gui.inputs.add{
|
|||||||
caption='utility/remove'
|
caption='utility/remove'
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local frame = event.element.parent.parent
|
local frame = event.element.parent.parent
|
||||||
local data = _global()._edit[event.player_index]
|
local data = global._edit[event.player_index]
|
||||||
if data._edit then
|
if data._edit then
|
||||||
table.remove(data._tasks,tonumber(frame.name))
|
table.remove(data._tasks,tonumber(frame.name))
|
||||||
table.remove(data._editing,tonumber(frame.name))
|
table.remove(data._editing,tonumber(frame.name))
|
||||||
else
|
else
|
||||||
table.remove(_global().tasks,tonumber(frame.name))
|
table.remove(global.tasks,tonumber(frame.name))
|
||||||
Gui.left.update('tasklist')
|
Gui.left.update('tasklist')
|
||||||
end
|
end
|
||||||
Gui.left.update('tasklist',event.player_index)
|
Gui.left.update('tasklist',event.player_index)
|
||||||
@@ -88,12 +89,12 @@ local add = Gui.inputs.add{
|
|||||||
caption='utility/add'
|
caption='utility/add'
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local frame = event.element.parent.parent
|
local frame = event.element.parent.parent
|
||||||
local data = _global()._edit[event.player_index]
|
local data = global._edit[event.player_index]
|
||||||
if data._edit then
|
if data._edit then
|
||||||
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
||||||
table.insert(data._editing,tonumber(frame.name)+1,true)
|
table.insert(data._editing,tonumber(frame.name)+1,true)
|
||||||
else
|
else
|
||||||
data._tasks = table.deepcopy(_global().tasks)
|
data._tasks = table.deepcopy(global.tasks)
|
||||||
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
||||||
table.insert(data._editing,tonumber(frame.name)+1,true)
|
table.insert(data._editing,tonumber(frame.name)+1,true)
|
||||||
end
|
end
|
||||||
@@ -102,8 +103,8 @@ end)
|
|||||||
|
|
||||||
local function _tasks(player)
|
local function _tasks(player)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
local data = _global()._edit[player.index]
|
local data = global._edit[player.index]
|
||||||
if not data then return _global().tasks end
|
if not data then return global.tasks end
|
||||||
local _edit = false
|
local _edit = false
|
||||||
for _,v in pairs(data._editing) do
|
for _,v in pairs(data._editing) do
|
||||||
if v == true then
|
if v == true then
|
||||||
@@ -112,16 +113,16 @@ local function _tasks(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if data._edit and not _edit then
|
if data._edit and not _edit then
|
||||||
_global().tasks = table.deepcopy(data._tasks)
|
global.tasks = table.deepcopy(data._tasks)
|
||||||
_global()._edit[player.index] = table.deepcopy(_global()._base)
|
global._edit[player.index] = table.deepcopy(global._base)
|
||||||
Gui.left.update('tasklist')
|
Gui.left.update('tasklist')
|
||||||
return _global().tasks
|
return global.tasks
|
||||||
elseif not data._edit and _edit then
|
elseif not data._edit and _edit then
|
||||||
data._edit = true
|
data._edit = true
|
||||||
for key,_ in pairs(data._tasks) do if not data._editing[key] then data._editing[key] = false end end
|
for key,_ in pairs(data._tasks) do if not data._editing[key] then data._editing[key] = false end end
|
||||||
return data._tasks
|
return data._tasks
|
||||||
elseif _edit then return data._tasks
|
elseif _edit then return data._tasks
|
||||||
else return _global().tasks
|
else return global.tasks
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -140,11 +141,10 @@ Gui.left.add{
|
|||||||
caption={'tasklist.name'},
|
caption={'tasklist.name'},
|
||||||
style='caption_label'
|
style='caption_label'
|
||||||
}
|
}
|
||||||
local data = _global()
|
|
||||||
local player = Game.get_player(frame.player_index)
|
local player = Game.get_player(frame.player_index)
|
||||||
local allowed = Role.allowed(player,'edit-tasklist')
|
local allowed = Role.allowed(player,'edit-tasklist')
|
||||||
if allowed then
|
if allowed then
|
||||||
if not data._edit[player.index] then data._edit[player.index] = table.deepcopy(data._base) end
|
if not global._edit[player.index] then global._edit[player.index] = table.deepcopy(global._base) end
|
||||||
end
|
end
|
||||||
for i,task in pairs(_tasks(player)) do
|
for i,task in pairs(_tasks(player)) do
|
||||||
local flow = frame.add{
|
local flow = frame.add{
|
||||||
@@ -168,7 +168,7 @@ Gui.left.add{
|
|||||||
}
|
}
|
||||||
if allowed then
|
if allowed then
|
||||||
_edit(button_flow)
|
_edit(button_flow)
|
||||||
if data._edit[player.index]._editing[i] then
|
if global._edit[player.index]._editing[i] then
|
||||||
local element = remove:draw(button_flow)
|
local element = remove:draw(button_flow)
|
||||||
element.style.height = 30
|
element.style.height = 30
|
||||||
element.style.width = 30
|
element.style.width = 30
|
||||||
@@ -192,10 +192,10 @@ Gui.left.add{
|
|||||||
element.style.height = 20
|
element.style.height = 20
|
||||||
element.style.width = 20
|
element.style.width = 20
|
||||||
end
|
end
|
||||||
if #_tasks(player) == 0 and not role:allowed('edit-tasklist') then frame.style.visible = false end
|
if #_tasks(player) == 0 and not allowed then frame.style.visible = false end
|
||||||
end,
|
end,
|
||||||
can_open=function(player)
|
can_open=function(player)
|
||||||
if Role.allowed(player,'edit-tasklist') or #_global().tasks > 0 then return true
|
if Role.allowed(player,'edit-tasklist') or #global.tasks > 0 then return true
|
||||||
else return {'tasklist.none'} end
|
else return {'tasklist.none'} end
|
||||||
end,
|
end,
|
||||||
open_on_join=true
|
open_on_join=true
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"license": "<blank>",
|
"license": "<blank>",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ExpGamingCore.Gui": "^4.0.0",
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
|
"ExpGamingCore.Role": "^4.0.0",
|
||||||
"FactoiorStdLib.Game": "^0.8.0"
|
"FactoiorStdLib.Game": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,6 +84,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ExpGamingCore.Gui": "^4.0.0",
|
"ExpGamingCore.Gui": "^4.0.0",
|
||||||
|
"ExpGamingCore.Role": "^4.0.0",
|
||||||
"FactoiorStdLib.Game": "^0.8.0"
|
"FactoiorStdLib.Game": "^0.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ return {
|
|||||||
['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban',
|
['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban',
|
||||||
['ChatPopup@4.0.0']='./modules/ChatPopup',
|
['ChatPopup@4.0.0']='./modules/ChatPopup',
|
||||||
['DamagePopup@4.0.0']='./modules/DamagePopup',
|
['DamagePopup@4.0.0']='./modules/DamagePopup',
|
||||||
['ExpGamingInfo.Readme@4.0.0']='./modules/DamagePopup',
|
['ExpGamingInfo.Readme@4.0.0']='./modules/ExpGamingInfo/Readme',
|
||||||
['ExpGamingInfo.Rockets@4.0.0']='./modules/DamagePopup',
|
['ExpGamingInfo.Rockets@4.0.0']='./modules/ExpGamingInfo/Rockets',
|
||||||
['ExpGamingInfo.Science@4.0.0']='./modules/DamagePopup',
|
['ExpGamingInfo.Science@4.0.0']='./modules/ExpGamingInfo/Science',
|
||||||
['ExpGamingInfo.Tasklist@4.0.0']='./modules/DamagePopup',
|
['ExpGamingInfo.Tasklist@4.0.0']='./modules/ExpGamingInfo/Tasklist',
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user