Compare commits

..

No commits in common. "7ce726f933432aae5f17f37f446675e034b5d21a" and "ca7b71fb3669969a128f0917591cda4c1ed29c4b" have entirely different histories.

4 changed files with 227 additions and 274 deletions

View file

@ -137,7 +137,6 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
void drawEyeColourPicker(); void drawEyeColourPicker();
void drawCustomFrameStyles(); void drawCustomFrameStyles();
void drawArmour(); void drawArmour();
void drawBLAttachment();
void drawCustomArmourStyles(); void drawCustomArmourStyles();
void drawWeapons(); void drawWeapons();
void drawWeaponCategory(Containers::StringView name, Containers::ArrayView<GameObjects::Weapon> weapons_view, void drawWeaponCategory(Containers::StringView name, Containers::ArrayView<GameObjects::Weapon> weapons_view,
@ -277,10 +276,9 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
bool _bLaunchersDirty = false; bool _bLaunchersDirty = false;
bool _eLaunchersDirty = false; bool _eLaunchersDirty = false;
Containers::Optional<std::size_t> _selectedArmourSlot{Containers::NullOpt};
Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit}; Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit};
Containers::StaticArray<38, std::int32_t> _selectedArmourAccessories{ValueInit}; Containers::StaticArray<38, std::int32_t> _selectedArmourAccessories{ValueInit};
std::uint32_t _selectedBLPlacement = 0; std::int32_t _selectedBLPlacement = 0;
std::int32_t _selectedWeaponPart = 0; std::int32_t _selectedWeaponPart = 0;
std::int32_t _selectedWeaponDecal = 0; std::int32_t _selectedWeaponDecal = 0;
std::int32_t _selectedWeaponAccessory = 0; std::int32_t _selectedWeaponAccessory = 0;

View file

