Skip to content

Commit

Permalink
Merge pull request #228 from KizKizz/system-rework
Browse files Browse the repository at this point in the history
System rework
  • Loading branch information
KizKizz authored Jun 19, 2024
2 parents efd17b4 + 2fc4433 commit d1e2e78
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 131 deletions.
2 changes: 1 addition & 1 deletion app_version_check/app_version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "PSO2NGS Mod Manager",
"version": "2.7.9",
"version": "2.7.10",
"description": [
"Added a custom filter to Add Mods that automatically ignores unwanted folders/mods when adding mods to the Manager",
"Added an option to add preview images and videos to mods and to ice files",
Expand Down
85 changes: 80 additions & 5 deletions lib/loaders/mod_files_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ Future<List<CategoryType>> modFileStructureLoader(context, bool reload) async {
modFile.ogMd5s = curJsonModFilesList[modFileIndex].ogMd5s;
//modFile.submodName = curJsonModFilesList[modFileIndex].submodName;
if (curJsonModFilesList[modFileIndex].applyLocations != null) modFile.applyLocations = curJsonModFilesList[modFileIndex].applyLocations;
if (curJsonModFilesList[modFileIndex].previewImages != null) modFile.previewImages = curJsonModFilesList[modFileIndex].previewImages;
if (curJsonModFilesList[modFileIndex].previewVideos != null) modFile.previewVideos = curJsonModFilesList[modFileIndex].previewVideos;
// if (curJsonModFilesList[modFileIndex].previewImages != null) modFile.previewImages = curJsonModFilesList[modFileIndex].previewImages;
// if (curJsonModFilesList[modFileIndex].previewVideos != null) modFile.previewVideos = curJsonModFilesList[modFileIndex].previewVideos;
modFile.isSet = curJsonModFilesList[modFileIndex].isSet;
modFile.setNames = curJsonModFilesList[modFileIndex].setNames;
} else {
Expand Down Expand Up @@ -357,8 +357,32 @@ List<Mod> modsFetcher(String itemPath, String cateName) {
List<File> iceFilesInItemDir = Directory(itemPath).listSync(recursive: false).whereType<File>().where((element) => p.extension(element.path) == '').toList();
if (iceFilesInItemDir.isNotEmpty) {
for (var iceFile in iceFilesInItemDir) {
final previewFilesInMainModDir = Directory(iceFile.parent.path)
.listSync(recursive: false)
.whereType<File>()
.where((element) => p.extension(element.path) != '' && p.basenameWithoutExtension(element.path) == p.basename(iceFile.path))
.toList();
modFilesInItemDir.add(ModFile(
p.basename(iceFile.path), p.basename(itemPath), p.basename(itemPath), p.basename(itemPath), cateName, '', [], iceFile.path, false, DateTime(0), 0, false, false, false, [], [], [], [], [], []));
p.basename(iceFile.path),
p.basename(itemPath),
p.basename(itemPath),
p.basename(itemPath),
cateName,
'',
[],
iceFile.path,
false,
DateTime(0),
0,
false,
false,
false,
[],
[],
[],
[],
previewFilesInMainModDir.where((element) => p.extension(element.path) == '.png' || p.extension(element.path) == '.jpg').map((e) => e.path).toList(),
previewFilesInMainModDir.where((element) => p.extension(element.path) == '.mp4' || p.extension(element.path) == '.webm').map((e) => e.path).toList()));
}
//Get preview images;
List<String> modPreviewImages = [];
Expand Down Expand Up @@ -426,7 +450,32 @@ List<SubMod> subModFetcher(String modPath, String cateName, String itemName) {
// for (var element in ogFiles) {
// ogFilePaths.add(element.path);
// }
modFiles.add(ModFile(p.basename(file.path), p.basename(modPath), p.basename(modPath), itemName, cateName, '', [], file.path, false, DateTime(0), 0, false, false, false, [], [], [], [], [], []));
final previewFilesInMainModDir = Directory(file.parent.path)
.listSync(recursive: false)
.whereType<File>()
.where((element) => p.extension(element.path) != '' && p.basenameWithoutExtension(element.path) == p.basename(file.path))
.toList();
modFiles.add(ModFile(
p.basename(file.path),
p.basename(modPath),
p.basename(modPath),
itemName,
cateName,
'',
[],
file.path,
false,
DateTime(0),
0,
false,
false,
false,
[],
[],
[],
[],
previewFilesInMainModDir.where((element) => p.extension(element.path) == '.png' || p.extension(element.path) == '.jpg').map((e) => e.path).toList(),
previewFilesInMainModDir.where((element) => p.extension(element.path) == '.mp4' || p.extension(element.path) == '.webm').map((e) => e.path).toList()));
}

//Get preview images;
Expand Down Expand Up @@ -498,7 +547,33 @@ List<SubMod> subModFetcher(String modPath, String cateName, String itemName) {
List<String> parentPaths = file.parent.path.split(modPath).last.trim().split(Uri.file('/').toFilePath());
parentPaths.removeWhere((element) => element.isEmpty);

modFiles.add(ModFile(p.basename(file.path), parentPaths.join(' > '), p.basename(modPath), itemName, cateName, '', [], file.path, false, DateTime(0), 0, false, false, false, [], [], [], [], [], []));
final previewFilesInMainModDir = Directory(file.parent.path)
.listSync(recursive: false)
.whereType<File>()
.where((element) => p.extension(element.path) != '' && p.basenameWithoutExtension(element.path) == p.basename(file.path))
.toList();

modFiles.add(ModFile(
p.basename(file.path),
parentPaths.join(' > '),
p.basename(modPath),
itemName,
cateName,
'',
[],
file.path,
false,
DateTime(0),
0,
false,
false,
false,
[],
[],
[],
[],
previewFilesInMainModDir.where((element) => p.extension(element.path) == '.png' || p.extension(element.path) == '.jpg').map((e) => e.path).toList(),
previewFilesInMainModDir.where((element) => p.extension(element.path) == '.mp4' || p.extension(element.path) == '.webm').map((e) => e.path).toList()));
}

//Get submod name
Expand Down
Loading

0 comments on commit d1e2e78

Please sign in to comment.