101 lines
3.8 KiB
GDScript
101 lines
3.8 KiB
GDScript
extends PanelContainer
|
|
## Compact field instrument with the actual orbital planet portrait.
|
|
var source: Control
|
|
var health: ProgressBar
|
|
var status: Label
|
|
var cargo: Label
|
|
var threat: Label
|
|
var portrait: TextureRect
|
|
const INK := Color("dedcc9")
|
|
const MUTED := Color("a2ab94")
|
|
const GOLD := Color("d6b477")
|
|
|
|
func text(parent: Node, value: String, font_size := 11, color := INK) -> Label:
|
|
var label := Label.new()
|
|
label.text = value
|
|
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
label.add_theme_font_override("font",ThemeDB.fallback_font)
|
|
label.add_theme_font_size_override("font_size",clampi(font_size,10,13))
|
|
label.add_theme_color_override("font_color",color)
|
|
parent.add_child(label)
|
|
return label
|
|
|
|
func _ready() -> void:
|
|
name = "PlanetTelemetry"
|
|
position = Vector2(18,18)
|
|
custom_minimum_size.x = 350
|
|
size.x = 350
|
|
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
var frame := StyleBoxFlat.new()
|
|
frame.bg_color = Color(0.10,0.13,0.10,0.48)
|
|
frame.border_color = Color("8b805b")
|
|
frame.border_width_top = 2
|
|
frame.border_width_bottom = 1
|
|
frame.border_width_left = 1
|
|
frame.border_width_right = 1
|
|
frame.set_corner_radius_all(8)
|
|
frame.set_content_margin_all(8)
|
|
frame.shadow_color = Color(0,0,0,0.4)
|
|
frame.shadow_size = 10
|
|
add_theme_stylebox_override("panel",frame)
|
|
var stack := VBoxContainer.new()
|
|
stack.add_theme_constant_override("separation",5)
|
|
add_child(stack)
|
|
text(stack,"DZIENNIK PLANETARNY / WYPRAWA",10,GOLD)
|
|
var heading := HBoxContainer.new()
|
|
heading.add_theme_constant_override("separation",10)
|
|
stack.add_child(heading)
|
|
var medallion := Control.new()
|
|
medallion.custom_minimum_size = Vector2(88,88)
|
|
medallion.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
heading.add_child(medallion)
|
|
var sky := Panel.new()
|
|
sky.position = Vector2(10,10)
|
|
sky.size = Vector2(68,68)
|
|
var circle := StyleBoxFlat.new()
|
|
circle.bg_color = Color("08100d")
|
|
circle.set_corner_radius_all(34)
|
|
sky.add_theme_stylebox_override("panel",circle)
|
|
medallion.add_child(sky)
|
|
portrait = TextureRect.new()
|
|
portrait.name = "PlanetPortrait"
|
|
portrait.position = Vector2(11,11)
|
|
portrait.size = Vector2(66,66)
|
|
portrait.texture = source.planet_texture
|
|
portrait.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
portrait.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
portrait.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR
|
|
medallion.add_child(portrait)
|
|
var bezel := TextureRect.new()
|
|
bezel.texture = load("res://assets/planets/ui/planet_bezel.png")
|
|
bezel.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
|
bezel.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
|
bezel.size = Vector2(88,88)
|
|
bezel.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR_WITH_MIPMAPS
|
|
medallion.add_child(bezel)
|
|
var title := VBoxContainer.new()
|
|
title.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
title.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
|
title.add_theme_constant_override("separation",3)
|
|
heading.add_child(title)
|
|
text(title,str(source.progress.active_profile.name),19,GOLD)
|
|
text(title,str(source.world.data.landscape.name),12)
|
|
text(title,preload("res://scripts/planets/planet_profiles.gd").biome_name(source.progress.active_profile),10,MUTED)
|
|
text(title,"Poziom %d" % preload("res://scripts/planets/planet_profiles.gd").level(source.progress.active_profile),12,MUTED)
|
|
threat = text(stack,"",11,GOLD)
|
|
threat.hide()
|
|
health = ProgressBar.new()
|
|
health.custom_minimum_size.y = 6
|
|
health.show_percentage = false
|
|
for state in ["background","fill"]:
|
|
var bar := StyleBoxFlat.new()
|
|
bar.bg_color = Color("86ae82") if state == "fill" else Color("30392b")
|
|
bar.set_corner_radius_all(3)
|
|
health.add_theme_stylebox_override(state,bar)
|
|
stack.add_child(health)
|
|
status = text(stack,"",10,MUTED)
|
|
cargo = text(stack,"",10,INK)
|
|
cargo.max_lines_visible = 3
|
|
cargo.mouse_filter = Control.MOUSE_FILTER_PASS
|
|
cargo.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|