From e988d9b38e49034c1f05b1a80bb373a94bb25ed2 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Thu, 8 Dec 2022 20:13:57 +0000 Subject: [PATCH] change to build mode with keyboard shortcuts #5 --- gdd.md | 13 ++++++ half-earth/nodes/debug_ui.tscn | 16 +++++++ half-earth/nodes/game.tscn | 6 ++- half-earth/nodes/interaction_mode.tscn | 7 ++++ half-earth/scripts/DebugUI.cs | 26 ++++++------ half-earth/scripts/InteractionMode.cs | 58 ++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 half-earth/nodes/interaction_mode.tscn create mode 100644 half-earth/scripts/InteractionMode.cs diff --git a/gdd.md b/gdd.md index 3c72c77..803f5d6 100644 --- a/gdd.md +++ b/gdd.md @@ -8,6 +8,19 @@ * Education * Supply chains +## Interaction Modes + +Interaction modes can be changed via keyboard shortcut. + +### Selection Mode + +This is the default interaction mode. +It can be accessed at any time by pressing the `esc` key. + +### Build Mode + +Build mode can be entered by pressing the `b` key. + ## Critical Path ### Grid diff --git a/half-earth/nodes/debug_ui.tscn b/half-earth/nodes/debug_ui.tscn index 4f2ab7f..95d6ea2 100644 --- a/half-earth/nodes/debug_ui.tscn +++ b/half-earth/nodes/debug_ui.tscn @@ -8,6 +8,22 @@ anchor_bottom = 1.0 script = ExtResource( 1 ) TicksLabelPath = NodePath("Ticks") PauseLabelPath = NodePath("Paused") +InteractionModeLabelPath = NodePath("Interaction Mode") + +[node name="Interaction Mode" type="Label" parent="."] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -94.0 +margin_top = -64.0 +margin_right = -10.0 +margin_bottom = -50.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "mode: SELECT" +align = 2 +valign = 2 [node name="Ticks" type="Label" parent="."] anchor_left = 1.0 diff --git a/half-earth/nodes/game.tscn b/half-earth/nodes/game.tscn index 9b75583..47ea5a6 100644 --- a/half-earth/nodes/game.tscn +++ b/half-earth/nodes/game.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://nodes/grid.tscn" type="PackedScene" id=1] [ext_resource path="res://nodes/grid_cursor.tscn" type="PackedScene" id=2] [ext_resource path="res://nodes/debug_ui.tscn" type="PackedScene" id=3] [ext_resource path="res://nodes/clock.tscn" type="PackedScene" id=4] +[ext_resource path="res://nodes/interaction_mode.tscn" type="PackedScene" id=5] [node name="Root" type="Node"] @@ -18,6 +19,9 @@ Grid = NodePath("../Grid") [node name="Clock" parent="." instance=ExtResource( 4 )] _autoTick = true +[node name="Interaction Mode" parent="." instance=ExtResource( 5 )] + [connection signal="OnPauseChanged" from="Clock" to="Debug UI" method="_on_Clock_OnPauseChanged"] [connection signal="OnTick" from="Clock" to="Grid" method="_on_Clock_OnTick"] [connection signal="OnTick" from="Clock" to="Debug UI" method="_on_Clock_OnTick"] +[connection signal="OnInteractionModeChanged" from="Interaction Mode" to="Debug UI" method="_on_Interaction_Mode_OnInteractionModeChanged"] diff --git a/half-earth/nodes/interaction_mode.tscn b/half-earth/nodes/interaction_mode.tscn new file mode 100644 index 0000000..c903c46 --- /dev/null +++ b/half-earth/nodes/interaction_mode.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/InteractionMode.cs" type="Script" id=1] + +[node name="Interaction Mode" type="Node"] +script = ExtResource( 1 ) +_buildMode = 66 diff --git a/half-earth/scripts/DebugUI.cs b/half-earth/scripts/DebugUI.cs index 8adc836..5c6fe7a 100644 --- a/half-earth/scripts/DebugUI.cs +++ b/half-earth/scripts/DebugUI.cs @@ -11,27 +11,29 @@ public class DebugUI : Control public NodePath PauseLabelPath { private get; set; } private Label _pauseLabel; + [Export] + public NodePath InteractionModeLabelPath { private get; set; } + private Label _interactionModeLabel; public override void _Ready() { _ticksLabel = GetNode