Edit TrackInfo Properties (#594)
* Fix finishline for toads turnpike in extra * Fixed trash bin in extra * Refactor fov * Update scene.json * Allow setting fog * impl fog save & load * Fix modifying resourceName and rename editor namespace to trackeditor * small change
This commit is contained in:
parent
2995361eb1
commit
eb11374093
|
|
@ -25,7 +25,7 @@ void AActor::BeginPlay() {
|
||||||
if ((nullptr != Model) && (Model[0] != '\0')) {
|
if ((nullptr != Model) && (Model[0] != '\0')) {
|
||||||
// Prevent collision mesh from being generated extra times.
|
// Prevent collision mesh from being generated extra times.
|
||||||
if (Triangles.size() == 0) {
|
if (Triangles.size() == 0) {
|
||||||
Editor::GenerateCollisionMesh(this, (Gfx*)LOAD_ASSET_RAW(Model), 1.0f);
|
TrackEditor::GenerateCollisionMesh(this, (Gfx*)LOAD_ASSET_RAW(Model), 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -495,7 +495,7 @@ void RegisterTracks(Registry<TrackInfo>& r) {
|
||||||
r.Add(info, []() { GetWorld()->SetCurrentTrack(std::make_unique<BigDonut>()); });
|
r.Add(info, []() { GetWorld()->SetCurrentTrack(std::make_unique<BigDonut>()); });
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
.ResourceName = "mk:test_track",
|
.ResourceName = "hm:test_track",
|
||||||
.Name = "test track",
|
.Name = "test track",
|
||||||
.DebugName = "test track",
|
.DebugName = "test track",
|
||||||
.Length = "100m",
|
.Length = "100m",
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,17 @@ public:
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if item succesfully removed
|
||||||
|
// Note that mCounter is not decremented on remove
|
||||||
|
bool Remove(const std::string& resourceName) {
|
||||||
|
auto it = mMap.find(resourceName);
|
||||||
|
if (it != mMap.end()) {
|
||||||
|
mMap.erase(it);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
mMap.clear();
|
mMap.clear();
|
||||||
mCounter = 0;
|
mCounter = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "TrackBrowser.h"
|
#include "TrackBrowser.h"
|
||||||
#include "port/Engine.h"
|
#include "port/Engine.h"
|
||||||
#include "engine/editor/SceneManager.h"
|
#include "engine/editor/SceneManager.h"
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
TrackBrowser* TrackBrowser::Instance;
|
TrackBrowser* TrackBrowser::Instance;
|
||||||
|
|
||||||
|
|
@ -8,65 +9,63 @@ void TrackBrowser::FindCustomTracks() {
|
||||||
auto manager = GameEngine::Instance->context->GetResourceManager()->GetArchiveManager();
|
auto manager = GameEngine::Instance->context->GetResourceManager()->GetArchiveManager();
|
||||||
|
|
||||||
auto ptr2 = manager->ListDirectories("tracks/*");
|
auto ptr2 = manager->ListDirectories("tracks/*");
|
||||||
if (ptr2) {
|
if (!ptr2) {
|
||||||
auto dirs = *ptr2;
|
return;
|
||||||
|
}
|
||||||
|
auto dirs = *ptr2;
|
||||||
|
|
||||||
for (const std::string& dir : dirs) {
|
for (const std::string& dir : dirs) {
|
||||||
std::string name = dir.substr(dir.find_last_of('/') + 1);
|
std::string name = dir.substr(dir.find_last_of('/') + 1);
|
||||||
std::string sceneFile = dir + "/scene.json";
|
std::string sceneFile = dir + "/scene.json";
|
||||||
std::string minimapFile = dir + "/minimap.png";
|
std::string minimapFile = dir + "/minimap.png";
|
||||||
|
|
||||||
// The track has a valid scene file, add it to the registry
|
// The track has a valid scene file, add it to the registry
|
||||||
if (manager->HasFile(sceneFile)) {
|
if (manager->HasFile(sceneFile)) {
|
||||||
auto archive = manager->GetArchiveFromFile(sceneFile);
|
auto archive = manager->GetArchiveFromFile(sceneFile);
|
||||||
|
|
||||||
|
TrackInfo info;
|
||||||
|
info.Path = dir;
|
||||||
|
TrackEditor::LoadTrackInfo(info, archive, sceneFile);
|
||||||
|
printf("[TrackBrowser] Added custom track %s\n", info.Name.c_str());
|
||||||
|
gTrackRegistry.Add(info, [info, archive]() {
|
||||||
|
auto track = std::make_unique<Track>();
|
||||||
|
track->ResourceName = info.ResourceName;
|
||||||
|
track->Archive = archive;
|
||||||
|
GetWorld()->SetCurrentTrack(std::move(track));
|
||||||
|
});
|
||||||
|
} else { // The track does not have a valid scene file
|
||||||
|
const std::string file = dir + "/data_track_sections";
|
||||||
|
// If the track has a data_track_sections file,
|
||||||
|
// then it must at least be a valid track.
|
||||||
|
// So lets add it as an uninitialized track.
|
||||||
|
if (manager->HasFile(file)) {
|
||||||
|
printf("[TrackBrowser] [FindCustomTracks] Found a new custom track!\n");
|
||||||
|
printf(" Creating scene.json so the track can be configured in the editor\n");
|
||||||
|
|
||||||
TrackInfo info;
|
TrackInfo info;
|
||||||
|
std::string resName = std::string("mods:") + name;
|
||||||
|
info.ResourceName = resName;
|
||||||
|
info.Name = name;
|
||||||
|
info.DebugName = name;
|
||||||
info.Path = dir;
|
info.Path = dir;
|
||||||
Editor::LoadTrackInfo(info, archive, sceneFile);
|
|
||||||
printf("Added custom track %s\n", info.Name.c_str());
|
// Create the track
|
||||||
|
auto archive = manager->GetArchiveFromFile(file);
|
||||||
|
auto track = std::make_unique<Track>();
|
||||||
|
track->Archive = archive;
|
||||||
|
track->ResourceName = info.ResourceName;
|
||||||
|
TrackEditor::SaveLevel(track.get(), static_cast<const TrackInfo*>(&info)); // Write scene file so it will show up in the track browser
|
||||||
|
printf("[TrackBrowser] [FindCustomTracks] Saved scene.json to new track!\n");
|
||||||
|
|
||||||
|
// Passing these through seems kinda bad. But it works?
|
||||||
gTrackRegistry.Add(info, [info, archive]() {
|
gTrackRegistry.Add(info, [info, archive]() {
|
||||||
auto track = std::make_unique<Track>();
|
auto track = std::make_unique<Track>();
|
||||||
track->ResourceName = info.ResourceName;
|
|
||||||
track->Archive = archive;
|
track->Archive = archive;
|
||||||
|
track->ResourceName = info.ResourceName;
|
||||||
GetWorld()->SetCurrentTrack(std::move(track));
|
GetWorld()->SetCurrentTrack(std::move(track));
|
||||||
});
|
});
|
||||||
} else { // The track does not have a valid scene file
|
} else {
|
||||||
const std::string file = dir + "/data_track_sections";
|
printf("[TrackBrowser] Track '%s' missing required track files. Cannot add to game\n Missing %s/data_track_sections file\n", name.c_str(), dir.c_str());
|
||||||
|
|
||||||
// If the track has a data_track_sections file,
|
|
||||||
// then it must at least be a valid track.
|
|
||||||
// So lets add it as an uninitialized track.
|
|
||||||
if (manager->HasFile(file)) {
|
|
||||||
printf("[TrackBrowser] [FindCustomTracks] Found a new custom track!\n");
|
|
||||||
printf(" Creating scene.json so the track can be configured in the editor\n");
|
|
||||||
|
|
||||||
TrackInfo info;
|
|
||||||
|
|
||||||
std::string resName = std::string("mods:") + name;
|
|
||||||
info.ResourceName = resName;
|
|
||||||
info.Name = name;
|
|
||||||
info.DebugName = name;
|
|
||||||
info.Path = dir;
|
|
||||||
|
|
||||||
auto archive = manager->GetArchiveFromFile(file);
|
|
||||||
//mNewTracks.push_back({info, "", dir, archive});
|
|
||||||
auto track = std::make_unique<Track>();
|
|
||||||
track->Archive = archive;
|
|
||||||
track->ResourceName = info.ResourceName;
|
|
||||||
Editor::SaveLevel(track.get(), &info); // Write scene file so it will show up in the track browser
|
|
||||||
printf("[TrackBrowser] [FindCustomTracks] Saved scene.json to new track!\n");
|
|
||||||
|
|
||||||
// Passing these through seems kinda bad. But it works?
|
|
||||||
gTrackRegistry.Add(info, [info, archive]() {
|
|
||||||
auto track = std::make_unique<Track>();
|
|
||||||
track->Archive = archive;
|
|
||||||
track->ResourceName = info.ResourceName;
|
|
||||||
GetWorld()->SetCurrentTrack(std::move(track));
|
|
||||||
});
|
|
||||||
|
|
||||||
} 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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ void ACloud::BeginPlay() {
|
||||||
// Prevent collision mesh from being generated extra times.
|
// Prevent collision mesh from being generated extra times.
|
||||||
if (Editor_IsEnabled()) {
|
if (Editor_IsEnabled()) {
|
||||||
if (Triangles.size() == 0) {
|
if (Triangles.size() == 0) {
|
||||||
Editor::GenerateCollisionMesh(this, (Gfx*)cloud_mesh, 1.0f);
|
TrackEditor::GenerateCollisionMesh(this, (Gfx*) cloud_mesh, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void AFinishline::BeginPlay() {
|
||||||
// Prevent collision mesh from being generated extra times.
|
// Prevent collision mesh from being generated extra times.
|
||||||
if (Editor_IsEnabled()) {
|
if (Editor_IsEnabled()) {
|
||||||
if (Triangles.size() == 0) {
|
if (Triangles.size() == 0) {
|
||||||
Editor::GenerateCollisionMesh(this, (Gfx*)LOAD_ASSET_RAW(D_0D001B90), 1.0f);
|
TrackEditor::GenerateCollisionMesh(this, (Gfx*)LOAD_ASSET_RAW(D_0D001B90), 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ void AShip::BeginPlay() {
|
||||||
// Prevent collision mesh from being generated extra times.
|
// Prevent collision mesh from being generated extra times.
|
||||||
if (Editor_IsEnabled()) {
|
if (Editor_IsEnabled()) {
|
||||||
if (Triangles.size() == 0) {
|
if (Triangles.size() == 0) {
|
||||||
Editor::GenerateCollisionMesh(this, (Gfx*)_skin, Scale.y);
|
TrackEditor::GenerateCollisionMesh(this, (Gfx*) _skin, Scale.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ void AStarship::BeginPlay() {
|
||||||
// Prevent collision mesh from being generated extra times.
|
// Prevent collision mesh from being generated extra times.
|
||||||
if (Editor_IsEnabled()) {
|
if (Editor_IsEnabled()) {
|
||||||
if (Triangles.size() == 0) {
|
if (Triangles.size() == 0) {
|
||||||
Editor::GenerateCollisionMesh(this, (Gfx*)Model, 1.0f);
|
TrackEditor::GenerateCollisionMesh(this, (Gfx*)Model, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ extern "C" {
|
||||||
#include "assets/textures/other_textures.h"
|
#include "assets/textures/other_textures.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
void GenerateCollisionMesh(std::variant<AActor*, OObject*, GameObject*> object, Gfx* model, float scale) {
|
void GenerateCollisionMesh(std::variant<AActor*, OObject*, GameObject*> object, Gfx* model, float scale) {
|
||||||
int8_t opcode;
|
int8_t opcode;
|
||||||
uintptr_t lo;
|
uintptr_t lo;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#define EDITOR_GFX_GET_OPCODE(var) ((uint32_t) ((var) & 0xFF000000))
|
#define EDITOR_GFX_GET_OPCODE(var) ((uint32_t) ((var) & 0xFF000000))
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
void GenerateCollisionMesh(std::variant<AActor*, OObject*, GameObject*> object, Gfx* model, float scale);
|
void GenerateCollisionMesh(std::variant<AActor*, OObject*, GameObject*> object, Gfx* model, float scale);
|
||||||
void DebugCollision(GameObject* obj, FVector pos, IRotator rot, FVector scale, const std::vector<Triangle>& triangles);
|
void DebugCollision(GameObject* obj, FVector pos, IRotator rot, FVector scale, const std::vector<Triangle>& triangles);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ extern "C" {
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
Editor* Editor::Instance;
|
Editor* Editor::Instance;
|
||||||
|
|
||||||
Editor::Editor() {
|
Editor::Editor() {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "ObjectPicker.h"
|
#include "ObjectPicker.h"
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class ObjectPicker;
|
class ObjectPicker;
|
||||||
|
|
||||||
class Editor {
|
class Editor {
|
||||||
|
|
@ -54,7 +54,7 @@ private:
|
||||||
void Copy(MtxF* src, MtxF* dest);
|
void Copy(MtxF* src, MtxF* dest);
|
||||||
void Clear(MtxF* mf);
|
void Clear(MtxF* mf);
|
||||||
};
|
};
|
||||||
} // namespace Editor
|
} // namespace TrackEditor
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <libultraship/libultraship.h>
|
#include <libultraship/libultraship.h>
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
GameObject::GameObject(FVector pos, IRotator rot, FVector scale, const char* model, std::vector<Triangle> triangles, CollisionType collision, float boundingBoxSize) {
|
GameObject::GameObject(FVector pos, IRotator rot, FVector scale, const char* model, std::vector<Triangle> triangles, CollisionType collision, float boundingBoxSize) {
|
||||||
Pos = pos;
|
Pos = pos;
|
||||||
|
|
@ -38,4 +38,4 @@ namespace Editor {
|
||||||
Scale = scale;
|
Scale = scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Editor
|
} // namespace TrackEditor
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ extern "C" {
|
||||||
|
|
||||||
struct Triangle;
|
struct Triangle;
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class GameObject {
|
class GameObject {
|
||||||
public:
|
public:
|
||||||
enum class CollisionType {
|
enum class CollisionType {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ extern "C" {
|
||||||
#include "math_util.h"
|
#include "math_util.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
void Gizmo::Load() {
|
void Gizmo::Load() {
|
||||||
/* Translate handle collision */
|
/* Translate handle collision */
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "engine/objects/Object.h"
|
#include "engine/objects/Object.h"
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
class Gizmo {
|
class Gizmo {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "Handles.h"
|
#include "Handles.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
Handles::Handles() {
|
Handles::Handles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <libultra/gbi.h>
|
#include <libultra/gbi.h>
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class Handles : public GameObject {
|
class Handles : public GameObject {
|
||||||
|
|
||||||
Handles();
|
Handles();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ extern "C" {
|
||||||
#include "math_util_2.h"
|
#include "math_util_2.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
size_t LightObject::NumLights = 0;
|
size_t LightObject::NumLights = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "Collision.h"
|
#include "Collision.h"
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
class LightObject : public GameObject {
|
class LightObject : public GameObject {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ extern "C" {
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
void ObjectPicker::Load() {
|
void ObjectPicker::Load() {
|
||||||
eGizmo.Load();
|
eGizmo.Load();
|
||||||
|
|
@ -230,7 +230,7 @@ std::pair<GameObject*, float> ObjectPicker::CheckEditorObjectRay(Ray ray) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GameObject::CollisionType::BOUNDING_SPHERE:
|
case GameObject::CollisionType::BOUNDING_SPHERE:
|
||||||
printf("Editor::ObjectPicker.cpp Bounding sphere collision type not yet supported\n");
|
printf("[ObjectPicker] [CheckEditorObjectRay] Bounding sphere collision type not yet supported\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
#include "engine/Matrix.h"
|
#include "engine/Matrix.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class ObjectPicker {
|
class ObjectPicker {
|
||||||
public:
|
public:
|
||||||
void SelectObject(std::vector<GameObject*> objects);
|
void SelectObject(std::vector<GameObject*> objects);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
#include "render_courses.h"
|
#include "render_courses.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
void SaveLevel(Track* track, const TrackInfo* info) {
|
void SaveLevel(Track* track, const TrackInfo* info) {
|
||||||
nlohmann::json data;
|
nlohmann::json data;
|
||||||
|
|
||||||
|
|
@ -42,6 +42,7 @@ namespace Editor {
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
data["Props"] = track->Props.to_json();
|
data["Props"] = track->Props.to_json();
|
||||||
|
data["Props"]["ResourceName"] = track->ResourceName.c_str();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
SPDLOG_ERROR("[SceneManager] [SaveLevel] Failed serializing track Props");
|
SPDLOG_ERROR("[SceneManager] [SaveLevel] Failed serializing track Props");
|
||||||
}
|
}
|
||||||
|
|
@ -331,6 +332,7 @@ namespace Editor {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
track->Props.from_json(data["Props"]);
|
track->Props.from_json(data["Props"]);
|
||||||
|
track->ResourceName = data["Props"].at("ResourceName").get<std::string>();
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
std::cerr << " Error parsing track properties: " << e.what() << std::endl;
|
std::cerr << " Error parsing track properties: " << e.what() << std::endl;
|
||||||
std::cerr << " Is your scene.json file out of date?" << std::endl;
|
std::cerr << " Is your scene.json file out of date?" << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
void SaveLevel(Track* track, const TrackInfo* info);
|
void SaveLevel(Track* track, const TrackInfo* info);
|
||||||
void LoadTrackDataFromJson(Track* track, const std::string& trackPath);
|
void LoadTrackDataFromJson(Track* track, const std::string& trackPath);
|
||||||
void LoadTrackInfo(TrackInfo& info, std::shared_ptr<Ship::Archive> archive, std::string sceneFile);
|
void LoadTrackInfo(TrackInfo& info, std::shared_ptr<Ship::Archive> archive, std::string sceneFile);
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ TestTrack::TestTrack() {
|
||||||
Props.Minimap.Colour = {255, 255, 255};
|
Props.Minimap.Colour = {255, 255, 255};
|
||||||
ResizeMinimap(&Props.Minimap);
|
ResizeMinimap(&Props.Minimap);
|
||||||
|
|
||||||
ResourceName = "mk:test_track";
|
ResourceName = "hm:test_track";
|
||||||
|
|
||||||
Props.SetText(Props.Name, "Test Track", sizeof(Props.Name));
|
Props.SetText(Props.Name, "Test Track", sizeof(Props.Name));
|
||||||
Props.SetText(Props.DebugName, "test track", sizeof(Props.DebugName));
|
Props.SetText(Props.DebugName, "test track", sizeof(Props.DebugName));
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,6 @@ bool IsTriangleWindingInverted() {
|
||||||
return !gModifiedGfxSet.empty();
|
return !gModifiedGfxSet.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Track::Track() {
|
Track::Track() {
|
||||||
Props.SetText(Props.ResourceName, "mod:blank_track", sizeof(Props.ResourceName));
|
Props.SetText(Props.ResourceName, "mod:blank_track", sizeof(Props.ResourceName));
|
||||||
Props.SetText(Props.Name, "Blank Track", sizeof(Props.Name));
|
Props.SetText(Props.Name, "Blank Track", sizeof(Props.Name));
|
||||||
|
|
@ -358,7 +357,7 @@ Track::Track() {
|
||||||
Props.SetText(Props.TrackLength, "100m", sizeof(Props.TrackLength));
|
Props.SetText(Props.TrackLength, "100m", sizeof(Props.TrackLength));
|
||||||
// Props.Cup = FLOWER_CUP;
|
// Props.Cup = FLOWER_CUP;
|
||||||
// Props.CupIndex = 3;
|
// Props.CupIndex = 3;
|
||||||
ResourceName = "";
|
ResourceName = "mod:blank_track";
|
||||||
Props.Minimap.Texture = minimap_mario_raceway;
|
Props.Minimap.Texture = minimap_mario_raceway;
|
||||||
Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture);
|
Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture);
|
||||||
Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture);
|
Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture);
|
||||||
|
|
@ -450,7 +449,7 @@ void Track::Load() {
|
||||||
} else { // Load custom track
|
} else { // Load custom track
|
||||||
bIsMod = true;
|
bIsMod = true;
|
||||||
|
|
||||||
Editor::LoadTrackDataFromJson(this, trackPath);
|
TrackEditor::LoadTrackDataFromJson(this, trackPath);
|
||||||
|
|
||||||
const std::string trackSectionPath = (trackPath + "/data_track_sections");
|
const std::string trackSectionPath = (trackPath + "/data_track_sections");
|
||||||
TrackSections* sections = (TrackSections*) LOAD_ASSET_RAW(trackSectionPath.c_str());
|
TrackSections* sections = (TrackSections*) LOAD_ASSET_RAW(trackSectionPath.c_str());
|
||||||
|
|
@ -647,6 +646,10 @@ void Track::Draw(ScreenContext* arg0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const TrackInfo* info = gTrackRegistry.GetInfo(ResourceName);
|
const TrackInfo* info = gTrackRegistry.GetInfo(ResourceName);
|
||||||
|
if (nullptr == info) {
|
||||||
|
printf("[Track] [Draw] Resource name did not return a valid TrackInfo %s\n", ResourceName.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::string res = info->Path + "/data_track_sections";
|
std::string res = info->Path + "/data_track_sections";
|
||||||
|
|
||||||
TrackSections* sections = (TrackSections*) LOAD_ASSET_RAW(res.c_str());
|
TrackSections* sections = (TrackSections*) LOAD_ASSET_RAW(res.c_str());
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,6 @@ typedef struct {
|
||||||
} TrackSections;
|
} TrackSections;
|
||||||
|
|
||||||
typedef struct Properties {
|
typedef struct Properties {
|
||||||
char ResourceName[128];
|
|
||||||
char Name[128];
|
char Name[128];
|
||||||
char DebugName[128];
|
char DebugName[128];
|
||||||
char TrackLength[128];
|
char TrackLength[128];
|
||||||
|
|
@ -116,8 +115,6 @@ typedef struct Properties {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
nlohmann::json to_json() const {
|
nlohmann::json to_json() const {
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
// j["Id"] = Id ? Id : "";
|
|
||||||
j["ResourceName"] = ResourceName ? ResourceName : "";
|
|
||||||
j["Name"] = Name ? Name : "";
|
j["Name"] = Name ? Name : "";
|
||||||
j["DebugName"] = DebugName ? DebugName : "";
|
j["DebugName"] = DebugName ? DebugName : "";
|
||||||
j["TrackLength"] = TrackLength ? TrackLength : "";
|
j["TrackLength"] = TrackLength ? TrackLength : "";
|
||||||
|
|
@ -180,19 +177,12 @@ typedef struct Properties {
|
||||||
|
|
||||||
// Function to load struct from JSON
|
// Function to load struct from JSON
|
||||||
void from_json(const nlohmann::json& j) {
|
void from_json(const nlohmann::json& j) {
|
||||||
//Id = j.at("Id").get<std::string>().c_str();
|
|
||||||
// Name = j.at("Name").get<std::string>().c_str();
|
|
||||||
strncpy(ResourceName, j.at("ResourceName").get<std::string>().c_str(), sizeof(ResourceName) - 1);
|
|
||||||
ResourceName[sizeof(ResourceName) - 1] = '\0'; // Ensure null termination
|
|
||||||
|
|
||||||
strncpy(Name, j.at("Name").get<std::string>().c_str(), sizeof(Name) - 1);
|
strncpy(Name, j.at("Name").get<std::string>().c_str(), sizeof(Name) - 1);
|
||||||
Name[sizeof(Name) - 1] = '\0'; // Ensure null termination
|
Name[sizeof(Name) - 1] = '\0'; // Ensure null termination
|
||||||
|
|
||||||
// DebugName = j.at("DebugName").get<std::string>().c_str();
|
|
||||||
strncpy(DebugName, j.at("DebugName").get<std::string>().c_str(), sizeof(DebugName) - 1);
|
strncpy(DebugName, j.at("DebugName").get<std::string>().c_str(), sizeof(DebugName) - 1);
|
||||||
DebugName[sizeof(DebugName) - 1] = '\0'; // Ensure null termination
|
DebugName[sizeof(DebugName) - 1] = '\0'; // Ensure null termination
|
||||||
|
|
||||||
// TrackLength = j.at("TrackLength").get<std::string>().c_str();
|
|
||||||
strncpy(TrackLength, j.at("TrackLength").get<std::string>().c_str(), sizeof(TrackLength) - 1);
|
strncpy(TrackLength, j.at("TrackLength").get<std::string>().c_str(), sizeof(TrackLength) - 1);
|
||||||
TrackLength[sizeof(TrackLength) - 1] = '\0'; // Ensure null termination
|
TrackLength[sizeof(TrackLength) - 1] = '\0'; // Ensure null termination
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1177,7 +1177,7 @@ void splash_menu_act(struct Controller* controller, u16 controllerIdx) {
|
||||||
}
|
}
|
||||||
case DEBUG_MENU_LAUNCH_EDITOR: {
|
case DEBUG_MENU_LAUNCH_EDITOR: {
|
||||||
if (btnAndStick & (A_BUTTON | START_BUTTON)) {
|
if (btnAndStick & (A_BUTTON | START_BUTTON)) {
|
||||||
Editor_Launch("mk:test_track");
|
Editor_Launch("hm:test_track");
|
||||||
play_sound2(SOUND_INTRO_ENTER_MENU);
|
play_sound2(SOUND_INTRO_ENTER_MENU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ Cup* gBattleCup;
|
||||||
|
|
||||||
HarbourMastersIntro gMenuIntro;
|
HarbourMastersIntro gMenuIntro;
|
||||||
|
|
||||||
Editor::Editor gEditor;
|
TrackEditor::Editor gEditor;
|
||||||
|
|
||||||
s32 gTrophyIndex = NULL;
|
s32 gTrophyIndex = NULL;
|
||||||
|
|
||||||
|
|
@ -757,7 +757,7 @@ void CM_ActorGenerateCollision(struct Actor* actor) {
|
||||||
|
|
||||||
if ((nullptr != act->Model) && (act->Model[0] != '\0')) {
|
if ((nullptr != act->Model) && (act->Model[0] != '\0')) {
|
||||||
if (act->Triangles.size() == 0) {
|
if (act->Triangles.size() == 0) {
|
||||||
Editor::GenerateCollisionMesh(act, (Gfx*)LOAD_ASSET_RAW(act->Model), 1.0f);
|
TrackEditor::GenerateCollisionMesh(act, (Gfx*)LOAD_ASSET_RAW(act->Model), 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ extern "C" {
|
||||||
extern s32 gTrophyIndex;
|
extern s32 gTrophyIndex;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern Editor::Editor gEditor;
|
extern TrackEditor::Editor gEditor;
|
||||||
extern HarbourMastersIntro gMenuIntro;
|
extern HarbourMastersIntro gMenuIntro;
|
||||||
extern bool bCleanWorld;
|
extern bool bCleanWorld;
|
||||||
extern Registry<TrackInfo> gTrackRegistry;
|
extern Registry<TrackInfo> gTrackRegistry;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ extern "C" {
|
||||||
#include "collision.h"
|
#include "collision.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
bool bIsTrainWindowOpen = false; // Global because member variables do not work in lambdas
|
bool bIsTrainWindowOpen = false; // Global because member variables do not work in lambdas
|
||||||
|
|
||||||
ContentBrowserWindow::~ContentBrowserWindow() {
|
ContentBrowserWindow::~ContentBrowserWindow() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "engine/tracks/Track.h"
|
#include "engine/tracks/Track.h"
|
||||||
#include "AllActors.h"
|
#include "AllActors.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class ContentBrowserWindow : public Ship::GuiWindow {
|
class ContentBrowserWindow : public Ship::GuiWindow {
|
||||||
public:
|
public:
|
||||||
using Ship::GuiWindow::GuiWindow;
|
using Ship::GuiWindow::GuiWindow;
|
||||||
|
|
|
||||||
|
|
@ -69,21 +69,21 @@ void SetupGuiElements() {
|
||||||
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
|
SPDLOG_ERROR("Could not find input GfxDebuggerWindow");
|
||||||
}
|
}
|
||||||
|
|
||||||
mToolsWindow = std::make_shared<Editor::ToolsWindow>("gEditorEnabled", "Tools", ImVec2(100, 100),
|
mToolsWindow = std::make_shared<TrackEditor::ToolsWindow>("gEditorEnabled", "Tools", ImVec2(100, 100),
|
||||||
(ImGuiWindowFlags_NoTitleBar));
|
(ImGuiWindowFlags_NoTitleBar));
|
||||||
gui->AddGuiWindow(mToolsWindow);
|
gui->AddGuiWindow(mToolsWindow);
|
||||||
|
|
||||||
mSceneExplorerWindow = std::make_shared<Editor::SceneExplorerWindow>("gEditorEnabled", "Scene Explorer");
|
mSceneExplorerWindow = std::make_shared<TrackEditor::SceneExplorerWindow>("gEditorEnabled", "Scene Explorer");
|
||||||
gui->AddGuiWindow(mSceneExplorerWindow);
|
gui->AddGuiWindow(mSceneExplorerWindow);
|
||||||
|
|
||||||
mPropertiesWindow = std::make_shared<Editor::PropertiesWindow>("gEditorEnabled", "Properties");
|
mPropertiesWindow = std::make_shared<TrackEditor::PropertiesWindow>("gEditorEnabled", "Properties");
|
||||||
gui->AddGuiWindow(mPropertiesWindow);
|
gui->AddGuiWindow(mPropertiesWindow);
|
||||||
|
|
||||||
mTrackPropertiesWindow = std::make_shared<Editor::TrackPropertiesWindow>("gEditorEnabled", "Track Properties");
|
mTrackPropertiesWindow = std::make_shared<TrackEditor::TrackPropertiesWindow>("gEditorEnabled", "Track Properties");
|
||||||
gui->AddGuiWindow(mTrackPropertiesWindow);
|
gui->AddGuiWindow(mTrackPropertiesWindow);
|
||||||
|
|
||||||
mContentBrowserWindow =
|
mContentBrowserWindow =
|
||||||
std::make_shared<Editor::ContentBrowserWindow>("gEditorEnabled", "Content Browser");
|
std::make_shared<TrackEditor::ContentBrowserWindow>("gEditorEnabled", "Content Browser");
|
||||||
gui->AddGuiWindow(mContentBrowserWindow);
|
gui->AddGuiWindow(mContentBrowserWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
||||||
#include "actors.h"
|
#include "actors.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
PropertiesWindow::~PropertiesWindow() {
|
PropertiesWindow::~PropertiesWindow() {
|
||||||
SPDLOG_TRACE("destruct properties window");
|
SPDLOG_TRACE("destruct properties window");
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <libultraship/libultraship.h>
|
#include <libultraship/libultraship.h>
|
||||||
#include "port/Game.h"
|
#include "port/Game.h"
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class PropertiesWindow : public Ship::GuiWindow {
|
class PropertiesWindow : public Ship::GuiWindow {
|
||||||
public:
|
public:
|
||||||
using Ship::GuiWindow::GuiWindow;
|
using Ship::GuiWindow::GuiWindow;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ extern "C" {
|
||||||
#include "actors.h"
|
#include "actors.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
SceneExplorerWindow::~SceneExplorerWindow() {
|
SceneExplorerWindow::~SceneExplorerWindow() {
|
||||||
SPDLOG_TRACE("destruct scene explorer window");
|
SPDLOG_TRACE("destruct scene explorer window");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include "port/Game.h"
|
#include "port/Game.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class SceneExplorerWindow : public Ship::GuiWindow {
|
class SceneExplorerWindow : public Ship::GuiWindow {
|
||||||
public:
|
public:
|
||||||
using Ship::GuiWindow::GuiWindow;
|
using Ship::GuiWindow::GuiWindow;
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,14 @@
|
||||||
#include <defines.h>
|
#include <defines.h>
|
||||||
#include "port/Game.h"
|
#include "port/Game.h"
|
||||||
#include "engine/editor/SceneManager.h"
|
#include "engine/editor/SceneManager.h"
|
||||||
|
#include "engine/TrackBrowser.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "code_800029B0.h"
|
#include "code_800029B0.h"
|
||||||
#include "code_80057C60.h"
|
#include "code_80057C60.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
ToolsWindow::~ToolsWindow() {
|
ToolsWindow::~ToolsWindow() {
|
||||||
SPDLOG_TRACE("destruct tools window");
|
SPDLOG_TRACE("destruct tools window");
|
||||||
|
|
@ -37,6 +38,7 @@ namespace Editor {
|
||||||
if (ImGui::Button(ICON_FA_FLOPPY_O, ImVec2(50, 25))) {
|
if (ImGui::Button(ICON_FA_FLOPPY_O, ImVec2(50, 25))) {
|
||||||
if (gEditor.IsPaused()) {
|
if (gEditor.IsPaused()) {
|
||||||
SaveLevel(GetWorld()->GetTrack(), gTrackRegistry.GetInfo(GetWorld()->GetTrack()->ResourceName));
|
SaveLevel(GetWorld()->GetTrack(), gTrackRegistry.GetInfo(GetWorld()->GetTrack()->ResourceName));
|
||||||
|
TrackBrowser::Instance->Refresh(gTrackRegistry);
|
||||||
} else {
|
} else {
|
||||||
printf("[Editor] Cannot save during simulation\n Please switch back to edit mode!\n\n");
|
printf("[Editor] Cannot save during simulation\n Please switch back to edit mode!\n\n");
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +142,8 @@ namespace Editor {
|
||||||
ImGui::PushStyleColor(ImGuiCol_Button, defaultColor);
|
ImGui::PushStyleColor(ImGuiCol_Button, defaultColor);
|
||||||
if (ImGui::Button(gEditor.IsPaused() ? ICON_FA_PLAY : ICON_FA_STOP, ImVec2(50, 25))) {
|
if (ImGui::Button(gEditor.IsPaused() ? ICON_FA_PLAY : ICON_FA_STOP, ImVec2(50, 25))) {
|
||||||
if (gEditor.IsPaused()) {
|
if (gEditor.IsPaused()) {
|
||||||
SaveLevel(GetWorld()->GetTrack(), gTrackRegistry.GetInfo(GetWorld()->GetTrack()->ResourceName));
|
SaveLevel(GetWorld()->GetTrack(), gTrackRegistry.GetInfo(GetWorld()->GetTrack()->ResourceName));
|
||||||
|
TrackBrowser::Instance->Refresh(gTrackRegistry);
|
||||||
CVarSetInteger("gFreecam", false);
|
CVarSetInteger("gFreecam", false);
|
||||||
CM_SetFreeCamera(false);
|
CM_SetFreeCamera(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <libultraship/libultraship.h>
|
#include <libultraship/libultraship.h>
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class ToolsWindow : public Ship::GuiWindow {
|
class ToolsWindow : public Ship::GuiWindow {
|
||||||
public:
|
public:
|
||||||
using Ship::GuiWindow::GuiWindow;
|
using Ship::GuiWindow::GuiWindow;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
#include "port/Game.h"
|
#include "port/Game.h"
|
||||||
|
|
||||||
#include "engine/cameras/TourCamera.h"
|
#include "engine/cameras/TourCamera.h"
|
||||||
|
#include "engine/TrackBrowser.h"
|
||||||
|
#include "engine/editor/SceneManager.h"
|
||||||
|
#include "engine/Registry.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "code_800029B0.h"
|
#include "code_800029B0.h"
|
||||||
|
|
@ -23,26 +26,23 @@ extern "C" {
|
||||||
#include "render_objects.h"
|
#include "render_objects.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
|
|
||||||
TrackPropertiesWindow::~TrackPropertiesWindow() {
|
TrackPropertiesWindow::~TrackPropertiesWindow() {
|
||||||
SPDLOG_TRACE("destruct track properties window");
|
SPDLOG_TRACE("destruct track properties window");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackPropertiesWindow::DrawElement() {
|
void TrackPropertiesWindow::DrawElement() {
|
||||||
static char idBuffer[256] = "mk:mario_raceway";
|
|
||||||
static char nameBuffer[256] = "Mario Raceway";
|
|
||||||
static char debugNameBuffer[256] = "m circuit";
|
|
||||||
static char lengthBuffer[256] = "567m";
|
|
||||||
|
|
||||||
if (nullptr == GetWorld()->GetTrack()) {
|
if (nullptr == GetWorld()->GetTrack()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::InputText("ID", idBuffer, IM_ARRAYSIZE(idBuffer));
|
if (ImGui::Button("Edit TrackInfo")) {
|
||||||
ImGui::InputText("Name", GetWorld()->GetTrack()->Props.Name, IM_ARRAYSIZE(nameBuffer));
|
ImGui::OpenPopup("Edit TrackInfo");
|
||||||
ImGui::InputText("Debug Name", GetWorld()->GetTrack()->Props.DebugName, IM_ARRAYSIZE(debugNameBuffer));
|
}
|
||||||
ImGui::InputText("Track Length", GetWorld()->GetTrack()->Props.TrackLength, IM_ARRAYSIZE(lengthBuffer));
|
|
||||||
|
DrawResourceNameEdit();
|
||||||
|
|
||||||
ImGui::InputFloat("Water Level", &GetWorld()->GetTrack()->Props.WaterLevel);
|
ImGui::InputFloat("Water Level", &GetWorld()->GetTrack()->Props.WaterLevel);
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader("Camera")) {
|
if (ImGui::CollapsingHeader("Camera")) {
|
||||||
|
|
@ -175,6 +175,99 @@ namespace Editor {
|
||||||
TrackPropertiesWindow::DrawTourCamera();
|
TrackPropertiesWindow::DrawTourCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackPropertiesWindow::DrawResourceNameEdit() {
|
||||||
|
Track* track = GetWorld()->GetTrack();
|
||||||
|
if (!track) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char resourceNameBuffer[128] = {};
|
||||||
|
static char nameBuffer[128] = "blank_track";
|
||||||
|
static char debugNameBuffer[128] = "blanktrack";
|
||||||
|
static char lengthBuffer[128] = "100m";
|
||||||
|
static bool initialized = false;
|
||||||
|
static std::string oldResourceName = track->ResourceName;
|
||||||
|
|
||||||
|
// Auto-sizing fills the height of the screen for a single frame.
|
||||||
|
// Because there's no content in the window in the first frame.
|
||||||
|
// This forces the window size to prevent that
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(400, 275), ImGuiCond_Always);
|
||||||
|
if (ImGui::BeginPopupModal("Edit TrackInfo", nullptr,
|
||||||
|
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
|
||||||
|
// Initialize once per popup open
|
||||||
|
if (!initialized) {
|
||||||
|
strncpy(resourceNameBuffer, track->ResourceName.c_str(), sizeof(resourceNameBuffer));
|
||||||
|
resourceNameBuffer[sizeof(resourceNameBuffer) - 1] = '\0';
|
||||||
|
oldResourceName = track->ResourceName;
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TextWrapped(
|
||||||
|
"Changing these fields will:\n"
|
||||||
|
"- Save the current track\n"
|
||||||
|
"- Reload the track\n"
|
||||||
|
"- Update the registry\n\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
gEditor.Pause();
|
||||||
|
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
ImGui::InputText("ResourceName", resourceNameBuffer, IM_ARRAYSIZE(resourceNameBuffer));
|
||||||
|
ImGui::InputText("Name", GetWorld()->GetTrack()->Props.Name, IM_ARRAYSIZE(nameBuffer));
|
||||||
|
ImGui::InputText("Debug Name", GetWorld()->GetTrack()->Props.DebugName, IM_ARRAYSIZE(debugNameBuffer));
|
||||||
|
ImGui::InputText("Track Length", GetWorld()->GetTrack()->Props.TrackLength, IM_ARRAYSIZE(lengthBuffer));
|
||||||
|
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
bool cancel = ImGui::Button("Cancel", ImVec2(120, 0));
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
bool confirm = ImGui::Button("Confirm", ImVec2(120, 0));
|
||||||
|
|
||||||
|
if (confirm) {
|
||||||
|
if (oldResourceName != resourceNameBuffer) {
|
||||||
|
track->ResourceName = resourceNameBuffer;
|
||||||
|
const TrackInfo* oldInfo = gTrackRegistry.GetInfo(oldResourceName);
|
||||||
|
TrackInfo info;
|
||||||
|
info.ResourceName = track->ResourceName;
|
||||||
|
info.Name = track->Props.Name;
|
||||||
|
info.DebugName = track->Props.DebugName;
|
||||||
|
info.Path = oldInfo->Path;
|
||||||
|
|
||||||
|
TrackEditor::SaveLevel(track, static_cast<const TrackInfo*>(&info));
|
||||||
|
auto archive = track->Archive;
|
||||||
|
gTrackRegistry.Remove(oldResourceName);
|
||||||
|
gTrackRegistry.Add(info, [info, archive]() {
|
||||||
|
auto track = std::make_unique<Track>();
|
||||||
|
track->Archive = archive;
|
||||||
|
track->ResourceName = info.ResourceName;
|
||||||
|
GetWorld()->SetCurrentTrack(std::move(track));
|
||||||
|
});
|
||||||
|
TrackBrowser::Instance->Refresh(gTrackRegistry);
|
||||||
|
gGotoMode = RACING;
|
||||||
|
|
||||||
|
}
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancel) {
|
||||||
|
initialized = false;
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TrackPropertiesWindow::DrawMusic() {
|
void TrackPropertiesWindow::DrawMusic() {
|
||||||
const char* items[] = {
|
const char* items[] = {
|
||||||
"None", "Title Screen", "Main Menu", "Wario Stadium", "Moo Moo Farm",
|
"None", "Title Screen", "Main Menu", "Wario Stadium", "Moo Moo Farm",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ extern "C" {
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Editor {
|
namespace TrackEditor {
|
||||||
class TrackPropertiesWindow : public Ship::GuiWindow {
|
class TrackPropertiesWindow : public Ship::GuiWindow {
|
||||||
public:
|
public:
|
||||||
using Ship::GuiWindow::GuiWindow;
|
using Ship::GuiWindow::GuiWindow;
|
||||||
|
|
@ -15,6 +15,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void InitElement() override {};
|
void InitElement() override {};
|
||||||
void DrawElement() override;
|
void DrawElement() override;
|
||||||
|
void DrawResourceNameEdit();
|
||||||
void DrawMusic();
|
void DrawMusic();
|
||||||
void DrawFog();
|
void DrawFog();
|
||||||
void DrawLight();
|
void DrawLight();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue