diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-12-07 21:00:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-07 21:00:06 -0700 |
| commit | dbae0c3aca33a022e8c1d511fe521407375057b2 (patch) | |
| tree | 889ebe9e5c03261d92304545c5beae13892831f2 /src/port | |
| parent | 04ca19a9757752676450364e998d6af0d90e73ef (diff) | |
Name ScreenContext, Refactor Course class to Track (#583)
* Rename Screen Contexts
* typedef ScreenContext struct
* Fix Compile
* Rename Course.cpp to Track.cpp
* Refactor Course to Track
* A few renames
* General Cleanup
* More Rename
* More names
* Move TrackSections struct to Track.h
---------
Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Diffstat (limited to 'src/port')
| -rw-r--r-- | src/port/Engine.cpp | 22 | ||||
| -rw-r--r-- | src/port/Game.cpp | 370 | ||||
| -rw-r--r-- | src/port/Game.h | 37 | ||||
| -rw-r--r-- | src/port/resource/importers/TrackSectionsFactory.cpp | 1 | ||||
| -rw-r--r-- | src/port/resource/type/TrackSections.cpp | 1 | ||||
| -rw-r--r-- | src/port/resource/type/TrackSections.h | 2 | ||||
| -rw-r--r-- | src/port/ui/ContentBrowser.cpp | 40 | ||||
| -rw-r--r-- | src/port/ui/ContentBrowser.h | 8 | ||||
| -rw-r--r-- | src/port/ui/ImguiUI.cpp | 7 | ||||
| -rw-r--r-- | src/port/ui/MultiplayerWindow.cpp | 164 | ||||
| -rw-r--r-- | src/port/ui/MultiplayerWindow.h | 6 | ||||
| -rw-r--r-- | src/port/ui/PortMenu.cpp | 16 | ||||
| -rw-r--r-- | src/port/ui/TrackProperties.cpp | 86 |
13 files changed, 277 insertions, 483 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index 9f0d6d3f9..ff476592e 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -734,28 +734,6 @@ extern "C" void Timer_SetValue(int32_t* address, int32_t value) { *address = value; } -// void Timer_CompleteTask(TimedEntry& task) { -// if (task.action != nullptr) { -// task.action(task.address, task.value); -// } -// task.active = false; -// } - -// extern "C" void Timer_Update() { - -// if(gTimerTasks.empty()) { -// return; -// } - -// const auto millis = Timer_GetCurrentMillis(); - -// for (auto& task : gTimerTasks) { -// if (task.active && millis >= task.duration) { -// Timer_CompleteTask(task); -// } -// } -// } - extern "C" float OTRGetAspectRatio() { return GetInterpreter()->mCurDimensions.aspect_ratio; } diff --git a/src/port/Game.cpp b/src/port/Game.cpp index 14aeee9ec..1a822712b 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -5,30 +5,30 @@ #include <graphic/Fast3D/Fast3dWindow.h> #include "engine/World.h" -#include "engine/courses/Course.h" -#include "engine/courses/MarioRaceway.h" -#include "engine/courses/ChocoMountain.h" -#include "engine/courses/BowsersCastle.h" -#include "engine/courses/BansheeBoardwalk.h" -#include "engine/courses/YoshiValley.h" -#include "engine/courses/FrappeSnowland.h" -#include "engine/courses/KoopaTroopaBeach.h" -#include "engine/courses/RoyalRaceway.h" -#include "engine/courses/LuigiRaceway.h" -#include "engine/courses/MooMooFarm.h" -#include "engine/courses/ToadsTurnpike.h" -#include "engine/courses/KalimariDesert.h" -#include "engine/courses/SherbetLand.h" -#include "engine/courses/RainbowRoad.h" -#include "engine/courses/WarioStadium.h" -#include "engine/courses/BlockFort.h" -#include "engine/courses/Skyscraper.h" -#include "engine/courses/DoubleDeck.h" -#include "engine/courses/DKJungle.h" -#include "engine/courses/BigDonut.h" -#include "engine/courses/TestCourse.h" - -#include "engine/courses/PodiumCeremony.h" +#include "engine/tracks/Track.h" +#include "engine/tracks/MarioRaceway.h" +#include "engine/tracks/ChocoMountain.h" +#include "engine/tracks/BowsersCastle.h" +#include "engine/tracks/BansheeBoardwalk.h" +#include "engine/tracks/YoshiValley.h" +#include "engine/tracks/FrappeSnowland.h" +#include "engine/tracks/KoopaTroopaBeach.h" +#include "engine/tracks/RoyalRaceway.h" +#include "engine/tracks/LuigiRaceway.h" +#include "engine/tracks/MooMooFarm.h" +#include "engine/tracks/ToadsTurnpike.h" +#include "engine/tracks/KalimariDesert.h" +#include "engine/tracks/SherbetLand.h" +#include "engine/tracks/RainbowRoad.h" +#include "engine/tracks/WarioStadium.h" +#include "engine/tracks/BlockFort.h" +#include "engine/tracks/Skyscraper.h" +#include "engine/tracks/DoubleDeck.h" +#include "engine/tracks/DKJungle.h" +#include "engine/tracks/BigDonut.h" +#include "engine/tracks/TestTrack.h" + +#include "engine/tracks/PodiumCeremony.h" #include "engine/GarbageCollector.h" @@ -62,6 +62,7 @@ extern "C" { #include "update_objects.h" #include "spawn_players.h" #include "src/enhancements/collision_viewer.h" +#include "code_800029B0.h" // #include "engine/wasm.h" } @@ -69,8 +70,6 @@ extern "C" void Graphics_PushFrame(Gfx* data) { GameEngine::ProcessGfxCommands(data); } -extern "C" void Timer_Update(); - // Create the world instance World gWorldInstance; @@ -92,33 +91,33 @@ Editor::Editor gEditor; s32 gTrophyIndex = NULL; void CustomEngineInit() { - /* Add all courses to the global course list */ - std::shared_ptr<Course> mario = gWorldInstance.AddCourse(std::make_shared<MarioRaceway>()); - std::shared_ptr<Course> choco = gWorldInstance.AddCourse(std::make_shared<ChocoMountain>()); - std::shared_ptr<Course> bowser = gWorldInstance.AddCourse(std::make_shared<BowsersCastle>()); - std::shared_ptr<Course> banshee = gWorldInstance.AddCourse(std::make_shared<BansheeBoardwalk>()); - std::shared_ptr<Course> yoshi = gWorldInstance.AddCourse(std::make_shared<YoshiValley>()); - std::shared_ptr<Course> frappe = gWorldInstance.AddCourse(std::make_shared<FrappeSnowland>()); - std::shared_ptr<Course> koopa = gWorldInstance.AddCourse(std::make_shared<KoopaTroopaBeach>()); - std::shared_ptr<Course> royal = gWorldInstance.AddCourse(std::make_shared<RoyalRaceway>()); - std::shared_ptr<Course> luigi = gWorldInstance.AddCourse(std::make_shared<LuigiRaceway>()); - std::shared_ptr<Course> mooMoo = gWorldInstance.AddCourse(std::make_shared<MooMooFarm>()); - std::shared_ptr<Course> toads = gWorldInstance.AddCourse(std::make_shared<ToadsTurnpike>()); - std::shared_ptr<Course> kalimari = gWorldInstance.AddCourse(std::make_shared<KalimariDesert>()); - std::shared_ptr<Course> sherbet = gWorldInstance.AddCourse(std::make_shared<SherbetLand>()); - std::shared_ptr<Course> rainbow = gWorldInstance.AddCourse(std::make_shared<RainbowRoad>()); - std::shared_ptr<Course> wario = gWorldInstance.AddCourse(std::make_shared<WarioStadium>()); - std::shared_ptr<Course> block = gWorldInstance.AddCourse(std::make_shared<BlockFort>()); - std::shared_ptr<Course> skyscraper = gWorldInstance.AddCourse(std::make_shared<Skyscraper>()); - std::shared_ptr<Course> doubleDeck = gWorldInstance.AddCourse(std::make_shared<DoubleDeck>()); - std::shared_ptr<Course> dkJungle = gWorldInstance.AddCourse(std::make_shared<DKJungle>()); - std::shared_ptr<Course> bigDonut = gWorldInstance.AddCourse(std::make_shared<BigDonut>()); -// std::shared_ptr<Course> harbour = gWorldInstance.AddCourse(std::make_shared<Harbour>()); - std::shared_ptr<Course> testCourse = gWorldInstance.AddCourse(std::make_shared<TestCourse>()); + /* Add all tracks to the global track list */ + std::shared_ptr<Track> mario = gWorldInstance.AddTrack(std::make_shared<MarioRaceway>()); + std::shared_ptr<Track> choco = gWorldInstance.AddTrack(std::make_shared<ChocoMountain>()); + std::shared_ptr<Track> bowser = gWorldInstance.AddTrack(std::make_shared<BowsersCastle>()); + std::shared_ptr<Track> banshee = gWorldInstance.AddTrack(std::make_shared<BansheeBoardwalk>()); + std::shared_ptr<Track> yoshi = gWorldInstance.AddTrack(std::make_shared<YoshiValley>()); + std::shared_ptr<Track> frappe = gWorldInstance.AddTrack(std::make_shared<FrappeSnowland>()); + std::shared_ptr<Track> koopa = gWorldInstance.AddTrack(std::make_shared<KoopaTroopaBeach>()); + std::shared_ptr<Track> royal = gWorldInstance.AddTrack(std::make_shared<RoyalRaceway>()); + std::shared_ptr<Track> luigi = gWorldInstance.AddTrack(std::make_shared<LuigiRaceway>()); + std::shared_ptr<Track> mooMoo = gWorldInstance.AddTrack(std::make_shared<MooMooFarm>()); + std::shared_ptr<Track> toads = gWorldInstance.AddTrack(std::make_shared<ToadsTurnpike>()); + std::shared_ptr<Track> kalimari = gWorldInstance.AddTrack(std::make_shared<KalimariDesert>()); + std::shared_ptr<Track> sherbet = gWorldInstance.AddTrack(std::make_shared<SherbetLand>()); + std::shared_ptr<Track> rainbow = gWorldInstance.AddTrack(std::make_shared<RainbowRoad>()); + std::shared_ptr<Track> wario = gWorldInstance.AddTrack(std::make_shared<WarioStadium>()); + std::shared_ptr<Track> block = gWorldInstance.AddTrack(std::make_shared<BlockFort>()); + std::shared_ptr<Track> skyscraper = gWorldInstance.AddTrack(std::make_shared<Skyscraper>()); + std::shared_ptr<Track> doubleDeck = gWorldInstance.AddTrack(std::make_shared<DoubleDeck>()); + std::shared_ptr<Track> dkJungle = gWorldInstance.AddTrack(std::make_shared<DKJungle>()); + std::shared_ptr<Track> bigDonut = gWorldInstance.AddTrack(std::make_shared<BigDonut>()); +// std::shared_ptr<Track> harbour = gWorldInstance.AddTrack(std::make_shared<Harbour>()); + std::shared_ptr<Track> testTrack = gWorldInstance.AddTrack(std::make_shared<TestTrack>()); gPodiumCeremony = std::make_unique<PodiumCeremony>(); - // Construct cups with vectors of Course* (non-owning references) + // Construct cups with vectors of Track* (non-owning references) gMushroomCup = new Cup("mk:mushroom_cup", "Mushroom Cup", { luigi, mooMoo, koopa, kalimari }); @@ -174,9 +173,9 @@ void HM_DrawIntro() { gMenuIntro.HM_DrawIntro(); } -// Set default course; mario raceway +// Set default track; mario raceway void SetMarioRaceway(void) { - SetCourseById(0); + SetTrackById(0); gWorldInstance.SetCurrentCup(gMushroomCup); gWorldInstance.GetCurrentCup()->CursorPosition = 3; gWorldInstance.CupIndex = 0; @@ -210,37 +209,37 @@ const char* GetCupName(void) { return gWorldInstance.GetCurrentCup()->Name; } -void LoadCourse() { +void LoadTrack() { gWorldInstance.GetRaceManager().Load(); } -// Unload can be call to frequently so even when if the course wasn't loaded before -void UnLoadCourse() { +// Unload can be call to frequently so even when if the track wasn't loaded before +void UnLoadTrack() { gWorldInstance.GetRaceManager().UnLoad(); } -size_t GetCourseIndex() { - return gWorldInstance.CourseIndex; +size_t GetTrackIndex() { + return gWorldInstance.TrackIndex; } -void SetCourse(const char* name) { - gWorldInstance.SetCourse(name); +void SetTrack(const char* name) { + gWorldInstance.SetTrack(name); } -void NextCourse() { - gWorldInstance.NextCourse(); +void NextTrack() { + gWorldInstance.NextTrack(); } -void PreviousCourse() { - gWorldInstance.PreviousCourse(); +void PreviousTrack() { + gWorldInstance.PreviousTrack(); } -void SetCourseById(s32 course) { - if (course < 0 || course >= gWorldInstance.Courses.size()) { +void SetTrackById(s32 track) { + if (track < 0 || track >= gWorldInstance.Tracks.size()) { return; } - gWorldInstance.CourseIndex = course; - gWorldInstance.SetCurrentCourse(gWorldInstance.Courses[gWorldInstance.CourseIndex]); + gWorldInstance.TrackIndex = track; + gWorldInstance.SetCurrentTrack(gWorldInstance.Tracks[gWorldInstance.TrackIndex]); } void CM_VehicleCollision(s32 playerId, Player* player) { @@ -315,18 +314,18 @@ s32 CM_GetCrossingOnTriggered(uintptr_t* crossing) { * 2) Full scene --> The entire scene is rendered at once * * Custom tracks only use the Render() method, and they only render the full scene. - * They do not use RenderCredits() and they do not use track sections. + * They do not use DrawCredits() and they do not use track sections. */ -void CM_RenderCourse(struct UnkStruct_800DC5EC* screen) { - if (nullptr == gWorldInstance.GetCurrentCourse()) { +void CM_DrawTrack(ScreenContext* screen) { + if (nullptr == gWorldInstance.GetTrack()) { return; } - // Custom tracks should never use RenderCredits(); - if (gWorldInstance.GetCurrentCourse()->IsMod()) { + // Custom tracks should never use DrawCredits(); + if (gWorldInstance.GetTrack()->IsMod()) { switch(screen->camera->renderMode) { default: - gWorldInstance.GetCurrentCourse()->Render(screen); + gWorldInstance.GetTrack()->Draw(screen); break; case RENDER_COLLISION_MESH: render_collision(); @@ -335,10 +334,10 @@ void CM_RenderCourse(struct UnkStruct_800DC5EC* screen) { } else { switch(screen->camera->renderMode) { case RENDER_FULL_SCENE: - gWorldInstance.GetCurrentCourse()->RenderCredits(); + gWorldInstance.GetTrack()->DrawCredits(); break; case RENDER_TRACK_SECTIONS: - gWorldInstance.GetCurrentCourse()->Render(screen); + gWorldInstance.GetTrack()->Draw(screen); break; case RENDER_COLLISION_MESH: render_collision(); @@ -348,7 +347,7 @@ void CM_RenderCourse(struct UnkStruct_800DC5EC* screen) { } void CM_TickActors() { - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { gWorldInstance.TickActors(); } } @@ -376,26 +375,26 @@ void CM_DrawStaticMeshActors() { void CM_BeginPlay() { static bool tour = false; - auto course = gWorldInstance.GetCurrentCourse(); + auto track = gWorldInstance.GetTrack(); - if (nullptr == course) { + if (nullptr == track) { return; } if (tour) { // gWorldInstance.Cameras[2]->SetActive(true); - // D_800DC5EC->camera = gWorldInstance.Cameras[2]->Get(); + // gScreenOneCtx->camera = gWorldInstance.Cameras[2]->Get(); if (reinterpret_cast<TourCamera*>(gWorldInstance.Cameras[2])->IsTourComplete()) { tour = false; - D_800DC5EC->pendingCamera = &cameras[0]; + gScreenOneCtx->pendingCamera = &cameras[0]; } } - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { // This line should likely be moved. // It's here so PreInit is after the scene file has been loaded // It used to be at the start of BeginPlay - Editor::LoadLevel(gWorldInstance.GetCurrentCourse().get(), gWorldInstance.GetCurrentCourse()->SceneFilePtr); + Editor::LoadLevel(gWorldInstance.GetTrack().get(), gWorldInstance.GetTrack()->SceneFilePtr); } gWorldInstance.GetRaceManager().PreInit(); @@ -450,23 +449,23 @@ Camera* CM_AddTourCamera(Vec3f spawn, s16 rot, u32 mode) { if (gWorldInstance.Cameras.size() >= NUM_CAMERAS) { // This is to prevent soft locking the game printf("Reached the max number of cameras, %d\n", NUM_CAMERAS); - if (gWorldInstance.GetCurrentCourse()->bTourEnabled) { + if (gWorldInstance.GetTrack()->bTourEnabled) { spawn_and_set_player_spawns(); } return nullptr; } - if (nullptr == gWorldInstance.GetCurrentCourse()) { + if (nullptr == gWorldInstance.GetTrack()) { // This is to prevent soft locking the game - if (gWorldInstance.GetCurrentCourse()->bTourEnabled) { + if (gWorldInstance.GetTrack()->bTourEnabled) { spawn_and_set_player_spawns(); } return nullptr; } - if (gWorldInstance.GetCurrentCourse()->TourShots.size() == 0) { + if (gWorldInstance.GetTrack()->TourShots.size() == 0) { // This is to prevent soft locking the game - if (gWorldInstance.GetCurrentCourse()->bTourEnabled) { + if (gWorldInstance.GetTrack()->bTourEnabled) { spawn_and_set_player_spawns(); } return nullptr; @@ -479,8 +478,8 @@ Camera* CM_AddTourCamera(Vec3f spawn, s16 rot, u32 mode) { } bool CM_IsTourEnabled() { - if (nullptr != gWorldInstance.GetCurrentCourse()) { - if ((gWorldInstance.GetCurrentCourse()->bTourEnabled) && (gTourComplete == false)) { + if (nullptr != gWorldInstance.GetTrack()) { + if ((gWorldInstance.GetTrack()->bTourEnabled) && (gTourComplete == false)) { return true; } else { return false; @@ -511,14 +510,14 @@ void CM_CameraSetActive(size_t idx, bool state) { void CM_SetFreeCamera(bool state) { for (auto* cam : gWorldInstance.Cameras) { - if (cam->Get() == D_800DC5EC->freeCamera) { + if (cam->Get() == gScreenOneCtx->freeCamera) { if (state) { - D_800DC5EC->pendingCamera = D_800DC5EC->freeCamera; + gScreenOneCtx->pendingCamera = gScreenOneCtx->freeCamera; cam->SetActive(true); } else { - if (nullptr != D_800DC5EC->raceCamera) { + if (nullptr != gScreenOneCtx->raceCamera) { if (gGamestate == RACING) { - D_800DC5EC->pendingCamera = D_800DC5EC->raceCamera; + gScreenOneCtx->pendingCamera = gScreenOneCtx->raceCamera; cam->SetActive(false); } else { cam->SetActive(false); @@ -538,7 +537,7 @@ void CM_ActivateTourCamera(Camera* camera) { } void CM_TickObjects() { - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { gWorldInstance.TickObjects(); } } @@ -546,13 +545,13 @@ void CM_TickObjects() { // A couple objects such as lakitu are ticked inside of process_game_tick which support 60fps. // This is a fallback to support that. void CM_TickObjects60fps() { - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { gWorldInstance.TickObjects60fps(); } } void CM_DrawObjects(s32 cameraId) { - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { gWorldInstance.DrawObjects(cameraId); } } @@ -570,119 +569,119 @@ void CM_Editor_SetLevelDimensions(s16 minX, s16 maxX, s16 minZ, s16 maxZ, s16 mi } void CM_TickParticles() { - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { gWorldInstance.TickParticles(); } } void CM_DrawParticles(s32 cameraId) { - if (gWorldInstance.GetCurrentCourse()) { + if (gWorldInstance.GetTrack()) { gWorldInstance.DrawParticles(cameraId); } } void CM_InitClouds() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->InitClouds(); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->InitClouds(); } } -void CM_UpdateClouds(s32 arg0, Camera* camera) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->UpdateClouds(arg0, camera); +void CM_TickClouds(s32 arg0, Camera* camera) { + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->TickClouds(arg0, camera); } } void CM_Waypoints(Player* player, int8_t playerId) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->Waypoints(player, playerId); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->Waypoints(player, playerId); } } void CM_SomeCollisionThing(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4, f32* arg5, f32* arg6, f32* arg7) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->SomeCollisionThing(player, arg1, arg2, arg3, arg4, arg5, arg6, arg7); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->SomeCollisionThing(player, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } } -void CM_InitCourseObjects() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->InitCourseObjects(); +void CM_InitTrackObjects() { + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->InitTrackObjects(); } } -void CM_UpdateCourseObjects() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->UpdateCourseObjects(); +void CM_TickTrackObjects() { + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->TickTrackObjects(); } TrainSmokeTick(); } -void CM_RenderCourseObjects(s32 cameraId) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->RenderCourseObjects(cameraId); +void CM_DrawTrackObjects(s32 cameraId) { + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->DrawTrackObjects(cameraId); } TrainSmokeDraw(cameraId); } void CM_SomeSounds() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->SomeSounds(); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->SomeSounds(); } } void CM_CreditsSpawnActors() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->CreditsSpawnActors(); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->CreditsSpawnActors(); } } void CM_WhatDoesThisDo(Player* player, int8_t playerId) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->WhatDoesThisDo(player, playerId); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->WhatDoesThisDo(player, playerId); } } void CM_WhatDoesThisDoAI(Player* player, int8_t playerId) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->WhatDoesThisDoAI(player, playerId); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->WhatDoesThisDoAI(player, playerId); } } void CM_SetStaffGhost() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->SetStaffGhost(); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->SetStaffGhost(); } } Properties* CM_GetProps() { - if (gWorldInstance.GetCurrentCourse()) { - return &gWorldInstance.GetCurrentCourse()->Props; + if (gWorldInstance.GetTrack()) { + return &gWorldInstance.GetTrack()->Props; } return NULL; } -Properties* CM_GetPropsCourseId(s32 courseId) { - return &gWorldInstance.Courses[courseId]->Props; +Properties* CM_GetPropsTrackId(s32 trackId) { + return &gWorldInstance.Tracks[trackId]->Props; } void CM_ScrollingTextures() { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->ScrollingTextures(); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->ScrollingTextures(); } } -void CM_DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, +void CM_DrawWater(ScreenContext* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection) { - if (gWorldInstance.GetCurrentCourse()) { - gWorldInstance.GetCurrentCourse()->DrawWater(screen, pathCounter, cameraRot, playerDirection); + if (gWorldInstance.GetTrack()) { + gWorldInstance.GetTrack()->DrawWater(screen, pathCounter, cameraRot, playerDirection); } } /** - * This should only be ran once per course, otherwise animation/timings might become sped up. + * This should only be ran once per track, otherwise animation/timings might become sped up. */ void CM_SpawnStarterLakitu() { if ((gDemoMode) || (gGamestate == CREDITS_SEQUENCE)) { @@ -730,7 +729,7 @@ size_t GetCupCursorPosition() { } void SetCupCursorPosition(size_t position) { - gWorldInstance.GetCurrentCup()->SetCourse(position); + gWorldInstance.GetCurrentCup()->SetTrack(position); // gWorldInstance.CurrentCup->CursorPosition = position; } @@ -738,12 +737,12 @@ size_t GetCupSize() { return gWorldInstance.GetCurrentCup()->GetSize(); } -void SetCourseFromCup() { - gWorldInstance.SetCurrentCourse(gWorldInstance.GetCurrentCup()->GetCourse()); +void SetTrackFromCup() { + gWorldInstance.SetCurrentTrack(gWorldInstance.GetCurrentCup()->GetTrack()); } -void* GetCourse(void) { - return gWorldInstance.GetCurrentCourse().get(); +void* GetTrack(void) { + return gWorldInstance.GetTrack().get(); } struct Actor* CM_GetActor(size_t index) { @@ -841,53 +840,53 @@ void CM_ActorCollision(Player* player, Actor* actor) { f32 CM_GetWaterLevel(Vec3f pos, Collision* collision) { FVector fPos = {pos[0], pos[1], pos[2]}; - return gWorldInstance.GetCurrentCourse()->GetWaterLevel(fPos, collision); + return gWorldInstance.GetTrack()->GetWaterLevel(fPos, collision); } // clang-format off -bool IsMarioRaceway() { return dynamic_cast<MarioRaceway*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsLuigiRaceway() { return dynamic_cast<LuigiRaceway*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsChocoMountain() { return dynamic_cast<ChocoMountain*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsBowsersCastle() { return dynamic_cast<BowsersCastle*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsBansheeBoardwalk() { return dynamic_cast<BansheeBoardwalk*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsYoshiValley() { return dynamic_cast<YoshiValley*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsFrappeSnowland() { return dynamic_cast<FrappeSnowland*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsKoopaTroopaBeach() { return dynamic_cast<KoopaTroopaBeach*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsRoyalRaceway() { return dynamic_cast<RoyalRaceway*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsMooMooFarm() { return dynamic_cast<MooMooFarm*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsToadsTurnpike() { return dynamic_cast<ToadsTurnpike*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsKalimariDesert() { return dynamic_cast<KalimariDesert*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsSherbetLand() { return dynamic_cast<SherbetLand*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsRainbowRoad() { return dynamic_cast<RainbowRoad*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsWarioStadium() { return dynamic_cast<WarioStadium*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsBlockFort() { return dynamic_cast<BlockFort*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsSkyscraper() { return dynamic_cast<Skyscraper*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsDoubleDeck() { return dynamic_cast<DoubleDeck*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsDkJungle() { return dynamic_cast<DKJungle*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsBigDonut() { return dynamic_cast<BigDonut*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } -bool IsPodiumCeremony() { return dynamic_cast<PodiumCeremony*>(gWorldInstance.GetCurrentCourse().get()) != nullptr; } - -void SelectMarioRaceway() { gWorldInstance.SetCourseByType<MarioRaceway>(); } -void SelectLuigiRaceway() { gWorldInstance.SetCourseByType<LuigiRaceway>(); } -void SelectChocoMountain() { gWorldInstance.SetCourseByType<ChocoMountain>(); } -void SelectBowsersCastle() { gWorldInstance.SetCourseByType<BowsersCastle>(); } -void SelectBansheeBoardwalk() { gWorldInstance.SetCourseByType<BansheeBoardwalk>(); } -void SelectYoshiValley() { gWorldInstance.SetCourseByType<YoshiValley>(); } -void SelectFrappeSnowland() { gWorldInstance.SetCourseByType<FrappeSnowland>(); } -void SelectKoopaTroopaBeach() { gWorldInstance.SetCourseByType<KoopaTroopaBeach>(); } -void SelectRoyalRaceway() { gWorldInstance.SetCourseByType<RoyalRaceway>(); } -void SelectMooMooFarm() { gWorldInstance.SetCourseByType<MooMooFarm>(); } -void SelectToadsTurnpike() { gWorldInstance.SetCourseByType<ToadsTurnpike>(); } -void SelectKalimariDesert() { gWorldInstance.SetCourseByType<KalimariDesert>(); } -void SelectSherbetLand() { gWorldInstance.SetCourseByType<SherbetLand>(); } -void SelectRainbowRoad() { gWorldInstance.SetCourseByType<RainbowRoad>(); } -void SelectWarioStadium() { gWorldInstance.SetCourseByType<WarioStadium>(); } -void SelectBlockFort() { gWorldInstance.SetCourseByType<BlockFort>(); } -void SelectSkyscraper() { gWorldInstance.SetCourseByType<Skyscraper>(); } -void SelectDoubleDeck() { gWorldInstance.SetCourseByType<DoubleDeck>(); } -void SelectDkJungle() { gWorldInstance.SetCourseByType<DKJungle>(); } -void SelectBigDonut() { gWorldInstance.SetCourseByType<BigDonut>(); } -void SelectPodiumCeremony() { gWorldInstance.SetCurrentCourse(gPodiumCeremony); } +bool IsMarioRaceway() { return dynamic_cast<MarioRaceway*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsLuigiRaceway() { return dynamic_cast<LuigiRaceway*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsChocoMountain() { return dynamic_cast<ChocoMountain*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsBowsersCastle() { return dynamic_cast<BowsersCastle*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsBansheeBoardwalk() { return dynamic_cast<BansheeBoardwalk*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsYoshiValley() { return dynamic_cast<YoshiValley*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsFrappeSnowland() { return dynamic_cast<FrappeSnowland*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsKoopaTroopaBeach() { return dynamic_cast<KoopaTroopaBeach*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsRoyalRaceway() { return dynamic_cast<RoyalRaceway*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsMooMooFarm() { return dynamic_cast<MooMooFarm*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsToadsTurnpike() { return dynamic_cast<ToadsTurnpike*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsKalimariDesert() { return dynamic_cast<KalimariDesert*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsSherbetLand() { return dynamic_cast<SherbetLand*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsRainbowRoad() { return dynamic_cast<RainbowRoad*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsWarioStadium() { return dynamic_cast<WarioStadium*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsBlockFort() { return dynamic_cast<BlockFort*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsSkyscraper() { return dynamic_cast<Skyscraper*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsDoubleDeck() { return dynamic_cast<DoubleDeck*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsDkJungle() { return dynamic_cast<DKJungle*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsBigDonut() { return dynamic_cast<BigDonut*>(gWorldInstance.GetTrack().get()) != nullptr; } +bool IsPodiumCeremony() { return dynamic_cast<PodiumCeremony*>(gWorldInstance.GetTrack().get()) != nullptr; } + +void SelectMarioRaceway() { gWorldInstance.SetTrackByType<MarioRaceway>(); } +void SelectLuigiRaceway() { gWorldInstance.SetTrackByType<LuigiRaceway>(); } +void SelectChocoMountain() { gWorldInstance.SetTrackByType<ChocoMountain>(); } +void SelectBowsersCastle() { gWorldInstance.SetTrackByType<BowsersCastle>(); } +void SelectBansheeBoardwalk() { gWorldInstance.SetTrackByType<BansheeBoardwalk>(); } +void SelectYoshiValley() { gWorldInstance.SetTrackByType<YoshiValley>(); } +void SelectFrappeSnowland() { gWorldInstance.SetTrackByType<FrappeSnowland>(); } +void SelectKoopaTroopaBeach() { gWorldInstance.SetTrackByType<KoopaTroopaBeach>(); } +void SelectRoyalRaceway() { gWorldInstance.SetTrackByType<RoyalRaceway>(); } +void SelectMooMooFarm() { gWorldInstance.SetTrackByType<MooMooFarm>(); } +void SelectToadsTurnpike() { gWorldInstance.SetTrackByType<ToadsTurnpike>(); } +void SelectKalimariDesert() { gWorldInstance.SetTrackByType<KalimariDesert>(); } +void SelectSherbetLand() { gWorldInstance.SetTrackByType<SherbetLand>(); } +void SelectRainbowRoad() { gWorldInstance.SetTrackByType<RainbowRoad>(); } +void SelectWarioStadium() { gWorldInstance.SetTrackByType<WarioStadium>(); } +void SelectBlockFort() { gWorldInstance.SetTrackByType<BlockFort>(); } +void SelectSkyscraper() { gWorldInstance.SetTrackByType<Skyscraper>(); } +void SelectDoubleDeck() { gWorldInstance.SetTrackByType<DoubleDeck>(); } +void SelectDkJungle() { gWorldInstance.SetTrackByType<DKJungle>(); } +void SelectBigDonut() { gWorldInstance.SetTrackByType<BigDonut>(); } +void SelectPodiumCeremony() { gWorldInstance.SetCurrentTrack(gPodiumCeremony); } // clang-format on void* GetMushroomCup(void) { @@ -936,7 +935,6 @@ void push_frame() { GameEngine::EndAudioFrame(); // thread5_game_loop(); // Graphics_ThreadUpdate();w - // Timer_Update(); } #ifdef _WIN32 diff --git a/src/port/Game.h b/src/port/Game.h index 8474efcc9..afc5241fe 100644 --- a/src/port/Game.h +++ b/src/port/Game.h @@ -2,18 +2,19 @@ #define _GAME_H #include <libultraship.h> -#include "engine/courses/Course.h" +#include "engine/tracks/Track.h" #include "engine/HM_Intro.h" #ifdef __cplusplus #include "engine/editor/Editor.h" -class Course; +class Track; struct Properties; class World; extern "C" { #endif #include "camera.h" #include "actor_types.h" +#include "code_800029B0.h" extern s32 gTrophyIndex; @@ -24,7 +25,7 @@ extern bool bCleanWorld; #endif Properties* CM_GetProps(); -Properties* CM_GetPropsCourseId(s32 courseId); +Properties* CM_GetPropsTrackId(s32 trackId); void HM_InitIntro(void); void HM_TickIntro(void); @@ -41,21 +42,21 @@ u32 GetCupIndex(void); const char* GetCupName(void); -void LoadCourse(); -void UnLoadCourse(); +void LoadTrack(); +void UnLoadTrack(); -size_t GetCourseIndex(); +size_t GetTrackIndex(); -void SetCourse(const char* name); +void SetTrack(const char* name); -void NextCourse(); -void PreviousCourse(); +void NextTrack(); +void PreviousTrack(); void CM_SetCup(void*); void CM_SetCupIndex(size_t index); -void CM_RenderCourse(struct UnkStruct_800DC5EC* arg0); +void CM_DrawTrack(ScreenContext* arg0); void CM_SpawnStarterLakitu(); void CM_ActivateFinishLakitu(s32 playerId); @@ -94,18 +95,18 @@ void Editor_CleanWorld(); void CM_TickParticles(void); void CM_DrawParticles(s32 cameraId); -void CM_UpdateClouds(s32 arg0, Camera* camera); +void CM_TickClouds(s32 arg0, Camera* camera); void CM_Waypoints(Player* player, int8_t playerId); void CM_SomeCollisionThing(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4, f32* arg5, f32* arg6, f32* arg7); -void CM_InitCourseObjects(); +void CM_InitTrackObjects(); -void CM_UpdateCourseObjects(); +void CM_TickTrackObjects(); -void CM_RenderCourseObjects(s32 cameraId); +void CM_DrawTrackObjects(s32 cameraId); void CM_SomeSounds(); @@ -125,7 +126,7 @@ s32 CM_GetCrossingOnTriggered(uintptr_t* crossing); void CM_BeginPlay(); -void CM_DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, +void CM_DrawWater(ScreenContext* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection); void CM_AICrossingBehaviour(s32 playerId); @@ -148,11 +149,11 @@ void SetCupCursorPosition(size_t position); size_t GetCupSize(); -void SetCourseFromCup(); +void SetTrackFromCup(); -void* GetCourse(void); +void* GetTrack(void); -void SetCourseById(s32 course); +void SetTrackById(s32 track); struct Actor* CM_GetActor(size_t index); void CM_DeleteActor(size_t index); diff --git a/src/port/resource/importers/TrackSectionsFactory.cpp b/src/port/resource/importers/TrackSectionsFactory.cpp index 70d964e40..b6cf8fe9f 100644 --- a/src/port/resource/importers/TrackSectionsFactory.cpp +++ b/src/port/resource/importers/TrackSectionsFactory.cpp @@ -4,6 +4,7 @@ #include "libultraship/libultra/gbi.h" #include "StrHash64.h" #include "tinyxml2.h" +#include "src/engine/tracks/Track.h" namespace MK64 { std::shared_ptr<Ship::IResource> diff --git a/src/port/resource/type/TrackSections.cpp b/src/port/resource/type/TrackSections.cpp index 4a63145e8..5fd89f5c8 100644 --- a/src/port/resource/type/TrackSections.cpp +++ b/src/port/resource/type/TrackSections.cpp @@ -1,5 +1,6 @@ #include "TrackSections.h" #include "libultraship/libultra/gbi.h" +#include "src/engine/tracks/Track.h" namespace MK64 { TrackSectionsClass::TrackSectionsClass() : Resource(std::shared_ptr<Ship::ResourceInitData>()) { diff --git a/src/port/resource/type/TrackSections.h b/src/port/resource/type/TrackSections.h index f91a117d3..d8da4a292 100644 --- a/src/port/resource/type/TrackSections.h +++ b/src/port/resource/type/TrackSections.h @@ -1,9 +1,9 @@ #pragma once -#include "include/course.h" #include "resource/Resource.h" #include <vector> #include <libultra/gbi.h> +#include "src/engine/tracks/Track.h" namespace MK64 { class TrackSectionsClass : public Ship::Resource<TrackSections> { diff --git a/src/port/ui/ContentBrowser.cpp b/src/port/ui/ContentBrowser.cpp index 3daeea5f1..7ae4e333d 100644 --- a/src/port/ui/ContentBrowser.cpp +++ b/src/port/ui/ContentBrowser.cpp @@ -274,7 +274,7 @@ namespace Editor { if (!track.SceneFile.empty()) { // has scene file std::string label = fmt::format("{}##{}", track.Name, i_track); if (ImGui::Button(label.c_str())) { - gWorldInstance.SetCurrentCourse(track.course); + gWorldInstance.SetCurrentTrack(track.track); gGamestateNext = RACING; SetSceneFile(track.Archive, track.SceneFile); break; @@ -283,7 +283,7 @@ namespace Editor { std::string label = fmt::format("{} {}", ICON_FA_EXCLAMATION_TRIANGLE, track.Name); if (ImGui::Button(label.c_str())) { track.SceneFile = track.Dir + "/scene.json"; - gWorldInstance.SetCurrentCourse(track.invalidTrack); + gWorldInstance.SetCurrentTrack(track.invalidTrack); SetSceneFile(track.Archive, track.SceneFile); SaveLevel(); Refresh = true; @@ -294,14 +294,14 @@ namespace Editor { } } - // When resetting the known content, we need to also pop the custom courses - // out of World::Courses vector. Otherwise, duplicate courses would show up for users. + // When resetting the known content, we need to also pop the custom tracks + // out of World::Tracks vector. Otherwise, duplicate tracks would show up for users. void ContentBrowserWindow::RemoveCustomTracksFromTrackList() { for (auto& track : Tracks) { - auto it = gWorldInstance.Courses.begin(); - while (it != gWorldInstance.Courses.end()) { - if (track.course.get() == it->get()) { - it = gWorldInstance.Courses.erase(it); + auto it = gWorldInstance.Tracks.begin(); + while (it != gWorldInstance.Tracks.end()) { + if (track.track.get() == it->get()) { + it = gWorldInstance.Tracks.erase(it); } else { ++it; } @@ -401,13 +401,13 @@ namespace Editor { if (manager->HasFile(sceneFile)) { auto archive = manager->GetArchiveFromFile(sceneFile); - auto course = std::make_shared<Course>(); - course->RootArchive = archive; - course->LoadO2R(dir); - LoadLevel(course.get(), sceneFile); - LoadMinimap(course.get(), minimapFile); - Tracks.push_back({nullptr, course, sceneFile, name, dir, archive}); - gWorldInstance.Courses.push_back(std::move(course)); + auto track = std::make_shared<Track>(); + track->RootArchive = archive; + track->LoadO2R(dir); + LoadLevel(track.get(), sceneFile); + LoadMinimap(track.get(), minimapFile); + Tracks.push_back({nullptr, track, sceneFile, name, dir, archive}); + gWorldInstance.Tracks.push_back(std::move(track)); } else { // The track does not have a valid scene file const std::string file = dir + "/data_track_sections"; @@ -416,12 +416,12 @@ namespace Editor { // So lets add it as an uninitialized track. if (manager->HasFile(file)) { - auto course = std::make_shared<Course>(); - course->Id = (std::string("mods:") + name).c_str(); - course->Props.SetText(course->Props.Name, name.c_str(), sizeof(course->Props.Name)); - course->Props.SetText(course->Props.DebugName, name.c_str(), sizeof(course->Props.Name)); + auto track = std::make_shared<Track>(); + track->Id = (std::string("mods:") + name).c_str(); + track->Props.SetText(track->Props.Name, name.c_str(), sizeof(track->Props.Name)); + track->Props.SetText(track->Props.DebugName, name.c_str(), sizeof(track->Props.Name)); auto archive = manager->GetArchiveFromFile(file); - Tracks.push_back({course, nullptr, "", name, dir, archive}); + Tracks.push_back({track, nullptr, "", name, dir, archive}); } else { printf("ContentBrowser.cpp: Track '%s' missing required track files. Cannot add to game\n Missing %s/data_track_sections file\n", name.c_str(), dir.c_str()); } diff --git a/src/port/ui/ContentBrowser.h b/src/port/ui/ContentBrowser.h index 5fbdbb12a..ce1da71df 100644 --- a/src/port/ui/ContentBrowser.h +++ b/src/port/ui/ContentBrowser.h @@ -1,7 +1,7 @@ #pragma once #include <libultraship/libultraship.h> -#include "engine/courses/Course.h" +#include "engine/tracks/Track.h" #include "AllActors.h" namespace Editor { @@ -11,8 +11,8 @@ public: ~ContentBrowserWindow(); struct Tracks { - std::shared_ptr<Course> invalidTrack; // If not nullptr, user needs to create a scene file for this track. - std::shared_ptr<Course> course; // A valid custom track. Used to reset the Courses array on a file system refresh. + std::shared_ptr<Track> invalidTrack; // If not nullptr, user needs to create a scene file for this track. + std::shared_ptr<Track> track; // A valid custom track. Used to reset the World->Tracks array on a file system refresh. std::string SceneFile; std::string Name; std::string Dir; // Directory @@ -34,7 +34,7 @@ protected: void DrawElement() override; void UpdateElement() override {}; void AddTrackContent(); - void RemoveCustomTracksFromTrackList(); // Prevents duplicate courses being added to World->Courses array + void RemoveCustomTracksFromTrackList(); // Prevents duplicate tracks being added to World->Tracks array void AddActorContent(); void AddObjectContent(); void AddCustomContent(); diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index c5014c45d..02aaaed70 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -1,7 +1,6 @@ #include "ImguiUI.h" #include "UIWidgets.h" #include "ResolutionEditor.h" -#include "MultiplayerWindow.h" #include "FreecamWindow.h" #include "Tools.h" #include "SceneExplorer.h" @@ -34,7 +33,6 @@ std::shared_ptr<Ship::GuiWindow> mConsoleWindow; std::shared_ptr<Ship::GuiWindow> mStatsWindow; std::shared_ptr<Ship::GuiWindow> mInputEditorWindow; std::shared_ptr<Ship::GuiWindow> mGfxDebuggerWindow; -std::shared_ptr<Ship::GuiWindow> mMultiplayerWindow; std::shared_ptr<Ship::GuiWindow> mToolsWindow; std::shared_ptr<Ship::GuiWindow> mSceneExplorerWindow; std::shared_ptr<Ship::GuiWindow> mPropertiesWindow; @@ -50,11 +48,6 @@ void SetupGuiElements() { mPortMenu = std::make_shared<PortMenu>("gOpenMenu", "Port Menu"); gui->SetMenu(mPortMenu); - //mMultiplayerWindow = gui->GetGuiWindow("Multiplayer"); - //if (mMultiplayerWindow == nullptr) { - // SPDLOG_ERROR("Could not find multiplayer window"); - //} - mStatsWindow = gui->GetGuiWindow("Stats"); if (mStatsWindow == nullptr) { SPDLOG_ERROR("Could not find stats window"); diff --git a/src/port/ui/MultiplayerWindow.cpp b/src/port/ui/MultiplayerWindow.cpp deleted file mode 100644 index 33f23ccee..000000000 --- a/src/port/ui/MultiplayerWindow.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include "MultiplayerWindow.h" -#include "UIWidgets.h" -#include "PortMenu.h" -#include "libultraship/src/Context.h" - -#include <imgui.h> -#include <libultraship/libultraship.h> -#include "spdlog/spdlog.h" -#include <common_structs.h> -#include <defines.h> - -extern "C" { -#include "main.h" -#include "networking/networking.h" -#include "actor_types.h" -#include "code_800029B0.h" -extern struct Actor gActorList[]; -extern char* gCupNames[]; -extern char* D_800E76A8[]; -extern Network gNetwork; -extern Camera cameras[]; -extern UnkStruct_800DC5EC* D_800DC5EC; -} - -namespace GameUI { -extern std::shared_ptr<PortMenu> mPortMenu; -namespace Multiplayer { - -static s32 sConnectedBool = false; -static s32 sReadyUpBool = false; -static s32 sCharacter = 0; -static s32 sCup = 0; - -void DrawColumn1(WidgetInfo& info) { - if (gNetwork.isConnected) { - ImGui::BeginDisabled(); - } - - static char username[NETWORK_USERNAME_LENGTH] = "TestUser"; - - ImGui::Text("Username:"); - ImGui::InputText("##edit", username, IM_ARRAYSIZE(username)); - - static char address[32] = "127.0.0.1:64010"; - static char addressCopy[32]; - strncpy(addressCopy, address, sizeof(addressCopy)); - addressCopy[sizeof(addressCopy) - 1] = '\0'; // Ensure null termination - - ImGui::Text("Host:"); - ImGui::InputText("##edit3", addressCopy, IM_ARRAYSIZE(addressCopy)); - - if (ImGui::Button("Connect!")) { - char* ip = NULL; - uint16_t port = 0; - - char* token = strtok(addressCopy, ":"); - ip = token; - - token = strtok(NULL, ":"); - if (token != NULL) { - port = (uint16_t) atoi(token); - } - - gNetwork.enabled = true; - ConnectToServer(ip, port, username); - } - if (gNetwork.isConnected) { - ImGui::EndDisabled(); - } -} - -void DrawColumn2(WidgetInfo& info) { - if (!gNetwork.isConnected) { - ImGui::BeginDisabled(); - } - - ImGui::Text("Select Character:"); - ImGui::Spacing(); - - for (size_t i = 0; i < NUM_PLAYERS; i++) { - // These are euc-jp characters that look sort of like a hyphen - - if (D_800E76A8[i] == NULL || D_800E76A8[i] == "\xA1\xBC\xA1\xBC\xA1\xBC\xA1\xBC") { - break; - } - ImGui::SameLine(); - if (ImGui::Button(D_800E76A8[i])) { - network_character_vote(i); - sCharacter = i; - } - } - ImGui::Spacing(); - ImGui::Text("-- %s --", D_800E76A8[sCharacter]); - - ImGui::Spacing(); - ImGui::Spacing(); - ImGui::Text("Course Vote:"); - - for (size_t i = 0; i < NUM_CUPS - 1; i++) { - if (ImGui::Button(gCupNames[i])) { - network_cup_vote(i); - sCup = i; - } - ImGui::SameLine(); - } - ImGui::Spacing(); - ImGui::Text("-- %s --", gCupNames[sCup]); - - if (ImGui::Button("test", ImVec2(-1, 0))) { - // Add disconnect logic here - } - - for (size_t i = 0; i < NETWORK_MAX_PLAYERS; i++) { - ImGui::Text("Slot %d: char: %d, hasAuthority: %d", clients[i].slot, clients[i].character, - gPlayers[i].nHasAuthority); - } - - /* Stick UI to the bottom of the panel */ - - float windowHeight = ImGui::GetWindowHeight(); - - // Move the cursor to a position relative to the bottom of the window - ImGui::SetCursorPosY(windowHeight - - ImGui::GetFrameHeightWithSpacing() * 2); // Adjust Y position for two buttons - - char buttonLabel[32]; - - if (sReadyUpBool) { - strcpy(buttonLabel, "Lets Go!"); - } else { - strcpy(buttonLabel, "Ready Up!"); - } - - // First button (Ready Up / Let's Go) - if (ImGui::Button(buttonLabel, ImVec2(-1, 0))) { - sReadyUpBool = !sReadyUpBool; - networking_ready_up(sReadyUpBool); - } - - // Add some vertical spacing between the buttons - ImGui::Spacing(); - - // Second button (Disconnect) - if (ImGui::Button("Disconnect", ImVec2(-1, 0))) { - // Add disconnect logic here - networking_disconnect(); - } - if (!gNetwork.isConnected) { - ImGui::EndDisabled(); - } -} - -void RegisterMultiplayerWidgets() { - // mPortMenu->AddSidebarEntry("Enhancements", "Multiplayer", 2); - // WidgetPath path = { "Enhancements", "Multiplayer", SECTION_COLUMN_1 }; - // mPortMenu->AddWidget(path, "Multi Custom 1", WIDGET_CUSTOM) - // .CustomFunction(DrawColumn1); - // path.column = SECTION_COLUMN_2; - // mPortMenu->AddWidget(path, "Multi Custom 2", WIDGET_CUSTOM) - // .CustomFunction(DrawColumn2); -} - -static RegisterMenuInitFunc initFunc(RegisterMultiplayerWidgets); -} // namespace Multiplayer -} // namespace GameUI diff --git a/src/port/ui/MultiplayerWindow.h b/src/port/ui/MultiplayerWindow.h deleted file mode 100644 index d196c33c0..000000000 --- a/src/port/ui/MultiplayerWindow.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include <libultraship/libultraship.h> - -namespace Multiplayer { -} // namespace Multiplayer diff --git a/src/port/ui/PortMenu.cpp b/src/port/ui/PortMenu.cpp index e54af35a0..9ac89dc2f 100644 --- a/src/port/ui/PortMenu.cpp +++ b/src/port/ui/PortMenu.cpp @@ -10,9 +10,9 @@ #include <tuple> #include "ResolutionEditor.h" -#include "courses/Course.h" -#include "courses/KalimariDesert.h" -#include "courses/ToadsTurnpike.h" +#include "engine/tracks/Track.h" +#include "engine/tracks/KalimariDesert.h" +#include "engine/tracks/ToadsTurnpike.h" #ifdef __SWITCH__ #include <port/switch/SwitchImpl.h> @@ -358,10 +358,6 @@ void PortMenu::AddEnhancements() { AddMenuEntry("Enhancements", "gSettings.Menu.EnhancementsSidebarSection"); WidgetPath path = { "Enhancements", "General", SECTION_COLUMN_1 }; AddSidebarEntry("Enhancements", "General", 3); - // UIWidgets::WindowButton("Multiplayer", "gMultiplayerWindowEnabled", GameUI::mMultiplayerWindow, - // { .tooltip = "Shows the multiplayer window" }); - // UIWidgets::WindowButton("Freecam", "gFreecam", GameUI::mFreecamWindow, - // { .tooltip = "Allows you to fly around the course" }); AddWidget(path, "No multiplayer feature cuts", WIDGET_CVAR_CHECKBOX) .CVar("gMultiplayerNoFeatureCuts") .Options(CheckboxOptions().Tooltip("Allows full train and jumbotron in multiplayer, etc.")); @@ -549,7 +545,7 @@ void PortMenu::AddDevTools() { .DefaultValue(60)); AddWidget(path, "Render Collision", WIDGET_CVAR_CHECKBOX) .CVar("gRenderCollisionMesh") - .Options(CheckboxOptions().Tooltip("Renders the collision mesh instead of the course mesh")); + .Options(CheckboxOptions().Tooltip("Draws the collision mesh instead of the track mesh")); path = { "Developer", "Gfx Debugger", SECTION_COLUMN_1 }; AddSidebarEntry("Developer", "Gfx Debugger", 1); @@ -580,10 +576,6 @@ PortMenu::PortMenu(const std::string& consoleVariable, const std::string& name) : Menu(consoleVariable, name, 0, UIWidgets::Colors::LightBlue) { } -// bool CheckNetworkConnected(disabledInfo& info) { -// return gNetwork.isConnected; -// } - void PortMenu::InitElement() { Ship::Menu::InitElement(); AddSettings(); diff --git a/src/port/ui/TrackProperties.cpp b/src/port/ui/TrackProperties.cpp index 499b74b1b..02536fe5e 100644 --- a/src/port/ui/TrackProperties.cpp +++ b/src/port/ui/TrackProperties.cpp @@ -35,19 +35,19 @@ namespace Editor { static char debugNameBuffer[256] = "m circuit"; static char lengthBuffer[256] = "567m"; - if (nullptr == gWorldInstance.GetCurrentCourse()) { + if (nullptr == gWorldInstance.GetTrack()) { return; } ImGui::InputText("ID", idBuffer, IM_ARRAYSIZE(idBuffer)); - ImGui::InputText("Name", gWorldInstance.GetCurrentCourse()->Props.Name, IM_ARRAYSIZE(nameBuffer)); - ImGui::InputText("Debug Name", gWorldInstance.GetCurrentCourse()->Props.DebugName, IM_ARRAYSIZE(debugNameBuffer)); - ImGui::InputText("Course Length", gWorldInstance.GetCurrentCourse()->Props.CourseLength, IM_ARRAYSIZE(lengthBuffer)); - ImGui::InputFloat("Water Level", &gWorldInstance.GetCurrentCourse()->Props.WaterLevel); + ImGui::InputText("Name", gWorldInstance.GetTrack()->Props.Name, IM_ARRAYSIZE(nameBuffer)); + ImGui::InputText("Debug Name", gWorldInstance.GetTrack()->Props.DebugName, IM_ARRAYSIZE(debugNameBuffer)); + ImGui::InputText("Track Length", gWorldInstance.GetTrack()->Props.TrackLength, IM_ARRAYSIZE(lengthBuffer)); + ImGui::InputFloat("Water Level", &gWorldInstance.GetTrack()->Props.WaterLevel); if (ImGui::CollapsingHeader("Camera")) { - ImGui::InputFloat("Near Perspective", &gWorldInstance.GetCurrentCourse()->Props.NearPersp); - ImGui::InputFloat("Far Perspective", &gWorldInstance.GetCurrentCourse()->Props.FarPersp); + ImGui::InputFloat("Near Perspective", &gWorldInstance.GetTrack()->Props.NearPersp); + ImGui::InputFloat("Far Perspective", &gWorldInstance.GetTrack()->Props.FarPersp); if (ImGui::IsItemHovered()) { ImGui::BeginTooltip(); ImGui::Text("Controls the far clipping distance for perspective rendering."); @@ -62,92 +62,92 @@ namespace Editor { if (ImGui::CollapsingHeader("AI")) { - ImGui::InputFloat("AI Max Separation", &gWorldInstance.GetCurrentCourse()->Props.AIMaximumSeparation); - ImGui::InputFloat("AI Min Separation", &gWorldInstance.GetCurrentCourse()->Props.AIMinimumSeparation); - ImGui::InputInt("AI Steering Sensitivity", (int*)&gWorldInstance.GetCurrentCourse()->Props.AISteeringSensitivity); + ImGui::InputFloat("AI Max Separation", &gWorldInstance.GetTrack()->Props.AIMaximumSeparation); + ImGui::InputFloat("AI Min Separation", &gWorldInstance.GetTrack()->Props.AIMinimumSeparation); + ImGui::InputInt("AI Steering Sensitivity", (int*)&gWorldInstance.GetTrack()->Props.AISteeringSensitivity); ImGui::Separator(); for (size_t i = 0; i < 32; i++) { - ImGui::InputScalar(("Element " + std::to_string(i)).c_str(), ImGuiDataType_S16, &gWorldInstance.GetCurrentCourse()->Props.AIDistance[i]); + ImGui::InputScalar(("Element " + std::to_string(i)).c_str(), ImGuiDataType_S16, &gWorldInstance.GetTrack()->Props.AIDistance[i]); } } if (ImGui::CollapsingHeader("Random Junk")) { for (size_t i = 0; i < 4; i++) { - ImGui::InputFloat(fmt::format("CurveTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetCurrentCourse()->Props.CurveTargetSpeed[i]); + ImGui::InputFloat(fmt::format("CurveTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.CurveTargetSpeed[i]); } ImGui::Separator(); for (size_t i = 0; i < 4; i++) { - ImGui::InputFloat(fmt::format("NormalTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetCurrentCourse()->Props.NormalTargetSpeed[i]); + ImGui::InputFloat(fmt::format("NormalTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.NormalTargetSpeed[i]); } ImGui::Separator(); for (size_t i = 0; i < 4; i++) { - ImGui::InputFloat(fmt::format("D_0D0096B8[{}]", i).c_str(), &gWorldInstance.GetCurrentCourse()->Props.D_0D0096B8[i]); + ImGui::InputFloat(fmt::format("D_0D0096B8[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.D_0D0096B8[i]); } ImGui::Separator(); for (size_t i = 0; i < 4; i++) { - ImGui::InputFloat(fmt::format("OffTrackTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetCurrentCourse()->Props.OffTrackTargetSpeed[i]); + ImGui::InputFloat(fmt::format("OffTrackTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.OffTrackTargetSpeed[i]); } } float minimapColour[3]; - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Minimap.Colour, minimapColour); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Minimap.Colour, minimapColour); if (ImGui::CollapsingHeader("Minimap")) { ImGui::Text("Position"); ImGui::SameLine(); - if (ImGui::DragInt2("##MinimapPosition", &gWorldInstance.GetCurrentCourse()->Props.Minimap.Pos[0].X, 1.0f)) { + if (ImGui::DragInt2("##MinimapPosition", &gWorldInstance.GetTrack()->Props.Minimap.Pos[0].X, 1.0f)) { } ImGui::Text("P2 Position"); ImGui::SameLine(); - if (ImGui::DragInt2("##MinimapPosition2p", &gWorldInstance.GetCurrentCourse()->Props.Minimap.Pos[1].X, 1.0f)) { + if (ImGui::DragInt2("##MinimapPosition2p", &gWorldInstance.GetTrack()->Props.Minimap.Pos[1].X, 1.0f)) { } ImGui::Text("Player Markers"); ImGui::SameLine(); - if (ImGui::DragInt2("##MinimapPlayers", &gWorldInstance.GetCurrentCourse()->Props.Minimap.PlayerX, 1.0f)) { + if (ImGui::DragInt2("##MinimapPlayers", &gWorldInstance.GetTrack()->Props.Minimap.PlayerX, 1.0f)) { } ImGui::Text("Player Scale Factor"); ImGui::SameLine(); - if (ImGui::DragFloat("##MinimapScaleFactor", &gWorldInstance.GetCurrentCourse()->Props.Minimap.PlayerScaleFactor, 0.0001f)) { + if (ImGui::DragFloat("##MinimapScaleFactor", &gWorldInstance.GetTrack()->Props.Minimap.PlayerScaleFactor, 0.0001f)) { } ImGui::Text("Finishline"); ImGui::SameLine(); - ImGui::DragFloat2("##MinimapFinishlineX", &gWorldInstance.GetCurrentCourse()->Props.Minimap.FinishlineX, 1.0f); + ImGui::DragFloat2("##MinimapFinishlineX", &gWorldInstance.GetTrack()->Props.Minimap.FinishlineX, 1.0f); ImGui::Text("Colour"); ImGui::SameLine(); ImGui::ColorEdit3("##MinimapColour", minimapColour, 1.0f); } - FloatToRGB8(minimapColour, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Minimap.Colour); + FloatToRGB8(minimapColour, (u8*)&gWorldInstance.GetTrack()->Props.Minimap.Colour); // Convert and pass to ImGui ColorEdit3 float topRight[3], bottomRight[3], bottomLeft[3], topLeft[3]; float floorTopRight[3], floorBottomRight[3], floorBottomLeft[3], floorTopLeft[3]; // Convert RGB8 (0-255) to float (0.0f to 1.0f) - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.TopRight, topRight); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.BottomRight, bottomRight); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.BottomLeft, bottomLeft); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.TopLeft, topLeft); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorTopRight, floorTopRight); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorBottomRight, floorBottomRight); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorBottomLeft, floorBottomLeft); - RGB8ToFloat((u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorTopLeft, floorTopLeft); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.TopRight, topRight); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.BottomRight, bottomRight); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.BottomLeft, bottomLeft); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.TopLeft, topLeft); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorTopRight, floorTopRight); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorBottomRight, floorBottomRight); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorBottomLeft, floorBottomLeft); + RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorTopLeft, floorTopLeft); if (ImGui::CollapsingHeader("Skybox")) { ImGui::ColorEdit3("Skybox Top Right", topRight); @@ -161,14 +161,14 @@ namespace Editor { } // Convert the modified float values back to RGB8 (0-255) - FloatToRGB8(topRight, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.TopRight); - FloatToRGB8(bottomRight, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.BottomRight); - FloatToRGB8(bottomLeft, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.BottomLeft); - FloatToRGB8(topLeft, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.TopLeft); - FloatToRGB8(floorTopRight, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorTopRight); - FloatToRGB8(floorBottomRight, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorBottomRight); - FloatToRGB8(floorBottomLeft, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorBottomLeft); - FloatToRGB8(floorTopLeft, (u8*)&gWorldInstance.GetCurrentCourse()->Props.Skybox.FloorTopLeft); + FloatToRGB8(topRight, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.TopRight); + FloatToRGB8(bottomRight, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.BottomRight); + FloatToRGB8(bottomLeft, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.BottomLeft); + FloatToRGB8(topLeft, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.TopLeft); + FloatToRGB8(floorTopRight, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorTopRight); + FloatToRGB8(floorBottomRight, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorBottomRight); + FloatToRGB8(floorBottomLeft, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorBottomLeft); + FloatToRGB8(floorTopLeft, (u8*)&gWorldInstance.GetTrack()->Props.Skybox.FloorTopLeft); TrackPropertiesWindow::DrawMusic(); TrackPropertiesWindow::DrawTourCamera(); @@ -185,15 +185,15 @@ namespace Editor { "Royal Raceway", "Yoshi Valley", "Block Fort", "Double Deck" }; - const char* currentItem = MusicSeqToString(gWorldInstance.GetCurrentCourse()->Props.Sequence); // Get the current selected value's string + const char* currentItem = MusicSeqToString(gWorldInstance.GetTrack()->Props.Sequence); // Get the current selected value's string if (ImGui::BeginCombo("Music Sequence", currentItem)) { for (size_t i = 0; i < IM_ARRAYSIZE(items); ++i) { bool isSelected = (currentItem == items[i]); if (ImGui::Selectable(items[i], isSelected)) { // Update the sequence when an option is selected - gWorldInstance.GetCurrentCourse()->Props.Sequence = static_cast<MusicSeq>(i); - play_sequence(gWorldInstance.GetCurrentCourse()->Props.Sequence); // Call play_sequence with the updated sequence + gWorldInstance.GetTrack()->Props.Sequence = static_cast<MusicSeq>(i); + play_sequence(gWorldInstance.GetTrack()->Props.Sequence); // Call play_sequence with the updated sequence // Update currentItem after selection is made currentItem = items[i]; @@ -299,12 +299,12 @@ namespace Editor { void TrackPropertiesWindow::DrawTourCamera() { - std::shared_ptr<Course> track = gWorldInstance.GetCurrentCourse(); + std::shared_ptr<Track> track = gWorldInstance.GetTrack(); if (nullptr == track) { return; } - Camera* camera = D_800DC5EC->camera; + Camera* camera = gScreenOneCtx->camera; if (nullptr == camera) { return; } |
