Set web client to 72fba92 baseline for confirmation
This commit is contained in:
@@ -159,7 +159,7 @@ func join(lid: String, deck_id: String, password: String,
|
|||||||
lobby["hasGuest"] = true
|
lobby["hasGuest"] = true
|
||||||
lobby["additionalPlayers"] = d.get("additionalPlayers", [])
|
lobby["additionalPlayers"] = d.get("additionalPlayers", [])
|
||||||
# Apply team assignments from join response if present.
|
# Apply team assignments from join response if present.
|
||||||
var raw_st := d.get("seatTeams", null)
|
var raw_st : Variant = d.get("seatTeams", null)
|
||||||
if raw_st != null:
|
if raw_st != null:
|
||||||
seat_teams.clear()
|
seat_teams.clear()
|
||||||
for k in (raw_st as Dictionary):
|
for k in (raw_st as Dictionary):
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ signal player_eliminated(session_id: String, eliminated_account_id: String, seat
|
|||||||
## event_type: "started" | "ended"
|
## event_type: "started" | "ended"
|
||||||
signal game_activity(event_type: String, session_id: String)
|
signal game_activity(event_type: String, session_id: String)
|
||||||
|
|
||||||
|
## Emitted when a Triggered ability needs the local player to pick a target.
|
||||||
|
## Payload keys: requestId, sourceInstanceId, abilityName, actionJson, rangeJson
|
||||||
|
signal triggered_target_request(request_data: Dictionary)
|
||||||
|
|
||||||
# ── State ─────────────────────────────────────────────────────────────────────
|
# ── State ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
var session_id : String = ""
|
var session_id : String = ""
|
||||||
@@ -333,6 +337,13 @@ func send_activate_ability(source_id: String, ability_index: int,
|
|||||||
payload["targets"] = targets
|
payload["targets"] = targets
|
||||||
_game_request("game.activate_ability", payload)
|
_game_request("game.activate_ability", payload)
|
||||||
|
|
||||||
|
|
||||||
|
func send_triggered_target_response(request_id: String, targets: Array) -> void:
|
||||||
|
var payload : Dictionary = { "requestId": request_id }
|
||||||
|
if not targets.is_empty():
|
||||||
|
payload["targets"] = targets
|
||||||
|
_game_request("game.triggered_target", payload)
|
||||||
|
|
||||||
# ── Private ───────────────────────────────────────────────────────────────────
|
# ── Private ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func _game_request(msg_type: String, extra: Dictionary) -> void:
|
func _game_request(msg_type: String, extra: Dictionary) -> void:
|
||||||
@@ -648,3 +659,6 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
|||||||
var ev_type : String = str(d.get("eventType", ""))
|
var ev_type : String = str(d.get("eventType", ""))
|
||||||
var ev_sid : String = str(d.get("sessionId", ""))
|
var ev_sid : String = str(d.get("sessionId", ""))
|
||||||
game_activity.emit(ev_type, ev_sid)
|
game_activity.emit(ev_type, ev_sid)
|
||||||
|
|
||||||
|
"game.ability.triggered_target_request":
|
||||||
|
triggered_target_request.emit(payload as Dictionary)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const SECTION := "audio"
|
|||||||
const SECTION_GAMEPLAY := "gameplay"
|
const SECTION_GAMEPLAY := "gameplay"
|
||||||
const SECTION_VISUAL := "visual"
|
const SECTION_VISUAL := "visual"
|
||||||
const SECTION_HIGHLIGHTS := "highlights"
|
const SECTION_HIGHLIGHTS := "highlights"
|
||||||
|
const SECTION_CAMERA := "camera"
|
||||||
|
|
||||||
## Audio bus names as configured in the Godot project.
|
## Audio bus names as configured in the Godot project.
|
||||||
const BUS_MUSIC := "Music"
|
const BUS_MUSIC := "Music"
|
||||||
@@ -56,6 +57,13 @@ var camera_follow_unit : bool = true :
|
|||||||
_save()
|
_save()
|
||||||
settings_changed.emit()
|
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.
|
## Skybox display mode in gameplay scenes.
|
||||||
## "live" — near-black sky with emissive stars; each star = an active game session.
|
## "live" — near-black sky with emissive stars; each star = an active game session.
|
||||||
## "cdn" — server-configured panoramic or animated skybox image.
|
## "cdn" — server-configured panoramic or animated skybox image.
|
||||||
@@ -66,6 +74,15 @@ var skybox_mode : String = "live" :
|
|||||||
_save()
|
_save()
|
||||||
settings_changed.emit()
|
settings_changed.emit()
|
||||||
|
|
||||||
|
## How touch camera control is activated.
|
||||||
|
## "gesture" — hold finger(s) still for 3 s to activate (1 = orbit, 2 = zoom, 3 = pan).
|
||||||
|
## "buttons" — tap the on-screen Orbit / Pan / Zoom toggle buttons.
|
||||||
|
var touch_camera_mode : String = "gesture" :
|
||||||
|
set(v):
|
||||||
|
touch_camera_mode = v
|
||||||
|
_save()
|
||||||
|
settings_changed.emit()
|
||||||
|
|
||||||
## Per-type highlight texture URL overrides entered by the player.
|
## Per-type highlight texture URL overrides entered by the player.
|
||||||
## Keys: "movement", "attack", "ability", "terramorpha", "selector"
|
## Keys: "movement", "attack", "ability", "terramorpha", "selector"
|
||||||
## Value: URL string, or "" to use the server default.
|
## Value: URL string, or "" to use the server default.
|
||||||
@@ -138,7 +155,9 @@ func _load() -> void:
|
|||||||
music_muted = bool(cfg.get_value(SECTION, "music_muted", false))
|
music_muted = bool(cfg.get_value(SECTION, "music_muted", false))
|
||||||
sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0))
|
sfx_volume = float(cfg.get_value(SECTION, "sfx_volume", 1.0))
|
||||||
sfx_muted = bool(cfg.get_value(SECTION, "sfx_muted", false))
|
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))
|
||||||
|
touch_camera_mode = str(cfg.get_value(SECTION_CAMERA, "touch_camera_mode", "gesture"))
|
||||||
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
skybox_mode = str(cfg.get_value(SECTION_VISUAL, "skybox_mode", "live"))
|
||||||
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
var raw_overrides = cfg.get_value(SECTION_HIGHLIGHTS, "highlight_overrides", {})
|
||||||
if raw_overrides is Dictionary:
|
if raw_overrides is Dictionary:
|
||||||
@@ -151,7 +170,9 @@ func _save() -> void:
|
|||||||
cfg.set_value(SECTION, "music_muted", music_muted)
|
cfg.set_value(SECTION, "music_muted", music_muted)
|
||||||
cfg.set_value(SECTION, "sfx_volume", sfx_volume)
|
cfg.set_value(SECTION, "sfx_volume", sfx_volume)
|
||||||
cfg.set_value(SECTION, "sfx_muted", sfx_muted)
|
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_CAMERA, "touch_camera_mode", touch_camera_mode)
|
||||||
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
cfg.set_value(SECTION_VISUAL, "skybox_mode", skybox_mode)
|
||||||
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
cfg.set_value(SECTION_HIGHLIGHTS, "highlight_overrides", highlight_overrides)
|
||||||
cfg.save(SAVE_PATH)
|
cfg.save(SAVE_PATH)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ func _build_fields(r: Dictionary) -> void:
|
|||||||
|
|
||||||
# Board template picker — populate from BoardTemplateCache (GUID values, not labels).
|
# Board template picker — populate from BoardTemplateCache (GUID values, not labels).
|
||||||
var tmpl_key := "boardTemplateIdOverride"
|
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 custom_tmpls : Array = BoardTemplateCache.get_templates_for_custom()
|
||||||
var tmpl_hbox := HBoxContainer.new()
|
var tmpl_hbox := HBoxContainer.new()
|
||||||
var tmpl_lbl := Label.new()
|
var tmpl_lbl := Label.new()
|
||||||
|
|||||||
@@ -320,3 +320,46 @@ unique_name_in_owner = true
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
wait_time = 0.5
|
wait_time = 0.5
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="CamGestureTimer" type="Timer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
wait_time = 3.0
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="CamCtrlPanel" type="PanelContainer" parent="HUD"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 56.0
|
||||||
|
offset_right = 104.0
|
||||||
|
offset_bottom = 200.0
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="CamCtrlVBox" type="VBoxContainer" parent="HUD/CamCtrlPanel"]
|
||||||
|
layout_mode = 2
|
||||||
|
theme_override_constants/separation = 4
|
||||||
|
|
||||||
|
[node name="CamOrbitBtn" type="Button" parent="HUD/CamCtrlPanel/CamCtrlVBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(0, 44)
|
||||||
|
toggle_mode = true
|
||||||
|
text = "Orbit"
|
||||||
|
|
||||||
|
[node name="CamPanBtn" type="Button" parent="HUD/CamCtrlPanel/CamCtrlVBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(0, 44)
|
||||||
|
toggle_mode = true
|
||||||
|
text = "Pan"
|
||||||
|
|
||||||
|
[node name="CamZoomBtn" type="Button" parent="HUD/CamCtrlPanel/CamCtrlVBox"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(0, 44)
|
||||||
|
toggle_mode = true
|
||||||
|
text = "Zoom"
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ anchor_top = 0.5
|
|||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
offset_left = -220.0
|
offset_left = -220.0
|
||||||
offset_top = -278.0
|
offset_top = -305.0
|
||||||
offset_right = 220.0
|
offset_right = 220.0
|
||||||
offset_bottom = 278.0
|
offset_bottom = 305.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_script")
|
script = ExtResource("1_script")
|
||||||
@@ -108,6 +108,39 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Center camera on selected unit"
|
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="HSeparatorCam" type="HSeparator" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="CameraLabel" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Camera Controls"
|
||||||
|
theme_override_font_sizes/font_size = 13
|
||||||
|
|
||||||
|
[node name="TouchCamRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="TouchCamLabel" type="Label" parent="MarginContainer/VBoxContainer/TouchCamRow"]
|
||||||
|
layout_mode = 2
|
||||||
|
custom_minimum_size = Vector2(100, 0)
|
||||||
|
text = "Touch Camera"
|
||||||
|
vertical_alignment = 1
|
||||||
|
|
||||||
|
[node name="TouchCamModeOption" type="OptionButton" parent="MarginContainer/VBoxContainer/TouchCamRow"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
item_count = 2
|
||||||
|
popup/item_0/text = "Gesture (long hold)"
|
||||||
|
popup/item_0/id = 0
|
||||||
|
popup/item_1/text = "Buttons (tap toggle)"
|
||||||
|
popup/item_1/id = 1
|
||||||
|
selected = 0
|
||||||
|
|
||||||
[node name="SkyboxRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
[node name="SkyboxRow" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,12 @@ enum Mode {
|
|||||||
@onready var _tiles_root : Node3D = $BoardRoot/TilesRoot
|
@onready var _tiles_root : Node3D = $BoardRoot/TilesRoot
|
||||||
@onready var _units_root : Node3D = $BoardRoot/UnitsRoot
|
@onready var _units_root : Node3D = $BoardRoot/UnitsRoot
|
||||||
@onready var _hi_root : Node3D = $BoardRoot/HighlightsRoot
|
@onready var _hi_root : Node3D = $BoardRoot/HighlightsRoot
|
||||||
@onready var _hold_timer : Timer = $HoldTimer
|
@onready var _hold_timer : Timer = $HoldTimer
|
||||||
|
@onready var _cam_gesture_timer : Timer = $CamGestureTimer
|
||||||
|
@onready var _cam_ctrl_panel : Control = %CamCtrlPanel
|
||||||
|
@onready var _cam_orbit_btn : Button = %CamOrbitBtn
|
||||||
|
@onready var _cam_pan_btn : Button = %CamPanBtn
|
||||||
|
@onready var _cam_zoom_btn : Button = %CamZoomBtn
|
||||||
|
|
||||||
# HUD
|
# HUD
|
||||||
@onready var _phase_lbl : Label = %PhaseLabel
|
@onready var _phase_lbl : Label = %PhaseLabel
|
||||||
@@ -116,10 +121,26 @@ var _cam_pivot : Vector3 = Vector3.ZERO
|
|||||||
var _drag_active : bool = false
|
var _drag_active : bool = false
|
||||||
var _press_was_on_board: bool = false # true only when the PRESS came from unhandled_input (board, not a UI card)
|
var _press_was_on_board: bool = false # true only when the PRESS came from unhandled_input (board, not a UI card)
|
||||||
var _camera_oriented : bool = false
|
var _camera_oriented : bool = false
|
||||||
var _pan_active : bool = false
|
var _pan_active : bool = false
|
||||||
var _last_mouse : Vector2 = Vector2.ZERO
|
var _orbit_active : bool = false # right-mouse drag → camera orbit on desktop
|
||||||
var _touch_points : Dictionary = {}
|
var _last_mouse : Vector2 = Vector2.ZERO
|
||||||
var _pinch_dist : float = 0.0
|
var _touch_points : Dictionary = {}
|
||||||
|
var _pinch_dist : float = 0.0
|
||||||
|
# True from the moment a second finger lands until ALL fingers lift.
|
||||||
|
# Prevents single-finger orbit from triggering during a pinch gesture even
|
||||||
|
# if a ScreenDrag for finger-0 arrives before finger-1's ScreenTouch is processed.
|
||||||
|
var _was_multi_touch : bool = false
|
||||||
|
var _touch_drag_active : bool = false # camera mode fired during this touch; suppresses tap-click
|
||||||
|
var _touch_drag_total : float = 0.0 # cumulative drag distance since last touch-down (gates camera actions)
|
||||||
|
var _touch_start_pos : Vector2 = Vector2.ZERO # finger position at touch-down (for start-to-end tap detection)
|
||||||
|
|
||||||
|
# Touch camera mode — which camera action is currently active on touch
|
||||||
|
var _touch_cam_orbit : bool = false # single-finger drag → orbit
|
||||||
|
var _touch_cam_pan : bool = false # single-finger drag → pan
|
||||||
|
var _touch_cam_zoom : bool = false # single-finger drag up/down → zoom
|
||||||
|
# Gesture-hold detection
|
||||||
|
var _gesture_move_accum : float = 0.0 # cumulative movement since fingers last settled
|
||||||
|
var _gesture_finger_count : int = 0 # finger count when _cam_gesture_timer was last started
|
||||||
|
|
||||||
# ── Selection state ───────────────────────────────────────────────────────────
|
# ── Selection state ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -152,6 +173,21 @@ var _ability_confirm_btn : Control = null # "Done" button shown for Up
|
|||||||
var _ability_branch_panel : Control = null # ChooseOne branch selector panel
|
var _ability_branch_panel : Control = null # ChooseOne branch selector panel
|
||||||
var _player_panel : Control = null
|
var _player_panel : Control = null
|
||||||
|
|
||||||
|
# Triggered ability target prompting
|
||||||
|
var _is_triggered_target : bool = false # true when targeting for a server-paused trigger
|
||||||
|
var _triggered_request_id : String = "" # requestId to echo back in the response
|
||||||
|
|
||||||
|
# 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 ─────────────────────────────────────────────────────
|
# ── Unit ownership lookup ─────────────────────────────────────────────────────
|
||||||
# Rebuilt on each state update for O(1) ownership checks.
|
# Rebuilt on each state update for O(1) ownership checks.
|
||||||
var _enemy_unit_ids : Dictionary = {} # instanceId → true
|
var _enemy_unit_ids : Dictionary = {} # instanceId → true
|
||||||
@@ -244,6 +280,14 @@ func _ready() -> void:
|
|||||||
_go_menu_btn.pressed.connect(func() -> void:
|
_go_menu_btn.pressed.connect(func() -> void:
|
||||||
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn"))
|
get_tree().change_scene_to_file("res://scenes/main/MainScreen.tscn"))
|
||||||
_hold_timer.timeout.connect(_on_hold_timer_fired)
|
_hold_timer.timeout.connect(_on_hold_timer_fired)
|
||||||
|
_cam_gesture_timer.timeout.connect(_on_cam_gesture_timer_fired)
|
||||||
|
_cam_orbit_btn.toggled.connect(_on_cam_orbit_btn_toggled)
|
||||||
|
_cam_pan_btn.toggled.connect(_on_cam_pan_btn_toggled)
|
||||||
|
_cam_zoom_btn.toggled.connect(_on_cam_zoom_btn_toggled)
|
||||||
|
_sync_cam_ctrl_panel()
|
||||||
|
Settings.settings_changed.connect(_sync_cam_ctrl_panel)
|
||||||
|
_create_tile_drawer()
|
||||||
|
Game.triggered_target_request.connect(_on_triggered_target_request)
|
||||||
|
|
||||||
# Chat overlay — add to viewport root so it renders above everything.
|
# Chat overlay — add to viewport root so it renders above everything.
|
||||||
var _chat_overlay := _CHAT_OVERLAY_SCENE.instantiate()
|
var _chat_overlay := _CHAT_OVERLAY_SCENE.instantiate()
|
||||||
@@ -296,6 +340,8 @@ func _exit_tree() -> void:
|
|||||||
Game.player_eliminated.disconnect(_on_player_eliminated)
|
Game.player_eliminated.disconnect(_on_player_eliminated)
|
||||||
if Game.game_activity.is_connected(_on_game_activity):
|
if Game.game_activity.is_connected(_on_game_activity):
|
||||||
Game.game_activity.disconnect(_on_game_activity)
|
Game.game_activity.disconnect(_on_game_activity)
|
||||||
|
if Game.triggered_target_request.is_connected(_on_triggered_target_request):
|
||||||
|
Game.triggered_target_request.disconnect(_on_triggered_target_request)
|
||||||
if Settings.settings_changed.is_connected(_on_skybox_setting_changed):
|
if Settings.settings_changed.is_connected(_on_skybox_setting_changed):
|
||||||
Settings.settings_changed.disconnect(_on_skybox_setting_changed)
|
Settings.settings_changed.disconnect(_on_skybox_setting_changed)
|
||||||
_reset_unit_hover_glow()
|
_reset_unit_hover_glow()
|
||||||
@@ -756,6 +802,70 @@ func _zoom(delta: float) -> void:
|
|||||||
_cam_distance = clampf(_cam_distance - delta, 4.0, 22.0)
|
_cam_distance = clampf(_cam_distance - delta, 4.0, 22.0)
|
||||||
_apply_camera()
|
_apply_camera()
|
||||||
|
|
||||||
|
|
||||||
|
func _sync_cam_ctrl_panel() -> void:
|
||||||
|
_cam_ctrl_panel.visible = (Settings.touch_camera_mode == "buttons")
|
||||||
|
if Settings.touch_camera_mode != "buttons":
|
||||||
|
_deactivate_touch_cam_modes()
|
||||||
|
|
||||||
|
|
||||||
|
func _deactivate_touch_cam_modes() -> void:
|
||||||
|
_touch_cam_orbit = false
|
||||||
|
_touch_cam_pan = false
|
||||||
|
_touch_cam_zoom = false
|
||||||
|
if is_instance_valid(_cam_orbit_btn): _cam_orbit_btn.set_pressed_no_signal(false)
|
||||||
|
if is_instance_valid(_cam_pan_btn): _cam_pan_btn.set_pressed_no_signal(false)
|
||||||
|
if is_instance_valid(_cam_zoom_btn): _cam_zoom_btn.set_pressed_no_signal(false)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_cam_orbit_btn_toggled(pressed: bool) -> void:
|
||||||
|
_touch_cam_orbit = pressed
|
||||||
|
if pressed:
|
||||||
|
_touch_cam_pan = false
|
||||||
|
_touch_cam_zoom = false
|
||||||
|
_cam_pan_btn.set_pressed_no_signal(false)
|
||||||
|
_cam_zoom_btn.set_pressed_no_signal(false)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_cam_pan_btn_toggled(pressed: bool) -> void:
|
||||||
|
_touch_cam_pan = pressed
|
||||||
|
if pressed:
|
||||||
|
_touch_cam_orbit = false
|
||||||
|
_touch_cam_zoom = false
|
||||||
|
_cam_orbit_btn.set_pressed_no_signal(false)
|
||||||
|
_cam_zoom_btn.set_pressed_no_signal(false)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_cam_zoom_btn_toggled(pressed: bool) -> void:
|
||||||
|
_touch_cam_zoom = pressed
|
||||||
|
if pressed:
|
||||||
|
_touch_cam_orbit = false
|
||||||
|
_touch_cam_pan = false
|
||||||
|
_cam_orbit_btn.set_pressed_no_signal(false)
|
||||||
|
_cam_pan_btn.set_pressed_no_signal(false)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_cam_gesture_timer_fired() -> void:
|
||||||
|
if Settings.touch_camera_mode != "gesture":
|
||||||
|
return
|
||||||
|
match _gesture_finger_count:
|
||||||
|
1:
|
||||||
|
_touch_cam_orbit = true
|
||||||
|
_touch_cam_pan = false
|
||||||
|
_touch_cam_zoom = false
|
||||||
|
2:
|
||||||
|
_touch_cam_zoom = true
|
||||||
|
_touch_cam_orbit = false
|
||||||
|
_touch_cam_pan = false
|
||||||
|
3:
|
||||||
|
_touch_cam_pan = true
|
||||||
|
_touch_cam_orbit = false
|
||||||
|
_touch_cam_zoom = false
|
||||||
|
# The user deliberately held — mark as drag so release won't fire a board click.
|
||||||
|
_touch_drag_active = true
|
||||||
|
_hold_timer.stop()
|
||||||
|
|
||||||
|
|
||||||
# ── Input ─────────────────────────────────────────────────────────────────────
|
# ── Input ─────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
@@ -770,6 +880,9 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
elif mb.button_index == MOUSE_BUTTON_MIDDLE:
|
elif mb.button_index == MOUSE_BUTTON_MIDDLE:
|
||||||
_pan_active = mb.pressed
|
_pan_active = mb.pressed
|
||||||
_last_mouse = mb.position
|
_last_mouse = mb.position
|
||||||
|
elif mb.button_index == MOUSE_BUTTON_RIGHT:
|
||||||
|
_orbit_active = mb.pressed
|
||||||
|
_last_mouse = mb.position
|
||||||
elif mb.button_index == MOUSE_BUTTON_LEFT:
|
elif mb.button_index == MOUSE_BUTTON_LEFT:
|
||||||
if mb.pressed:
|
if mb.pressed:
|
||||||
# Double-click on a battlefield unit → show full card detail popup.
|
# Double-click on a battlefield unit → show full card detail popup.
|
||||||
@@ -789,23 +902,24 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
_held_coord = Vector2i(-1, -1)
|
_held_coord = Vector2i(-1, -1)
|
||||||
else:
|
else:
|
||||||
_hold_timer.stop()
|
_hold_timer.stop()
|
||||||
if not _drag_active and _press_was_on_board:
|
if not _drag_active and not _touch_drag_active and _press_was_on_board:
|
||||||
_handle_board_click(mb.position)
|
_handle_board_click(mb.position)
|
||||||
_drag_active = false
|
_drag_active = false
|
||||||
|
_touch_drag_active = false
|
||||||
|
_touch_drag_total = 0.0
|
||||||
_press_was_on_board = false
|
_press_was_on_board = false
|
||||||
|
|
||||||
elif event is InputEventMouseMotion:
|
elif event is InputEventMouseMotion:
|
||||||
var mm := event as InputEventMouseMotion
|
var mm := event as InputEventMouseMotion
|
||||||
var delta := mm.position - _last_mouse
|
var delta := mm.position - _last_mouse
|
||||||
_last_mouse = mm.position
|
_last_mouse = mm.position
|
||||||
if mm.button_mask & MOUSE_BUTTON_MASK_LEFT:
|
# On some mobile browsers, pinch emits synthetic mouse-motion/left-drag
|
||||||
if delta.length() > 2.0:
|
# alongside touch/gesture events. Ignore mouse-orbit while touch is active
|
||||||
_drag_active = true
|
# Right-mouse drag orbits camera on desktop; left-click is reserved for board actions.
|
||||||
_hold_timer.stop()
|
if _orbit_active and _touch_points.is_empty() and not _was_multi_touch:
|
||||||
if _drag_active:
|
_cam_yaw -= delta.x * 0.4
|
||||||
_cam_yaw -= delta.x * 0.4
|
_cam_pitch = clampf(_cam_pitch + delta.y * 0.3, 15.0, 75.0)
|
||||||
_cam_pitch = clampf(_cam_pitch + delta.y * 0.3, 15.0, 75.0)
|
_apply_camera()
|
||||||
_apply_camera()
|
|
||||||
# Always update cursor/hover on mouse move (even while drag — hides during drag).
|
# Always update cursor/hover on mouse move (even while drag — hides during drag).
|
||||||
_update_hover(mm.position)
|
_update_hover(mm.position)
|
||||||
if _pan_active:
|
if _pan_active:
|
||||||
@@ -823,22 +937,105 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
var st := event as InputEventScreenTouch
|
var st := event as InputEventScreenTouch
|
||||||
if st.pressed:
|
if st.pressed:
|
||||||
_touch_points[st.index] = st.position
|
_touch_points[st.index] = st.position
|
||||||
if _touch_points.size() == 2:
|
if _touch_points.size() == 1:
|
||||||
_pinch_dist = _touch_pair_dist()
|
# Single-touch start: arm tap + hold (touch right-click) behavior.
|
||||||
|
_touch_drag_active = false
|
||||||
|
_touch_drag_total = 0.0
|
||||||
|
_touch_start_pos = st.position
|
||||||
|
_press_was_on_board = true
|
||||||
|
_last_mouse = st.position
|
||||||
|
var touch_coord := _mouse_to_tile_coord(st.position)
|
||||||
|
if touch_coord.x >= 0:
|
||||||
|
_held_coord = touch_coord
|
||||||
|
_hold_timer.start()
|
||||||
|
else:
|
||||||
|
_held_coord = Vector2i(-1, -1)
|
||||||
|
elif _touch_points.size() >= 2:
|
||||||
|
_pinch_dist = _touch_pair_dist()
|
||||||
|
_last_mouse = _touch_pair_mid()
|
||||||
|
_was_multi_touch = true
|
||||||
|
_held_coord = Vector2i(-1, -1)
|
||||||
_hold_timer.stop()
|
_hold_timer.stop()
|
||||||
|
# Gesture mode: (re)start timer whenever finger count changes.
|
||||||
|
if Settings.touch_camera_mode == "gesture":
|
||||||
|
_gesture_finger_count = _touch_points.size()
|
||||||
|
_gesture_move_accum = 0.0
|
||||||
|
_cam_gesture_timer.start()
|
||||||
else:
|
else:
|
||||||
|
var released_pos := st.position
|
||||||
|
var had_single_touch := (_touch_points.size() == 1 and _touch_points.has(st.index))
|
||||||
_touch_points.erase(st.index)
|
_touch_points.erase(st.index)
|
||||||
|
if had_single_touch and not _was_multi_touch and _press_was_on_board:
|
||||||
|
# Use start-to-end distance, not cumulative, to detect taps.
|
||||||
|
# Cumulative distance mis-classifies natural finger jitter (A→B→A) as a drag.
|
||||||
|
var tap_dist := released_pos.distance_to(_touch_start_pos)
|
||||||
|
if tap_dist < 50.0 and not _touch_drag_active:
|
||||||
|
_hold_timer.stop()
|
||||||
|
_handle_board_click(released_pos)
|
||||||
|
if _touch_points.is_empty():
|
||||||
|
_was_multi_touch = false
|
||||||
|
_touch_drag_active = false
|
||||||
|
_touch_drag_total = 0.0
|
||||||
|
_touch_start_pos = Vector2.ZERO
|
||||||
|
_press_was_on_board = false
|
||||||
|
_held_coord = Vector2i(-1, -1)
|
||||||
|
_hold_timer.stop()
|
||||||
|
_cam_gesture_timer.stop()
|
||||||
|
# Gesture mode: deactivate camera mode when all fingers lift.
|
||||||
|
if Settings.touch_camera_mode == "gesture":
|
||||||
|
_deactivate_touch_cam_modes()
|
||||||
|
_gesture_move_accum = 0.0
|
||||||
|
_gesture_finger_count = 0
|
||||||
|
|
||||||
elif event is InputEventScreenDrag:
|
elif event is InputEventScreenDrag:
|
||||||
var sd := event as InputEventScreenDrag
|
var sd := event as InputEventScreenDrag
|
||||||
_touch_points[sd.index] = sd.position
|
_touch_points[sd.index] = sd.position
|
||||||
if _touch_points.size() == 1:
|
|
||||||
_cam_yaw -= sd.relative.x * 0.4
|
# Cancel gesture timer if fingers move significantly before the hold activates.
|
||||||
_cam_pitch = clampf(_cam_pitch + sd.relative.y * 0.3, 15.0, 75.0)
|
_gesture_move_accum += sd.relative.length()
|
||||||
_apply_camera()
|
if _gesture_move_accum > 50.0:
|
||||||
if sd.relative.length() > 2.0:
|
_cam_gesture_timer.stop()
|
||||||
|
|
||||||
|
if _touch_points.size() == 1 and not _was_multi_touch:
|
||||||
|
_touch_drag_total += sd.relative.length()
|
||||||
|
if _touch_drag_total > 36.0:
|
||||||
_hold_timer.stop()
|
_hold_timer.stop()
|
||||||
elif _touch_points.size() == 2:
|
# Only suppress the tap click when a camera action will actually happen.
|
||||||
|
# Without this, a normal swipe with no camera mode active silently eats the touch.
|
||||||
|
if _touch_cam_orbit or _touch_cam_pan or _touch_cam_zoom:
|
||||||
|
_touch_drag_active = true
|
||||||
|
if _touch_drag_active:
|
||||||
|
if _touch_cam_orbit:
|
||||||
|
_cam_yaw -= sd.relative.x * 0.4
|
||||||
|
_cam_pitch = clampf(_cam_pitch + sd.relative.y * 0.3, 15.0, 75.0)
|
||||||
|
_apply_camera()
|
||||||
|
elif _touch_cam_pan:
|
||||||
|
var ps_p := _cam_distance * 0.002
|
||||||
|
var right_p := _camera_rig.global_basis.x * -sd.relative.x * ps_p
|
||||||
|
var fwd_p := Vector3(_camera_rig.global_basis.z.x, 0,
|
||||||
|
_camera_rig.global_basis.z.z).normalized()
|
||||||
|
_cam_pivot += right_p + fwd_p * sd.relative.y * ps_p
|
||||||
|
var pan_lim_p := clampf(max(Game.board_width(), Game.board_height()) * TILE_SPACING * 0.5, 6.0, 20.0)
|
||||||
|
_cam_pivot.x = clampf(_cam_pivot.x, -pan_lim_p, pan_lim_p)
|
||||||
|
_cam_pivot.z = clampf(_cam_pivot.z, -pan_lim_p, pan_lim_p)
|
||||||
|
_apply_camera()
|
||||||
|
elif _touch_cam_zoom:
|
||||||
|
_zoom(sd.relative.y * -0.05)
|
||||||
|
elif _touch_points.size() == 3 and _touch_cam_pan:
|
||||||
|
# 3-finger pan (gesture mode): only process the leading finger to avoid triple-apply.
|
||||||
|
var keys3 := _touch_points.keys()
|
||||||
|
keys3.sort()
|
||||||
|
if sd.index == keys3[0]:
|
||||||
|
var ps3 := _cam_distance * 0.002
|
||||||
|
var right3 := _camera_rig.global_basis.x * -sd.relative.x * ps3
|
||||||
|
var fwd3 := Vector3(_camera_rig.global_basis.z.x, 0,
|
||||||
|
_camera_rig.global_basis.z.z).normalized()
|
||||||
|
_cam_pivot += right3 + fwd3 * sd.relative.y * ps3
|
||||||
|
var pan_lim3 := clampf(max(Game.board_width(), Game.board_height()) * TILE_SPACING * 0.5, 6.0, 20.0)
|
||||||
|
_cam_pivot.x = clampf(_cam_pivot.x, -pan_lim3, pan_lim3)
|
||||||
|
_cam_pivot.z = clampf(_cam_pivot.z, -pan_lim3, pan_lim3)
|
||||||
|
_apply_camera()
|
||||||
|
elif _touch_points.size() >= 2:
|
||||||
var keys := _touch_points.keys()
|
var keys := _touch_points.keys()
|
||||||
var pos_a : Vector2 = _touch_points[keys[0]]
|
var pos_a : Vector2 = _touch_points[keys[0]]
|
||||||
var pos_b : Vector2 = _touch_points[keys[1]]
|
var pos_b : Vector2 = _touch_points[keys[1]]
|
||||||
@@ -859,11 +1056,42 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
_apply_camera()
|
_apply_camera()
|
||||||
|
|
||||||
|
|
||||||
|
# ── Browser high-level gesture events (Chromium / WebKit) ──────────────────
|
||||||
|
# Browsers sometimes emit these *instead of* dual ScreenDrag events.
|
||||||
|
# factor > 1.0 = spreading (zoom in), < 1.0 = pinching (zoom out).
|
||||||
|
elif event is InputEventMagnifyGesture:
|
||||||
|
var mg := event as InputEventMagnifyGesture
|
||||||
|
_zoom((mg.factor - 1.0) * 8.0)
|
||||||
|
|
||||||
|
elif event is InputEventPanGesture:
|
||||||
|
# On touch devices, treat pan-gesture as two-finger pan only.
|
||||||
|
# Some browsers emit PanGesture during single-finger movement;
|
||||||
|
# ignore that so single-finger remains orbit.
|
||||||
|
if _touch_points.size() == 1 and not _was_multi_touch:
|
||||||
|
return
|
||||||
|
var pg := event as InputEventPanGesture
|
||||||
|
var ps := _cam_distance * 0.004
|
||||||
|
var right := _camera_rig.global_basis.x * -pg.delta.x * ps
|
||||||
|
var fwd := Vector3(_camera_rig.global_basis.z.x, 0,
|
||||||
|
_camera_rig.global_basis.z.z).normalized()
|
||||||
|
_cam_pivot += right + fwd * pg.delta.y * ps
|
||||||
|
var pan_lim3 := clampf(max(Game.board_width(), Game.board_height()) * TILE_SPACING * 0.5, 6.0, 20.0)
|
||||||
|
_cam_pivot.x = clampf(_cam_pivot.x, -pan_lim3, pan_lim3)
|
||||||
|
_cam_pivot.z = clampf(_cam_pivot.z, -pan_lim3, pan_lim3)
|
||||||
|
_apply_camera()
|
||||||
|
|
||||||
|
|
||||||
func _touch_pair_dist() -> float:
|
func _touch_pair_dist() -> float:
|
||||||
var keys := _touch_points.keys()
|
var keys := _touch_points.keys()
|
||||||
if keys.size() < 2: return 0.0
|
if keys.size() < 2: return 0.0
|
||||||
return (_touch_points[keys[0]] as Vector2).distance_to(_touch_points[keys[1]])
|
return (_touch_points[keys[0]] as Vector2).distance_to(_touch_points[keys[1]])
|
||||||
|
|
||||||
|
|
||||||
|
func _touch_pair_mid() -> Vector2:
|
||||||
|
var keys := _touch_points.keys()
|
||||||
|
if keys.size() < 2: return Vector2.ZERO
|
||||||
|
return ((_touch_points[keys[0]] as Vector2) + (_touch_points[keys[1]] as Vector2)) * 0.5
|
||||||
|
|
||||||
# ── Coord helpers ─────────────────────────────────────────────────────────────
|
# ── Coord helpers ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
## Grid spacing: 1.0 tile + 0.1 gap between tiles (visual only).
|
## Grid spacing: 1.0 tile + 0.1 gap between tiles (visual only).
|
||||||
@@ -2333,6 +2561,130 @@ func _valid_sacrifice_spirits() -> Array:
|
|||||||
results.append(unit)
|
results.append(unit)
|
||||||
return results
|
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 ────────────────────────────────────────────────────────────
|
# ── Click handling ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func _handle_board_click(mouse_pos: Vector2) -> void:
|
func _handle_board_click(mouse_pos: Vector2) -> void:
|
||||||
@@ -2342,6 +2694,18 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
|||||||
match _mode:
|
match _mode:
|
||||||
|
|
||||||
Mode.NONE:
|
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) \
|
if not unit_id.is_empty() and _is_friendly_unit(unit_id) \
|
||||||
and Game.is_my_turn() and Game.get_phase() != "Placement":
|
and Game.is_my_turn() and Game.get_phase() != "Placement":
|
||||||
_select_unit(unit_id)
|
_select_unit(unit_id)
|
||||||
@@ -2400,6 +2764,12 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
|
|||||||
_add_highlight(nx, ny, "movement")
|
_add_highlight(nx, ny, "movement")
|
||||||
|
|
||||||
Mode.UNIT_SELECTED:
|
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 not unit_id.is_empty():
|
||||||
if _is_enemy_unit(unit_id):
|
if _is_enemy_unit(unit_id):
|
||||||
_last_attack_target_iid = unit_id
|
_last_attack_target_iid = unit_id
|
||||||
@@ -2506,6 +2876,8 @@ func _set_mode(new_mode: Mode) -> void:
|
|||||||
_mode = new_mode
|
_mode = new_mode
|
||||||
_terra_targets = []
|
_terra_targets = []
|
||||||
_terra_count = 0
|
_terra_count = 0
|
||||||
|
if new_mode != Mode.NONE:
|
||||||
|
_close_tile_drawer()
|
||||||
if new_mode == Mode.NONE:
|
if new_mode == Mode.NONE:
|
||||||
_sel_card_id = ""
|
_sel_card_id = ""
|
||||||
_sel_unit_id = ""
|
_sel_unit_id = ""
|
||||||
@@ -3064,13 +3436,73 @@ func _hide_branch_panel() -> void:
|
|||||||
|
|
||||||
## Fire the ability request with all collected targets.
|
## Fire the ability request with all collected targets.
|
||||||
func _send_ability() -> void:
|
func _send_ability() -> void:
|
||||||
if not _ability_card_id.is_empty():
|
if _is_triggered_target:
|
||||||
|
_is_triggered_target = false
|
||||||
|
var rid := _triggered_request_id
|
||||||
|
_triggered_request_id = ""
|
||||||
|
Game.send_triggered_target_response(rid, _ability_targets)
|
||||||
|
elif not _ability_card_id.is_empty():
|
||||||
Game.send_play_card_with_targets(_ability_card_id, _ability_targets)
|
Game.send_play_card_with_targets(_ability_card_id, _ability_targets)
|
||||||
else:
|
else:
|
||||||
Game.send_activate_ability(_ability_unit_id, _ability_idx, _ability_targets)
|
Game.send_activate_ability(_ability_unit_id, _ability_idx, _ability_targets)
|
||||||
_set_mode(Mode.NONE)
|
_set_mode(Mode.NONE)
|
||||||
|
|
||||||
|
|
||||||
|
## Called when the server pushes a triggered_target_request for this player.
|
||||||
|
## Sets up the standard ability-targeting UI re-using the existing ABILITY_TARGET mode.
|
||||||
|
func _on_triggered_target_request(req: Dictionary) -> void:
|
||||||
|
# If already in a targeting mode, cancel it first to avoid stacking.
|
||||||
|
if _mode != Mode.NONE:
|
||||||
|
_set_mode(Mode.NONE)
|
||||||
|
|
||||||
|
_is_triggered_target = true
|
||||||
|
_triggered_request_id = str(req.get("requestId", ""))
|
||||||
|
_ability_unit_id = str(req.get("sourceInstanceId", ""))
|
||||||
|
_ability_idx = -1
|
||||||
|
_ability_card_id = ""
|
||||||
|
_ability_target_conditions = []
|
||||||
|
|
||||||
|
# Parse and normalise the action definition sent by the server.
|
||||||
|
var action_json : String = str(req.get("actionJson", "{}"))
|
||||||
|
var action_raw = JSON.parse_string(action_json)
|
||||||
|
if action_raw is Dictionary:
|
||||||
|
_ability_def = [_normalize_keys(action_raw)]
|
||||||
|
elif action_raw is Array:
|
||||||
|
_ability_def = _normalize_keys(action_raw) as Array
|
||||||
|
else:
|
||||||
|
_ability_def = []
|
||||||
|
|
||||||
|
var range_json : String = str(req.get("rangeJson", ""))
|
||||||
|
if not range_json.is_empty() and range_json != "null":
|
||||||
|
var r = JSON.parse_string(range_json)
|
||||||
|
_ability_range = _normalize_keys(r) as Dictionary if r is Dictionary else {}
|
||||||
|
else:
|
||||||
|
_ability_range = {}
|
||||||
|
|
||||||
|
_ability_targets = []
|
||||||
|
_ability_cur_action_idx = 0
|
||||||
|
_ability_target_n = 1
|
||||||
|
_ability_target_up_to = false
|
||||||
|
_ability_targets_this_action = 0
|
||||||
|
|
||||||
|
_show_triggered_banner(str(req.get("abilityName", "Triggered Ability")))
|
||||||
|
_start_ability_targeting()
|
||||||
|
|
||||||
|
|
||||||
|
## Brief top-centre banner indicating a triggered ability needs player input.
|
||||||
|
func _show_triggered_banner(ability_name: String) -> void:
|
||||||
|
var lbl := Label.new()
|
||||||
|
lbl.text = "Triggered: %s — select a target" % ability_name
|
||||||
|
lbl.set_anchors_preset(Control.PRESET_TOP_WIDE)
|
||||||
|
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||||
|
lbl.position = Vector2(0, 72)
|
||||||
|
lbl.add_theme_font_size_override("font_size", 15)
|
||||||
|
lbl.modulate = Color(1.0, 0.85, 0.2)
|
||||||
|
_hud.add_child(lbl)
|
||||||
|
get_tree().create_timer(4.0).timeout.connect(func() -> void:
|
||||||
|
if is_instance_valid(lbl): lbl.queue_free())
|
||||||
|
|
||||||
|
|
||||||
## Show a left-side panel to let the player select a player (and optionally a
|
## Show a left-side panel to let the player select a player (and optionally a
|
||||||
## zone) as the ability target.
|
## zone) as the ability target.
|
||||||
func _show_player_panel(scope: String, ownership: String) -> void:
|
func _show_player_panel(scope: String, ownership: String) -> void:
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ extends PanelContainer
|
|||||||
@onready var _sfx_slider : HSlider = %SfxSlider
|
@onready var _sfx_slider : HSlider = %SfxSlider
|
||||||
@onready var _sfx_mute : CheckButton = %SfxMute
|
@onready var _sfx_mute : CheckButton = %SfxMute
|
||||||
@onready var _cam_follow : CheckButton = %CameraFollowUnit
|
@onready var _cam_follow : CheckButton = %CameraFollowUnit
|
||||||
@onready var _skybox_opt : OptionButton = %SkyboxModeOption
|
@onready var _tile_focus_cam : CheckButton = %TileFocusCamera
|
||||||
|
@onready var _skybox_opt : OptionButton = %SkyboxModeOption
|
||||||
|
@onready var _touch_cam_mode_opt : OptionButton = %TouchCamModeOption
|
||||||
@onready var _sync_btn : Button = %SyncBtn
|
@onready var _sync_btn : Button = %SyncBtn
|
||||||
@onready var _concede_btn : Button = %ConcedeBtn
|
@onready var _concede_btn : Button = %ConcedeBtn
|
||||||
@onready var _confirm_row : HBoxContainer = %ConcedeConfirmRow
|
@onready var _confirm_row : HBoxContainer = %ConcedeConfirmRow
|
||||||
@@ -26,7 +28,10 @@ func _ready() -> void:
|
|||||||
_sfx_slider.value_changed.connect(_on_sfx_volume_changed)
|
_sfx_slider.value_changed.connect(_on_sfx_volume_changed)
|
||||||
_sfx_mute.toggled.connect(_on_sfx_mute_toggled)
|
_sfx_mute.toggled.connect(_on_sfx_mute_toggled)
|
||||||
_cam_follow.toggled.connect(func(v: bool) -> void: Settings.camera_follow_unit = v)
|
_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)
|
_skybox_opt.item_selected.connect(_on_skybox_mode_changed)
|
||||||
|
_touch_cam_mode_opt.item_selected.connect(func(idx: int) -> void:
|
||||||
|
Settings.touch_camera_mode = (["gesture", "buttons"] as Array)[idx])
|
||||||
|
|
||||||
_sync_btn.pressed.connect(_on_sync_pressed)
|
_sync_btn.pressed.connect(_on_sync_pressed)
|
||||||
_concede_btn.pressed.connect(_on_concede_pressed)
|
_concede_btn.pressed.connect(_on_concede_pressed)
|
||||||
@@ -55,7 +60,9 @@ func _sync_from_settings() -> void:
|
|||||||
_sfx_slider.set_value_no_signal(Settings.sfx_volume)
|
_sfx_slider.set_value_no_signal(Settings.sfx_volume)
|
||||||
_sfx_mute.set_pressed_no_signal(Settings.sfx_muted)
|
_sfx_mute.set_pressed_no_signal(Settings.sfx_muted)
|
||||||
_cam_follow.set_pressed_no_signal(Settings.camera_follow_unit)
|
_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)
|
_skybox_opt.selected = ["live", "cdn", "off"].find(Settings.skybox_mode)
|
||||||
|
_touch_cam_mode_opt.selected = ["gesture", "buttons"].find(Settings.touch_camera_mode)
|
||||||
_music_slider.modulate.a = 0.4 if Settings.music_muted else 1.0
|
_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
|
_sfx_slider.modulate.a = 0.4 if Settings.sfx_muted else 1.0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user