mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
Merge pull request #632 from iltar/fix-tasklist-desync
Fix tasklist desync
This commit is contained in:
commit
d7e068e0c9
@ -35,7 +35,7 @@ global.config = {
|
||||
},
|
||||
-- enables players to create and prioritize tasks
|
||||
tasklist = {
|
||||
enabled = false,
|
||||
enabled = true,
|
||||
},
|
||||
-- enables the blueprint helper
|
||||
blueprint_helper = {
|
||||
|
@ -44,7 +44,7 @@ Global.register(
|
||||
player_tasks = player_tasks,
|
||||
tasks_counter = tasks_counter,
|
||||
last_task_update_data = last_task_update_data,
|
||||
no_notify_announcements_players = no_notify_players
|
||||
no_notify_players = no_notify_players
|
||||
},
|
||||
function(tbl)
|
||||
announcements = tbl.announcements
|
||||
@ -52,7 +52,7 @@ Global.register(
|
||||
player_tasks = tbl.player_tasks
|
||||
tasks_counter = tbl.tasks_counter
|
||||
last_task_update_data = tbl.last_task_update_data
|
||||
no_notify_players = tbl.no_notify_announcements_players
|
||||
no_notify_players = tbl.no_notify_players
|
||||
end
|
||||
)
|
||||
|
||||
@ -296,7 +296,7 @@ local function redraw_tasks(data, enabled)
|
||||
Gui.set_data(volunteer_button, task)
|
||||
update_volunteer_button(volunteer_button, task)
|
||||
|
||||
volunteer_buttons[task] = volunteer_button
|
||||
volunteer_buttons[task.task_id] = volunteer_button
|
||||
|
||||
local label =
|
||||
parent.add {
|
||||
@ -315,13 +315,13 @@ local function draw_main_frame(left, player)
|
||||
|
||||
local data = {}
|
||||
|
||||
local edit_announcments_button_tooltip
|
||||
local edit_announcements_button_tooltip
|
||||
local add_task_button_tooltip
|
||||
if enabled then
|
||||
edit_announcments_button_tooltip = 'Edit announcments.'
|
||||
edit_announcements_button_tooltip = 'Edit announcements.'
|
||||
add_task_button_tooltip = 'Create a new task.'
|
||||
else
|
||||
edit_announcments_button_tooltip = 'Sorry, you need to a regular to edit announcments.'
|
||||
edit_announcements_button_tooltip = 'Sorry, you need to be a regular to edit announcements.'
|
||||
add_task_button_tooltip = 'Sorry, you need to be a regular to create a new tasks.'
|
||||
end
|
||||
|
||||
@ -330,15 +330,15 @@ local function draw_main_frame(left, player)
|
||||
|
||||
local announcements_header_flow = frame.add {type = 'flow'}
|
||||
|
||||
local edit_announcments_button =
|
||||
local edit_announcements_button =
|
||||
announcements_header_flow.add {
|
||||
type = 'sprite-button',
|
||||
name = announcements_edit_button_name,
|
||||
sprite = 'utility/rename_icon_normal',
|
||||
tooltip = edit_announcments_button_tooltip
|
||||
tooltip = edit_announcements_button_tooltip
|
||||
}
|
||||
edit_announcments_button.enabled = enabled
|
||||
apply_button_style(edit_announcments_button)
|
||||
edit_announcements_button.enabled = enabled
|
||||
apply_button_style(edit_announcements_button)
|
||||
|
||||
local announcements_header = announcements_header_flow.add {type = 'label', caption = 'Announcements'}
|
||||
announcements_header.style.font = 'default-listbox'
|
||||
@ -401,14 +401,14 @@ local function draw_main_frame(left, player)
|
||||
frame.add {
|
||||
type = 'checkbox',
|
||||
name = notify_checkbox_name,
|
||||
caption = 'Notify me about new annoucements or tasks',
|
||||
caption = 'Notify me about new announcements or tasks',
|
||||
state = not no_notify_players[left.player_index]
|
||||
}
|
||||
|
||||
frame.add {type = 'button', name = main_button_name, caption = 'Close'}
|
||||
end
|
||||
|
||||
local function close_edit_announcments_frame(frame)
|
||||
local function close_edit_announcements_frame(frame)
|
||||
local editing_players = announcements.editing_players
|
||||
editing_players[frame.player_index] = nil
|
||||
Gui.destroy(frame)
|
||||
@ -434,7 +434,7 @@ local function toggle(event)
|
||||
Gui.destroy(frame)
|
||||
frame = left[edit_announcements_frame_name]
|
||||
if frame and frame.valid then
|
||||
close_edit_announcments_frame(frame)
|
||||
close_edit_announcements_frame(frame)
|
||||
end
|
||||
frame = left[create_task_frame_name]
|
||||
if frame and frame.valid then
|
||||
@ -584,7 +584,7 @@ local function draw_create_task_frame(left, previous_task)
|
||||
Gui.set_data(confirm_button, {frame = frame, textbox = textbox, previous_task = previous_task})
|
||||
end
|
||||
|
||||
local function player_created(event)
|
||||
local function player_joined(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
@ -617,8 +617,8 @@ local function player_created(event)
|
||||
local data = Gui.get_data(main_frame)
|
||||
local volunteer_buttons = data.volunteer_buttons
|
||||
|
||||
for t, _ in pairs(tasks_for_player) do
|
||||
update_volunteer_button(volunteer_buttons[t], t)
|
||||
for index, task in pairs(tasks_for_player) do
|
||||
update_volunteer_button(volunteer_buttons[index], task)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -636,7 +636,7 @@ local function player_left(event)
|
||||
|
||||
local frame = left[edit_announcements_frame_name]
|
||||
if frame and frame.valid then
|
||||
close_edit_announcments_frame(frame)
|
||||
close_edit_announcements_frame(frame)
|
||||
end
|
||||
end
|
||||
|
||||
@ -658,7 +658,7 @@ local function on_tick()
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, player_created)
|
||||
Event.add(defines.events.on_player_joined_game, player_joined)
|
||||
Event.add(defines.events.on_player_left_game, player_left)
|
||||
Event.on_nth_tick(3600, on_tick)
|
||||
|
||||
@ -746,7 +746,7 @@ Gui.on_click(
|
||||
edit_close_button_name,
|
||||
function(event)
|
||||
local frame = Gui.get_data(event.element)
|
||||
close_edit_announcments_frame(frame)
|
||||
close_edit_announcements_frame(frame)
|
||||
end
|
||||
)
|
||||
|
||||
@ -774,7 +774,7 @@ Gui.on_click(
|
||||
edit_confirm_button_name,
|
||||
function(event)
|
||||
local frame = Gui.get_data(event.element)
|
||||
close_edit_announcments_frame(frame)
|
||||
close_edit_announcements_frame(frame)
|
||||
|
||||
local player = event.player
|
||||
update_announcements(player)
|
||||
@ -807,10 +807,11 @@ Gui.on_click(
|
||||
task.name
|
||||
}
|
||||
|
||||
local task_id = task.task_id
|
||||
for pi, _ in pairs(task.volunteers) do
|
||||
local tasks_for_player = player_tasks[pi]
|
||||
if tasks_for_player then
|
||||
tasks_for_player[task] = nil
|
||||
tasks_for_player[task_id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -900,6 +901,7 @@ Gui.on_click(
|
||||
function(event)
|
||||
local button = event.element
|
||||
local task = Gui.get_data(button)
|
||||
local task_id = task.task_id
|
||||
|
||||
local player_index = event.player_index
|
||||
local volunteers = task.volunteers
|
||||
@ -908,7 +910,7 @@ Gui.on_click(
|
||||
volunteers[player_index] = nil
|
||||
|
||||
local tasks_for_player = player_tasks[player_index]
|
||||
tasks_for_player[task] = nil
|
||||
tasks_for_player[task_id] = nil
|
||||
else
|
||||
volunteers[player_index] = event.player
|
||||
|
||||
@ -918,7 +920,7 @@ Gui.on_click(
|
||||
player_tasks[player_index] = tasks_for_player
|
||||
end
|
||||
|
||||
tasks_for_player[task] = true
|
||||
tasks_for_player[task_id] = task
|
||||
end
|
||||
|
||||
for _, p in ipairs(game.connected_players) do
|
||||
@ -927,7 +929,7 @@ Gui.on_click(
|
||||
local data = Gui.get_data(frame)
|
||||
local volunteer_buttons = data.volunteer_buttons
|
||||
|
||||
update_volunteer_button(volunteer_buttons[task], task)
|
||||
update_volunteer_button(volunteer_buttons[task_id], task)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -155,7 +155,7 @@ function Command.add(command_name, options, callback)
|
||||
return
|
||||
end
|
||||
|
||||
if regular_only and not UserGroups.is_regular(player_name) then
|
||||
if regular_only and not UserGroups.is_regular(player_name) and not player.admin then
|
||||
print(format("The command '%s' is not available to guests.", command_name))
|
||||
return
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user