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

Fixed rendering background

Minor tweaks to cutscene in diggy
This commit is contained in:
SimonFlapse 2019-06-10 19:10:02 +02:00
parent 71d850d04f
commit 36f51bc2e5
3 changed files with 59 additions and 35 deletions

View File

@ -37,14 +37,14 @@ function Public.draw_text(original_resolution, original_zoom, player_zoom, offse
local tile_scalar = (original_zoom * 32) / (player_zoom * 32)
scale = scale * height_scalar
local size = (0.0065 * player.display_resolution.height * scale) / (player_zoom * 32)
local size = (0.0065 * player.display_resolution.height * scale) / 32 -- First part is pixel height of text, result is size in number of tiles
local offset_x = offset.x * width_scalar * tile_scalar
local offset_y = (offset.y * height_scalar * tile_scalar) - size
local offset_y = (offset.y * height_scalar * tile_scalar) - (size / player_zoom)
if draw_background then
local left_top = {x = -40, y = -(size * 0.75) / tile_scalar}
local right_bottom = {x = 40, y = (size) / tile_scalar}
local left_top = {x = -40, y = -(size) * 1.75 / height_scalar}
local right_bottom = {x = 40, y = (size) * 2 / height_scalar}
local background_params = create_background_params(params)
Public.draw_rectangle(original_resolution, original_zoom, player_zoom, offset, left_top, right_bottom, player, background_params)
end
@ -52,7 +52,7 @@ function Public.draw_text(original_resolution, original_zoom, player_zoom, offse
local target = {x = player.position.x + offset_x, y = player.position.y + offset_y}
local color = params.color
color = color and color or {r = 255, g = 255, b = 255}
color = color and color or {}
local font = params.font
@ -149,7 +149,7 @@ function Public.draw_rectangle(original_resolution, original_zoom, player_zoom,
local target_right = {x = player.position.x + right_bottom_x + offset_x, y = player.position.y + right_bottom_y + offset_y}
local color = params.color
color = color and color or {}
color = color and color or {r = 255, g = 255, b = 255}
local width = params.width
width = width and width or 0

View File

@ -47,23 +47,22 @@ cutscene_case_line2=Welcome to __1__
cutscene_case_line4=This is a custom scenario developed by __1__
cutscene_case_line5=Join us at __1__
cutscene_case_line6=The following introduction will help you get started!
cutscene_case_line7=Use the __1__ command if you wish to skip this introduction
cutscene_case_line8=You can always replay this introduction by using the __1__ command
cutscene_case0_line1=This is the starting area
cutscene_case1_line1=Expanding the mine is dangerous!
cutscene_case1_line3=Walls are used to keep the cave roof from crushing us
cutscene_case2_line1=The market provides extra supplies in exchange of coins
cutscene_case0_line3=Expanding the mine is dangerous!
cutscene_case1_line1=Walls are used to keep the cave roof from crushing us
cutscene_case2_line1=The market provides extra supplies in exchange for coins
cutscene_case2_line3=You unlock new items when you level up
cutscene_case3_line1=Cave ins happens frequently when you don't add supports
cutscene_case3_line3=Different types of brick and concrete can reinforce our support pillars!
cutscene_case4_line1=This world contains brittle rocks
cutscene_case4_line3=Our tools are too powerful to preserve any resources from destroying them
cutscene_case5_line1=Most actions gives experience!
cutscene_case5_line1=Most actions give experience!
cutscene_case5_line3=The floating text indicates the quantity and cause of the experience
cutscene_case6_line1=The native population is lurking in the dark
cutscene_case6_line3=Be wary when digging, always bring along some defences
cutscene_case7_line1=This concludes the introduction
cutscene_case7_line3=Have fun and keep digging!
replay_cutscene=To replay the introduction, use the __1__ command
# locale linked to the quadrants scenario
[quadrants]

View File

@ -14,6 +14,29 @@ local draw_multi_line = Rendering.draw_multi_line_text
local DiggyCutscene = {}
local delayed_draw_text =
Token.register(
function(params)
if params.play_sound > 1 then
play_sound(params.player, 'utility/list_box_click', 1)
end
register_rendering(params.player.index, draw_text(params.original_resolution, params.original_zoom, params.player_zoom, params.offset, params.text, params.scale, params.player, params.params, params.draw_background))
end
)
local function draw_text_auto_replacing(original_resolution, original_zoom, player_zoom, offset, texts, scale, player, params, draw_background, time, between_time)
time = time or 400
time = time / #texts
between_time = between_time or 30
params.time_to_live = time - between_time
if params.background then
params.background.time_to_live = time - between_time
end
for i = 1, #texts do
Task.set_timeout_in_ticks(time * (i - 1), delayed_draw_text, {original_resolution = original_resolution, original_zoom = original_zoom, player_zoom = player_zoom, offset = offset, text = texts[i], scale = scale, player = player, params = params, draw_background = draw_background, play_sound = i})
end
end
local function cutscene_function(player_index, waypoint_index, params)
local cases = {}
local player = game.players[player_index]
@ -25,7 +48,7 @@ local function cutscene_function(player_index, waypoint_index, params)
end
cases[-1] = function()
play_sound(player, 'utility/game_won')
play_sound(player, 'ambient/first-light', 1, 400)
play_sound(player, 'ambient/first-light', 1, 550)
register_rendering(player_index, Rendering.blackout(player, zoom, ttw + 1))
register_rendering(player_index, draw_text({height = 1440, width = 2560}, 1, zoom, {x = 0, y = -16}, 'Diggy', 10, player, {time_to_live = ttw, color = Color.yellow}, false))
register_rendering(
@ -33,10 +56,10 @@ local function cutscene_function(player_index, waypoint_index, params)
draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = -5}, {{'diggy.cutscene_case_line2', 'Diggy'}, '---------------------', {'diggy.cutscene_case_line4', 'Redmew'}, {'diggy.cutscene_case_line5', 'www.redmew.com/discord'}}, 5, player, {time_to_live = ttw}, false)
)
register_rendering(player_index, draw_text({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 10}, {'diggy.cutscene_case_line6'}, 3, player, {time_to_live = ttw}, false))
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 13}, {{'diggy.cutscene_case_line7', '/skip'}, {'diggy.cutscene_case_line8', '/replay'}}, 1.5, player, {time_to_live = ttw}, false))
--register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 13}, {{'diggy.cutscene_case_line7', '/skip'}, {'diggy.cutscene_case_line8', '/replay'}}, 1.5, player, {time_to_live = ttw}, false))
end
cases[0] = function()
register_rendering(player_index, draw_text({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {'diggy.cutscene_case0_line1'}, 2.5, player, {time_to_live = ttw}, true))
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case0_line1'}, {'diggy.cutscene_case0_line3'}}, 2.5, player, {}, true, ttw)
local entity = RS.get_surface().find_entities_filtered {position = {0, 0}, radius = 20, name = 'stone-wall', limit = 1}
if entity[1] then
local position = entity[1].position
@ -44,7 +67,7 @@ local function cutscene_function(player_index, waypoint_index, params)
-- case 1
position = position,
transition_time = 120,
time_to_wait = 300,
time_to_wait = 275,
zoom = 5
}
Debug.print_position(position, 'position of wall ')
@ -52,14 +75,14 @@ local function cutscene_function(player_index, waypoint_index, params)
end
end
cases[1] = function()
play_sound(player, 'utility/build_small', 1, 25)
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case1_line1'}, '', {'diggy.cutscene_case1_line3'}}, 2.5, player, {time_to_live = ttw}, true))
--play_sound(player, 'utility/build_small', 1, 25)
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case1_line1'}}, 2.5, player, {}, true, ttw)
end
cases[2] = function()
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case2_line1'}, '', {'diggy.cutscene_case2_line3'}}, 2.5, player, {time_to_live = ttw}, true))
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case2_line1'}, {'diggy.cutscene_case2_line3'}}, 2.5, player, {}, true, ttw)
end
cases[3] = function()
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case3_line1'}, '', {'diggy.cutscene_case3_line3'}}, 2.5, player, {time_to_live = ttw}, true))
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case3_line1'}, {'diggy.cutscene_case3_line3'}}, 2.5, player, {}, true, ttw)
local radius = 10
local entity
repeat
@ -80,29 +103,29 @@ local function cutscene_function(player_index, waypoint_index, params)
-- case 4
position = position,
transition_time = 120,
time_to_wait = 300,
time_to_wait = 550,
zoom = way_zoom
}
Cutscene.inject_waypoint(player_index, waypoint, 6)
end
cases[4] = function()
play_sound(player, 'utility/axe_mining_ore', 3, 35)
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case4_line1'}, '', {'diggy.cutscene_case4_line3'}}, 2.5, player, {time_to_live = ttw}, true))
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case4_line1'}, {'diggy.cutscene_case4_line3'}}, 2.5, player, {}, true, ttw)
end
cases[5] = function()
play_sound(player, 'utility/research_completed', 1, 5)
local exp = 2500
local text = {'', '[img=item/automation-science-pack] ', {'diggy.float_xp_gained_research', exp}}
player.create_local_flying_text {position = params.position, text = text, color = Color.light_sky_blue, time_to_live = ttw / 3}
draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case5_line1'}, '', {'diggy.cutscene_case5_line3'}}, 2.5, player, {time_to_live = ttw}, true)
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case5_line1'}, {'diggy.cutscene_case5_line3'}}, 2.5, player, {}, true, ttw)
end
cases[6] = function()
play_sound(player, 'utility/axe_fighting', 5, 25, 10)
play_sound(player, 'worm-sends-biters', 1, 70)
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case6_line1'}, '', {'diggy.cutscene_case6_line3'}}, 2.5, player, {time_to_live = ttw}, true))
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case6_line1'}, {'diggy.cutscene_case6_line3'}}, 2.5, player, {}, true, ttw)
end
cases[7] = function()
register_rendering(player_index, draw_multi_line({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case7_line1'}, '', {'diggy.cutscene_case7_line3'}}, 2.5, player, {time_to_live = ttw}, true))
draw_text_auto_replacing({height = 1440, width = 2560}, 1, zoom, {x = 0, y = 18}, {{'diggy.cutscene_case7_line1'}, {'diggy.cutscene_case7_line3'}}, 2.5, player, {}, true, ttw)
--play_sound(player, 'utility/tutorial_notice', 1)
end
local case = cases[waypoint_index]
@ -116,35 +139,35 @@ local waypoints = {
-- case -1
position = {x = 0, y = 0},
transition_time = 60,
time_to_wait = 400,
time_to_wait = 600,
zoom = 0.5
},
{
-- case 0
position = {x = 0, y = 0},
transition_time = 120,
time_to_wait = 300,
time_to_wait = 550,
zoom = 1
},
{
-- case 1
position = {x = 0, y = 0},
transition_time = 120,
time_to_wait = 300,
time_to_wait = 275,
zoom = 1.5
},
{
-- case 2
position = {x = 0.5, y = 3.5},
transition_time = 120,
time_to_wait = 300,
time_to_wait = 550,
zoom = 5
},
{
-- case 3
position = {x = 0, y = 0},
transition_time = 120,
time_to_wait = 300,
time_to_wait = 550,
zoom = 2
},
-- inserting case 4
@ -152,27 +175,29 @@ local waypoints = {
-- case 5
position = {x = 0, y = -2},
transition_time = 120,
time_to_wait = 300,
zoom = 1.5
time_to_wait = 550,
zoom = 1.8
},
{
-- case 6
position = {x = 0, y = 0},
transition_time = 120,
time_to_wait = 300,
time_to_wait = 550,
zoom = 0.3
},
{
-- case 7
position = {x = 0, y = 0},
transition_time = 120,
time_to_wait = 300,
time_to_wait = 430,
zoom = 0.8
}
}
local function terminate_function(player_index)
PC.show_start_up(game.get_player(player_index))
local player = game.get_player(player_index)
PC.show_start_up(player)
player.print({'diggy.replay_cutscene', '/replay'}, Color.yellow)
end
Cutscene.register_cutscene_function('Diggy_Welcome', waypoints, Token.register(cutscene_function), Token.register(terminate_function))