fix(ui): address PR #124 review — navigation, error handling, cleanup
- Economics panel: replace dead _gui_input LEFT/RIGHT with public navigate() method, wire [ ] keys in main.gd (avoids movement key conflict, fixes focus_mode=NONE issue) - Debug console: add explicit effect guard in econ inject no-commodity branch so invalid effects don't fall to commodity-form error - Snapshot consumer: null-clear GameState.economy_snapshot after consuming (matches one-shot consumer invariant) - Star map: remove duplicate doc comment above set_insert_active() - Generate script: remove stale comment, dead _WORKTREE_PARENT var, dead field extraction in parse_wiki_index, add try/except around DB queries Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -176,6 +176,14 @@ func _unhandled_key_input(event: InputEvent) -> void:
|
||||
# #824: E — toggle Economics Monitor implant panel
|
||||
if economics_panel:
|
||||
economics_panel.toggle_visible()
|
||||
elif event is InputEventKey and event.keycode == KEY_BRACKETLEFT:
|
||||
# #824: [ — cycle economics panel system selector backward
|
||||
if economics_panel and HudGroups.is_app_active("implant/economics"):
|
||||
economics_panel.navigate(-1)
|
||||
elif event is InputEventKey and event.keycode == KEY_BRACKETRIGHT:
|
||||
# #824: ] — cycle economics panel system selector forward
|
||||
if economics_panel and HudGroups.is_app_active("implant/economics"):
|
||||
economics_panel.navigate(1)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
||||
@@ -183,6 +183,7 @@ func consume_economy_snapshot() -> void:
|
||||
return
|
||||
if economics_panel.has_method("receive_economy_data"):
|
||||
economics_panel.receive_economy_data(GameState.economy_snapshot)
|
||||
GameState.economy_snapshot = null
|
||||
|
||||
|
||||
# #174: Consume examine result — show overlay when server sends character-filtered observation.
|
||||
|
||||
@@ -287,6 +287,12 @@ func _econ_inject(parts: Array) -> void:
|
||||
magnitude_str = args[2]
|
||||
if args.size() >= 4:
|
||||
ticks_str = args[3]
|
||||
elif args.size() == 3:
|
||||
# 3 args but args[1] isn't shock/boost — bad effect keyword, not a commodity
|
||||
_append_text(
|
||||
"econ inject: effect must be 'shock' or 'boost', got '%s'" % args[1], ERROR_COLOR
|
||||
)
|
||||
return
|
||||
else:
|
||||
# With commodity_id: econ inject <system> <commodity> <effect> <magnitude> [ticks]
|
||||
commodity_id = args[1]
|
||||
|
||||
@@ -167,10 +167,11 @@ func _load_system_list() -> void:
|
||||
var sid: String = node.get("system_id", "")
|
||||
if not sid.is_empty():
|
||||
_systems.append(node)
|
||||
_systems.sort_custom(func(a: Dictionary, b: Dictionary) -> bool:
|
||||
var na: String = a.get("proper_name", a.get("system_id", ""))
|
||||
var nb: String = b.get("proper_name", b.get("system_id", ""))
|
||||
return na < nb
|
||||
_systems.sort_custom(
|
||||
func(a: Dictionary, b: Dictionary) -> bool:
|
||||
var na: String = a.get("proper_name", a.get("system_id", ""))
|
||||
var nb: String = b.get("proper_name", b.get("system_id", ""))
|
||||
return na < nb
|
||||
)
|
||||
if not _systems.is_empty():
|
||||
selected_system = _systems[0].get("system_id", "")
|
||||
@@ -256,7 +257,7 @@ func _rebuild_panel() -> void:
|
||||
_panel.add_component(_placeholder_notice)
|
||||
|
||||
_panel.add_component(ImplantSeparator.new())
|
||||
_panel.add_component(ImplantTextBlock.new("◄ ► select · E close"))
|
||||
_panel.add_component(ImplantTextBlock.new("[ ] select system · E close"))
|
||||
|
||||
|
||||
func _current_node() -> Dictionary:
|
||||
@@ -304,27 +305,11 @@ func _on_economy_data_updated(system_id: String, data: Dictionary) -> void:
|
||||
_placeholder_notice.text = "LIVE DATA ACTIVE"
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Input — LEFT/RIGHT arrow navigation between systems
|
||||
# =============================================================================
|
||||
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if not visible:
|
||||
return
|
||||
if event is InputEventKey and event.pressed and not event.is_echo():
|
||||
match event.keycode:
|
||||
KEY_LEFT:
|
||||
_cycle_system(-1)
|
||||
get_viewport().set_input_as_handled()
|
||||
KEY_RIGHT:
|
||||
_cycle_system(1)
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _cycle_system(direction: int) -> void:
|
||||
## Cycle the system selector by delta steps (+1 or -1).
|
||||
## Called from main.gd _unhandled_key_input — [ and ] keys when panel is active.
|
||||
func navigate(delta: int) -> void:
|
||||
if _systems.is_empty():
|
||||
return
|
||||
_selected_idx = wrapi(_selected_idx + direction, 0, _systems.size())
|
||||
_selected_idx = wrapi(_selected_idx + delta, 0, _systems.size())
|
||||
selected_system = _systems[_selected_idx].get("system_id", "")
|
||||
_rebuild_panel()
|
||||
|
||||
@@ -135,7 +135,6 @@ func _process(_delta: float) -> void:
|
||||
_dirty = false
|
||||
|
||||
|
||||
## Called from main.gd when insert state changes.
|
||||
## Called from main.gd when insert state changes.
|
||||
func set_insert_active(active: bool) -> void:
|
||||
_insert_active = active
|
||||
|
||||
Reference in New Issue
Block a user