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
local function show_reports(player)
local reports = global.reports or {}
local reports = global.reports or {}
local center = player.gui.center
if player.opened then --Destroy whatever is open
Gui.remove_data_recursivly(player.opened)
player.opened.destroy()
end
local center = player.gui.center
if player.opened then --Destroy whatever is open
Gui.remove_data_recursivly(player.opened)
player.opened.destroy()
end
report_frame =
center.add {
type = 'frame',
name = report_frame_name,
direction = 'vertical',
caption = 'User reports'
}
report_frame.style.maximal_width = 700
player.opened = report_frame
report_frame =
center.add {
type = 'frame',
name = report_frame_name,
direction = 'vertical',
caption = 'User reports'
}
report_frame.style.maximal_width = 700
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 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,
caption = game.players[report.reporting_player_index].name
}
end
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,
caption = game.players[report.reporting_player_index].name
}
end
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'}
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)
draw_report(report_body, #reports)
end
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
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
local notified = false
for _,p in pairs(game.players) do
if p.admin then
show_reports(p)
if p.admin and p.connected then
show_reports(p)
if p.afk_time < 3600 then notified = true 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
Gui.on_custom_close(
@ -105,11 +105,11 @@ Gui.on_click(
Gui.on_click(
report_tab_button_name,
function(event)
local center = event.player.gui.center
local report_frame = center[report_frame_name]
local report_uid_str = string.sub(event.element.parent.caption, 10)
local report_uid = tonumber(report_uid_str)
draw_report(report_frame[report_body_name], report_uid)
local center = event.player.gui.center
local report_frame = center[report_frame_name]
local report_uid_str = string.sub(event.element.parent.caption, 10)
local report_uid = tonumber(report_uid_str)
draw_report(report_frame[report_body_name], report_uid)
end
)