mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Tasklist Done
This commit is contained in:
@@ -20,40 +20,33 @@ local edit = Gui.inputs.add{
|
|||||||
caption='utility/rename_icon_normal'
|
caption='utility/rename_icon_normal'
|
||||||
}: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[frame.player_index]
|
local data = _global()._edit[event.player_index]
|
||||||
if text_flow.text.type == 'label' then
|
if not data._edit then data._tasks = table.deepcopy(_global().tasks) end
|
||||||
data._editing[text_flow.parent.name]=true
|
if text_flow.input.type == 'label' then
|
||||||
local text = text_flow.text.caption
|
data._editing[tonumber(text_flow.parent.name)]=true
|
||||||
text_flow.clear()
|
Gui.left.update('tasklist',event.player_index)
|
||||||
local _text = text_flow.add{
|
elseif text_flow.input.type == 'textfield' then
|
||||||
name='text',
|
local text = text_flow.input.text
|
||||||
type='textfield',
|
data._editing[tonumber(text_flow.parent.name)]=false
|
||||||
text=text
|
data._tasks[tonumber(text_flow.parent.name)]=text
|
||||||
}
|
|
||||||
_text.style.width = 100
|
|
||||||
event.element.sprite = 'utility/enter'
|
|
||||||
elseif text_flow.text.type == 'textfield' then
|
|
||||||
local text = text_flow.text.text
|
|
||||||
data._editing[text_flow.parent.name]=false
|
|
||||||
data._tasks[text_flow.parent.name]=text
|
|
||||||
text_flow.parent.parent.clear()
|
|
||||||
Gui.left.update('tasklist',event.player_index)
|
Gui.left.update('tasklist',event.player_index)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function _edit(frame)
|
local function _edit(frame)
|
||||||
local element = edit:draw()
|
local element = edit:draw(frame)
|
||||||
local text_flow = element.parent.parent.text_flow
|
local text_flow = element.parent.parent.text_flow
|
||||||
local data = _global()._edit[frame.player_index]
|
local data = _global()._edit[frame.player_index]
|
||||||
if data._editing[text_flow.parent.name] then
|
data._tasks[text_flow.parent.name]=text
|
||||||
local text = text_flow.text.caption
|
if data._editing[tonumber(text_flow.parent.name)] then
|
||||||
|
local text = text_flow.input.caption
|
||||||
text_flow.clear()
|
text_flow.clear()
|
||||||
local _text = text_flow.add{
|
local _text = text_flow.add{
|
||||||
name='text',
|
name='input',
|
||||||
type='textfield',
|
type='textfield',
|
||||||
text=text
|
text=text
|
||||||
}
|
}
|
||||||
_text.style.width = 100
|
_text.style.width = 200
|
||||||
element.sprite = 'utility/enter'
|
element.sprite = 'utility/enter'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -63,22 +56,32 @@ local remove = Gui.inputs.add{
|
|||||||
type='button',
|
type='button',
|
||||||
caption='utility/remove'
|
caption='utility/remove'
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local frame = event.element.parent.parent.parent
|
local frame = event.element.parent.parent
|
||||||
local data = _global()._edit[event.player_index]
|
local data = _global()._edit[event.player_index]
|
||||||
table.remove(data._tasks,frame.name)
|
if data._edit then
|
||||||
table.remove(data._editing,frame.name)
|
table.remove(data._tasks,tonumber(frame.name))
|
||||||
|
table.remove(data._editing,tonumber(frame.name))
|
||||||
|
else
|
||||||
|
table.remove(_global().tasks,tonumber(frame.name))
|
||||||
|
end
|
||||||
Gui.left.update('tasklist',event.player_index)
|
Gui.left.update('tasklist',event.player_index)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local add = Gui.inputs.add{
|
local add = Gui.inputs.add{
|
||||||
name='tasklist-add',
|
name='tasklist-add',
|
||||||
type='button',
|
type='button',
|
||||||
caption='add'
|
caption='utility/add'
|
||||||
}:on_event('click',function(event)
|
}:on_event('click',function(event)
|
||||||
local frame = event.element.parent.parent.parent
|
local frame = event.element.parent.parent
|
||||||
local data = _global()._edit[event.player_index]
|
local data = _global()._edit[event.player_index]
|
||||||
table.insert(data._tasks,frame.name,'New Value')
|
if data._edit then
|
||||||
table.insert(data._editing,frame.name,true)
|
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)
|
||||||
|
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
||||||
|
table.insert(data._editing,tonumber(frame.name)+1,true)
|
||||||
|
end
|
||||||
Gui.left.update('tasklist',event.player_index)
|
Gui.left.update('tasklist',event.player_index)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -95,11 +98,12 @@ local function _tasks(player)
|
|||||||
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)
|
||||||
data._edit = false
|
_global()._edit[player.index] = table.deepcopy(_global()._base)
|
||||||
Gui.left.update('tasklist')
|
Gui.left.update('tasklist')
|
||||||
|
return _global().tasks
|
||||||
elseif not data._edit and _edit then
|
elseif not data._edit and _edit then
|
||||||
data.tasks = table.deepcopy(_global()._tasks)
|
|
||||||
data._edit = true
|
data._edit = true
|
||||||
|
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
|
||||||
@@ -115,7 +119,7 @@ Gui.left.add{
|
|||||||
local player = Game.get_player(frame.player_index)
|
local player = Game.get_player(frame.player_index)
|
||||||
local rank = Ranking.get_rank(player)
|
local rank = Ranking.get_rank(player)
|
||||||
if rank:allowed('edit-tasklist') then
|
if rank:allowed('edit-tasklist') then
|
||||||
if not data._edit[player.index] then data._edit[player.index] = data._base end
|
if not data._edit[player.index] then data._edit[player.index] = table.deepcopy(data._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{
|
||||||
@@ -129,7 +133,7 @@ Gui.left.add{
|
|||||||
direction='horizontal'
|
direction='horizontal'
|
||||||
}
|
}
|
||||||
text_flow.add{
|
text_flow.add{
|
||||||
name='text',
|
name='input',
|
||||||
type='label',
|
type='label',
|
||||||
caption=task
|
caption=task
|
||||||
}
|
}
|
||||||
@@ -144,8 +148,22 @@ Gui.left.add{
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #_tasks(player) == 0 then
|
if #_tasks(player) == 0 then
|
||||||
|
local flow = frame.add{
|
||||||
|
name=0,
|
||||||
|
type='flow',
|
||||||
|
direction='horizontal'
|
||||||
|
}
|
||||||
|
local button_flow = flow.add{
|
||||||
|
type='flow',
|
||||||
|
direction='horizontal'
|
||||||
|
}
|
||||||
add:draw(button_flow)
|
add:draw(button_flow)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
can_open=function(player)
|
||||||
|
local rank = Ranking.get_rank(player)
|
||||||
|
if rank:allowed('edit-tasklist') or #_global().tasks > 0 then return true
|
||||||
|
else return {'tasklist.none'} end
|
||||||
|
end,
|
||||||
open_on_join=true
|
open_on_join=true
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ Discord: https://discord.gg/r6dC2uK
|
|||||||
]]
|
]]
|
||||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||||
|
|
||||||
local return_err = false
|
local return_err = true
|
||||||
local _require = require
|
local _require = require
|
||||||
local function require(path)
|
local function require(path)
|
||||||
local success, err = pcall(_require,path)
|
local success, err = pcall(_require,path)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
[tasklist]
|
[tasklist]
|
||||||
name=Task List
|
name=Task List
|
||||||
tooltip=What jobs need to be done round the factory.
|
tooltip=What jobs need to be done round the factory.
|
||||||
|
none=There are no tasks to do right now, ask a member to add some.
|
||||||
Reference in New Issue
Block a user