mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-09-08 03:56:50 -04:00
Refactor Track Class To Instantiate On Track Load (#587)
* Initial Commit * First compilation of Registry template * Further changes * wip changes * Impl TrackBrowser and Registry Info * Remove const from TInfo * Prep GetWorld * Name refactor * Refactor gWorldInstance to GetWorld() * wip * Should work now * Data menu work again * Fix editor staying open after program close * Rename LoadLevel to LoadTrackDataFromJson * More changes * Add statue * Add search to content browser using tags * Fix statue pos and register tags * Fix actor loading * Fix delete all bug which deleted cameras * reduce some boiler plate in actor and object * Remove unused rulesets * Search bar for all tabs * fix data screen * fix actor spawning * temp editor fix * Clean up * improve extra mode transformation * fix podium crash * Fix editor clicking * Fix editor clicking 2 * fix extra in custom track * Fix FI for three actors * Fix divide by zero error * Ids managed by Registry * Add scary comment --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> Co-authored-by: coco875 <pereira.jannin@gmail.com>
This commit is contained in:
@@ -35,19 +35,19 @@ namespace Editor {
|
||||
static char debugNameBuffer[256] = "m circuit";
|
||||
static char lengthBuffer[256] = "567m";
|
||||
|
||||
if (nullptr == gWorldInstance.GetTrack()) {
|
||||
if (nullptr == GetWorld()->GetTrack()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::InputText("ID", idBuffer, IM_ARRAYSIZE(idBuffer));
|
||||
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);
|
||||
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::InputFloat("Water Level", &GetWorld()->GetTrack()->Props.WaterLevel);
|
||||
|
||||
if (ImGui::CollapsingHeader("Camera")) {
|
||||
ImGui::InputFloat("Near Perspective", &gWorldInstance.GetTrack()->Props.NearPersp);
|
||||
ImGui::InputFloat("Far Perspective", &gWorldInstance.GetTrack()->Props.FarPersp);
|
||||
ImGui::InputFloat("Near Perspective", &GetWorld()->GetTrack()->Props.NearPersp);
|
||||
ImGui::InputFloat("Far Perspective", &GetWorld()->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.GetTrack()->Props.AIMaximumSeparation);
|
||||
ImGui::InputFloat("AI Min Separation", &gWorldInstance.GetTrack()->Props.AIMinimumSeparation);
|
||||
ImGui::InputInt("AI Steering Sensitivity", (int*)&gWorldInstance.GetTrack()->Props.AISteeringSensitivity);
|
||||
ImGui::InputFloat("AI Max Separation", &GetWorld()->GetTrack()->Props.AIMaximumSeparation);
|
||||
ImGui::InputFloat("AI Min Separation", &GetWorld()->GetTrack()->Props.AIMinimumSeparation);
|
||||
ImGui::InputInt("AI Steering Sensitivity", (int*)&GetWorld()->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.GetTrack()->Props.AIDistance[i]);
|
||||
ImGui::InputScalar(("Element " + std::to_string(i)).c_str(), ImGuiDataType_S16, &GetWorld()->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.GetTrack()->Props.CurveTargetSpeed[i]);
|
||||
ImGui::InputFloat(fmt::format("CurveTargetSpeed[{}]", i).c_str(), &GetWorld()->GetTrack()->Props.CurveTargetSpeed[i]);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
ImGui::InputFloat(fmt::format("NormalTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.NormalTargetSpeed[i]);
|
||||
ImGui::InputFloat(fmt::format("NormalTargetSpeed[{}]", i).c_str(), &GetWorld()->GetTrack()->Props.NormalTargetSpeed[i]);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
ImGui::InputFloat(fmt::format("D_0D0096B8[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.D_0D0096B8[i]);
|
||||
ImGui::InputFloat(fmt::format("D_0D0096B8[{}]", i).c_str(), &GetWorld()->GetTrack()->Props.D_0D0096B8[i]);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
ImGui::InputFloat(fmt::format("OffTrackTargetSpeed[{}]", i).c_str(), &gWorldInstance.GetTrack()->Props.OffTrackTargetSpeed[i]);
|
||||
ImGui::InputFloat(fmt::format("OffTrackTargetSpeed[{}]", i).c_str(), &GetWorld()->GetTrack()->Props.OffTrackTargetSpeed[i]);
|
||||
}
|
||||
}
|
||||
|
||||
float minimapColour[3];
|
||||
RGB8ToFloat((u8*)&gWorldInstance.GetTrack()->Props.Minimap.Colour, minimapColour);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Minimap.Colour, minimapColour);
|
||||
|
||||
if (ImGui::CollapsingHeader("Minimap")) {
|
||||
ImGui::Text("Position");
|
||||
ImGui::SameLine();
|
||||
|
||||
|
||||
if (ImGui::DragInt2("##MinimapPosition", &gWorldInstance.GetTrack()->Props.Minimap.Pos[0].X, 1.0f)) {
|
||||
if (ImGui::DragInt2("##MinimapPosition", &GetWorld()->GetTrack()->Props.Minimap.Pos[0].X, 1.0f)) {
|
||||
}
|
||||
ImGui::Text("P2 Position");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::DragInt2("##MinimapPosition2p", &gWorldInstance.GetTrack()->Props.Minimap.Pos[1].X, 1.0f)) {
|
||||
if (ImGui::DragInt2("##MinimapPosition2p", &GetWorld()->GetTrack()->Props.Minimap.Pos[1].X, 1.0f)) {
|
||||
}
|
||||
|
||||
ImGui::Text("Player Markers");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::DragInt2("##MinimapPlayers", &gWorldInstance.GetTrack()->Props.Minimap.PlayerX, 1.0f)) {
|
||||
if (ImGui::DragInt2("##MinimapPlayers", &GetWorld()->GetTrack()->Props.Minimap.PlayerX, 1.0f)) {
|
||||
}
|
||||
|
||||
ImGui::Text("Player Scale Factor");
|
||||
ImGui::SameLine();
|
||||
if (ImGui::DragFloat("##MinimapScaleFactor", &gWorldInstance.GetTrack()->Props.Minimap.PlayerScaleFactor, 0.0001f)) {
|
||||
if (ImGui::DragFloat("##MinimapScaleFactor", &GetWorld()->GetTrack()->Props.Minimap.PlayerScaleFactor, 0.0001f)) {
|
||||
}
|
||||
|
||||
ImGui::Text("Finishline");
|
||||
ImGui::SameLine();
|
||||
ImGui::DragFloat2("##MinimapFinishlineX", &gWorldInstance.GetTrack()->Props.Minimap.FinishlineX, 1.0f);
|
||||
ImGui::DragFloat2("##MinimapFinishlineX", &GetWorld()->GetTrack()->Props.Minimap.FinishlineX, 1.0f);
|
||||
|
||||
ImGui::Text("Colour");
|
||||
ImGui::SameLine();
|
||||
ImGui::ColorEdit3("##MinimapColour", minimapColour, 1.0f);
|
||||
}
|
||||
|
||||
FloatToRGB8(minimapColour, (u8*)&gWorldInstance.GetTrack()->Props.Minimap.Colour);
|
||||
FloatToRGB8(minimapColour, (u8*)&GetWorld()->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.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);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.TopRight, topRight);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.BottomRight, bottomRight);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.BottomLeft, bottomLeft);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.TopLeft, topLeft);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.FloorTopRight, floorTopRight);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.FloorBottomRight, floorBottomRight);
|
||||
RGB8ToFloat((u8*)&GetWorld()->GetTrack()->Props.Skybox.FloorBottomLeft, floorBottomLeft);
|
||||
RGB8ToFloat((u8*)&GetWorld()->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.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);
|
||||
FloatToRGB8(topRight, (u8*)&GetWorld()->GetTrack()->Props.Skybox.TopRight);
|
||||
FloatToRGB8(bottomRight, (u8*)&GetWorld()->GetTrack()->Props.Skybox.BottomRight);
|
||||
FloatToRGB8(bottomLeft, (u8*)&GetWorld()->GetTrack()->Props.Skybox.BottomLeft);
|
||||
FloatToRGB8(topLeft, (u8*)&GetWorld()->GetTrack()->Props.Skybox.TopLeft);
|
||||
FloatToRGB8(floorTopRight, (u8*)&GetWorld()->GetTrack()->Props.Skybox.FloorTopRight);
|
||||
FloatToRGB8(floorBottomRight, (u8*)&GetWorld()->GetTrack()->Props.Skybox.FloorBottomRight);
|
||||
FloatToRGB8(floorBottomLeft, (u8*)&GetWorld()->GetTrack()->Props.Skybox.FloorBottomLeft);
|
||||
FloatToRGB8(floorTopLeft, (u8*)&GetWorld()->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.GetTrack()->Props.Sequence); // Get the current selected value's string
|
||||
const char* currentItem = MusicSeqToString(GetWorld()->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.GetTrack()->Props.Sequence = static_cast<MusicSeq>(i);
|
||||
play_sequence(gWorldInstance.GetTrack()->Props.Sequence); // Call play_sequence with the updated sequence
|
||||
GetWorld()->GetTrack()->Props.Sequence = static_cast<MusicSeq>(i);
|
||||
play_sequence(GetWorld()->GetTrack()->Props.Sequence); // Call play_sequence with the updated sequence
|
||||
|
||||
// Update currentItem after selection is made
|
||||
currentItem = items[i];
|
||||
@@ -299,7 +299,7 @@ namespace Editor {
|
||||
|
||||
void TrackPropertiesWindow::DrawTourCamera() {
|
||||
|
||||
std::shared_ptr<Track> track = gWorldInstance.GetTrack();
|
||||
Track* track = GetWorld()->GetTrack();
|
||||
if (nullptr == track) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user