mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-11-06 09:09:26 +02:00
Autoformat (#415)
This commit is contained in:
@@ -199,7 +199,6 @@ This can be changed in options -> controls -> "toggle lua console".
|
||||
maps_textbox.read_only = true
|
||||
|
||||
parent.add({type = 'flow'}).style.height = 24
|
||||
|
||||
end
|
||||
},
|
||||
{
|
||||
|
||||
@@ -41,8 +41,8 @@ local filter_table_close_button_name = Gui.uid_name()
|
||||
|
||||
global.paint_brushes_by_player = {}
|
||||
local function player_build_tile(event)
|
||||
if not global.scenario.config.paint.enable then
|
||||
return
|
||||
if not global.scenario.config.paint.enable then
|
||||
return
|
||||
end
|
||||
if event.item.name ~= brush_tool then
|
||||
return
|
||||
@@ -75,8 +75,8 @@ local function player_build_tile(event)
|
||||
end
|
||||
|
||||
local function player_joined(event)
|
||||
if not global.scenario.config.paint.enable then
|
||||
return
|
||||
if not global.scenario.config.paint.enable then
|
||||
return
|
||||
end
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
if not player or not player.valid then
|
||||
|
||||
@@ -441,18 +441,18 @@ local column_builders = {
|
||||
|
||||
local function get_default_player_settings()
|
||||
columns = {
|
||||
sprite_heading_name,
|
||||
player_name_heading_name,
|
||||
time_heading_name,
|
||||
rank_heading_name,
|
||||
distance_heading_name
|
||||
sprite_heading_name,
|
||||
player_name_heading_name,
|
||||
time_heading_name,
|
||||
rank_heading_name,
|
||||
distance_heading_name
|
||||
}
|
||||
local offset = 6
|
||||
if global.scenario.config.player_list.enable_coin_col then
|
||||
columns[6] = coin_heading_name
|
||||
offset = 7
|
||||
end
|
||||
columns[offset] = deaths_heading_name
|
||||
columns[offset] = deaths_heading_name
|
||||
columns[offset + 1] = poke_name_heading_name
|
||||
columns[offset + 2] = report_heading_name
|
||||
return {
|
||||
|
||||
@@ -3,8 +3,8 @@ local Global = require 'utils.global'
|
||||
local Event = require 'utils.event'
|
||||
local UserGroups = require 'features.user_groups'
|
||||
local Game = require 'utils.game'
|
||||
local math = require "utils.math"
|
||||
local Utils = require "utils.utils"
|
||||
local math = require 'utils.math'
|
||||
local Utils = require 'utils.utils'
|
||||
|
||||
local default_poll_duration = 300 * 60 -- in ticks
|
||||
local duration_max = 3600 -- in seconds
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
local Gui = require 'utils.gui'
|
||||
local Utils = require "utils.utils"
|
||||
local Game = require "utils.game"
|
||||
local Utils = require 'utils.utils'
|
||||
local Game = require 'utils.game'
|
||||
|
||||
local close_name = Gui.uid_name()
|
||||
|
||||
|
||||
local function show_popup(player, message)
|
||||
local frame = player.gui.center.add {type = 'frame', direction = 'vertical', style = 'captionless_frame'}
|
||||
frame.style.minimal_width = 300
|
||||
|
||||
@@ -1,60 +1,61 @@
|
||||
local Event = require "utils.event"
|
||||
local Event = require 'utils.event'
|
||||
local Game = require 'utils.game'
|
||||
|
||||
if not global.score_rockets_launched then global.score_rockets_launched = 0 end
|
||||
if not global.score_rockets_launched then
|
||||
global.score_rockets_launched = 0
|
||||
end
|
||||
|
||||
local function create_score_gui(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
|
||||
if player.gui.top.score == nil then
|
||||
local button = player.gui.top.add({ type = "sprite-button", name = "score", sprite = "item/rocket-silo" })
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.top_padding = 2
|
||||
button.style.left_padding = 4
|
||||
button.style.right_padding = 4
|
||||
button.style.bottom_padding = 2
|
||||
end
|
||||
if player.gui.top.score == nil then
|
||||
local button = player.gui.top.add({type = 'sprite-button', name = 'score', sprite = 'item/rocket-silo'})
|
||||
button.style.minimal_height = 38
|
||||
button.style.minimal_width = 38
|
||||
button.style.top_padding = 2
|
||||
button.style.left_padding = 4
|
||||
button.style.right_padding = 4
|
||||
button.style.bottom_padding = 2
|
||||
end
|
||||
end
|
||||
|
||||
local function refresh_score()
|
||||
local x = 1
|
||||
while (Game.get_player_by_index(x) ~= nil) do
|
||||
local player = Game.get_player_by_index(x)
|
||||
local frame = player.gui.top["score_panel"]
|
||||
local x = 1
|
||||
while (Game.get_player_by_index(x) ~= nil) do
|
||||
local player = Game.get_player_by_index(x)
|
||||
local frame = player.gui.top['score_panel']
|
||||
|
||||
if (frame) then
|
||||
frame.score_table.label_rockets_launched.caption = "Rockets launched: " .. global.score_rockets_launched
|
||||
frame.score_table.label_biters_killed.caption = "Biters liberated: " .. global.score_biter_total_kills
|
||||
-- frame.score_table.label_score_polls_created.caption = "Polls created: " .. global.score_total_polls_created
|
||||
end
|
||||
x = x + 1
|
||||
end
|
||||
if (frame) then
|
||||
frame.score_table.label_rockets_launched.caption = 'Rockets launched: ' .. global.score_rockets_launched
|
||||
frame.score_table.label_biters_killed.caption = 'Biters liberated: ' .. global.score_biter_total_kills
|
||||
-- frame.score_table.label_score_polls_created.caption = "Polls created: " .. global.score_total_polls_created
|
||||
end
|
||||
x = x + 1
|
||||
end
|
||||
end
|
||||
|
||||
local function score_show(player)
|
||||
local rocket_score_value_string = tostring(global.score_rockets_launched)
|
||||
|
||||
local rocket_score_value_string = tostring(global.score_rockets_launched)
|
||||
local frame = player.gui.top.add {type = 'frame', name = 'score_panel'}
|
||||
|
||||
local frame = player.gui.top.add { type = "frame", name = "score_panel" }
|
||||
local score_table = frame.add {type = 'table', column_count = 5, name = 'score_table'}
|
||||
local label = score_table.add {type = 'label', caption = '', name = 'label_rockets_launched'}
|
||||
label.style.font = 'default-bold'
|
||||
label.style.font_color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
label.style.top_padding = 2
|
||||
label.style.left_padding = 4
|
||||
label.style.right_padding = 4
|
||||
|
||||
local score_table = frame.add { type = "table", column_count = 5, name = "score_table" }
|
||||
local label = score_table.add { type = "label", caption = "", name = "label_rockets_launched" }
|
||||
label.style.font = "default-bold"
|
||||
label.style.font_color = { r=0.98, g=0.66, b=0.22}
|
||||
label.style.top_padding = 2
|
||||
label.style.left_padding = 4
|
||||
label.style.right_padding = 4
|
||||
score_table.add {type = 'label', caption = '|'}
|
||||
|
||||
score_table.add { type = "label", caption = "|"}
|
||||
|
||||
local label = score_table.add { type = "label", caption = "", name = "label_biters_killed" }
|
||||
label.style.font = "default-bold"
|
||||
label.style.font_color = { r=0.98, g=0.11, b=0.11}
|
||||
label.style.top_padding = 2
|
||||
label.style.left_padding = 4
|
||||
label.style.right_padding = 4
|
||||
--[[
|
||||
local label = score_table.add {type = 'label', caption = '', name = 'label_biters_killed'}
|
||||
label.style.font = 'default-bold'
|
||||
label.style.font_color = {r = 0.98, g = 0.11, b = 0.11}
|
||||
label.style.top_padding = 2
|
||||
label.style.left_padding = 4
|
||||
label.style.right_padding = 4
|
||||
--[[
|
||||
if global.score_total_polls_created then
|
||||
score_table.add { type = "label", caption = "|"}
|
||||
|
||||
@@ -66,35 +67,33 @@ local function score_show(player)
|
||||
label.style.right_padding = 4
|
||||
end
|
||||
--]]
|
||||
refresh_score()
|
||||
refresh_score()
|
||||
end
|
||||
|
||||
|
||||
local function on_gui_click(event)
|
||||
if not (event and event.element and event.element.valid) then return end
|
||||
if not (event and event.element and event.element.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local player = Game.get_player_by_index(event.element.player_index)
|
||||
local name = event.element.name
|
||||
local frame = player.gui.top["score_panel"]
|
||||
|
||||
if (name == "score") and (frame == nil) then
|
||||
score_show(player)
|
||||
else
|
||||
if (name == "score") then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
local player = Game.get_player_by_index(event.element.player_index)
|
||||
local name = event.element.name
|
||||
local frame = player.gui.top['score_panel']
|
||||
|
||||
if (name == 'score') and (frame == nil) then
|
||||
score_show(player)
|
||||
else
|
||||
if (name == 'score') then
|
||||
frame.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function rocket_launched(event)
|
||||
global.score_rockets_launched = global.score_rockets_launched + 1
|
||||
game.print ("A rocket has been launched!")
|
||||
refresh_score()
|
||||
global.score_rockets_launched = global.score_rockets_launched + 1
|
||||
game.print('A rocket has been launched!')
|
||||
refresh_score()
|
||||
end
|
||||
|
||||
|
||||
|
||||
Event.add(defines.events.on_entity_died, refresh_score)
|
||||
Event.add(defines.events.on_gui_click, on_gui_click)
|
||||
Event.add(defines.events.on_player_joined_game, create_score_gui)
|
||||
|
||||
@@ -3,7 +3,7 @@ local Gui = require 'utils.gui'
|
||||
local Global = require 'utils.global'
|
||||
local UserGroups = require 'features.user_groups'
|
||||
local Game = require 'utils.game'
|
||||
local Utils = require "utils.utils"
|
||||
local Utils = require 'utils.utils'
|
||||
|
||||
local deafult_verb = 'expanded'
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ local Global = require 'utils.global'
|
||||
local UserGroups = require 'features.user_groups'
|
||||
local Utils = require 'utils.utils'
|
||||
local Game = require 'utils.game'
|
||||
local math = require "utils.math"
|
||||
local math = require 'utils.math'
|
||||
|
||||
local normal_color = {r = 1, g = 1, b = 1}
|
||||
local focus_color = {r = 1, g = 0.55, b = 0.1}
|
||||
@@ -227,8 +227,7 @@ local function redraw_tasks(data, enabled)
|
||||
delete_button_tooltip = 'Delete task.'
|
||||
edit_button_tooltip = 'Edit task.'
|
||||
up_button_tooltip = 'Move the task up, right click moves 5 spaces, shift click moves the task to the top.'
|
||||
down_button_tooltip =
|
||||
'Move the task down, right click moves 5 spaces, shift click moves the task to the bottom.'
|
||||
down_button_tooltip = 'Move the task down, right click moves 5 spaces, shift click moves the task to the bottom.'
|
||||
else
|
||||
delete_button_tooltip = 'Sorry, you have to be a regular to delete tasks.'
|
||||
edit_button_tooltip = 'Sorry, you have to be a regular to edit tasks.'
|
||||
@@ -565,8 +564,7 @@ local function draw_create_task_frame(left, previous_task)
|
||||
confirm_button_caption = 'Create Task'
|
||||
end
|
||||
|
||||
local frame =
|
||||
left.add {type = 'frame', name = create_task_frame_name, caption = frame_caption, direction = 'vertical'}
|
||||
local frame = left.add {type = 'frame', name = create_task_frame_name, caption = frame_caption, direction = 'vertical'}
|
||||
frame.style.width = 470
|
||||
|
||||
local textbox = frame.add {type = 'textfield', text = text}
|
||||
@@ -580,8 +578,7 @@ local function draw_create_task_frame(left, previous_task)
|
||||
local clear_button = bottom_flow.add {type = 'button', name = create_task_clear_button_name, caption = 'Clear'}
|
||||
Gui.set_data(clear_button, textbox)
|
||||
bottom_flow.add({type = 'flow'}).style.horizontally_stretchable = true
|
||||
local confirm_button =
|
||||
bottom_flow.add {type = 'button', name = confirm_button_name, caption = confirm_button_caption}
|
||||
local confirm_button = bottom_flow.add {type = 'button', name = confirm_button_name, caption = confirm_button_caption}
|
||||
Gui.set_data(confirm_button, {frame = frame, textbox = textbox, previous_task = previous_task})
|
||||
end
|
||||
|
||||
@@ -693,8 +690,7 @@ Gui.on_click(
|
||||
local last_edit_player_label = top_flow.add {type = 'label'}
|
||||
local editing_players_label = top_flow.add {type = 'label'}
|
||||
|
||||
local textbox =
|
||||
frame.add {type = 'text-box', name = edit_announcements_textbox_name, text = announcements.edit_text}
|
||||
local textbox = frame.add {type = 'text-box', name = edit_announcements_textbox_name, text = announcements.edit_text}
|
||||
textbox.word_wrap = true
|
||||
local textbox_style = textbox.style
|
||||
textbox_style.width = 450
|
||||
|
||||
Reference in New Issue
Block a user