From 942edf5556d0d4f4b925fde751430c6a1e447091 Mon Sep 17 00:00:00 2001 From: Ategon <benjamin@barbeau.net> Date: Mon, 7 Oct 2024 04:25:58 -0400 Subject: [PATCH] Add functioning UI buttons --- Fonts/Theme.tres | 1 + Main.tscn | 6 + components/Cursor/Cursor.tscn | 1 + components/Cursor/cursor.gd | 2 +- main.gd | 24 +++- parts/upgrades/more-creature-resources.txt | 6 + parts/upgrades/more-creatures.txt | 5 + parts/upgrades/more-customers.txt | 5 + parts/upgrades/more-resources.txt | 6 + parts/zones/desert.txt | 4 +- parts/zones/farm.txt | 4 +- parts/zones/forest.txt | 4 +- parts/zones/lake.txt | 4 +- project.godot | 2 +- small_wave.gd | 29 +++++ src/BuildWindow.tscn | 145 +++++++++++++++++++++ src/PauseWindow.tscn | 43 ++++++ src/UIButtons.tscn | 45 +++++++ src/Zone.tscn | 1 + src/build_window.gd | 52 ++++++++ src/buttons.gd | 7 + src/manager/time_manager.gd | 3 + src/pause.gd | 25 ++++ src/ui/MainUI.tscn | 70 ++++------ src/ui/action_button.gd | 14 +- src/ui/resume.aseprite | Bin 0 -> 379 bytes src/ui/resume.png | Bin 0 -> 146 bytes src/ui/resume.png.import | 34 +++++ src/ui/upgrade-close.aseprite | Bin 0 -> 406 bytes src/ui/upgrade-close.png | Bin 0 -> 176 bytes src/ui/upgrade-close.png.import | 34 +++++ src/zone.gd | 18 +++ 32 files changed, 533 insertions(+), 61 deletions(-) create mode 100644 parts/upgrades/more-creature-resources.txt create mode 100644 parts/upgrades/more-creatures.txt create mode 100644 parts/upgrades/more-customers.txt create mode 100644 parts/upgrades/more-resources.txt create mode 100644 small_wave.gd create mode 100644 src/BuildWindow.tscn create mode 100644 src/PauseWindow.tscn create mode 100644 src/UIButtons.tscn create mode 100644 src/build_window.gd create mode 100644 src/buttons.gd create mode 100644 src/pause.gd create mode 100644 src/ui/resume.aseprite create mode 100644 src/ui/resume.png create mode 100644 src/ui/resume.png.import create mode 100644 src/ui/upgrade-close.aseprite create mode 100644 src/ui/upgrade-close.png create mode 100644 src/ui/upgrade-close.png.import diff --git a/Fonts/Theme.tres b/Fonts/Theme.tres index 062fe31..97b39b7 100644 --- a/Fonts/Theme.tres +++ b/Fonts/Theme.tres @@ -5,5 +5,6 @@ [resource] default_font = ExtResource("1_y7uny") default_font_size = 8 +HBoxContainer/constants/separation = 37 RichTextLabel/colors/font_outline_color = Color(0, 0, 0, 1) RichTextLabel/constants/outline_size = 4 diff --git a/Main.tscn b/Main.tscn index 8a7da48..bb604ab 100644 --- a/Main.tscn +++ b/Main.tscn @@ -22,4 +22,10 @@ wait_time = 3.0 one_shot = true autostart = true +[node name="Timer2" type="Timer" parent="."] +wait_time = 3.0 +one_shot = true +autostart = true + [connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] +[connection signal="timeout" from="Timer2" to="." method="_on_timer_timeout"] diff --git a/components/Cursor/Cursor.tscn b/components/Cursor/Cursor.tscn index e30aae1..f3fd45e 100644 --- a/components/Cursor/Cursor.tscn +++ b/components/Cursor/Cursor.tscn @@ -17,6 +17,7 @@ input_pickable = false shape = SubResource("RectangleShape2D_4cq27") [node name="Sprite2D" type="Sprite2D" parent="MouseControl"] +visible = false position = Vector2(2, 4) texture = ExtResource("2_ucp64") diff --git a/components/Cursor/cursor.gd b/components/Cursor/cursor.gd index 8b78d11..ea68741 100644 --- a/components/Cursor/cursor.gd +++ b/components/Cursor/cursor.gd @@ -82,7 +82,7 @@ func _process(delta): _on_release() if Input.is_action_just_pressed("left_click"): _on_click() - Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) + #Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) mouse_control.position = mouse_control.get_global_mouse_position() if held_item: diff --git a/main.gd b/main.gd index 7efad57..1fa2f3d 100644 --- a/main.gd +++ b/main.gd @@ -4,12 +4,24 @@ extends Node2D const CURSOR = preload("res://components/Cursor/Cursor.tscn") const ZONE = preload("res://src/Zone.tscn") +const UI_BUTTONS = preload("res://src/UIButtons.tscn") +const PAUSE_WINDOW = preload("res://src/PauseWindow.tscn") +const BUILD_WINDOW = preload("res://src/BuildWindow.tscn") + +var build_object func _ready() -> void: Triggerer.listen("spawn_window", _on_spawn_window) + Triggerer.listen("upgrade_menu", _on_build_menu) Triggerer.listen("quit", _on_quit) DisplayServer.window_set_title("Home") get_viewport().transparent_bg = true + DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_MOUSE_PASSTHROUGH, true) + + var new_buttons = UI_BUTTONS.instantiate() + var new_cursor = CURSOR.instantiate() + new_buttons.add_child(new_cursor) + add_child(new_buttons) func _process(delta: float) -> void: @@ -23,7 +35,6 @@ func _on_spawn_window(data) -> void: var new_window = ZONE.instantiate() new_window.key = data.key new_window.size = Vector2(int(zone.size[0]) * 12 * 4, int(zone.size[1]) * 12 * 4) - new_window.position = Vector2(int(zone.spawn_position[0]), int(zone.spawn_position[1])) var new_cursor = CURSOR.instantiate() new_window.add_child(new_cursor) @@ -36,3 +47,14 @@ func _on_timer_timeout() -> void: func _on_quit(_data) -> void: get_tree().quit() + + +func _on_build_menu(data): + if data.value: + var new_window = BUILD_WINDOW.instantiate() + var new_cursor = CURSOR.instantiate() + new_window.add_child(new_cursor) + add_child(new_window) + build_object = new_window + else: + build_object.queue_free() diff --git a/parts/upgrades/more-creature-resources.txt b/parts/upgrades/more-creature-resources.txt new file mode 100644 index 0000000..829b4b6 --- /dev/null +++ b/parts/upgrades/more-creature-resources.txt @@ -0,0 +1,6 @@ +name: Creature Resources +description: More chance for a creature to drop a resource every day +key: creature_resource_spawn_rate +type: percent +amount: 10 +cost: 10 diff --git a/parts/upgrades/more-creatures.txt b/parts/upgrades/more-creatures.txt new file mode 100644 index 0000000..7e6728b --- /dev/null +++ b/parts/upgrades/more-creatures.txt @@ -0,0 +1,5 @@ +name: Creature Bait +description: More creatures will wander onto your property every day +key: creature_amount +amount: 2 +cost: 15 diff --git a/parts/upgrades/more-customers.txt b/parts/upgrades/more-customers.txt new file mode 100644 index 0000000..3a4d8f3 --- /dev/null +++ b/parts/upgrades/more-customers.txt @@ -0,0 +1,5 @@ +name: Advertising +description: More customers will visit your shop every day +key: customer_amount +amount: 4 +cost: 12 diff --git a/parts/upgrades/more-resources.txt b/parts/upgrades/more-resources.txt new file mode 100644 index 0000000..cade028 --- /dev/null +++ b/parts/upgrades/more-resources.txt @@ -0,0 +1,6 @@ +name: More Resources +description: More chance for a resource to spawn in a zone every day +key: resource_spawn_rate +type: percent +amount: 10 +cost: 10 diff --git a/parts/zones/desert.txt b/parts/zones/desert.txt index d4e1ce1..affb109 100644 --- a/parts/zones/desert.txt +++ b/parts/zones/desert.txt @@ -1,7 +1,5 @@ name: Desert -spawn_position[] - 300 - 300 size[] 6 6 +description: Test diff --git a/parts/zones/farm.txt b/parts/zones/farm.txt index 8913982..056b7d4 100644 --- a/parts/zones/farm.txt +++ b/parts/zones/farm.txt @@ -1,7 +1,5 @@ name: Farm -spawn_position[] - 300 - 300 size[] 6 5 +description: Test diff --git a/parts/zones/forest.txt b/parts/zones/forest.txt index eae2012..f43a003 100644 --- a/parts/zones/forest.txt +++ b/parts/zones/forest.txt @@ -1,7 +1,5 @@ name: Forest -spawn_position[] - 300 - 300 size[] 5 6 +description: Test diff --git a/parts/zones/lake.txt b/parts/zones/lake.txt index 9fccfa8..1e560c0 100644 --- a/parts/zones/lake.txt +++ b/parts/zones/lake.txt @@ -1,7 +1,5 @@ name: Lake -spawn_position[] - 300 - 300 size[] 7 4 +description: Test diff --git a/project.godot b/project.godot index 6299970..6091fc3 100644 --- a/project.godot +++ b/project.godot @@ -21,7 +21,6 @@ Logger="*res://components/Logger/Logger.tscn" Data="*res://components/Data/Data.tscn" Triggerer="*res://components/Triggerer/Triggerer.tscn" Persister="*res://components/Persister/Persister.tscn" -Cursor="*res://components/Cursor/Cursor.tscn" Achievements="*res://components/Achievements/Achievements.tscn" Dialogue="*res://components/Dialogue/Dialogue.tscn" @@ -32,6 +31,7 @@ window/size/viewport_height=180 window/size/mode=3 window/size/resizable=false window/size/borderless=true +window/size/always_on_top=true window/size/transparent=true window/size/no_focus=true window/size/window_width_override=1248 diff --git a/small_wave.gd b/small_wave.gd new file mode 100644 index 0000000..bd749cf --- /dev/null +++ b/small_wave.gd @@ -0,0 +1,29 @@ +@tool +extends RichTextEffect +class_name SmallWaveEffect + +var bbcode = "smallwave" + +func _process_custom_fx(char_fx: CharFXTransform) -> bool: + var time = fmod(char_fx.elapsed_time * 8 - char_fx.relative_index + 100, 10) + var local_time = fmod(time, 1) + + if time < 1: + char_fx.offset = Vector2(0, -1 * (sin(local_time * PI))) + if time < 3 or time >= 8: + var color_time = local_time + if time >= 1 and time < 3: + color_time += 1 + if time >= 2 and time < 3: + color_time += 1 + if time >= 0 and time < 3: + color_time += 1 + if time >= 9 or time < 3: + color_time += 1 + + + char_fx.color.a = (sin(color_time / 5 * PI)) * 0.1 + 0.9 + else: + char_fx.color.a = 0.9 + + return true diff --git a/src/BuildWindow.tscn b/src/BuildWindow.tscn new file mode 100644 index 0000000..bcf2a67 --- /dev/null +++ b/src/BuildWindow.tscn @@ -0,0 +1,145 @@ +[gd_scene load_steps=5 format=3 uid="uid://b5gq1bw4bj56b"] + +[ext_resource type="Theme" uid="uid://ck7603ob4gflc" path="res://Fonts/Theme.tres" id="1_ta3q3"] +[ext_resource type="Script" path="res://src/build_window.gd" id="1_y8qy0"] +[ext_resource type="Script" path="res://small_wave.gd" id="3_0qyx5"] + +[sub_resource type="RichTextEffect" id="RichTextEffect_lhkb8"] +script = ExtResource("3_0qyx5") + +[node name="BuildWindow" type="Window"] +canvas_item_default_texture_filter = 0 +position = Vector2i(0, 36) +size = Vector2i(900, 500) +always_on_top = true +content_scale_factor = 4.0 + +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_ta3q3") +script = ExtResource("1_y8qy0") + +[node name="RichTextLabel" type="RichTextLabel" parent="Control"] +modulate = Color(0.559673, 1, 0.532353, 1) +clip_contents = false +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -20.0 +offset_top = 9.56 +offset_right = 20.0 +offset_bottom = 49.56 +grow_horizontal = 2 +bbcode_enabled = true +text = "[smallwave][center]Upgrades" +custom_effects = [SubResource("RichTextEffect_lhkb8")] + +[node name="RichTextLabel2" type="RichTextLabel" parent="Control"] +modulate = Color(0.633757, 0.633757, 0.633757, 1) +clip_contents = false +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -84.93 +offset_top = 105.945 +offset_right = 83.15 +offset_bottom = 145.945 +grow_horizontal = 2 +bbcode_enabled = true +text = "[center]Test Description" + +[node name="HBoxContainer" type="HBoxContainer" parent="Control"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = -20.0 +offset_right = 20.0 +offset_bottom = 20.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Upgrade" type="ColorRect" parent="Control/HBoxContainer"] +custom_minimum_size = Vector2(32, 40) +layout_mode = 2 + +[node name="Card1Title" type="RichTextLabel" parent="Control/HBoxContainer/Upgrade"] +clip_contents = false +layout_mode = 0 +offset_left = -22.885 +offset_top = -12.315 +offset_right = 55.925 +offset_bottom = 27.685 +bbcode_enabled = true +text = "[center]Test Title" + +[node name="Card1Cost" type="RichTextLabel" parent="Control/HBoxContainer/Upgrade"] +modulate = Color(1, 0.812823, 0.471338, 1) +clip_contents = false +layout_mode = 0 +offset_left = -22.43 +offset_top = 46.24 +offset_right = 56.38 +offset_bottom = 86.24 +bbcode_enabled = true +text = "[center]20G" + +[node name="Upgrade2" type="ColorRect" parent="Control/HBoxContainer"] +custom_minimum_size = Vector2(32, 40) +layout_mode = 2 + +[node name="Card2Title" type="RichTextLabel" parent="Control/HBoxContainer/Upgrade2"] +clip_contents = false +layout_mode = 0 +offset_left = -22.885 +offset_top = -12.315 +offset_right = 55.925 +offset_bottom = 27.685 +bbcode_enabled = true +text = "[center]Test Title" + +[node name="Card2Cost" type="RichTextLabel" parent="Control/HBoxContainer/Upgrade2"] +modulate = Color(1, 0.812823, 0.471338, 1) +clip_contents = false +layout_mode = 0 +offset_left = -22.43 +offset_top = 46.24 +offset_right = 56.38 +offset_bottom = 86.24 +bbcode_enabled = true +text = "[center]20G" + +[node name="Upgrade3" type="ColorRect" parent="Control/HBoxContainer"] +custom_minimum_size = Vector2(32, 40) +layout_mode = 2 + +[node name="ZoneTitle" type="RichTextLabel" parent="Control/HBoxContainer/Upgrade3"] +clip_contents = false +layout_mode = 0 +offset_left = -22.885 +offset_top = -12.315 +offset_right = 55.925 +offset_bottom = 27.685 +bbcode_enabled = true +text = "[center]Test Title" + +[node name="ZoneCost" type="RichTextLabel" parent="Control/HBoxContainer/Upgrade3"] +modulate = Color(1, 0.812823, 0.471338, 1) +clip_contents = false +layout_mode = 0 +offset_left = -22.43 +offset_top = 46.24 +offset_right = 56.38 +offset_bottom = 86.24 +bbcode_enabled = true +text = "[center]20G" diff --git a/src/PauseWindow.tscn b/src/PauseWindow.tscn new file mode 100644 index 0000000..e5f5f2d --- /dev/null +++ b/src/PauseWindow.tscn @@ -0,0 +1,43 @@ +[gd_scene load_steps=3 format=3 uid="uid://fqm81ew717o1"] + +[ext_resource type="Theme" uid="uid://ck7603ob4gflc" path="res://Fonts/Theme.tres" id="1_nkmbb"] +[ext_resource type="Script" path="res://src/pause.gd" id="2_h2gml"] + +[node name="PauseWindow" type="Window"] +transparent_bg = true +canvas_item_default_texture_filter = 0 +position = Vector2i(0, 36) +size = Vector2i(400, 50) +borderless = true +always_on_top = true +transparent = true +content_scale_factor = 5.0 + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="Control" type="Control" parent="CanvasLayer"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_nkmbb") +script = ExtResource("2_h2gml") + +[node name="RichTextLabel" type="RichTextLabel" parent="CanvasLayer/Control"] +clip_contents = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -60.0 +offset_top = -2.845 +offset_right = 60.0 +offset_bottom = 37.155 +grow_horizontal = 2 +grow_vertical = 2 +bbcode_enabled = true +text = "[center]Game Paused" diff --git a/src/UIButtons.tscn b/src/UIButtons.tscn new file mode 100644 index 0000000..daa1147 --- /dev/null +++ b/src/UIButtons.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=8 format=3 uid="uid://bqd2ulwe0bsrb"] + +[ext_resource type="Script" path="res://src/buttons.gd" id="1_rc6dx"] +[ext_resource type="PackedScene" uid="uid://br46gg7k10wt2" path="res://src/ui/ActionButton.tscn" id="1_ydcg5"] +[ext_resource type="Texture2D" uid="uid://ccvmfqybnygqp" path="res://src/ui/pause.png" id="2_n0s2l"] +[ext_resource type="Texture2D" uid="uid://d1h8n8h0to033" path="res://src/ui/upgrades.png" id="3_qishi"] +[ext_resource type="Texture2D" uid="uid://dwabjc45s6l27" path="res://src/ui/quit.png" id="4_6jhet"] +[ext_resource type="Texture2D" uid="uid://cblr2row5bl8c" path="res://src/ui/resume.png" id="4_n6ajx"] +[ext_resource type="Texture2D" uid="uid://dde40wino3goe" path="res://src/ui/upgrade-close.png" id="6_g4yuf"] + +[node name="UiButtons" type="Window"] +transparent_bg = true +canvas_item_default_texture_filter = 0 +size = Vector2i(100, 260) +borderless = true +always_on_top = true +transparent = true +content_scale_factor = 4.0 + +[node name="Node2D" type="Node2D" parent="."] +position = Vector2(-16.09, 0) +script = ExtResource("1_rc6dx") + +[node name="PauseButton" parent="Node2D" instance=ExtResource("1_ydcg5")] +position = Vector2(28, 13) +key = "paused" +value = "toggle" +image = ExtResource("2_n0s2l") +alt_image = ExtResource("4_n6ajx") +color = Color(0.991606, 1, 0.496144, 1) + +[node name="BuildButton" parent="Node2D" instance=ExtResource("1_ydcg5")] +position = Vector2(28, 32) +key = "upgrade_menu" +value = "toggle" +image = ExtResource("3_qishi") +alt_image = ExtResource("6_g4yuf") +color = Color(0.680476, 1, 0.652914, 1) + +[node name="QuitButton" parent="Node2D" instance=ExtResource("1_ydcg5")] +position = Vector2(28, 51) +key = "quit" +value = "value" +image = ExtResource("4_6jhet") +color = Color(1, 0.734185, 0.691036, 1) diff --git a/src/Zone.tscn b/src/Zone.tscn index 9f29208..ac1a13b 100644 --- a/src/Zone.tscn +++ b/src/Zone.tscn @@ -6,6 +6,7 @@ canvas_item_default_texture_filter = 0 position = Vector2i(0, 36) unresizable = true +always_on_top = true content_scale_mode = 1 content_scale_factor = 4.0 script = ExtResource("1_gihyf") diff --git a/src/build_window.gd b/src/build_window.gd new file mode 100644 index 0000000..76ff907 --- /dev/null +++ b/src/build_window.gd @@ -0,0 +1,52 @@ +extends Control + +var upgrade_pool = Data.data.upgrades.keys() +var zone_pool = Data.data.zones.keys() +var current_zone + +@onready var cards = [ + { + "title": $HBoxContainer/Upgrade/Card1Title, + "cost": $HBoxContainer/Upgrade/Card1Cost + }, + { + "title": $HBoxContainer/Upgrade2/Card2Title, + "cost": $HBoxContainer/Upgrade2/Card2Cost + }, + { + "title": $HBoxContainer/Upgrade3/ZoneTitle, + "cost": $HBoxContainer/Upgrade3/ZoneCost + } +] + +func _ready() -> void: + upgrade_pool.shuffle() + zone_pool.shuffle() + + var screen_size = DisplayServer.screen_get_size(0) + + get_window().position = DisplayServer.screen_get_position(0) + screen_size / 2 - Vector2i(450, 250) + _refresh_cards() + + +func _refresh_cards(): + for i in range(0, 3): + _update_card(i) + + +func _update_card(index): + var choice + var card_data + var cost + + if index == 2: + choice = zone_pool.pop_back() + card_data = Data.data.zones[choice] + cost = 20 + else: + choice = upgrade_pool.pop_back() + card_data = Data.data.upgrades[choice] + cost = card_data.cost + + cards[index].title.text = "[center]%s" % [card_data.name] + cards[index].cost.text = "[center]%d G" % [cost] diff --git a/src/buttons.gd b/src/buttons.gd new file mode 100644 index 0000000..1443096 --- /dev/null +++ b/src/buttons.gd @@ -0,0 +1,7 @@ +extends Node2D + + +func _ready() -> void: + var screen_size = DisplayServer.screen_get_size(0) + + get_window().position = Vector2i(screen_size.x - 100, 0) + DisplayServer.screen_get_position(0) diff --git a/src/manager/time_manager.gd b/src/manager/time_manager.gd index 1fb655e..50b7ef0 100644 --- a/src/manager/time_manager.gd +++ b/src/manager/time_manager.gd @@ -22,6 +22,9 @@ func _process(delta: float) -> void: delay -= delta return + if Persister.get_value("paused"): + return + time += delta Persister.persist_data("time", int(time * 1000)) diff --git a/src/pause.gd b/src/pause.gd new file mode 100644 index 0000000..4959062 --- /dev/null +++ b/src/pause.gd @@ -0,0 +1,25 @@ +extends Control + +@onready var rich_text_label: RichTextLabel = $RichTextLabel + +var tween + +func _ready() -> void: + rich_text_label.scale = Vector2.ZERO + Triggerer.listen("paused", _on_paused) + + +func _on_paused(data): + if tween: + tween.kill() + + tween = create_tween() + + if data.value: + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_BACK) + tween.tween_property(rich_text_label, "scale", Vector2.ONE, 0.25) + else: + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_QUAD) + tween.tween_property(rich_text_label, "scale", Vector2.ZERO, 0.125) diff --git a/src/ui/MainUI.tscn b/src/ui/MainUI.tscn index f1b8121..7775d8b 100644 --- a/src/ui/MainUI.tscn +++ b/src/ui/MainUI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=3 uid="uid://ccdhbljb3e0oh"] +[gd_scene load_steps=10 format=3 uid="uid://ccdhbljb3e0oh"] [ext_resource type="Theme" uid="uid://ck7603ob4gflc" path="res://Fonts/Theme.tres" id="1_k6a0m"] [ext_resource type="Texture2D" uid="uid://ca5dpjaoimrej" path="res://src/ui/top-left.png" id="2_nvcj5"] @@ -6,12 +6,11 @@ [ext_resource type="Script" path="res://src/ui/day_text.gd" id="3_k76r2"] [ext_resource type="Script" path="res://src/ui/time_text.gd" id="4_7xwp1"] [ext_resource type="Script" path="res://src/ui/gold_text.gd" id="5_uk4d4"] -[ext_resource type="PackedScene" uid="uid://br46gg7k10wt2" path="res://src/ui/ActionButton.tscn" id="7_gchpm"] -[ext_resource type="Script" path="res://src/ui/pause_menu.gd" id="8_bnf8a"] -[ext_resource type="Texture2D" uid="uid://ccvmfqybnygqp" path="res://src/ui/pause.png" id="8_vlg72"] -[ext_resource type="Texture2D" uid="uid://dwabjc45s6l27" path="res://src/ui/quit.png" id="8_ytenc"] -[ext_resource type="Texture2D" uid="uid://d1h8n8h0to033" path="res://src/ui/upgrades.png" id="9_5s7ww"] -[ext_resource type="PackedScene" uid="uid://b782aedv3v7df" path="res://src/ui/TextActionButton.tscn" id="9_pynn5"] +[ext_resource type="Script" path="res://src/pause.gd" id="7_gi2gs"] +[ext_resource type="Script" path="res://small_wave.gd" id="8_88rs2"] + +[sub_resource type="RichTextEffect" id="RichTextEffect_a7xgu"] +script = ExtResource("8_88rs2") [node name="CanvasLayer" type="CanvasLayer"] @@ -98,47 +97,28 @@ offset_left = -40.0 offset_bottom = 40.0 grow_horizontal = 0 -[node name="PauseButton" parent="Control/TopRight" instance=ExtResource("7_gchpm")] -position = Vector2(28, 13) -key = "paused" -value = "true" -image = ExtResource("8_vlg72") -color = Color(0.991606, 1, 0.496144, 1) - -[node name="BuildButton" parent="Control/TopRight" instance=ExtResource("7_gchpm")] -position = Vector2(28, 32) -key = "upgrade_menu" -value = "true" -image = ExtResource("9_5s7ww") -color = Color(0.680476, 1, 0.652914, 1) - -[node name="QuitButton" parent="Control/TopRight" instance=ExtResource("7_gchpm")] -position = Vector2(28, 51) -key = "quit" -value = "value" -image = ExtResource("8_ytenc") -color = Color(1, 0.734185, 0.691036, 1) - -[node name="PauseMenu" type="Control" parent="."] -visible = false -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("8_bnf8a") - -[node name="ActionButton" parent="PauseMenu" instance=ExtResource("9_pynn5")] -position = Vector2(160, 96) -key = "paused" -value = "false" - -[node name="ColorRect" type="ColorRect" parent="PauseMenu"] +[node name="PauseText" type="Control" parent="Control"] layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -color = Color(0, 0, 0, 0.458824) +theme = ExtResource("1_k6a0m") +script = ExtResource("7_gi2gs") + +[node name="RichTextLabel" type="RichTextLabel" parent="Control/PauseText"] +clip_contents = false +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -124.0 +offset_top = 9.0 +offset_right = -4.0 +offset_bottom = 49.0 +grow_horizontal = 0 +pivot_offset = Vector2(58, 4) +bbcode_enabled = true +text = "[center][smallwave]Game Paused" +custom_effects = [SubResource("RichTextEffect_a7xgu")] diff --git a/src/ui/action_button.gd b/src/ui/action_button.gd index 132d7fe..312a37e 100644 --- a/src/ui/action_button.gd +++ b/src/ui/action_button.gd @@ -2,6 +2,7 @@ extends Node2D @export var key: String @export var value: String @export var image: Texture2D +@export var alt_image: Texture2D @export var color: Color var size_tween @@ -12,7 +13,18 @@ func _ready() -> void: sprite_2d.texture = image func _on_mouse_handler_clicked() -> void: - Persister.persist_data(key, value) + if value == "toggle": + var old_value = Persister.get_value(key) + + Persister.persist_data(key, not old_value) + + if alt_image: + if old_value: + sprite_2d.texture = image + else: + sprite_2d.texture = alt_image + else: + Persister.persist_data(key, value) func _on_mouse_handler_hovered() -> void: diff --git a/src/ui/resume.aseprite b/src/ui/resume.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..175aec9910051c42d96c23b5181668a444ddf199 GIT binary patch literal 379 zcmb<sWMFu(l#zi42o)HB9EKDiMgX7~NRUAQ2x$R+0}cK4kp*lk3y>`a#Ow-SE0L_r z0<u{^u2TRqloU){HEhx>4g15a?-#1wT#)we@T}jT%w|3f$l7OMJ|)jPQ$NUC#mL6e z-oC^jp(#4=Ve;(%@n@f$zWwL_|NpbsZf~h;&&<k-3=1lA>RMxDbTd5pdiAdU>0Vv= z2J#@A6qtb|4EzT&*cp5hD^rUU41ItcRs{y2Qy3ZkGr^Q_F>o<d%t=m2_;J4Bz>fp< s0tpIh{@EKHSp3i4tijbbtn|i};6;5C_O|?S^w}XWft{Iw@!;ZE0R6U6xc~qF literal 0 HcmV?d00001 diff --git a/src/ui/resume.png b/src/ui/resume.png new file mode 100644 index 0000000000000000000000000000000000000000..9b5c685cdb10ed40f37b0156cfa68a48bc661010 GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}KAtX)AsQ2> zPITmAP~cz*{qukNcJJ03YF5(^m7VcO>3Ao)#BJkd#&ykC8tx0Q1cpxg$vrj0UyDJZ sKZ=`YJ>N}_kQH)o?<VMNv(G!j^tn(>eAO*}cc8fpp00i_>zopr0K(!gnE(I) literal 0 HcmV?d00001 diff --git a/src/ui/resume.png.import b/src/ui/resume.png.import new file mode 100644 index 0000000..732506c --- /dev/null +++ b/src/ui/resume.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cblr2row5bl8c" +path="res://.godot/imported/resume.png-6ef6a5626dfa8f2343a1da8519f8b7aa.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/ui/resume.png" +dest_files=["res://.godot/imported/resume.png-6ef6a5626dfa8f2343a1da8519f8b7aa.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/src/ui/upgrade-close.aseprite b/src/ui/upgrade-close.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..82ec5cba524afa6c7b98ed247158fe13c77e6c92 GIT binary patch literal 406 zcmbQn$iVPmDI)_95GpVLISeU4i~v9}kRXEq5YhsO0Zsq)kp*lk3(x{FAZAwpTZv>{ z7Ld&Xa-9N@p`>8qs$r96Y1kiTeZNrc=7O|$hiCo%WH$3@K-NA3^C@}WnfgKADn>Sz z_Vy(P2~E*?50hvAk3ak5^zA?Y|No!8c6&=*duCQvWLQv{Q`Z_JqnqK$*Q<B+PxtD| zH;@O}q`(X$Vc<WI!Oq~5SeaU+V3-c%uqr^L{xd;n25{h2%xRq%$i<+*;and4zP{^g zXpiOFMwcJc0uMBMYpz}2!V~ElYnwgu*{sFCEB-w?zN_|Y4x5^JihKF)^ACPiKYpyX RZGUIo49g-0hMRl-0svIJU_<}_ literal 0 HcmV?d00001 diff --git a/src/ui/upgrade-close.png b/src/ui/upgrade-close.png new file mode 100644 index 0000000000000000000000000000000000000000..8b69c10d0e203868d122e6d27db67c82b6198e17 GIT binary patch literal 176 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}S)MMAAsQ1) zCkFBzP~dQm)<5;v|6(oA*1Ty)B2GGM3R$<vlze1fI#-EbjF};X^}gr2)T8YaR&Dv> zefQj5$HUp@S-a%YtS=wFviPjQK|2Qd>6gyVv-d5ZKmT9iEuZus;>tFst?T~3<X}F) YEGALdxb6-YKhRbNPgg&ebxsLQ0OM&tLjV8( literal 0 HcmV?d00001 diff --git a/src/ui/upgrade-close.png.import b/src/ui/upgrade-close.png.import new file mode 100644 index 0000000..6074556 --- /dev/null +++ b/src/ui/upgrade-close.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dde40wino3goe" +path="res://.godot/imported/upgrade-close.png-5524d429469fc4cb06662fa5943d80a6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/ui/upgrade-close.png" +dest_files=["res://.godot/imported/upgrade-close.png-5524d429469fc4cb06662fa5943d80a6.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/src/zone.gd b/src/zone.gd index b1e33ac..d44526d 100644 --- a/src/zone.gd +++ b/src/zone.gd @@ -10,6 +10,10 @@ var key const CREATURE = preload("res://src/Creature.tscn") func _ready() -> void: + var window_size = get_tree().root.get_window().size + + get_window().position = Vector2i(randi_range(250, window_size.x - 250 - 200), randi_range(250, window_size.y - 250 - 200)) + DisplayServer.screen_get_position(0) + title = data.name sprite_2d.texture = image sprite_2d.position = Vector2(int(data.size[0]) * 12 / 2, int(data.size[1]) * 12 / 2) @@ -18,3 +22,17 @@ func _ready() -> void: new_creature.position = Vector2(50, 50) new_creature.key = "1x1-1" add_child(new_creature) + + +# +#New Zones +# +#- Get More Customers +#- Creatures drop resources more often +#- Resources randomly spawn more often +#- More wild creatures spawn +#- Closing time is 10 minutes later +#- More chance for creatures to drop a large amount at once +#- Customers are willing to pay more +#- Less chance of thieves +#- Chance for rich customer