mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Fixed some of the requested changes
* Made add_task and update_task have consistent arguments * Removed default task title and body * Task list resized to fit to 10 items
This commit is contained in:
@@ -43,8 +43,6 @@ local task_id = Tasks.add_task(game.player.force.name, nil, game.player.name)
|
||||
function Tasks.add_task(force_name, player_name, task_title, task_body)
|
||||
-- Get a new task id
|
||||
local task_id = tostring(force_tasks._uid)
|
||||
task_title = task_title or 'New Task'
|
||||
task_body = task_body or 'Do x or y'
|
||||
force_tasks._uid = force_tasks._uid + 1
|
||||
|
||||
-- Get the existing tasks for this force
|
||||
@@ -67,8 +65,8 @@ function Tasks.add_task(force_name, player_name, task_title, task_body)
|
||||
TaskData:set(task_id, {
|
||||
task_id = task_id,
|
||||
force_name = force_name,
|
||||
title = task_title,
|
||||
body = task_body,
|
||||
title = task_title or '',
|
||||
body = task_body or '',
|
||||
last_edit_name = player_name or '<server>',
|
||||
last_edit_time = game.tick,
|
||||
currently_editing = editing
|
||||
@@ -93,20 +91,20 @@ end
|
||||
|
||||
--[[-- Update the message and last edited information for a task
|
||||
@tparam string task_id the uid of the task that you want to update
|
||||
@tparam string message_title the message title that you want to have for the task
|
||||
@tparam string message_body the message body that you want to have for the task
|
||||
@tparam[opt='server'] string player_name the name of the player who made the edit
|
||||
@tparam string player_name the name of the player who made the edit
|
||||
@tparam string task_title the message title that you want to have for the task
|
||||
@tparam string task_body the message body that you want to have for the task
|
||||
|
||||
@usage-- Updating the message for on a task
|
||||
Task.update_task(task_id, 'We need more iron!', game.player.name)
|
||||
|
||||
]]
|
||||
function Tasks.update_task(task_id, message_title, message_body, player_name)
|
||||
function Tasks.update_task(task_id, player_name, task_title, task_body)
|
||||
TaskData:update(task_id, function(_, task)
|
||||
task.last_edit_name = player_name or '<server>'
|
||||
task.last_edit_name = player_name
|
||||
task.last_edit_time = game.tick
|
||||
task.title = message_title
|
||||
task.body = message_body
|
||||
task.title = task_title
|
||||
task.body = task_body
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ local task_list =
|
||||
}
|
||||
scroll_pane.style.horizontally_stretchable = true
|
||||
scroll_pane.style.padding = 0
|
||||
scroll_pane.style.maximal_height = 300
|
||||
scroll_pane.style.maximal_height = 280
|
||||
|
||||
local flow =
|
||||
scroll_pane.add {
|
||||
@@ -292,8 +292,7 @@ local task_view_footer =
|
||||
local title_label =
|
||||
footer.add {
|
||||
type = "label",
|
||||
name = "title",
|
||||
caption = "New task"
|
||||
name = "title"
|
||||
}
|
||||
title_label.style.padding = 4
|
||||
title_label.style.font = "default-bold"
|
||||
@@ -301,8 +300,7 @@ local task_view_footer =
|
||||
local body_label =
|
||||
footer.add {
|
||||
type = "label",
|
||||
name = "body",
|
||||
caption = "Do x or y"
|
||||
name = "body"
|
||||
}
|
||||
body_label.style.padding = 4
|
||||
body_label.style.single_line = false
|
||||
@@ -321,7 +319,7 @@ local message_pattern = "(.-)\n(.*)"
|
||||
-- @tparam string str message data
|
||||
local function parse_message(str)
|
||||
-- Trimm the spaces of the string
|
||||
local trimmed = (string.gsub(str, "^%s*(.-)%s*$", "%1"))
|
||||
local trimmed = string.gsub(str, "^%s*(.-)%s*$", "%1")
|
||||
local message = { title = "", body = "" }
|
||||
local title, body = string.match(trimmed, message_pattern)
|
||||
if not title then
|
||||
@@ -379,7 +377,7 @@ edit_task_confirm_button =
|
||||
PlayerIsEditing:set(player, false)
|
||||
local new_message = element.parent.parent[task_message_textfield.name].text
|
||||
local parsed = parse_message(new_message)
|
||||
Tasks.update_task(selected, parsed.title, parsed.body, player.name)
|
||||
Tasks.update_task(selected, player.name, parsed.title, parsed.body)
|
||||
Tasks.set_editing(selected, player.name, nil)
|
||||
end
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user