class_name LuneArmyChip extends Button ## One own troop in the army strip: real-model portrait, a band with its lane (T, M, B or G) ## and stage (II for upgraded troops). Selected = pressed style. In combat a fallen troop is ## dimmed and crossed out. Size adapts to how many troops the strip must hold. const BAND: float = 15.0 var uid: String = "" var type_id: String = "" var lane: String = "mid" var fallen: bool = false: set(value): if value != fallen: fallen = value portrait.dimmed = value portrait.crossed = value var portrait: LunePortraitRect func _init() -> void: theme_type_variation = "HudChip" toggle_mode = true focus_mode = Control.FOCUS_ALL mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND portrait = LunePortraitRect.new() add_child(portrait) resized.connect(_place) func setup(entry: Dictionary, edge: float) -> void: uid = str(entry.uid) type_id = str(entry.type_id) lane = str(entry.lane) custom_minimum_size = Vector2(edge, edge + BAND) portrait.show_model(type_id) _place() queue_redraw() func _place() -> void: portrait.position = Vector2(2, 2) portrait.size = Vector2(size.x - 4.0, size.y - BAND - 2.0) func _draw() -> void: var band := Rect2(Vector2(2, size.y - BAND - 1.0), Vector2(size.x - 4.0, BAND)) draw_rect(band, Color(0, 0, 0, .55)) var font: Font = get_theme_font("font", "HudCaps") var grotto: bool = lane == LuneMatch.GROTTO var letter: String = "G" if grotto else str(LuneMap.LANE_NAMES.get(lane, "?")).left(1) var size_px: int = 13 draw_string(font, Vector2(5, size.y - 5.0), letter, HORIZONTAL_ALIGNMENT_LEFT, -1, size_px, LuneUiTheme.TEAM[2] if grotto else LuneUiTheme.BRONZE_LIGHT) if LuneHudModel.stage_of(type_id) == 2: draw_string(font, Vector2(size.x - 20.0, size.y - 5.0), "II", HORIZONTAL_ALIGNMENT_LEFT, -1, size_px, LuneUiTheme.GOLD)