extends PanelContainer var resource_name := "" var description := "" var accent := Color("91dbea") var icon_texture: Texture2D var _count: Label func _ready() -> void: custom_minimum_size = Vector2(86, 44) size_flags_horizontal = Control.SIZE_EXPAND_FILL var style := _style(false) add_theme_stylebox_override("panel", style) var row := HBoxContainer.new() row.add_theme_constant_override("separation", 5) add_child(row) var icon := TextureRect.new() icon.texture = icon_texture icon.custom_minimum_size = Vector2(32, 32) icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED icon.mouse_filter = Control.MOUSE_FILTER_IGNORE row.add_child(icon) _count = Label.new() _count.size_flags_horizontal = Control.SIZE_EXPAND_FILL _count.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT _count.add_theme_font_size_override("font_size", 11) _count.add_theme_color_override("font_color", accent.lightened(0.2)) _count.mouse_filter = Control.MOUSE_FILTER_IGNORE row.add_child(_count) row.mouse_filter = Control.MOUSE_FILTER_IGNORE mouse_entered.connect(func() -> void: add_theme_stylebox_override("panel", _style(true))) mouse_exited.connect(func() -> void: add_theme_stylebox_override("panel", _style(false))) set_amount(0) func _style(hovered: bool) -> StyleBoxFlat: var style := StyleBoxFlat.new() style.bg_color = Color("172737") if hovered else Color("0c1723") style.bg_color.a = 0.36 style.border_color = accent if hovered else accent.darkened(0.65) style.set_border_width_all(1) style.set_corner_radius_all(4) style.content_margin_left = 6 style.content_margin_right = 6 style.content_margin_top = 5 style.content_margin_bottom = 5 return style func set_amount(amount: float) -> void: if _count == null: return _count.text = str(roundi(amount)) if is_equal_approx(amount, roundf(amount)) else "%.1f" % amount tooltip_text = "%s\n%s\nZapas: %s" % [resource_name, description, _count.text] func _make_custom_tooltip(_text: String) -> Object: var panel := PanelContainer.new() panel.add_theme_stylebox_override("panel", _style(true)) var contents := VBoxContainer.new() contents.add_theme_constant_override("separation", 4) panel.add_child(contents) var title := Label.new() title.text = resource_name title.add_theme_font_size_override("font_size", 12) title.add_theme_color_override("font_color", accent) contents.add_child(title) var body := Label.new() body.text = description + "\nZapas: " + _count.text body.custom_minimum_size.x = 240 body.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART body.add_theme_font_size_override("font_size", 10) contents.add_child(body) return panel