SaveTool: reorganise some code.

This commit is contained in:
Guillaume Jacquemin 2021-06-20 23:48:23 +02:00
parent 9fb654c89d
commit 057185cb65

View file

@ -69,17 +69,50 @@ void SaveTool::drawManager() {
ImGui::BeginGroup();
drawGeneralInfo();
if(ImGui::BeginChild("##GeneralProfileInfo",
{ImGui::GetContentRegionAvailWidth() * 0.60f, (ImGui::GetContentRegionAvail().y - ImGui::GetStyle().ItemSpacing.x) / 2.0f},
true, ImGuiWindowFlags_MenuBar))
{
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted("General profile information");
ImGui::EndMenuBar();
}
drawGeneralInfo();
}
ImGui::EndChild();
ImGui::Dummy({0.0f, 0.0f});
drawResearchInventory();
if(ImGui::BeginChild("##ResearchInventory",
{ImGui::GetContentRegionAvailWidth() * 0.60f, 0.0f},
true, ImGuiWindowFlags_MenuBar))
{
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted("Research inventory");
ImGui::EndMenuBar();
}
drawResearchInventory();
}
ImGui::EndChild();
ImGui::EndGroup();
ImGui::SameLine();
drawMassManager();
if(ImGui::BeginChild("##MASSManager", {0.0f, 0.0f},
true, ImGuiWindowFlags_MenuBar))
{
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted("M.A.S.S. management");
drawHelpMarker("To move, import, or export builds, drag-and-drop them.");
ImGui::EndMenuBar();
}
drawMassManager();
}
ImGui::EndChild();
ImGui::End();
}
@ -163,19 +196,6 @@ void SaveTool::drawGeneralInfo() {
return;
}
if(!ImGui::BeginChild("##GeneralProfileInfo",
{ImGui::GetContentRegionAvailWidth() * 0.60f, (ImGui::GetContentRegionAvail().y - ImGui::GetStyle().ItemSpacing.x) / 2.0f},
true, ImGuiWindowFlags_MenuBar))
{
ImGui::EndChild();
return;
}
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted("General profile information");
ImGui::EndMenuBar();
}
ImGui::Text("Credits: %i", _currentProfile->credits());
auto it = std::find_if(story_progress.begin(), story_progress.end(),
@ -277,8 +297,6 @@ void SaveTool::drawGeneralInfo() {
}
ImGui::EndPopup();
}
ImGui::EndChild();
}
void SaveTool::drawResearchInventory() {
@ -286,19 +304,6 @@ void SaveTool::drawResearchInventory() {
return;
}
if(!ImGui::BeginChild("##ResearchInventory",
{ImGui::GetContentRegionAvailWidth() * 0.60f, 0.0f},
true, ImGuiWindowFlags_MenuBar))
{
ImGui::EndChild();
return;
}
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted("Research inventory");
ImGui::EndMenuBar();
}
#define unavRow(name) \
ImGui::TableNextRow(); \
ImGui::TableSetColumnIndex(0); \
@ -392,8 +397,6 @@ void SaveTool::drawResearchInventory() {
#undef unavRow
#undef matRow
ImGui::EndChild();
}
void SaveTool::drawMassManager() {
@ -401,19 +404,6 @@ void SaveTool::drawMassManager() {
return;
}
if(!ImGui::BeginChild("##MASSManager", {0.0f, 0.0f},
true, ImGuiWindowFlags_MenuBar))
{
ImGui::EndChild();
return;
}
if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted("M.A.S.S. management");
drawHelpMarker("To move, import, or export builds, drag-and-drop them.");
ImGui::EndMenuBar();
}
static int mass_to_delete = 0;
static ImGuiID mass_deletion_popup_ID = drawDeleteMassPopup(mass_to_delete);
@ -593,8 +583,6 @@ void SaveTool::drawMassManager() {
}
drawDeleteStagedMassPopup(staged_mass_to_delete.get());
ImGui::EndChild();
}
auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {