Compare commits

...

2 commits

Author SHA1 Message Date
51602c713a SaveTool: update layout. 2022-01-14 13:42:09 +01:00
1621a4dbd5 SaveTool: move M.A.S.S. viewer state tracking.
That way, it's easier to reset. Some states, such as the current tab or
which headers are open/collapsed, are internal to ImGui, though, so I
can't do much there. Well, I could use the internal ImGui API, but, it's
still a pain in the ass.
2022-01-14 13:22:51 +01:00
3 changed files with 58 additions and 48 deletions

View file

@ -248,5 +248,14 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
std::string _releaseLink; std::string _releaseLink;
std::string _downloadLink; std::string _downloadLink;
bool _jointsDirty{false};
bool _stylesDirty{false};
bool _eyeFlareDirty{false};
Containers::StaticArray<38, Int> _selectedArmourDecals{ValueInit};
Containers::StaticArray<38, Int> _selectedArmourAccessories{ValueInit};
Int _selectedWeaponPart{0};
Int _selectedWeaponDecal{0};
Int _selectedWeaponAccessory{0};
bool _cheatMode{false}; bool _cheatMode{false};
}; };

View file

@ -409,7 +409,7 @@ void SaveTool::drawMassManager() {
ImGui::TableSetupColumn("##Hangar", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("##Hangar", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("##MASSName", ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("##MASSName", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("##Active", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("##Active", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("##DeleteButton", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("##Buttons", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupScrollFreeze(0, 1); ImGui::TableSetupScrollFreeze(0, 1);
@ -504,6 +504,11 @@ void SaveTool::drawMassManager() {
} }
ImGui::SameLine(0.0f, 2.0f); ImGui::SameLine(0.0f, 2.0f);
} }
else{
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.0f);
ImGui::SmallButton(ICON_FA_SEARCH);
ImGui::PopStyleVar();
}
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

@ -74,6 +74,9 @@ void SaveTool::drawMassViewer() {
if(ImGui::SmallButton(ICON_FA_SYNC_ALT " Refresh")) { if(ImGui::SmallButton(ICON_FA_SYNC_ALT " Refresh")) {
_currentMass->refreshValues(); _currentMass->refreshValues();
_currentMass->setDirty(false); _currentMass->setDirty(false);
_jointsDirty = false;
_stylesDirty = false;
_eyeFlareDirty = false;
} }
} }
@ -82,7 +85,15 @@ void SaveTool::drawMassViewer() {
current_weapon = nullptr; current_weapon = nullptr;
_currentMass = nullptr; _currentMass = nullptr;
_uiState = UiState::MainManager; _uiState = UiState::MainManager;
} _jointsDirty = false;
_stylesDirty = false;
_eyeFlareDirty = false;
_selectedArmourDecals = Containers::StaticArray<38, Int>{ValueInit};
_selectedArmourAccessories = Containers::StaticArray<38, Int>{ValueInit};
_selectedWeaponPart = 0;
_selectedWeaponDecal = 0;
_selectedWeaponAccessory = 0;
};
ImGui::EndTable(); ImGui::EndTable();
} }
@ -201,8 +212,6 @@ void SaveTool::drawJointSliders() {
return; return;
} }
static bool joints_dirty = false;
ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game."); ImGui::TextWrapped("In-game values are multiplied by 100.\nFor example, 0.500 here is equal to 50 in-game.");
if(ImGui::BeginTable("##JointSliderTable", 2, ImGuiTableFlags_Borders)) { if(ImGui::BeginTable("##JointSliderTable", 2, ImGuiTableFlags_Borders)) {
@ -216,7 +225,7 @@ void SaveTool::drawJointSliders() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##NeckSlider", &_currentMass->jointSliders().neck, 0.0f, 1.0f)) { if(ImGui::SliderFloat("##NeckSlider", &_currentMass->jointSliders().neck, 0.0f, 1.0f)) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::TableNextRow(); ImGui::TableNextRow();
@ -226,7 +235,7 @@ void SaveTool::drawJointSliders() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##BodySlider", &_currentMass->jointSliders().body, 0.0f, 1.0f)) { if(ImGui::SliderFloat("##BodySlider", &_currentMass->jointSliders().body, 0.0f, 1.0f)) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::TableNextRow(); ImGui::TableNextRow();
@ -236,7 +245,7 @@ void SaveTool::drawJointSliders() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##ShouldersSlider", &_currentMass->jointSliders().shoulders, 0.0f, 1.0f)) { if(ImGui::SliderFloat("##ShouldersSlider", &_currentMass->jointSliders().shoulders, 0.0f, 1.0f)) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::TableNextRow(); ImGui::TableNextRow();
@ -246,7 +255,7 @@ void SaveTool::drawJointSliders() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##HipsSlider", &_currentMass->jointSliders().hips, 0.0f, 1.0f)) { if(ImGui::SliderFloat("##HipsSlider", &_currentMass->jointSliders().hips, 0.0f, 1.0f)) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::TableNextRow(); ImGui::TableNextRow();
@ -262,12 +271,12 @@ void SaveTool::drawJointSliders() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##UpperArmsSlider", &_currentMass->jointSliders().upperArms, 0.0f, 1.0f, "Upper: %.3f")) { if(ImGui::SliderFloat("##UpperArmsSlider", &_currentMass->jointSliders().upperArms, 0.0f, 1.0f, "Upper: %.3f")) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##LowerArmsSlider", &_currentMass->jointSliders().lowerArms, 0.0f, 1.0f, "Lower: %.3f")) { if(ImGui::SliderFloat("##LowerArmsSlider", &_currentMass->jointSliders().lowerArms, 0.0f, 1.0f, "Lower: %.3f")) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::EndTable(); ImGui::EndTable();
@ -287,12 +296,12 @@ void SaveTool::drawJointSliders() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##UpperLegsSlider", &_currentMass->jointSliders().upperLegs, 0.0f, 1.0f, "Upper: %.3f")) { if(ImGui::SliderFloat("##UpperLegsSlider", &_currentMass->jointSliders().upperLegs, 0.0f, 1.0f, "Upper: %.3f")) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-1.0f); ImGui::SetNextItemWidth(-1.0f);
if(ImGui::SliderFloat("##LowerLegsSlider", &_currentMass->jointSliders().lowerLegs, 0.0f, 1.0f, "Lower: %.3f")) { if(ImGui::SliderFloat("##LowerLegsSlider", &_currentMass->jointSliders().lowerLegs, 0.0f, 1.0f, "Lower: %.3f")) {
joints_dirty = true; _jointsDirty = true;
} }
ImGui::EndTable(); ImGui::EndTable();
@ -302,7 +311,7 @@ void SaveTool::drawJointSliders() {
ImGui::EndTable(); ImGui::EndTable();
} }
if(!joints_dirty) { if(!_jointsDirty) {
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::Button(ICON_FA_SAVE " Save"); ImGui::Button(ICON_FA_SAVE " Save");
ImGui::SameLine(); ImGui::SameLine();
@ -314,12 +323,12 @@ void SaveTool::drawJointSliders() {
if(!_currentMass->writeJointSliders()) { if(!_currentMass->writeJointSliders()) {
_queue.addToast(Toast::Type::Error, "Error: " + Mass::lastError()); _queue.addToast(Toast::Type::Error, "Error: " + Mass::lastError());
} }
joints_dirty = false; _jointsDirty = false;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button(ICON_FA_UNDO " Reset")) { if(ImGui::Button(ICON_FA_UNDO " Reset")) {
_currentMass->getJointSliders(); _currentMass->getJointSliders();
joints_dirty = false; _jointsDirty = false;
} }
} }
} }
@ -329,8 +338,6 @@ void SaveTool::drawFrameStyles() {
return; return;
} }
static bool styles_dirty = false;
for(Int i = 0; i < 4; i++) { for(Int i = 0; i < 4; i++) {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::Text("Slot %d:", i + 1); ImGui::Text("Slot %d:", i + 1);
@ -343,7 +350,7 @@ void SaveTool::drawFrameStyles() {
for(const auto& style : style_names) { for(const auto& style : style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()), _currentMass->frameStyles()[i] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()), _currentMass->frameStyles()[i] == style.first)) {
_currentMass->frameStyles()[i] = style.first; _currentMass->frameStyles()[i] = style.first;
styles_dirty = true; _stylesDirty = true;
} }
} }
@ -353,7 +360,7 @@ void SaveTool::drawFrameStyles() {
ImGui::PopID(); ImGui::PopID();
} }
if(!styles_dirty) { if(!_stylesDirty) {
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::Button(ICON_FA_SAVE " Save"); ImGui::Button(ICON_FA_SAVE " Save");
ImGui::SameLine(); ImGui::SameLine();
@ -365,12 +372,12 @@ void SaveTool::drawFrameStyles() {
if(!_currentMass->writeFrameStyles()) { if(!_currentMass->writeFrameStyles()) {
_queue.addToast(Toast::Type::Error, "Error: " + Mass::lastError()); _queue.addToast(Toast::Type::Error, "Error: " + Mass::lastError());
} }
styles_dirty = false; _stylesDirty = false;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button(ICON_FA_UNDO " Reset")) { if(ImGui::Button(ICON_FA_UNDO " Reset")) {
_currentMass->getFrameStyles(); _currentMass->getFrameStyles();
styles_dirty = false; _stylesDirty = false;
} }
} }
} }
@ -380,13 +387,11 @@ void SaveTool::drawEyeColourPicker() {
return; return;
} }
static bool eye_flare_dirty = false;
if(ImGui::ColorPicker3("##EyeFlarePicker", &_currentMass->eyeFlareColour().x())) { if(ImGui::ColorPicker3("##EyeFlarePicker", &_currentMass->eyeFlareColour().x())) {
eye_flare_dirty = true; _eyeFlareDirty = true;
} }
if(!eye_flare_dirty) { if(!_eyeFlareDirty) {
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::Button(ICON_FA_SAVE " Save"); ImGui::Button(ICON_FA_SAVE " Save");
ImGui::SameLine(); ImGui::SameLine();
@ -398,12 +403,12 @@ void SaveTool::drawEyeColourPicker() {
if(!_currentMass->writeEyeFlareColour()) { if(!_currentMass->writeEyeFlareColour()) {
_queue.addToast(Toast::Type::Error, "Error writing the eye flare colour."); _queue.addToast(Toast::Type::Error, "Error writing the eye flare colour.");
} }
eye_flare_dirty = false; _eyeFlareDirty = false;
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button(ICON_FA_UNDO " Reset")) { if(ImGui::Button(ICON_FA_UNDO " Reset")) {
_currentMass->getEyeFlareColour(); _currentMass->getEyeFlareColour();
eye_flare_dirty = false; _eyeFlareDirty = false;
} }
} }
} }
@ -454,9 +459,6 @@ void SaveTool::drawArmour() {
return; return;
} }
static Containers::StaticArray<38, Int> selected_decals{ValueInit};
static Containers::StaticArray<38, Int> selected_accessories{ValueInit};
for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) { for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) {
ImGui::PushID(i); ImGui::PushID(i);
@ -543,10 +545,10 @@ void SaveTool::drawArmour() {
ImGui::TextUnformatted("Showing/editing decal"); ImGui::TextUnformatted("Showing/editing decal");
for(UnsignedLong j = 0; j < part.demoDecals; j++) { for(UnsignedLong j = 0; j < part.demoDecals; j++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::to_string(j + 1).c_str(), &selected_decals[i], j); ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], j);
} }
drawDecalEditor(part.decals[selected_decals[i]]); drawDecalEditor(part.decals[_selectedArmourDecals[i]]);
ImGui::PopID(); ImGui::PopID();
@ -559,10 +561,10 @@ void SaveTool::drawArmour() {
ImGui::TextUnformatted("Showing/editing accessory"); ImGui::TextUnformatted("Showing/editing accessory");
for(UnsignedInt j = 0; j < part.accessories.size(); j++) { for(UnsignedInt j = 0; j < part.accessories.size(); j++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &selected_accessories[i], j); ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], j);
} }
drawAccessoryEditor(part.accessories[selected_accessories[i]], _currentMass->armourCustomStyles()); drawAccessoryEditor(part.accessories[_selectedArmourAccessories[i]], _currentMass->armourCustomStyles());
ImGui::PopID(); ImGui::PopID();
} }
@ -872,19 +874,17 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::Separator(); ImGui::Separator();
if(ImGui::CollapsingHeader("Weapon parts")) { if(ImGui::CollapsingHeader("Weapon parts")) {
static Int selected_part = 0;
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Viewing/editing part:"); ImGui::TextUnformatted("Viewing/editing part:");
for(Int i = 0; UnsignedLong(i) < weapon.parts.size(); i++) { for(Int i = 0; UnsignedLong(i) < weapon.parts.size(); i++) {
if(UnsignedLong(selected_part) >= weapon.parts.size()) { if(UnsignedLong(_selectedWeaponPart) >= weapon.parts.size()) {
selected_part = 0; _selectedWeaponPart = 0;
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::to_string(i + 1).c_str(), &selected_part, i); ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponPart, i);
} }
auto& part = weapon.parts[selected_part]; auto& part = weapon.parts[_selectedWeaponPart];
ImGui::Text("ID: %i", part.id); ImGui::Text("ID: %i", part.id);
@ -917,16 +917,14 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID("Decal"); ImGui::PushID("Decal");
static Int selected_decal = 0;
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Showing/editing decal"); ImGui::TextUnformatted("Showing/editing decal");
for(UnsignedLong i = 0; i < part.demoDecals; i++) { for(UnsignedLong i = 0; i < part.demoDecals; i++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::to_string(i + 1).c_str(), &selected_decal, i); ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, i);
} }
drawDecalEditor(part.decals[selected_decal]); drawDecalEditor(part.decals[_selectedWeaponDecal]);
ImGui::PopID(); ImGui::PopID();
@ -935,16 +933,14 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID("Accessory"); ImGui::PushID("Accessory");
static Int selected_accessory = 0;
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::TextUnformatted("Showing/editing accessory"); ImGui::TextUnformatted("Showing/editing accessory");
for(UnsignedLong i = 0; i < part.accessories.size(); i++) { for(UnsignedLong i = 0; i < part.accessories.size(); i++) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &selected_accessory, i); ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, i);
} }
drawAccessoryEditor(part.accessories[selected_accessory], weapon.customStyles); drawAccessoryEditor(part.accessories[_selectedWeaponAccessory], weapon.customStyles);
ImGui::PopID(); ImGui::PopID();
} }