From faad712b6593d271fd7aa991e8c4b2f717e8cd21 Mon Sep 17 00:00:00 2001 From: Saara Date: Mon, 4 Jul 2022 21:30:27 +0200 Subject: [PATCH 1/4] Choose location with keys --- scenes/Notebook/Map.tscn | 55 ++++++++++++++++++++++++++++++++++------ src/Map.cs | 43 +++++-------------------------- 2 files changed, 53 insertions(+), 45 deletions(-) diff --git a/scenes/Notebook/Map.tscn b/scenes/Notebook/Map.tscn index 384f63f5..4d45afb3 100644 --- a/scenes/Notebook/Map.tscn +++ b/scenes/Notebook/Map.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=2] +[gd_scene load_steps=20 format=2] [ext_resource path="res://scenes/Notebook/MapIcon.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/05_map/map.png" type="Texture" id=2] @@ -13,8 +13,27 @@ [ext_resource path="res://assets/05_map/adminIcon.png" type="Texture" id=11] [ext_resource path="res://assets/05_map/casinoIcon-hover-export.png" type="Texture" id=12] [ext_resource path="res://assets/05_map/breweryIcon-Hover.png" type="Texture" id=13] +[ext_resource path="res://src/Map.cs" type="Script" id=14] +[ext_resource path="res://assets/05_map/breweryIcon.png" type="Texture" id=15] + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 15 ) +region = Rect2( -1, 0, 50, 17 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 13 ) +region = Rect2( 2, 1, 50, 18 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 11 ) +region = Rect2( -1, -1, 68, 18 ) + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 9 ) +region = Rect2( 2, 2, 68, 18 ) [node name="Map" type="Node2D"] +script = ExtResource( 14 ) [node name="Map" type="Sprite" parent="."] position = Vector2( 224, 132 ) @@ -73,10 +92,14 @@ text = "" [node name="brasserie_button" parent="." instance=ExtResource( 1 )] margin_left = 120.0 -margin_top = 88.0 -margin_right = 171.0 -margin_bottom = 98.0 +margin_top = 87.0 +margin_right = 178.0 +margin_bottom = 112.0 +focus_neighbour_right = NodePath("../palud_button") +focus_neighbour_bottom = NodePath("../palud_button") +texture_normal = SubResource( 3 ) texture_hover = ExtResource( 13 ) +texture_focused = SubResource( 4 ) id = "Brasserie/Brasserie" [node name="moulin_button" parent="." instance=ExtResource( 1 )] @@ -84,8 +107,11 @@ margin_left = 163.0 margin_top = 199.0 margin_right = 208.0 margin_bottom = 214.0 +focus_neighbour_top = NodePath("../palud_button") +focus_neighbour_right = NodePath("../casino_button") texture_normal = ExtResource( 4 ) texture_hover = ExtResource( 3 ) +texture_focused = ExtResource( 3 ) id = "Flon/Flon" text = "Flon" @@ -94,8 +120,13 @@ margin_left = 190.0 margin_top = 124.0 margin_right = 234.0 margin_bottom = 148.0 +focus_neighbour_left = NodePath("../brasserie_button") +focus_neighbour_top = NodePath("../brasserie_button") +focus_neighbour_right = NodePath("../office_button") +focus_neighbour_bottom = NodePath("../moulin_button") texture_normal = ExtResource( 5 ) texture_hover = ExtResource( 10 ) +texture_focused = ExtResource( 10 ) id = "Palud/ProtoPalud" text = "Palud" @@ -104,8 +135,11 @@ margin_left = 263.0 margin_top = 204.0 margin_right = 331.0 margin_bottom = 227.0 +focus_neighbour_left = NodePath("../moulin_button") +focus_neighbour_top = NodePath("../office_button") texture_normal = ExtResource( 6 ) texture_hover = ExtResource( 12 ) +texture_focused = ExtResource( 12 ) id = "Casino/Casino" text = "Casino" @@ -115,10 +149,15 @@ texture = ExtResource( 8 ) [node name="office_button" parent="." instance=ExtResource( 1 )] margin_left = 269.0 -margin_top = 111.0 -margin_right = 336.0 -margin_bottom = 128.0 -texture_normal = ExtResource( 11 ) +margin_top = 109.0 +margin_right = 344.0 +margin_bottom = 134.0 +focus_neighbour_left = NodePath("../palud_button") +focus_neighbour_bottom = NodePath("../casino_button") +texture_normal = SubResource( 2 ) texture_hover = ExtResource( 9 ) +texture_focused = SubResource( 1 ) id = "Intro/Intro" text = "Bureau" + +[connection signal="visibility_changed" from="." to="." method="_on_Map_visibility_changed"] diff --git a/src/Map.cs b/src/Map.cs index c09f4030..3503546b 100644 --- a/src/Map.cs +++ b/src/Map.cs @@ -1,51 +1,20 @@ -/* -Historically accurate educational video game based in 1830s Lausanne. -Copyright (C) 2021 GameLab UNIL-EPFL - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ using Godot; using System; public class Map : Node2D { - private bool hidden = true; - - private AudioStreamPlayer ASP; - private Sprite S; - + private TextureButton office; + // Called when the node enters the scene tree for the first time. public override void _Ready() { - ASP = GetNode("../ButtonSound"); - S = GetNode("../TabMap"); + office = GetNode("office_button"); } - public void _on_MapButton_pressed() { - if(ASP.Playing == false) { - ASP.Play(); - } - if(hidden) { - Show(); - S.Frame = 0; - } else { - Hide(); - S.Frame = 1; - } - hidden = !hidden; + private void _on_Map_visibility_changed() { + office.GrabFocus(); } - } + From cccd9c3fcfedb0de637ef5d53f2a6b1a8dbd6228 Mon Sep 17 00:00:00 2001 From: Saara Date: Wed, 6 Jul 2022 14:07:59 +0200 Subject: [PATCH 2/4] icon size fix --- ...n.png-3688bd3c074b54dd0cdc871d8dcdd8ce.md5 | 3 ++ ....png-3688bd3c074b54dd0cdc871d8dcdd8ce.stex | Bin 0 -> 256 bytes ...n.png-342c5fb510f55800453b35945f1f0115.md5 | 3 ++ ....png-342c5fb510f55800453b35945f1f0115.stex | Bin 0 -> 222 bytes assets/05_map/adminIcon.png | Bin 454 -> 482 bytes assets/05_map/adminIcon.png.import | 35 +++++++++++++++ assets/05_map/breweryIcon.png | Bin 395 -> 423 bytes assets/05_map/breweryIcon.png.import | 35 +++++++++++++++ assets/{ => 06_UI_menus}/wasd.aseprite | Bin scenes/Notebook/Map.tscn | 40 +++++------------- 10 files changed, 87 insertions(+), 29 deletions(-) create mode 100644 .import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.md5 create mode 100644 .import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.stex create mode 100644 .import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.md5 create mode 100644 .import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.stex create mode 100644 assets/05_map/adminIcon.png.import create mode 100644 assets/05_map/breweryIcon.png.import rename assets/{ => 06_UI_menus}/wasd.aseprite (100%) diff --git a/.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.md5 b/.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.md5 new file mode 100644 index 00000000..0160b85a --- /dev/null +++ b/.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.md5 @@ -0,0 +1,3 @@ +source_md5="5af8d800314babecccc487fe554ad7c9" +dest_md5="6fdb71a36f05c72dc727140ad9a18232" + diff --git a/.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.stex b/.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.stex new file mode 100644 index 0000000000000000000000000000000000000000..3ab8473e48af370dcfb13a2418c92f382d211d03 GIT binary patch literal 256 zcmZ>F2@dgMU|<LoIBBXzLONC$0u3zXeKC yF7D<#ORp#0+sJi0Wb#tS(lqbKc?bU*7+>Zt_r5#%%DO*QH+Ov3eEhY+kO2UH#A*Ei literal 0 HcmV?d00001 diff --git a/.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.md5 b/.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.md5 new file mode 100644 index 00000000..5ac8c850 --- /dev/null +++ b/.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.md5 @@ -0,0 +1,3 @@ +source_md5="a5c32aa00d965ca952623d1b3fe45610" +dest_md5="5377adfcfa3dabf2693b9ab22d876fc9" + diff --git a/.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.stex b/.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.stex new file mode 100644 index 0000000000000000000000000000000000000000..a5b9c0cf6e520a40e0146e44d04e4fc0b336c502 GIT binary patch literal 222 zcmZ>F2@Wx1U|Px$oJmAMR9J=Wm#=b!Fc8L<&Iu$w0ugn?8=!0Y4A?$ReI54R0!^O)$#f9$NE{VR zZo;zpKP}fbKf@&#zI<6WumMOU5+{)1j;?K1`TP0xcKH9la#0&y+pLT+$cqxjp+C#h zkK>XY7pjvI2q88jySAY;UGDMr&8r%gd4jHOR?4?AP>eC(`F6wxTBB(lz~=SbR10sr^*j z=EbI~^Wln9pvIvGUe!Bs+@_3T4U;yn>btIb#dBdV)Of5L6Cg=YMo~yZ*f9QI*Kg9t zx-q4T&W8=>K`D`DSJY+0OA9nLT%3&c7>I!%mKFALRRU2 znPr~tYX#WWO%;r~{5E{ncG!AUm8uH*WSGx=lKq3uQxC;Lh~p6i z3A!E^Ld=I|v&)eL!>c-z+mOO`*30Bm)qRo3U_J=cyXN!b9RRk6aD90L0JrmFB9SPx$fJsC_R9J=OSD|u*Fc5v|Adq+j0@dLU&^7%AY`>iLfh+HpJ5U>b+9U%~02&^v9;mVSMGc0bqN;wmBjadCqrP)fd0^m&T%8ID6`MuK)(SGlGK&ND0yZQoqkX^?T%Mmw4Fl3L#A} z#KtF*k06(gN3bPx$VM#*$R z^Mk^0aY@uOk?K)jNaR;+p=lf*4is*q?@SK*qPx$MM*?KR7i={Rw0&!FbtgTLm=@L2qZT^?=7%RqPr%8c6 z{`guE!RE;I6?48B!@?G8x!)@6>yhy~ChlK59b%IDjp zVm@LEPUGDj!ZCprcxK#46(}{6qpBN2$4Q!n p40TSs#>66TLRB~Fph%*9d;>xT@)+^z1EK%`002ovPDHLkV1l Date: Wed, 6 Jul 2022 14:12:37 +0200 Subject: [PATCH 3/4] Update Map.cs --- src/Map.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Map.cs b/src/Map.cs index 3503546b..7a4b9dbc 100644 --- a/src/Map.cs +++ b/src/Map.cs @@ -12,7 +12,9 @@ public override void _Ready() } private void _on_Map_visibility_changed() { - office.GrabFocus(); + if(Visible) { + office.GrabFocus(); + } } } From 5bc402aa8eaf5b5e2cda72f9cf817d7bea112fa8 Mon Sep 17 00:00:00 2001 From: Saara Date: Wed, 6 Jul 2022 15:47:19 +0200 Subject: [PATCH 4/4] right location focus --- scenes/Notebook/Map.tscn | 8 ++++---- src/Map.cs | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/scenes/Notebook/Map.tscn b/scenes/Notebook/Map.tscn index 4fa27527..0d1f0a06 100644 --- a/scenes/Notebook/Map.tscn +++ b/scenes/Notebook/Map.tscn @@ -74,10 +74,10 @@ id = "Brasserie/Brasserie" text = "" [node name="brasserie_button" parent="." instance=ExtResource( 1 )] -margin_left = 126.0 -margin_top = 93.0 -margin_right = 176.0 -margin_bottom = 109.0 +margin_left = 132.0 +margin_top = 86.0 +margin_right = 182.0 +margin_bottom = 102.0 focus_neighbour_right = NodePath("../palud_button") focus_neighbour_bottom = NodePath("../palud_button") texture_hover = ExtResource( 13 ) diff --git a/src/Map.cs b/src/Map.cs index 7a4b9dbc..a331365a 100644 --- a/src/Map.cs +++ b/src/Map.cs @@ -4,16 +4,51 @@ public class Map : Node2D { private TextureButton office; + private TextureButton brasserie; + private TextureButton moulin; + private TextureButton palud; + private TextureButton casino; + private Context context; // Called when the node enters the scene tree for the first time. public override void _Ready() { office = GetNode("office_button"); + brasserie = GetNode("brasserie_button"); + moulin = GetNode("moulin_button"); + palud = GetNode("palud_button"); + casino = GetNode("casino_button"); + context = GetNode("/root/Context"); + } + + private void GrabFocusPos(Locations l) { + switch(l) { + case Locations.INTRO: + office.GrabFocus(); + break; + case Locations.PALUD: + palud.GrabFocus(); + break; + case Locations.CASINO: + casino.GrabFocus(); + break; + case Locations.BRASSERIE: + brasserie.GrabFocus(); + break; + case Locations.MOULIN: + case Locations.FLON: + moulin.GrabFocus(); + break; + default: + break; + } + } + private void _on_Map_visibility_changed() { if(Visible) { - office.GrabFocus(); + GrabFocusPos(context._GetLocation()); } } }