Fixed Task list and Admin Commands

This commit is contained in:
Cooldude2606
2018-09-29 18:17:18 +01:00
parent 5cc5546a05
commit 627f5a4651
10 changed files with 31 additions and 28 deletions

View File

@@ -10,6 +10,7 @@ local Gui = require('ExpGamingCore.Gui@^4.0.0')
local Role = require('ExpGamingCore.Role@^4.0.0')
local Game = require('FactorioStdLib.Game@^0.8.0')
local playerInfo -- ExpGamingPlayer@^4.0.0
local mod_gui = require('mod-gui')
-- Module Define
local module_verbose = false
@@ -137,7 +138,7 @@ Admin.center = Gui.center.add{
open=function(event,pre_select_player,pre_select_action)
local _player = Game.get_player(pre_select_player)
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)
if center_flow[_center.name] then Gui.center.clear(player) return end
local center_frame = center_flow.add{

View File

@@ -8,6 +8,7 @@
-- @function _comment
local Game = require('FactorioStdLib.Game')
local Server = require('ExpGamingCore.Server')
local Color = require('FactorioStdLib.Color')
local Role -- this is optional and is hanndled by it being present, it is loaded on init
local mod_gui = require("mod-gui")

View File

@@ -178,7 +178,7 @@ end
--[[ cant be used V
--- Adds a event handler to tell threads about events
-- @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
function Server.add_thread_handler(event)
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.queue > 0 then -- resolve one thread
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
end
end)

View File

@@ -6,7 +6,7 @@
-- Module Require
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
local module_verbose = false

View File

@@ -6,7 +6,7 @@
-- Module Require
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
local module_verbose = false

View File

@@ -6,7 +6,7 @@
-- Module Require
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 science_packs = {

View File

@@ -5,8 +5,9 @@
-- @alais ThisModule
-- Module Require
local Gui = require('ExpGamingCore.Role@^4.0.0')
local Game = require('FactoiorStdLib.Game@^0.8.0')
local Gui = require('ExpGamingCore.Gui@^4.0.0')
local Role = require('ExpGamingCore.Role@^4.0.0')
local Game = require('FactorioStdLib.Game@^0.8.0')
-- Module Define
local module_verbose = false
@@ -31,7 +32,7 @@ local edit = Gui.inputs.add{
}:on_event('click',function(event)
local text_flow = event.element.parent.parent.text_flow
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
data._editing[tonumber(text_flow.parent.name)]=true
Gui.left.update('tasklist',event.player_index)
@@ -71,12 +72,12 @@ local remove = Gui.inputs.add{
caption='utility/remove'
}:on_event('click',function(event)
local frame = event.element.parent.parent
local data = _global()._edit[event.player_index]
local data = global._edit[event.player_index]
if data._edit then
table.remove(data._tasks,tonumber(frame.name))
table.remove(data._editing,tonumber(frame.name))
else
table.remove(_global().tasks,tonumber(frame.name))
table.remove(global.tasks,tonumber(frame.name))
Gui.left.update('tasklist')
end
Gui.left.update('tasklist',event.player_index)
@@ -88,12 +89,12 @@ local add = Gui.inputs.add{
caption='utility/add'
}:on_event('click',function(event)
local frame = event.element.parent.parent
local data = _global()._edit[event.player_index]
local data = global._edit[event.player_index]
if data._edit then
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
table.insert(data._editing,tonumber(frame.name)+1,true)
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._editing,tonumber(frame.name)+1,true)
end
@@ -102,8 +103,8 @@ end)
local function _tasks(player)
local player = Game.get_player(player)
local data = _global()._edit[player.index]
if not data then return _global().tasks end
local data = global._edit[player.index]
if not data then return global.tasks end
local _edit = false
for _,v in pairs(data._editing) do
if v == true then
@@ -112,16 +113,16 @@ local function _tasks(player)
end
end
if data._edit and not _edit then
_global().tasks = table.deepcopy(data._tasks)
_global()._edit[player.index] = table.deepcopy(_global()._base)
global.tasks = table.deepcopy(data._tasks)
global._edit[player.index] = table.deepcopy(global._base)
Gui.left.update('tasklist')
return _global().tasks
return global.tasks
elseif not data._edit and _edit then
data._edit = true
for key,_ in pairs(data._tasks) do if not data._editing[key] then data._editing[key] = false end end
return data._tasks
elseif _edit then return data._tasks
else return _global().tasks
else return global.tasks
end
end
@@ -140,11 +141,10 @@ Gui.left.add{
caption={'tasklist.name'},
style='caption_label'
}
local data = _global()
local player = Game.get_player(frame.player_index)
local allowed = Role.allowed(player,'edit-tasklist')
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
for i,task in pairs(_tasks(player)) do
local flow = frame.add{
@@ -168,7 +168,7 @@ Gui.left.add{
}
if allowed then
_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)
element.style.height = 30
element.style.width = 30
@@ -192,10 +192,10 @@ Gui.left.add{
element.style.height = 20
element.style.width = 20
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,
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
end,
open_on_join=true

View File

@@ -15,6 +15,7 @@
"license": "<blank>",
"dependencies": {
"ExpGamingCore.Gui": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactoiorStdLib.Game": "^0.8.0"
}
}

View File

@@ -84,6 +84,7 @@
],
"dependencies": {
"ExpGamingCore.Gui": "^4.0.0",
"ExpGamingCore.Role": "^4.0.0",
"FactoiorStdLib.Game": "^0.8.0"
}
}

View File

@@ -50,8 +50,8 @@ return {
['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban',
['ChatPopup@4.0.0']='./modules/ChatPopup',
['DamagePopup@4.0.0']='./modules/DamagePopup',
['ExpGamingInfo.Readme@4.0.0']='./modules/DamagePopup',
['ExpGamingInfo.Rockets@4.0.0']='./modules/DamagePopup',
['ExpGamingInfo.Science@4.0.0']='./modules/DamagePopup',
['ExpGamingInfo.Tasklist@4.0.0']='./modules/DamagePopup',
['ExpGamingInfo.Readme@4.0.0']='./modules/ExpGamingInfo/Readme',
['ExpGamingInfo.Rockets@4.0.0']='./modules/ExpGamingInfo/Rockets',
['ExpGamingInfo.Science@4.0.0']='./modules/ExpGamingInfo/Science',
['ExpGamingInfo.Tasklist@4.0.0']='./modules/ExpGamingInfo/Tasklist',
}