Compare commits
No commits in common. "63a8cf70754faa2542a4b04120cb01ec9dba1b03" and "fd3306b175bff5b8d73a1f6b39ce919a9b3ad6e1" have entirely different histories.
63a8cf7075
...
fd3306b175
7 changed files with 13 additions and 52 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <Corrade/Containers/Pair.h>
|
||||
#include <Corrade/Containers/ScopeGuard.h>
|
||||
#include <Corrade/Containers/StringStl.h>
|
||||
#include <Corrade/Utility/Format.h>
|
||||
#include <Corrade/Utility/Path.h>
|
||||
#include <Corrade/Utility/String.h>
|
||||
|
@ -209,7 +210,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id,
|
|||
event.user.code = action;
|
||||
event.user.data1 = Containers::String{Containers::AllocatedInit, filename.c_str()}.release();
|
||||
if(action == efsw::Actions::Moved) {
|
||||
event.user.data2 = Containers::String{Containers::AllocatedInit, old_filename.c_str()}.release();
|
||||
event.user.data2 = Containers::String{old_filename}.release();
|
||||
}
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
|
@ -358,8 +359,8 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
|
|||
std::chrono::milliseconds{5000});
|
||||
_updateAvailable = true;
|
||||
_latestVersion = latest_ver;
|
||||
_releaseLink = release["html_url"].get<std::string>().c_str();
|
||||
_downloadLink = release["assets"][0]["browser_download_url"].get<std::string>().c_str();
|
||||
_releaseLink = to_string(release["html_url"]);
|
||||
_downloadLink = to_string(release["assets"][0]["browser_download_url"]);
|
||||
}
|
||||
else if(latest_ver == current_ver || (current_ver > latest_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) {
|
||||
_queue.addToast(Toast::Type::Success, "The application is already up to date."_s);
|
||||
|
@ -389,7 +390,7 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
|||
index = ((filename[_currentProfile->isDemo() ? 8 : 4] - 0x30) * 10) +
|
||||
(filename[_currentProfile->isDemo() ? 9 : 5] - 0x30);
|
||||
}
|
||||
|
||||
static bool is_moved_after_save = false;
|
||||
if(event.user.code == FileMoved) {
|
||||
old_filename = Containers::String{static_cast<char*>(event.user.data2), std::strlen(static_cast<char*>(event.user.data2)), nullptr};
|
||||
old_index = ((old_filename[_currentProfile->isDemo() ? 8 : 4] - 0x30) * 10) +
|
||||
|
@ -428,15 +429,8 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
|||
_massManager->refreshHangar(index);
|
||||
}
|
||||
else {
|
||||
if(_modifiedBySaveTool && _currentMass->filename() == filename) {
|
||||
auto handle = CreateFileW(Utility::Unicode::widen(Containers::StringView{filename}).data(), GENERIC_READ, 0,
|
||||
nullptr, OPEN_EXISTING, 0, nullptr);
|
||||
if(handle && handle != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(handle);
|
||||
_modifiedBySaveTool = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!is_moved_after_save) {
|
||||
is_moved_after_save = false;
|
||||
_currentMass->setDirty();
|
||||
}
|
||||
}
|
||||
|
@ -444,6 +438,10 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) {
|
|||
break;
|
||||
case FileMoved:
|
||||
if(is_unit) {
|
||||
if(old_filename.hasSuffix(".tmp"_s)) {
|
||||
is_moved_after_save = true;
|
||||
return;
|
||||
}
|
||||
if(old_filename.hasSuffix(".sav"_s)) {
|
||||
_massManager->refreshHangar(index);
|
||||
_massManager->refreshHangar(old_index);
|
||||
|
|
|
@ -277,7 +277,6 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
|
|||
Containers::String _releaseLink;
|
||||
Containers::String _downloadLink;
|
||||
|
||||
bool _modifiedBySaveTool{false};
|
||||
bool _jointsDirty{false};
|
||||
bool _stylesDirty{false};
|
||||
bool _eyeFlareDirty{false};
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <Magnum/ImGuiIntegration/Integration.h>
|
||||
|
||||
#include "../Maps/Accessories.h"
|
||||
|
||||
#define STYLENAMES_DEFINITION
|
||||
#include "../Maps/StyleNames.h"
|
||||
|
||||
|
@ -174,9 +175,7 @@ void SaveTool::drawGlobalStyles() {
|
|||
_currentMass->getGlobalStyles();
|
||||
break;
|
||||
case DCS_Save:
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeGlobalStyle(i)) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -152,9 +152,7 @@ void SaveTool::drawArmour() {
|
|||
ImGui::Separator();
|
||||
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeArmourPart(part.slot)) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
}
|
||||
|
@ -276,11 +274,9 @@ void SaveTool::drawArmour() {
|
|||
ImGui::EndGroup();
|
||||
}
|
||||
|
||||
_modifiedBySaveTool = true;
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); }) &&
|
||||
!_currentMass->writeBulletLauncherAttachments())
|
||||
{
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
}
|
||||
|
@ -309,9 +305,7 @@ void SaveTool::drawCustomArmourStyles() {
|
|||
_currentMass->getArmourCustomStyles();
|
||||
break;
|
||||
case DCS_Save:
|
||||
_modifiedBySaveTool = true;
|
||||
if(_currentMass->writeArmourCustomStyle(i)) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -180,9 +180,7 @@ void SaveTool::drawJointSliders() {
|
|||
}
|
||||
else {
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeJointSliders()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
_jointsDirty = false;
|
||||
|
@ -230,9 +228,7 @@ void SaveTool::drawFrameStyles() {
|
|||
}
|
||||
else {
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeFrameStyles()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
_stylesDirty = false;
|
||||
|
@ -263,9 +259,7 @@ void SaveTool::drawEyeColourPicker() {
|
|||
}
|
||||
else {
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeEyeFlareColour()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
_eyeFlareDirty = false;
|
||||
|
@ -299,9 +293,7 @@ void SaveTool::drawCustomFrameStyles() {
|
|||
_currentMass->getFrameCustomStyles();
|
||||
break;
|
||||
case DCS_Save:
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeFrameCustomStyle(i)) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -57,9 +57,7 @@ void SaveTool::drawWeapons() {
|
|||
|
||||
if(drawUnsafeWidget([]{ return ImGui::Button(ICON_FA_SAVE " Save"); })) {
|
||||
if(_meleeDirty) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeMeleeWeapons()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
else {
|
||||
|
@ -68,9 +66,7 @@ void SaveTool::drawWeapons() {
|
|||
}
|
||||
|
||||
if(_shieldsDirty) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeShields()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
else {
|
||||
|
@ -79,9 +75,7 @@ void SaveTool::drawWeapons() {
|
|||
}
|
||||
|
||||
if(_bShootersDirty) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(!_currentMass->writeBulletShooters()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
else {
|
||||
|
@ -90,9 +84,7 @@ void SaveTool::drawWeapons() {
|
|||
}
|
||||
|
||||
if(_eShootersDirty) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(_currentMass->writeEnergyShooters()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
else {
|
||||
|
@ -101,9 +93,7 @@ void SaveTool::drawWeapons() {
|
|||
}
|
||||
|
||||
if(_bLaunchersDirty) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(_currentMass->writeBulletLaunchers()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
else {
|
||||
|
@ -112,9 +102,7 @@ void SaveTool::drawWeapons() {
|
|||
}
|
||||
|
||||
if(_eLaunchersDirty) {
|
||||
_modifiedBySaveTool = true;
|
||||
if(_currentMass->writeEnergyLaunchers()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
else {
|
||||
|
@ -179,47 +167,40 @@ void SaveTool::drawWeapons() {
|
|||
ImGui::Separator();
|
||||
|
||||
if(drawUnsafeWidget([](){ return ImGui::Button(ICON_FA_SAVE " Save changes to weapon category"); })) {
|
||||
_modifiedBySaveTool = true;
|
||||
switch(_currentWeapon->type) {
|
||||
case WeaponType::Melee:
|
||||
if(!_currentMass->writeMeleeWeapons()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
case WeaponType::Shield:
|
||||
if(!_currentMass->writeShields()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
case WeaponType::BulletShooter:
|
||||
if(!_currentMass->writeBulletShooters()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
case WeaponType::EnergyShooter:
|
||||
if(!_currentMass->writeEnergyShooters()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
case WeaponType::BulletLauncher:
|
||||
if(!_currentMass->writeBulletLaunchers()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
case WeaponType::EnergyLauncher:
|
||||
if(!_currentMass->writeEnergyLaunchers()) {
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, _currentMass->lastError());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_modifiedBySaveTool = false;
|
||||
_queue.addToast(Toast::Type::Error, "Unknown weapon type");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#include "SaveTool/SaveTool.h"
|
||||
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <errhandlingapi.h>
|
||||
#include <synchapi.h>
|
||||
|
|
Loading…
Reference in a new issue