Compare commits

..

2 commits

6 changed files with 118 additions and 40 deletions

View file

@ -23,8 +23,13 @@ extends Resource
_generate_job_time()
@export var job_description: String
@export var job_material: String = "PLA":
set(value):
job_material = value
_generate_job_time()
var job_time: float
var job_material: String = "PLA"
func _init() -> void:

View file

@ -17,9 +17,9 @@ func initialize_printer(data: PrinterData) -> void:
printer_data = data
printer_name.text = printer_data.printer_manufacturer
printer_model.text = printer_data.printer_type
printer_speed.text = "Speed: " + str(printer_data.printer_speed) + "/5"
printer_quality.text = "Quality: " + str(printer_data.printer_quality) + "/5"
printer_price.text = "Price: " + str(printer_data.printer_price) + ""
printer_speed.text = 'Speed: %d/5' % printer_data.printer_speed
printer_quality.text = 'Quality: %d/5' % printer_data.printer_quality
printer_price.text = 'Price: %d' % printer_data.printer_price
if PlayerData.money > printer_data.printer_price:
buy_button.disabled = false

View file

@ -6,13 +6,17 @@ signal printer_purchase_requested(printer_data: PrinterData)
const PRINTER_SCENE = preload("uid://bdpqvwvwmaian")
func _ready() -> void:
for printer in printers_array:
var new_printer = PRINTER_SCENE.instantiate()
$PrinterList.add_child(new_printer)
new_printer.initialize_printer(printer)
new_printer.buy_printer.connect(_buy_printer_pressed)
generate_printers()
generate_printers()
printer_purchase_requested.connect(GameData._on_shop_printer_purchase_req)
func generate_printers() -> void:
for printer in printers_array:
var new_printer = PRINTER_SCENE.instantiate()
%PrinterList.add_child(new_printer)
new_printer.initialize_printer(printer)
new_printer.buy_printer.connect(_buy_printer_pressed)
func _buy_printer_pressed(bought_printer) -> void:
printer_purchase_requested.emit(bought_printer.printer_data)

View file

@ -6,6 +6,7 @@
[node name="PrinterCard" type="PanelContainer" unique_id=1714388686]
offset_right = 40.0
offset_bottom = 40.0
size_flags_horizontal = 3
script = ExtResource("1_tl8ce")
[node name="MarginContainer" type="MarginContainer" parent="." unique_id=2020543953]

View file

@ -7,7 +7,7 @@ extends Control
@onready var debug_xp: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugXP
@onready var debug_money: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugMoney
@onready var debug_button: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugButton
@onready var jobs_tab_button: Button = $VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons/JobsTabButton
@onready var jobs_tab_button: Button = $VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons/JobsTabButton
const PRINTER = preload("uid://33ctlyrpibs3")
@ -33,12 +33,12 @@ func _on_level_changed(level) -> void:
func _on_money_changed(money) -> void:
%Money.text = 'Money: %.2f' % money
func _on_job_generated(job: Node) -> void:
%JobContainer.add_child(job)
func _on_job_interact() -> void:
jobs_tab_button.text = 'Jobs (%d / %d)' % [GameData.current_job_count, GameData.MAX_JOBS]
func _on_job_generated(job: Node) -> void:
%JobContainer.add_child(job)
func _on_printer_bought(new_printer: Node) -> void:
%PrinterContainer.add_child(new_printer)

View file

