67 lines
2.8 KiB
GDScript
67 lines
2.8 KiB
GDScript
extends Control
|
||
const GEAR := preload("res://scripts/planets/captain_equipment.gd")
|
||
var _reductions: Dictionary = {}
|
||
func _ready() -> void:
|
||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
var figure := TextureRect.new()
|
||
figure.name = "CaptainSilhouette"
|
||
figure.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||
figure.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||
figure.texture = load("res://assets/avatars/captain_full_body.png")
|
||
figure.position = Vector2(43,0)
|
||
figure.size = Vector2(144,248)
|
||
figure.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
|
||
figure.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
add_child(figure)
|
||
var positions := [Vector2(5,26),Vector2(175,88),Vector2(175,174)]
|
||
for index in GEAR.KINDS.size():
|
||
var kind: String = GEAR.KINDS[index]
|
||
var slot := PanelContainer.new()
|
||
slot.name = kind.capitalize()+"Slot"
|
||
slot.set_script(preload("res://scripts/ui/captain_gear_slot.gd"))
|
||
slot.set("kind",kind)
|
||
slot.position = positions[index]
|
||
add_child(slot)
|
||
var reduction := Label.new()
|
||
reduction.position = positions[index]+Vector2(0,-18)
|
||
reduction.size.x = 48
|
||
reduction.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
reduction.add_theme_font_override("font",ThemeDB.fallback_font)
|
||
reduction.add_theme_font_size_override("font_size",11)
|
||
reduction.add_theme_color_override("font_color",Color("a5d6ac"))
|
||
reduction.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
add_child(reduction)
|
||
_reductions[kind] = reduction
|
||
var label := Label.new()
|
||
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||
label.text = {"breathing":"Oddychanie","suit":"Skafander","sidearm":"Broń ręczna"}[kind]
|
||
label.position = positions[index]+Vector2(-5,51)
|
||
label.size.x = 58
|
||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||
label.add_theme_font_override("font",ThemeDB.fallback_font)
|
||
label.add_theme_font_size_override("font_size",9)
|
||
label.add_theme_color_override("font_color",Color("c3b894"))
|
||
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||
add_child(label)
|
||
GameState.captain.changed.connect(_refresh_reductions)
|
||
_refresh_reductions()
|
||
|
||
func _refresh_reductions() -> void:
|
||
for kind in _reductions:
|
||
_reductions[kind].text = "−%d%%" % mini(100,2*GEAR.level(GameState.captain,kind))
|
||
|
||
func _draw() -> void:
|
||
draw_style_box(_background(),Rect2(Vector2.ZERO,size))
|
||
draw_arc(Vector2(114,126),84,0,TAU,80,Color(0.7,0.6,0.4,0.10),1,true)
|
||
for pair in [[Vector2(53,50),Vector2(110,39)],[Vector2(175,112),Vector2(126,92)],[Vector2(175,198),Vector2(133,157)]]:
|
||
draw_line(pair[0],pair[1],Color(0.75,0.65,0.43,0.45),1,true)
|
||
draw_circle(pair[1],2,Color("aa9665"))
|
||
|
||
func _background() -> StyleBoxFlat:
|
||
var style := StyleBoxFlat.new()
|
||
style.bg_color = Color("0c1419")
|
||
style.border_color = Color("3f514e")
|
||
style.set_border_width_all(1)
|
||
style.set_corner_radius_all(6)
|
||
return style
|