diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-12-13 11:50:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-13 11:50:28 -0700 |
| commit | b934e98fc34964970ab5efacb2fb7c3372ae0b1a (patch) | |
| tree | cd96e5fabec7fdcc098d0de33b3b7e2754fb6cd5 /src/engine/editor/Editor.cpp | |
| parent | e6acb59ef4797ce27ddc9e21982c3f4e40824b52 (diff) | |
Refactor Track Class To Instantiate On Track Load (#587)
* Initial Commit
* First compilation of Registry template
* Further changes
* wip changes
* Impl TrackBrowser and Registry Info
* Remove const from TInfo
* Prep GetWorld
* Name refactor
* Refactor gWorldInstance to GetWorld()
* wip
* Should work now
* Data menu work again
* Fix editor staying open after program close
* Rename LoadLevel to LoadTrackDataFromJson
* More changes
* Add statue
* Add search to content browser using tags
* Fix statue pos and register tags
* Fix actor loading
* Fix delete all bug which deleted cameras
* reduce some boiler plate in actor and object
* Remove unused rulesets
* Search bar for all tabs
* fix data screen
* fix actor spawning
* temp editor fix
* Clean up
* improve extra mode transformation
* fix podium crash
* Fix editor clicking
* Fix editor clicking 2
* fix extra in custom track
* Fix FI for three actors
* Fix divide by zero error
* Ids managed by Registry
* Add scary comment
---------
Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Co-authored-by: coco875 <pereira.jannin@gmail.com>
Diffstat (limited to 'src/engine/editor/Editor.cpp')
| -rw-r--r-- | src/engine/editor/Editor.cpp | 83 |
1 files changed, 72 insertions, 11 deletions
diff --git a/src/engine/editor/Editor.cpp b/src/engine/editor/Editor.cpp index 911cc9a8c..698a6cc40 100644 --- a/src/engine/editor/Editor.cpp +++ b/src/engine/editor/Editor.cpp @@ -12,6 +12,7 @@ #include <ship/controller/controldevice/controller/mapping/keyboard/KeyboardScancodes.h> #include <ship/window/Window.h> +#include "engine/TrackBrowser.h" #include "engine/actors/Ship.h" #include "port/Game.h" @@ -24,7 +25,10 @@ extern "C" { } namespace Editor { + Editor* Editor::Instance; + Editor::Editor() { + Instance = this; } Editor::~Editor() { @@ -43,28 +47,65 @@ namespace Editor { printf("Editor: Loading Complete!\n"); } + void Editor::Enable() { + bEditorEnabled = true; + bIsEditorPaused = true; + CVarSetInteger("gFreecam", true); + CM_SetFreeCamera(true); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->Show(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->Show(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->Show(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Track Properties")->Show(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Properties")->Show(); + } + + void Editor::Disable() { + bEditorEnabled = false; + bIsEditorPaused = false; + CVarSetInteger("gFreecam", false); + CM_SetFreeCamera(false); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Tools")->Hide(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Scene Explorer")->Hide(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Content Browser")->Hide(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Track Properties")->Hide(); + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Properties")->Hide(); + } + + bool Editor::IsEnabled() { + return bEditorEnabled; + } + + void Editor::Play() { + bIsEditorPaused = false; + } + + void Editor::Pause() { + bIsEditorPaused = true; + } + + bool Editor::IsPaused() { + return bIsEditorPaused; + } + + void Editor::TogglePlayState() { + bIsEditorPaused = !bIsEditorPaused; + } + void Editor::GenerateCollision() { - // for (auto& actor : gWorldInstance.Actors) { + // for (auto& actor : GetWorld()->Actors) { // GenerateCollisionMesh(actor, (Gfx*)actor->Model, 1.0f); // } } void Editor::Tick() { - if (CVarGetInteger("gEditorEnabled", 0) == true) { + if (Editor_IsEnabled() == true) { bEditorEnabled = true; } else { bEditorEnabled = false; - gIsEditorPaused = false; // Prevents game being paused with the editor closed. + bIsEditorPaused = false; // Prevents game being paused with the editor closed. return; } - // Set camera - if (CVarGetInteger("gFreecam", 0) == true) { - eCamera = &cameras[CAMERA_FREECAM]; - } else { - eCamera = &cameras[0]; - } - auto wnd = GameEngine::Instance->context->GetWindow(); static bool wasMouseDown = false; @@ -111,7 +152,6 @@ namespace Editor { if (!isDragging) { eObjectPicker.SelectObject(eGameObjects); } - } wasMouseDown = isMouseDown; // Update previous state @@ -197,3 +237,24 @@ namespace Editor { eObjectPicker.eGizmo.dimensions.MaxZ = maxZ + 1000; } } + +/** C BRIDGE FUNCTIONS **/ + +extern "C" void Editor_Launch(const char* resourceName) { +#if not defined(__SWITCH__) and not defined(__WIIU__) + TrackBrowser::Instance->SetTrack(std::string(resourceName)); + gEditor.Enable(); +#endif +} + +extern "C" void Editor_SetLevelDimensions(s16 minX, s16 maxX, s16 minZ, s16 maxZ, s16 minY, s16 maxY) { + gEditor.SetLevelDimensions(minX, maxX, minZ, maxZ, minY, maxY); +} + +extern "C" bool Editor_IsEnabled() { + return gEditor.IsEnabled(); +} + +extern "C" bool Editor_IsPaused() { + return gEditor.IsPaused(); +} |
