1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Merge pull request #831 from SimonFlapse/Info-fix

Fixing info GUI
This commit is contained in:
Matthew 2019-02-28 12:16:41 -05:00 committed by GitHub
commit ab2b3edb63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 91 additions and 40 deletions

View File

@ -10,7 +10,7 @@ global.config = {
-- The title of the map
map_name_key = 'This Map has no name',
-- The long description of the map, typically 1 paragraph
map_description_key = "This section is supposed to be filled out on a per map basis. If you're seeing this message, ping the admin team to get a description added for this map. A 20 coin bonus is available to the first person to point this out.",
map_description_key = "This section is supposed to be filled out on a per map basis.\nIf you're seeing this message, ping the admin team to get a description\nadded for this map. 20 coins is rewarded to the first person that points this out.",
-- The feature list of the map
map_extra_info_key = 'This map has no extra information',
-- New Scenario Features, appears in the "What's new" tab

View File

@ -17,6 +17,7 @@ local config_prewards = config.player_rewards
local normal_color = Color.white
local focus_color = Color.dark_orange
local unfocus_color = Color.black
local reward_amount = 2
local reward_plural_indicator = reward_amount > 1 and 's' or ''
@ -80,7 +81,8 @@ end
local changelog_callback = Token.register(process_changelog)
local function prepare_title()
local welcome_title = [[
local welcome_title =
[[
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
@ -133,12 +135,12 @@ end
local function centered_label(parent, string)
local flow = parent.add {type = 'flow'}
local flow_style = flow.style
flow_style.horizontal_align = 'center'
flow_style.horizontal_align = 'center'
flow_style.horizontally_stretchable = true
local label = flow.add {type = 'label', caption = string}
local label_style = label.style
label_style.horizontal_align = 'center'
label_style.horizontal_align = 'center'
label_style.single_line = false
return label
@ -147,12 +149,12 @@ end
local function header_label(parent, string)
local flow = parent.add {type = 'flow'}
local flow_style = flow.style
flow_style.horizontal_align = 'center'
flow_style.horizontal_align = 'center'
flow_style.horizontally_stretchable = true
local label = flow.add {type = 'label', caption = string}
local label_style = label.style
label_style.horizontal_align = 'center'
label_style.horizontal_align = 'center'
label_style.single_line = false
label_style.font = 'default-dialog-button'
@ -167,7 +169,9 @@ local pages = {
end,
content = function(parent)
local parent_style = parent.style
parent_style.right_padding = 2
parent_style.right_padding = 0
parent_style.left_padding = 0
parent_style.top_padding = 1
parent =
parent.add {
@ -176,9 +180,9 @@ local pages = {
horizontal_scroll_policy = 'never'
}
parent_style = parent.style
parent_style.vertically_stretchable = true
parent_style.vertically_stretchable = false
header_label(parent, 'Welcome to the Redmew Server!')
header_label(parent, 'Welcome to Redmew!')
centered_label(
parent,
[[
@ -189,14 +193,26 @@ We are a friendly bunch, our objective is to have as much fun as possible and we
)
header_label(parent, 'How To Chat')
centered_label(parent, [[
centered_label(
parent,
[[
To chat with other players, press the "grave" key on your keyboard.
It is below the ESC key on English keyboards and looks like ~ or `
This can be changed in options -> controls -> "toggle lua console".
]])
]]
)
if config_prewards.enabled and config_prewards.info_player_reward then
local string = format('You have been given %s %s%s for looking at the welcome tab.\nChecking each tab will reward you %s more %s%s.\n', reward_amount, reward_token, reward_plural_indicator, reward_amount, reward_token, reward_plural_indicator)
local string =
format(
'You have been given %s %s%s for looking at the welcome tab.\nChecking each tab will reward you %s more %s%s.\n',
reward_amount,
reward_token,
reward_plural_indicator,
reward_amount,
reward_token,
reward_plural_indicator
)
header_label(parent, 'Free Coins')
centered_label(parent, string)
end
@ -205,36 +221,45 @@ This can be changed in options -> controls -> "toggle lua console".
centered_label(parent, [[Check out our discord for new map info and to suggest new maps / ideas.]])
local discord_textbox_flow = parent.add {type = 'flow'}
local discord_textbox_flow_style = discord_textbox_flow.style
discord_textbox_flow_style.horizontal_align = 'center'
discord_textbox_flow_style.horizontal_align = 'center'
discord_textbox_flow_style.horizontally_stretchable = true
discord_textbox_flow.add({type = 'label', caption = 'Discord: '}).style.font = 'default-bold'
local discord_textbox = discord_textbox_flow.add {type = 'text-box', text = 'redmew.com/discord '}
local discord_textbox =
discord_textbox_flow.add {type = 'text-box', text = 'https://www.redmew.com/discord '}
discord_textbox.read_only = true
discord_textbox.style.width = 235
discord_textbox.style.height = 28
centered_label(parent, 'Contribute to our Patreon to receive special perks and help maintain our servers.')
local patreon_flow = parent.add {type = 'flow', direction = 'horizontal'}
local patreon_flow_style = patreon_flow.style
patreon_flow_style.horizontal_align = 'center'
patreon_flow_style.horizontal_align = 'center'
patreon_flow_style.horizontally_stretchable = true
patreon_flow.add({type = 'label', caption = 'Patreon:'}).style.font = 'default-bold'
local patreon_textbox = patreon_flow.add {type = 'text-box', text = 'patreon.com/redmew '}
local patreon_textbox = patreon_flow.add {type = 'text-box', text = 'https://www.patreon.com/redmew '}
patreon_textbox.read_only = true
patreon_textbox.style.width = 235
patreon_textbox.style.height = 28
centered_label(parent, 'Download our maps, start and finish state, from our website.')
local save_textbox_flow = parent.add {type = 'flow'}
local save_textbox_flow_style = save_textbox_flow.style
save_textbox_flow_style.horizontal_align = 'center'
save_textbox_flow_style.horizontal_align = 'center'
save_textbox_flow_style.horizontally_stretchable = true
save_textbox_flow.add({type = 'label', caption = 'Saves: '}).style.font = 'default-bold'
local save_textbox = save_textbox_flow.add {type = 'text-box', text = 'http://www.redmew.com/saves/ '}
save_textbox.read_only = true
save_textbox.style.width = 235
save_textbox.style.height = 28
centered_label(parent, 'View our past maps as a Google Map.')
local maps_textbox_flow = parent.add {type = 'flow'}
local maps_textbox_flow_style = maps_textbox_flow.style
maps_textbox_flow_style.horizontal_align = 'center'
maps_textbox_flow_style.horizontal_align = 'center'
maps_textbox_flow_style.horizontally_stretchable = true
maps_textbox_flow.add({type = 'label', caption = 'Maps: '}).style.font = 'default-bold'
local maps_textbox = maps_textbox_flow.add {type = 'text-box', text = 'https://factoriomaps.com/browse/redmew.html '}
local maps_textbox =
maps_textbox_flow.add {type = 'text-box', text = 'https://factoriomaps.com/browse/redmew.html '}
maps_textbox.read_only = true
maps_textbox.style.width = 315
maps_textbox.style.height = 28
parent.add({type = 'flow'}).style.height = 24
end
@ -245,6 +270,20 @@ This can be changed in options -> controls -> "toggle lua console".
return button
end,
content = function(parent)
local parent_style = parent.style
parent_style.right_padding = 0
parent_style.left_padding = 0
parent_style.top_padding = 1
parent =
parent.add {
type = 'flow',
direction = 'vertical'
}
parent_style = parent.style
parent_style.vertically_stretchable = false
parent_style.width = 600
header_label(parent, 'Rules')
centered_label(
@ -266,14 +305,14 @@ If you suspect someone is griefing, notify the admin team by using /report or by
end,
content = function(parent, player)
local read_only = not player.admin
local text_width = 480
local text_width = 490
local top_flow = parent.add {type = 'flow'}
local top_flow_style = top_flow.style
top_flow_style.horizontal_align = 'center'
top_flow_style.horizontal_align = 'center'
top_flow_style.horizontally_stretchable = true
local top_label = top_flow.add {type = 'label', caption = 'Map Infomation'}
local top_label = top_flow.add {type = 'label', caption = 'Map Information'}
local top_label_style = top_label.style
top_label_style.font = 'default-dialog-button'
@ -289,11 +328,11 @@ If you suspect someone is griefing, notify the admin team by using /report or by
text = editable_info[map_name_key]
}
map_name_textbox.read_only = read_only
map_name_textbox.word_wrap = true
--map_name_textbox.word_wrap = true
local map_name_textbox_style = map_name_textbox.style
map_name_textbox_style.width = text_width
map_name_textbox_style.maximal_height = 27
map_name_textbox_style.maximal_height = 30
Gui.set_data(map_name_textbox, map_name_key)
@ -305,11 +344,13 @@ If you suspect someone is griefing, notify the admin team by using /report or by
text = editable_info[map_description_key]
}
map_description_textbox.read_only = read_only
map_description_textbox.word_wrap = true
--map_description_textbox.word_wrap = true
local map_description_textbox_style = map_description_textbox.style
map_description_textbox_style.width = text_width
map_description_textbox_style.maximal_height = 72
map_description_textbox_style.minimal_height = 80
map_description_textbox_style.vertically_stretchable = true
map_description_textbox_style.maximal_height = 100
Gui.set_data(map_description_textbox, map_description_key)
@ -321,7 +362,7 @@ If you suspect someone is griefing, notify the admin team by using /report or by
text = editable_info[map_extra_info_key]
}
map_extra_info_textbox.read_only = read_only
map_extra_info_textbox.word_wrap = true
--map_extra_info_textbox.word_wrap = true
local map_extra_info_textbox_style = map_extra_info_textbox.style
map_extra_info_textbox_style.width = text_width
@ -337,7 +378,9 @@ If you suspect someone is griefing, notify the admin team by using /report or by
end,
content = function(parent, player)
local parent_style = parent.style
parent_style.right_padding = 2
parent_style.right_padding = 0
parent_style.left_padding = 0
parent_style.top_padding = 1
parent =
parent.add {
@ -517,8 +560,8 @@ Shows number of rockets launched and biters liberated.]]
header_label(parent, 'New Features')
local new_info_flow = parent.add {type = 'flow'}
new_info_flow.style.horizontal_align = 'center'
local new_info_flow = parent.add {name = 'whatsNew_new_info_flow', type = 'flow'}
new_info_flow.style.horizontal_align = 'center'
local new_info_textbox =
new_info_flow.add {
@ -529,8 +572,9 @@ Shows number of rockets launched and biters liberated.]]
new_info_textbox.read_only = read_only
local new_info_textbox_style = new_info_textbox.style
new_info_textbox_style.width = 590
new_info_textbox_style.height = 300
new_info_textbox_style.width = 600
new_info_textbox_style.height = 360
new_info_textbox_style.left_margin = 2
Gui.set_data(new_info_textbox, new_info_key)
end
@ -548,7 +592,7 @@ local function draw_main_frame(center, player)
local top_flow = frame.add {type = 'flow'}
local top_flow_style = top_flow.style
top_flow_style.horizontal_align = 'center'
top_flow_style.horizontal_align = 'center'
top_flow_style.top_padding = 8
top_flow_style.horizontally_stretchable = true
@ -558,6 +602,7 @@ local function draw_main_frame(center, player)
local ele
if char then
ele = title_grid.add {type = 'sprite', sprite = 'virtual-signal/signal-red'}
ele.style.stretch_image_to_widget_size = true
else
ele = title_grid.add {type = 'label', caption = ' '}
end
@ -584,7 +629,7 @@ local function draw_main_frame(center, player)
local tab_flow = frame.add {type = 'flow', direction = 'horizontal'}
local tab_flow_style = tab_flow.style
tab_flow_style.horizontal_align = 'center'
tab_flow_style.horizontal_align = 'center'
tab_flow_style.horizontally_stretchable = true
for index, page in ipairs(pages) do
@ -618,7 +663,7 @@ local function draw_main_frame(center, player)
local bottom_flow = frame.add {type = 'flow'}
local bottom_flow_style = bottom_flow.style
bottom_flow_style.horizontal_align = 'center'
bottom_flow_style.horizontal_align = 'center'
bottom_flow_style.top_padding = 8
bottom_flow_style.horizontally_stretchable = true
@ -739,7 +784,7 @@ Gui.on_click(
local tab_buttons = data.tab_buttons
local old_button = tab_buttons[active_tab]
old_button.style.font_color = normal_color
old_button.style.font_color = unfocus_color
button.style.font_color = focus_color
data.active_tab = index
@ -748,7 +793,13 @@ Gui.on_click(
Gui.clear(content)
pages[index].content(content, player)
local string = format('%s %s%s awarded for reading a tab on the info screen.', reward_amount, reward_token, reward_plural_indicator)
local string =
format(
'%s %s%s awarded for reading a tab on the info screen.',
reward_amount,
reward_token,
reward_plural_indicator
)
if rewarded_players[player.index] then
reward_player(player, index, string)
end

View File

@ -354,7 +354,7 @@ local function draw_main_frame(left, player)
local announcements_textbox = frame.add {type = 'text-box', text = announcements.text}
announcements_textbox.read_only = true
announcements_textbox.word_wrap = true
--announcements_textbox.word_wrap = true
local announcements_textbox_style = announcements_textbox.style
announcements_textbox_style.width = 450
announcements_textbox_style.height = 100
@ -694,7 +694,7 @@ Gui.on_click(
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}
textbox.word_wrap = true
--textbox.word_wrap = true
local textbox_style = textbox.style
textbox_style.width = 450
textbox_style.height = 100