mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-11-06 09:09:26 +02:00
Fix formatting
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local Module = {}
|
||||
|
||||
local Gui = require("utils.gui")
|
||||
local Utils = require("utils.utils");
|
||||
local Gui = require('utils.gui')
|
||||
local Utils = require('utils.utils')
|
||||
local Game = require 'utils.game'
|
||||
|
||||
local report_frame_name = Gui.uid_name()
|
||||
@@ -19,14 +19,14 @@ global.player_report_data = {}
|
||||
local function draw_report(parent, report_id)
|
||||
local report = global.reports[report_id]
|
||||
if report_id == 0 or not report then
|
||||
parent.add {type = "label", caption="No reports yet."}
|
||||
parent.add {type = 'label', caption = 'No reports yet.'}
|
||||
return
|
||||
end
|
||||
|
||||
local reported_player_name = Game.get_player_by_index(report.reported_player_index).name
|
||||
local reporting_player_name = "<script>"
|
||||
local reporting_player_name = '<script>'
|
||||
if report.reporting_player_index then
|
||||
reporting_player_name = Game.get_player_by_index(report.reporting_player_index).name
|
||||
reporting_player_name = Game.get_player_by_index(report.reporting_player_index).name
|
||||
end
|
||||
local time = Utils.format_time(report.tick)
|
||||
local time_ago = Utils.format_time(game.tick - report.tick)
|
||||
@@ -35,12 +35,12 @@ local function draw_report(parent, report_id)
|
||||
Gui.clear(parent)
|
||||
|
||||
local permission_group = game.permissions.get_group(jail_name)
|
||||
local jail_offender_button_caption = (Game.get_player_by_index(report.reported_player_index).permission_group == permission_group) and 'Unjail ' .. reported_player_name or 'Jail ' .. reported_player_name
|
||||
local jail_offender_button_caption = (Game.get_player_by_index(report.reported_player_index).permission_group == permission_group) and 'Unjail ' .. reported_player_name or 'Jail ' .. reported_player_name
|
||||
|
||||
parent.add {type="label", caption="Offender: " .. reported_player_name}
|
||||
local msg_label_pane = parent.add {type="scroll-pane", vertical_scroll_policy = "auto-and-reserve-space", horizontal_scroll_policy="never"}
|
||||
parent.add {type = 'label', caption = 'Offender: ' .. reported_player_name}
|
||||
local msg_label_pane = parent.add {type = 'scroll-pane', vertical_scroll_policy = 'auto-and-reserve-space', horizontal_scroll_policy = 'never'}
|
||||
msg_label_pane.style.maximal_height = 400
|
||||
local msg_label = msg_label_pane.add {type="label", caption="Message: " .. message}
|
||||
local msg_label = msg_label_pane.add {type = 'label', caption = 'Message: ' .. message}
|
||||
local jail_offender_button = parent.add {type = 'button', name = jail_offender_button_name, caption = jail_offender_button_caption}
|
||||
jail_offender_button.style.height = 24
|
||||
jail_offender_button.style.font = 'default-small'
|
||||
@@ -50,11 +50,12 @@ local function draw_report(parent, report_id)
|
||||
jail_offender_button.style.right_padding = 0
|
||||
msg_label.style.single_line = false
|
||||
msg_label.style.maximal_width = 680
|
||||
parent.add {type="label", caption=string.format("Time: %s (%s ago)", time, time_ago)}
|
||||
parent.add {type="label", caption="Reported by: " .. reporting_player_name}
|
||||
parent.add {type = 'label', caption = string.format('Time: %s (%s ago)', time, time_ago)}
|
||||
parent.add {type = 'label', caption = 'Reported by: ' .. reporting_player_name}
|
||||
end
|
||||
|
||||
Module.show_reports = function(player)
|
||||
Module.show_reports =
|
||||
function(player)
|
||||
local reports = global.reports or {}
|
||||
|
||||
local center = player.gui.center
|
||||
@@ -64,7 +65,8 @@ Module.show_reports = function(player)
|
||||
Gui.destroy(report_frame)
|
||||
end
|
||||
|
||||
report_frame = center.add {
|
||||
report_frame =
|
||||
center.add {
|
||||
type = 'frame',
|
||||
name = report_frame_name,
|
||||
direction = 'vertical',
|
||||
@@ -74,18 +76,18 @@ Module.show_reports = function(player)
|
||||
player.opened = report_frame
|
||||
|
||||
if #reports > 1 then
|
||||
local scroll_pane = report_frame.add{type = "scroll-pane", horizontal_scroll_policy = "auto-and-reserve-space", vertical_scroll_policy="never"}
|
||||
local tab_flow = scroll_pane.add{type="flow"}
|
||||
for k,report in pairs(reports) do
|
||||
local button_cell = tab_flow.add{type="flow", caption="reportuid" .. k}
|
||||
local scroll_pane = report_frame.add {type = 'scroll-pane', horizontal_scroll_policy = 'auto-and-reserve-space', vertical_scroll_policy = 'never'}
|
||||
local tab_flow = scroll_pane.add {type = 'flow'}
|
||||
for k, report in pairs(reports) do
|
||||
local button_cell = tab_flow.add {type = 'flow', caption = 'reportuid' .. k}
|
||||
button_cell.add {
|
||||
type="button",
|
||||
name=report_tab_button_name,
|
||||
type = 'button',
|
||||
name = report_tab_button_name,
|
||||
caption = Game.get_player_by_index(report.reported_player_index).name
|
||||
}
|
||||
end
|
||||
end
|
||||
local report_body = report_frame.add {type = "scroll-pane", name = report_body_name, horizontal_scroll_policy = "never", vertical_scroll_policy="never"}
|
||||
local report_body = report_frame.add {type = 'scroll-pane', name = report_body_name, horizontal_scroll_policy = 'never', vertical_scroll_policy = 'never'}
|
||||
report_frame.add {type = 'button', name = report_close_button_name, caption = 'Close'}
|
||||
|
||||
draw_report(report_body, #reports)
|
||||
@@ -99,15 +101,17 @@ function Module.report(reporting_player, reported_player, message)
|
||||
table.insert(global.reports, {reporting_player_index = player_index, reported_player_index = reported_player.index, message = message, tick = game.tick})
|
||||
|
||||
local notified = false
|
||||
for _,p in pairs(game.players) do
|
||||
for _, p in pairs(game.players) do
|
||||
if p.admin and p.connected then
|
||||
p.play_sound{path='utility/tutorial_notice', volume_modifier = 1}
|
||||
p.play_sound {path = 'utility/tutorial_notice', volume_modifier = 1}
|
||||
Module.show_reports(p)
|
||||
if p.afk_time < 3600 then notified = true end
|
||||
if p.afk_time < 3600 then
|
||||
notified = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not notified then
|
||||
for _,p in pairs(game.players) do
|
||||
for _, p in pairs(game.players) do
|
||||
if p.admin then
|
||||
Module.show_reports(p)
|
||||
end
|
||||
@@ -144,11 +148,11 @@ function Module.jail(target_player, player)
|
||||
local print
|
||||
local jailed_by
|
||||
if player then
|
||||
jailed_by = "a server admin"
|
||||
jailed_by = 'a server admin'
|
||||
print = player.print
|
||||
else
|
||||
player = {name = 'server'}
|
||||
jailed_by = "the server"
|
||||
jailed_by = 'the server'
|
||||
print = log
|
||||
end
|
||||
|
||||
@@ -183,14 +187,15 @@ function Module.jail(target_player, player)
|
||||
permission_group.add_player(target_player)
|
||||
|
||||
-- Kick player out of vehicle
|
||||
target_player.driving=false
|
||||
target_player.driving = false
|
||||
|
||||
-- If a player is shooting when they're jailed they can't stop shooting, so we change their shooting state
|
||||
if target_player.shooting_state.state ~= 0 then
|
||||
target_player.shooting_state.state = {state = defines.shooting.not_shooting, position = {0,0}}
|
||||
target_player.shooting_state.state = {state = defines.shooting.not_shooting, position = {0, 0}}
|
||||
end
|
||||
|
||||
if target_player.walking_state.walking == true then -- Stop them walking while jailed
|
||||
-- Stop player walking while jailed
|
||||
if target_player.walking_state.walking == true then
|
||||
target_player.walking_state = {walking = false, direction = defines.direction.north}
|
||||
end
|
||||
|
||||
@@ -262,10 +267,7 @@ function Module.unjail_player(cmd)
|
||||
Utils.log_command(player, 'unjail', target_player.name)
|
||||
else
|
||||
-- Let admin know it didn't work.
|
||||
Game.player_print(
|
||||
'Something went wrong in the unjailing of ' ..
|
||||
target .. '. You can still change their group via /permissions and inform them.'
|
||||
)
|
||||
Game.player_print('Something went wrong in the unjailing of ' .. target .. '. You can still change their group via /permissions and inform them.')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -310,21 +312,21 @@ Gui.on_click(
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
local reporting_popup_name = Gui.uid_name()
|
||||
local reporting_cancel_button_name = Gui.uid_name()
|
||||
local reporting_submit_button_name = Gui.uid_name()
|
||||
local reporting_input_name = Gui.uid_name()
|
||||
|
||||
Module.spawn_reporting_popup = function(player, reported_player)
|
||||
|
||||
Module.spawn_reporting_popup =
|
||||
function(player, reported_player)
|
||||
local center = player.gui.center
|
||||
|
||||
local reporting_popup = center[reporting_popup_name]
|
||||
if reporting_popup and reporting_popup.valid then
|
||||
Gui.destroy(reporting_popup)
|
||||
end
|
||||
reporting_popup = center.add {
|
||||
reporting_popup =
|
||||
center.add {
|
||||
type = 'frame',
|
||||
name = reporting_popup_name,
|
||||
direction = 'vertical',
|
||||
@@ -338,12 +340,12 @@ Module.spawn_reporting_popup = function(player, reported_player)
|
||||
type = 'label',
|
||||
caption = 'Report message:'
|
||||
}
|
||||
local input = reporting_popup.add {type = 'text-box', name=reporting_input_name}
|
||||
local input = reporting_popup.add {type = 'text-box', name = reporting_input_name}
|
||||
input.style.width = 400
|
||||
input.style.height = 85
|
||||
local button_flow = reporting_popup.add {type = "flow"}
|
||||
button_flow.add {type = "button", name = reporting_submit_button_name, caption="Submit"}
|
||||
button_flow.add {type = "button", name = reporting_cancel_button_name, caption="Cancel"}
|
||||
local button_flow = reporting_popup.add {type = 'flow'}
|
||||
button_flow.add {type = 'button', name = reporting_submit_button_name, caption = 'Submit'}
|
||||
button_flow.add {type = 'button', name = reporting_cancel_button_name, caption = 'Cancel'}
|
||||
end
|
||||
|
||||
Gui.on_custom_close(
|
||||
@@ -367,13 +369,13 @@ Gui.on_click(
|
||||
local frame = event.element.parent.parent
|
||||
local msg = frame[reporting_input_name].text
|
||||
local data = Gui.get_data(frame)
|
||||
local reported_player_index = data["reported_player_index"]
|
||||
local reported_player_index = data['reported_player_index']
|
||||
local print = event.player.print
|
||||
|
||||
Gui.destroy(frame)
|
||||
Module.report(event.player, Game.get_player_by_index(reported_player_index), msg)
|
||||
print(prefix)
|
||||
print("You have successfully reported the player: " .. Game.get_player_by_index(reported_player_index).name)
|
||||
print('You have successfully reported the player: ' .. Game.get_player_by_index(reported_player_index).name)
|
||||
print(prefix_e)
|
||||
end
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user