1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

fixed report formatting

This commit is contained in:
Maik Wild 2018-08-13 17:08:24 +02:00
parent 9dcb4c86e5
commit 1a68f0c984

View File

@ -31,59 +31,59 @@ local function draw_report(parent, report_id)
end end
local function show_reports(player) local function show_reports(player)
local reports = global.reports or {} local reports = global.reports or {}
local center = player.gui.center local center = player.gui.center
if player.opened then --Destroy whatever is open if player.opened then --Destroy whatever is open
Gui.remove_data_recursivly(player.opened) Gui.remove_data_recursivly(player.opened)
player.opened.destroy() player.opened.destroy()
end end
report_frame = report_frame =
center.add { center.add {
type = 'frame', type = 'frame',
name = report_frame_name, name = report_frame_name,
direction = 'vertical', direction = 'vertical',
caption = 'User reports' caption = 'User reports'
} }
report_frame.style.maximal_width = 700 report_frame.style.maximal_width = 700
player.opened = report_frame player.opened = report_frame
local scroll_pane = report_frame.add{type = "scroll-pane", horizontal_scroll_policy = "auto-and-reserve-space", vertical_scroll_policy="never"} 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"} local tab_flow = scroll_pane.add{type="flow"}
for k,report in pairs(reports) do for k,report in pairs(reports) do
local button_cell = tab_flow.add{type="flow", caption="reportuid" .. k} local button_cell = tab_flow.add{type="flow", caption="reportuid" .. k}
button_cell.add button_cell.add {
{ type="button",
type="button", name=report_tab_button_name,
name=report_tab_button_name, caption = game.players[report.reporting_player_index].name
caption = game.players[report.reporting_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'} report_frame.add {type = 'button', name = report_close_button_name, caption = 'Close'}
draw_report(report_body, #reports) draw_report(report_body, #reports)
end end
local function report(reporting_player, reported_player, message) local function report(reporting_player, reported_player, message)
table.insert(global.reports, {reporting_player_index = reporting_player.index, reported_player_index = reported_player.index, message = message, tick = game.tick}) table.insert(global.reports, {reporting_player_index = reporting_player.index, reported_player_index = reported_player.index, message = message, tick = game.tick})
local notified = false local notified = false
for _,p in pairs(game.players) do
if p.admin and p.connected then
show_reports(p)
if p.afk_time < 3600 then notified = true end
end
end
if not notified then end
for _,p in pairs(game.players) do for _,p in pairs(game.players) do
if p.admin then if p.admin and p.connected then
show_reports(p) show_reports(p)
if p.afk_time < 3600 then notified = true end
end end
end end
if not notified then
for _,p in pairs(game.players) do
if p.admin then
show_reports(p)
end
end
end
end end
Gui.on_custom_close( Gui.on_custom_close(
@ -105,11 +105,11 @@ Gui.on_click(
Gui.on_click( Gui.on_click(
report_tab_button_name, report_tab_button_name,
function(event) function(event)
local center = event.player.gui.center local center = event.player.gui.center
local report_frame = center[report_frame_name] local report_frame = center[report_frame_name]
local report_uid_str = string.sub(event.element.parent.caption, 10) local report_uid_str = string.sub(event.element.parent.caption, 10)
local report_uid = tonumber(report_uid_str) local report_uid = tonumber(report_uid_str)
draw_report(report_frame[report_body_name], report_uid) draw_report(report_frame[report_body_name], report_uid)
end end
) )