@ -28,6 +28,9 @@ corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
corner_detail = 6
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vqjbf"]
bg_color = Color(0.6, 0.6, 0.6, 0)
[node name="UI" type="Control" unique_id=256887379]
layout_mode = 3
anchors_preset = 15
@ -104,14 +107,24 @@ theme_override_styles/fill = SubResource("StyleBoxFlat_8fchy")
value = 65.27
show_percentage = false
[node name="MainArea" type="HBoxContainer" parent="VBoxContainer" unique_id=352001241]
[node name="MainAreaMargin" type="MarginContainer" parent="VBoxContainer" unique_id=1858818142]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_top = 5
[node name="LeftColumn" type="VBoxContainer" parent="VBoxContainer/MainArea" unique_id=497978034]
[node name="MainArea" type="HBoxContainer" parent="VBoxContainer/MainAreaMargin" unique_id=352001241]
layout_mode = 2
size_flags_vertical = 3
[node name="LeftColumn" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea" unique_id=497978034]
layout_mode = 2
size_flags_horizontal = 3
[node name="Header" type="MarginContainer" parent="VBoxContainer/MainArea/LeftColumn" unique_id=674103883]
[node name="MainMargin" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/LeftColumn" unique_id=1390444828]
layout_mode = 2
size_flags_vertical = 3
[node name="Header" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/LeftColumn/MainMargin" unique_id=674103883]
visible = false
layout_mode = 2
theme_override_constants/margin_left = 10
@ -119,21 +132,35 @@ theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="Label" type="Label" parent="VBoxContainer/MainArea/LeftColumn/Header" unique_id=1155403735]
[node name="Label" type="Label" parent="VBoxContainer/MainAreaMargin/MainArea/LeftColumn/MainMargin/Header" unique_id=1155403735]
layout_mode = 2
text = "Printers"
[node name="PrinterContainer" type="VBoxContainer" parent="VBoxContainer/MainArea/LeftColumn" unique_id=374703275]
[node name="PrinterScroll" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/LeftColumn/MainMargin" unique_id=1351903470]
layout_mode = 2
horizontal_scroll_mode = 0
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/LeftColumn/MainMargin/PrinterScroll" unique_id=134445001]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="PrinterContainer" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/LeftColumn/MainMargin/PrinterScroll/MarginContainer" unique_id=374703275]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/separation = 8
[node name="RightColumn" type="VBoxContainer" parent="VBoxContainer/MainArea" unique_id=653054059]
[node name="RightColumn" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea" unique_id=653054059]
layout_mode = 2
size_flags_horizontal = 3
[node name="TabSwitcher" type="MarginContainer" parent="VBoxContainer/MainArea/RightColumn" unique_id=1366955734]
[node name="TabSwitcher" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn" unique_id=1366955734]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
@ -141,41 +168,65 @@ theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
script = ExtResource("13_vqjbf")
[node name="TabButtons" type="HBoxContainer" parent="VBoxContainer/MainArea/RightColumn/TabSwitcher" unique_id=454550378]
[node name="TabButtons" type="HBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher" unique_id=454550378]
layout_mode = 2
[node name="JobsTabButton" type="Button" parent="VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons" unique_id=332022453]
[node name="JobsTabButton" type="Button" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons" unique_id=332022453]
layout_mode = 2
size_flags_horizontal = 3
text = "Jobs"
[node name="ShopTabButton" type="Button" parent="VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons" unique_id=748682284]
[node name="ShopTabButton" type="Button" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons" unique_id=748682284]
layout_mode = 2
size_flags_horizontal = 3
text = "Shop"
[node name="MenuTabButton" type="Button" parent="VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons" unique_id=1414728414]
[node name="MenuTabButton" type="Button" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons" unique_id=1414728414]
layout_mode = 2
size_flags_horizontal = 3
text = "Menu"
[node name="JobsTab" type="PanelContainer" parent="VBoxContainer/MainArea/RightColumn" unique_id=859027615]
[node name="MainMargin" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn" unique_id=562508461]
layout_mode = 2
size_flags_vertical = 3
theme_override_constants/margin_left = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="JobsTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=859027615]
unique_name_in_owner = true
visible = false
layout_mode = 2
[node name="JobContainer" type="VBoxContainer" parent="VBoxContainer/MainArea/RightColumn/JobsTab" unique_id=1821891785]
[node name="JobScroll" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/JobsTab" unique_id=1046443254]
layout_mode = 2
horizontal_scroll_mode = 0
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/JobsTab/JobScroll" unique_id=708828708]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="JobContainer" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/JobsTab/JobScroll/MarginContainer" unique_id=1821891785]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/separation = 8
[node name="ShopTab" type="PanelContainer" parent="VBoxContainer/MainArea/RightColumn" unique_id=23859514]
[node name="ShopTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=23859514]
unique_name_in_owner = true
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_vqjbf")
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MainArea/RightColumn/ShopTab" unique_id=1098619767]
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab" unique_id=1098619767]
layout_mode = 2
[node name="ShopTabSwitcher" type="MarginContainer" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer" unique_id=40136169]
[node name="ShopTabSwitcher" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer" unique_id=40136169]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
@ -183,33 +234,50 @@ theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
script = ExtResource("14_vqjbf")
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher" unique_id=1669205646]
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" unique_id=1669205646]
layout_mode = 2
[node name="PrintersButton" type="Button" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer" unique_id=96323903]
[node name="PrintersButton" type="Button" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer" unique_id=96323903]
layout_mode = 2
size_flags_horizontal = 3
text = "Printers"
[node name="FilamentsButton" type="Button" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer" unique_id=659653173]
[node name="FilamentsButton" type="Button" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer" unique_id=659653173]
layout_mode = 2
size_flags_horizontal = 3
text = "Filaments"
[node name="Printers" type="PanelContainer" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer" unique_id=1896524960]
[node name="Printers" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer" unique_id=1896524960]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
script = ExtResource("15_vqjbf")
printers_array = Array[ExtResource("16_rdojl")]([ExtResource("17_llrls"), ExtResource("18_8rt22"), ExtResource("19_1ohgd")])
[node name="PrinterList" type="VBoxContainer" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/Printers" unique_id=474412195]
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Printers" unique_id=1757920718]
layout_mode = 2
horizontal_scroll_mode = 0
[node name="Filaments" type="PanelContainer" parent="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer" unique_id=1891341317]
[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Printers/ScrollContainer" unique_id=64943590]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="PrinterList" type="VBoxContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Printers/ScrollContainer/MarginContainer" unique_id=474412195]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 8
[node name="Filaments" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer" unique_id=1891341317]
unique_name_in_owner = true
layout_mode = 2
[node name="MenuTab" type="PanelContainer" parent="VBoxContainer/MainArea/RightColumn" unique_id=526907583]
[node name="MenuTab" type="PanelContainer" parent="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin" unique_id=526907583]
unique_name_in_owner = true
visible = false
layout_mode = 2
@ -220,10 +288,10 @@ autostart = true
[connection signal="pressed" from="VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugMoney" to="." method="_on_debug_money_pressed"]
[connection signal="pressed" from="VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugXP" to="." method="_on_debug_xp_pressed"]
[connection signal="pressed" from="VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugButton" to="." method="_on_debug_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons/JobsTabButton" to="VBoxContainer/MainArea/RightColumn/TabSwitcher" method="_on_jobs_tab_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons/ShopTabButton" to="VBoxContainer/MainArea/RightColumn/TabSwitcher" method="_on_shop_tab_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainArea/RightColumn/TabSwitcher/TabButtons/MenuTabButton" to="VBoxContainer/MainArea/RightColumn/TabSwitcher" method="_on_menu_tab_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/PrintersButton" to="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_printers_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/FilamentsButton" to="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_filaments_button_pressed"]
[connection signal="printer_purchase_requested" from="VBoxContainer/MainArea/RightColumn/ShopTab/VBoxContainer/Printers" to="." method="_on_printers_printer_purchase_requested"]
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons/JobsTabButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher" method="_on_jobs_tab_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons/ShopTabButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher" method="_on_shop_tab_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher/TabButtons/MenuTabButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/TabSwitcher" method="_on_menu_tab_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/PrintersButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_printers_button_pressed"]
[connection signal="pressed" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher/HBoxContainer/FilamentsButton" to="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/ShopTabSwitcher" method="_on_filaments_button_pressed"]
[connection signal="printer_purchase_requested" from="VBoxContainer/MainAreaMargin/MainArea/RightColumn/MainMargin/ShopTab/VBoxContainer/Printers" to="." method="_on_printers_printer_purchase_requested"]
[connection signal="timeout" from="JobSpawner" to="." method="_on_job_spawner_timeout"]