Skip to content

Add panelBitFlags to GameMenu for original behavior and centering options#67

Open
th3w1zard1 wants to merge 2 commits intoKobaltBlu:masterfrom
th3w1zard1:pr/5592a133
Open

Add panelBitFlags to GameMenu for original behavior and centering options#67
th3w1zard1 wants to merge 2 commits intoKobaltBlu:masterfrom
th3w1zard1:pr/5592a133

Conversation

@th3w1zard1
Copy link
Contributor

@th3w1zard1 th3w1zard1 commented Feb 8, 2026

Summary of what was implemented:

GameMenu.ts (lines 216–265) – updates

note: The KotOR binary uses a different UI stack (C++ panels, different types). This behavior is based on the existing MenuManager (Add/Remove, activeMenus, show/hide) and common panel semantics.

1. getControlByName(name: string): GUIControl | undefined

  • Return type is now GUIControl | undefined so missing controls are typed correctly.
  • No try/catch; property access is used and missing name is handled by returning undefined and logging.
  • JSDoc added: control is looked up by GFF/layout name (e.g. BTN_QUIT, LBL_TITLE).

2. hide(): void

  • Guard: only call GameState.scene_gui.remove(...) if this.tGuiPanel?.getControl() exists (avoids errors before the menu is loaded).
  • Child menu handling unchanged; explicit void return type.

3. show(): void

  • Guard: return early if this.tGuiPanel?.getControl() is missing.
  • Optional chaining for this.childMenu.tGuiPanel?.updateBoundsRecursive?.() so child bounds update is safe when panel isn’t ready.
  • Explicit void return type.

4. close(): void

  • Calls this.manager?.Remove?.(this) only when manager and Remove exist, so close is safe before the menu is added to a manager.
  • JSDoc: close = hide + remove from manager stack; menu below becomes current.

5. open(): void

  • Calls this.manager?.Add?.(this) only when manager and Add exist.
  • JSDoc: open = add to manager stack + show.

6. remove(): void (was TODO)

  • Implemented as this.close() so “remove from stack and hide” is a single, consistent action.
  • JSDoc: same effect as close(); name clarifies “remove from stack” for API users.

Overall, the menu stack behavior (open = Add + show, close = hide + Remove, remove = close) matches the existing MenuManager and is robust when panels or manager are not yet set.

…ions

- Introduced `panelBitFlags` to match original game's CSWGuiPanel behavior, allowing for centering at arbitrary resolutions.
- Updated position handling in `show()` and `hide()` methods to align with original layout behavior.
- Enhanced `getControlByName()` method to improve error handling and return type.
- Added detailed documentation for new and modified methods to clarify functionality and usage.

(cherry picked from commit 5592a13)
Removed detailed comments about panel bit_flags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant