Skip to content

Commit

Permalink
Merge pull request pioneerspacesim#5787 from Web-eWorks/editor-fixes
Browse files Browse the repository at this point in the history
System Editor Fixes
  • Loading branch information
Webster Sheets authored Mar 2, 2024
2 parents 4b7509a + fa42d04 commit 384d8f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/editor/system/GalaxyEditAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,16 @@ void SystemBody::EditorAPI::EditOrbitalParameters(SystemBody *body, UndoSystem *

void SystemBody::EditorAPI::EditEconomicProperties(SystemBody *body, UndoSystem *undo)
{
ImGui::SeparatorText("Economic Parameters");

// TODO: system generation currently ignores these fields of a system body
// and overwrites them with randomly-rolled values.
return;
ImGui::BeginDisabled();

ImGui::SeparatorText("Economic Parameters");
ImGui::PushTextWrapPos(ImGui::GetContentRegionAvail().x);
ImGui::TextColored(ImVec4(0.8, 0.8, 0.8, 1.0), "These fields are currently overwritten when the system is loaded.");
ImGui::PopTextWrapPos();
ImGui::Spacing();

ImGui::InputFixed("Population", &body->m_population);
if (Draw::UndoHelper("Edit Population", undo))
Expand All @@ -561,6 +566,8 @@ void SystemBody::EditorAPI::EditEconomicProperties(SystemBody *body, UndoSystem
ImGui::InputFixed("Agricultural Activity", &body->m_agricultural);
if (Draw::UndoHelper("Edit Agricultural Activity", undo))
AddUndoSingleValue(undo, &body->m_agricultural);

ImGui::EndDisabled();
}

void SystemBody::EditorAPI::EditStarportProperties(SystemBody *body, UndoSystem *undo)
Expand Down
7 changes: 3 additions & 4 deletions src/editor/system/SystemEditorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ bool Draw::InputFixedDegrees(const char *str, fixed *val, double val_min, double
double val_d = RAD2DEG(val->ToDouble());

bool changed = ImGui::SliderScalar(str, ImGuiDataType_Double, &val_d, &val_min, &val_max, "%.3f°", ImGuiSliderFlags_NoRoundToFormat);
// bool changed = ImGui::InputDouble(str, &val_d, 1.0, 10.0, "%.3f°", flags | ImGuiInputTextFlags_EnterReturnsTrue);
// delay one frame before writing back the value for the undo system to push a value
if (changed && !ImGui::IsItemActivated())
*val = fixed::FromDouble(DEG2RAD(val_d));
Expand Down Expand Up @@ -170,7 +169,7 @@ bool Draw::InputFixedDistance(const char *str, fixed *val, ImGuiInputTextFlags f

ImGui::SameLine(0.f, 1.f);
Draw::SubtractItemWidth();
bool changed = ImGui::InputDouble(str, &val_d, val_step, val_step * 10.0, distance_formats[unit_type], flags | ImGuiInputTextFlags_EnterReturnsTrue);
bool changed = ImGui::InputDouble(str, &val_d, val_step, val_step * 10.0, distance_formats[unit_type], flags);
if (changed)
*val = fixed::FromDouble(val_d / distance_multipliers[unit_type]);

Expand Down Expand Up @@ -218,7 +217,7 @@ bool Draw::InputFixedMass(const char *str, fixed *val, bool is_solar, ImGuiInput

ImGui::SameLine(0.f, 1.f);
Draw::SubtractItemWidth();
bool changed = ImGui::InputDouble(str, &val_d, val_step, val_step * 10.0, mass_formats[unit_type], flags | ImGuiInputTextFlags_EnterReturnsTrue);
bool changed = ImGui::InputDouble(str, &val_d, val_step, val_step * 10.0, mass_formats[unit_type], flags);

if (is_solar && unit_type != MASS_SOLS)
val_d /= unit_type == MASS_EARTH ? SOL_TO_EARTH_MASS : SOL_MASS_PT;
Expand Down Expand Up @@ -272,7 +271,7 @@ bool Draw::InputFixedRadius(const char *str, fixed *val, bool is_solar, ImGuiInp

ImGui::SameLine(0.f, 1.f);
Draw::SubtractItemWidth();
bool changed = ImGui::InputDouble(str, &val_d, val_step, val_step * 10.0, radius_formats[unit_type], flags | ImGuiInputTextFlags_EnterReturnsTrue);
bool changed = ImGui::InputDouble(str, &val_d, val_step, val_step * 10.0, radius_formats[unit_type], flags);

if (is_solar && unit_type != RADIUS_SOLS)
val_d /= unit_type == RADIUS_EARTH ? SOL_TO_EARTH_MASS : SOL_RADIUS_KM;
Expand Down

0 comments on commit 384d8f3

Please sign in to comment.