1
Fork 0
mirror of https://github.com/Steffo99/swear-jar.git synced 2024-11-25 17:14:20 +00:00

Begin creation of ShopUI

This commit is contained in:
Steffo 2023-10-01 14:39:16 +02:00
parent cf3cef96e4
commit 73ede51027
Signed by: steffo
GPG key ID: 2A24051445686895
10 changed files with 377 additions and 86 deletions

37
game/game.tscn Normal file
View file

@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=3 uid="uid://c3rxmcwa5nqng"]
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_y7o2l"]
[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_h2pfr"]
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_qwsty"]
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="4_e5nwi"]
[node name="Game" type="Node2D"]
texture_filter = 1
[node name="Bottle" parent="." instance=ExtResource("1_y7o2l")]
[node name="GravityFromGyro" parent="Bottle" instance=ExtResource("2_h2pfr")]
[node name="TimeSpawner" parent="." instance=ExtResource("3_qwsty")]
position = Vector2(0, -480)
scene = ExtResource("4_e5nwi")
buffer_cap = 1
spawn_position_range_x = 32.0
spawn_rotation_range = 15.0
overlapping_bodies_collision_mask = 4
overlapping_body_count_limit = 4
[node name="Timer" type="Timer" parent="TimeSpawner"]
wait_time = 0.03
autostart = true
[node name="ButtonSpawner" parent="." instance=ExtResource("3_qwsty")]
position = Vector2(0, -480)
scene = ExtResource("4_e5nwi")
buffer_cap = 50
spawn_position_range_x = 32.0
spawn_rotation_range = 15.0
overlapping_bodies_collision_mask = 4
overlapping_body_count_limit = 4
[connection signal="timeout" from="TimeSpawner/Timer" to="TimeSpawner" method="spawn"]

View file

@ -0,0 +1,15 @@
[gd_scene load_steps=2 format=3 uid="uid://mfa1v4fsnupp"]
[ext_resource type="PackedScene" uid="uid://c3rxmcwa5nqng" path="res://game/game.tscn" id="1_dbqdv"]
[node name="GameContainer" type="Control"]
layout_mode = 3
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
[node name="Game" parent="." instance=ExtResource("1_dbqdv")]

45
interface/game_ui.tscn Normal file
View file

