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"
|
|
|
|
|
2024-03-28 12:50:15 +01:00
|
|
|
#include "../GameData/StyleNames.h"
|
|
|
|
#include "../GameData/WeaponParts.h"
|
2022-03-02 14:43:02 +01:00
|
|
|
|
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::drawWeapons() {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid) {
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentWeapon = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-10-29 10:48:31 +01:00
|
|
|
const float footer_height_to_reserve = ImGui::GetFrameHeightWithSpacing();
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
|
|
|
if(!ImGui::BeginTable("##WeaponsList", 1,
|
|
|
|
ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_BordersInnerH,
|
2022-11-25 10:33:55 +01:00
|
|
|
{ImGui::GetContentRegionAvail().x * 0.2f, -footer_height_to_reserve}))
|
2022-03-02 14:43:02 +01:00
|
|
|
{
|
|
|
|
ImGui::EndGroup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::TableSetupColumn("Weapon");
|
|
|
|
|
|
|
|
drawWeaponCategory("Melee weapons", _currentMass->meleeWeapons(), _meleeDirty, "MeleeWeapon", "Melee weapon");
|
|
|
|
drawWeaponCategory("Shield", _currentMass->shields(), _shieldsDirty, "Shield", "Shield");
|
|
|
|
drawWeaponCategory("Bullet shooters", _currentMass->bulletShooters(), _bShootersDirty, "BShooter", "Bullet shooter");
|
|
|
|
drawWeaponCategory("Energy shooters", _currentMass->energyShooters(), _eShootersDirty, "EShooter", "Energy shooter");
|
|
|
|
drawWeaponCategory("Bullet launchers", _currentMass->bulletLaunchers(), _bLaunchersDirty, "BLauncher", "Bullet launcher");
|
|
|
|
drawWeaponCategory("Energy launchers", _currentMass->energyLaunchers(), _eLaunchersDirty, "ELauncher", "Energy launcher");
|
|
|
|
|
|
|
|
ImGui::EndTable();
|
|
|
|
|
|
|
|
bool dirty = _meleeDirty || _shieldsDirty || _bShootersDirty || _eShootersDirty || _bLaunchersDirty || _eLaunchersDirty;
|
|
|
|
|
2023-09-02 14:28:28 +02:00
|
|
|
ImGui::BeginDisabled(!dirty);
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2023-10-29 10:48:31 +01:00
|
|
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save order"); })) {
|
2022-03-02 14:43:02 +01:00
|
|
|
if(_meleeDirty) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeMeleeWeapons()) {
|
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());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_meleeDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_shieldsDirty) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeShields()) {
|
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());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_shieldsDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_bShootersDirty) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeBulletShooters()) {
|
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());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_bShootersDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_eShootersDirty) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(_currentMass->writeEnergyShooters()) {
|
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());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_eShootersDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_bLaunchersDirty) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(_currentMass->writeBulletLaunchers()) {
|
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());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_bLaunchersDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_eLaunchersDirty) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
if(_currentMass->writeEnergyLaunchers()) {
|
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());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
_eLaunchersDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if(ImGui::Button(ICON_FA_UNDO_ALT " Reset")) {
|
|
|
|
if(_meleeDirty) {
|
|
|
|
_currentMass->getMeleeWeapons();
|
|
|
|
_meleeDirty = false;
|
|
|
|
}
|
|
|
|
if(_shieldsDirty) {
|
|
|
|
_currentMass->getShields();
|
|
|
|
_shieldsDirty = false;
|
|
|
|
}
|
|
|
|
if(_bShootersDirty) {
|
|
|
|
_currentMass->getBulletShooters();
|
|
|
|
_bShootersDirty = false;
|
|
|
|
}
|
|
|
|
if(_eShootersDirty) {
|
|
|
|
_currentMass->getEnergyShooters();
|
|
|
|
_eShootersDirty = false;
|
|
|
|
}
|
|
|
|
if(_bLaunchersDirty) {
|
|
|
|
_currentMass->getBulletLaunchers();
|
|
|
|
_bLaunchersDirty = false;
|
|
|
|
}
|
|
|
|
if(_eLaunchersDirty) {
|
|
|
|
_currentMass->getEnergyLaunchers();
|
|
|
|
_eLaunchersDirty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-02 14:28:28 +02:00
|
|
|
ImGui::EndDisabled();
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if(!_currentWeapon) {
|
|
|
|
ImGui::TextUnformatted("No weapon selected.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
|
|
|
|
if(!ImGui::BeginChild("##WeaponChild", {0.0f, -footer_height_to_reserve})) {
|
|
|
|
ImGui::EndChild();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawWeaponEditor(*_currentWeapon);
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
|
|
|
|
if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) {
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = true;
|
2022-03-02 14:43:02 +01:00
|
|
|
switch(_currentWeapon->type) {
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::Melee:
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeMeleeWeapons()) {
|
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;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::Shield:
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeShields()) {
|
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;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::BulletShooter:
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeBulletShooters()) {
|
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;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::EnergyShooter:
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeEnergyShooters()) {
|
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;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::BulletLauncher:
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeBulletLaunchers()) {
|
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;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::EnergyLauncher:
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!_currentMass->writeEnergyLaunchers()) {
|
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:
|
2022-03-22 09:59:30 +01:00
|
|
|
_modifiedBySaveTool = false;
|
2022-03-02 14:43:02 +01:00
|
|
|
_queue.addToast(Toast::Type::Error, "Unknown weapon type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) {
|
|
|
|
switch(_currentWeapon->type) {
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::Melee:
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->getMeleeWeapons();
|
|
|
|
break;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::Shield:
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->getShields();
|
|
|
|
break;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::BulletShooter:
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->getBulletShooters();
|
|
|
|
break;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::EnergyShooter:
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->getEnergyShooters();
|
|
|
|
break;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::BulletLauncher:
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->getBulletLaunchers();
|
|
|
|
break;
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::EnergyLauncher:
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentMass->getEnergyLaunchers();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_queue.addToast(Toast::Type::Error, "Unknown weapon type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndGroup();
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<GameObjects::Weapon> weapons_view, bool& dirty,
|
2022-12-03 16:49:39 +01:00
|
|
|
Containers::StringView payload_type, Containers::StringView payload_tooltip)
|
2022-03-02 14:43:02 +01:00
|
|
|
{
|
|
|
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
|
|
|
ImGui::TableNextColumn();
|
2024-02-08 11:08:14 +01:00
|
|
|
ImGui::TextUnformatted(name.cbegin(), name.cend());
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
ImGui::PushID(payload_type.data());
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::uint32_t i = 0; i < weapons_view.size(); i++) {
|
2022-03-02 14:43:02 +01:00
|
|
|
auto& weapon = weapons_view[i];
|
|
|
|
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::PushID(int(i));
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
if(ImGui::Selectable(weapon.name.data(), _currentWeapon == &weapon)) {
|
2022-03-02 14:43:02 +01:00
|
|
|
_currentWeapon = &weapon;
|
|
|
|
}
|
|
|
|
if(ImGui::BeginDragDropSource()) {
|
2022-12-05 11:32:18 +01:00
|
|
|
ImGui::SetDragDropPayload(payload_type.data(), &i, sizeof(std::uint32_t));
|
2022-03-02 14:43:02 +01:00
|
|
|
if(ImGui::GetIO().KeyCtrl) {
|
2022-03-04 21:18:55 +01:00
|
|
|
ImGui::Text("%s %i - %s (copy)", payload_tooltip.data(), i + 1, weapon.name.data());
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
else {
|
2022-03-04 21:18:55 +01:00
|
|
|
ImGui::Text("%s %i - %s", payload_tooltip.data(), i + 1, weapon.name.data());
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
ImGui::EndDragDropSource();
|
|
|
|
}
|
|
|
|
if(ImGui::BeginDragDropTarget()) {
|
2022-03-04 21:18:55 +01:00
|
|
|
if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(payload_type.data())) {
|
2022-03-02 14:43:02 +01:00
|
|
|
int index = *static_cast<int*>(payload->Data);
|
|
|
|
|
|
|
|
if(!ImGui::GetIO().KeyCtrl) {
|
|
|
|
if(_currentWeapon == &weapons_view[index]) {
|
|
|
|
_currentWeapon = &weapons_view[i];
|
|
|
|
}
|
|
|
|
else if (_currentWeapon == &weapons_view[i]) {
|
|
|
|
_currentWeapon = &weapons_view[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
std::swap(weapons_view[index], weapons_view[i]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
weapons_view[i] = weapons_view[index];
|
|
|
|
}
|
|
|
|
dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
|
2022-11-21 20:47:09 +01:00
|
|
|
if(weapon.attached) {
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, 0x1F008CFFu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
|
2022-12-03 16:49:39 +01:00
|
|
|
void
|
2023-11-29 12:33:26 +01:00
|
|
|
Application::drawWeaponEditor(GameObjects::Weapon& weapon) {
|
|
|
|
if(!_currentMass || _currentMass->state() != GameObjects::Mass::State::Valid || !_currentWeapon) {
|
2022-03-02 14:43:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
static Containers::StringView labels[] {
|
|
|
|
#define c(enumerator, strenum, name) name,
|
|
|
|
#include "../Maps/WeaponTypes.hpp"
|
|
|
|
#undef c
|
2022-03-02 14:43:02 +01:00
|
|
|
};
|
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
drawAlignedText("%s: %s", labels[std::uint32_t(weapon.type)].data(), weapon.name.data());
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
static Containers::StaticArray<33, char> name_buf{ValueInit};
|
|
|
|
if(ImGui::Button(ICON_FA_EDIT " Rename")) {
|
|
|
|
for(auto& c : name_buf) {
|
|
|
|
c = '\0';
|
|
|
|
}
|
2022-03-04 21:18:55 +01:00
|
|
|
std::strncpy(name_buf.data(), weapon.name.data(), 32);
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::OpenPopup("name_edit");
|
|
|
|
}
|
|
|
|
if(drawRenamePopup(name_buf)) {
|
|
|
|
weapon.name = name_buf.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
drawAlignedText("Equipped:");
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
if(weapon.type != GameObjects::Weapon::Type::Shield) {
|
2022-03-02 14:43:02 +01:00
|
|
|
drawAlignedText("Damage type:");
|
|
|
|
}
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
if(weapon.type == GameObjects::Weapon::Type::Melee) {
|
2022-03-02 14:43:02 +01:00
|
|
|
drawAlignedText("Dual-wield:");
|
|
|
|
|
|
|
|
drawAlignedText("Custom effect mode:");
|
|
|
|
|
|
|
|
drawAlignedText("Custom effect colour:");
|
|
|
|
}
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
ImGui::BeginGroup();
|
|
|
|
ImGui::Checkbox("##EquippedCheckbox", &weapon.attached);
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
if(weapon.type != GameObjects::Weapon::Type::Shield) {
|
|
|
|
if(weapon.type == GameObjects::Weapon::Type::Melee &&
|
|
|
|
ImGui::RadioButton("Physical##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Physical))
|
2022-03-02 14:43:02 +01:00
|
|
|
{
|
2023-11-29 12:33:26 +01:00
|
|
|
weapon.damageType = GameObjects::Weapon::DamageType::Physical;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
else if((weapon.type == GameObjects::Weapon::Type::BulletShooter || weapon.type == GameObjects::Weapon::Type::BulletLauncher) &&
|
|
|
|
ImGui::RadioButton("Piercing##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Piercing))
|
2022-03-02 14:43:02 +01:00
|
|
|
{
|
2023-11-29 12:33:26 +01:00
|
|
|
weapon.damageType = GameObjects::Weapon::DamageType::Piercing;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
else if((weapon.type == GameObjects::Weapon::Type::EnergyShooter || weapon.type == GameObjects::Weapon::Type::EnergyLauncher) &&
|
|
|
|
ImGui::RadioButton("Plasma##NoElement", weapon.damageType == GameObjects::Weapon::DamageType::Plasma))
|
2022-03-02 14:43:02 +01:00
|
|
|
{
|
2023-11-29 12:33:26 +01:00
|
|
|
weapon.damageType = GameObjects::Weapon::DamageType::Plasma;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2023-11-29 12:33:26 +01:00
|
|
|
if(ImGui::RadioButton("Heat##Heat", weapon.damageType == GameObjects::Weapon::DamageType::Heat)) {
|
|
|
|
weapon.damageType = GameObjects::Weapon::DamageType::Heat;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2023-11-29 12:33:26 +01:00
|
|
|
if(ImGui::RadioButton("Freeze##Freeze", weapon.damageType == GameObjects::Weapon::DamageType::Freeze)) {
|
|
|
|
weapon.damageType = GameObjects::Weapon::DamageType::Freeze;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2023-11-29 12:33:26 +01:00
|
|
|
if(ImGui::RadioButton("Shock##Shock", weapon.damageType == GameObjects::Weapon::DamageType::Shock)) {
|
|
|
|
weapon.damageType = GameObjects::Weapon::DamageType::Shock;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
if(weapon.type == GameObjects::Weapon::Type::Melee) {
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::Checkbox("##DualWield", &weapon.dualWield);
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
if(ImGui::RadioButton("Default##Default", weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Default)) {
|
|
|
|
weapon.effectColourMode = GameObjects::Weapon::EffectColourMode::Default;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2023-11-29 12:33:26 +01:00
|
|
|
if(ImGui::RadioButton("Custom##Custom", weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Custom)) {
|
|
|
|
weapon.effectColourMode = GameObjects::Weapon::EffectColourMode::Custom;
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
bool custom_effect = (weapon.effectColourMode == GameObjects::Weapon::EffectColourMode::Custom);
|
2022-03-02 14:43:02 +01:00
|
|
|
if(!custom_effect) {
|
|
|
|
ImGui::BeginDisabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::ColorEdit3("##CustomEffectColourPicker", &weapon.effectColour.x(), ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_Float);
|
2022-04-04 09:22:12 +02:00
|
|
|
ImGui::SameLine();
|
|
|
|
drawHelpMarker("Click the coloured square for the full picker.");
|
2022-03-02 14:43:02 +01:00
|
|
|
|
|
|
|
if(!custom_effect) {
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndGroup();
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
if(ImGui::CollapsingHeader("Weapon parts")) {
|
|
|
|
drawAlignedText("Viewing/editing part:");
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::int32_t i = 0; std::size_t(i) < weapon.parts.size(); i++) {
|
|
|
|
if(std::size_t(_selectedWeaponPart) >= weapon.parts.size()) {
|
2022-03-02 14:43:02 +01:00
|
|
|
_selectedWeaponPart = 0;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
2022-04-08 14:12:56 +02:00
|
|
|
ImGui::RadioButton(std::to_string(i).c_str(), &_selectedWeaponPart, i);
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto& part = weapon.parts[_selectedWeaponPart];
|
|
|
|
|
2022-12-05 11:32:18 +01:00
|
|
|
const auto* map = [this, &weapon]()-> const std::map<std::int32_t, Containers::StringView>* {
|
2022-04-15 11:05:01 +02:00
|
|
|
switch(weapon.type) {
|
2023-11-29 12:33:26 +01:00
|
|
|
case GameObjects::Weapon::Type::Melee:
|
|
|
|
return _selectedWeaponPart == 0 ? &GameData::melee_grips : &GameData::melee_assaulters;
|
|
|
|
case GameObjects::Weapon::Type::Shield:
|
|
|
|
return _selectedWeaponPart == 0 ? &GameData::shield_handles : &GameData::shield_shells;
|
|
|
|
case GameObjects::Weapon::Type::BulletShooter:
|
|
|
|
return _selectedWeaponPart == 0 ? &GameData::bshooter_triggers : &GameData::bshooter_barrels;
|
|
|
|
case GameObjects::Weapon::Type::EnergyShooter:
|
|
|
|
return _selectedWeaponPart == 0 ? &GameData::eshooter_triggers : &GameData::eshooter_busters;
|
|
|
|
case GameObjects::Weapon::Type::BulletLauncher:
|
|
|
|
return _selectedWeaponPart == 0 ? &GameData::blauncher_pods : &GameData::blauncher_projectiles;
|
|
|
|
case GameObjects::Weapon::Type::EnergyLauncher:
|
|
|
|
return _selectedWeaponPart == 0 ? &GameData::elauncher_generators : &GameData::elauncher_pods;
|
2022-04-15 11:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}();
|
|
|
|
|
2022-11-21 20:47:09 +01:00
|
|
|
if(!map) {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-15 11:05:01 +02:00
|
|
|
|
|
|
|
if(map->find(part.id) != map->cend()) {
|
2024-02-08 11:08:14 +01:00
|
|
|
ImGui::TextUnformatted(map->at(part.id).cbegin(), map->at(part.id).cend());
|
2022-04-15 11:05:01 +02:00
|
|
|
}
|
|
|
|
else if(part.id == -1) {
|
|
|
|
ImGui::TextUnformatted("<none>");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
ImGui::Text("ID: %i", part.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!map->empty()) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::SmallButton("Change")) {
|
|
|
|
ImGui::OpenPopup("##WeaponPartPopup");
|
|
|
|
}
|
|
|
|
if(ImGui::BeginPopup("##WeaponPartPopup")) {
|
|
|
|
if(ImGui::BeginListBox("##WeaponParts")) {
|
|
|
|
for(const auto& mapped_part : *map) {
|
|
|
|
if(ImGui::Selectable(mapped_part.second.data(), mapped_part.first == part.id)) {
|
|
|
|
part.id = mapped_part.first;
|
|
|
|
}
|
2022-11-25 09:43:32 +01:00
|
|
|
if(mapped_part.first == part.id) {
|
|
|
|
ImGui::SetItemDefaultFocus();
|
|
|
|
}
|
2022-04-15 11:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndListBox();
|
|
|
|
}
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-29 12:33:26 +01:00
|
|
|
if(weapon.type == GameObjects::Weapon::Type::Shield ||
|
|
|
|
(weapon.type == GameObjects::Weapon::Type::BulletLauncher && _selectedWeaponPart != 0))
|
2022-04-08 14:33:17 +02:00
|
|
|
{
|
|
|
|
ImGui::SameLine();
|
|
|
|
if(ImGui::SmallButton("Unequip")) {
|
|
|
|
part.id = -1;
|
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
if(weapon.type == GameObjects::Weapon::Type::Shield && _selectedWeaponPart == 0) {
|
2022-04-08 14:33:17 +02:00
|
|
|
drawTooltip("This will make the whole shield and its accessories invisible.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
drawTooltip("This will make accessories invisible as well.");
|
|
|
|
}
|
|
|
|
}
|
2022-03-02 14:43:02 +01:00
|
|
|
|
2023-11-29 13:12:18 +01:00
|
|
|
if(ImGui::BeginChild("##PartDetails", {}, ImGuiChildFlags_Border)) {
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::TextUnformatted("Styles:");
|
|
|
|
|
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);
|
|
|
|
|
2022-03-04 21:18:55 +01:00
|
|
|
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles).data())) {
|
2024-03-08 19:27:44 +01:00
|
|
|
for(const auto& style: GameData::builtin_style_names) {
|
2022-03-04 21:18:55 +01:00
|
|
|
if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles).data(),
|
2022-03-02 14:43:02 +01:00
|
|
|
part.styles[i] == style.first)) {
|
|
|
|
part.styles[i] = style.first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
ImGui::PushID("Decal");
|
|
|
|
|
|
|
|
drawAlignedText("Showing/editing decal");
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::size_t i = 0; i < part.decals.size(); i++) {
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::SameLine();
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, int(i));
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
drawDecalEditor(part.decals[_selectedWeaponDecal]);
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
|
2023-10-29 11:31:21 +01:00
|
|
|
if(!part.accessories.isEmpty()) {
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
ImGui::PushID("Accessory");
|
|
|
|
|
|
|
|
drawAlignedText("Showing/editing accessory");
|
2022-12-05 11:32:18 +01:00
|
|
|
for(std::size_t i = 0; i < part.accessories.size(); i++) {
|
2022-03-02 14:43:02 +01:00
|
|
|
ImGui::SameLine();
|
2022-11-21 20:47:09 +01:00
|
|
|
ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, int(i));
|
2022-03-02 14:43:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
drawAccessoryEditor(part.accessories[_selectedWeaponAccessory], weapon.customStyles);
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
}
|
2023-11-29 12:33:26 +01:00
|
|
|
|
|
|
|
}
|