Skip to content

Commit 188c94f

Browse files
authored
Merge pull request #43 from oblivioncth/dev
Merge to master for v0.7.4
2 parents 870b319 + ac077d7 commit 188c94f

File tree

16 files changed

+218
-107
lines changed

16 files changed

+218
-107
lines changed

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ cmake_minimum_required(VERSION 3.24.0...3.26.0)
66
# Project
77
# NOTE: DON'T USE TRAILING ZEROS IN VERSIONS
88
project(FIL
9-
VERSION 0.7.3.1
9+
VERSION 0.7.4
1010
LANGUAGES CXX
1111
DESCRIPTION "Flashpoint Importer for Launchers"
1212
)
1313

1414
# Get helper scripts
1515
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchOBCMake.cmake)
16-
fetch_ob_cmake("v0.3.3")
16+
fetch_ob_cmake("v0.3.4")
1717

1818
# Initialize project according to standard rules
1919
include(OB/Project)
@@ -64,18 +64,18 @@ set(FIL_QX_COMPONENTS
6464

6565
include(OB/FetchQx)
6666
ob_fetch_qx(
67-
REF "v0.5.5.1"
67+
REF "v0.5.6"
6868
COMPONENTS
6969
${FIL_QX_COMPONENTS}
7070
)
7171

7272
# Fetch libfp (build and import from source)
7373
include(OB/Fetchlibfp)
74-
ob_fetch_libfp("v0.5.1.1")
74+
ob_fetch_libfp("v0.5.2")
7575

7676
# Fetch CLIFp (build and import from source)
7777
include(OB/FetchCLIFp)
78-
ob_fetch_clifp("v0.9.9")
78+
ob_fetch_clifp("v0.9.10")
7979

8080
# TODO: The shared build of this is essentially useless as only the CLIFp executable
8181
# is deployed, which only works if it's statically linked. There isn't a simple way

app/src/clifp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
//-Class Functions--------------------------------------------------------------------------------------------
1515
//Public:
16-
QString CLIFp::standardCLIFpPath(const Fp::Install& fpInstall) { return fpInstall.fullPath() + '/' + EXE_NAME; }
16+
QString CLIFp::standardCLIFpPath(const Fp::Install& fpInstall) { return fpInstall.dir().absoluteFilePath(EXE_NAME); }
1717

1818
bool CLIFp::hasCLIFp(const Fp::Install& fpInstall)
1919
{

app/src/frontend/attractmode/am-install.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,6 @@ Qx::Error Install::populateExistingDocs()
118118
return Qx::Error();
119119
}
120120

121-
QString Install::translateDocName(const QString& originalName, Fe::DataDoc::Type type) const
122-
{
123-
// Perform general kosherization
124-
QString translatedName = Qx::kosherizeFileName(originalName);
125-
126-
// Prefix platforms/playlists
127-
if(type == Fe::DataDoc::Type::Platform)
128-
translatedName.prepend(PLATFORM_TAG_PREFIX);
129-
else if(type == Fe::DataDoc::Type::Playlist)
130-
translatedName.prepend(PLAYLIST_TAG_PREFIX);
131-
132-
return translatedName;
133-
}
134-
135121
QString Install::executableSubPath() const { return MAIN_EXE_PATH; }
136122

137123
QString Install::imageDestinationPath(Fp::ImageType imageType, const Fe::Game* game) const
@@ -350,6 +336,20 @@ QString Install::versionString() const
350336
return u"UNKNOWN VERSION"_s;
351337
}
352338

