Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System Editor Fixes #5787

Merged
merged 2 commits into from Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/editor/system/GalaxyEditAPI.cpp
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
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