Skip to content

Commit

Permalink
right location focus
Browse files Browse the repository at this point in the history
  • Loading branch information
astonedf committed Jul 6, 2022
1 parent 5450e32 commit 5bc402a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
8 changes: 4 additions & 4 deletions scenes/Notebook/Map.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
37 changes: 36 additions & 1 deletion src/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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");

}

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());
}
}
}
Expand Down

0 comments on commit 5bc402a

Please sign in to comment.