Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CrashTeamEditor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<ClCompile Include="src\io.cpp" />
<ClCompile Include="src\level.cpp" />
<ClCompile Include="src\levelui.cpp" />
<ClCompile Include="src\minimap.cpp" />
<ClCompile Include="src\script.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\material.cpp" />
Expand Down Expand Up @@ -92,6 +93,7 @@
<ClInclude Include="src\lev.h" />
<ClInclude Include="src\level.h" />
<ClInclude Include="src\material.h" />
<ClInclude Include="src\minimap.h" />
<ClInclude Include="src\path.h" />
<ClInclude Include="src\process.h" />
<ClInclude Include="src\psx_types.h" />
Expand Down
6 changes: 6 additions & 0 deletions CrashTeamEditor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
<ClCompile Include="src\levelui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\minimap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\script.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -197,6 +200,9 @@
<ClInclude Include="src\material.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\minimap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\renderer.h">
<Filter>Renderer</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions src/gui_render_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bool GuiRenderSettings::showStartpoints = false;
bool GuiRenderSettings::showVisTree = false;
bool GuiRenderSettings::filterActive = true;
bool GuiRenderSettings::showSelectedQuadblockInfo = true;
bool GuiRenderSettings::showMinimapBounds = false;
Color GuiRenderSettings::defaultFilterColor = Color(static_cast<unsigned char>(255), static_cast<unsigned char>(128), static_cast<unsigned char>(0));
Color GuiRenderSettings::selectedCheckpointColor = Color(static_cast<unsigned char>(0), static_cast < unsigned char>(255), static_cast < unsigned char>(255));
int GuiRenderSettings::renderType = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/gui_render_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct GuiRenderSettings
static float camFovDeg, camZoomMult, camRotateMult, camMoveMult, camSprintMult;
static int camKeyForward, camKeyBack, camKeyLeft, camKeyRight, camKeyUp, camKeyDown, camKeySprint;
static int camOrbitMouseButton;
static bool showLowLOD, showWireframe, showVerts, showBackfaces, showBspRectTree, showLevel, showCheckpoints, showStartpoints, showVisTree, filterActive, showSelectedQuadblockInfo;
static bool showLowLOD, showWireframe, showVerts, showBackfaces, showBspRectTree, showLevel, showCheckpoints, showStartpoints, showVisTree, filterActive, showSelectedQuadblockInfo, showMinimapBounds;
static Color defaultFilterColor, selectedCheckpointColor;
static const std::vector<const char*> renderTypeLabels;
};
51 changes: 51 additions & 0 deletions src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,57 @@ void from_json(const nlohmann::json& json, Stars& stars)
if (json.contains("depth")) { stars.zDepth = json["depth"]; }
}

void to_json(nlohmann::json& json, const MinimapConfig& minimap)
{
json = {
{"enabled", minimap.enabled},
{"worldEndX", minimap.worldEndX},
{"worldEndY", minimap.worldEndY},
{"worldStartX", minimap.worldStartX},
{"worldStartY", minimap.worldStartY},
{"iconSizeX", minimap.iconSizeX},
{"iconSizeY", minimap.iconSizeY},
{"driverDotStartX", minimap.driverDotStartX},
{"driverDotStartY", minimap.driverDotStartY},
{"orientationMode", minimap.orientationMode},
{"unk", minimap.unk},
{"sourceTexturePath", minimap.sourceTexturePath.string()}
};
}

void from_json(const nlohmann::json& json, MinimapConfig& minimap)
{
if (json.contains("enabled")) { json.at("enabled").get_to(minimap.enabled); }
if (json.contains("worldEndX")) { json.at("worldEndX").get_to(minimap.worldEndX); }
if (json.contains("worldEndY")) { json.at("worldEndY").get_to(minimap.worldEndY); }
if (json.contains("worldStartX")) { json.at("worldStartX").get_to(minimap.worldStartX); }
if (json.contains("worldStartY")) { json.at("worldStartY").get_to(minimap.worldStartY); }
if (json.contains("iconSizeX")) { json.at("iconSizeX").get_to(minimap.iconSizeX); }
if (json.contains("iconSizeY")) { json.at("iconSizeY").get_to(minimap.iconSizeY); }
if (json.contains("driverDotStartX")) { json.at("driverDotStartX").get_to(minimap.driverDotStartX); }
if (json.contains("driverDotStartY")) { json.at("driverDotStartY").get_to(minimap.driverDotStartY); }
if (json.contains("orientationMode")) { json.at("orientationMode").get_to(minimap.orientationMode); }
if (json.contains("unk")) { json.at("unk").get_to(minimap.unk); }

// New format: single source texture path
if (json.contains("sourceTexturePath"))
{
std::string path;
json.at("sourceTexturePath").get_to(path);
if (!path.empty()) { minimap.sourceTexturePath = path; }
}
// Old format backwards compatibility: if topTexturePath exists but sourceTexturePath doesn't, use topTexturePath
else if (json.contains("topTexturePath"))
{
std::string path;
json.at("topTexturePath").get_to(path);
if (!path.empty()) { minimap.sourceTexturePath = path; }
}

// Load textures after setting paths
minimap.LoadTextures();
}

void ReadBinaryFile(std::vector<uint8_t>& v, const std::filesystem::path& path)
{
std::ifstream file(path, std::ios::binary);
Expand Down
4 changes: 4 additions & 0 deletions src/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "path.h"
#include "quadblock.h"
#include "animtexture.h"
#include "minimap.h"

#include <nlohmann/json.hpp>

Expand All @@ -26,6 +27,9 @@ void from_json(const nlohmann::json& json, ColorGradient& spawn);
void to_json(nlohmann::json& json, const Stars& stars);
void from_json(const nlohmann::json& json, Stars& stars);

void to_json(nlohmann::json& json, const MinimapConfig& minimap);
void from_json(const nlohmann::json& json, MinimapConfig& minimap);

void ReadBinaryFile(std::vector<uint8_t>& v, const std::filesystem::path& path);

template<typename T> static inline void Read(std::ifstream& file, T& data)
Expand Down
Loading