From 43f3cf9d504b708729d87b630a6f0596936b7d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20H=C3=BCbner?= Date: Fri, 21 Sep 2018 04:11:14 +0200 Subject: [PATCH] intro and scene switch test stuff --- scene.gd => common/scene.gd | 0 dialog/first_scene.txt | 1 + dialog/introduction.txt | 3 ++- dialog_layer.gd | 9 ++++++--- game.gd | 14 ++++++++++++-- menus/main_menu.gd | 2 +- menus/main_menu.tscn | 15 +++++++++++++-- scenes/first_scene.tscn | 25 +++++++++++++++++++++++++ scene.tscn => scenes/intro.tscn | 4 ++-- ui/dialog_box.gd | 16 ---------------- ui/dialog_box.tscn | 13 +++++++++++-- 11 files changed, 73 insertions(+), 29 deletions(-) rename scene.gd => common/scene.gd (100%) create mode 100644 dialog/first_scene.txt create mode 100644 scenes/first_scene.tscn rename scene.tscn => scenes/intro.tscn (86%) diff --git a/scene.gd b/common/scene.gd similarity index 100% rename from scene.gd rename to common/scene.gd diff --git a/dialog/first_scene.txt b/dialog/first_scene.txt new file mode 100644 index 0000000..2ab5540 --- /dev/null +++ b/dialog/first_scene.txt @@ -0,0 +1 @@ + ... Looking around, it definitely wasn't time to get up just yet. diff --git a/dialog/introduction.txt b/dialog/introduction.txt index 85ba903..556d718 100644 --- a/dialog/introduction.txt +++ b/dialog/introduction.txt @@ -1,2 +1,3 @@ ... You wake up to the sound of sirens blaring. - +... maybe it's time to go to school? +> SWITCH_SCENE [FIRST_SCENE] diff --git a/dialog_layer.gd b/dialog_layer.gd index e594650..9fc9d02 100644 --- a/dialog_layer.gd +++ b/dialog_layer.gd @@ -14,13 +14,16 @@ func _ready(): # set up params dialog_box.set_dialog_path(dialog_path) - - # init after yes - dialog_box.initialize_dialog() func _on_scene_ready(): + + # init after yes + dialog_box.initialize_dialog() + + # then entero dialog_box.enter_frame() + func _on_dialog_init(d): pass diff --git a/game.gd b/game.gd index 63ef633..6687896 100644 --- a/game.gd +++ b/game.gd @@ -47,15 +47,22 @@ const Scenes = { MAIN_MENU = "res://menus/main_menu.tscn", # GAME - SCENE = "res://scene.tscn" + INTRO = "res://scenes/intro.tscn", + FIRST_SCENE = "res://scenes/first_scene.tscn" } func _register_functions(): - pass + current_registry["SWITCH_SCENE"] = funcref(self, "_switch_scene_fnc") + +func _switch_scene_fnc(args): + if args.size() == 1: + var scene_name = args[0] + SceneSwitcher.goto_scene(Scenes[scene_name]) func _on_game_started_set(v): if v and not game_started: + print("STARTO") _on_game_start() game_started = v @@ -63,6 +70,9 @@ func _on_game_start(): # all game state here current_registry = {} + print("YAH") + # register all de stuff + _register_functions() func _ready(): diff --git a/menus/main_menu.gd b/menus/main_menu.gd index 218365a..5e29716 100644 --- a/menus/main_menu.gd +++ b/menus/main_menu.gd @@ -15,7 +15,7 @@ func _ready(): func _on_start_pressed(): - SceneSwitcher.goto_scene(Game.Scenes.SCENE) + SceneSwitcher.goto_scene(Game.Scenes.INTRO) func _on_load_pressed(): pass diff --git a/menus/main_menu.tscn b/menus/main_menu.tscn index 5853619..0e9e35f 100644 --- a/menus/main_menu.tscn +++ b/menus/main_menu.tscn @@ -1,8 +1,15 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=2] [ext_resource path="res://menus/main_menu.gd" type="Script" id=1] -[node name="main_menu" type="Control" index="0"] +[sub_resource type="StyleBoxEmpty" id=1] + +content_margin_left = -1.0 +content_margin_right = -1.0 +content_margin_top = -1.0 +content_margin_bottom = -1.0 + +[node name="main_menu" type="Control"] anchor_left = 0.0 anchor_top = 0.0 @@ -87,6 +94,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) custom_colors/font_color_pressed = Color( 0, 0, 0, 1 ) @@ -114,6 +122,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) custom_colors/font_color_pressed = Color( 0, 0, 0, 1 ) @@ -141,6 +150,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) custom_colors/font_color_pressed = Color( 0, 0, 0, 1 ) @@ -168,6 +178,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 0, 0, 0, 1 ) custom_colors/font_color_pressed = Color( 0, 0, 0, 1 ) diff --git a/scenes/first_scene.tscn b/scenes/first_scene.tscn new file mode 100644 index 0000000..549d8fd --- /dev/null +++ b/scenes/first_scene.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://common/scene.gd" type="Script" id=1] +[ext_resource path="res://dialog_layer.gd" type="Script" id=2] +[ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3] + +[node name="first_scene" type="Node2D" index="0"] + +script = ExtResource( 1 ) + +[node name="background" type="Sprite" parent="." index="0"] + +[node name="dialog_layer" type="CanvasLayer" parent="." index="1"] + +layer = 1 +offset = Vector2( 0, 0 ) +rotation = 0.0 +scale = Vector2( 1, 1 ) +transform = Transform2D( 1, 0, 0, 1, 0, 0 ) +script = ExtResource( 2 ) +dialog_path = "res://dialog/first_scene.txt" + +[node name="dialog_box" parent="dialog_layer" index="0" instance=ExtResource( 3 )] + + diff --git a/scene.tscn b/scenes/intro.tscn similarity index 86% rename from scene.tscn rename to scenes/intro.tscn index ddb6dd6..e810ee9 100644 --- a/scene.tscn +++ b/scenes/intro.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://scene.gd" type="Script" id=1] +[ext_resource path="res://common/scene.gd" type="Script" id=1] [ext_resource path="res://dialog_layer.gd" type="Script" id=2] [ext_resource path="res://ui/dialog_box.tscn" type="PackedScene" id=3] -[node name="scene" type="Node2D"] +[node name="intro" type="Node2D"] script = ExtResource( 1 ) diff --git a/ui/dialog_box.gd b/ui/dialog_box.gd index 943dc11..70c762b 100644 --- a/ui/dialog_box.gd +++ b/ui/dialog_box.gd @@ -148,21 +148,6 @@ func _register_functions(): # anim shite, also yieldy _register_func(r, "PLAY_ANIM", "_play_anim_fnc") - # PLAY AND WAIT; HOW ABOUT DEM APPLES - _register_func(r, "PLAY_ANIM_WITH_WAIT", "_play_wait_with_anim_fnc") - -func _play_wait_with_anim_fnc(args): - if args.size() == 2: - var anim_name = args[0] - var wait_time = float(args[1]) - - if anim_player: - anim_player.play(anim_name) - - timer.one_shot = true - timer.wait_time = wait_time - timer.start() - return [timer, "timeout"] func _play_anim_fnc(args): if args.size() == 1: @@ -264,7 +249,6 @@ func initialize_dialog(): func _on_dialog_completed(d): emit_signal("on_dialog_completed", self) - exit_frame() func _on_update_dialog(s): _update_dialog(s) diff --git a/ui/dialog_box.tscn b/ui/dialog_box.tscn index 1d47594..fa4b207 100644 --- a/ui/dialog_box.tscn +++ b/ui/dialog_box.tscn @@ -1,7 +1,14 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://ui/dialog_box.gd" type="Script" id=1] +[sub_resource type="StyleBoxEmpty" id=2] + +content_margin_left = -1.0 +content_margin_right = -1.0 +content_margin_top = -1.0 +content_margin_bottom = -1.0 + [sub_resource type="StyleBoxEmpty" id=1] content_margin_left = -1.0 @@ -11,7 +18,6 @@ content_margin_bottom = -1.0 [node name="dialog_box" type="Control" index="0"] -editor/display_folded = true anchor_left = 0.0 anchor_top = 0.0 anchor_right = 1.0 @@ -66,6 +72,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 2 ) custom_colors/font_color_disabled = Color( 0.378906, 0.378906, 0.378906, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 1, 0.647059, 0, 1 ) @@ -95,6 +102,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 2 ) custom_colors/font_color_disabled = Color( 0.378906, 0.378906, 0.378906, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 1, 0.647059, 0, 1 ) @@ -123,6 +131,7 @@ mouse_filter = 0 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 +custom_styles/focus = SubResource( 2 ) custom_colors/font_color_disabled = Color( 0.378906, 0.378906, 0.378906, 1 ) custom_colors/font_color = Color( 1, 1, 1, 1 ) custom_colors/font_color_hover = Color( 1, 0.647059, 0, 1 )