@ -88,7 +88,6 @@ Application::drawMassViewer() {
_jointsDirty = false; _jointsDirty = false;
_stylesDirty = false; _stylesDirty = false;
_eyeFlareDirty = false; _eyeFlareDirty = false;
_selectedArmourSlot = Containers::NullOpt;
_selectedArmourDecals = Containers::StaticArray<38, std::int32_t>{ValueInit}; _selectedArmourDecals = Containers::StaticArray<38, std::int32_t>{ValueInit};
_selectedArmourAccessories = Containers::StaticArray<38, std::int32_t>{ValueInit}; _selectedArmourAccessories = Containers::StaticArray<38, std::int32_t>{ValueInit};
_selectedBLPlacement = 0; _selectedBLPlacement = 0;
@ -127,13 +126,6 @@ Application::drawMassViewer() {
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if(_currentMass->bulletLauncherAttachmentStyle() != GameObjects::BulletLauncherAttachmentStyle::NotFound &&
ImGui::BeginTabItem("Bullet launcher attachment"))
{
drawBLAttachment();
ImGui::EndTabItem();
}
if(ImGui::BeginTabItem("Custom armour styles")) { if(ImGui::BeginTabItem("Custom armour styles")) {
drawCustomArmourStyles(); drawCustomArmourStyles();
ImGui::EndTabItem(); ImGui::EndTabItem();

View file

@ -29,77 +29,63 @@ Application::drawArmour() {
return; return;
} }
constexpr static Containers::StringView slot_labels[] = { if(ImGui::Button(ICON_FA_UNDO_ALT " Reset all")) {
_currentMass->getArmourParts();
_currentMass->getBulletLauncherAttachments();
}
if(!ImGui::BeginChild("##ArmourParts", {}, ImGuiChildFlags_Border)) {
ImGui::EndChild();
return;
}
static Containers::StringView slot_labels[] = {
#define c(enumerator, strenum, name) name, #define c(enumerator, strenum, name) name,
#include "../Maps/ArmourSlots.hpp" #include "../Maps/ArmourSlots.hpp"
#undef c #undef c
}; };
auto labels_view = arrayView(slot_labels); for(std::uint32_t i = 0; i < _currentMass->armourParts().size(); i++) {
ImGui::PushID(int(i));
const static float footer_height_to_reserve = ImGui::GetFrameHeightWithSpacing(); auto& part = _currentMass->armourParts()[i];
ImGui::BeginGroup(); static char header[129] = {'\0'};
if(ImGui::BeginTable("##SlotsTable", 1, std::memset(header, '\0', 129);
ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_BordersInnerH,
{ImGui::GetContentRegionAvail().x * 0.15f, -footer_height_to_reserve}))
{
ImGui::TableSetupColumn("##Slots", ImGuiTableColumnFlags_WidthStretch);
for(std::size_t i = 0; i < labels_view.size(); i++) {
ImGui::TableNextRow();
ImGui::TableNextColumn();
if(ImGui::Selectable(labels_view[i].data(), _selectedArmourSlot && (*_selectedArmourSlot) == i,
ImGuiSelectableFlags_SpanAvailWidth))
{
_selectedArmourSlot = i;
}
}
ImGui::EndTable();
}
if(ImGui::Button(ICON_FA_UNDO_ALT " Reset all")) {
_currentMass->getArmourParts();
}
ImGui::EndGroup();
ImGui::SameLine();
if(!_selectedArmourSlot) {
ImGui::TextUnformatted("No selected armour slot.");
return;
}
auto& part = _currentMass->armourParts()[*_selectedArmourSlot];
ImGui::BeginGroup();
if(ImGui::BeginChild("##ArmourEditor", {0.0f, -footer_height_to_reserve})) {
ImGui::SeparatorText("Part");
if(GameData::armour_sets.find(part.id) != GameData::armour_sets.cend()) { if(GameData::armour_sets.find(part.id) != GameData::armour_sets.cend()) {
ImGui::Text("Set name: %s", GameData::armour_sets.at(part.id).name.data()); std::snprintf(header, 128, "%s: %s###%u",
slot_labels[std::uint32_t(part.slot)].data(),
GameData::armour_sets.at(part.id).name.data(),
std::uint32_t(part.slot));
} }
else { else {
ImGui::Text("Set ID: %u", part.id); std::snprintf(header, 128, "%s: %i###%u",
slot_labels[std::uint32_t(part.slot)].data(),
part.id,
std::uint32_t(part.slot));
} }
ImGui::SameLine(); if(ImGui::CollapsingHeader(header)) {
ImGui::BeginGroup();
if(ImGui::SmallButton("Change")) { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f);
ImGui::OpenPopup("##ArmourPartPopup");
}
if(ImGui::BeginPopup("##ArmourPartPopup")) {
if(ImGui::BeginListBox("##ChangePart")) { if(ImGui::BeginListBox("##ChangePart")) {
if(std::strncmp("Neck", slot_labels[std::uint32_t(part.slot)].data(), 4) != 0) {
for(auto& set : GameData::armour_sets) { for(auto& set : GameData::armour_sets) {
if(part.slot != GameObjects::ArmourPart::Slot::Neck || set.second.neck_compatible) { if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, part.id = set.first;
ImGuiSelectableFlags_SpanAvailWidth)) }
{ }
}
else {
for(auto& set : GameData::armour_sets) {
if(!set.second.neck_compatible) {
continue;
}
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
part.id = set.first; part.id = set.first;
} }
} }
@ -107,79 +93,72 @@ Application::drawArmour() {
ImGui::EndListBox(); ImGui::EndListBox();
} }
ImGui::EndPopup(); ImGui::EndGroup();
}
ImGui::SeparatorText("Styles");
for(std::int32_t i = 0; i < 4; i++) {
drawAlignedText("Slot %d:", i + 1);
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushID(i); ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
if(ImGui::BeginCombo("##Style",
getStyleName(part.styles[i], _currentMass->armourCustomStyles()).data())) ImGui::SameLine();
{
ImGui::BeginGroup();
ImGui::TextUnformatted("Styles:");
for(std::int32_t j = 0; j < 4; j++) {
drawAlignedText("Slot %d:", j + 1);
ImGui::SameLine();
ImGui::PushID(j);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - 2.0f);
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[j], _currentMass->armourCustomStyles()).data())) {
for(const auto& style : GameData::style_names) { for(const auto& style : GameData::style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(), if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(), part.styles[j] == style.first)) {
part.styles[i] == style.first)) part.styles[j] = style.first;
{
part.styles[i] = style.first;
} }
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
ImGui::PopID(); ImGui::PopID();
} }
ImGui::SeparatorText("Decals"); ImGui::EndGroup();
constexpr static float selectable_width = 25.0f; ImGui::Separator();
drawAlignedText("Showing/editing decal:"); ImGui::PushID("Decal");
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
for(std::uint32_t i = 0; i < part.decals.size(); i++) { drawAlignedText("Showing/editing decal");
for(std::uint32_t j = 0; j < part.decals.size(); j++) {
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Selectable(std::to_string(i + 1).c_str(), _selectedArmourDecals[*_selectedArmourSlot] == int(i), ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], int(j));
ImGuiSelectableFlags_None, {selectable_width, 0.0f}))
{
_selectedArmourDecals[*_selectedArmourSlot] = int(i);
} }
if(i != part.decals.size() - 1) {
ImGui::SameLine(); drawDecalEditor(part.decals[_selectedArmourDecals[i]]);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
} ImGui::PopID();
}
ImGui::PopStyleVar();
drawDecalEditor(part.decals[_selectedArmourDecals[*_selectedArmourSlot]]);
if(!part.accessories.isEmpty()) { if(!part.accessories.isEmpty()) {
ImGui::SeparatorText("Accessories"); ImGui::Separator();
drawAlignedText("Showing/editing accessory:"); ImGui::PushID("Accessory");
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
for(std::uint32_t i = 0; i < part.accessories.size(); i++) { drawAlignedText("Showing/editing accessory");
for(std::uint32_t j = 0; j < part.accessories.size(); j++) {
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Selectable((std::string{} + char(i + 65)).c_str(), ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], int(j));
_selectedArmourAccessories[*_selectedArmourSlot] == int(i),
ImGuiSelectableFlags_None, {selectable_width, 0.0f}))
{
_selectedArmourAccessories[*_selectedArmourSlot] = int(i);
}
if(i != part.accessories.size() - 1) {
ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
}
}
ImGui::PopStyleVar();
drawAccessoryEditor(part.accessories[_selectedArmourAccessories[*_selectedArmourSlot]],
_currentMass->armourCustomStyles());
}
} }
ImGui::EndChild(); drawAccessoryEditor(part.accessories[_selectedArmourAccessories[i]], _currentMass->armourCustomStyles());
ImGui::PopID();
}
ImGui::Separator();
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) { if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
_modifiedBySaveTool = true; _modifiedBySaveTool = true;
@ -188,54 +167,36 @@ Application::drawArmour() {
_queue.addToast(Toast::Type::Error, _currentMass->lastError()); _queue.addToast(Toast::Type::Error, _currentMass->lastError());
} }
} }
ImGui::EndGroup();
}
void
Application::drawBLAttachment() {
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
return;
} }
ImGui::PopID();
}
if(_currentMass->bulletLauncherAttachmentStyle() != GameObjects::BulletLauncherAttachmentStyle::NotFound &&
ImGui::CollapsingHeader("Bullet launcher placement"))
{
drawAlignedText("Attachment style:"_s); drawAlignedText("Attachment style:"_s);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::RadioButton("Active one", ImGui::RadioButton("Active one",
_currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOne)) _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOne);
{
_currentMass->bulletLauncherAttachmentStyle() = GameObjects::BulletLauncherAttachmentStyle::ActiveOne;
}
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::RadioButton("Active one per slot", ImGui::RadioButton("Active one per slot",
_currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOnePerSlot)) _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::ActiveOnePerSlot);
{
_currentMass->bulletLauncherAttachmentStyle() = GameObjects::BulletLauncherAttachmentStyle::ActiveOnePerSlot;
}
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::RadioButton("All equipped", ImGui::RadioButton("All equipped",
_currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::AllEquipped)) _currentMass->bulletLauncherAttachmentStyle() == GameObjects::BulletLauncherAttachmentStyle::AllEquipped);
{
_currentMass->bulletLauncherAttachmentStyle() = GameObjects::BulletLauncherAttachmentStyle::ActiveOnePerSlot;
}
ImGui::Separator(); ImGui::Separator();
constexpr static float selectable_width = 25.0f;
drawAlignedText("Launcher slot:"); drawAlignedText("Launcher slot:");
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
for(auto i = 0u; i < _currentMass->bulletLauncherAttachments().size(); i++) {
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Selectable(std::to_string(i).c_str(), _selectedBLPlacement == i, ImGuiSelectableFlags_None, ImGui::RadioButton("1", &_selectedBLPlacement, 0);
{selectable_width, 0.0f}))
{
_selectedBLPlacement = i;
}
if(i != _currentMass->bulletLauncherAttachments().size() - 1) {
ImGui::SameLine(); ImGui::SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); ImGui::RadioButton("2", &_selectedBLPlacement, 1);
} ImGui::SameLine();
} ImGui::RadioButton("3", &_selectedBLPlacement, 2);
ImGui::PopStyleVar(); ImGui::SameLine();
ImGui::RadioButton("4", &_selectedBLPlacement, 3);
auto& placement = _currentMass->bulletLauncherAttachments()[_selectedBLPlacement]; auto& placement = _currentMass->bulletLauncherAttachments()[_selectedBLPlacement];
@ -325,13 +286,15 @@ Application::drawBLAttachment() {
} }
_modifiedBySaveTool = true; _modifiedBySaveTool = true;
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) { if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); }) &&
_modifiedBySaveTool = true; !_currentMass->writeBulletLauncherAttachments())
if(!_currentMass->writeBulletLauncherAttachments()) { {
_modifiedBySaveTool = false; _modifiedBySaveTool = false;
_queue.addToast(Toast::Type::Error, _currentMass->lastError()); _queue.addToast(Toast::Type::Error, _currentMass->lastError());
} }
} }
ImGui::EndChild();
} }
void void

View file

@ -72,7 +72,7 @@ Application::drawAbout() {
if(ImGui::Button("Open in browser")) { if(ImGui::Button("Open in browser")) {
openUri(website); openUri(website);
} }
auto repo = "https://git.williamjcm.ovh/williamjcm/MassBuilderSaveTool"; auto repo = "https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool";
drawAlignedText(ICON_FA_GIT_ALT " %s", repo); drawAlignedText(ICON_FA_GIT_ALT " %s", repo);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {