diff --git a/gfx/ui/main_frame.png b/gfx/ui/main_frame.png new file mode 100644 index 0000000..fdcfc3c --- /dev/null +++ b/gfx/ui/main_frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44e44686c59f6700a45da4ec87200dbe7c0c97f3c98093e632c2b4115e578e8e +size 3384 diff --git a/gfx/ui/main_frame.png.import b/gfx/ui/main_frame.png.import new file mode 100644 index 0000000..fc77ee5 --- /dev/null +++ b/gfx/ui/main_frame.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ccxs3ctob15es" +path="res://.godot/imported/main_frame.png-cf8337ea780d2d72badf7c10f22782c2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://gfx/ui/main_frame.png" +dest_files=["res://.godot/imported/main_frame.png-cf8337ea780d2d72badf7c10f22782c2.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project.godot b/project.godot index ed5114e..994f3e8 100644 --- a/project.godot +++ b/project.godot @@ -19,7 +19,8 @@ config/icon="res://icon.svg" [autoload] Loader="*res://scripts/loader.gd" -GameManager="*res://scripts/GameManager.gd" +GameManager="*res://scripts/game/GameManager.gd" +CommandDispatcher="*res://scripts/game/commands/CommandDispatcher.gd" [display] diff --git a/scenes/game.tscn b/scenes/game.tscn index c267bf3..62451a7 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,9 +1,52 @@ -[gd_scene load_steps=2 format=3 uid="uid://c0b5w48jk67qd"] +[gd_scene load_steps=5 format=3 uid="uid://c0b5w48jk67qd"] -[ext_resource type="Script" uid="uid://dq5qq5xj76nwe" path="res://scripts/game/game_screen.gd" id="1_uwrxv"] +[ext_resource type="Script" uid="uid://c0uvlwmkm3r8o" path="res://scripts/game/game_screen.gd" id="1_uwrxv"] +[ext_resource type="Script" uid="uid://dcqqr8b42tn0x" path="res://scripts/game/CommandProcessor.gd" id="2_lbhrr"] +[ext_resource type="Texture2D" uid="uid://ccxs3ctob15es" path="res://gfx/ui/main_frame.png" id="2_lnu2h"] +[ext_resource type="FontFile" uid="uid://1u28cjgctsn7" path="res://fonts/alagard_by_pix3m-d6awiwp.ttf" id="3_lbhrr"] [node name="Game" type="Node" node_paths=PackedStringArray("map")] script = ExtResource("1_uwrxv") map = NodePath("Map") +[node name="Command Processor" type="Timer" parent="."] +wait_time = 3.0 +autostart = true +script = ExtResource("2_lbhrr") + [node name="Map" type="Node" parent="."] + +[node name="UI" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="UI"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_lnu2h") + +[node name="Left Panel" type="VBoxContainer" parent="UI"] +layout_mode = 0 +offset_left = 13.0 +offset_top = 15.0 +offset_right = 166.0 +offset_bottom = 216.0 + +[node name="Command Menu" type="VBoxContainer" parent="UI/Left Panel"] +layout_mode = 2 + +[node name="Pass Button" type="Button" parent="UI/Left Panel/Command Menu"] +layout_mode = 2 +theme_override_fonts/font = ExtResource("3_lbhrr") +text = "Pass" + +[connection signal="timeout" from="Command Processor" to="Command Processor" method="_on_timeout"] +[connection signal="pressed" from="UI/Left Panel/Command Menu/Pass Button" to="." method="_on_pass_button_pressed"] diff --git a/scripts/GameManager.gd b/scripts/GameManager.gd deleted file mode 100644 index 9ec3c99..0000000 --- a/scripts/GameManager.gd +++ /dev/null @@ -1,17 +0,0 @@ -extends Node - -var defaultMapPath: String = "res://scenes/game/maps/world_map.tscn" -var currentMapPath: String = "" - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - - -func startNewGame(): - currentMapPath = defaultMapPath diff --git a/scripts/GameManager.gd.uid b/scripts/GameManager.gd.uid deleted file mode 100644 index acf38d3..0000000 --- a/scripts/GameManager.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://0mhwqcwput71 diff --git a/scripts/game/CommandProcessor.gd b/scripts/game/CommandProcessor.gd new file mode 100644 index 0000000..353b17e --- /dev/null +++ b/scripts/game/CommandProcessor.gd @@ -0,0 +1,46 @@ +extends Timer + +class_name CommandProcessor +signal BROADCAST_COMMAND(label) + +var resumeWaiting:bool = true + +func _ready(): + CommandDispatcher.PROCESS_COMMAND.connect(processCommand) + CommandDispatcher.WAIT_FOR_COMMAND.connect(waitForCommand) + CommandDispatcher.PAUSE_PROCESSOR.connect(pauseProcessor) + + +func processCommand(command:Command): + if (is_stopped()): + return + + stop() + + command.COMMAND_PROCESSED.connect(onCommandProcessed) + + BROADCAST_COMMAND.emit(command.getCommandText()) + + command.execute() + + +func waitForCommand(): + resumeWaiting = true + start() + + +func pauseProcessor(): + stop() + resumeWaiting = false + + +func onCommandProcessed(result): + if (result != null): + print(result) + + if (resumeWaiting): + waitForCommand() + + +func _on_timeout(): + processCommand(PassCommand.new()) diff --git a/scripts/game/CommandProcessor.gd.uid b/scripts/game/CommandProcessor.gd.uid new file mode 100644 index 0000000..5058b27 --- /dev/null +++ b/scripts/game/CommandProcessor.gd.uid @@ -0,0 +1 @@ +uid://dcqqr8b42tn0x diff --git a/scripts/game/GameManager.gd b/scripts/game/GameManager.gd new file mode 100644 index 0000000..cfeec11 --- /dev/null +++ b/scripts/game/GameManager.gd @@ -0,0 +1,7 @@ +extends Node + +var defaultMapPath: String = "res://scenes/game/maps/world_map.tscn" +var currentMapPath: String = "" + +func startNewGame(): + currentMapPath = defaultMapPath diff --git a/scripts/game/GameManager.gd.uid b/scripts/game/GameManager.gd.uid new file mode 100644 index 0000000..7a71100 --- /dev/null +++ b/scripts/game/GameManager.gd.uid @@ -0,0 +1 @@ +uid://bos3psfp6dgdn diff --git a/scripts/game/commands/Command.gd b/scripts/game/commands/Command.gd new file mode 100644 index 0000000..cafac40 --- /dev/null +++ b/scripts/game/commands/Command.gd @@ -0,0 +1,13 @@ +class_name Command + +signal COMMAND_PROCESSED(label) + +var commandLabel + + +func execute(): + COMMAND_PROCESSED.emit(commandLabel) + + +func getCommandText(): + return commandLabel diff --git a/scripts/game/commands/Command.gd.uid b/scripts/game/commands/Command.gd.uid new file mode 100644 index 0000000..19e8a2a --- /dev/null +++ b/scripts/game/commands/Command.gd.uid @@ -0,0 +1 @@ +uid://b4ee6hsxy7qwc diff --git a/scripts/game/commands/CommandDispatcher.gd b/scripts/game/commands/CommandDispatcher.gd new file mode 100644 index 0000000..49a28b7 --- /dev/null +++ b/scripts/game/commands/CommandDispatcher.gd @@ -0,0 +1,5 @@ +extends Node + +signal PROCESS_COMMAND(command) +signal WAIT_FOR_COMMAND +signal PAUSE_PROCESSOR diff --git a/scripts/game/commands/CommandDispatcher.gd.uid b/scripts/game/commands/CommandDispatcher.gd.uid new file mode 100644 index 0000000..e81158f --- /dev/null +++ b/scripts/game/commands/CommandDispatcher.gd.uid @@ -0,0 +1 @@ +uid://buuwlxv16l2lu diff --git a/scripts/game/commands/PassCommand.gd b/scripts/game/commands/PassCommand.gd new file mode 100644 index 0000000..ef2e81c --- /dev/null +++ b/scripts/game/commands/PassCommand.gd @@ -0,0 +1,10 @@ +extends Command + +class_name PassCommand + +func _init() -> void: + commandLabel = "Pass" + +func execute(): + print("Player passed.") + COMMAND_PROCESSED.emit(commandLabel) diff --git a/scripts/game/commands/PassCommand.gd.uid b/scripts/game/commands/PassCommand.gd.uid new file mode 100644 index 0000000..aa55e10 --- /dev/null +++ b/scripts/game/commands/PassCommand.gd.uid @@ -0,0 +1 @@ +uid://1a8ulyob7ld5 diff --git a/scripts/game/game_screen.gd b/scripts/game/game_screen.gd index 62ac859..4577e5f 100644 --- a/scripts/game/game_screen.gd +++ b/scripts/game/game_screen.gd @@ -8,7 +8,5 @@ class_name GameScreen func _ready() -> void: map.add_child(load(GameManager.currentMapPath).instantiate()) - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass +func _on_pass_button_pressed() -> void: + CommandDispatcher.PROCESS_COMMAND.emit(PassCommand.new()) diff --git a/scripts/game/game_screen.gd.uid b/scripts/game/game_screen.gd.uid index 85719c3..48617eb 100644 --- a/scripts/game/game_screen.gd.uid +++ b/scripts/game/game_screen.gd.uid @@ -1 +1 @@ -uid://dq5qq5xj76nwe +uid://c0uvlwmkm3r8o diff --git a/scripts/loader.gd b/scripts/loader.gd index 51eee21..e00e76c 100644 --- a/scripts/loader.gd +++ b/scripts/loader.gd @@ -16,7 +16,7 @@ func loadScene(caller: Node, path: String): # Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: +func _process(_delta: float) -> void: if scenePath: var progress: Array = [] var loaderStatus: ResourceLoader.ThreadLoadStatus = ResourceLoader.load_threaded_get_status(scenePath, progress) diff --git a/scripts/title/title_screen.gd b/scripts/title/title_screen.gd index 2d08747..de834ad 100644 --- a/scripts/title/title_screen.gd +++ b/scripts/title/title_screen.gd @@ -1,16 +1,6 @@ extends Control -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - - func _on_new_game_button_pressed() -> void: GameManager.startNewGame() diff --git a/scripts/title/version_number.gd b/scripts/title/version_number.gd index bda38bb..9c876fc 100644 --- a/scripts/title/version_number.gd +++ b/scripts/title/version_number.gd @@ -4,8 +4,3 @@ extends Label # Called when the node enters the scene tree for the first time. func _ready() -> void: text += ProjectSettings.get_setting("application/config/version") - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass diff --git a/scripts/ui/loading_screen.gd b/scripts/ui/loading_screen.gd index 378c543..5c15c32 100644 --- a/scripts/ui/loading_screen.gd +++ b/scripts/ui/loading_screen.gd @@ -7,10 +7,5 @@ func _ready() -> void: Loader.LOADING_PROGRESS_UPDATED.connect(_on_progress_updated) -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - - func _on_progress_updated(percentage: float) -> void: loadingBar.value = percentage