Skip to content

Commit

Permalink
Merge pull request #209 from GameLab-UNIL-EPFL/MapControls
Browse files Browse the repository at this point in the history
Choose location with keys
  • Loading branch information
dobios authored Jul 13, 2022
2 parents 3abd1d3 + 5bc402a commit 2a160e5
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="5af8d800314babecccc487fe554ad7c9"
dest_md5="6fdb71a36f05c72dc727140ad9a18232"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="a5c32aa00d965ca952623d1b3fe45610"
dest_md5="5377adfcfa3dabf2693b9ab22d876fc9"

Binary file not shown.
Binary file modified assets/05_map/adminIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/05_map/adminIcon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/05_map/adminIcon.png"
dest_files=[ "res://.import/adminIcon.png-3688bd3c074b54dd0cdc871d8dcdd8ce.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file modified assets/05_map/breweryIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/05_map/breweryIcon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/05_map/breweryIcon.png"
dest_files=[ "res://.import/breweryIcon.png-342c5fb510f55800453b35945f1f0115.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
File renamed without changes.
35 changes: 28 additions & 7 deletions scenes/Notebook/Map.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=15 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]
Expand All @@ -13,8 +13,10 @@
[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]

[node name="Map" type="Node2D"]
script = ExtResource( 14 )

[node name="Map" type="Sprite" parent="."]
position = Vector2( 224, 132 )
Expand Down Expand Up @@ -72,20 +74,26 @@ id = "Brasserie/Brasserie"
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_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 )
texture_focused = ExtResource( 13 )
id = "Brasserie/Brasserie"

[node name="moulin_button" parent="." instance=ExtResource( 1 )]
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"

Expand All @@ -94,8 +102,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"

Expand All @@ -104,8 +117,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"

Expand All @@ -115,10 +131,15 @@ texture = ExtResource( 8 )

[node name="office_button" parent="." instance=ExtResource( 1 )]
margin_left = 269.0
margin_top = 111.0
margin_top = 113.0
margin_right = 336.0
margin_bottom = 128.0
margin_bottom = 130.0
focus_neighbour_left = NodePath("../palud_button")
focus_neighbour_bottom = NodePath("../casino_button")
texture_normal = ExtResource( 11 )
texture_hover = ExtResource( 9 )
texture_focused = ExtResource( 9 )
id = "Intro/Intro"
text = "Bureau"

[connection signal="visibility_changed" from="." to="." method="_on_Map_visibility_changed"]
78 changes: 42 additions & 36 deletions src/Map.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,57 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
using Godot;
using System;

public class Map : Node2D
{
private bool hidden = true;

private AudioStreamPlayer ASP;
private Sprite S;

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()
{
ASP = GetNode<AudioStreamPlayer>("../ButtonSound");
S = GetNode<Sprite>("../TabMap");
office = GetNode<TextureButton>("office_button");
brasserie = GetNode<TextureButton>("brasserie_button");
moulin = GetNode<TextureButton>("moulin_button");
palud = GetNode<TextureButton>("palud_button");
casino = GetNode<TextureButton>("casino_button");
context = GetNode<Context>("/root/Context");

}

public void _on_MapButton_pressed() {
if(ASP.Playing == false) {
ASP.Play();
}
if(hidden) {
Show();
S.Frame = 0;
} else {
Hide();
S.Frame = 1;

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;
}
hidden = !hidden;
}


private void _on_Map_visibility_changed() {
if(Visible) {
GrabFocusPos(context._GetLocation());
}
}
}



0 comments on commit 2a160e5

Please sign in to comment.