@ -0,0 +1,45 @@
[gd_scene load_steps=2 format=3 uid="uid://bo5unrhqpoyim"]
[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_ppf8y"]
[node name="Rows" type="VBoxContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_ppf8y")
[node name="UpperButtons" type="HBoxContainer" parent="."]
custom_minimum_size = Vector2(0, 54)
layout_mode = 2
size_flags_vertical = 8
alignment = 1
[node name="MoneyButton" type="Button" parent="UpperButtons"]
custom_minimum_size = Vector2(72, 0)
layout_mode = 2
size_flags_horizontal = 0
text = "$0"
alignment = 0
[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UpperButtons"]
layout_mode = 2
size_flags_horizontal = 3
[node name="SpawnButton" type="Button" parent="UpperButtons"]
custom_minimum_size = Vector2(72, 0)
layout_mode = 2
size_flags_horizontal = 4
text = "Drop"
[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UpperButtons"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ShopButton" type="Button" parent="UpperButtons"]
custom_minimum_size = Vector2(72, 0)
layout_mode = 2
size_flags_horizontal = 8
text = "Shop"
alignment = 2

View file

@ -0,0 +1,6 @@
[gd_resource type="Theme" load_steps=2 format=3 uid="uid://ba5utvfhnxa5i"]
[ext_resource type="FontFile" uid="uid://cs8tiwyb76gig" path="res://font/press-start/prstart.ttf" id="1_mtdor"]
[resource]
default_font = ExtResource("1_mtdor")

View file

@ -0,0 +1,78 @@
extends Panel
class_name PurchasableItem
## Name of the item that can be purchased.
@export var item_name: String:
get:
return item_name
set(value):
item_name = value
$Contents/Header/NameLabel.text = value
## Description of the item that can be purchased.
@export var item_description: String:
get:
return item_description
set(value):
item_description = value
$Contents/Header/DescriptionLabel.text = value
## Text to be displayed on the cost label of the item.
@export var item_cost_text: String:
get:
return item_cost_text
set(value):
item_cost_text = value
$Contents/Action/CostLabel.text = value
## Collectible type of the item required to buy the item.
@export var item_cost_type: StringName
## Amount of items of the given type to collect to buy the item.
@export var item_cost_goal: int
## Whether the player can click or not the Buy button.
##
## Used to prevent two items from getting bought at the same time.
@export var can_buy: bool:
get:
return can_buy
set(value):
can_buy = value
$Contents/Action/BuyButton.disabled = not can_buy
## Whether the player is currently buying this item.
##
## Used to cancel the purchase.
var is_buying: bool:
get:
return is_buying
set(value):
is_buying = value
$Contents/Action/BuyButton.text = "Cancel" if value else "Buy"
## Emitted when a purchase has started.
signal purchase_begin
## Emitted when a purchase is cancelled.
signal purchase_cancel
## Emitted when a purchase is completed.
##
## Emitted by complete_purchase().
signal purchase_success
func _on_buy_button_pressed():
if is_buying:
is_buying = false
purchase_cancel.emit()
else:
is_buying = true
purchase_begin.emit()
func complete_purchase():
is_buying = false
purchase_success.emit()

View file

@ -0,0 +1,115 @@
[gd_scene load_steps=3 format=3 uid="uid://dul1fpyh733t7"]
[ext_resource type="Texture2D" uid="uid://cxsl5yvdhswc7" path="res://icon.png" id="1_drwcj"]
[ext_resource type="Script" path="res://interface/purchasable_item.gd" id="1_h8jix"]
[node name="PurchasableItem" type="Panel"]
custom_minimum_size = Vector2(0, 182)
anchors_preset = 10
anchor_right = 1.0
grow_horizontal = 2
size_flags_horizontal = 3
script = ExtResource("1_h8jix")
[node name="Contents" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="HeaderPaddingTop" type="Control" parent="Contents"]
custom_minimum_size = Vector2(0, 4)
layout_mode = 2
[node name="Header" type="HBoxContainer" parent="Contents"]
layout_mode = 2
size_flags_vertical = 8
[node name="IconPaddingLeft" type="Control" parent="Contents/Header"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="IconRect" type="TextureRect" parent="Contents/Header"]
custom_minimum_size = Vector2(54, 54)
layout_mode = 2
texture = ExtResource("1_drwcj")
expand_mode = 2
[node name="IconNameSeparator" type="Control" parent="Contents/Header"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="NameLabel" type="Label" parent="Contents/Header"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 20
text = "Garasaut"
uppercase = true
[node name="NamePaddingRight" type="Control" parent="Contents/Header"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="HeaderDescriptionPadding" type="Control" parent="Contents"]
custom_minimum_size = Vector2(0, 4)
layout_mode = 2
size_flags_vertical = 3
[node name="Description" type="HBoxContainer" parent="Contents"]
layout_mode = 2
size_flags_vertical = 4
[node name="DescriptionPaddingLeft" type="Control" parent="Contents/Description"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="DescriptionLabel" type="Label" parent="Contents/Description"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 12
text = "Garasa tutte le auto della zona per ottenere upgrade"
autowrap_mode = 2
[node name="DescriptionPaddingRight" type="Control" parent="Contents/Description"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="DescriptionActionPadding" type="Control" parent="Contents"]
custom_minimum_size = Vector2(0, 4)
layout_mode = 2
size_flags_vertical = 3
[node name="Action" type="HBoxContainer" parent="Contents"]
layout_mode = 2
size_flags_vertical = 0
[node name="BuyButtonPaddingLeft" type="Control" parent="Contents/Action"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="BuyButton" type="Button" parent="Contents/Action"]
layout_mode = 2
text = "Buy"
[node name="BuyCostPadding" type="Control" parent="Contents/Action"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="CostLabel" type="Label" parent="Contents/Action"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_font_sizes/font_size = 8
text = "3 copper coins"
vertical_alignment = 1
[node name="CostLabelPaddingRight" type="Control" parent="Contents/Action"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
[node name="ActionPaddingBottom" type="Control" parent="Contents"]
custom_minimum_size = Vector2(0, 4)
layout_mode = 2
[connection signal="pressed" from="Contents/Action/BuyButton" to="." method="_on_buy_button_pressed"]

View file

@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://wodgj6rp2ewm"]
[node name="PurchasableItemPadding" type="Control"]
custom_minimum_size = Vector2(0, 8)
layout_mode = 3
anchors_preset = 0

2
interface/shop_ui.gd Normal file
View file

@ -0,0 +1,2 @@
extends Panel
class_name ShopUI

63
interface/shop_ui.tscn Normal file
View file

@ -0,0 +1,63 @@
[gd_scene load_steps=4 format=3 uid="uid://cklkdygv61bny"]
[ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_qdf0y"]
[ext_resource type="PackedScene" uid="uid://dul1fpyh733t7" path="res://interface/purchasable_item.tscn" id="2_2dtc0"]
[ext_resource type="PackedScene" uid="uid://wodgj6rp2ewm" path="res://interface/purchasable_item_padding.tscn" id="3_4feaj"]
[node name="ShopUI" type="Panel"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_qdf0y")
[node name="Rows" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="UpperButtons" type="HBoxContainer" parent="Rows"]
custom_minimum_size = Vector2(0, 54)
layout_mode = 2
[node name="MoneyButton" type="Button" parent="Rows/UpperButtons"]
custom_minimum_size = Vector2(54, 0)
layout_mode = 2
size_flags_horizontal = 0
text = "$0"
alignment = 0
[node name="UpperButtonsSpacer" type="PanelContainer" parent="Rows/UpperButtons"]
layout_mode = 2
size_flags_horizontal = 3
[node name="BackButton" type="Button" parent="Rows/UpperButtons"]
custom_minimum_size = Vector2(54, 0)
layout_mode = 2
size_flags_horizontal = 8
text = "Back"
alignment = 2
[node name="Scrollable" type="ScrollContainer" parent="Rows"]
layout_mode = 2
size_flags_vertical = 3
horizontal_scroll_mode = 0
vertical_scroll_mode = 2
[node name="ScrollableItems" type="VBoxContainer" parent="Rows/Scrollable"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="PurchasableItem" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")]
layout_mode = 2
[node name="PurchasableItemPadding" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("3_4feaj")]
layout_mode = 2
[node name="PurchasableItem2" parent="Rows/Scrollable/ScrollableItems" instance=ExtResource("2_2dtc0")]
layout_mode = 2

View file

@ -1,13 +1,14 @@
[gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"] [gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"]
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"] [ext_resource type="Theme" uid="uid://ba5utvfhnxa5i" path="res://interface/interface_theme.tres" id="1_h26ax"]
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"] [ext_resource type="PackedScene" uid="uid://mfa1v4fsnupp" path="res://interface/game_container.tscn" id="1_xjgvu"]
[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"] [ext_resource type="PackedScene" uid="uid://cklkdygv61bny" path="res://interface/shop_ui.tscn" id="3_lvefk"]
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"] [ext_resource type="PackedScene" uid="uid://bo5unrhqpoyim" path="res://interface/game_ui.tscn" id="5_2cc15"]
[node name="Root" type="Node"] [node name="Root" type="Node"]
[node name="UI" type="Control" parent="."] [node name="UI" type="Control" parent="."]
texture_filter = 1
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@ -15,90 +16,13 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
size_flags_vertical = 8 size_flags_vertical = 8
theme = ExtResource("1_h26ax")
[node name="GameContainer" type="Control" parent="UI"] [node name="GameContainer" parent="UI" instance=ExtResource("1_xjgvu")]
layout_mode = 1 layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
[node name="Game" type="Node2D" parent="UI/GameContainer"] [node name="GameUI" parent="UI" instance=ExtResource("5_2cc15")]
texture_filter = 1
[node name="Bottle" parent="UI/GameContainer/Game" instance=ExtResource("1_4fmd3")]
[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")]
[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
position = Vector2(0, -480)
scene = ExtResource("2_dv01l")
buffer_cap = 1
spawn_position_range_x = 32.0
spawn_rotation_range = 15.0
overlapping_bodies_collision_mask = 4
overlapping_body_count_limit = 4
[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"]
wait_time = 0.03
autostart = true
[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
position = Vector2(0, -480)
scene = ExtResource("2_dv01l")
buffer_cap = 50
spawn_position_range_x = 32.0
spawn_rotation_range = 15.0
overlapping_bodies_collision_mask = 4
overlapping_body_count_limit = 4
[node name="Rows" type="VBoxContainer" parent="UI"]
layout_mode = 1 layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="NotchSpacer" type="PanelContainer" parent="UI/Rows"] [node name="ShopUI" parent="UI" instance=ExtResource("3_lvefk")]
layout_mode = 2 layout_mode = 1
size_flags_horizontal = 3
[node name="UpperButtons" type="HBoxContainer" parent="UI/Rows"]
custom_minimum_size = Vector2(0, 54)
layout_mode = 2
size_flags_vertical = 8
[node name="MoneyButton" type="Button" parent="UI/Rows/UpperButtons"]
custom_minimum_size = Vector2(54, 0)
layout_mode = 2
size_flags_horizontal = 8
text = "$0"
alignment = 0
[node name="UpperButtonsSpacerLeft" type="PanelContainer" parent="UI/Rows/UpperButtons"]
layout_mode = 2
size_flags_horizontal = 3
[node name="SpawnButton" type="Button" parent="UI/Rows/UpperButtons"]
custom_minimum_size = Vector2(54, 0)
layout_mode = 2
size_flags_horizontal = 8
text = "Drop"
[node name="UpperButtonsSpacerRight" type="PanelContainer" parent="UI/Rows/UpperButtons"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ShopButton" type="Button" parent="UI/Rows/UpperButtons"]
custom_minimum_size = Vector2(54, 0)
layout_mode = 2
size_flags_horizontal = 8
text = "Shop"
alignment = 2
[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"]
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"]