339+
QString Install::translateDocName(const QString& originalName, Fe::DataDoc::Type type) const
340+
{
341+
// Perform general kosherization
342+
QString translatedName = Qx::kosherizeFileName(originalName);
343+
344+
// Prefix platforms/playlists
345+
if(type == Fe::DataDoc::Type::Platform)
346+
translatedName.prepend(PLATFORM_TAG_PREFIX);
347+
else if(type == Fe::DataDoc::Type::Playlist)
348+
translatedName.prepend(PLAYLIST_TAG_PREFIX);
349+
350+
return translatedName;
351+
}
352+
353353
Qx::Error Install::preImport(const ImportDetails& details)
354354
{
355355
//-Ensure that required directories exist----------------------------------------------------------------

app/src/frontend/attractmode/am-install.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class Install : public Fe::Install
9090
// Install management
9191
void nullify() override;
9292
Qx::Error populateExistingDocs() override;
93-
QString translateDocName(const QString& originalName, Fe::DataDoc::Type type) const override;
9493

9594
// Info
9695
QString executableSubPath() const override;
@@ -119,6 +118,7 @@ class Install : public Fe::Install
119118
QString name() const override;
120119
QList<Fe::ImageMode> preferredImageModeOrder() const override;
121120
QString versionString() const override;
121+
QString translateDocName(const QString& originalName, Fe::DataDoc::Type type) const override;
122122

123123
// Import stage notifier hooks
124124
Qx::Error preImport(const ImportDetails& details) override;

app/src/frontend/fe-data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ PlaylistDoc::PlaylistDoc(Install* const parent, const QString& docPath, QString
331331

332332
//-Instance Functions--------------------------------------------------------------------------------------------------
333333
//Private:
334-
DataDoc::Type PlaylistDoc::type() const { return Type::Platform; }
334+
DataDoc::Type PlaylistDoc::type() const { return Type::Playlist; }
335335

336336
//===============================================================================================================
337337
// PlaylistDoc::Reader

app/src/frontend/fe-install.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ void Install::nullify()
5151
InstallFoundation::nullify();
5252
}
5353

54-
QString Install::translateDocName(const QString& originalName, DataDoc::Type type) const
55-
{
56-
// Redundant with base version, but here to make it clear its part of the main Install interface
57-
return InstallFoundation::translateDocName(originalName, type);
58-
}
5954

6055
//Public:
6156
void Install::softReset()
@@ -106,6 +101,12 @@ Qx::Error Install::postImageProcessing() { return {}; }
106101
Qx::Error Install::prePlaylistsImport() { return {}; }
107102
Qx::Error Install::postPlaylistsImport() { return {}; }
108103

104+
QString Install::translateDocName(const QString& originalName, DataDoc::Type type) const
105+
{
106+
// Redundant with base version, but here to make it clear its part of the main Install interface
107+
return InstallFoundation::translateDocName(originalName, type);
108+
}
109+
109110
Fe::DocHandlingError Install::checkoutPlatformDoc(std::unique_ptr<PlatformDoc>& returnBuffer, const QString& name)
110111
{
111112
// Translate to frontend doc name

app/src/frontend/fe-install.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class Install : public InstallFoundation
6262
// Install management
6363
virtual void nullify() override;
6464
virtual Qx::Error populateExistingDocs() override = 0;
65-
virtual QString translateDocName(const QString& originalName, DataDoc::Type type) const override;
6665

6766
// Doc Handling
6867
virtual std::shared_ptr<PlatformDoc::Reader> preparePlatformDocCheckout(std::unique_ptr<PlatformDoc>& platformDoc, const QString& translatedName) = 0;
@@ -94,6 +93,7 @@ class Install : public InstallFoundation
9493
virtual Qx::Error postPlaylistsImport();
9594

9695
// Doc handling
96+
virtual QString translateDocName(const QString& originalName, DataDoc::Type type) const override;
9797
Fe::DocHandlingError checkoutPlatformDoc(std::unique_ptr<PlatformDoc>& returnBuffer, const QString& name);
9898
Fe::DocHandlingError checkoutPlaylistDoc(std::unique_ptr<PlaylistDoc>& returnBuffer, const QString& name);
9999
Fe::DocHandlingError commitPlatformDoc(std::unique_ptr<PlatformDoc> platformDoc);

app/src/frontend/fe-installfoundation.cpp

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void InstallFoundation::softReset()
126126
{
127127
mRevertableFilePaths.clear();
128128
mModifiedDocuments.clear();
129+
mDeletedDocuments.clear();
129130
mLeasedDocuments.clear();
130131
mImportDetails.reset();
131132
}
@@ -170,13 +171,16 @@ Fe::DocHandlingError InstallFoundation::checkoutDataDocument(DataDoc* docToOpen,
170171

171172
Fe::DocHandlingError InstallFoundation::commitDataDocument(DataDoc* docToSave, std::shared_ptr<DataDoc::Writer> docWriter)
172173
{
173-
// Create backup and add to modified list if required
174-
if(!mModifiedDocuments.contains(docToSave->identifier()))
174+
DataDoc::Identifier id = docToSave->identifier();
175+
bool wasDeleted = mDeletedDocuments.contains(id);
176+
bool wasModified = mDeletedDocuments.contains(id);
177+
bool wasUntouched = !wasDeleted && !wasModified;
178+
179+
// Handle backup/revert prep
180+
if(wasUntouched)
175181
{
176-
// Insert
177182
QString docPath = docToSave->path();
178-
mModifiedDocuments.insert(docToSave->identifier());
179-
mRevertableFilePaths.append(docPath);
183+
mRevertableFilePaths.append(docPath); // Correctly handles if doc ends up deleted
180184

181185
// Backup
182186
if(QFile::exists(docPath))
@@ -190,28 +194,40 @@ Fe::DocHandlingError InstallFoundation::commitDataDocument(DataDoc* docToSave, s
190194
}
191195

192196
if(!QFile::copy(docPath, backupPath))
193-
return Fe::DocHandlingError(*docToSave, Fe::DocHandlingError::CantRemoveBackup);
197+
return Fe::DocHandlingError(*docToSave, Fe::DocHandlingError::CantCreateBackup);
194198
}
195199
}
196200

197-
// Write to file if it contains content
198-
Fe::DocHandlingError saveWriteError;
201+
// Error State
202+
Fe::DocHandlingError commitError;
203+
204+
// Handle modification
199205
if(!docToSave->isEmpty())
200-
saveWriteError = docWriter->writeOutOf();
206+
{
207+
mModifiedDocuments.insert(id);
208+
if(wasDeleted)
209+
mDeletedDocuments.remove(id);
201210

202-
// Set document permissions
203-
allowUserWriteOnFile(docToSave->path());
211+
commitError = docWriter->writeOutOf();
212+
allowUserWriteOnFile(docToSave->path());
213+
}
214+
else // Handle deletion
215+
{
216+
mDeletedDocuments.insert(id);
217+
if(wasModified)
218+
mModifiedDocuments.remove(id);
219+
}
204220

205221
// Remove handle reservation
206222
mLeasedDocuments.remove(docToSave->identifier());
207223

208224
// Return write status and let document ptr auto delete
209-
return saveWriteError;
225+
return commitError;
210226
}
211227

212228
QList<QString> InstallFoundation::modifiedPlatforms() const { return modifiedDataDocs(DataDoc::Type::Platform); }
213229

214-
QList<QString> InstallFoundation::modifiedPlaylists() const { return modifiedDataDocs(DataDoc::Type::Platform);}
230+
QList<QString> InstallFoundation::modifiedPlaylists() const { return modifiedDataDocs(DataDoc::Type::Playlist);}
215231

216232
//Public:
217233
bool InstallFoundation::isValid() const { return mValid; }

app/src/frontend/fe-installfoundation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class InstallFoundation
108108
// Document tracking
109109
QSet<DataDoc::Identifier> mExistingDocuments;
110110
QSet<DataDoc::Identifier> mModifiedDocuments;
111+
QSet<DataDoc::Identifier> mDeletedDocuments;
111112
QSet<DataDoc::Identifier> mLeasedDocuments;
112113

113114
// Backup/Deletion tracking

app/src/frontend/launchbox/lb-data.cpp

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ void PlaylistDoc::Reader::parsePlaylistGame()
720720
existingPlaylistGame->setLBDatabaseId(optIdx.value_or(0));
721721
}
722722
else
723-
static_cast<PlaylistDoc*>(mTargetDocument)->mLaunchBoxDatabaseIdTracker->release(existingPlaylistGame->lbDatabaseId());
723+
static_cast<PlaylistDoc*>(mTargetDocument)->mLaunchBoxDatabaseIdTracker->reserve(existingPlaylistGame->lbDatabaseId());
724724

725725
// Add to document
726726
targetDocExistingPlaylistGames()[existingPlaylistGame->gameId()] = existingPlaylistGame;
@@ -1090,36 +1090,64 @@ ParentsDoc::ParentsDoc(Install* const parent, const QString& xmlPath, const DocK
10901090
//Private:
10911091
Fe::DataDoc::Type ParentsDoc::type() const { return Fe::DataDoc::Type::Config; }
10921092

1093-
//Public:
1094-
bool ParentsDoc::isEmpty() const { return mParents.isEmpty(); }
1095-
1096-
bool ParentsDoc::containsPlatformCategory(QStringView platformCategory)
1093+
bool ParentsDoc::removeIfPresent(qsizetype idx)
10971094
{
1098-
for(const Parent& p : mParents)
1099-
if(p.platformCategoryName() == platformCategory)
1100-
return true;
1095+
if(idx != -1)
1096+
{
1097+
mParents.remove(idx);
1098+
return true;
1099+
}
11011100

11021101
return false;
11031102
}
11041103

1105-
bool ParentsDoc::containsPlatformUnderCategory(QStringView platform, QStringView platformCategory)
1104+
qsizetype ParentsDoc::findPlatformCategory(QStringView platformCategory, QStringView parentCategory) const
11061105
{
1107-
for(const Parent& p : mParents)
1108-
if(p.parentPlatformCategoryName() == platformCategory && p.platformName() == platform)
1109-
return true;
1106+
for(auto i = 0; i < mParents.size(); i++)
1107+
{
1108+
auto p = mParents.at(i);
1109+
if(p.platformCategoryName() == platformCategory && p.parentPlatformCategoryName() == parentCategory)
1110+
return i;
1111+
}
11101112

1111-
return false;
1113+
return -1;
11121114
}
11131115

1114-
bool ParentsDoc::containsPlaylistUnderCategory(const QUuid& playlistId, QStringView platformCategory)
1116+
qsizetype ParentsDoc::findPlatform(QStringView platform, QStringView parentCategory) const
11151117
{
1116-
for(const Parent& p : mParents)
1117-
if(p.parentPlatformCategoryName() == platformCategory && p.playlistId() == playlistId)
1118-
return true;
1118+
for(auto i = 0; i < mParents.size(); i++)
1119+
{
1120+
auto p = mParents.at(i);
1121+
if(p.platformName() == platform && p.parentPlatformCategoryName() == parentCategory)
1122+
return i;
1123+
}
11191124

1120-
return false;
1125+
return -1;
11211126
}
11221127

1128+
qsizetype ParentsDoc::findPlaylist(const QUuid& playlistId, QStringView parentCategory) const
1129+
{
1130+
for(auto i = 0; i < mParents.size(); i++)
1131+
{
1132+
auto p = mParents.at(i);
1133+
if(p.playlistId() == playlistId && p.parentPlatformCategoryName() == parentCategory)
1134+
return i;
1135+
}
1136+
1137+
return -1;
1138+
}
1139+
1140+
//Public:
1141+
bool ParentsDoc::isEmpty() const { return mParents.isEmpty(); }
1142+
1143+
bool ParentsDoc::containsPlatformCategory(QStringView platformCategory, QStringView parentCategory) const { return findPlatformCategory(platformCategory, parentCategory) != -1; }
1144+
bool ParentsDoc::containsPlatform(QStringView platform, QStringView parentCategory) const { return findPlatform(platform, parentCategory) != -1; }
1145+
bool ParentsDoc::containsPlaylist(const QUuid& playlistId, QStringView parentCategory) const { return findPlaylist(playlistId, parentCategory) != -1; }
1146+
1147+
bool ParentsDoc::removePlatformCategory(QStringView platformCategory, QStringView parentCategory) { return removeIfPresent(findPlatformCategory(platformCategory, parentCategory)); }
1148+
bool ParentsDoc::removePlatform(QStringView platform, QStringView parentCategory) { return removeIfPresent(findPlatform(platform, parentCategory)); }
1149+
bool ParentsDoc::removePlaylist(const QUuid& playlistId, QStringView parentCategory) { return removeIfPresent(findPlaylist(playlistId, parentCategory)); }
1150+
11231151
const QList<Parent>& ParentsDoc::parents() const { return mParents; }
11241152

11251153
void ParentsDoc::addParent(const Parent& parent) { mParents.append(parent); }

0 commit comments

Comments
 (0)