2018-08-09 02:26:43 +02:00
|
|
|
local Gui = require 'utils.gui'
|
|
|
|
local Global = require 'utils.global'
|
|
|
|
local Event = require 'utils.event'
|
2019-01-30 05:52:43 +02:00
|
|
|
local Donator = require 'features.donator'
|
|
|
|
local Rank = require 'features.rank_system'
|
2018-12-19 15:56:02 +02:00
|
|
|
local PlayerRewards = require 'utils.player_rewards'
|
2019-01-04 15:45:37 +02:00
|
|
|
local Server = require 'features.server'
|
|
|
|
local Token = require 'utils.token'
|
2019-01-30 05:52:43 +02:00
|
|
|
local Color = require 'resources.color_presets'
|
2019-01-25 18:32:49 +02:00
|
|
|
|
2018-12-19 15:56:02 +02:00
|
|
|
local format = string.format
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2019-01-25 18:32:49 +02:00
|
|
|
local config = global.config
|
|
|
|
local config_mapinfo = config.map_info
|
|
|
|
local config_prewards = config.player_rewards
|
|
|
|
|
2018-12-29 19:39:20 +02:00
|
|
|
local normal_color = Color.white
|
|
|
|
local focus_color = Color.dark_orange
|
2019-02-27 23:16:46 +02:00
|
|
|
local unfocus_color = Color.black
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2018-12-19 15:56:02 +02:00
|
|
|
local reward_amount = 2
|
|
|
|
local reward_token = PlayerRewards.get_reward()
|
|
|
|
local info_tab_flags = {
|
|
|
|
0x1, -- welcome
|
|
|
|
0x2, -- rules
|
|
|
|
0x4, -- map_info
|
|
|
|
0x8, -- scenario_mods
|
2019-01-24 23:32:40 +02:00
|
|
|
0x10 -- whats_new
|
2018-12-19 15:56:02 +02:00
|
|
|
}
|
|
|
|
local flags_sum = 0
|
|
|
|
for _, v in pairs(info_tab_flags) do
|
|
|
|
flags_sum = flags_sum + v
|
|
|
|
end
|
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
local map_name_key = 1
|
|
|
|
local map_description_key = 2
|
|
|
|
local map_extra_info_key = 3
|
|
|
|
local new_info_key = 4
|
|
|
|
|
2018-12-19 15:56:02 +02:00
|
|
|
local rewarded_players = {}
|
2021-01-01 20:04:14 +02:00
|
|
|
local primitives = {map_extra_info_lock = nil, info_edited = nil}
|
2018-11-13 01:30:30 +02:00
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
local editable_info = {
|
2019-01-25 18:32:49 +02:00
|
|
|
[map_name_key] = config_mapinfo.map_name_key,
|
|
|
|
[map_description_key] = config_mapinfo.map_description_key,
|
|
|
|
[map_extra_info_key] = config_mapinfo.map_extra_info_key,
|
|
|
|
[new_info_key] = config_mapinfo.new_info_key
|
2018-08-10 22:30:55 +02:00
|
|
|
}
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
Global.register({rewarded_players = rewarded_players, editable_info = editable_info, primitives = primitives},
|
2018-08-09 02:26:43 +02:00
|
|
|
function(tbl)
|
2018-12-19 15:56:02 +02:00
|
|
|
rewarded_players = tbl.rewarded_players
|
2018-08-12 22:03:50 +02:00
|
|
|
editable_info = tbl.editable_info
|
2019-01-25 18:45:58 +02:00
|
|
|
primitives = tbl.primitives
|
2021-01-01 20:04:14 +02:00
|
|
|
end)
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2019-01-24 23:32:40 +02:00
|
|
|
--- Sets the "new info" according to the changelog located on the server
|
2019-01-25 18:23:06 +02:00
|
|
|
local function process_changelog(data)
|
|
|
|
local key = data.key
|
|
|
|
if key ~= 'changelog' then
|
|
|
|
return
|
2019-01-24 23:32:40 +02:00
|
|
|
end
|
2019-01-25 18:23:06 +02:00
|
|
|
|
|
|
|
local value = data.value -- will be nil if no data
|
|
|
|
if value then
|
|
|
|
editable_info[new_info_key] = value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local changelog_callback = Token.register(process_changelog)
|
2019-01-24 23:32:40 +02:00
|
|
|
|
2019-06-21 11:56:37 +02:00
|
|
|
--- Uploads the contents of new info tab to the server.
|
|
|
|
-- Is triggered on closing the info window by clicking the close button or by pressing escape.
|
|
|
|
local function upload_changelog(player)
|
|
|
|
if not player or not player.valid or not player.admin then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if editable_info[new_info_key] ~= config_mapinfo.new_info_key and primitives.info_edited then
|
|
|
|
Server.set_data('misc', 'changelog', editable_info[new_info_key])
|
|
|
|
primitives.info_edited = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Tries to download the latest changelog
|
|
|
|
local function download_changelog()
|
|
|
|
Server.try_get_data('misc', 'changelog', changelog_callback)
|
|
|
|
end
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
local function prepare_title()
|
2021-01-01 20:04:14 +02:00
|
|
|
local welcome_title = [[
|
2018-08-09 02:26:43 +02:00
|
|
|
111111 1111111 111111 111 111 1111111 11 11
|
|
|
|
11 11 11 11 11 1111 1111 11 11 11
|
|
|
|
111111 11111 11 11 11 1111 11 11111 11 1 11
|
|
|
|
11 11 11 11 11 11 11 11 11 11 111 11
|
|
|
|
11 11 1111111 111111 11 11 1111111 111 111
|
|
|
|
]]
|
|
|
|
|
|
|
|
local row = {}
|
|
|
|
local welcome_title2 = {row}
|
|
|
|
local row_index = 1
|
|
|
|
local column_index = 1
|
|
|
|
|
|
|
|
local max = 0
|
|
|
|
for i = 1, #welcome_title do
|
|
|
|
local char = welcome_title:sub(i, i)
|
|
|
|
if char == '\n' then
|
|
|
|
row_index = row_index + 1
|
|
|
|
row = {}
|
|
|
|
welcome_title2[row_index] = row
|
|
|
|
|
|
|
|
max = math.max(max, column_index - 1)
|
|
|
|
|
|
|
|
column_index = 1
|
|
|
|
elseif char == '1' then
|
|
|
|
row[column_index] = true
|
|
|
|
column_index = column_index + 1
|
|
|
|
elseif char == ' ' then
|
|
|
|
row[column_index] = false
|
|
|
|
column_index = column_index + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return welcome_title2, max
|
2017-06-13 13:16:07 +02:00
|
|
|
end
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
local title, title_max = prepare_title()
|
|
|
|
|
|
|
|
local main_button_name = Gui.uid_name()
|
|
|
|
local main_frame_name = Gui.uid_name()
|
|
|
|
local tab_button_name = Gui.uid_name()
|
2018-08-10 22:30:55 +02:00
|
|
|
local editable_textbox_name = Gui.uid_name()
|
2018-08-09 02:26:43 +02:00
|
|
|
|
|
|
|
local function line_bar(parent)
|
|
|
|
local bar = parent.add {type = 'progressbar', value = 1}
|
|
|
|
local style = bar.style
|
|
|
|
style.color = normal_color
|
|
|
|
style.horizontally_stretchable = true
|
|
|
|
end
|
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
local function centered_label(parent, string)
|
|
|
|
local flow = parent.add {type = 'flow'}
|
|
|
|
local flow_style = flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
flow_style.horizontal_align = 'center'
|
2018-08-12 22:03:50 +02:00
|
|
|
flow_style.horizontally_stretchable = true
|
|
|
|
|
|
|
|
local label = flow.add {type = 'label', caption = string}
|
|
|
|
local label_style = label.style
|
2019-02-27 17:57:17 +02:00
|
|
|
label_style.horizontal_align = 'center'
|
2018-08-12 22:03:50 +02:00
|
|
|
label_style.single_line = false
|
|
|
|
|
|
|
|
return label
|
|
|
|
end
|
|
|
|
|
|
|
|
local function header_label(parent, string)
|
|
|
|
local flow = parent.add {type = 'flow'}
|
|
|
|
local flow_style = flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
flow_style.horizontal_align = 'center'
|
2018-08-12 22:03:50 +02:00
|
|
|
flow_style.horizontally_stretchable = true
|
|
|
|
|
|
|
|
local label = flow.add {type = 'label', caption = string}
|
|
|
|
local label_style = label.style
|
2019-02-27 17:57:17 +02:00
|
|
|
label_style.horizontal_align = 'center'
|
2018-08-12 22:03:50 +02:00
|
|
|
label_style.single_line = false
|
2019-02-26 19:36:20 +02:00
|
|
|
label_style.font = 'default-dialog-button'
|
2018-08-12 22:03:50 +02:00
|
|
|
|
|
|
|
return label
|
|
|
|
end
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
local pages = {
|
|
|
|
{
|
2018-12-19 15:56:02 +02:00
|
|
|
tab_button = function(parent)
|
2018-08-09 02:26:43 +02:00
|
|
|
local button = parent.add {type = 'button', name = tab_button_name, caption = 'Welcome'}
|
|
|
|
return button
|
|
|
|
end,
|
2018-12-19 15:56:02 +02:00
|
|
|
content = function(parent)
|
2018-08-12 22:03:50 +02:00
|
|
|
local parent_style = parent.style
|
2019-02-27 17:57:17 +02:00
|
|
|
parent_style.right_padding = 0
|
|
|
|
parent_style.left_padding = 0
|
|
|
|
parent_style.top_padding = 1
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
parent = parent.add {
|
2018-08-12 22:03:50 +02:00
|
|
|
type = 'scroll-pane',
|
|
|
|
vertical_scroll_policy = 'auto-and-reserve-space',
|
|
|
|
horizontal_scroll_policy = 'never'
|
2018-08-09 02:26:43 +02:00
|
|
|
}
|
2018-08-12 22:03:50 +02:00
|
|
|
parent_style = parent.style
|
2019-02-27 17:57:17 +02:00
|
|
|
parent_style.vertically_stretchable = false
|
2018-08-12 22:03:50 +02:00
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
header_label(parent, {'info.welcome_header'})
|
|
|
|
centered_label(parent, {'info.welcome_text'})
|
|
|
|
|
|
|
|
header_label(parent, {'info.chatting_header'})
|
2021-01-01 20:04:14 +02:00
|
|
|
centered_label(parent, {
|
|
|
|
'info.chatting_text',
|
|
|
|
{'gui-menu.settings'},
|
|
|
|
{'gui-menu.controls'},
|
|
|
|
{'controls.toggle-console'}
|
|
|
|
})
|
2018-11-17 13:59:51 +02:00
|
|
|
|
2019-01-25 18:32:49 +02:00
|
|
|
if config_prewards.enabled and config_prewards.info_player_reward then
|
2019-03-04 00:13:56 +02:00
|
|
|
header_label(parent, {'info.free_coin_header'})
|
2021-01-01 20:04:14 +02:00
|
|
|
centered_label(parent, {'info.free_coin_text', reward_amount, reward_token, reward_amount, reward_token})
|
2018-12-19 15:56:02 +02:00
|
|
|
end
|
2018-11-17 13:59:51 +02:00
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
header_label(parent, {'info.links_header'})
|
|
|
|
centered_label(parent, {'info.links_discord'})
|
2018-08-09 02:26:43 +02:00
|
|
|
local discord_textbox_flow = parent.add {type = 'flow'}
|
|
|
|
local discord_textbox_flow_style = discord_textbox_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
discord_textbox_flow_style.horizontal_align = 'center'
|
2018-08-09 02:26:43 +02:00
|
|
|
discord_textbox_flow_style.horizontally_stretchable = true
|
2018-08-12 23:26:30 +02:00
|
|
|
discord_textbox_flow.add({type = 'label', caption = 'Discord: '}).style.font = 'default-bold'
|
2020-09-14 22:14:15 +02:00
|
|
|
local discord_textbox = discord_textbox_flow.add {type = 'text-box', text = 'https://redmew.com/discord '}
|
2018-08-09 02:26:43 +02:00
|
|
|
discord_textbox.read_only = true
|
2019-02-28 16:05:30 +02:00
|
|
|
discord_textbox.style.width = 235
|
2019-02-27 17:57:17 +02:00
|
|
|
discord_textbox.style.height = 28
|
2019-03-04 00:13:56 +02:00
|
|
|
centered_label(parent, {'info.links_patreon'})
|
2018-08-12 22:03:50 +02:00
|
|
|
local patreon_flow = parent.add {type = 'flow', direction = 'horizontal'}
|
|
|
|
local patreon_flow_style = patreon_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
patreon_flow_style.horizontal_align = 'center'
|
2018-08-12 22:03:50 +02:00
|
|
|
patreon_flow_style.horizontally_stretchable = true
|
2018-08-12 23:26:30 +02:00
|
|
|
patreon_flow.add({type = 'label', caption = 'Patreon:'}).style.font = 'default-bold'
|
2019-02-28 16:05:30 +02:00
|
|
|
local patreon_textbox = patreon_flow.add {type = 'text-box', text = 'https://www.patreon.com/redmew '}
|
2018-08-12 22:03:50 +02:00
|
|
|
patreon_textbox.read_only = true
|
2019-02-28 16:05:30 +02:00
|
|
|
patreon_textbox.style.width = 235
|
2019-02-27 17:57:17 +02:00
|
|
|
patreon_textbox.style.height = 28
|
2019-03-04 00:13:56 +02:00
|
|
|
centered_label(parent, {'info.links_saves'})
|
2018-08-12 23:26:30 +02:00
|
|
|
local save_textbox_flow = parent.add {type = 'flow'}
|
|
|
|
local save_textbox_flow_style = save_textbox_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
save_textbox_flow_style.horizontal_align = 'center'
|
2018-08-12 23:26:30 +02:00
|
|
|
save_textbox_flow_style.horizontally_stretchable = true
|
|
|
|
save_textbox_flow.add({type = 'label', caption = 'Saves: '}).style.font = 'default-bold'
|
2020-07-17 10:39:23 +02:00
|
|
|
local save_textbox = save_textbox_flow.add {type = 'text-box', text = 'http://redmew.com/saves/ '}
|
2018-08-12 23:26:30 +02:00
|
|
|
save_textbox.read_only = true
|
2019-02-28 16:05:30 +02:00
|
|
|
save_textbox.style.width = 235
|
2019-02-27 17:57:17 +02:00
|
|
|
save_textbox.style.height = 28
|
2019-03-04 00:13:56 +02:00
|
|
|
centered_label(parent, {'info.links_factoriomaps'})
|
2018-08-25 13:54:33 +02:00
|
|
|
local maps_textbox_flow = parent.add {type = 'flow'}
|
|
|
|
local maps_textbox_flow_style = maps_textbox_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
maps_textbox_flow_style.horizontal_align = 'center'
|
2018-08-25 13:54:33 +02:00
|
|
|
maps_textbox_flow_style.horizontally_stretchable = true
|
|
|
|
maps_textbox_flow.add({type = 'label', caption = 'Maps: '}).style.font = 'default-bold'
|
2021-01-01 20:04:14 +02:00
|
|
|
local maps_textbox = maps_textbox_flow.add {
|
|
|
|
type = 'text-box',
|
|
|
|
text = 'https://factoriomaps.com/browse/redmew.html '
|
|
|
|
}
|
2018-08-25 13:54:33 +02:00
|
|
|
maps_textbox.read_only = true
|
2019-02-28 16:05:30 +02:00
|
|
|
maps_textbox.style.width = 315
|
2019-02-27 17:57:17 +02:00
|
|
|
maps_textbox.style.height = 28
|
2018-08-25 13:54:33 +02:00
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
parent.add({type = 'flow'}).style.height = 24
|
2018-08-09 02:26:43 +02:00
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2018-12-19 15:56:02 +02:00
|
|
|
tab_button = function(parent)
|
2018-08-09 02:26:43 +02:00
|
|
|
local button = parent.add {type = 'button', name = tab_button_name, caption = 'Rules'}
|
|
|
|
return button
|
|
|
|
end,
|
2018-12-19 15:56:02 +02:00
|
|
|
content = function(parent)
|
2019-02-28 16:05:30 +02:00
|
|
|
local parent_style = parent.style
|
|
|
|
parent_style.right_padding = 0
|
|
|
|
parent_style.left_padding = 0
|
|
|
|
parent_style.top_padding = 1
|
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
parent = parent.add {type = 'flow', direction = 'vertical'}
|
2019-02-28 16:05:30 +02:00
|
|
|
parent_style = parent.style
|
|
|
|
parent_style.vertically_stretchable = false
|
|
|
|
parent_style.width = 600
|
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
header_label(parent, {'info.rules_header'})
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
centered_label(parent, {'info.rules_text'})
|
2018-08-09 02:26:43 +02:00
|
|
|
end
|
|
|
|
},
|
2018-11-17 13:59:51 +02:00
|
|
|
{
|
2018-12-19 15:56:02 +02:00
|
|
|
tab_button = function(parent)
|
2019-03-04 00:13:56 +02:00
|
|
|
local button = parent.add {type = 'button', name = tab_button_name, caption = {'info.map_info_button'}}
|
2018-11-17 13:59:51 +02:00
|
|
|
return button
|
|
|
|
end,
|
|
|
|
content = function(parent, player)
|
|
|
|
local read_only = not player.admin
|
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local parent_style = parent.style
|
|
|
|
parent_style.right_padding = 8
|
|
|
|
parent_style.left_padding = 8
|
|
|
|
parent_style.top_padding = 1
|
|
|
|
|
2018-11-17 13:59:51 +02:00
|
|
|
local top_flow = parent.add {type = 'flow'}
|
|
|
|
local top_flow_style = top_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
top_flow_style.horizontal_align = 'center'
|
2018-11-17 13:59:51 +02:00
|
|
|
top_flow_style.horizontally_stretchable = true
|
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
local top_label = top_flow.add {type = 'label', caption = {'info.map_info_header'}}
|
2018-11-17 13:59:51 +02:00
|
|
|
local top_label_style = top_label.style
|
2019-02-26 19:36:20 +02:00
|
|
|
top_label_style.font = 'default-dialog-button'
|
2018-11-17 13:59:51 +02:00
|
|
|
|
|
|
|
local grid = parent.add {type = 'table', column_count = 2}
|
|
|
|
local grid_style = grid.style
|
|
|
|
grid_style.horizontally_stretchable = true
|
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
grid.add {type = 'label', caption = {'info.map_name_label'}}
|
2021-01-01 20:04:14 +02:00
|
|
|
local map_name_textbox = grid.add({type = 'flow'}).add {
|
2018-11-17 13:59:51 +02:00
|
|
|
type = 'text-box',
|
|
|
|
name = editable_textbox_name,
|
|
|
|
text = editable_info[map_name_key]
|
|
|
|
}
|
|
|
|
map_name_textbox.read_only = read_only
|
|
|
|
|
|
|
|
local map_name_textbox_style = map_name_textbox.style
|
2021-01-01 20:04:14 +02:00
|
|
|
map_name_textbox_style.width = 490
|
2019-02-27 23:16:46 +02:00
|
|
|
map_name_textbox_style.maximal_height = 30
|
2018-11-17 13:59:51 +02:00
|
|
|
|
|
|
|
Gui.set_data(map_name_textbox, map_name_key)
|
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
grid.add {type = 'label', caption = {'info.map_desc_label'}}
|
2021-01-01 20:04:14 +02:00
|
|
|
local map_description_textbox = grid.add({type = 'flow'}).add {
|
2018-11-17 13:59:51 +02:00
|
|
|
type = 'text-box',
|
|
|
|
name = editable_textbox_name,
|
|
|
|
text = editable_info[map_description_key]
|
|
|
|
}
|
|
|
|
map_description_textbox.read_only = read_only
|
2021-01-01 20:04:14 +02:00
|
|
|
map_description_textbox.word_wrap = true
|
2018-11-17 13:59:51 +02:00
|
|
|
|
|
|
|
local map_description_textbox_style = map_description_textbox.style
|
2021-01-01 20:04:14 +02:00
|
|
|
map_description_textbox_style.width = 490
|
2019-02-28 16:05:30 +02:00
|
|
|
map_description_textbox_style.minimal_height = 80
|
|
|
|
map_description_textbox_style.vertically_stretchable = true
|
|
|
|
map_description_textbox_style.maximal_height = 100
|
2018-11-17 13:59:51 +02:00
|
|
|
|
|
|
|
Gui.set_data(map_description_textbox, map_description_key)
|
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
grid.add {type = 'label', caption = {'info.map_extra_info_label'}}
|
2021-01-01 20:04:14 +02:00
|
|
|
local map_extra_info_textbox = grid.add({type = 'flow'}).add {
|
2018-11-17 13:59:51 +02:00
|
|
|
type = 'text-box',
|
|
|
|
name = editable_textbox_name,
|
|
|
|
text = editable_info[map_extra_info_key]
|
|
|
|
}
|
|
|
|
map_extra_info_textbox.read_only = read_only
|
2021-01-01 20:04:14 +02:00
|
|
|
map_extra_info_textbox.word_wrap = true
|
2018-11-17 13:59:51 +02:00
|
|
|
|
|
|
|
local map_extra_info_textbox_style = map_extra_info_textbox.style
|
2019-10-18 23:20:55 +02:00
|
|
|
map_extra_info_textbox_style.width = 490
|
2021-01-01 20:04:14 +02:00
|
|
|
map_extra_info_textbox_style.height = 248
|
2018-11-17 13:59:51 +02:00
|
|
|
|
|
|
|
Gui.set_data(map_extra_info_textbox, map_extra_info_key)
|
|
|
|
end
|
|
|
|
},
|
2018-08-09 02:26:43 +02:00
|
|
|
{
|
2018-12-19 15:56:02 +02:00
|
|
|
tab_button = function(parent)
|
2019-03-04 00:13:56 +02:00
|
|
|
local button = parent.add {type = 'button', name = tab_button_name, caption = {'info.softmods_button'}}
|
2018-08-09 02:26:43 +02:00
|
|
|
return button
|
|
|
|
end,
|
|
|
|
content = function(parent, player)
|
2018-08-10 22:30:55 +02:00
|
|
|
local parent_style = parent.style
|
2019-02-27 17:57:17 +02:00
|
|
|
parent_style.right_padding = 0
|
|
|
|
parent_style.left_padding = 0
|
|
|
|
parent_style.top_padding = 1
|
2018-08-10 22:30:55 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
parent = parent.add {
|
2018-08-09 02:26:43 +02:00
|
|
|
type = 'scroll-pane',
|
|
|
|
vertical_scroll_policy = 'auto-and-reserve-space',
|
|
|
|
horizontal_scroll_policy = 'never'
|
|
|
|
}
|
2018-08-10 22:30:55 +02:00
|
|
|
parent_style = parent.style
|
2021-01-01 20:04:14 +02:00
|
|
|
parent_style.right_padding = 8
|
|
|
|
parent_style.left_padding = 8
|
2018-08-09 02:26:43 +02:00
|
|
|
parent_style.vertically_stretchable = true
|
|
|
|
|
2019-03-04 00:13:56 +02:00
|
|
|
header_label(parent, {'info.softmods_header'})
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
local grid = parent.add {type = 'table', column_count = 3}
|
|
|
|
local grid_style = grid.style
|
|
|
|
grid_style.vertical_spacing = 24
|
|
|
|
grid_style.horizontal_spacing = 8
|
|
|
|
grid_style.top_padding = 8
|
|
|
|
grid_style.bottom_padding = 16
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
grid.add {type = 'label'}
|
|
|
|
local ranks = grid.add {type = 'label', caption = 'Ranks'}
|
2018-08-09 02:26:43 +02:00
|
|
|
ranks.style.font = 'default-listbox'
|
2018-08-12 22:03:50 +02:00
|
|
|
local ranks_flow = grid.add {type = 'flow', direction = 'vertical'}
|
2021-01-01 20:04:14 +02:00
|
|
|
local ranks_label = ranks_flow.add {type = 'label', caption = {'info.softmods_rank_text'}}
|
2018-08-09 02:26:43 +02:00
|
|
|
local ranks_label_style = ranks_label.style
|
|
|
|
ranks_label_style.single_line = false
|
2018-08-12 22:03:50 +02:00
|
|
|
local player_rank_flow = ranks_flow.add {type = 'flow', direction = 'horizontal'}
|
2019-03-04 00:13:56 +02:00
|
|
|
player_rank_flow.add {type = 'label', caption = {'info.softmods_rank_is'}}
|
2019-01-30 05:52:43 +02:00
|
|
|
local player_name = player.name
|
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local rank = Rank.get_player_rank(player_name)
|
|
|
|
local rank_label = player_rank_flow.add {type = 'label', caption = Rank.get_rank_name(rank)}
|
|
|
|
rank_label.style.font_color = Rank.get_rank_color(rank)
|
2019-02-13 01:45:27 +02:00
|
|
|
|
2019-01-30 05:52:43 +02:00
|
|
|
if Donator.is_donator(player_name) then
|
2019-02-13 01:45:27 +02:00
|
|
|
local donator_label = player_rank_flow.add {type = 'label', caption = {'ranks.donator'}}
|
|
|
|
donator_label.style.font_color = Color.donator
|
2018-08-09 02:26:43 +02:00
|
|
|
end
|
|
|
|
|
2018-08-12 22:03:50 +02:00
|
|
|
grid.add {type = 'sprite', sprite = 'entity/market'}
|
2019-03-04 00:13:56 +02:00
|
|
|
local market = grid.add {type = 'label', caption = {'info.softmods_market_label'}}
|
2018-08-12 22:03:50 +02:00
|
|
|
market.style.font = 'default-listbox'
|
2021-01-01 20:04:14 +02:00
|
|
|
local market_label = grid.add {type = 'label', caption = {'info.softmods_market_text'}}
|
2018-08-12 22:03:50 +02:00
|
|
|
market_label.style.single_line = false
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2020-11-15 22:53:32 +02:00
|
|
|
grid.add {type = 'sprite', sprite = 'item/player-port'}
|
2019-03-04 00:13:56 +02:00
|
|
|
local train_savior = grid.add {type = 'label', caption = {'info.softmods_saviour_label'}}
|
2018-11-17 13:59:51 +02:00
|
|
|
local train_savior_style = train_savior.style
|
|
|
|
train_savior_style.font = 'default-listbox'
|
|
|
|
train_savior_style.single_line = false
|
2021-01-01 20:04:14 +02:00
|
|
|
local train_savior_label = grid.add {type = 'label', caption = {'info.softmods_saviour_text'}}
|
2018-11-17 13:59:51 +02:00
|
|
|
train_savior_label.style.single_line = false
|
|
|
|
|
2019-01-25 18:32:49 +02:00
|
|
|
if config.player_list.enabled then
|
2019-05-02 17:02:53 +02:00
|
|
|
grid.add {type = 'sprite', sprite = 'entity/character'}
|
2019-03-04 00:13:56 +02:00
|
|
|
local player_list = grid.add {type = 'label', caption = {'info.softmods_plist_label'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
player_list.style.font = 'default-listbox'
|
|
|
|
player_list.style.single_line = false
|
2021-01-01 20:04:14 +02:00
|
|
|
local player_list_label = grid.add {type = 'label', caption = {'info.softmods_plist_text'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
player_list_label.style.single_line = false
|
|
|
|
end
|
2019-01-25 18:32:49 +02:00
|
|
|
if config.poll.enabled then
|
2018-12-06 13:18:52 +02:00
|
|
|
grid.add {type = 'sprite', sprite = 'item/programmable-speaker'}
|
2019-03-04 00:13:56 +02:00
|
|
|
local poll = grid.add {type = 'label', caption = {'info.softmods_polls_label'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
poll.style.font = 'default-listbox'
|
2021-01-01 20:04:14 +02:00
|
|
|
local poll_label = grid.add {type = 'label', caption = {'info.softmods_polls_text'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
poll_label.style.single_line = false
|
|
|
|
end
|
|
|
|
|
2019-01-25 18:32:49 +02:00
|
|
|
if config.tag_group.enabled then
|
2018-12-06 13:18:52 +02:00
|
|
|
local tag_button = grid.add {type = 'label', caption = 'tag'}
|
|
|
|
local tag_button_style = tag_button.style
|
|
|
|
tag_button_style.font = 'default-listbox'
|
2018-12-29 19:39:20 +02:00
|
|
|
tag_button_style.font_color = Color.black
|
2019-03-04 00:13:56 +02:00
|
|
|
local tag = grid.add {type = 'label', caption = {'info.softmods_tags_label'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
tag.style.font = 'default-listbox'
|
2021-01-01 20:04:14 +02:00
|
|
|
local tag_label = grid.add {type = 'label', caption = {'info.softmods_tags_text'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
tag_label.style.single_line = false
|
|
|
|
end
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2019-01-25 18:32:49 +02:00
|
|
|
if config.tasklist.enabled then
|
2018-12-06 13:18:52 +02:00
|
|
|
grid.add {type = 'sprite', sprite = 'item/repair-pack'}
|
2019-03-04 00:13:56 +02:00
|
|
|
local task = grid.add {type = 'label', caption = {'info.softmods_tasks_label'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
task.style.font = 'default-listbox'
|
2021-01-01 20:04:14 +02:00
|
|
|
local task_label = grid.add {type = 'label', caption = {'info.softmods_tasks_text'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
task_label.style.single_line = false
|
|
|
|
end
|
|
|
|
|
2019-01-25 18:32:49 +02:00
|
|
|
if config.score.enabled then
|
2018-12-06 13:18:52 +02:00
|
|
|
grid.add {type = 'sprite', sprite = 'item/rocket-silo'}
|
2019-03-04 00:13:56 +02:00
|
|
|
local score = grid.add {type = 'label', caption = {'info.softmods_score_label'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
score.style.font = 'default-listbox'
|
2021-01-01 20:04:14 +02:00
|
|
|
local score_label = grid.add {type = 'label', caption = {'info.softmods_score_text'}}
|
2018-12-06 13:18:52 +02:00
|
|
|
score_label.style.single_line = false
|
|
|
|
end
|
2018-08-09 02:26:43 +02:00
|
|
|
end
|
|
|
|
},
|
|
|
|
{
|
2018-12-06 13:18:52 +02:00
|
|
|
tab_button = function(parent)
|
2019-03-04 00:13:56 +02:00
|
|
|
local button = parent.add {type = 'button', name = tab_button_name, caption = {'info.whats_new_button'}}
|
2018-08-09 02:26:43 +02:00
|
|
|
return button
|
|
|
|
end,
|
|
|
|
content = function(parent, player)
|
2018-08-12 22:03:50 +02:00
|
|
|
local read_only = not player.admin
|
2018-08-10 22:30:55 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local parent_style = parent.style
|
|
|
|
parent_style.right_padding = 8
|
|
|
|
parent_style.left_padding = 8
|
|
|
|
parent_style.top_padding = 1
|
|
|
|
|
2018-11-17 13:59:51 +02:00
|
|
|
header_label(parent, 'New Features')
|
2018-08-10 22:30:55 +02:00
|
|
|
|
2019-02-28 16:05:30 +02:00
|
|
|
local new_info_flow = parent.add {name = 'whatsNew_new_info_flow', type = 'flow'}
|
2019-02-27 17:57:17 +02:00
|
|
|
new_info_flow.style.horizontal_align = 'center'
|
2018-08-10 22:30:55 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local new_info_textbox = new_info_flow.add {
|
2018-08-12 22:03:50 +02:00
|
|
|
type = 'text-box',
|
|
|
|
name = editable_textbox_name,
|
|
|
|
text = editable_info[new_info_key]
|
|
|
|
}
|
|
|
|
new_info_textbox.read_only = read_only
|
|
|
|
|
|
|
|
local new_info_textbox_style = new_info_textbox.style
|
2021-01-01 20:04:14 +02:00
|
|
|
new_info_textbox_style.width = 590
|
2019-02-28 18:36:28 +02:00
|
|
|
new_info_textbox_style.height = 360
|
2019-02-28 16:05:30 +02:00
|
|
|
new_info_textbox_style.left_margin = 2
|
2018-08-12 22:03:50 +02:00
|
|
|
|
|
|
|
Gui.set_data(new_info_textbox, new_info_key)
|
2018-08-09 02:26:43 +02:00
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
local function draw_main_frame(center, player)
|
|
|
|
local frame = center.add {type = 'frame', name = main_frame_name, direction = 'vertical'}
|
|
|
|
local frame_style = frame.style
|
|
|
|
frame_style.height = 600
|
2018-08-12 22:03:50 +02:00
|
|
|
frame_style.width = 650
|
2018-08-09 02:26:43 +02:00
|
|
|
frame_style.left_padding = 16
|
|
|
|
frame_style.right_padding = 16
|
|
|
|
frame_style.top_padding = 16
|
|
|
|
|
|
|
|
local top_flow = frame.add {type = 'flow'}
|
|
|
|
local top_flow_style = top_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
top_flow_style.horizontal_align = 'center'
|
2018-08-09 02:26:43 +02:00
|
|
|
top_flow_style.top_padding = 8
|
|
|
|
top_flow_style.horizontally_stretchable = true
|
|
|
|
|
|
|
|
local title_grid = top_flow.add {type = 'table', column_count = title_max}
|
|
|
|
for _, row in ipairs(title) do
|
|
|
|
for _, char in ipairs(row) do
|
|
|
|
local ele
|
|
|
|
if char then
|
|
|
|
ele = title_grid.add {type = 'sprite', sprite = 'virtual-signal/signal-red'}
|
2019-02-27 17:57:17 +02:00
|
|
|
ele.style.stretch_image_to_widget_size = true
|
2018-08-09 02:26:43 +02:00
|
|
|
else
|
|
|
|
ele = title_grid.add {type = 'label', caption = ' '}
|
|
|
|
end
|
|
|
|
|
|
|
|
local ele_style = ele.style
|
|
|
|
ele_style.height = 10
|
|
|
|
ele_style.width = 10
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local title_grid_style = title_grid.style
|
|
|
|
title_grid_style.vertical_spacing = 0
|
|
|
|
title_grid_style.horizontal_spacing = 0
|
|
|
|
title_grid_style.bottom_padding = 8
|
|
|
|
|
|
|
|
line_bar(frame)
|
|
|
|
|
|
|
|
local tab_buttons = {}
|
|
|
|
local active_tab = 1
|
2021-01-01 20:04:14 +02:00
|
|
|
local data = {tab_buttons = tab_buttons, active_tab = active_tab}
|
2018-08-09 02:26:43 +02:00
|
|
|
|
|
|
|
local tab_flow = frame.add {type = 'flow', direction = 'horizontal'}
|
|
|
|
local tab_flow_style = tab_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
tab_flow_style.horizontal_align = 'center'
|
2018-08-09 02:26:43 +02:00
|
|
|
tab_flow_style.horizontally_stretchable = true
|
|
|
|
|
|
|
|
for index, page in ipairs(pages) do
|
|
|
|
local button_flow = tab_flow.add {type = 'flow'}
|
2018-08-10 22:30:55 +02:00
|
|
|
local button = page.tab_button(button_flow, player)
|
2018-08-14 12:36:55 +02:00
|
|
|
|
|
|
|
local button_style = button.style
|
|
|
|
button_style.left_padding = 3
|
|
|
|
button_style.right_padding = 3
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
Gui.set_data(button, {index = index, data = data})
|
|
|
|
|
|
|
|
tab_buttons[index] = button
|
|
|
|
end
|
|
|
|
|
|
|
|
tab_buttons[active_tab].style.font_color = focus_color
|
|
|
|
|
|
|
|
line_bar(frame)
|
|
|
|
|
2020-05-26 18:35:14 +02:00
|
|
|
local content = frame.add {type = 'frame', direction = 'vertical', style = 'inside_shallow_frame'}
|
2018-08-09 02:26:43 +02:00
|
|
|
local content_style = content.style
|
|
|
|
content_style.horizontally_stretchable = true
|
|
|
|
content_style.vertically_stretchable = true
|
|
|
|
content_style.left_padding = 8
|
|
|
|
content_style.right_padding = 8
|
|
|
|
content_style.top_padding = 4
|
|
|
|
|
|
|
|
pages[active_tab].content(content, player)
|
|
|
|
|
|
|
|
data.content = content
|
|
|
|
|
|
|
|
local bottom_flow = frame.add {type = 'flow'}
|
|
|
|
local bottom_flow_style = bottom_flow.style
|
2019-02-27 17:57:17 +02:00
|
|
|
bottom_flow_style.horizontal_align = 'center'
|
2018-08-09 02:26:43 +02:00
|
|
|
bottom_flow_style.top_padding = 8
|
|
|
|
bottom_flow_style.horizontally_stretchable = true
|
|
|
|
|
2020-10-04 22:13:09 +02:00
|
|
|
Gui.make_close_button(bottom_flow, main_button_name)
|
2018-08-09 02:26:43 +02:00
|
|
|
|
|
|
|
player.opened = frame
|
|
|
|
end
|
|
|
|
|
2019-06-21 11:56:37 +02:00
|
|
|
local function close_main_frame(frame, player)
|
|
|
|
upload_changelog(player)
|
|
|
|
Gui.destroy(frame)
|
2020-11-24 19:44:31 +02:00
|
|
|
player.gui.top[main_button_name].style = 'slot_button'
|
2019-06-21 11:56:37 +02:00
|
|
|
end
|
|
|
|
|
2018-12-19 15:56:02 +02:00
|
|
|
local function reward_player(player, index, message)
|
2019-01-25 18:32:49 +02:00
|
|
|
if not config_prewards.enabled or not config_prewards.info_player_reward then
|
2018-12-19 15:56:02 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local player_index = player.index
|
|
|
|
if not rewarded_players[player_index] then
|
|
|
|
error('Player with no entry in rewarded_players table')
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
local tab_flag = info_tab_flags[index]
|
|
|
|
|
|
|
|
if bit32.band(rewarded_players[player_index], tab_flag) == tab_flag then
|
|
|
|
return
|
|
|
|
else
|
|
|
|
PlayerRewards.give_reward(player, reward_amount, message)
|
|
|
|
rewarded_players[player_index] = rewarded_players[player_index] + tab_flag
|
|
|
|
if rewarded_players[player_index] == flags_sum then
|
|
|
|
rewarded_players[player_index] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
local function toggle(event)
|
|
|
|
local player = event.player
|
2019-06-20 13:39:18 +02:00
|
|
|
local gui = player.gui
|
|
|
|
local center = gui.center
|
2018-08-09 02:26:43 +02:00
|
|
|
local main_frame = center[main_frame_name]
|
2019-06-20 13:39:18 +02:00
|
|
|
local main_button = gui.top[main_button_name]
|
2018-08-09 02:26:43 +02:00
|
|
|
|
|
|
|
if main_frame then
|
2019-06-21 11:56:37 +02:00
|
|
|
close_main_frame(main_frame, player)
|
2018-08-09 02:26:43 +02:00
|
|
|
else
|
2020-11-24 19:44:31 +02:00
|
|
|
main_button.style = 'highlighted_tool_button'
|
2019-06-20 13:39:18 +02:00
|
|
|
local style = main_button.style
|
2020-11-24 19:44:31 +02:00
|
|
|
style.width = 40
|
|
|
|
style.height = 40
|
|
|
|
style.padding = 0
|
2019-06-21 11:56:37 +02:00
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
draw_main_frame(center, player)
|
|
|
|
end
|
2017-06-13 13:16:07 +02:00
|
|
|
end
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
local function player_created(event)
|
2019-05-16 12:10:56 +02:00
|
|
|
local player = game.get_player(event.player_index)
|
2018-08-09 02:26:43 +02:00
|
|
|
if not player or not player.valid then
|
|
|
|
return
|
|
|
|
end
|
2017-07-09 02:28:01 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
player.gui.top.add({
|
|
|
|
type = 'sprite-button',
|
|
|
|
name = main_button_name,
|
|
|
|
sprite = 'virtual-signal/signal-info',
|
|
|
|
tooltip = {'info.tooltip'}
|
|
|
|
})
|
2017-07-09 02:28:01 +02:00
|
|
|
|
2018-12-19 15:56:02 +02:00
|
|
|
rewarded_players[player.index] = 0
|
|
|
|
reward_player(player, info_tab_flags[1])
|
2017-06-13 13:16:07 +02:00
|
|
|
end
|
|
|
|
|
2018-12-29 03:19:55 +02:00
|
|
|
--- Sets editable_info[map_extra_info_key] outright or adds info to it.
|
|
|
|
-- Forbids map_extra_info being explicitly set twice
|
|
|
|
local function create_map_extra_info(value, set)
|
2019-01-25 18:45:58 +02:00
|
|
|
if primitives.map_extra_info_lock and set then
|
2018-12-29 03:19:55 +02:00
|
|
|
error('Cannot set extra info twice, use add instead')
|
|
|
|
return
|
2019-01-25 18:45:58 +02:00
|
|
|
elseif primitives.map_extra_info_lock then
|
2018-12-29 03:19:55 +02:00
|
|
|
return
|
|
|
|
elseif set then
|
|
|
|
editable_info[map_extra_info_key] = value
|
2019-01-25 18:45:58 +02:00
|
|
|
primitives.map_extra_info_lock = true
|
2019-01-25 18:32:49 +02:00
|
|
|
elseif editable_info[map_extra_info_key] == config_mapinfo.map_extra_info_key then
|
2018-12-29 03:19:55 +02:00
|
|
|
editable_info[map_extra_info_key] = value
|
|
|
|
else
|
2019-01-25 18:32:49 +02:00
|
|
|
editable_info[map_extra_info_key] = format('%s\n%s', editable_info[map_extra_info_key], value)
|
2018-12-29 03:19:55 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
Event.add(defines.events.on_player_created, player_created)
|
|
|
|
|
2019-01-24 23:32:40 +02:00
|
|
|
Event.add(Server.events.on_server_started, download_changelog)
|
|
|
|
|
2019-01-25 18:23:06 +02:00
|
|
|
Server.on_data_set_changed('misc', process_changelog)
|
2019-01-04 15:45:37 +02:00
|
|
|
|
2018-08-09 02:26:43 +02:00
|
|
|
Gui.on_click(main_button_name, toggle)
|
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
Gui.on_click(tab_button_name, function(event)
|
|
|
|
local button = event.element
|
|
|
|
local player = event.player
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local button_data = Gui.get_data(button)
|
|
|
|
local index = button_data.index
|
|
|
|
local data = button_data.data
|
|
|
|
local active_tab = data.active_tab
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
if active_tab == index then
|
|
|
|
return
|
|
|
|
end
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local tab_buttons = data.tab_buttons
|
|
|
|
local old_button = tab_buttons[active_tab]
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
old_button.style.font_color = unfocus_color
|
|
|
|
button.style.font_color = focus_color
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
data.active_tab = index
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
local content = data.content
|
|
|
|
Gui.clear(content)
|
2018-08-09 02:26:43 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
pages[index].content(content, player)
|
|
|
|
if rewarded_players[player.index] then
|
|
|
|
reward_player(player, index, {'info.free_coin_print', reward_amount, reward_token})
|
2018-08-09 02:26:43 +02:00
|
|
|
end
|
2021-01-01 20:04:14 +02:00
|
|
|
end)
|
2017-06-13 13:16:07 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
Gui.on_text_changed(editable_textbox_name, function(event)
|
|
|
|
local textbox = event.element
|
|
|
|
local key = Gui.get_data(textbox)
|
2018-08-10 22:30:55 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
editable_info[key] = textbox.text
|
|
|
|
primitives.info_edited = true
|
|
|
|
end)
|
2018-08-10 22:30:55 +02:00
|
|
|
|
2021-01-01 20:04:14 +02:00
|
|
|
Gui.on_custom_close(main_frame_name, function(event)
|
|
|
|
close_main_frame(event.element, event.player)
|
|
|
|
end)
|
2018-09-11 16:55:20 +02:00
|
|
|
|
2018-12-16 03:28:00 +02:00
|
|
|
Gui.allow_player_to_toggle_top_element_visibility(main_button_name)
|
|
|
|
|
2018-09-11 16:55:20 +02:00
|
|
|
local Public = {}
|
|
|
|
|
2018-11-15 21:04:03 +02:00
|
|
|
function Public.show_info(player)
|
2019-01-11 20:25:54 +02:00
|
|
|
toggle({player = player})
|
2018-11-15 21:04:03 +02:00
|
|
|
end
|
|
|
|
|
2018-10-07 16:49:12 +02:00
|
|
|
function Public.get_map_name()
|
2018-09-11 16:55:20 +02:00
|
|
|
return editable_info[map_name_key]
|
|
|
|
end
|
|
|
|
|
|
|
|
function Public.set_map_name(value)
|
|
|
|
editable_info[map_name_key] = value
|
|
|
|
end
|
|
|
|
|
2018-10-07 16:49:12 +02:00
|
|
|
function Public.get_map_description()
|
2018-09-11 16:55:20 +02:00
|
|
|
return editable_info[map_description_key]
|
|
|
|
end
|
|
|
|
|
|
|
|
function Public.set_map_description(value)
|
|
|
|
editable_info[map_description_key] = value
|
|
|
|
end
|
|
|
|
|
2018-10-07 16:49:12 +02:00
|
|
|
function Public.get_map_extra_info()
|
2018-09-11 16:55:20 +02:00
|
|
|
return editable_info[map_extra_info_key]
|
|
|
|
end
|
|
|
|
|
2018-12-22 01:38:47 +02:00
|
|
|
--- Adds to existing map_extra_info. Removes default text if it is the only text in place.
|
|
|
|
function Public.add_map_extra_info(value)
|
2018-12-29 03:19:55 +02:00
|
|
|
create_map_extra_info(value, false)
|
|
|
|
end
|
|
|
|
|
2019-02-04 21:39:36 +02:00
|
|
|
--- Overrides all info added via add_map_extra_info.
|
2018-12-29 03:19:55 +02:00
|
|
|
-- This should only be used in maps, never in features/modules.
|
|
|
|
-- Use case: for maps that know exactly what features they're using and
|
|
|
|
-- want full control over the info presented.
|
|
|
|
function Public.set_map_extra_info(value)
|
|
|
|
create_map_extra_info(value, true)
|
2018-09-11 16:55:20 +02:00
|
|
|
end
|
|
|
|
|
2018-10-07 16:49:12 +02:00
|
|
|
function Public.get_new_info()
|
2018-09-11 16:55:20 +02:00
|
|
|
return editable_info[new_info_key]
|
|
|
|
end
|
|
|
|
|
|
|
|
function Public.set_new_info(value)
|
|
|
|
editable_info[new_info_key] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
return Public
|