Added debug option, fixed #1, visual tweaks
This commit is contained in:
parent
05df588aa7
commit
bb80a4b2d9
6 changed files with 51 additions and 10 deletions
|
|
@ -31,6 +31,7 @@ func _ready() -> void:
|
|||
give_money.connect(_on_give_money)
|
||||
|
||||
func _on_give_experience(amount: float) -> void:
|
||||
print('Gave: %.0f xp' % amount)
|
||||
xp += amount
|
||||
if xp >= 100:
|
||||
while xp >= 100:
|
||||
|
|
|
|||
15
printer.gd
15
printer.gd
|
|
@ -6,6 +6,7 @@ extends PanelContainer
|
|||
@onready var select_job: OptionButton = $MarginContainer/MainArea/SelectJob
|
||||
@onready var status_label: Label = $MarginContainer/MainArea/TopInfo/StatusLabel
|
||||
@onready var time_left_label: Label = $MarginContainer/MainArea/PrintInfo/TimeLeftLabel
|
||||
@onready var start_button: Button = $MarginContainer/MainArea/Buttons/StartButton
|
||||
|
||||
var printer_data: PrinterData
|
||||
var selected_job: JobData
|
||||
|
|
@ -31,9 +32,6 @@ func _process(delta) -> void:
|
|||
set_status()
|
||||
var total_time = selected_job.job_time
|
||||
var progress = (total_time - time_left) / total_time
|
||||
#print('Job time: %.2f' % total_time)
|
||||
#print('Time left: %.2f' % time_left)
|
||||
#print('Progress: %.2f' % progress)
|
||||
time_left -= delta
|
||||
progress_bar.value = progress
|
||||
time_left_label.text = 'Time left: %s' % calculate_time_left(time_left)
|
||||
|
|
@ -82,13 +80,17 @@ func _on_select_job_pressed() -> void:
|
|||
|
||||
if PlayerData.jobs.is_empty():
|
||||
select_job.add_item("No jobs accepted")
|
||||
start_button.disabled = true
|
||||
else:
|
||||
start_button.disabled = false
|
||||
for job in PlayerData.jobs:
|
||||
var item_text = '%s (XP: %d | %d €)' % [job.job_name, job.job_experience, job.job_reward]
|
||||
var item_text = '%s (XP: %d | %d € | %s)' % [job.job_name, job.job_experience, job.job_reward, calculate_time_left(job.job_time)]
|
||||
select_job.add_item(item_text)
|
||||
|
||||
var current_index = select_job.item_count - 1
|
||||
select_job.set_item_metadata(current_index, job)
|
||||
selected_job = select_job.get_item_metadata(0)
|
||||
selected_job_index = 0
|
||||
|
||||
func _on_start_button_pressed() -> void:
|
||||
if select_job.get_item_text(0) == "No jobs accepted":
|
||||
|
|
@ -97,11 +99,6 @@ func _on_start_button_pressed() -> void:
|
|||
time_left = selected_job.job_time
|
||||
is_printing = true
|
||||
|
||||
#PlayerData.give_money.emit(selected_job.job_reward)
|
||||
#if PlayerData.jobs.size() == 1:
|
||||
# PlayerData.jobs.clear()
|
||||
#else:
|
||||
# PlayerData.jobs.remove_at(selected_job_index)
|
||||
_on_select_job_pressed()
|
||||
|
||||
func _on_select_job_item_selected(index: int) -> void:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
[ext_resource type="Script" uid="uid://dj7pngpg53qdb" path="res://printer.gd" id="1_jhpce"]
|
||||
[ext_resource type="StyleBox" uid="uid://csahw36txnewl" path="res://Styles/btn_style_box_green_hover.tres" id="2_tnxmo"]
|
||||
[ext_resource type="StyleBox" uid="uid://b0kxbbhtsbhcr" path="res://Styles/btn_style_box_red_hover.tres" id="3_vtisp"]
|
||||
|
||||
[node name="Printer" type="PanelContainer" unique_id=1372437203]
|
||||
custom_minimum_size = Vector2(0, 150)
|
||||
|
|
@ -72,6 +73,7 @@ text = "Upgrade"
|
|||
[node name="SellButton" type="Button" parent="MarginContainer/MainArea/Buttons" unique_id=929234066]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_styles/hover = ExtResource("3_vtisp")
|
||||
text = "Sell printer"
|
||||
|
||||
[node name="SelectJob" type="OptionButton" parent="MarginContainer/MainArea" unique_id=1500040832]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ var printer_data: PrinterData
|
|||
@onready var printer_price: Label = $MarginContainer/VBoxContainer/HBoxContainer/Price
|
||||
@onready var buy_button: Button = $MarginContainer/VBoxContainer/HBoxContainer/BuyButton
|
||||
|
||||
func _ready() -> void:
|
||||
PlayerData.money_changed.connect(_on_toggle_button)
|
||||
|
||||
func initialize_printer(data: PrinterData) -> void:
|
||||
printer_data = data
|
||||
printer_name.text = printer_data.printer_manufacturer
|
||||
|
|
@ -26,3 +29,9 @@ func initialize_printer(data: PrinterData) -> void:
|
|||
func _on_buy_button_pressed() -> void:
|
||||
buy_printer.emit(self)
|
||||
print("Shop tab printer clicked: " + self.printer_data.printer_manufacturer)
|
||||
|
||||
func _on_toggle_button(money) -> void:
|
||||
if PlayerData.money > printer_data.printer_price:
|
||||
buy_button.disabled = false
|
||||
else:
|
||||
buy_button.disabled = true
|
||||
|
|
|
|||
21
ui.gd
21
ui.gd
|
|
@ -2,11 +2,18 @@ extends Control
|
|||
|
||||
@export var jobs_array: Array[JobData]
|
||||
@export var job_limit: int = 5
|
||||
@export var debug: bool = false
|
||||
var jobs_tab_button: Button
|
||||
|
||||
@onready var debug_xp: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugXP
|
||||
@onready var debug_money: Button = $VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer/DebugMoney
|
||||
|
||||
const JOB_SCENE = preload("uid://dvfcie8hqcb0")
|
||||
const PRINTER = preload("uid://33ctlyrpibs3")
|
||||
|
||||
func _ready() -> void:
|
||||
check_debug()
|
||||
|
||||
%Money.text = "Money: " + str(PlayerData.money) + " €"
|
||||
%Experience.value = PlayerData.xp
|
||||
%Level.text = "Level: " + str(PlayerData.level)
|
||||
|
|
@ -54,3 +61,17 @@ func _on_printers_printer_purchase_requested(printer_data: PrinterData) -> void:
|
|||
var new_printer = PRINTER.instantiate()
|
||||
%PrinterContainer.add_child(new_printer)
|
||||
new_printer.initialize_printer(printer_data)
|
||||
|
||||
func check_debug() -> void:
|
||||
debug_xp.visible = false
|
||||
debug_money.visible = false
|
||||
if debug:
|
||||
debug_xp.visible = true
|
||||
debug_money.visible = true
|
||||
|
||||
func _on_debug_money_pressed() -> void:
|
||||
PlayerData.give_money.emit(100)
|
||||
|
||||
func _on_debug_xp_pressed() -> void:
|
||||
var xp = randf() * 100
|
||||
PlayerData.give_experience.emit(xp)
|
||||
|
|
|
|||
11
ui.tscn
11
ui.tscn
|
|
@ -70,6 +70,14 @@ layout_mode = 2
|
|||
size_flags_horizontal = 3
|
||||
text = "Money: 0 €"
|
||||
|
||||
[node name="DebugMoney" type="Button" parent="VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer" unique_id=601739475]
|
||||
layout_mode = 2
|
||||
text = "Give 100€"
|
||||
|
||||
[node name="DebugXP" type="Button" parent="VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer" unique_id=535993224]
|
||||
layout_mode = 2
|
||||
text = "Give xp"
|
||||
|
||||
[node name="Time" type="Label" parent="VBoxContainer/TopBar/VBoxContainer/MarginContainer/HBoxContainer" unique_id=1503956629]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
|
@ -100,6 +108,7 @@ layout_mode = 2
|
|||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Header" type="MarginContainer" parent="VBoxContainer/MainArea/LeftColumn" unique_id=674103883]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
|
|
@ -204,6 +213,8 @@ layout_mode = 2
|
|||
[node name="JobSpawner" type="Timer" parent="." unique_id=1696213535]
|
||||
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/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"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue