Skip to content

Commit

Permalink
allow to set project name in new simulation dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Nov 13, 2024
1 parent 3c6108f commit 2bcfc3f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ Size=308,116
Collapsed=0

[Window][New simulation]
Pos=823,411
Size=299,166
Pos=823,390
Size=300,191
Collapsed=0

[Window][Network settings]
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/AutosaveWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void AutosaveWindow::processStatusBar()
return "Next autosave in " + StringHelper::format(std::chrono::seconds(_autosaveInterval * 60) - secondsSinceLastAutosave);
}();
if (_savepointTable.has_value()) {
statusText += " " ICON_FA_INFO_CIRCLE " " + std::to_string(_savepointTable->getSize()) + " savepoints";
statusText += " " ICON_FA_INFO_CIRCLE " " + std::to_string(_savepointTable->getSize()) + " save points";
}
AlienImGui::StatusBar(statusText);
}
Expand Down
7 changes: 6 additions & 1 deletion source/Gui/NewSimulationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

namespace
{
auto const ContentTextInputWidth = 60.0f;
auto const ContentTextInputWidth = 100.0f;
auto const ProjectNameSize = sizeof(Char64) / sizeof(char);
}

void NewSimulationDialog::initIntern(SimulationFacade simulationFacade)
Expand All @@ -34,6 +35,7 @@ NewSimulationDialog::NewSimulationDialog()

void NewSimulationDialog::processIntern()
{
AlienImGui::InputText(AlienImGui::InputTextParameters().name("Project name").textWidth(ContentTextInputWidth), _projectName, ProjectNameSize);
AlienImGui::InputInt(AlienImGui::InputIntParameters().name("Width").textWidth(ContentTextInputWidth), _width);
AlienImGui::InputInt(AlienImGui::InputIntParameters().name("Height").textWidth(ContentTextInputWidth), _height);
AlienImGui::Checkbox(
Expand Down Expand Up @@ -71,6 +73,9 @@ void NewSimulationDialog::onNewSimulation()
if (_adoptSimulationParameters) {
parameters = _simulationFacade->getSimulationParameters();
}
for (int i = 0; i < ProjectNameSize; ++i) {
parameters.projectName[i] = _projectName[i];
}
_simulationFacade->closeSimulation();

GeneralSettings generalSettings;
Expand Down
4 changes: 3 additions & 1 deletion source/Gui/NewSimulationDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Base/Singleton.h"
#include "EngineInterface/Definitions.h"
#include "EngineInterface/Descriptions.h"
#include "EngineInterface/SimulationParameters.h"
#include "Definitions.h"
#include "AlienDialog.h"

Expand All @@ -23,6 +24,7 @@ class NewSimulationDialog : public AlienDialog<SimulationFacade>
SimulationFacade _simulationFacade;

bool _adoptSimulationParameters = true;
Char64 _projectName = "<unnamed>";
int _width = 0;
int _height = 0;
};
};
5 changes: 2 additions & 3 deletions source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ void SimulationParametersWindow::processBase()
AlienImGui::InputTextParameters()
.name("Project name")
.textWidth(RightColumnWidth)
.defaultValue(origParameters.projectName)
.tooltip(Const::ColoringParameterTooltip),
.defaultValue(origParameters.projectName),
parameters.projectName,
sizeof(parameters.projectName) / sizeof(char));
sizeof(Char64) / sizeof(char));

AlienImGui::EndTreeNode();
}
Expand Down

0 comments on commit 2bcfc3f

Please sign in to comment.