mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-17 20:58:13 +02:00
Merge pull request #11 from Gerkiz/poll-fix
bypass for desync in poll for 0.17.x
This commit is contained in:
commit
e48b113896
56
poll.lua
56
poll.lua
@ -13,8 +13,8 @@ local duration_slider_max = duration_max / duration_step
|
||||
local tick_duration_step = duration_step * 60
|
||||
local inv_tick_duration_step = 1 / tick_duration_step
|
||||
|
||||
local normal_color = {r = 250, g = 235, b = 215}
|
||||
local focus_color = {r = 255, g = 165, b = 0}
|
||||
--local normal_color = {r = 250, g = 235, b = 215}
|
||||
--local focus_color = {r = 255, g = 165, b = 0}
|
||||
|
||||
local polls = {}
|
||||
local polls_counter = {0}
|
||||
@ -81,8 +81,9 @@ end
|
||||
|
||||
local function apply_button_style(button)
|
||||
local button_style = button.style
|
||||
button_style.font = 'default-bold'
|
||||
button_style.font = 'default-semibold'
|
||||
button_style.height = 26
|
||||
button_style.minimal_width = 26
|
||||
button_style.top_padding = 0
|
||||
button_style.bottom_padding = 0
|
||||
button_style.left_padding = 2
|
||||
@ -193,7 +194,7 @@ local function redraw_poll_viewer_content(data)
|
||||
created_by_text = ''
|
||||
end
|
||||
|
||||
local top_flow = poll_viewer_content.add {type = 'flow', direction = 'horizontal'}
|
||||
local top_flow = poll_viewer_content.add {type = 'flow', direction = 'vertical'}
|
||||
top_flow.add {type = 'label', caption = table.concat {'Poll #', poll.id, created_by_text}}
|
||||
|
||||
local edited_by_players = poll.edited_by
|
||||
@ -210,7 +211,9 @@ local function redraw_poll_viewer_content(data)
|
||||
table.remove(edit_names)
|
||||
local edit_text = table.concat(edit_names)
|
||||
|
||||
top_flow.add {type = 'label', caption = edit_text, tooltip = edit_text}
|
||||
local top_flow_label = top_flow.add {type = 'label', caption = edit_text, tooltip = edit_text}
|
||||
top_flow_label.style.single_line = false
|
||||
top_flow_label.style.horizontally_stretchable = false
|
||||
end
|
||||
|
||||
local poll_enabled = do_remaining_time(poll, remaining_time_label)
|
||||
@ -233,12 +236,12 @@ local function redraw_poll_viewer_content(data)
|
||||
|
||||
local question_label = question_flow.add {type = 'label', caption = poll.question}
|
||||
question_label.style.height = 32
|
||||
question_label.style.font_color = focus_color
|
||||
--question_label.style.font_color = focus_color
|
||||
question_label.style.font = 'default-listbox'
|
||||
|
||||
local grid = poll_viewer_content.add {type = 'table', column_count = 2}
|
||||
|
||||
local answer = voters[player.index]
|
||||
--local answer = voters[player.index]
|
||||
local vote_buttons = {}
|
||||
for i, a in pairs(answers) do
|
||||
local vote_button_flow = grid.add {type = 'flow'}
|
||||
@ -264,10 +267,10 @@ local function redraw_poll_viewer_content(data)
|
||||
vote_button_style.left_padding = 0
|
||||
vote_button_style.right_padding = 0
|
||||
|
||||
if answer == a then
|
||||
vote_button_style.font_color = focus_color
|
||||
vote_button_style.disabled_font_color = focus_color
|
||||
end
|
||||
--if answer == a then
|
||||
-- vote_button_style.font_color = focus_color
|
||||
-- vote_button_style.disabled_font_color = focus_color
|
||||
--end
|
||||
|
||||
Gui.set_data(vote_button, {answer = a, data = data})
|
||||
vote_buttons[i] = vote_button
|
||||
@ -307,7 +310,7 @@ end
|
||||
|
||||
local function draw_main_frame(left, player)
|
||||
local frame = left.add {type = 'frame', name = main_frame_name, caption = 'Polls', direction = 'vertical'}
|
||||
frame.style.maximal_width = 360
|
||||
frame.style.maximal_width = 320
|
||||
|
||||
local poll_viewer_top_flow = frame.add {type = 'table', column_count = 5}
|
||||
poll_viewer_top_flow.style.horizontal_spacing = 0
|
||||
@ -377,7 +380,7 @@ local function draw_main_frame(left, player)
|
||||
type = 'button',
|
||||
caption = 'Create Poll',
|
||||
enabled = false,
|
||||
tooltip = 'Sorry, you need to be a regular to create polls.'
|
||||
tooltip = 'Sorry, you need to be trusted to create polls.'
|
||||
}
|
||||
apply_button_style(create_poll_button)
|
||||
end
|
||||
@ -473,7 +476,7 @@ local function redraw_create_poll_content(data)
|
||||
|
||||
local question_textfield =
|
||||
grid.add({type = 'flow'}).add {type = 'textfield', name = create_poll_question_name, text = data.question}
|
||||
question_textfield.style.width = 400
|
||||
question_textfield.style.width = 175
|
||||
|
||||
Gui.set_data(question_label, question_textfield)
|
||||
Gui.set_data(question_textfield, data)
|
||||
@ -509,7 +512,7 @@ local function redraw_create_poll_content(data)
|
||||
local textfield_flow = grid.add {type = 'flow'}
|
||||
|
||||
local textfield = textfield_flow.add {type = 'textfield', name = create_poll_answer_name, text = answer.text}
|
||||
textfield.style.width = 400
|
||||
textfield.style.width = 175
|
||||
Gui.set_data(textfield, {answers = answers, count = count})
|
||||
|
||||
if delete_button then
|
||||
@ -559,7 +562,7 @@ local function draw_create_poll_frame(parent, player, previous_data)
|
||||
|
||||
local frame =
|
||||
parent.add {type = 'frame', name = create_poll_frame_name, caption = title_text, direction = 'vertical'}
|
||||
frame.style.maximal_width = 360
|
||||
frame.style.maximal_width = 320
|
||||
|
||||
local scroll_pane = frame.add {type = 'scroll-pane', vertical_scroll_policy = 'always'}
|
||||
scroll_pane.style.maximal_height = 250
|
||||
@ -761,22 +764,21 @@ local function vote(event)
|
||||
vote_button.caption = previous_vote_button_count
|
||||
vote_button.tooltip = previous_vote_button_tooltip
|
||||
|
||||
if p.index == player_index then
|
||||
local vote_button_style = vote_button.style
|
||||
vote_button_style.font_color = normal_color
|
||||
vote_button_style.disabled_font_color = normal_color
|
||||
end
|
||||
--if p.index == player_index then
|
||||
-- local vote_button_style = vote_button.style
|
||||
-- vote_button_style.font_color = normal_color
|
||||
-- vote_button_style.disabled_font_color = normal_color
|
||||
--end
|
||||
end
|
||||
|
||||
local vote_button = vote_buttons[vote_index]
|
||||
vote_button.caption = vote_button_count
|
||||
vote_button.tooltip = vote_button_tooltip
|
||||
|
||||
if p.index == player_index then
|
||||
local vote_button_style = vote_button.style
|
||||
vote_button_style.font_color = focus_color
|
||||
vote_button_style.disabled_font_color = focus_color
|
||||
end
|
||||
-- if p.index == player_index then -- block commented to avoid desync risk
|
||||
-- local vote_button_style = vote_button.style
|
||||
-- vote_button_style.font_color = focus_color
|
||||
-- vote_button_style.disabled_font_color = focus_color
|
||||
-- end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user