2022-03-02 14:43:02 +01:00
|
|
|
// MassBuilderSaveTool
|
2024-03-08 20:25:32 +01:00
|
|
|
// Copyright (C) 2021-2024 Guillaume Jacquemin
|
2022-03-02 14:43:02 +01:00
|
|
|
//
|
|
|
|
// 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 "../Maps/StyleNames.h"
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
#include "Application.h"
|
|
|
|
|
|
|
|
namespace mbst {
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawFrameInfo() {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
|
2022-03-02 14:43:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ImGui::BeginChild("##FrameInfo")) {
|
|
|
|
ImGui::EndChild();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
2023-09-02 14:28:28 +02:00
|
|
|
if(ImGui::BeginChild("##JointSliders",
|
|
|
|
{(ImGui::GetContentRegionAvail().x / 2.0f) - (ImGui::GetStyle().WindowPadding.x / 2.0f),
|
2023-11-29 13:12:18 +01:00
|
|
|
0.0f},
|
|
|
|
ImGuiChildFlags_Border|ImGuiChildFlags_AutoResizeY, ImGuiWindowFlags_MenuBar))
|
2023-09-02 14:28:28 +02:00
|
|
|
{
|
2022-03-02 14:43:02 +01:00
|
|
|
if(ImGui::BeginMenuBar()) {
|
|
|
|
ImGui::TextUnformatted("Joint sliders");
|
2023-11-29 13:51:36 +01:00
|
|
|
drawHelpMarker("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.",
|
|
|
|
static_cast<float>(windowSize().x()) / 4.0f);
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
drawJointSliders();
|
|
|
|
}
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
2023-09-02 14:28:28 +02:00
|
|
|
if(ImGui::BeginChild("##FrameStyles",
|
|
|
|
{(ImGui::GetContentRegionAvail().x / 2.0f) - (ImGui::GetStyle().WindowPadding.x / 2.0f), 0.0f},
|
2023-11-29 13:12:18 +01:00
|
|
|
ImGuiChildFlags_Border, ImGuiWindowFlags_MenuBar))
|
2023-09-02 14:28:28 +02:00
|
|
|
{
|
2022-03-02 14:43:02 +01:00
|
|
|
if(ImGui::BeginMenuBar()) {
|
|
|
|
ImGui::TextUnformatted("Frame styles");
|
|
|
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
drawFrameStyles();
|
|
|
|
}
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
2023-11-29 13:51:36 +01:00
|
|
|
if(ImGui::BeginChild("##EyeFlare", {}, ImGuiChildFlags_Border, ImGuiWindowFlags_MenuBar)) {
|
2022-03-02 14:43:02 +01:00
|
|
|
if(ImGui::BeginMenuBar()) {
|
|
|
|
ImGui::TextUnformatted("Eye flare colour");
|
|
|
|
drawHelpMarker("Right-click the picker for more options.", 250.0f);
|
|
|
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
drawEyeColourPicker();
|
|
|
|
}
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawJointSliders() {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
|
2022-03-02 14:43:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-29 13:51:36 +01:00
|
|
|
ImGui::BeginGroup();
|
|
|
|
drawAlignedText("Neck:");
|
|
|
|
drawAlignedText("Body:");
|
|
|
|
drawAlignedText("Shoulders:");
|
|
|
|
drawAlignedText("Hips:");
|
|
|
|
drawAlignedText("Arms:");
|
|
|
|
drawAlignedText("Legs:");
|
|
|
|
ImGui::EndGroup();
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2023-11-29 13:51:36 +01:00
|
|
|
ImGui::SameLine();
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2023-11-29 13:51:36 +01:00
|
|
|
ImGui::BeginGroup();
|
|
|
|
ImGui::PushItemWidth(-1.0f);
|
|
|
|
if(ImGui::SliderFloat("##NeckSlider", &_currentMass->jointSliders().neck, 0.0f, 1.0f)) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
if(ImGui::SliderFloat("##BodySlider", &_currentMass->jointSliders().body, 0.0f, 1.0f)) {
|
|
|
|
_jointsDirty = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
2023-11-29 13:51:36 +01:00
|
|
|
if(ImGui::SliderFloat("##ShouldersSlider", &_currentMass->jointSliders().shoulders, 0.0f, 1.0f)) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
if(ImGui::SliderFloat("##HipsSlider", &_currentMass->jointSliders().hips, 0.0f, 1.0f)) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth());
|
|
|
|
if(ImGui::SliderFloat("##UpperArmsSlider", &_currentMass->jointSliders().upperArms, 0.0f, 1.0f, "Upper: %.3f")) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
|
|
|
if(ImGui::SliderFloat("##LowerArmsSlider", &_currentMass->jointSliders().lowerArms, 0.0f, 1.0f, "Lower: %.3f")) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth());
|
|
|
|
if(ImGui::SliderFloat("##UpperLegsSlider", &_currentMass->jointSliders().upperLegs, 0.0f, 1.0f, "Upper: %.3f")) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
|
|
|
if(ImGui::SliderFloat("##LowerLegsSlider", &_currentMass->jointSliders().lowerLegs, 0.0f, 1.0f, "Lower: %.3f")) {
|
|
|
|
_jointsDirty = true;
|
|
|
|
}
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::EndGroup();
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
if(!_jointsDirty) {
|
|
|
|
ImGui::BeginDisabled();
|
|
|
|
ImGui::Button(ICON_FA_SAVE " Save");
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Button(ICON_FA_UNDO " Reset");
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeJointSliders()) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = false;
|
2022-03-02 14:43:02 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
|
|
}
|
|
|
|
_jointsDirty = false;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button(ICON_FA_UNDO " Reset")) {
|
|
|
|
_currentMass->getJointSliders();
|
|
|
|
_jointsDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawFrameStyles() {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
|
2022-03-02 14:43:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::int32_t i = 0; i < 4; i++) {
|
2022-03-02 14:43:02 +01:00
|
|
|
drawAlignedText("Slot %d:", i + 1);
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::PushID(i);
|
|
|
|
|
2023-11-29 13:51:36 +01:00
|
|
|
ImGui::PushItemWidth(-1.0f);
|
|
|
|
if(ImGui::BeginCombo("##Style",
|
|
|
|
getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data()))
|
|
|
|
{
|
2024-03-08 19:27:44 +01:00
|
|
|
for(const auto& style : GameData::builtin_style_names) {
|
2023-11-29 13:51:36 +01:00
|
|
|
if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(),
|
|
|
|
_currentMass->frameStyles()[i] == style.first))
|
|
|
|
{
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->frameStyles()[i] = style.first;
|
|
|
|
_stylesDirty = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
2023-11-29 13:51:36 +01:00
|
|
|
ImGui::PopItemWidth();
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!_stylesDirty) {
|
|
|
|
ImGui::BeginDisabled();
|
|
|
|
ImGui::Button(ICON_FA_SAVE " Save");
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Button(ICON_FA_UNDO " Reset");
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeFrameStyles()) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = false;
|
2022-03-02 14:43:02 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
|
|
}
|
|
|
|
_stylesDirty = false;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button(ICON_FA_UNDO " Reset")) {
|
|
|
|
_currentMass->getFrameStyles();
|
|
|
|
_stylesDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawEyeColourPicker() {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
|
2022-03-02 14:43:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ImGui::ColorPicker3("##EyeFlarePicker", &_currentMass->eyeFlareColour().x())) {
|
|
|
|
_eyeFlareDirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!_eyeFlareDirty) {
|
|
|
|
ImGui::BeginDisabled();
|
|
|
|
ImGui::Button(ICON_FA_SAVE " Save");
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Button(ICON_FA_UNDO " Reset");
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeEyeFlareColour()) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = false;
|
2022-03-02 14:43:02 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
|
|
}
|
|
|
|
_eyeFlareDirty = false;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::Button(ICON_FA_UNDO " Reset")) {
|
|
|
|
_currentMass->getEyeFlareColour();
|
|
|
|
_eyeFlareDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawCustomFrameStyles() {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
|
2022-03-02 14:43:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!ImGui::BeginChild("##FrameStyles")) {
|
|
|
|
ImGui::EndChild();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game.");
|
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t i = 0; i < _currentMass->frameCustomStyles().size(); i++) {
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushID(int(i));
|
2024-03-10 15:23:39 +01:00
|
|
|
auto result = drawCustomStyle(_currentMass->frameCustomStyles()[i]);
|
2022-03-02 14:43:02 +01:00
|
|
|
switch(result) {
|
|
|
|
case DCS_ResetStyle:
|
|
|
|
_currentMass->getFrameCustomStyles();
|
|
|
|
break;
|
|
|
|
case DCS_Save:
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeFrameCustomStyle(i)) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = false;
|
2022-03-02 14:43:02 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
|
|
|
|
}
|