diff --git a/Null/test01/scripts/Room will not have a script configured. b/Null/test01/scripts/Room will not have a script configured. new file mode 100644 index 00000000..ed56af38 --- /dev/null +++ b/Null/test01/scripts/Room will not have a script configured. @@ -0,0 +1,41 @@ +# Room script template + +# ":setup" is used to configure anything you want in place before the +# transition-in event runs (i.e. anything you need to set up before the player +# sees the room). Reset movable objects to their start positions here. + +:setup + + + +# ":ready" runs after any events configured in setup complete. It is used to +# configure everything that happens after the transition-in (if any) completes. +# runs. Story telling events go here (e.g. if you want the character to walk to +# a specific location in the room before giving control to the player.) + +:ready + + + +# Code examples - feel free to delete this section +# +# 1) Run this code when the player enters this room for the first time only. +# This assumes your room is called "room_hallway". Also resets the "window" +# to closed by playing the animation "close_window" using 'set_state'. +# +# > [!room_hallway_visited] +# set_global room_hallway_visited true +# set_state window close_window true +# +# +# 2) Change where the player starts depending on which doorway they entered +# the room from. Assumes your character is called "cleaner" +# +# > [eq ESC_LAST_SCENE room2] +# teleport cleaner r1_r_exit +# # Set cleaner look left +# set_angle cleaner 270 +# +# + + diff --git a/Null/test01/test01.tscn b/Null/test01/test01.tscn new file mode 100644 index 00000000..8f209b2f --- /dev/null +++ b/Null/test01/test01.tscn @@ -0,0 +1,32 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=1] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=2] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_terrain.gd" type="Script" id=3] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_location.gd" type="Script" id=4] + +[sub_resource type="NavigationPolygon" id=1] + +[node name="test01" type="Node2D"] +script = ExtResource( 2 ) +global_id = "test01" + +[node name="Background" type="TextureRect" parent="."] +margin_right = 1280.0 +margin_bottom = 900.0 +mouse_filter = 2 +script = ExtResource( 1 ) + +[node name="WalkableArea" type="Navigation2D" parent="."] +script = ExtResource( 3 ) + +[node name="NavigationPolygonInstance" type="NavigationPolygonInstance" parent="WalkableArea"] +navpoly = SubResource( 1 ) + +[node name="RoomObjects" type="Node2D" parent="."] + +[node name="StartPos" type="Position2D" parent="."] +position = Vector2( 640, 450 ) +script = ExtResource( 4 ) +global_id = "test01_start_pos" +is_start_location = true diff --git a/game/rooms/intro/intro_room.tscn b/game/rooms/intro/intro_room.tscn index f219e154..08e1d0e7 100644 --- a/game/rooms/intro/intro_room.tscn +++ b/game/rooms/intro/intro_room.tscn @@ -1,13 +1,16 @@ [gd_scene load_steps=17 format=2] [ext_resource path="res://game/rooms/intro/escoria-logo-comet-anim.png" type="Texture" id=1] -[ext_resource path="res://game/rooms/intro/intro_background_space.png" type="Texture" id=2] [ext_resource path="res://game/rooms/intro/escoria-logo-comet.png" type="Texture" id=3] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=4] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=5] [ext_resource path="res://game/rooms/intro/escoria_background.png" type="Texture" id=6] [ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7] +[sub_resource type="StreamTexture" id=10] +flags = 4 +load_path = "res://.import/intro_background_space.png-03815c403298b393ba1bea2b29eafeac.stex" + [sub_resource type="AtlasTexture" id=1] flags = 4 atlas = ExtResource( 1 ) @@ -273,7 +276,7 @@ script = ExtResource( 4 ) [node name="initial_background" type="Sprite" parent="."] position = Vector2( 640, 450 ) -texture = ExtResource( 2 ) +texture = SubResource( 10 ) [node name="animated_asteroid" type="AnimatedSprite" parent="."] visible = false @@ -295,6 +298,7 @@ texture = ExtResource( 3 ) pause_mode = 1 script = ExtResource( 7 ) global_id = "intro_animation_player" +combine_when_selected_action_is_in = [ ] dialog_color = Color( 1, 1, 1, 1 ) animations = null diff --git a/game/rooms/room14/room14.tscn b/game/rooms/room14/room14.tscn index 58871c23..7f2fc199 100644 --- a/game/rooms/room14/room14.tscn +++ b/game/rooms/room14/room14.tscn @@ -179,13 +179,11 @@ __meta__ = { [node name="worker" parent="." instance=ExtResource( 10 )] position = Vector2( 204.268, 376.233 ) esc_script = "res://game/rooms/room14/esc/worker.esc" -combine_when_selected_action_is_in = [ ] [node name="worker2" parent="." instance=ExtResource( 10 )] position = Vector2( 726, 390 ) global_id = "worker2" esc_script = "res://game/rooms/room14/esc/worker2.esc" -combine_when_selected_action_is_in = [ ] [node name="worker_target" type="Position2D" parent="."] position = Vector2( 917.51, 475.808 ) diff --git a/game/rooms/room17/background.tscn b/game/rooms/room17/background.tscn index fa42fc10..b84521fe 100644 --- a/game/rooms/room17/background.tscn +++ b/game/rooms/room17/background.tscn @@ -7,9 +7,6 @@ margin_right = 1289.0 margin_bottom = 555.0 mouse_filter = 2 script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="l_platform" type="Line2D" parent="."] position = Vector2( 2, -266 ) diff --git a/game/rooms/room17/room17.tscn b/game/rooms/room17/room17.tscn index 69f46cf3..dcf264da 100644 --- a/game/rooms/room17/room17.tscn +++ b/game/rooms/room17/room17.tscn @@ -54,6 +54,7 @@ esc_script = "res://game/rooms/room17/esc/left_exit.esc" is_exit = true tooltip_name = "Left exit" default_action = "walk" +combine_when_selected_action_is_in = [ ] dialog_color = Color( 1, 1, 1, 1 ) animations = null @@ -68,6 +69,7 @@ global_id = "r12_l_exit" [node name="r_door" parent="Hotspots" instance=ExtResource( 8 )] global_id = "" esc_script = "" +combine_when_selected_action_is_in = [ ] [node name="ESCLocation" type="Position2D" parent="Hotspots/r_door"] position = Vector2( 1231.78, 360.624 ) diff --git a/game/rooms/sarrera/Gymkhana.png b/game/rooms/sarrera/Gymkhana.png new file mode 100644 index 00000000..7b7dea11 Binary files /dev/null and b/game/rooms/sarrera/Gymkhana.png differ diff --git a/game/rooms/sarrera/esc/intro.esc b/game/rooms/sarrera/esc/intro.esc new file mode 100644 index 00000000..5ebf3c68 --- /dev/null +++ b/game/rooms/sarrera/esc/intro.esc @@ -0,0 +1,13 @@ +:setup +anim_block intro_animation_player RESET + +:ready | NO_UI +# Until we have a proper way to skip animations/cutscenes, we want to prevent +# something silly like being able to pause during the intro. +accept_input NONE + +anim_block intro_animation_player intro + +accept_input ALL + +show_menu main diff --git a/game/rooms/sarrera/escoria-logo-comet-anim.png b/game/rooms/sarrera/escoria-logo-comet-anim.png new file mode 100644 index 00000000..b9b1b674 Binary files /dev/null and b/game/rooms/sarrera/escoria-logo-comet-anim.png differ diff --git a/game/rooms/sarrera/escoria-logo-comet.png b/game/rooms/sarrera/escoria-logo-comet.png new file mode 100644 index 00000000..296c1ae7 Binary files /dev/null and b/game/rooms/sarrera/escoria-logo-comet.png differ diff --git a/game/rooms/sarrera/escoria_background.png b/game/rooms/sarrera/escoria_background.png new file mode 100644 index 00000000..8168be03 Binary files /dev/null and b/game/rooms/sarrera/escoria_background.png differ diff --git a/game/rooms/sarrera/escoria_background_1080p.png b/game/rooms/sarrera/escoria_background_1080p.png new file mode 100644 index 00000000..7d1aff79 Binary files /dev/null and b/game/rooms/sarrera/escoria_background_1080p.png differ diff --git a/game/rooms/sarrera/intro_background_space.png b/game/rooms/sarrera/intro_background_space.png new file mode 100644 index 00000000..8c254e00 Binary files /dev/null and b/game/rooms/sarrera/intro_background_space.png differ diff --git a/game/rooms/sarrera/intro_background_space_1080p.png b/game/rooms/sarrera/intro_background_space_1080p.png new file mode 100644 index 00000000..5e1dacb2 Binary files /dev/null and b/game/rooms/sarrera/intro_background_space_1080p.png differ diff --git a/game/rooms/sarrera/intro_room.tscn b/game/rooms/sarrera/intro_room.tscn new file mode 100644 index 00000000..195c2fc0 --- /dev/null +++ b/game/rooms/sarrera/intro_room.tscn @@ -0,0 +1,281 @@ +[gd_scene load_steps=17 format=2] + +[ext_resource path="res://game/rooms/intro/escoria-logo-comet-anim.png" type="Texture" id=1] +[ext_resource path="res://game/rooms/sarrera/intro_background_space.png" type="Texture" id=2] +[ext_resource path="res://game/rooms/intro/escoria-logo-comet.png" type="Texture" id=3] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_background.gd" type="Script" id=4] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_room.gd" type="Script" id=5] +[ext_resource path="res://game/rooms/intro/escoria_background.png" type="Texture" id=6] +[ext_resource path="res://addons/escoria-core/game/core-scripts/esc_item.gd" type="Script" id=7] + +[sub_resource type="AtlasTexture" id=1] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 340, 400 ) + +[sub_resource type="AtlasTexture" id=2] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 340, 0, 340, 400 ) + +[sub_resource type="AtlasTexture" id=3] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 680, 0, 340, 400 ) + +[sub_resource type="AtlasTexture" id=4] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 1020, 0, 340, 400 ) + +[sub_resource type="AtlasTexture" id=5] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 1360, 0, 340, 400 ) + +[sub_resource type="AtlasTexture" id=6] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 1700, 0, 340, 400 ) + +[sub_resource type="SpriteFrames" id=7] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ], +"loop": true, +"name": "default", +"speed": 10.0 +} ] + +[sub_resource type="Animation" id=8] +length = 0.1 +tracks/0/type = "value" +tracks/0/path = NodePath("asteroid:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ false ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("animated_asteroid:visible") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ false ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("ESCBackground:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("asteroid:position") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 620, 450 ) ] +} +tracks/4/type = "value" +tracks/4/path = NodePath("Polygon2D:visible") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ true ] +} + +[sub_resource type="Animation" id=9] +length = 6.0 +tracks/0/type = "value" +tracks/0/path = NodePath("animated_asteroid:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 350, -20 ), Vector2( 630, 471 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("animated_asteroid:playing") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} +tracks/2/type = "value" +tracks/2/path = NodePath("animated_asteroid:scale") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/keys = { +"times": PoolRealArray( 0, 3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector2( 0.1, 0.1 ), Vector2( 1, 1 ) ] +} +tracks/3/type = "value" +tracks/3/path = NodePath("animated_asteroid:visible") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/keys = { +"times": PoolRealArray( 0, 3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ true, false ] +} +tracks/4/type = "value" +tracks/4/path = NodePath("asteroid:visible") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/keys = { +"times": PoolRealArray( 0, 3 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 1, +"values": [ false, true ] +} +tracks/5/type = "value" +tracks/5/path = NodePath("asteroid:modulate") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/keys = { +"times": PoolRealArray( 0, 3.5, 4.5 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] +} +tracks/6/type = "value" +tracks/6/path = NodePath("Polygon2D:color") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 1 ) ] +} +tracks/7/type = "value" +tracks/7/path = NodePath("Polygon2D:modulate") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/keys = { +"times": PoolRealArray( 0, 3, 3.5, 5 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 0, +"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ] +} +tracks/8/type = "value" +tracks/8/path = NodePath("asteroid:position") +tracks/8/interp = 1 +tracks/8/loop_wrap = true +tracks/8/imported = false +tracks/8/enabled = true +tracks/8/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector2( 620, 450 ) ] +} +tracks/9/type = "value" +tracks/9/path = NodePath("Polygon2D:visible") +tracks/9/interp = 1 +tracks/9/loop_wrap = true +tracks/9/imported = false +tracks/9/enabled = true +tracks/9/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ true ] +} + +[node name="ESCRoom" type="Node2D"] +script = ExtResource( 5 ) +global_id = "intro_cutscene" +esc_script = "res://game/rooms/intro/esc/intro.esc" +camera_limits = [ Rect2( 0, 0, 1920, 1080 ) ] + +[node name="ESCBackground" type="TextureRect" parent="."] +margin_right = 1279.0 +margin_bottom = 900.0 +mouse_filter = 2 +texture = ExtResource( 6 ) +expand = true +stretch_mode = 1 +script = ExtResource( 4 ) + +[node name="IntroBackgroundSpace" type="Sprite" parent="."] +position = Vector2( 641, 451 ) +texture = ExtResource( 2 ) + +[node name="animated_asteroid" type="AnimatedSprite" parent="."] +visible = false +position = Vector2( 630, 471 ) +frames = SubResource( 7 ) + +[node name="Polygon2D" type="Polygon2D" parent="."] +modulate = Color( 1, 1, 1, 0 ) +position = Vector2( 0, 2 ) +polygon = PoolVector2Array( 0, 0, 1280, 0, 1280, 900, 0, 900 ) + +[node name="asteroid" type="Sprite" parent="."] +visible = false +modulate = Color( 1, 1, 1, 0 ) +position = Vector2( 620, 450 ) +texture = ExtResource( 3 ) + +[node name="ESCItem" type="Area2D" parent="."] +pause_mode = 1 +script = ExtResource( 7 ) +global_id = "intro_animation_player" +combine_when_selected_action_is_in = [ ] +dialog_color = Color( 1, 1, 1, 1 ) +animations = null + +[node name="AnimationPlayer" type="AnimationPlayer" parent="ESCItem"] +root_node = NodePath("../..") +anims/RESET = SubResource( 8 ) +anims/intro = SubResource( 9 ) diff --git a/game/start_game.esc b/game/start_game.esc index a71b3053..e1b5bd43 100644 --- a/game/start_game.esc +++ b/game/start_game.esc @@ -1,6 +1,6 @@ :init # Play Escoria logo cutscene -change_scene res://game/rooms/intro/intro_room.tscn false +change_scene res://game/rooms/sarrera/intro_room.tscn false # When control is passed back after the logo, start the music play_snd res://game/sfx/Game-Menu_Looping.mp3 _music @@ -8,44 +8,3 @@ play_snd res://game/sfx/Game-Menu_Looping.mp3 _music :newgame # 1/ Simple scene change_scene res://game/rooms/room01/room01.tscn - -# 2/ Button bridge -#change_scene res://game/rooms/room02/room02.tscn - -# 3/ Broken button -#change_scene res://game/rooms/room03/room03.tscn - -# 4/ wide room -#change_scene res://game/rooms/room04/room04.tscn - -# 5/ items rooms -#change_scene res://game/rooms/room05/room05.tscn - -# 6/ character room -#change_scene res://game/rooms/room06/room06.tscn - -# 7/ long room with camera shift to object 2 if look on object 1 -# and stairs with camera shift too -#change_scene res://game/rooms/room07/room07.tscn - -# 8/ puzzle in superposed scene -#change_scene res://game/rooms/room08/room08.tscn - -# 9/ Indy4 3 closets -#change_scene res://game/rooms/room09/room09.tscn - -# 10/ -#change_scene res://game/rooms/room10/room10.tscn - -# 11/ Event flags tests -#change_scene res://game/rooms/room11/room11.tscn - -# 12/ Event flags tests 2 -#change_scene res://game/rooms/room12/room12.tscn - -# 13/ -#change_scene res://game/rooms/room13/room13.tscn - -# 14/ -#change_scene res://game/rooms/room14/room14.tscn - diff --git a/game/translations/game.de.translation b/game/translations/game.de.translation index 727a8267..2ef6c016 100644 Binary files a/game/translations/game.de.translation and b/game/translations/game.de.translation differ diff --git a/game/translations/game.en.translation b/game/translations/game.en.translation index 9b738f4d..d96a8c63 100644 Binary files a/game/translations/game.en.translation and b/game/translations/game.en.translation differ diff --git a/game/translations/game.fr.translation b/game/translations/game.fr.translation index 399a6ad6..6bfdea05 100644 Binary files a/game/translations/game.fr.translation and b/game/translations/game.fr.translation differ diff --git a/game/translations/main_menu.de.translation b/game/translations/main_menu.de.translation index 7e71580a..a812a3d4 100644 Binary files a/game/translations/main_menu.de.translation and b/game/translations/main_menu.de.translation differ diff --git a/game/translations/main_menu.en.translation b/game/translations/main_menu.en.translation index 0a45fd1b..b1e8b8c0 100644 Binary files a/game/translations/main_menu.en.translation and b/game/translations/main_menu.en.translation differ diff --git a/game/translations/main_menu.fr.translation b/game/translations/main_menu.fr.translation index 9985abc1..0da3f996 100644 Binary files a/game/translations/main_menu.fr.translation and b/game/translations/main_menu.fr.translation differ diff --git a/game/ui/inventory/esc_inventory_button.gd b/game/ui/inventory/esc_inventory_button.gd new file mode 100644 index 00000000..0b93535a --- /dev/null +++ b/game/ui/inventory/esc_inventory_button.gd @@ -0,0 +1,107 @@ +# The inventory representation of an ESC item if pickable (only used by +# the inventory components) +extends TextureButton +class_name ESCInventoryButton + + +# Signal emitted when the item was left clicked +# +# #### Parameters +# +# - item_id: Global ID of the clicked item +signal mouse_left_inventory_item(item_id) + +# Signal emitted when the item was right clicked +# +# #### Parameters +# +# - item_id: Global ID of the clicked item +signal mouse_right_inventory_item(item_id) + +# Signal emitted when the item was double clicked +# +# #### Parameters +# +# - item_id: Global ID of the clicked item +signal mouse_double_left_inventory_item(item_id) + +# Signal emitted when the item was focused +# +# #### Parameters +# +# - item_id: Global ID of the clicked item +signal inventory_item_focused(item_id) + +# Signal emitted when the item is not focused anymore +signal inventory_item_unfocused() + + +# Global ID of the ESCItem that uses this ESCInventoryItem +var global_id: String = "" + + +func _init(p_item: ESCInventoryItem) -> void: + global_id = p_item.global_id + texture_normal = p_item.texture + expand = true + stretch_mode = TextureButton.STRETCH_KEEP_ASPECT + + +func _process(_delta: float) -> void: + rect_size = ProjectSettings.get_setting("escoria/ui/inventory_item_size") + rect_min_size = ProjectSettings.get_setting( + "escoria/ui/inventory_item_size" + ) + +# Connect input handlers +func _ready(): + connect("gui_input", self, "_on_inventory_item_gui_input") + connect("mouse_entered", self, "_on_inventory_item_mouse_enter") + connect("mouse_exited", self, "_on_inventory_item_mouse_exit") + + +# Handle the gui input and emit the respective signals +# +# #### Parameters +# +# - event: The event received +func _on_inventory_item_gui_input(event: InputEvent): + if InputMap.has_action("switch_action_verb") \ + and event.is_action_pressed("switch_action_verb"): + if event.button_index == BUTTON_WHEEL_UP: + escoria.inputs_manager._on_mousewheel_action(-1) + elif event.button_index == BUTTON_WHEEL_DOWN: + escoria.inputs_manager._on_mousewheel_action(1) + if event is InputEventMouseButton: +# var p = get_global_mouse_position() + if event.doubleclick: + if event.button_index == BUTTON_LEFT: + emit_signal( + "mouse_double_left_inventory_item", + global_id, + event + ) + else: + if event.is_pressed(): + if event.button_index == BUTTON_LEFT: + emit_signal( + "mouse_left_inventory_item", + global_id, + event + ) + if event.button_index == BUTTON_RIGHT: + emit_signal( + "mouse_right_inventory_item", + global_id, + event + ) + + +# Handle mouse entering the item and send the respecitve signal +func _on_inventory_item_mouse_enter(): + emit_signal("inventory_item_focused", global_id) + + +# Handle mouse leaving the item and send the respecitve signal +func _on_inventory_item_mouse_exit(): + emit_signal("inventory_item_unfocused") diff --git a/game/ui/menus/load_save/load/load_game.gd b/game/ui/menus/load_save/load/load_game.gd new file mode 100644 index 00000000..e5e9e0cb --- /dev/null +++ b/game/ui/menus/load_save/load/load_game.gd @@ -0,0 +1,46 @@ +# A container for loading from a save slot +extends Control + + +# Emitted when the back button is pressed +signal back_button_pressed + + +# The scene to display a slot +export(PackedScene) var slot_ui_scene + + +# Load the savegames when loaded +func _ready(): + refresh_savegames() + + +# A slot was pressed. Load the game +# +# #### Parameters +# - slot_id: The slot that was pressed +func _on_slot_pressed(slot_id: int) -> void: + escoria.save_manager.load_game(slot_id) + + +# The back button was pressed +func _on_back_pressed(): + emit_signal("back_button_pressed") + + +# Create the slots from the list of savegames +func refresh_savegames(): + for slot in $VBoxContainer/ScrollContainer/slots.get_children(): + $VBoxContainer/ScrollContainer/slots.remove_child(slot) + + var saves_list = escoria.save_manager.get_saves_list() + if not saves_list.empty(): + for save_key in saves_list.keys(): + var new_slot = slot_ui_scene.instance() + $VBoxContainer/ScrollContainer/slots.add_child( + new_slot + ) + # Move newest save to the top of the list + $VBoxContainer/ScrollContainer/slots.move_child(new_slot, 0) + new_slot.set_slot_name_date(saves_list[save_key]["name"], saves_list[save_key]["date"]) + new_slot.connect("pressed", self, "_on_slot_pressed", [save_key]) diff --git a/game/ui/menus/load_save/load/load_game.tscn b/game/ui/menus/load_save/load/load_game.tscn new file mode 100644 index 00000000..9da16b5f --- /dev/null +++ b/game/ui/menus/load_save/load/load_game.tscn @@ -0,0 +1,60 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.tscn" type="PackedScene" id=2] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.gd" type="Script" id=3] + +[node name="load_game" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} +slot_ui_scene = ExtResource( 2 ) + +[node name="Panel" type="Panel" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_editor_description_": "" +} + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_left = 0.3 +anchor_top = 0.3 +anchor_right = 0.7 +anchor_bottom = 0.7 +margin_left = -55.5 +margin_right = 55.5 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"] +margin_right = 623.0 +margin_bottom = 336.0 +size_flags_vertical = 3 +scroll_horizontal_enabled = false +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="slots" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"] +margin_right = 623.0 +margin_bottom = 336.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="back" type="Button" parent="VBoxContainer"] +margin_top = 340.0 +margin_right = 623.0 +margin_bottom = 360.0 +text = "OPTIONS_BACK" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="pressed" from="VBoxContainer/back" to="." method="_on_back_pressed"] diff --git a/game/ui/menus/load_save/load_save_slot/load_save_slot.gd b/game/ui/menus/load_save/load_save_slot/load_save_slot.gd new file mode 100644 index 00000000..9de5d905 --- /dev/null +++ b/game/ui/menus/load_save/load_save_slot/load_save_slot.gd @@ -0,0 +1,7 @@ +extends Button + + +func set_slot_name_date(p_name: String, p_date: String): + $VBoxContainer/slot_name.text = p_name + $VBoxContainer/date.text = p_date + diff --git a/game/ui/menus/load_save/load_save_slot/load_save_slot.tscn b/game/ui/menus/load_save/load_save_slot/load_save_slot.tscn new file mode 100644 index 00000000..1863dee8 --- /dev/null +++ b/game/ui/menus/load_save/load_save_slot/load_save_slot.tscn @@ -0,0 +1,35 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.gd" type="Script" id=2] + +[node name="slot" type="Button"] +margin_right = 665.0 +margin_bottom = 86.0 +rect_min_size = Vector2( 0, 100 ) +size_flags_horizontal = 3 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="slot_name" type="Label" parent="VBoxContainer"] +margin_top = 34.0 +margin_right = 665.0 +margin_bottom = 48.0 +text = "slot_name" +align = 1 + +[node name="date" type="Label" parent="VBoxContainer"] +margin_top = 52.0 +margin_right = 665.0 +margin_bottom = 66.0 +text = "date" +align = 1 diff --git a/game/ui/menus/load_save/save/overwrite_confirm_popup.gd b/game/ui/menus/load_save/save/overwrite_confirm_popup.gd new file mode 100644 index 00000000..ce7b090f --- /dev/null +++ b/game/ui/menus/load_save/save/overwrite_confirm_popup.gd @@ -0,0 +1,12 @@ +extends PopupDialog + +signal confirm_yes + +func _on_no_pressed(): + hide() + + +func _on_yes_pressed(): + emit_signal("confirm_yes") + hide() + diff --git a/game/ui/menus/load_save/save/overwrite_confirm_popup.tscn b/game/ui/menus/load_save/save/overwrite_confirm_popup.tscn new file mode 100644 index 00000000..d244c463 --- /dev/null +++ b/game/ui/menus/load_save/save/overwrite_confirm_popup.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/overwrite_confirm_popup.gd" type="Script" id=2] + +[node name="overwrite_confirm_popup" type="PopupDialog"] +visible = true +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MarginContainer" type="MarginContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +custom_constants/margin_right = 30 +custom_constants/margin_top = 30 +custom_constants/margin_left = 30 +custom_constants/margin_bottom = 30 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +margin_left = 30.0 +margin_top = 423.0 +margin_right = 1250.0 +margin_bottom = 477.0 +size_flags_vertical = 4 +custom_constants/separation = 20 + +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"] +margin_right = 1220.0 +margin_bottom = 14.0 +text = "CONFIRM_OVERWRITE" + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +margin_top = 34.0 +margin_right = 1220.0 +margin_bottom = 54.0 +custom_constants/separation = 10 +alignment = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="yes" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +margin_left = 1144.0 +margin_right = 1177.0 +margin_bottom = 20.0 +text = "YES" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="no" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +margin_left = 1187.0 +margin_right = 1220.0 +margin_bottom = 20.0 +text = "NO" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/yes" to="." method="_on_yes_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/no" to="." method="_on_no_pressed"] diff --git a/game/ui/menus/load_save/save/save_game.gd b/game/ui/menus/load_save/save/save_game.gd new file mode 100644 index 00000000..aee7e5ab --- /dev/null +++ b/game/ui/menus/load_save/save/save_game.gd @@ -0,0 +1,75 @@ +# A container for saving to a save slot +extends Control + +# Emitted when the back button is pressed +signal back_button_pressed + + +# The scene to display a slot +export(PackedScene) var slot_ui_scene + + +# The slot that was pressed +var _slot_pressed = null + + +# Load the savegames when loaded +func _ready(): + refresh_savegames() + + +# A slot was pressed, save the game +func _on_slot_pressed(p_slot_n: int): + _slot_pressed = p_slot_n + if escoria.save_manager.save_game_exists(p_slot_n): + $overwrite_confirm_popup.popup_centered_ratio(.3) + else: + $save_name_popup.popup_centered_ratio(.3) + + +# Create the slots from the list of savegames +func refresh_savegames(): + var _slots = $VBoxContainer/ScrollContainer/slots + for slot in _slots.get_children(): + _slots.remove_child(slot) + + var saves_list = escoria.save_manager.get_saves_list() + if not saves_list.empty(): + for save_key in saves_list.keys(): + var new_slot = slot_ui_scene.instance() + _slots.add_child(new_slot) + new_slot.set_slot_name_date(saves_list[save_key]["name"], saves_list[save_key]["date"]) + new_slot.connect("pressed", self, "_on_slot_pressed", [save_key]) + + var datetime = OS.get_datetime() + var datetime_string = "%02d/%02d/%02d %02d:%02d" % [ + datetime["day"], + datetime["month"], + datetime["year"], + datetime["hour"], + datetime["minute"], + ] + var new_slot = slot_ui_scene.instance() + _slots.add_child(new_slot) + new_slot.set_slot_name_date(tr("New save"), datetime_string) + new_slot.connect("pressed", self, "_on_slot_pressed", [saves_list.size()+1]) + + +# The back button was pressed +func _on_back_pressed(): + emit_signal("back_button_pressed") + + +# The name for the save game was given, save the game. +# +# #### Parameters +# - p_savename: The name of the savegame entered +func _on_save_name_popup_savegame_name_ok(p_savename: String): + escoria.save_manager.save_game(_slot_pressed, p_savename) + refresh_savegames() + _slot_pressed = null + + +# Overwriting the savegame was confirmed, show the save name popup +func _on_overwrite_confirm_popup_confirm_yes(): + $save_name_popup.popup_centered_ratio(.3) diff --git a/game/ui/menus/load_save/save/save_game.tscn b/game/ui/menus/load_save/save/save_game.tscn new file mode 100644 index 00000000..44cd0803 --- /dev/null +++ b/game/ui/menus/load_save/save/save_game.tscn @@ -0,0 +1,72 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load_save_slot/load_save_slot.tscn" type="PackedScene" id=1] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_game.gd" type="Script" id=2] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_name_popup.tscn" type="PackedScene" id=4] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/overwrite_confirm_popup.tscn" type="PackedScene" id=5] + +[node name="save_game" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} +slot_ui_scene = ExtResource( 1 ) + +[node name="Panel" type="Panel" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = -1.0 +margin_bottom = -1.0 +__meta__ = { +"_editor_description_": "" +} + +[node name="save_name_popup" parent="." instance=ExtResource( 4 )] +visible = false + +[node name="overwrite_confirm_popup" parent="." instance=ExtResource( 5 )] +visible = false + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_left = 0.3 +anchor_top = 0.3 +anchor_right = 0.7 +anchor_bottom = 0.7 +margin_left = -55.5 +margin_right = 55.5 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"] +margin_right = 623.0 +margin_bottom = 336.0 +size_flags_vertical = 3 +scroll_horizontal_enabled = false +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="slots" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"] +margin_right = 623.0 +margin_bottom = 336.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="back" type="Button" parent="VBoxContainer"] +margin_top = 340.0 +margin_right = 623.0 +margin_bottom = 360.0 +text = "OPTIONS_BACK" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="savegame_name_ok" from="save_name_popup" to="." method="_on_save_name_popup_savegame_name_ok"] +[connection signal="confirm_yes" from="overwrite_confirm_popup" to="." method="_on_overwrite_confirm_popup_confirm_yes"] +[connection signal="pressed" from="VBoxContainer/back" to="." method="_on_back_pressed"] diff --git a/game/ui/menus/load_save/save/save_name_popup.gd b/game/ui/menus/load_save/save/save_name_popup.gd new file mode 100644 index 00000000..eed9ec37 --- /dev/null +++ b/game/ui/menus/load_save/save/save_name_popup.gd @@ -0,0 +1,14 @@ +extends PopupDialog + +signal savegame_name_ok(savegame_name) +signal savegame_cancel + +func _on_cancel_pressed(): + emit_signal("savegame_cancel") + hide() + +func _on_ok_pressed(): + if not $MarginContainer/VBoxContainer/LineEdit.text.empty(): + emit_signal("savegame_name_ok", $MarginContainer/VBoxContainer/LineEdit.text) + $MarginContainer/VBoxContainer/LineEdit.clear() + hide() diff --git a/game/ui/menus/load_save/save/save_name_popup.tscn b/game/ui/menus/load_save/save/save_name_popup.tscn new file mode 100644 index 00000000..e18cf00b --- /dev/null +++ b/game/ui/menus/load_save/save/save_name_popup.tscn @@ -0,0 +1,72 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_name_popup.gd" type="Script" id=2] + +[node name="save_name_popup" type="PopupDialog"] +visible = true +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MarginContainer" type="MarginContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +custom_constants/margin_right = 30 +custom_constants/margin_top = 30 +custom_constants/margin_left = 30 +custom_constants/margin_bottom = 30 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +margin_left = 30.0 +margin_top = 401.0 +margin_right = 1250.0 +margin_bottom = 499.0 +size_flags_vertical = 4 +custom_constants/separation = 20 + +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer"] +margin_right = 1220.0 +margin_bottom = 14.0 +text = "ENTER_SAVE_NAME" + +[node name="LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"] +margin_top = 34.0 +margin_right = 1220.0 +margin_bottom = 58.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +margin_top = 78.0 +margin_right = 1220.0 +margin_bottom = 98.0 +custom_constants/separation = 10 +alignment = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="cancel" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +margin_left = 1118.0 +margin_right = 1179.0 +margin_bottom = 20.0 +text = "CANCEL" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ok" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"] +margin_left = 1189.0 +margin_right = 1220.0 +margin_bottom = 20.0 +text = "OK" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/cancel" to="." method="_on_cancel_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/ok" to="." method="_on_ok_pressed"] diff --git a/game/ui/menus/main_menu/main_menu.gd b/game/ui/menus/main_menu/main_menu.gd new file mode 100644 index 00000000..dac988b2 --- /dev/null +++ b/game/ui/menus/main_menu/main_menu.gd @@ -0,0 +1,42 @@ +# A simple main menu +extends Control + + +# Start the game +func _on_new_game_pressed(): + escoria.new_game() + + +# Show the load slots +func _on_load_game_pressed(): + $main.hide() + $load_game.refresh_savegames() + $load_game.show() + + +# Show the options panel +func _on_options_pressed(): + $main.hide() + $options.show() + + +# Quit the game +func _on_quit_pressed(): + escoria.quit() + + +# Hide the options panel again +func _on_options_back_button_pressed(): + reset() + + +# Hide the load panel +func _on_load_game_back_button_pressed(): + reset() + + +# Resets the UI to initial state +func reset(): + $load_game.hide() + $options.hide() + $main.show() diff --git a/game/ui/menus/main_menu/main_menu.tscn b/game/ui/menus/main_menu/main_menu.tscn new file mode 100644 index 00000000..f4a807b3 --- /dev/null +++ b/game/ui/menus/main_menu/main_menu.tscn @@ -0,0 +1,104 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/main_menu/main_menu.gd" type="Script" id=1] +[ext_resource path="res://gymkhana-logo.png" type="Texture" id=2] +[ext_resource path="res://addons/escoria-core/ui_library/menus/options/options.tscn" type="PackedScene" id=4] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.tscn" type="PackedScene" id=5] + +[sub_resource type="ImageTexture" id=1] + +[node name="main_menu" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="load_game" parent="." instance=ExtResource( 5 )] +visible = false + +[node name="options" parent="." instance=ExtResource( 4 )] +visible = false + +[node name="main" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Panel" type="Panel" parent="main"] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_editor_description_": "" +} + +[node name="main" type="VBoxContainer" parent="main"] +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -313.0 +margin_top = -2.0 +margin_right = 303.0 +margin_bottom = -2.0 +custom_constants/separation = 100 +alignment = 1 + +[node name="TextureRect" type="TextureRect" parent="main/main"] +margin_top = 280.0 +margin_right = 616.0 +margin_bottom = 280.0 +texture = SubResource( 1 ) + +[node name="Gymkhana-logo" type="Sprite" parent="main/main/TextureRect"] +position = Vector2( 301, -47 ) +texture = ExtResource( 2 ) + +[node name="buttons" type="VBoxContainer" parent="main/main"] +margin_top = 380.0 +margin_right = 616.0 +margin_bottom = 620.0 +custom_constants/separation = 10 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="new_game" type="Button" parent="main/main/buttons"] +margin_right = 616.0 +margin_bottom = 150.0 +rect_min_size = Vector2( 0, 150 ) +size_flags_vertical = 3 +text = "NEW_GAME" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="load_game" type="Button" parent="main/main/buttons"] +margin_top = 160.0 +margin_right = 616.0 +margin_bottom = 180.0 +text = "LOAD_GAME" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="options" type="Button" parent="main/main/buttons"] +margin_top = 190.0 +margin_right = 616.0 +margin_bottom = 210.0 +text = "OPTIONS" + +[node name="quit" type="Button" parent="main/main/buttons"] +margin_top = 220.0 +margin_right = 616.0 +margin_bottom = 240.0 +text = "QUIT" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="back_button_pressed" from="load_game" to="." method="_on_load_game_back_button_pressed"] +[connection signal="back_button_pressed" from="options" to="." method="_on_options_back_button_pressed"] +[connection signal="pressed" from="main/main/buttons/new_game" to="." method="_on_new_game_pressed"] +[connection signal="pressed" from="main/main/buttons/load_game" to="." method="_on_load_game_pressed"] +[connection signal="pressed" from="main/main/buttons/options" to="." method="_on_options_pressed"] +[connection signal="pressed" from="main/main/buttons/quit" to="." method="_on_quit_pressed"] diff --git a/game/ui/menus/options/flags/de.png b/game/ui/menus/options/flags/de.png new file mode 100644 index 00000000..4fe98a89 Binary files /dev/null and b/game/ui/menus/options/flags/de.png differ diff --git a/game/ui/menus/options/flags/en.png b/game/ui/menus/options/flags/en.png new file mode 100644 index 00000000..05892848 Binary files /dev/null and b/game/ui/menus/options/flags/en.png differ diff --git a/game/ui/menus/options/flags/fr.png b/game/ui/menus/options/flags/fr.png new file mode 100644 index 00000000..fcaf2cc1 Binary files /dev/null and b/game/ui/menus/options/flags/fr.png differ diff --git a/game/ui/menus/options/options.gd b/game/ui/menus/options/options.gd new file mode 100644 index 00000000..33301939 --- /dev/null +++ b/game/ui/menus/options/options.gd @@ -0,0 +1,157 @@ +# An options menu +extends Control + + +# The back button was pressed +signal back_button_pressed + + +# Custom setting key +const CUSTOM_SETTING: String = "a_custom_setting" + + +# The current settings +var backup_settings + + +# A list of languages already added to the language selection +var _loaded_languages: Array = [] + + +# The settings changed +onready var settings_changed = false + + +# Initialize the flags +func _ready() -> void: + var _flags_container: HBoxContainer = \ + $VBoxContainer/MarginContainer/options/flags + for child in _flags_container.get_children(): + _flags_container.remove_child(child) + child.queue_free() + + _loaded_languages = [] + + for lang in TranslationServer.get_loaded_locales(): + if not lang in _loaded_languages: + _loaded_languages.append(lang) + var _lang = TextureRect.new() + _lang.texture = load( + "res://addons/escoria-core/ui_library" + \ + "/menus/options/flags/%s.png" % lang + ) + _flags_container.add_child(_lang) + _lang.connect("gui_input", self, "_on_language_input", [lang]) + + +# Show the options +func show(): + backup_settings = escoria.settings_manager.get_settings() + initialize_options(backup_settings) + visible = true + + +# Set the sliders to the values of the settings +# +# #### Parameters +# - p_settings: The settings to use +func initialize_options(p_settings): + var _options = $VBoxContainer/MarginContainer/options + _options.get_node("general_volume").value = p_settings["master_volume"] + _options.get_node("sound_volume").value = p_settings["sfx_volume"] + _options.get_node("music_volume").value = p_settings["music_volume"] + _options.get_node("speech_volume").value = p_settings["speech_volume"] + + +# The language was changed +# +# #### Parameters +# - event: The input event from the flag +# - language: The language to set +func _on_language_input(event: InputEvent, language: String): + if event.is_pressed(): + TranslationServer.set_locale(language) + ESCProjectSettingsManager.set_setting( + ESCProjectSettingsManager.TEXT_LANG, + language + ) + settings_changed = true + + +# Sound volume was changed +# +# #### Parameters +# - value: The new volume level +func _on_sound_volume_changed(value): + if ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.SFX_VOLUME + ) != value: + ESCProjectSettingsManager.set_setting( + ESCProjectSettingsManager.SFX_VOLUME, + value + ) + escoria.settings_manager.apply_settings() + settings_changed = true + + +# Music volume was changed +# +# #### Parameters +# - value: The new volume level +func _on_music_volume_changed(value): + if ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.MUSIC_VOLUME + ) != value: + ESCProjectSettingsManager.set_setting( + ESCProjectSettingsManager.MUSIC_VOLUME, + value + ) + escoria.settings_manager.apply_settings() + settings_changed = true + + +# General volume was changed +# +# #### Parameters +# - value: The new volume level +func _on_general_volume_changed(value): + if ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.MASTER_VOLUME + ) != value: + ESCProjectSettingsManager.set_setting( + ESCProjectSettingsManager.MASTER_VOLUME, + value + ) + escoria.settings_manager.apply_settings() + settings_changed = true + + +# Speech volume was changed +# +# #### Parameters +# - value: The new volume level +func _on_speech_volume_value_changed(value: float) -> void: + if ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.SPEECH_VOLUME + ) != value: + ESCProjectSettingsManager.set_setting( + ESCProjectSettingsManager.SPEECH_VOLUME, + value + ) + escoria.settings_manager.apply_settings() + settings_changed = true + + +# Save the settings +func _on_apply_pressed(): + escoria.settings_manager.custom_settings[CUSTOM_SETTING] = 100 + escoria.settings_manager.save_settings() + settings_changed = false + emit_signal("back_button_pressed") + + +# The back button was pressed +func _on_back_pressed(): + escoria.settings_manager.save_settings_resource_to_project_settings(backup_settings) + escoria.settings_manager.apply_settings() + emit_signal("back_button_pressed") diff --git a/game/ui/menus/options/options.tscn b/game/ui/menus/options/options.tscn new file mode 100644 index 00000000..b6c4c59c --- /dev/null +++ b/game/ui/menus/options/options.tscn @@ -0,0 +1,164 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/options/flags/de.png" type="Texture" id=1] +[ext_resource path="res://addons/escoria-core/ui_library/menus/options/options.gd" type="Script" id=4] + +[node name="options" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 4 ) + +[node name="Panel" type="Panel" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_editor_description_": "" +} + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] +margin_left = 391.0 +margin_top = 340.0 +margin_right = 888.0 +margin_bottom = 535.0 +size_flags_horizontal = 6 +custom_constants/margin_right = 20 +custom_constants/margin_top = 20 +custom_constants/margin_left = 20 +custom_constants/margin_bottom = 20 + +[node name="options" type="GridContainer" parent="VBoxContainer/MarginContainer"] +margin_left = 20.0 +margin_top = 20.0 +margin_right = 477.0 +margin_bottom = 175.0 +size_flags_vertical = 6 +custom_constants/hseparation = 40 +columns = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="label" type="Label" parent="VBoxContainer/MarginContainer/options"] +margin_top = 30.0 +margin_right = 137.0 +margin_bottom = 44.0 +text = "OPTIONS_LANGUAGE" + +[node name="flags" type="HBoxContainer" parent="VBoxContainer/MarginContainer/options"] +margin_left = 177.0 +margin_right = 457.0 +margin_bottom = 75.0 +size_flags_vertical = 3 +custom_constants/separation = 30 +alignment = 1 + +[node name="TextureRect2" type="TextureRect" parent="VBoxContainer/MarginContainer/options/flags"] +margin_right = 125.0 +margin_bottom = 75.0 +texture = ExtResource( 1 ) + +[node name="TextureRect3" type="TextureRect" parent="VBoxContainer/MarginContainer/options/flags"] +margin_left = 155.0 +margin_right = 280.0 +margin_bottom = 75.0 +texture = ExtResource( 1 ) + +[node name="label2" type="Label" parent="VBoxContainer/MarginContainer/options"] +margin_top = 80.0 +margin_right = 137.0 +margin_bottom = 94.0 +text = "GENERAL_VOLUME" + +[node name="general_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"] +margin_left = 177.0 +margin_top = 79.0 +margin_right = 457.0 +margin_bottom = 95.0 +size_flags_horizontal = 3 +max_value = 1.0 +step = 0.001 + +[node name="label3" type="Label" parent="VBoxContainer/MarginContainer/options"] +margin_top = 100.0 +margin_right = 137.0 +margin_bottom = 114.0 +text = "SOUND_VOLUME" + +[node name="sound_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"] +margin_left = 177.0 +margin_top = 99.0 +margin_right = 457.0 +margin_bottom = 115.0 +size_flags_horizontal = 3 +max_value = 1.0 +step = 0.001 + +[node name="label4" type="Label" parent="VBoxContainer/MarginContainer/options"] +margin_top = 120.0 +margin_right = 137.0 +margin_bottom = 134.0 +text = "MUSIC_VOLUME" + +[node name="music_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"] +margin_left = 177.0 +margin_top = 119.0 +margin_right = 457.0 +margin_bottom = 135.0 +size_flags_horizontal = 3 +max_value = 1.0 +step = 0.001 + +[node name="label5" type="Label" parent="VBoxContainer/MarginContainer/options"] +margin_top = 140.0 +margin_right = 137.0 +margin_bottom = 154.0 +text = "SPEECH_VOLUME" + +[node name="speech_volume" type="HSlider" parent="VBoxContainer/MarginContainer/options"] +margin_left = 177.0 +margin_top = 139.0 +margin_right = 457.0 +margin_bottom = 155.0 +size_flags_horizontal = 3 +max_value = 1.0 +step = 0.001 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +margin_top = 539.0 +margin_right = 1280.0 +margin_bottom = 559.0 +custom_constants/separation = 20 +alignment = 1 + +[node name="back" type="Button" parent="VBoxContainer/HBoxContainer"] +margin_left = 549.0 +margin_right = 660.0 +margin_bottom = 20.0 +text = "OPTIONS_BACK" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="apply" type="Button" parent="VBoxContainer/HBoxContainer"] +margin_left = 680.0 +margin_right = 731.0 +margin_bottom = 20.0 +text = "APPLY" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/general_volume" to="." method="_on_general_volume_changed"] +[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/sound_volume" to="." method="_on_sound_volume_changed"] +[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/music_volume" to="." method="_on_music_volume_changed"] +[connection signal="value_changed" from="VBoxContainer/MarginContainer/options/speech_volume" to="." method="_on_speech_volume_value_changed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/back" to="." method="_on_back_pressed"] +[connection signal="pressed" from="VBoxContainer/HBoxContainer/apply" to="." method="_on_apply_pressed"] diff --git a/game/ui/menus/pause_menu/pause_menu.gd b/game/ui/menus/pause_menu/pause_menu.gd new file mode 100644 index 00000000..c25ddf58 --- /dev/null +++ b/game/ui/menus/pause_menu/pause_menu.gd @@ -0,0 +1,68 @@ +# A menu shown in game +extends Control + + +# Make the pause menu process in pause mode and hide it just to be sure +func _ready(): + self.pause_mode = Node.PAUSE_MODE_PROCESS + hide() + + +# Continue the game +func _on_continue_pressed(): + escoria.main.current_scene.game.unpause_game() + + +# Show the save slots +func _on_save_game_pressed(): + $VBoxContainer.hide() + $save_game.show() + + +# Show the load slots +func _on_load_game_pressed(): + $VBoxContainer.hide() + $load_game.refresh_savegames() + $load_game.show() + + +# Show the options menu +func _on_options_pressed(): + $VBoxContainer.hide() + $options.show() + + +# Quit the game +func _on_quit_pressed(): + escoria.quit() + + +# Hide the save slots after clicking back button +func _on_save_game_back_button_pressed(): + reset() + + +# Hide the load slots after clicking back button +func _on_load_game_back_button_pressed(): + reset() + + +# Hide options menu after clicking back button +func _on_options_back_button_pressed(): + reset() + + +# Set whether saving is enabled currently +# +# #### Parameters +# - p_enabled: Enable or disable saving +func set_save_enabled(p_enabled: bool): + $VBoxContainer/menuitems/save_game.disabled = !p_enabled + + +# Resets the UI to initial state +func reset(): + $save_game.hide() + $load_game.hide() + $options.hide() + $VBoxContainer.show() diff --git a/game/ui/menus/pause_menu/pause_menu.tscn b/game/ui/menus/pause_menu/pause_menu.tscn new file mode 100644 index 00000000..3ea98f9b --- /dev/null +++ b/game/ui/menus/pause_menu/pause_menu.tscn @@ -0,0 +1,115 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/menus/pause_menu/pause_menu.gd" type="Script" id=1] +[ext_resource path="res://addons/escoria-core/ui_library/menus/options/options.tscn" type="PackedScene" id=2] +[ext_resource path="res://addons/escoria-core/design/escoria-logo-small.png" type="Texture" id=3] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/save/save_game.tscn" type="PackedScene" id=4] +[ext_resource path="res://addons/escoria-core/ui_library/menus/load_save/load/load_game.tscn" type="PackedScene" id=5] + +[node name="pause_menu" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Panel" type="Panel" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="save_game" parent="." instance=ExtResource( 4 )] +visible = false + +[node name="load_game" parent="." instance=ExtResource( 5 )] +visible = false + +[node name="options" parent="." instance=ExtResource( 2 )] + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_left = -308.0 +margin_right = 308.0 +custom_constants/separation = 100 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TextureRect" type="TextureRect" parent="VBoxContainer"] +margin_top = 147.0 +margin_right = 616.0 +margin_bottom = 383.0 +texture = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="menuitems" type="VBoxContainer" parent="VBoxContainer"] +margin_top = 483.0 +margin_right = 616.0 +margin_bottom = 753.0 +custom_constants/separation = 10 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="continue" type="Button" parent="VBoxContainer/menuitems"] +margin_right = 616.0 +margin_bottom = 150.0 +rect_min_size = Vector2( 0, 150 ) +size_flags_vertical = 3 +text = "CONTINUE_GAME" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="save_game" type="Button" parent="VBoxContainer/menuitems"] +margin_top = 160.0 +margin_right = 616.0 +margin_bottom = 180.0 +size_flags_vertical = 3 +text = "SAVE_GAME" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="load_game" type="Button" parent="VBoxContainer/menuitems"] +margin_top = 190.0 +margin_right = 616.0 +margin_bottom = 210.0 +size_flags_vertical = 3 +text = "LOAD_GAME" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="options" type="Button" parent="VBoxContainer/menuitems"] +margin_top = 220.0 +margin_right = 616.0 +margin_bottom = 240.0 +text = "OPTIONS" + +[node name="quit" type="Button" parent="VBoxContainer/menuitems"] +margin_top = 250.0 +margin_right = 616.0 +margin_bottom = 270.0 +size_flags_vertical = 3 +text = "QUIT" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="back_button_pressed" from="save_game" to="." method="_on_save_game_back_button_pressed"] +[connection signal="back_button_pressed" from="load_game" to="." method="_on_load_game_back_button_pressed"] +[connection signal="back_button_pressed" from="options" to="." method="_on_options_back_button_pressed"] +[connection signal="pressed" from="VBoxContainer/menuitems/continue" to="." method="_on_continue_pressed"] +[connection signal="pressed" from="VBoxContainer/menuitems/save_game" to="." method="_on_save_game_pressed"] +[connection signal="pressed" from="VBoxContainer/menuitems/load_game" to="." method="_on_load_game_pressed"] +[connection signal="pressed" from="VBoxContainer/menuitems/options" to="." method="_on_options_pressed"] +[connection signal="pressed" from="VBoxContainer/menuitems/quit" to="." method="_on_quit_pressed"] diff --git a/game/ui/tools/room_select/room_select.gd b/game/ui/tools/room_select/room_select.gd new file mode 100644 index 00000000..f43b7922 --- /dev/null +++ b/game/ui/tools/room_select/room_select.gd @@ -0,0 +1,81 @@ +# A small utility to quickly switch to a room while developing +extends OptionButton + + +# The selected option +var _selected_id = 0 + + +# The path to available rooms +var _options_paths = [] + + +# Build up the list of rooms +func _ready(): + var rooms_folder = ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.ROOM_SELECTOR_ROOM_DIR + ) + if rooms_folder == "" or \ + not ESCProjectSettingsManager.get_setting( + ESCProjectSettingsManager.ENABLE_ROOM_SELECTOR + ): + return + var dir = Directory.new() + var rooms_list: Array = [] + var path = ProjectSettings.globalize_path(rooms_folder) + if not OS.has_feature("editor"): + path = OS.get_executable_path().get_base_dir().plus_file(path) + var tmp = dir.open(path) + if tmp == OK: + dir.list_dir_begin(true) + var file_name = dir.get_next() + while file_name != "": + if dir.current_is_dir(): + rooms_list.push_back(file_name) + file_name = dir.get_next() + + rooms_list.sort() + for room in rooms_list: + add_item(room) + _options_paths.push_back("%s/%s/%s.tscn" %[ + rooms_folder, + room, + room + ]) + + else: + escoria.logger.warn( + self, + "A problem occurred while opening rooms folder %s." % str(path) + ) + + +# Switch to the selected room +func _on_button_pressed(): + # When next room is loaded, we don't want to consider ESC_LAST_SCENE for + # automatic transitions. + # If FORCE_LAST_SCENE_NULL is True when change_scene starts: + # - ESC_LAST_SCENE is set to empty + escoria.globals_manager.set_global( + escoria.room_manager.GLOBAL_FORCE_LAST_SCENE_NULL, + true, + true + ) + + var script = escoria.esc_compiler.compile([ + ":room_selector", + "change_scene %s" % _options_paths[_selected_id] + ], + get_class() + ) + escoria.event_manager.interrupt() + escoria.event_manager.queue_event(script.events['room_selector']) + + + +# A room was selected, store the selection +# +# #### Parameters +# - index: The index of the selected room in the paths list +func _on_option_item_selected(index): + _selected_id = index diff --git a/game/ui/tools/room_select/room_select.tscn b/game/ui/tools/room_select/room_select.tscn new file mode 100644 index 00000000..8c35f79f --- /dev/null +++ b/game/ui/tools/room_select/room_select.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/escoria-core/ui_library/tools/room_select/room_select.gd" type="Script" id=1] + +[node name="room_select" type="HBoxContainer"] +margin_right = 63.0 +margin_bottom = 40.0005 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="option" type="OptionButton" parent="."] +margin_right = 29.0 +margin_bottom = 40.0 +size_flags_horizontal = 3 +script = ExtResource( 1 ) + +[node name="button" type="Button" parent="."] +margin_left = 33.0 +margin_right = 63.0 +margin_bottom = 40.0 +text = "Go" + +[connection signal="item_selected" from="option" to="option" method="_on_option_item_selected"] +[connection signal="pressed" from="button" to="option" method="_on_button_pressed"] diff --git a/gymkhana-logo.png b/gymkhana-logo.png new file mode 100644 index 00000000..7b7dea11 Binary files /dev/null and b/gymkhana-logo.png differ diff --git a/project.godot b/project.godot index 684ef88c..ae2ed3de 100644 --- a/project.godot +++ b/project.godot @@ -297,7 +297,7 @@ _global_script_classes=[ { "base": "TextureButton", "class": "ESCInventoryButton", "language": "GDScript", -"path": "res://addons/escoria-core/ui_library/inventory/esc_inventory_button.gd" +"path": "res://game/ui/inventory/esc_inventory_button.gd" }, { "base": "Control", "class": "ESCInventoryContainer", @@ -826,10 +826,10 @@ _global_script_class_icons={ config/name="Escoria" run/main_scene="res://addons/escoria-core/game/main_scene.tscn" -boot_splash/image="res://addons/escoria-core/design/escoria-logo-small.png" +boot_splash/image="res://gymkhana-logo.png" boot_splash/fullsize=false boot_splash/use_filter=false -boot_splash/bg_color=Color( 0.960784, 0.384314, 0, 1 ) +boot_splash/bg_color=Color( 0, 0, 0, 1 ) config/icon="res://icon.png" [audio]