73 lines
2.9 KiB
GDScript
73 lines
2.9 KiB
GDScript
extends PanelContainer
|
||
|
||
const BALANCE := preload("res://scripts/captain/captain_balance.gd")
|
||
|
||
@onready var player: CharacterBody2D = get_node("../../../PlayerShip")
|
||
@onready var level_label: Label = $Contents/Header/Level
|
||
@onready var xp_label: Label = $Contents/XPLabel
|
||
@onready var xp_bar: ProgressBar = $Contents/XPBar
|
||
@onready var credits_label: Label = $Contents/Wallet/Credits
|
||
@onready var points_label: Label = $Contents/Wallet/Points
|
||
@onready var critical_label: Label = $Contents/Critical
|
||
|
||
var _captain: CaptainProgress
|
||
var _rank_labels: Dictionary = {}
|
||
var _effect_labels: Dictionary = {}
|
||
var _buttons: Dictionary = {}
|
||
|
||
func _ready() -> void:
|
||
_captain = GameState.captain
|
||
for skill in BALANCE.SKILL_NAMES:
|
||
var row := HBoxContainer.new()
|
||
row.name = skill
|
||
row.add_theme_constant_override("separation", 5)
|
||
var title := Label.new()
|
||
title.text = BALANCE.SKILL_NAMES[skill]
|
||
title.tooltip_text = BALANCE.SKILL_HELP[skill]
|
||
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
title.add_theme_font_size_override("font_size", 11)
|
||
row.add_child(title)
|
||
var rank := Label.new()
|
||
rank.custom_minimum_size.x = 22
|
||
rank.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||
rank.add_theme_font_size_override("font_size", 11)
|
||
row.add_child(rank)
|
||
_rank_labels[skill] = rank
|
||
var effect := Label.new()
|
||
effect.custom_minimum_size.x = 58
|
||
effect.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||
effect.add_theme_font_size_override("font_size", 10)
|
||
row.add_child(effect)
|
||
_effect_labels[skill] = effect
|
||
var button := Button.new()
|
||
button.name = "Train_" + skill
|
||
button.text = "+"
|
||
button.custom_minimum_size = Vector2(24, 22)
|
||
button.add_theme_font_size_override("font_size", 13)
|
||
button.tooltip_text = "Rozwiń umiejętność za 1 punkt nauki.\n" + BALANCE.SKILL_HELP[skill]
|
||
button.pressed.connect(_train.bind(skill))
|
||
row.add_child(button)
|
||
_buttons[skill] = button
|
||
$Contents/Skills.add_child(row)
|
||
_captain.changed.connect(_refresh)
|
||
player.get_node("ShipInventory").connect("inventory_changed", _refresh)
|
||
_refresh()
|
||
|
||
func _train(skill: String) -> void:
|
||
_captain.train_skill(skill)
|
||
|
||
func _refresh() -> void:
|
||
level_label.text = "POZ. %d" % _captain.level
|
||
xp_label.text = "XP %d / %d" % [_captain.experience, _captain.get_xp_required()]
|
||
xp_bar.max_value = _captain.get_xp_required()
|
||
xp_bar.value = _captain.experience
|
||
credits_label.text = "Kredyty: %d" % _captain.credits
|
||
points_label.text = "Punkty: %d" % _captain.learning_points
|
||
for skill in _buttons:
|
||
var rank := _captain.get_skill_rank(skill)
|
||
_rank_labels[skill].text = str(rank)
|
||
var suffix: String = {"piloting": "unik", "gunner": "DMG", "mechanic": "redukcji", "sharp_eye": "kryt"}[skill]
|
||
_effect_labels[skill].text = "%d%% %s" % [rank, suffix]
|
||
_buttons[skill].disabled = not _captain.can_train(skill)
|
||
critical_label.text = "Krytyk: %.1f%% · ×%.2f\nCzęści: %.1f" % [float(player.call("get_critical_chance")) * 100.0, float(player.call("get_critical_multiplier")), _captain.parts]
|