restructured folders

This commit is contained in:
Luca 2024-09-26 20:07:44 +02:00
parent e3aec75404
commit 0f5045dc22
22 changed files with 32 additions and 21 deletions

38
ui/camera_controls.gd Normal file
View file

@ -0,0 +1,38 @@
extends Control
var pressed: bool = false
var previous_position : Vector2 = Vector2.ZERO
var speed : float = 0.04
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _gui_input(event: InputEvent) -> void:
# Filter touch or drag events only.
if event is not InputEventScreenTouch and event is not InputEventScreenDrag:
return
if event is InputEventScreenTouch:
if event.is_pressed():
pressed = true
else:
pressed = false
simulate_joystick_motion(JOY_AXIS_RIGHT_X, 0, 0)
if pressed and event is InputEventScreenDrag:
var delta_position : Vector2 = event.position - previous_position
print(delta_position)
simulate_joystick_motion(JOY_AXIS_RIGHT_X, -delta_position.x * speed, 0)
#simulate_joystick_motion(JOY_AXIS_RIGHT_Y, delta_position.y * speed, 0)
# finally update the previous position
previous_position = event.position
func simulate_joystick_motion(axis: int, value: float, device_id: int = 0) -> void:
var joystick_event = InputEventJoypadMotion.new()
joystick_event.device = device_id
joystick_event.axis = axis # Axis index (e.g., 0 for X-axis, 1 for Y-axis)
joystick_event.axis_value = value # Value of the axis, typically between -1 and 1
Input.parse_input_event(joystick_event) # Process the event

53
ui/ingame_controls.gd Normal file
View file

@ -0,0 +1,53 @@
extends MarginContainer
class_name IngameControls
signal menu_button_clicked
signal settings_button_clicked
signal save_button_clicked
signal save_button_released
signal save_timer_incremented(value: int)
signal save_timer_reached
var save_button_held_down: bool = false
var save_timer: float = 0.0
var time_to_save: float = 0.8 # second
func _process(delta) -> void:
if save_button_held_down:
if save_timer >= time_to_save:
save_timer_reached.emit()
save_timer = 0.0
# Save the game
SaveGame.save()
save_button_held_down = false
else:
save_timer_incremented.emit(ceili((save_timer / time_to_save) * 100))
save_timer += delta
func _on_menu_button_pressed() -> void:
menu_button_clicked.emit()
func _on_settings_button_pressed() -> void:
settings_button_clicked.emit()
# the save function should work as follows:
# a percentage sign with 0% should be shown
# the player has to hold down the save button
# during holding down, the percentage increases until 100%
# a finishing animation plays, the game is saved and the countdown disappears again
func _on_save_button_button_down() -> void:
save_button_held_down = true
save_button_clicked.emit()
func _on_save_button_button_up() -> void:
save_button_held_down = false
save_button_released.emit()
save_timer = 0.0
func disable_save_button() -> void:
%SaveButton.disabled = true
func enable_save_button() -> void:
%SaveButton.disabled = false

116
ui/ingame_controls.tscn Normal file
View file

@ -0,0 +1,116 @@
[gd_scene load_steps=11 format=3 uid="uid://1anjhvi173g3"]
[ext_resource type="Script" path="res://ui/ingame_controls.gd" id="1_iw1sp"]
[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="1_wr5sh"]
[ext_resource type="Script" path="res://ui/joystick.gd" id="2_pyri2"]
[ext_resource type="Texture2D" uid="uid://8anyvhkcy4ng" path="res://assets/textures/Xbox Series/Vector/xbox_button_a.svg" id="3_lgi8v"]
[ext_resource type="Texture2D" uid="uid://cbep021ykpb23" path="res://assets/textures/Game Icons/Vector/2x/save.png" id="5_2pil1"]
[ext_resource type="Texture2D" uid="uid://bwyoxxotdisyp" path="res://assets/textures/Game Icons/Vector/2x/gear.png" id="5_nwwsc"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_uoef2"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nfkty"]
bg_color = Color(0, 0, 0, 0.196078)
corner_radius_top_left = 999
corner_radius_top_right = 999
corner_radius_bottom_right = 999
corner_radius_bottom_left = 999
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_hfsbq"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_x4icw"]
[node name="IngameControls" type="MarginContainer"]
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -338.0
grow_horizontal = 2
grow_vertical = 0
size_flags_vertical = 8
theme_override_constants/margin_left = 30
theme_override_constants/margin_right = 30
theme_override_constants/margin_bottom = 30
script = ExtResource("1_iw1sp")
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
size_flags_vertical = 8
alignment = 2
[node name="Left" type="VBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/separation = 8
alignment = 2
[node name="MenuButton" type="Button" parent="HBoxContainer/Left"]
self_modulate = Color(0, 0, 0, 0.392157)
custom_minimum_size = Vector2(120, 120)
layout_mode = 2
size_flags_horizontal = 0
theme_override_styles/focus = SubResource("StyleBoxEmpty_uoef2")
icon = ExtResource("1_wr5sh")
flat = true
expand_icon = true
[node name="JoystickPanel" type="Panel" parent="HBoxContainer/Left"]
custom_minimum_size = Vector2(180, 180)
layout_mode = 2
size_flags_horizontal = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_nfkty")
script = ExtResource("2_pyri2")
[node name="Thumbstick" type="TextureRect" parent="HBoxContainer/Left/JoystickPanel"]
self_modulate = Color(0, 0, 0, 0.392157)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -65.0
offset_top = -65.0
offset_right = 65.0
offset_bottom = 65.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("3_lgi8v")
expand_mode = 3
stretch_mode = 5
[node name="Right" type="VBoxContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_vertical = 8
theme_override_constants/separation = 0
alignment = 2
[node name="SaveButton" type="Button" parent="HBoxContainer/Right"]
unique_name_in_owner = true
self_modulate = Color(0, 0, 0, 0.392157)
custom_minimum_size = Vector2(120, 120)
layout_mode = 2
theme_override_styles/focus = SubResource("StyleBoxEmpty_hfsbq")
icon = ExtResource("5_2pil1")
flat = true
icon_alignment = 1
expand_icon = true
[node name="SettingsButton" type="Button" parent="HBoxContainer/Right"]
self_modulate = Color(0, 0, 0, 0.392157)
custom_minimum_size = Vector2(120, 120)
layout_mode = 2
theme_override_styles/focus = SubResource("StyleBoxEmpty_x4icw")
icon = ExtResource("5_nwwsc")
flat = true
icon_alignment = 1
expand_icon = true
[connection signal="pressed" from="HBoxContainer/Left/MenuButton" to="." method="_on_menu_button_pressed"]
[connection signal="gui_input" from="HBoxContainer/Left/JoystickPanel" to="HBoxContainer/Left/JoystickPanel" method="_on_gui_input"]
[connection signal="resized" from="HBoxContainer/Left/JoystickPanel" to="HBoxContainer/Left/JoystickPanel" method="_on_resized"]
[connection signal="button_down" from="HBoxContainer/Right/SaveButton" to="." method="_on_save_button_button_down"]
[connection signal="button_up" from="HBoxContainer/Right/SaveButton" to="." method="_on_save_button_button_up"]
[connection signal="pressed" from="HBoxContainer/Right/SettingsButton" to="." method="_on_settings_button_pressed"]

27
ui/ingame_menu.gd Normal file
View file

@ -0,0 +1,27 @@
extends MarginContainer
class_name MonsterList
@onready var monster_list_entry_container: MarginContainer = $MarginContainer/PanelContainer/VBoxContainer/MonsterListEntryContainer
@onready var monster_list_entry = preload("res://ui/monster_list_entry.tscn")
func _ready() -> void:
visible = false
func _on_close_button_pressed() -> void:
visible = false
pass # Replace with function body.
func _update_monster_list() -> void:
for i in SaveData.monsters.size():
var monster = SaveData.monsters[i]
var entry = monster_list_entry.instantiate()
# populate the new entry
entry.populate(SaveData.monsters[i])
# add it to the list
monster_list_entry_container.add_child(entry)
func _update_player_info() -> void:
#%PlayerName.text =
pass

113
ui/ingame_menu.tscn Normal file
View file

@ -0,0 +1,113 @@
[gd_scene load_steps=8 format=3 uid="uid://bbvbnrcjatkrb"]
[ext_resource type="Script" path="res://ui/ingame_menu.gd" id="1_beinb"]
[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_1e4kf"]
[ext_resource type="Texture2D" uid="uid://bhh31i3wgww43" path="res://assets/textures/Game Icons/Vector/2x/singleplayer.png" id="2_c2ia0"]
[ext_resource type="Texture2D" uid="uid://c737p2osplq2o" path="res://assets/textures/Xbox Series/Vector/xbox_button_x_outline.svg" id="3_kgfth"]
[ext_resource type="Texture2D" uid="uid://cxry7h4q17lir" path="res://assets/textures/Game Icons/Vector/2x/star.png" id="3_oo4iu"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_co4a0"]
bg_color = Color(0.9, 0.9, 0.9, 1)
corner_radius_top_left = 64
corner_radius_top_right = 64
corner_radius_bottom_right = 64
corner_radius_bottom_left = 64
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_flvbu"]
[node name="IngameMenu" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_beinb")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 2
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 50
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50
[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"]
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_co4a0")
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"]
layout_mode = 2
[node name="PlayerInfo" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 40
theme_override_constants/margin_top = 30
theme_override_constants/margin_right = 40
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo"]
layout_mode = 2
[node name="PlayerThumbnail" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
self_modulate = Color(0, 0, 0, 1)
layout_mode = 2
texture = ExtResource("2_c2ia0")
expand_mode = 3
[node name="PlayerName" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "PLAYER_NAME"
vertical_alignment = 1
[node name="MoneyValue" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "1.000.000"
vertical_alignment = 1
[node name="CurrencyIcon" type="TextureRect" parent="MarginContainer/PanelContainer/VBoxContainer/PlayerInfo/HBoxContainer"]
self_modulate = Color(0.941789, 0.802506, 0.327877, 1)
layout_mode = 2
texture = ExtResource("3_oo4iu")
expand_mode = 3
[node name="MonsterInfoTitle" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 40
theme_override_constants/margin_top = 30
theme_override_constants/margin_right = 40
[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/MonsterInfoTitle"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_fonts/font = ExtResource("2_1e4kf")
theme_override_font_sizes/font_size = 36
text = "Your Monsters"
vertical_alignment = 1
[node name="MonsterListEntryContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 2
theme_override_constants/margin_left = 20
theme_override_constants/margin_right = 20
[node name="CloseButtonContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_bottom = 32
[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer"]
unique_name_in_owner = true
self_modulate = Color(0, 0, 0, 1)
custom_minimum_size = Vector2(120, 120)
layout_mode = 2
size_flags_horizontal = 4
theme_override_styles/focus = SubResource("StyleBoxEmpty_flvbu")
icon = ExtResource("3_kgfth")
flat = true
icon_alignment = 1
expand_icon = true
[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/CloseButtonContainer/CloseButton" to="." method="_on_close_button_pressed"]

69
ui/joystick.gd Normal file
View file

@ -0,0 +1,69 @@
extends Panel
@onready var talk_a_texture = preload("res://assets/textures/Xbox Series/Vector/xbox_button_a.svg")
@onready var drag_texture = preload("res://assets/textures/Generic/Vector/generic_button_circle.svg")
@onready var thumbstick = $Thumbstick
var thumbstick_size_factor = 0.5
var middle: Vector2 = Vector2(100, 100)
var touch_start: Vector2 = Vector2(0, 0)
var jump_threshold: float = 10.0
var delta: float = 0.0
var pressed: bool = false
# debug rotation
var rotation_delta: Vector2 = Vector2(0, 0)
func _ready() -> void:
#thumbstick.custom_minimum_size = Vector2(size.x, size.x) * thumbstick_size_factor
thumbstick.position = middle - thumbstick.size / 2.0
func _on_gui_input(event: InputEvent) -> void:
if event is not InputEventScreenTouch and event is not InputEventScreenDrag:
return
if event.is_pressed() == false:
simulate_joystick_motion(JOY_AXIS_LEFT_X, Vector2.ZERO.x)
simulate_joystick_motion(JOY_AXIS_LEFT_Y, Vector2.ZERO.y)
thumbstick.position = middle - thumbstick.size / 2.0
thumbstick.texture = talk_a_texture
if event is InputEventScreenTouch and pressed == true:
Input.action_press("ui_select")
pressed = false
if event is InputEventScreenTouch and event.is_pressed():
pressed = true
if event is InputEventScreenDrag:
# cancel the talking action
pressed = false
# swap to drag texture
thumbstick.texture = drag_texture
var touch_position = event.position
# visual thumbstick movement
var thumbstick_position = touch_position - thumbstick.size / 2.0
#var clamped_thumbstick_position = thumbstick_position.clampf(-40.0, 40.0)
thumbstick.position = thumbstick_position
# actual value
var _delta = middle - touch_position
var direction = _delta.normalized()
simulate_joystick_motion(JOY_AXIS_LEFT_X, -direction.x)
simulate_joystick_motion(JOY_AXIS_LEFT_Y, -direction.y)
func simulate_joystick_motion(axis: int, value: float, device_id: int = 0) -> void:
var joystick_event = InputEventJoypadMotion.new()
joystick_event.device = device_id
joystick_event.axis = axis # Axis index (e.g., 0 for X-axis, 1 for Y-axis)
joystick_event.axis_value = value # Value of the axis, typically between -1 and 1
Input.parse_input_event(joystick_event) # Process the event
func _on_resized() -> void:
middle = size / 2.0
thumbstick = get_node("Thumbstick")
thumbstick.position = middle - thumbstick.size / 2.0

33
ui/main_menu.gd Normal file
View file

@ -0,0 +1,33 @@
extends Control
signal on_new_game_started
signal on_game_continued
# On ready, check which buttons to show
func _ready() -> void:
if SaveGame.savegame_exists():
%ContinueGameButton.visible = true
%NewGameButton.visible = false
func _on_new_game_button_pressed() -> void:
# Hide the main menu
self.visible = false
# emit the new game signal
on_new_game_started.emit()
func _on_continue_game_button_pressed() -> void:
# Hide the main menu
self.visible = false
# emit the continue game signal
on_game_continued.emit()
func _on_options_button_pressed() -> void:
print("TODO")
func _on_licenses_button_pressed() -> void:
print("TODO")
func _on_exit_button_pressed() -> void:
get_tree().quit()

198
ui/main_menu.tscn Normal file
View file

@ -0,0 +1,198 @@
[gd_scene load_steps=10 format=3 uid="uid://dt00rjsodtady"]
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="1_1fmce"]
[ext_resource type="Script" path="res://ui/main_menu.gd" id="1_5gs73"]
[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_aqmkw"]
[ext_resource type="Texture2D" uid="uid://da7o6lfuoliid" path="res://assets/textures/Backgrounds/meadow2.jpg" id="2_bb61v"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7grw7"]
content_margin_left = 20.0
content_margin_right = 20.0
content_margin_bottom = 5.0
bg_color = Color(0.799841, 0.529277, 0.323387, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xjg0j"]
content_margin_left = 20.0
content_margin_right = 20.0
content_margin_bottom = 5.0
bg_color = Color(0.799841, 0.529277, 0.323387, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3y6oq"]
content_margin_left = 20.0
content_margin_right = 20.0
content_margin_bottom = 5.0
bg_color = Color(0.799841, 0.529277, 0.323387, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cnake"]
content_margin_left = 20.0
content_margin_right = 20.0
content_margin_bottom = 5.0
bg_color = Color(0.799841, 0.529277, 0.323387, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0d7mr"]
content_margin_left = 20.0
content_margin_right = 20.0
content_margin_bottom = 5.0
bg_color = Color(0.799841, 0.529277, 0.323387, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[node name="MainMenu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_5gs73")
[node name="Background" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("2_bb61v")
expand_mode = 3
stretch_mode = 6
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 50
[node name="Logo" type="TextureRect" parent="VBoxContainer"]
custom_minimum_size = Vector2(600, 600)
layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("1_1fmce")
expand_mode = 4
stretch_mode = 5
[node name="Label" type="Label" parent="VBoxContainer/Logo"]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -23.0
grow_horizontal = 2
grow_vertical = 0
theme_override_colors/font_color = Color(0.945573, 0.745802, 0.348774, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 30
theme_override_fonts/font = ExtResource("2_aqmkw")
theme_override_font_sizes/font_size = 70
text = "MONSTER
FANGEN"
horizontal_alignment = 1
max_lines_visible = 2
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 50
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 50
theme_override_constants/margin_bottom = 50
[node name="MenuButtons" type="VBoxContainer" parent="VBoxContainer/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 3
[node name="NewGameButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0.355673, 0.203473, 0.0399276, 1)
theme_override_fonts/font = ExtResource("2_aqmkw")
theme_override_font_sizes/font_size = 45
theme_override_styles/focus = SubResource("StyleBoxFlat_7grw7")
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_xjg0j")
theme_override_styles/hover = SubResource("StyleBoxFlat_3y6oq")
theme_override_styles/pressed = SubResource("StyleBoxFlat_cnake")
theme_override_styles/normal = SubResource("StyleBoxFlat_0d7mr")
text = "New Game"
[node name="ContinueGameButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(0.356863, 0.203922, 0.0392157, 1)
theme_override_fonts/font = ExtResource("2_aqmkw")
theme_override_font_sizes/font_size = 45
theme_override_styles/focus = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/normal = SubResource("StyleBoxFlat_0d7mr")
text = "Continue"
[node name="OptionsButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0.356863, 0.203922, 0.0392157, 1)
theme_override_fonts/font = ExtResource("2_aqmkw")
theme_override_font_sizes/font_size = 45
theme_override_styles/focus = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/normal = SubResource("StyleBoxFlat_0d7mr")
text = "Options"
[node name="LicensesButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0.356863, 0.203922, 0.0392157, 1)
theme_override_fonts/font = ExtResource("2_aqmkw")
theme_override_font_sizes/font_size = 45
theme_override_styles/focus = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/normal = SubResource("StyleBoxFlat_0d7mr")
text = "Licenses"
[node name="ExitButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 10
theme_override_colors/font_color = Color(0.356863, 0.203922, 0.0392157, 1)
theme_override_fonts/font = ExtResource("2_aqmkw")
theme_override_font_sizes/font_size = 45
theme_override_styles/focus = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/hover = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/pressed = SubResource("StyleBoxFlat_0d7mr")
theme_override_styles/normal = SubResource("StyleBoxFlat_0d7mr")
text = "Exit"
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/NewGameButton" to="." method="_on_new_game_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/ContinueGameButton" to="." method="_on_continue_game_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/OptionsButton" to="." method="_on_options_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/LicensesButton" to="." method="_on_licenses_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"]

21
ui/monster_list_entry.gd Normal file
View file

@ -0,0 +1,21 @@
extends HBoxContainer
class_name MonsterListEntry
# 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 populate(monster) -> void:
%MonsterID.text = str(0)
%MonsterName.text = monster.display_name
%MonsterLevel.text = "Lvl. %s" % monster.level
%HealthProgressBar.value = monster.health
%HealthProgressBar.max_value = monster.health
%ExperienceProgressBar.value = monster.xp
%ExperienceProgressBar.max_value = monster.base_xp_for_next_level

107
ui/monster_list_entry.tscn Normal file
View file

@ -0,0 +1,107 @@
[gd_scene load_steps=9 format=3 uid="uid://brp2sljqnkuhe"]
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="1_16gb7"]
[ext_resource type="Script" path="res://ui/monster_list_entry.gd" id="1_spojl"]
[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="2_5n4ar"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s3mod"]
content_margin_top = 24.0
bg_color = Color(0.4, 0.5, 0.455, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nb1sm"]
bg_color = Color(0, 0.843137, 0.466667, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fkb5g"]
content_margin_top = 12.0
bg_color = Color(0.4, 0.466667, 0.5, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b4pov"]
bg_color = Color(0, 0.56, 0.84, 1)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_x2rfb"]
[node name="MonsterListEntry" type="HBoxContainer"]
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 72.0
grow_horizontal = 2
script = ExtResource("1_spojl")
[node name="Thumbnail" type="TextureRect" parent="."]
unique_name_in_owner = true
custom_minimum_size = Vector2(70, 70)
layout_mode = 2
texture = ExtResource("1_16gb7")
expand_mode = 3
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
[node name="NameAndLevelContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="MonsterID" type="Label" parent="VBoxContainer/NameAndLevelContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "ID"
vertical_alignment = 1
[node name="MonsterName" type="Label" parent="VBoxContainer/NameAndLevelContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 24
text = "Name"
vertical_alignment = 1
[node name="MonsterLevel" type="Label" parent="VBoxContainer/NameAndLevelContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 8
theme_override_colors/font_color = Color(0, 0, 0, 1)
theme_override_font_sizes/font_size = 24
text = "Lvl"
vertical_alignment = 1
[node name="ProgressBarContainer" type="VBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
theme_override_constants/separation = 0
[node name="HealthProgressBar" type="ProgressBar" parent="VBoxContainer/ProgressBarContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 4
theme_override_styles/background = SubResource("StyleBoxFlat_s3mod")
theme_override_styles/fill = SubResource("StyleBoxFlat_nb1sm")
step = 1.0
rounded = true
show_percentage = false
[node name="ExperienceProgressBar" type="ProgressBar" parent="VBoxContainer/ProgressBarContainer"]
unique_name_in_owner = true
layout_mode = 2
theme_override_styles/background = SubResource("StyleBoxFlat_fkb5g")
theme_override_styles/fill = SubResource("StyleBoxFlat_b4pov")
step = 1.0
rounded = true
show_percentage = false
[node name="SwapPositionButton" type="Button" parent="."]
unique_name_in_owner = true
self_modulate = Color(0, 0, 0, 1)
custom_minimum_size = Vector2(100, 100)
layout_mode = 2
size_flags_horizontal = 8
theme_override_styles/focus = SubResource("StyleBoxEmpty_x2rfb")
icon = ExtResource("2_5n4ar")
flat = true
icon_alignment = 1
expand_icon = true

72
ui/ui.gd Normal file
View file

@ -0,0 +1,72 @@
extends Node
# these two signals come from the MainMenu and start / continue the game
# gets sent to the main.gd scene
signal on_new_game_started
signal on_game_continued
@onready var root: CanvasLayer = $/root/Game/UI
@onready var main_menu: Control = $/root/Game/UI/MainMenu
@onready var ingame_controls: MarginContainer = $/root/Game/UI/IngameControls
@onready var ingame_menu: Control = $/root/Game/UI/IngameMenu
@onready var camera_control_area : Control = $/root/Game/UI/CameraControlArea
@onready var save_ui : Control = $/root/Game/UI/SaveUI
func _ready() -> void:
main_menu.connect("on_game_continued", _on_main_menu_on_game_continued)
main_menu.connect("on_new_game_started", _on_main_menu_on_new_game_started)
ingame_controls.connect("menu_button_clicked", _on_ingame_controls_menu_button_clicked)
ingame_controls.connect("save_button_clicked", _on_ingame_controls_save_button_clicked)
ingame_controls.connect("save_button_released", _on_ingame_controls_save_button_released)
ingame_controls.connect("save_timer_incremented", _on_ingame_controls_save_timer_incremented)
ingame_controls.connect("save_timer_reached", _on_ingame_controls_save_timer_reached)
pass
func show_main_menu(p_visible = true) -> void:
main_menu.visible = p_visible
func show_ingame_controls(p_visible = true) -> void:
ingame_controls.visible = p_visible
func _on_ingame_controls_menu_button_clicked() -> void:
ingame_menu.visible = true
# Updates the whole UI
func _update_ui() -> void:
# Updating the player info
ingame_menu._update_player_info()
# Updating the monster list
ingame_menu._update_monster_list()
print("UI updated")
func _on_ingame_controls_save_button_clicked() -> void:
save_ui.visible = true
func _on_ingame_controls_save_button_released() -> void:
save_ui.visible = false
func _on_ingame_controls_save_timer_incremented(value) -> void:
save_ui.get_node("SavePercentage").text = str(value)
func _on_ingame_controls_save_timer_reached() -> void:
save_ui.get_node("SavePercentage").text = "Saved!"
ingame_controls.disable_save_button()
await get_tree().create_timer(1.0).timeout
ingame_controls.enable_save_button()
save_ui.visible = false
save_ui.get_node("SavePercentage").text = "0%"
# sends the signal from the MainMenu node up to the main.gd scene
func _on_main_menu_on_new_game_started() -> void:
on_new_game_started.emit()
# sends the signal from the MainMenu node up to the main.gd scene
func _on_main_menu_on_game_continued() -> void:
on_game_continued.emit()

61
ui/ui.tscn Normal file
View file

@ -0,0 +1,61 @@
[gd_scene load_steps=5 format=3 uid="uid://b5y7pdfe6ougf"]
[ext_resource type="Script" path="res://ui/camera_controls.gd" id="1_x56x6"]
[ext_resource type="PackedScene" uid="uid://dt00rjsodtady" path="res://ui/main_menu.tscn" id="3_tcmm8"]
[ext_resource type="PackedScene" uid="uid://1anjhvi173g3" path="res://ui/ingame_controls.tscn" id="4_likk0"]
[ext_resource type="PackedScene" uid="uid://bbvbnrcjatkrb" path="res://ui/ingame_menu.tscn" id="5_qjqu1"]
[node name="UI" type="CanvasLayer"]
[node name="CameraControlArea" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_x56x6")
[node name="SaveUI" type="Control" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="SavePercentage" type="Label" parent="SaveUI"]
unique_name_in_owner = true
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 = -11.5
offset_right = 20.0
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
theme_override_colors/font_color = Color(0.3895, 0.856583, 0.95, 1)
theme_override_colors/font_outline_color = Color(0.2419, 0.531983, 0.59, 1)
theme_override_constants/outline_size = 30
theme_override_font_sizes/font_size = 100
text = "0 % ..."
horizontal_alignment = 1
vertical_alignment = 1
[node name="MainMenu" parent="." instance=ExtResource("3_tcmm8")]
unique_name_in_owner = true
[node name="IngameControls" parent="." instance=ExtResource("4_likk0")]
unique_name_in_owner = true
visible = false
[node name="IngameMenu" parent="." instance=ExtResource("5_qjqu1")]
unique_name_in_owner = true
visible = false