Skip to content

Add ScriptLibraryManager and replace raw dlLoad usage in Editor/Game/UI#20

Closed
Thomas-Chqt wants to merge 7 commits intorefactorfrom
codex/move-script-library-loading-to-engine
Closed

Add ScriptLibraryManager and replace raw dlLoad usage in Editor/Game/UI#20
Thomas-Chqt wants to merge 7 commits intorefactorfrom
codex/move-script-library-loading-to-engine

Conversation

@Thomas-Chqt
Copy link
Copy Markdown
Owner

Motivation

  • Centralize dynamic script library loading and symbol lookup into a dedicated manager to avoid scattered dlLoad/function-pointer handling.
  • Simplify Editor and Game interfaces by passing a ScriptLibraryManager instead of raw callbacks and raw handles.
  • Ensure the shared library remains alive for the lifetime of created script instances so instances remain valid after unload() is called.

Description

  • Add GE::ScriptLibraryManager (include/Game-Engine/ScriptLibraryManager.hpp and src/ScriptLibraryManager.cpp) which implements load, unload, isLoaded, listScriptNames, listScriptParameters, and makeScriptInstance and keeps a LibraryHandle alive via shared_ptr so instances keep the library alive.
  • Replace direct dlLoad and raw function-pointer fields in Editor with std::optional<GE::ScriptLibraryManager> m_scriptLibrary, and update Editor::reloadScriptLib, startGame, and UI wiring to use the manager.
  • Update EntityInspectorPanel to accept a const GE::ScriptLibraryManager* and use it to list scripts and parameters, and display a notice when no library is loaded.
  • Update Game to accept a ScriptLibraryManager* and use it in setupScene/setActiveScene to create script instances and populate parameters.
  • Remove legacy includes/typedefs and function-pointer members and add necessary headers where appropriate.
  • Add/modify unit test tests/Script_testCases.cpp to include ScriptLibraryManager and add a ScriptLibraryManagerTest that verifies the library remains usable for script instances after unload() is called.

Testing

  • Ran the script unit tests in tests/Script_testCases.cpp, including ScriptLibraryTest and the new ScriptLibraryManagerTest, and they succeeded.
  • Project builds and editor UI paths that list scripts were exercised via unit tests and compilation checks which passed.

Codex Task

Introduce GE::ListScriptNamesFn, GE::ListScriptParametersFn and
GE::MakeScriptInstanceFn and replace uses of
ScriptLibraryManager::ListScript* / MakeScriptInstance across the
codebase.
ScriptLibraryManager now keeps raw C symbol pointer types (with Sym
suffix)
and exposes std::function wrappers. Update call sites and tests to the
new
API and remove now-unused includes and typedefs.
@Thomas-Chqt Thomas-Chqt marked this pull request as ready for review April 26, 2026 03:38
@Thomas-Chqt Thomas-Chqt deleted the codex/move-script-library-loading-to-engine branch April 26, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant