Compare commits
No commits in common. "de2ba9ce7ffb2e5fe32d88d86e3a7c8865ebbec9" and "a1c17b713829bcdfa7752b0e38b6b95b1d440168" have entirely different histories.
de2ba9ce7f
...
a1c17b7138
6 changed files with 39 additions and 37 deletions
|
@ -14,6 +14,8 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <Corrade/Containers/Array.h>
|
#include <Corrade/Containers/Array.h>
|
||||||
|
@ -912,18 +914,12 @@ auto Mass::updateAccount(const std::string& new_account) -> bool {
|
||||||
auto account = _mass->at<StringProperty>("Account");
|
auto account = _mass->at<StringProperty>("Account");
|
||||||
if(!account) {
|
if(!account) {
|
||||||
_state = State::Invalid;
|
_state = State::Invalid;
|
||||||
_lastError = "Couldn't find the account property.";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
account->value = new_account;
|
account->value = new_account;
|
||||||
|
|
||||||
if(!_mass->saveToFile()) {
|
return _mass->saveToFile();
|
||||||
_lastError = _mass->lastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array) {
|
void Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array) {
|
||||||
|
|
|
@ -49,11 +49,11 @@ auto MassManager::lastError() -> std::string const& {
|
||||||
return _lastError;
|
return _lastError;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MassManager::hangar(Int hangar) -> Mass& {
|
auto MassManager::hangar(int hangar) -> Mass& {
|
||||||
return _hangars[hangar];
|
return _hangars[hangar];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MassManager::refreshHangar(Int hangar) {
|
void MassManager::refreshHangar(int hangar) {
|
||||||
if(hangar < 0 || hangar >= 32) {
|
if(hangar < 0 || hangar >= 32) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ void MassManager::refreshHangar(Int hangar) {
|
||||||
_hangars[hangar] = Mass{mass_filename};
|
_hangars[hangar] = Mass{mass_filename};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MassManager::importMass(const std::string& staged_fn, Int hangar) -> bool {
|
auto MassManager::importMass(const std::string& staged_fn, int hangar) -> bool {
|
||||||
if(hangar < 0 || hangar >= 32) {
|
if(hangar < 0 || hangar >= 32) {
|
||||||
_lastError = "Hangar out of range in MassManager::importMass()";
|
_lastError = "Hangar out of range in MassManager::importMass()";
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,22 +79,18 @@ auto MassManager::importMass(const std::string& staged_fn, Int hangar) -> bool {
|
||||||
std::string source = Utility::Directory::join(_stagingAreaDirectory, staged_fn);
|
std::string source = Utility::Directory::join(_stagingAreaDirectory, staged_fn);
|
||||||
Utility::Directory::copy(source, source + ".tmp");
|
Utility::Directory::copy(source, source + ".tmp");
|
||||||
|
|
||||||
|
if(!Mass{source + ".tmp"}.updateAccount(_steamId))
|
||||||
{
|
{
|
||||||
Mass mass{source + ".tmp"};
|
_lastError = "The M.A.S.S. file at " + source + " seems to be corrupt.";
|
||||||
if(!mass.updateAccount(_steamId)) {
|
Utility::Directory::rm(source + ".tmp");
|
||||||
_lastError = mass.lastError();
|
return false;
|
||||||
Utility::Directory::rm(source + ".tmp");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dest = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename());
|
if(Utility::Directory::exists(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
|
||||||
|
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()));
|
||||||
if(Utility::Directory::exists(dest)) {
|
|
||||||
Utility::Directory::rm(dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utility::Directory::move(source + ".tmp", dest)) {
|
if(!Utility::Directory::move(source + ".tmp", Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
|
||||||
_lastError = Utility::formatString("Couldn't move {} to hangar {:.2d}", staged_fn, hangar + 1);
|
_lastError = Utility::formatString("Couldn't move {} to hangar {:.2d}", staged_fn, hangar + 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +98,7 @@ auto MassManager::importMass(const std::string& staged_fn, Int hangar) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MassManager::exportMass(Int hangar) -> bool {
|
auto MassManager::exportMass(int hangar) -> bool {
|
||||||
if(hangar < 0 || hangar >= 32) {
|
if(hangar < 0 || hangar >= 32) {
|
||||||
_lastError = "Hangar out of range in MassManager::exportMass()";
|
_lastError = "Hangar out of range in MassManager::exportMass()";
|
||||||
return false;
|
return false;
|
||||||
|
@ -125,7 +121,7 @@ auto MassManager::exportMass(Int hangar) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MassManager::moveMass(Int source, Int destination) -> bool {
|
auto MassManager::moveMass(int source, int destination) -> bool {
|
||||||
if(source < 0 || source >= 32) {
|
if(source < 0 || source >= 32) {
|
||||||
_lastError = "Source hangar out of range.";
|
_lastError = "Source hangar out of range.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -160,14 +156,14 @@ auto MassManager::moveMass(Int source, Int destination) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto MassManager::deleteMass(Int hangar) -> bool {
|
auto MassManager::deleteMass(int hangar) -> bool {
|
||||||
if(hangar < 0 || hangar >= 32) {
|
if(hangar < 0 || hangar >= 32) {
|
||||||
_lastError = "Hangar out of range.";
|
_lastError = "Hangar out of bounds";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
|
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
|
||||||
_lastError = Utility::formatString("Deletion failed: {}", std::strerror(errno));
|
_lastError = "Deletion failed. Maybe the file was already deleted, or it's locked by another application.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +202,7 @@ auto MassManager::deleteStagedMass(const std::string& filename) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Utility::Directory::rm(Utility::Directory::join(_stagingAreaDirectory, filename))) {
|
if(!Utility::Directory::rm(Utility::Directory::join(_stagingAreaDirectory, filename))) {
|
||||||
_lastError = Utility::formatString("{} couldn't be deleted: {}", filename, std::strerror(errno));
|
_lastError = "The file " + filename + " couldn't be deleted for unknown reasons.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "../UESaveFile/Types/IntProperty.h"
|
#include "../UESaveFile/Types/IntProperty.h"
|
||||||
#include "../UESaveFile/Types/StringProperty.h"
|
#include "../UESaveFile/Types/StringProperty.h"
|
||||||
|
|
||||||
|
#include "ResourceIDs.h"
|
||||||
|
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
|
|
||||||
using namespace Corrade;
|
using namespace Corrade;
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "../UESaveFile/UESaveFile.h"
|
#include "../UESaveFile/UESaveFile.h"
|
||||||
|
|
||||||
#include "ResourceIDs.h"
|
|
||||||
|
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|
||||||
enum class ProfileType : UnsignedByte {
|
enum class ProfileType : UnsignedByte {
|
||||||
|
|
|
@ -445,7 +445,8 @@ void SaveTool::drawMassManager() {
|
||||||
std::string file = *(static_cast<std::string*>(payload->Data));
|
std::string file = *(static_cast<std::string*>(payload->Data));
|
||||||
|
|
||||||
if(!_massManager->importMass(file, i)) {
|
if(!_massManager->importMass(file, i)) {
|
||||||
_queue.addToast(Toast::Type::Error, _massManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error importing M.A.S.S.",
|
||||||
|
_massManager->lastError().c_str(), window());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if((payload = ImGui::AcceptDragDropPayload("Mass"))) {
|
else if((payload = ImGui::AcceptDragDropPayload("Mass"))) {
|
||||||
|
@ -459,7 +460,9 @@ void SaveTool::drawMassManager() {
|
||||||
int index = *(static_cast<int*>(payload->Data));
|
int index = *(static_cast<int*>(payload->Data));
|
||||||
|
|
||||||
if(!_massManager->moveMass(index, i)) {
|
if(!_massManager->moveMass(index, i)) {
|
||||||
_queue.addToast(Toast::Type::Error, _massManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
||||||
|
_massManager->lastError().c_str(),
|
||||||
|
window());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,7 +575,9 @@ void SaveTool::drawMassManager() {
|
||||||
int index = *(static_cast<int*>(payload->Data));
|
int index = *(static_cast<int*>(payload->Data));
|
||||||
|
|
||||||
if(!_massManager->exportMass(index)) {
|
if(!_massManager->exportMass(index)) {
|
||||||
_queue.addToast(Toast::Type::Error, _massManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
|
||||||
|
_massManager->lastError().c_str(),
|
||||||
|
window());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +626,8 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(ImGui::Button("Yes")) {
|
if(ImGui::Button("Yes")) {
|
||||||
if(!_massManager->deleteMass(mass_index)) {
|
if(!_massManager->deleteMass(mass_index)) {
|
||||||
_queue.addToast(Toast::Type::Error, _massManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error when deleting M.A.S.S.",
|
||||||
|
_massManager->lastError().c_str(), window());
|
||||||
}
|
}
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
@ -659,7 +665,8 @@ auto SaveTool::drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(ImGui::Button("Yes")) {
|
if(ImGui::Button("Yes")) {
|
||||||
if(!_massManager->deleteStagedMass(filename)) {
|
if(!_massManager->deleteStagedMass(filename)) {
|
||||||
_queue.addToast(Toast::Type::Error, _massManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error when deleting M.A.S.S.",
|
||||||
|
_massManager->lastError().c_str(), window());
|
||||||
}
|
}
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,8 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(ImGui::Button("Yes")) {
|
if(ImGui::Button("Yes")) {
|
||||||
if(!_profileManager->restoreBackup(backup_index)) {
|
if(!_profileManager->restoreBackup(backup_index)) {
|
||||||
_queue.addToast(Toast::Type::Error, _profileManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error when restoring backup",
|
||||||
|
_profileManager->lastError().c_str(), window());
|
||||||
}
|
}
|
||||||
_profileManager->refreshProfiles();
|
_profileManager->refreshProfiles();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
@ -189,7 +190,8 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(ImGui::Button("Yes")) {
|
if(ImGui::Button("Yes")) {
|
||||||
if(!_profileManager->deleteBackup(backup_index)) {
|
if(!_profileManager->deleteBackup(backup_index)) {
|
||||||
_queue.addToast(Toast::Type::Error, _profileManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error when deleting backup",
|
||||||
|
_profileManager->lastError().c_str(), window());
|
||||||
}
|
}
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
@ -376,7 +378,8 @@ auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID {
|
||||||
ImGui::TableSetColumnIndex(1);
|
ImGui::TableSetColumnIndex(1);
|
||||||
if(ImGui::Button("Yes")) {
|
if(ImGui::Button("Yes")) {
|
||||||
if(!_profileManager->deleteProfile(profile_index, delete_builds)) {
|
if(!_profileManager->deleteProfile(profile_index, delete_builds)) {
|
||||||
_queue.addToast(Toast::Type::Error, _profileManager->lastError());
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error when deleting profile",
|
||||||
|
_profileManager->lastError().c_str(), window());
|
||||||
}
|
}
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue