Skip to content

Commit

Permalink
SystemEditor: station type / heightmap properties
Browse files Browse the repository at this point in the history
  • Loading branch information
sturnclaw committed Oct 15, 2023
1 parent 3cad5e4 commit 55afc98
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/editor/system/GalaxyEditAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,14 @@ void SystemBody::EditorAPI::EditStarportProperties(SystemBody *body, UndoSystem
}

EditEconomicProperties(body, undo);

ImGui::SeparatorText("Misc. Properties");

ImGui::InputText("Model Name", &body->m_spaceStationType);
if (Draw::UndoHelper("Edit Station Model Name", undo))
AddUndoSingleValue(undo, &body->m_spaceStationType);

Draw::HelpMarker("Model name (without extension) to use for this starport.\nA random model is chosen if not specified.");
}

void SystemBody::EditorAPI::EditBodyName(SystemBody *body, Random &rng, LuaNameGen *nameGen, UndoSystem *undo)
Expand Down Expand Up @@ -743,6 +751,18 @@ void SystemBody::EditorAPI::EditProperties(SystemBody *body, Random &rng, UndoSy
if (Draw::UndoHelper("Edit Life", undo))
AddUndoSingleValue(undo, &body->m_life);

ImGui::InputText("HMap Path", &body->m_heightMapFilename);
if (Draw::UndoHelper("Edit Heightmap Path", undo))
AddUndoSingleValue(undo, &body->m_heightMapFilename);

Draw::HelpMarker("Path to a custom heightmap file for this body, relative to the game's data directory.");

ImGui::SliderInt("HMap Fractal", reinterpret_cast<int *>(&body->m_heightMapFractal), 0, 1, "%d", ImGuiSliderFlags_AlwaysClamp);
if (Draw::UndoHelper("Edit Heightmap Fractal", undo))
AddUndoSingleValue(undo, &body->m_heightMapFractal);

Draw::HelpMarker("Fractal type index for use with a custom heightmap file.");

if (Draw::DerivedValues("Surface Parameters")) {
ImGui::BeginDisabled();

Expand Down
6 changes: 6 additions & 0 deletions src/galaxy/SystemBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ void SystemBodyData::LoadFromJson(const Json &obj)
m_rings.baseColor = obj.value<Color>("ringsBaseColor", {});
}

// NOTE: the following parameters should be replaced with entries
// in a PropertyMap owned by the system body
m_spaceStationType = obj.value<std::string>("spaceStationType", "");

// HACK: this is to support the current / legacy heightmap fractal system
// Should be replaced with PropertyMap entries and validation moved to Terrain.cpp
m_heightMapFilename = obj.value<std::string>("heightMapFilename", "");
m_heightMapFractal = obj.value<uint32_t>("heightMapFractal", 0);

m_heightMapFractal = std::min(m_heightMapFractal, uint32_t(1));
}

SystemBody::SystemBody(const SystemPath &path, StarSystem *system) :
Expand Down
2 changes: 1 addition & 1 deletion src/terrain/Terrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Terrain *Terrain::InstanceTerrain(const SystemBody *body)
// special case for heightmaps
// XXX this is terrible but will do for now until we get a unified
// heightmap setup. if you add another height fractal, remember to change
// the check in CustomSystem::l_height_map
// the check in CustomSystem::l_height_map / SystemBodyData::LoadFromJson
if (!body->GetHeightMapFilename().empty()) {
const GeneratorInstancer choices[] = {
InstanceGenerator<TerrainHeightMapped, TerrainColorEarthLikeHeightmapped>,
Expand Down

0 comments on commit 55afc98

Please sign in to comment.