Build viewer/editor #13
2 changed files with 90 additions and 9 deletions
|
@ -260,6 +260,12 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
||||||
Int _selectedWeaponPart{0};
|
Int _selectedWeaponPart{0};
|
||||||
Int _selectedWeaponDecal{0};
|
Int _selectedWeaponDecal{0};
|
||||||
Int _selectedWeaponAccessory{0};
|
Int _selectedWeaponAccessory{0};
|
||||||
|
bool _meleeDirty{false};
|
||||||
|
bool _shieldsDirty{false};
|
||||||
|
bool _bShootersDirty{false};
|
||||||
|
bool _eShootersDirty{false};
|
||||||
|
bool _bLaunchersDirty{false};
|
||||||
|
bool _eLaunchersDirty{false};
|
||||||
|
|
||||||
bool _cheatMode{false};
|
bool _cheatMode{false};
|
||||||
};
|
};
|
||||||
|
|
|
@ -620,7 +620,14 @@ void SaveTool::drawWeapons() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ImGui::BeginTable("##WeaponsList", 1, ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_BordersInnerH, {ImGui::GetContentRegionAvailWidth() * 0.2f, 0.0f})) {
|
const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
||||||
|
|
||||||
|
ImGui::BeginGroup();
|
||||||
|
|
||||||
|
if(!ImGui::BeginTable("##WeaponsList", 1,
|
||||||
|
ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_BordersInnerH,
|
||||||
|
{ImGui::GetContentRegionAvailWidth() * 0.2f, -footer_height_to_reserve}))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +635,7 @@ void SaveTool::drawWeapons() {
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
#define weapcat(header, array, payload_type, payload_tooltip) \
|
#define weapcat(header, array, dirty, payload_type, payload_tooltip) \
|
||||||
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); \
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); \
|
||||||
ImGui::TableNextColumn(); \
|
ImGui::TableNextColumn(); \
|
||||||
ImGui::TextUnformatted(header); \
|
ImGui::TextUnformatted(header); \
|
||||||
|
@ -659,6 +666,7 @@ void SaveTool::drawWeapons() {
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
std::swap(_currentMass->array()[index], _currentMass->array()[i]); \
|
std::swap(_currentMass->array()[index], _currentMass->array()[i]); \
|
||||||
|
(dirty) = true; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
ImGui::EndDragDropTarget(); \
|
ImGui::EndDragDropTarget(); \
|
||||||
|
@ -672,17 +680,85 @@ void SaveTool::drawWeapons() {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
weapcat("Melee weapons", meleeWeapons, "MeleeWeapon", "Melee weapon")
|
weapcat("Melee weapons", meleeWeapons, _meleeDirty, "MeleeWeapon", "Melee weapon")
|
||||||
weapcat("Shield", shields, "Shield", "Shield")
|
weapcat("Shield", shields, _shieldsDirty, "Shield", "Shield")
|
||||||
weapcat("Bullet shooters", bulletShooters, "BShooter", "Bullet shooter")
|
weapcat("Bullet shooters", bulletShooters, _bShootersDirty, "BShooter", "Bullet shooter")
|
||||||
weapcat("Energy shooters", energyShooters, "EShooter", "Energy shooter")
|
weapcat("Energy shooters", energyShooters, _eShootersDirty, "EShooter", "Energy shooter")
|
||||||
weapcat("Bullet launchers", bulletLaunchers, "BLauncher", "Bullet launcher")
|
weapcat("Bullet launchers", bulletLaunchers, _bLaunchersDirty, "BLauncher", "Bullet launcher")
|
||||||
weapcat("Energy launchers", energyLaunchers, "ELauncher", "Energy launcher")
|
weapcat("Energy launchers", energyLaunchers, _eLaunchersDirty, "ELauncher", "Energy launcher")
|
||||||
|
|
||||||
#undef weapcat
|
#undef weapcat
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
|
|
||||||
|
bool dirty = _meleeDirty || _shieldsDirty || _bShootersDirty || _eShootersDirty || _bLaunchersDirty || _eLaunchersDirty;
|
||||||
|
|
||||||
|
if(!dirty) {
|
||||||
|
ImGui::BeginDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||||
|
if(_meleeDirty) {
|
||||||
|
_currentMass->writeMeleeWeapons();
|
||||||
|
_meleeDirty = false;
|
||||||
|
}
|
||||||
|
if(_shieldsDirty) {
|
||||||
|
_currentMass->writeShields();
|
||||||
|
_shieldsDirty = false;
|
||||||
|
}
|
||||||
|
if(_bShootersDirty) {
|
||||||
|
_currentMass->writeBulletShooters();
|
||||||
|
_bShootersDirty = false;
|
||||||
|
}
|
||||||
|
if(_eShootersDirty) {
|
||||||
|
_currentMass->writeEnergyShooters();
|
||||||
|
_eShootersDirty = false;
|
||||||
|
}
|
||||||
|
if(_bLaunchersDirty) {
|
||||||
|
_currentMass->writeBulletLaunchers();
|
||||||
|
_bLaunchersDirty = false;
|
||||||
|
}
|
||||||
|
if(_eLaunchersDirty) {
|
||||||
|
_currentMass->writeEnergyLaunchers();
|
||||||
|
_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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!dirty) {
|
||||||
|
ImGui::EndDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndGroup();
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
if(!current_weapon) {
|
if(!current_weapon) {
|
||||||
|
@ -692,7 +768,6 @@ void SaveTool::drawWeapons() {
|
||||||
|
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
|
|
||||||
const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
|
|
||||||
if(!ImGui::BeginChild("##WeaponChild", {0.0f, -footer_height_to_reserve})) {
|
if(!ImGui::BeginChild("##WeaponChild", {0.0f, -footer_height_to_reserve})) {
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue