Application: improve weapon management UI.
This commit is contained in:
parent
a3c2865e68
commit
08de4ef475
2 changed files with 36 additions and 142 deletions
|
@ -140,9 +140,9 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
|
||||||
void drawBLAttachment();
|
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, GameObjects::Weapon::Type category,
|
||||||
bool& dirty, Containers::StringView payload_type,
|
Containers::ArrayView<GameObjects::Weapon> weapons_view,
|
||||||
Containers::StringView payload_tooltip);
|
Containers::StringView payload_type, Containers::StringView payload_tooltip);
|
||||||
void drawWeaponEditor(GameObjects::Weapon& weapon);
|
void drawWeaponEditor(GameObjects::Weapon& weapon);
|
||||||
void drawGlobalStyles();
|
void drawGlobalStyles();
|
||||||
void drawTuning();
|
void drawTuning();
|
||||||
|
@ -280,12 +280,6 @@ class Application: public Platform::Sdl2Application, public efsw::FileWatchListe
|
||||||
bool _jointsDirty = false;
|
bool _jointsDirty = false;
|
||||||
bool _stylesDirty = false;
|
bool _stylesDirty = false;
|
||||||
bool _eyeFlareDirty = false;
|
bool _eyeFlareDirty = false;
|
||||||
bool _meleeDirty = false;
|
|
||||||
bool _shieldsDirty = false;
|
|
||||||
bool _bShootersDirty = false;
|
|
||||||
bool _eShootersDirty = false;
|
|
||||||
bool _bLaunchersDirty = false;
|
|
||||||
bool _eLaunchersDirty = false;
|
|
||||||
|
|
||||||
Containers::Optional<std::size_t> _selectedArmourSlot{Containers::NullOpt};
|
Containers::Optional<std::size_t> _selectedArmourSlot{Containers::NullOpt};
|
||||||
Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit};
|
Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit};
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../GameData/WeaponParts.h"
|
#include "../GameData/WeaponParts.h"
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "../Configuration/Configuration.h"
|
||||||
|
|
||||||
namespace mbst {
|
namespace mbst {
|
||||||
|
|
||||||
|
@ -32,13 +33,11 @@ Application::drawWeapons() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float footer_height_to_reserve = ImGui::GetFrameHeightWithSpacing();
|
|
||||||
|
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
|
|
||||||
if(!ImGui::BeginTable("##WeaponsList", 1,
|
if(!ImGui::BeginTable("##WeaponsList", 1,
|
||||||
ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_BordersInnerH,
|
ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_BordersInnerH,
|
||||||
{ImGui::GetContentRegionAvail().x * 0.2f, -footer_height_to_reserve}))
|
{ImGui::GetContentRegionAvail().x * 0.2f, 0.0f}))
|
||||||
{
|
{
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
return;
|
return;
|
||||||
|
@ -46,118 +45,20 @@ Application::drawWeapons() {
|
||||||
|
|
||||||
ImGui::TableSetupColumn("Weapon");
|
ImGui::TableSetupColumn("Weapon");
|
||||||
|
|
||||||
drawWeaponCategory("Melee weapons", _currentMass->meleeWeapons(), _meleeDirty, "MeleeWeapon", "Melee weapon");
|
drawWeaponCategory("Melee weapons", GameObjects::Weapon::Type::Melee, _currentMass->meleeWeapons(), "MeleeWeapon",
|
||||||
drawWeaponCategory("Shield", _currentMass->shields(), _shieldsDirty, "Shield", "Shield");
|
"Melee weapon");
|
||||||
drawWeaponCategory("Bullet shooters", _currentMass->bulletShooters(), _bShootersDirty, "BShooter", "Bullet shooter");
|
drawWeaponCategory("Shield", GameObjects::Weapon::Type::Shield, _currentMass->shields(), "Shield", "Shield");
|
||||||
drawWeaponCategory("Energy shooters", _currentMass->energyShooters(), _eShootersDirty, "EShooter", "Energy shooter");
|
drawWeaponCategory("Bullet shooters", GameObjects::Weapon::Type::BulletShooter, _currentMass->bulletShooters(),
|
||||||
drawWeaponCategory("Bullet launchers", _currentMass->bulletLaunchers(), _bLaunchersDirty, "BLauncher", "Bullet launcher");
|
"BShooter", "Bullet shooter");
|
||||||
drawWeaponCategory("Energy launchers", _currentMass->energyLaunchers(), _eLaunchersDirty, "ELauncher", "Energy launcher");
|
drawWeaponCategory("Energy shooters", GameObjects::Weapon::Type::EnergyShooter, _currentMass->energyShooters(),
|
||||||
|
"EShooter", "Energy shooter");
|
||||||
|
drawWeaponCategory("Bullet launchers", GameObjects::Weapon::Type::BulletLauncher, _currentMass->bulletLaunchers(),
|
||||||
|
"BLauncher", "Bullet launcher");
|
||||||
|
drawWeaponCategory("Energy launchers", GameObjects::Weapon::Type::EnergyLauncher, _currentMass->energyLaunchers(),
|
||||||
|
"ELauncher", "Energy launcher");
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|
||||||
bool dirty = _meleeDirty || _shieldsDirty || _bShootersDirty || _eShootersDirty || _bLaunchersDirty || _eLaunchersDirty;
|
|
||||||
|
|
||||||
ImGui::BeginDisabled(!dirty);
|
|
||||||
|
|
||||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save order"); })) {
|
|
||||||
if(_meleeDirty) {
|
|
||||||
_modifiedBySaveTool = true;
|
|
||||||
if(!_currentMass->writeMeleeWeapons()) {
|
|
||||||
_modifiedBySaveTool = false;
|
|
||||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_meleeDirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_shieldsDirty) {
|
|
||||||
_modifiedBySaveTool = true;
|
|
||||||
if(!_currentMass->writeShields()) {
|
|
||||||
_modifiedBySaveTool = false;
|
|
||||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_shieldsDirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_bShootersDirty) {
|
|
||||||
_modifiedBySaveTool = true;
|
|
||||||
if(!_currentMass->writeBulletShooters()) {
|
|
||||||
_modifiedBySaveTool = false;
|
|
||||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_bShootersDirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_eShootersDirty) {
|
|
||||||
_modifiedBySaveTool = true;
|
|
||||||
if(_currentMass->writeEnergyShooters()) {
|
|
||||||
_modifiedBySaveTool = false;
|
|
||||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_eShootersDirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_bLaunchersDirty) {
|
|
||||||
_modifiedBySaveTool = true;
|
|
||||||
if(_currentMass->writeBulletLaunchers()) {
|
|
||||||
_modifiedBySaveTool = false;
|
|
||||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_bLaunchersDirty = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_eLaunchersDirty) {
|
|
||||||
_modifiedBySaveTool = true;
|
|
||||||
if(_currentMass->writeEnergyLaunchers()) {
|
|
||||||
_modifiedBySaveTool = false;
|
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndDisabled();
|
|
||||||
|
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
@ -169,7 +70,7 @@ Application::drawWeapons() {
|
||||||
|
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
|
|
||||||
if(!ImGui::BeginChild("##WeaponChild", {0.0f, -footer_height_to_reserve})) {
|
if(!ImGui::BeginChild("##WeaponChild")) {
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -178,9 +79,23 @@ Application::drawWeapons() {
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) {
|
ImGui::EndGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Application::drawWeaponCategory(Containers::StringView name, GameObjects::Weapon::Type category,
|
||||||
|
Containers::ArrayView<GameObjects::Weapon> weapons_view,
|
||||||
|
Containers::StringView payload_type, Containers::StringView payload_tooltip)
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextUnformatted(name.cbegin(), name.cend());
|
||||||
|
|
||||||
|
ImGui::PushID(payload_type.data());
|
||||||
|
|
||||||
|
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_SAVE " Save")) {
|
||||||
_modifiedBySaveTool = true;
|
_modifiedBySaveTool = true;
|
||||||
switch(_currentWeapon->type) {
|
switch(category) {
|
||||||
case GameObjects::Weapon::Type::Melee:
|
case GameObjects::Weapon::Type::Melee:
|
||||||
if(!_currentMass->writeMeleeWeapons()) {
|
if(!_currentMass->writeMeleeWeapons()) {
|
||||||
_modifiedBySaveTool = false;
|
_modifiedBySaveTool = false;
|
||||||
|
@ -225,8 +140,8 @@ Application::drawWeapons() {
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if(ImGui::Button(ICON_FA_UNDO_ALT " Reset weapon category")) {
|
if(ImGui::SmallButton(ICON_FA_UNDO_ALT " Reset")) {
|
||||||
switch(_currentWeapon->type) {
|
switch(category) {
|
||||||
case GameObjects::Weapon::Type::Melee:
|
case GameObjects::Weapon::Type::Melee:
|
||||||
_currentMass->getMeleeWeapons();
|
_currentMass->getMeleeWeapons();
|
||||||
break;
|
break;
|
||||||
|
@ -250,20 +165,6 @@ Application::drawWeapons() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<GameObjects::Weapon> weapons_view,
|
|
||||||
bool& dirty, Containers::StringView payload_type,
|
|
||||||
Containers::StringView payload_tooltip)
|
|
||||||
{
|
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
|
||||||
ImGui::TableNextColumn();
|
|
||||||
ImGui::TextUnformatted(name.cbegin(), name.cend());
|
|
||||||
|
|
||||||
ImGui::PushID(payload_type.data());
|
|
||||||
|
|
||||||
for(std::uint32_t i = 0; i < weapons_view.size(); i++) {
|
for(std::uint32_t i = 0; i < weapons_view.size(); i++) {
|
||||||
auto& weapon = weapons_view[i];
|
auto& weapon = weapons_view[i];
|
||||||
|
|
||||||
|
@ -302,7 +203,6 @@ Application::drawWeaponCategory(Containers::StringView name, Containers::ArrayVi
|
||||||
else {
|
else {
|
||||||
weapons_view[i] = weapons_view[index];
|
weapons_view[i] = weapons_view[index];
|
||||||
}
|
}
|
||||||
dirty = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndDragDropTarget();
|
ImGui::EndDragDropTarget();
|
||||||
|
|
Loading…
Reference in a new issue