SaveTool: initial work for the viewer UI.

This commit is contained in:
Guillaume Jacquemin 2021-08-19 20:35:00 +02:00
parent 4cdd1b35ec
commit 597e9dfe98
5 changed files with 59 additions and 1 deletions

View file

@ -35,6 +35,7 @@ add_executable(MassBuilderSaveTool WIN32
SaveTool/SaveTool_drawAbout.cpp SaveTool/SaveTool_drawAbout.cpp
SaveTool/SaveTool_drawMainMenu.cpp SaveTool/SaveTool_drawMainMenu.cpp
SaveTool/SaveTool_MainManager.cpp SaveTool/SaveTool_MainManager.cpp
SaveTool/SaveTool_MassViewer.cpp
SaveTool/SaveTool_ProfileManager.cpp SaveTool/SaveTool_ProfileManager.cpp
ProfileManager/ProfileManager.h ProfileManager/ProfileManager.h
ProfileManager/ProfileManager.cpp ProfileManager/ProfileManager.cpp

View file

@ -576,6 +576,9 @@ void SaveTool::drawGui() {
case UiState::MainManager: case UiState::MainManager:
drawManager(); drawManager();
break; break;
case UiState::MassViewer:
drawMassViewer();
break;
} }
if(_aboutPopup) { if(_aboutPopup) {

View file

@ -100,6 +100,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawMassManager(); void drawMassManager();
auto drawDeleteMassPopup(int mass_index) -> ImGuiID; auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID; auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID;
void drawMassViewer();
void drawAbout(); void drawAbout();
void drawGameState(); void drawGameState();
@ -152,7 +153,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
Disclaimer, Disclaimer,
Initialising, Initialising,
ProfileManager, ProfileManager,
MainManager MainManager,
MassViewer
} _uiState{UiState::Disclaimer}; } _uiState{UiState::Disclaimer};
bool _aboutPopup{false}; bool _aboutPopup{false};
@ -190,6 +192,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
Profile* _currentProfile{nullptr}; Profile* _currentProfile{nullptr};
Containers::Pointer<MassManager> _massManager; Containers::Pointer<MassManager> _massManager;
Mass* _currentMass{nullptr};
Containers::Pointer<efsw::FileWatcher> _fileWatcher; Containers::Pointer<efsw::FileWatcher> _fileWatcher;
enum watchID { enum watchID {

View file

@ -497,6 +497,13 @@ void SaveTool::drawMassManager() {
if(_massManager->hangar(i).state() != MassState::Empty) { if(_massManager->hangar(i).state() != MassState::Empty) {
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(i); 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)) { if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_TRASH_ALT)) {
mass_to_delete = i; mass_to_delete = i;
ImGui::OpenPopup(mass_deletion_popup_ID); ImGui::OpenPopup(mass_deletion_popup_ID);

View file

@ -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 <https://www.gnu.org/licenses/>.
#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();
}