Add tile detail drawer, click-to-focus-camera, and occupied tile click redirect
- Right-side slide-in drawer shows tile coords, affinity, base1/base2, ruin, and occupant name when any tile is clicked in NONE mode; auto-closes on mode change - New 'Focus camera when clicking a tile' setting (Settings.click_to_focus_camera), toggled in in-game settings panel, tweens camera to clicked tile - Clicking a tile occupied by a unit now redirects to that unit in both NONE and UNIT_SELECTED modes, so you no longer need to hit the unit mesh exactly Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -56,6 +56,13 @@ var camera_follow_unit : bool = true :
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
## When true, clicking any tile smoothly pans the camera to center on it.
|
||||
var click_to_focus_camera : bool = false :
|
||||
set(v):
|
||||
click_to_focus_camera = v
|
||||
_save()
|
||||
settings_changed.emit()
|
||||
|
||||
## Skybox display mode in gameplay scenes.
|
||||
## "live" — near-black sky with emissive stars; each star = an active game session.
|
||||
## "cdn" — server-configured panoramic or animated skybox image.
|
||||
@@ -138,7 +145,8 @@ func _load() -> void:
|
||||
music_muted = bool(cfg.get_value(SECTION, "music_muted", false))
|
||||
sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0))
|
||||
sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false))
|
||||
camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true))
|
||||
camera_follow_unit = bool(cfg.get_value(SECTION_GAMEPLAY, "camera_follow_unit", true))
|
||||
click_to_focus_camera = bool(cfg.get_value(SECTION_GAMEPLAY, "click_to_focus_camera", false))
|
||||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||||
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
||||
if raw_overrides is Dictionary:
|
||||
@@ -151,7 +159,8 @@ func _save() -> void:
|
||||
cfg.set_value(SECTION, "music_muted", music_muted)
|
||||
cfg.set_value(SECTION, "sfx_volume", sfx_volume)
|
||||
cfg.set_value(SECTION, "sfx_muted", sfx_muted)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "camera_follow_unit", camera_follow_unit)
|
||||
cfg.set_value(SECTION_GAMEPLAY, "click_to_focus_camera", click_to_focus_camera)
|
||||
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||||
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
||||
cfg.save(SAVE_PATH)
|
||||
|
||||
@@ -120,7 +120,7 @@ func _build_fields(r: Dictionary) -> void:
|
||||
|
||||
# Board template picker — populate from BoardTemplateCache (GUID values, not labels).
|
||||
var tmpl_key := "boardTemplateIdOverride"
|
||||
var cur_tmpl_id := get_s.call(tmpl_key, "")
|
||||
var cur_tmpl_id : Variant = get_s.call(tmpl_key, "")
|
||||
var custom_tmpls : Array = BoardTemplateCache.get_templates_for_custom()
|
||||
var tmpl_hbox := HBoxContainer.new()
|
||||
var tmpl_lbl := Label.new()
|
||||
|
||||
@@ -108,6 +108,11 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Center camera on selected unit"
|
||||
|
||||
[node name="TileFocusCamera" type="CheckButton" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Focus camera when clicking a tile"
|
||||
|
||||
[node name="SkyboxRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
|
||||
@@ -152,6 +152,17 @@ var _ability_confirm_btn : Control = null # "Done" button shown for Up
|
||||
var _ability_branch_panel : Control = null # ChooseOne branch selector panel
|
||||
var _player_panel : Control = null
|
||||
|
||||
# Tile detail drawer (right-side slide-in panel)
|
||||
var _tile_drawer : PanelContainer = null
|
||||
var _tile_drawer_open : bool = false
|
||||
var _tile_drawer_tween : Tween = null
|
||||
var _tile_drawer_lbl_coord : Label = null
|
||||
var _tile_drawer_lbl_aff : Label = null
|
||||
var _tile_drawer_lbl_b1 : Label = null
|
||||
var _tile_drawer_lbl_b2 : Label = null
|
||||
var _tile_drawer_lbl_ruin : Label = null
|
||||
var _tile_drawer_lbl_occ : Label = null
|
||||
|
||||
# ── Unit ownership lookup ─────────────────────────────────────────────────────
|
||||
# Rebuilt on each state update for O(1) ownership checks.
|
||||
var _enemy_unit_ids : Dictionary = {} # instanceId → true
|
||||
@@ -244,6 +255,7 @@ func _ready() -> void:
|
||||
_go_menu_btn.pressed.connect(func() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn"))
|
||||
_hold_timer.timeout.connect(_on_hold_timer_fired)
|
||||
_create_tile_drawer()
|
||||
|
||||
# Chat overlay — add to viewport root so it renders above everything.
|
||||
var _chat_overlay := _CHAT_OVERLAY_SCENE.instantiate()
|
||||
@@ -2333,6 +2345,130 @@ func _valid_sacrifice_spirits() -> Array:
|
||||
results.append(unit)
|
||||
return results
|
||||
|
||||
# ── Tile detail drawer ────────────────────────────────────────────────────────
|
||||
|
||||
func _create_tile_drawer() -> void:
|
||||
var panel := PanelContainer.new()
|
||||
panel.anchor_left = 1.0
|
||||
panel.anchor_right = 1.0
|
||||
panel.anchor_top = 0.0
|
||||
panel.anchor_bottom = 1.0
|
||||
panel.offset_left = 0.0
|
||||
panel.offset_right = 0.0
|
||||
panel.offset_top = 0.0
|
||||
panel.offset_bottom = 0.0
|
||||
panel.visible = false
|
||||
_hud.add_child(panel)
|
||||
_tile_drawer = panel
|
||||
|
||||
var margin := MarginContainer.new()
|
||||
margin.layout_mode = 2
|
||||
margin.add_theme_constant_override("margin_left", 12)
|
||||
margin.add_theme_constant_override("margin_right", 12)
|
||||
margin.add_theme_constant_override("margin_top", 12)
|
||||
margin.add_theme_constant_override("margin_bottom", 12)
|
||||
panel.add_child(margin)
|
||||
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.layout_mode = 2
|
||||
vbox.add_theme_constant_override("separation", 6)
|
||||
margin.add_child(vbox)
|
||||
|
||||
# Title row with close button.
|
||||
var title_row := HBoxContainer.new()
|
||||
title_row.layout_mode = 2
|
||||
var title_lbl := Label.new()
|
||||
title_lbl.text = "Tile Detail"
|
||||
title_lbl.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
title_lbl.add_theme_font_size_override("font_size", 15)
|
||||
var close_btn := Button.new()
|
||||
close_btn.text = "×"
|
||||
close_btn.custom_minimum_size = Vector2(28, 28)
|
||||
close_btn.pressed.connect(_close_tile_drawer)
|
||||
title_row.add_child(title_lbl)
|
||||
title_row.add_child(close_btn)
|
||||
vbox.add_child(title_row)
|
||||
|
||||
var sep := HSeparator.new()
|
||||
sep.layout_mode = 2
|
||||
vbox.add_child(sep)
|
||||
|
||||
# Detail labels.
|
||||
_tile_drawer_lbl_coord = Label.new()
|
||||
_tile_drawer_lbl_aff = Label.new()
|
||||
_tile_drawer_lbl_b1 = Label.new()
|
||||
_tile_drawer_lbl_b2 = Label.new()
|
||||
_tile_drawer_lbl_ruin = Label.new()
|
||||
_tile_drawer_lbl_occ = Label.new()
|
||||
for lbl: Label in [_tile_drawer_lbl_coord, _tile_drawer_lbl_aff,
|
||||
_tile_drawer_lbl_b1, _tile_drawer_lbl_b2,
|
||||
_tile_drawer_lbl_ruin, _tile_drawer_lbl_occ]:
|
||||
lbl.layout_mode = 2
|
||||
lbl.add_theme_font_size_override("font_size", 12)
|
||||
lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
vbox.add_child(lbl)
|
||||
|
||||
|
||||
func _open_tile_drawer(tile: Dictionary) -> void:
|
||||
if not is_instance_valid(_tile_drawer): return
|
||||
var coord : Dictionary = tile.get("coord", {})
|
||||
var cx : int = int(coord.get("x", 0))
|
||||
var cy : int = int(coord.get("y", 0))
|
||||
var aff : String = str(tile.get("resolvedAffinity", "?"))
|
||||
var b1 : String = str(tile.get("base1", "?"))
|
||||
var b2 : String = str(tile.get("base2", "?"))
|
||||
var ruin_id : String = str(tile.get("ruinId", ""))
|
||||
var occ_id : String = str(tile.get("occupantId", ""))
|
||||
|
||||
_tile_drawer_lbl_coord.text = "(%d, %d)" % [cx, cy]
|
||||
_tile_drawer_lbl_aff.text = "Affinity: %s" % aff
|
||||
_tile_drawer_lbl_b1.text = "Base1: %s" % b1
|
||||
_tile_drawer_lbl_b2.text = "Base2: %s" % b2
|
||||
|
||||
if not ruin_id.is_empty() and ruin_id != "null":
|
||||
_tile_drawer_lbl_ruin.text = "Ruin: %s" % ruin_id
|
||||
_tile_drawer_lbl_ruin.visible = true
|
||||
else:
|
||||
_tile_drawer_lbl_ruin.visible = false
|
||||
|
||||
if not occ_id.is_empty() and occ_id != "null":
|
||||
var occ_unit := Game.get_unit_by_id(occ_id)
|
||||
_tile_drawer_lbl_occ.text = "Occupant: %s" % (
|
||||
occ_unit.get("name", occ_id) if not occ_unit.is_empty() else occ_id)
|
||||
_tile_drawer_lbl_occ.visible = true
|
||||
else:
|
||||
_tile_drawer_lbl_occ.visible = false
|
||||
|
||||
if _tile_drawer_open:
|
||||
return # already open, content updated above
|
||||
_tile_drawer_open = true
|
||||
_tile_drawer.visible = true
|
||||
if _tile_drawer_tween: _tile_drawer_tween.kill()
|
||||
_tile_drawer.offset_left = 0.0
|
||||
_tile_drawer_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
|
||||
_tile_drawer_tween.tween_property(_tile_drawer, "offset_left", -260.0, 0.3)
|
||||
|
||||
|
||||
func _close_tile_drawer() -> void:
|
||||
if not is_instance_valid(_tile_drawer) or not _tile_drawer_open: return
|
||||
_tile_drawer_open = false
|
||||
if _tile_drawer_tween: _tile_drawer_tween.kill()
|
||||
_tile_drawer_tween = create_tween().set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_CUBIC)
|
||||
_tile_drawer_tween.tween_property(_tile_drawer, "offset_left", 0.0, 0.25)
|
||||
_tile_drawer_tween.tween_callback(func() -> void:
|
||||
if is_instance_valid(_tile_drawer): _tile_drawer.visible = false)
|
||||
|
||||
|
||||
func _focus_camera_on_tile(x: int, y: int) -> void:
|
||||
var target := _coord_to_world(x, y)
|
||||
var from := _cam_pivot
|
||||
if _cam_tween: _cam_tween.kill()
|
||||
_cam_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
|
||||
_cam_tween.tween_method(
|
||||
func(v: Vector3) -> void: _cam_pivot = v; _apply_camera(),
|
||||
from, target, 0.4)
|
||||
|
||||
|
||||
# ── Click handling ────────────────────────────────────────────────────────────
|
||||
|
||||
func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
@@ -2342,6 +2478,18 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
match _mode:
|
||||
|
||||
Mode.NONE:
|
||||
# Occupied tile with no direct unit-mesh hit → redirect to the occupant.
|
||||
if unit_id.is_empty() and coord.x >= 0:
|
||||
var _t := Game.get_tile(coord.x, coord.y)
|
||||
var _occ := str(_t.get("occupantId", ""))
|
||||
if not _occ.is_empty() and _occ != "null":
|
||||
unit_id = _occ
|
||||
# Show tile detail drawer and optionally pan camera.
|
||||
if coord.x >= 0:
|
||||
_open_tile_drawer(Game.get_tile(coord.x, coord.y))
|
||||
if Settings.click_to_focus_camera:
|
||||
_focus_camera_on_tile(coord.x, coord.y)
|
||||
# Unit selection.
|
||||
if not unit_id.is_empty() and _is_friendly_unit(unit_id) \
|
||||
and Game.is_my_turn() and Game.get_phase() != "Placement":
|
||||
_select_unit(unit_id)
|
||||
@@ -2400,6 +2548,12 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||
_add_highlight(nx, ny, "movement")
|
||||
|
||||
Mode.UNIT_SELECTED:
|
||||
# Occupied tile with no direct unit-mesh hit → redirect to the occupant.
|
||||
if unit_id.is_empty() and coord.x >= 0:
|
||||
var _t2 := Game.get_tile(coord.x, coord.y)
|
||||
var _occ2 := str(_t2.get("occupantId", ""))
|
||||
if not _occ2.is_empty() and _occ2 != "null":
|
||||
unit_id = _occ2
|
||||
if not unit_id.is_empty():
|
||||
if _is_enemy_unit(unit_id):
|
||||
_last_attack_target_iid = unit_id
|
||||
@@ -2506,6 +2660,8 @@ func _set_mode(new_mode: Mode) -> void:
|
||||
_mode = new_mode
|
||||
_terra_targets = []
|
||||
_terra_count = 0
|
||||
if new_mode != Mode.NONE:
|
||||
_close_tile_drawer()
|
||||
if new_mode == Mode.NONE:
|
||||
_sel_card_id = ""
|
||||
_sel_unit_id = ""
|
||||
|
||||
@@ -7,6 +7,7 @@ extends PanelContainer
|
||||
@onready var _sfx_slider : HSlider = %SfxSlider
|
||||
@onready var _sfx_mute : CheckButton = %SfxMute
|
||||
@onready var _cam_follow : CheckButton = %CameraFollowUnit
|
||||
@onready var _tile_focus_cam : CheckButton = %TileFocusCamera
|
||||
@onready var _skybox_opt : OptionButton = %SkyboxModeOption
|
||||
@onready var _sync_btn : Button = %SyncBtn
|
||||
@onready var _concede_btn : Button = %ConcedeBtn
|
||||
@@ -26,6 +27,7 @@ func _ready() -> void:
|
||||
_sfx_slider.value_changed.connect(_on_sfx_volume_changed)
|
||||
_sfx_mute.toggled.connect(_on_sfx_mute_toggled)
|
||||
_cam_follow.toggled.connect(func(v: bool) -> void: Settings.camera_follow_unit = v)
|
||||
_tile_focus_cam.toggled.connect(func(v: bool) -> void: Settings.click_to_focus_camera = v)
|
||||
_skybox_opt.item_selected.connect(_on_skybox_mode_changed)
|
||||
|
||||
_sync_btn.pressed.connect(_on_sync_pressed)
|
||||
@@ -55,6 +57,7 @@ func _sync_from_settings() -> void:
|
||||
_sfx_slider.set_value_no_signal(Settings.sfx_volume)
|
||||
_sfx_mute.set_pressed_no_signal(Settings.sfx_muted)
|
||||
_cam_follow.set_pressed_no_signal(Settings.camera_follow_unit)
|
||||
_tile_focus_cam.set_pressed_no_signal(Settings.click_to_focus_camera)
|
||||
_skybox_opt.selected = ["live", "cdn", "off"].find(Settings.skybox_mode)
|
||||
_music_slider.modulate.a = 0.4 if Settings.music_muted else 1.0
|
||||
_sfx_slider.modulate.a = 0.4 if Settings.sfx_muted else 1.0
|
||||
|
||||
Reference in New Issue
Block a user