Skip to content

Commit

Permalink
Jake UI updates (#27)
Browse files Browse the repository at this point in the history
* Exit Button

functional exit button, early skeleton of showing the values of prompts

* Temp Changes

my json file/dialogue stuff isn't fully updated, pushing this for stability

* Context Values Functional

Context values update as you collect more fruits

* Developer Mode Basics

Made the updating hud only accessible under developer mode.

* Dev Mode

added the ability to see hitboxes, and fixed issue with the toggle button

* Added more mobs

for sillies
  • Loading branch information
mcnerv authored Dec 5, 2023
1 parent 2b265a2 commit 6b200e3
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 16 deletions.
1 change: 1 addition & 0 deletions DialogueManager/DialogueDatabase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var fruits_collected = 0
@export var rainState = 0
@export var numOfFruits = 50
@export var fruits = [apple, watermelon, banana]
@export var developer_mode = 0

func _init():
load_dialogues()
Expand Down
22 changes: 19 additions & 3 deletions Scenes/Cave.tscn
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[gd_scene load_steps=10 format=3 uid="uid://m2hetha383la"]
[gd_scene load_steps=13 format=3 uid="uid://m2hetha383la"]

[ext_resource type="Script" path="res://Scenes/Global.gd" id="1_8mbyw"]
[ext_resource type="Texture2D" uid="uid://rmyte122fvng" path="res://Assets/tiles.png" id="1_pp2yt"]
[ext_resource type="PackedScene" uid="uid://culk7qt4b4ddq" path="res://Scenes/Player/player.tscn" id="2_gfx07"]
[ext_resource type="PackedScene" uid="uid://hcdtajw7vlmj" path="res://Scenes/Portal.tscn" id="3_kva1f"]
[ext_resource type="Script" path="res://Scenes/CaveFruitSpawn.gd" id="3_m88q7"]
[ext_resource type="PackedScene" uid="uid://cl3pe88eyrurq" path="res://Scenes/PromptInput.tscn" id="5_ugwpr"]
[ext_resource type="PackedScene" uid="uid://bxx5taw2bblgt" path="res://Scenes/Mobs/Ghost/ghost.tscn" id="7_68r0u"]
[ext_resource type="PackedScene" uid="uid://dga31it1rxr3q" path="res://Scenes/Mobs/Slime/Bat.tscn" id="7_purr7"]
[ext_resource type="PackedScene" uid="uid://cvhu1xm2ecqne" path="res://Scenes/ShowDialogueHUD.tscn" id="8_ig5lf"]
[ext_resource type="PackedScene" uid="uid://c7di5npf3casw" path="res://Scenes/UI/ExitGameButton.tscn" id="9_jxfd6"]

[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ncpbu"]
texture = ExtResource("1_pp2yt")
Expand Down Expand Up @@ -391,7 +394,20 @@ next_scene_path = "res://Scenes/main.tscn"
player_spawn_location = Vector2(391, 54)
player_direction_facing = Vector2(0, -1)

[node name="PromptInput" parent="." instance=ExtResource("5_ugwpr")]

[node name="Bat" parent="." instance=ExtResource("7_purr7")]
position = Vector2(129, -64)

[node name="Bat2" parent="." instance=ExtResource("7_purr7")]
position = Vector2(457, -61)

[node name="ghost" parent="." instance=ExtResource("7_68r0u")]
position = Vector2(423, -5)

[node name="ghost2" parent="." instance=ExtResource("7_68r0u")]
position = Vector2(422, -116)

[node name="ShowDialogueHUD" parent="." instance=ExtResource("8_ig5lf")]

[node name="ExitGameButton" parent="." instance=ExtResource("9_jxfd6")]

[node name="PromptInput" parent="." instance=ExtResource("5_ugwpr")]
13 changes: 7 additions & 6 deletions Scenes/CaveFruitSpawn.gd
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
extends TileMap

#same code as TileMap.gd, just wanted to change coords for where the fruits spawn

var apple = preload("res://Scenes/Objects/apple.tscn")
var watermelon = preload("res://Scenes/Objects/watermelon.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
spawn(10)
var fruits = DialogueDatabase
print("NUMBER OF FRUITS SPAWNED IN THIS INSTANCE: ", fruits.getNumOfFruits())
spawn(fruits.getNumOfFruits())
pass

# Called every frame. 'delta' is the elapsed time since the previous frame.
# x = number of object instances to spawn
# x = number of object instances to spaw
func spawn(x):
while (x != 0):
randomize()
var fruits = [apple, watermelon]
var database = DialogueDatabase
var fruits = database.fruits
var kinds = fruits[randi()% fruits.size()]
var fruit = kinds.instantiate()
fruit.position = Vector2(randi_range(180,350), randi_range(16, -150))
Expand Down
1 change: 1 addition & 0 deletions Scenes/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ extends Node
var player_map_position = Vector2(200,150)
#this would be used if we want character to face a specific direction leaving the portals
var player_facing = Vector2(0,0)

21 changes: 21 additions & 0 deletions Scenes/ShowDialogueHUD.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends Label

var JSON_URL = "res://DialogueManager/dialogues.json"

#sets the rain state right away, doesn't need to be constantly updated
func _ready():
if(DialogueDatabase.rainState == 0):
$RainState.text = str("No Rain")
elif(DialogueDatabase.rainState == 1):
$RainState.text = str("Light Rain")
else:
$RainState.text = str("Heavy Rain")
# Called every frame. 'delta' is the elapsed time since the previous frame.
# using this to have a constant update to the values as I do not fully know how to update only when a prompt is changed
func _process(delta):
$Health.text = str(DialogueManager.game_context["health"])
$Hunger.text = str(DialogueManager.game_context["hunger"])
$TotalApple.text = str(DialogueManager.game_context["total_apple"])
$TotalBanana.text = str(DialogueManager.game_context["total_banana"])
$TotalWatermelon.text = str(DialogueManager.game_context["total_watermelon"])

119 changes: 119 additions & 0 deletions Scenes/ShowDialogueHUD.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
[gd_scene load_steps=4 format=3 uid="uid://cvhu1xm2ecqne"]

[ext_resource type="Script" path="res://Scenes/ShowDialogueHUD.gd" id="1_prukx"]
[ext_resource type="FontFile" uid="uid://dg5ck0bgmm7yp" path="res://Assets/PixelifySans-Regular.ttf" id="1_sw1ca"]
[ext_resource type="Script" path="res://Scenes/ShowHud.gd" id="1_vg2at"]

[node name="ShowDialogueHUD" type="CanvasLayer"]
script = ExtResource("1_vg2at")

[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = -1
anchor_right = 0.224
anchor_bottom = 0.292
offset_right = -0.0160065
offset_bottom = -0.0720062
color = Color(1, 1, 1, 0.313726)

[node name="NamesOfContexts" type="Label" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -299.0
offset_bottom = -150.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 7
text = "hunger:
health:
total_apple:
total_banana:
total_watermelon:
rain_state:"
autowrap_mode = 2
script = ExtResource("1_prukx")

[node name="Hunger" type="Label" parent="NamesOfContexts"]
layout_mode = 1
anchors_preset = -1
anchor_right = 4.518
anchor_bottom = 3.273
offset_left = 28.0
offset_right = -299.03
offset_bottom = -205.018
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 7
text = "0"
autowrap_mode = 2

[node name="Health" type="Label" parent="NamesOfContexts"]
layout_mode = 1
anchors_preset = -1
anchor_right = 4.518
anchor_bottom = 3.273
offset_left = 26.0
offset_top = 11.0
offset_right = -299.03
offset_bottom = -183.018
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 7
text = "0
"

[node name="TotalApple" type="Label" parent="NamesOfContexts"]
layout_mode = 1
anchors_preset = -1
anchor_right = 4.518
anchor_bottom = 3.273
offset_left = 45.0
offset_top = 21.0
offset_right = -299.03
offset_bottom = -174.018
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 6
text = "0"

[node name="TotalBanana" type="Label" parent="NamesOfContexts"]
layout_mode = 1
anchors_preset = -1
anchor_right = 4.518
anchor_bottom = 3.273
offset_left = 51.0
offset_top = 31.0
offset_right = -299.637
offset_bottom = -163.018
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 7
text = "0"

[node name="TotalWatermelon" type="Label" parent="NamesOfContexts"]
layout_mode = 1
anchors_preset = -1
anchor_right = 4.518
anchor_bottom = 3.273
offset_left = 66.0
offset_top = 42.0
offset_right = -299.03
offset_bottom = -163.018
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 7
text = "0"

[node name="RainState" type="Label" parent="NamesOfContexts"]
layout_mode = 1
anchors_preset = -1
anchor_right = 4.518
anchor_bottom = 3.273
offset_left = 41.0
offset_top = 51.0
offset_right = -301.03
offset_bottom = -154.018
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_sw1ca")
theme_override_font_sizes/font_size = 7
text = "0"
7 changes: 7 additions & 0 deletions Scenes/ShowHud.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends CanvasLayer


# Called when the node enters the scene tree for the first time.
func _ready():
if(DialogueDatabase.developer_mode != 1):
hide()
5 changes: 5 additions & 0 deletions Scenes/UI/ExitGameButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends CanvasLayer

#pretty self explanitory(quits code)
func _on_button_pressed():
get_tree().quit()
22 changes: 22 additions & 0 deletions Scenes/UI/ExitGameButton.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[gd_scene load_steps=3 format=3 uid="uid://c7di5npf3casw"]

[ext_resource type="Script" path="res://Scenes/UI/ExitGameButton.gd" id="1_ajcr2"]
[ext_resource type="FontFile" uid="uid://dg5ck0bgmm7yp" path="res://Assets/PixelifySans-Regular.ttf" id="1_dd0oi"]

[node name="ExitGameButton" type="CanvasLayer"]
script = ExtResource("1_ajcr2")

[node name="Button" type="Button" parent="."]
anchors_preset = -1
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 335.0
offset_top = 199.0
offset_right = -1.0
offset_bottom = -1.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("1_dd0oi")
theme_override_font_sizes/font_size = 7
text = "CLOSE GAME"

[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
8 changes: 4 additions & 4 deletions Scenes/UI/Options.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 10.0
offset_top = 10.0
offset_right = 10.0
offset_bottom = 10.0
offset_left = 3.0
offset_top = 6.0
offset_right = 3.0
offset_bottom = 6.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_goqlf")
Expand Down
12 changes: 10 additions & 2 deletions Scenes/UI/mainMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ extends Control

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
pass

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass



#PLAY BUTTON
func _on_play_pressed():
get_tree().change_scene_to_file("res://Scenes/main.tscn")
Expand All @@ -28,3 +27,12 @@ func _on_exit_pressed():
#LINK BUTTON
func _on_link_button_pressed():
OS.shell_open("https://github.com/Godot-Dynamic-Dialog/GodotDynamicDialog")

#dev mode
func _on_check_button_toggled(button_pressed):
if(button_pressed):
DialogueDatabase.developer_mode = 1
get_tree().set_debug_collisions_hint(true)
else:
DialogueDatabase.developer_mode = 0
get_tree().set_debug_collisions_hint(false)
3 changes: 3 additions & 0 deletions Scenes/UI/mainMenu.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 3.0
offset_bottom = 3.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_i7ne0")
Expand Down Expand Up @@ -153,4 +155,5 @@ uri = "https://github.com/Godot-Dynamic-Dialog/GodotDynamicDialog"
[connection signal="tree_exiting" from="VBoxContainer/VBoxContainer/Options" to="VBoxContainer/VBoxContainer/Options" method="_on_tree_exiting"]
[connection signal="pressed" from="VBoxContainer/VBoxContainer/Exit" to="." method="_on_exit_pressed"]
[connection signal="pressed" from="VBoxContainer/VBoxContainer/Exit" to="VBoxContainer/VBoxContainer/Exit" method="_on_pressed"]
[connection signal="toggled" from="VBoxContainer/VBoxContainer/CheckButton" to="." method="_on_check_button_toggled"]
[connection signal="pressed" from="CenterContainer/LinkButton" to="." method="_on_link_button_pressed"]
8 changes: 7 additions & 1 deletion Scenes/main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://c4lhqu3mr88aq"]
[gd_scene load_steps=24 format=3 uid="uid://c4lhqu3mr88aq"]

[ext_resource type="Script" path="res://Scenes/Global.gd" id="1_xba4t"]
[ext_resource type="PackedScene" uid="uid://cl3pe88eyrurq" path="res://Scenes/PromptInput.tscn" id="2_ieakw"]
Expand All @@ -18,6 +18,8 @@
[ext_resource type="Script" path="res://Scenes/Weather/HeavyRain.gd" id="16_llvw4"]
[ext_resource type="PackedScene" uid="uid://lcvbg5jnamtj" path="res://Scenes/Objects/watermelon.tscn" id="16_tqygu"]
[ext_resource type="PackedScene" uid="uid://bt81ja7c3kxxw" path="res://Scenes/Objects/banana.tscn" id="17_y71rb"]
[ext_resource type="PackedScene" uid="uid://cvhu1xm2ecqne" path="res://Scenes/ShowDialogueHUD.tscn" id="19_qcixd"]
[ext_resource type="PackedScene" uid="uid://c7di5npf3casw" path="res://Scenes/UI/ExitGameButton.tscn" id="20_ojuqt"]

[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_7w0kc"]
texture = ExtResource("2_ih2nm")
Expand Down Expand Up @@ -421,6 +423,10 @@ position = Vector2(80, 232)
[node name="banana" parent="." instance=ExtResource("17_y71rb")]
position = Vector2(128, 232)

[node name="ShowDialogueHUD" parent="." instance=ExtResource("19_qcixd")]

[node name="ExitGameButton" parent="." instance=ExtResource("20_ojuqt")]

[node name="PromptInput" parent="." instance=ExtResource("2_ieakw")]

[connection signal="hidden" from="MainRain" to="MainRain" method="_on_hidden"]
Expand Down

0 comments on commit 6b200e3

Please sign in to comment.