From 597e9dfe983455fe1dc5e22e47c0c02707b4a425 Mon Sep 17 00:00:00 2001 From: William JCM Date: Thu, 19 Aug 2021 20:35:00 +0200 Subject: [PATCH] SaveTool: initial work for the viewer UI. --- src/CMakeLists.txt | 1 + src/SaveTool/SaveTool.cpp | 3 ++ src/SaveTool/SaveTool.h | 5 ++- src/SaveTool/SaveTool_MainManager.cpp | 7 +++++ src/SaveTool/SaveTool_MassViewer.cpp | 44 +++++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/SaveTool/SaveTool_MassViewer.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c202ffd..25cd758 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ add_executable(MassBuilderSaveTool WIN32 SaveTool/SaveTool_drawAbout.cpp SaveTool/SaveTool_drawMainMenu.cpp SaveTool/SaveTool_MainManager.cpp + SaveTool/SaveTool_MassViewer.cpp SaveTool/SaveTool_ProfileManager.cpp ProfileManager/ProfileManager.h ProfileManager/ProfileManager.cpp diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index f00fa1f..808622d 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -576,6 +576,9 @@ void SaveTool::drawGui() { case UiState::MainManager: drawManager(); break; + case UiState::MassViewer: + drawMassViewer(); + break; } if(_aboutPopup) { diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index f50f6cf..f975d06 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -100,6 +100,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawMassManager(); auto drawDeleteMassPopup(int mass_index) -> ImGuiID; auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID; + void drawMassViewer(); void drawAbout(); void drawGameState(); @@ -152,7 +153,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener Disclaimer, Initialising, ProfileManager, - MainManager + MainManager, + MassViewer } _uiState{UiState::Disclaimer}; bool _aboutPopup{false}; @@ -190,6 +192,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener Profile* _currentProfile{nullptr}; Containers::Pointer _massManager; + Mass* _currentMass{nullptr}; Containers::Pointer _fileWatcher; enum watchID { diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/SaveTool/SaveTool_MainManager.cpp index 3708694..23d1a1f 100644 --- a/src/SaveTool/SaveTool_MainManager.cpp +++ b/src/SaveTool/SaveTool_MainManager.cpp @@ -497,6 +497,13 @@ void SaveTool::drawMassManager() { if(_massManager->hangar(i).state() != MassState::Empty) { ImGui::TableSetColumnIndex(3); ImGui::PushID(i); + if(_massManager->hangar(i).state() == MassState::Valid) { + if(ImGui::SmallButton(ICON_FA_SEARCH)) { + _currentMass = &_massManager->hangar(i); + _uiState = UiState::MassViewer; + } + ImGui::SameLine(0.0f, 2.0f); + } if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) { mass_to_delete = i; ImGui::OpenPopup(mass_deletion_popup_ID); diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/SaveTool/SaveTool_MassViewer.cpp new file mode 100644 index 0000000..7ad9212 --- /dev/null +++ b/src/SaveTool/SaveTool_MassViewer.cpp @@ -0,0 +1,44 @@ +// MassBuilderSaveTool +// Copyright (C) 2021 Guillaume Jacquemin +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "../FontAwesome/IconsFontAwesome5.h" + +#include "SaveTool.h" + +void SaveTool::drawMassViewer() { + ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); + ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y}, + ImGuiCond_Always); + if(!ImGui::Begin("##MainWindow", nullptr, + ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove| + ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoBringToFrontOnFocus)) + { + ImGui::End(); + return; + } + + ImGui::AlignTextToFramePadding(); + ImGui::Text("Current M.A.S.S.: %s (%s)", + _currentMass->name().c_str(), + _currentMass->filename().c_str()); + ImGui::SameLine(); + if(ImGui::Button(ICON_FA_ARROW_LEFT " Back to main manager")) { + _currentMass = nullptr; + _uiState = UiState::MainManager; + } + + ImGui::End(); +}