Track Id is now std::string and outside of Props
This commit is contained in:
parent
308cf1c23d
commit
5a689ada2f
|
|
@ -1,7 +1,7 @@
|
|||
#include "Cup.h"
|
||||
#include "courses/Course.h"
|
||||
|
||||
Cup::Cup(const char* id, const char* name, std::vector<Course*> courses) {
|
||||
Cup::Cup(std::string id, const char* name, std::vector<Course*> courses) {
|
||||
Id = id;
|
||||
Name = name;
|
||||
Courses = courses;
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ class Course; // <-- Forward declare
|
|||
|
||||
class Cup {
|
||||
public:
|
||||
const char* Id;
|
||||
std::string Id;
|
||||
const char* Name;
|
||||
u8 *Thumbnail;
|
||||
size_t CursorPosition = 0; // Course index in cup
|
||||
std::vector<Course*> Courses;
|
||||
|
||||
explicit Cup(const char* id, const char* name, std::vector<Course*> courses);
|
||||
explicit Cup(std::string id, const char* name, std::vector<Course*> courses);
|
||||
|
||||
virtual void ShuffleCourses();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
// #include <vector>
|
||||
// #include <functional>
|
||||
// #include <iostream>
|
||||
// #include <map>
|
||||
|
||||
// #include "Registry.h"
|
||||
// #include "Course.h"
|
||||
// #include "port/Game.h"
|
||||
|
||||
// template <class T> Registry<T>::Registry() {
|
||||
// }
|
||||
|
||||
// template <class T> void Registry<T>::Add(std::string id, std::function<T*()> fn) {
|
||||
// // need to handle duplicate registration
|
||||
// ContentVault[id] = fn;
|
||||
// }
|
||||
|
||||
// template <class T>
|
||||
// void Registry<T>::AddArgs(std::string id) {
|
||||
// ArgsVault[id] = [](Args&&... args) -> T* {
|
||||
// return new T(std::forward<Args>(args)...);
|
||||
// };
|
||||
// }
|
||||
|
||||
// template <class T>
|
||||
// T* Registry<T>::Get(std::string id) {
|
||||
// auto it = ContentVault.find(id);
|
||||
// if (it != ContentVault.end()) {
|
||||
// return it->second();
|
||||
// }
|
||||
// return nullptr;
|
||||
// }
|
||||
|
||||
// // Available Registries
|
||||
// Registry<Course> Courses;
|
||||
// Registry<Cup> Cups;
|
||||
// Registry<AActor> Actors;
|
||||
|
||||
// void AddCourse(std::string id, Course* course) {
|
||||
// Courses.Add(id, [course]() { return course; });
|
||||
// course->Id = id;
|
||||
// }
|
||||
|
||||
// void AddCup(std::string id, Cup* cup) {
|
||||
// Cups.Add(id, [cup]() { return cup; });
|
||||
// //cup->Id = id;
|
||||
// }
|
||||
|
||||
// void AddActor(std::string id, AActor* actor) {
|
||||
// Actors.Add(id, [actor]() { return actor; });
|
||||
// }
|
||||
|
||||
// void AddStockContent() {
|
||||
// AddActor("mk:banana", new AMarioSign({0, 0, 0}));
|
||||
// }
|
||||
|
||||
// template class Registry<Course>;
|
||||
// template class Registry<Cup>;
|
||||
// template class Registry<AActor>;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// #pragma once
|
||||
|
||||
// #include "Course.h"
|
||||
// #include "Cup.h"
|
||||
// #include <unordered_map>
|
||||
// #include "AllActors.h"
|
||||
// #include "Actor.h"
|
||||
// #include "objects/Object.h"
|
||||
|
||||
// class AActor; // <-- Forward delare
|
||||
|
||||
// template <class T> class Registry {
|
||||
// public:
|
||||
// Registry();
|
||||
// void Add(std::string name, std::function<T*()>);
|
||||
|
||||
// template <typename... Args>
|
||||
// void AddArgs(std::string id);
|
||||
// T* Get(std::string id);
|
||||
// private:
|
||||
// std::unordered_map<std::string, std::function<T*()>> ContentVault;
|
||||
// std::map<std::string, std::function<T*(Args&&...)>> ArgsVault;
|
||||
// };
|
||||
|
||||
// void AddCourse(std::string id, Course* course);
|
||||
// void AddCup(std::string id, Cup* cup);
|
||||
// void AddActor(std::string id, AActor* actor);
|
||||
|
||||
// void AddStockContent();
|
||||
|
||||
// extern Registry<Course> Courses;
|
||||
// extern Registry<Cup> Cups;
|
||||
// extern Registry<AActor> Actors;
|
||||
|
|
@ -81,7 +81,7 @@ BansheeBoardwalk::BansheeBoardwalk() {
|
|||
Props.Minimap.FinishlineX = 0;
|
||||
Props.Minimap.FinishlineY = 0;
|
||||
|
||||
Props.Id = "mk:banshee_boardwalk";
|
||||
Id = "mk:banshee_boardwalk";
|
||||
|
||||
Props.SetText(Props.Name, "banshee boardwalk", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "ghost", sizeof(Props.DebugName));
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ BowsersCastle::BowsersCastle() {
|
|||
Props.Minimap.FinishlineX = 0;
|
||||
Props.Minimap.FinishlineY = 0;
|
||||
|
||||
Props.Id = "mk:bowsers_castle";
|
||||
Id = "mk:bowsers_castle";
|
||||
|
||||
Props.SetText(Props.Name, "bowser's castle", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "castle", sizeof(Props.DebugName));
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ ChocoMountain::ChocoMountain() {
|
|||
Props.Minimap.FinishlineX = 0;
|
||||
Props.Minimap.FinishlineY = -16.0;
|
||||
|
||||
Props.Id = "mk:choco_mountain";
|
||||
Id = "mk:choco_mountain";
|
||||
Props.SetText(Props.Name, "choco mountain", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "mountain", sizeof(Props.DebugName));
|
||||
Props.SetText(Props.CourseLength, "687m", sizeof(Props.CourseLength));
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ Course::Course() {
|
|||
Props.SetText(Props.CourseLength, "100m", sizeof(Props.CourseLength));
|
||||
// Props.Cup = FLOWER_CUP;
|
||||
// Props.CupIndex = 3;
|
||||
Props.Id = "";
|
||||
Id = "";
|
||||
Props.Minimap.Texture = gTextureCourseOutlineMarioRaceway;
|
||||
Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture);
|
||||
Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ typedef struct MinimapProps {
|
|||
} MinimapProps;
|
||||
|
||||
typedef struct Properties {
|
||||
const char* Id;
|
||||
char Name[128];
|
||||
char DebugName[128];
|
||||
char CourseLength[128];
|
||||
|
|
@ -245,6 +244,7 @@ class World; // <-- Forward declare
|
|||
class Course {
|
||||
|
||||
public:
|
||||
std::string Id;
|
||||
Properties Props;
|
||||
|
||||
// This allows multiple water levels in a map.
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ Harbour::Harbour() {
|
|||
Props.Minimap.PlayerY = 28;
|
||||
Props.Minimap.PlayerScaleFactor = 0.022f;
|
||||
|
||||
Props.Id = "mk:harbour";
|
||||
Id = "mk:harbour";
|
||||
Props.SetText(Props.Name, "Harbour", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "harbour", sizeof(Props.DebugName));
|
||||
Props.SetText(Props.CourseLength, "99m", sizeof(Props.CourseLength));
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ KoopaTroopaBeach::KoopaTroopaBeach() {
|
|||
Props.Minimap.FinishlineX = 0;
|
||||
Props.Minimap.FinishlineY = 0;
|
||||
|
||||
Props.Id = "mk:koopa_beach";
|
||||
Id = "mk:koopa_beach";
|
||||
Props.SetText(Props.Name, "koopa troopa beach", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "beach", sizeof(Props.DebugName));
|
||||
Props.SetText(Props.CourseLength, "691m", sizeof(Props.CourseLength));
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ LuigiRaceway::LuigiRaceway() {
|
|||
Props.Minimap.FinishlineX = 0;
|
||||
Props.Minimap.FinishlineY = 0;
|
||||
|
||||
Props.Id = "mk:luigi_raceway";
|
||||
Id = "mk:luigi_raceway";
|
||||
Props.SetText(Props.Name, "luigi raceway", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "l circuit", sizeof(Props.DebugName));
|
||||
Props.SetText(Props.CourseLength, "717m", sizeof(Props.CourseLength));
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ MarioRaceway::MarioRaceway() {
|
|||
Props.Minimap.FinishlineX = 0;
|
||||
Props.Minimap.FinishlineY = -2.0;
|
||||
|
||||
Props.Id = "mk:mario_raceway";
|
||||
Id = "mk:mario_raceway";
|
||||
Props.SetText(Props.Name, "mario raceway", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "m circuit", sizeof(Props.DebugName));
|
||||
Props.SetText(Props.CourseLength, "567m", sizeof(Props.CourseLength));
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ TestCourse::TestCourse() {
|
|||
Props.Minimap.FinishlineY = 0;
|
||||
Props.Minimap.Colour = {255, 255, 255};
|
||||
|
||||
Props.Id = "mk:test_course";
|
||||
Id = "mk:test_course";
|
||||
|
||||
Props.SetText(Props.Name, "Test Course", sizeof(Props.Name));
|
||||
Props.SetText(Props.DebugName, "test track", sizeof(Props.DebugName));
|
||||
|
|
|
|||
|
|
@ -87,7 +87,12 @@ namespace Editor {
|
|||
// Load the Props (deserialize it)
|
||||
if (data.contains("Props")) {
|
||||
auto& propsJson = data["Props"];
|
||||
course->Props.from_json(propsJson); // Assuming you have a `from_json` function
|
||||
try {
|
||||
course->Props.from_json(propsJson);
|
||||
} catch(const std::exception& e) {
|
||||
std::cerr << "SceneManager::LoadLevel() Error parsing track properties: " << e.what() << std::endl;
|
||||
std::cerr << " Is your scene.json file out of date?" << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Props data not found in the JSON file!" << std::endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ namespace Editor {
|
|||
if (manager->HasFile(file)) {
|
||||
|
||||
Course* course = new Course();
|
||||
course->Props.Id = (std::string("mods:") + name).c_str();
|
||||
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));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue