Import courses working now

This commit is contained in:
MegaMech
2025-04-21 13:17:14 -06:00
parent 9055c9c7ee
commit 12c3f2b7e3
6 changed files with 87 additions and 70 deletions
+5 -1
View File
@@ -29,9 +29,13 @@ extern StaffGhost* d_mario_raceway_staff_ghost;
Course::Course() {
// Props.Name = "Course Name";
// Props.DebugName = "CName";
// Props.CourseLength = "567m";
Props.SetText(Props.CourseLength, "100m", sizeof(Props.CourseLength));
// Props.Cup = FLOWER_CUP;
// Props.CupIndex = 3;
Props.Id = "";
Props.MinimapTexture = gTextureCourseOutlineMarioRaceway;
Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture));
Props.LakituTowType = (s32) OLakitu::LakituTowType::NORMAL;
Props.AIBehaviour = D_0D008F28;
Props.AIMaximumSeparation = 50.0f;
+3
View File
@@ -122,6 +122,8 @@ typedef struct Properties {
// j["Skybox"] = Skybox; // Implement your serialization logic here
j["Sequence"] = static_cast<int>(Sequence);
j["WaterLevel"] = static_cast<float>(WaterLevel);
return j;
}
@@ -194,6 +196,7 @@ typedef struct Properties {
MinimapFinishlineY = j.at("MinimapFinishlineY").get<float>();
//textures = nullptr; // Deserialize textures if present
Sequence = static_cast<MusicSeq>(j.at("Sequence").get<int>());
WaterLevel = static_cast<float>(j.at("WaterLevel").get<float>());
}
void SetText(char* name, const char* title, size_t bufferSize) {
// Copy the title into the name buffer, ensuring it's null-terminated and within bounds
+7 -10
View File
@@ -46,17 +46,14 @@ namespace Editor {
}
}
void LoadLevel(std::string sceneFile) {
printf("LOAD TRACK PROPS %s\n", sceneFile.c_str());
void LoadLevel(std::shared_ptr<Ship::Archive> archive, Course* course, std::string sceneFile) {
nlohmann::json data;
CurrentArchive = GameEngine::Instance->context->GetResourceManager()->GetArchiveManager()->GetArchiveFromFile(sceneFile);
SceneFile = sceneFile;
if (CurrentArchive) {
if (archive) {
auto initData = std::make_shared<Ship::ResourceInitData>();
initData->Parent = CurrentArchive;
initData->Parent = archive;
initData->Format = RESOURCE_FORMAT_BINARY;
initData->ByteOrder = Ship::Endianness::Little;
initData->Type = static_cast<uint32_t>(Ship::ResourceType::Json);
@@ -72,7 +69,7 @@ namespace Editor {
// Load the Props (deserialize it)
if (data.contains("Props")) {
auto& propsJson = data["Props"];
gWorldInstance.CurrentCourse->Props.from_json(propsJson); // Assuming you have a `from_json` function
course->Props.from_json(propsJson); // Assuming you have a `from_json` function
} else {
std::cerr << "Props data not found in the JSON file!" << std::endl;
}
@@ -102,8 +99,8 @@ namespace Editor {
GameObject::CollisionType::BOUNDING_BOX, 20.0f, (int32_t*) &actor->bPendingDestroy, (int32_t) 1);
}
void SetSceneFile(std::string archive, std::string sceneFile) {
CurrentArchive = GameEngine::Instance->context->GetResourceManager()->GetArchiveManager()->GetArchiveFromFile(archive);
SceneFile = sceneFile+"/scene.json";
void SetSceneFile(std::shared_ptr<Ship::Archive> archive, std::string sceneFile) {
CurrentArchive = archive;
SceneFile = sceneFile;
}
}
+3 -3
View File
@@ -1,11 +1,11 @@
#include <libultraship/libultraship.h>
#include "Course.h"
#include "engine/courses/Course.h"
namespace Editor {
void SaveLevel();
void LoadLevel(std::string sceneFile);
void LoadLevel(std::shared_ptr<Ship::Archive> archive, Course* course, std::string sceneFile);
void Load_AddStaticMeshActor(const nlohmann::json& actorJson);
void SetSceneFile(std::string archive, std::string sceneFile);
void SetSceneFile(std::shared_ptr<Ship::Archive> archive, std::string sceneFile);
extern std::shared_ptr<Ship::Archive> CurrentArchive; // This is used to retrieve and write the scene data file
extern std::string SceneFile;