Skip to content

Commit

Permalink
Merge pull request #257 from KizKizz/system-rework
Browse files Browse the repository at this point in the history
System rework
  • Loading branch information
KizKizz authored Aug 10, 2024
2 parents ad8c8ad + 4055a4c commit ef9dc85
Show file tree
Hide file tree
Showing 19 changed files with 619 additions and 838 deletions.
7 changes: 5 additions & 2 deletions Language/CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@
"uiNewMods": "新Mod",
"uiNewMod": "新Mod",
"uiNew": "",
"uiShowNew": "Show New",
"uiShowApplied": "Show Applied",
"uiUndo": "Undo",
"uiPreparing": "准备中",
"uiDragDropFiles": "拖放文件夹、.zip、.rar、.7z文件\n以及.ice文件到这里\n或者点击\"添加文件夹或文件\"按钮选择文件夹或文件。\n大量文件的处理可能会花费较长时间。",
"uiAchiveCurrentlyNotSupported": "当前不支持的压缩文件类型。请解压存档文件后,再将内容拖到此处。",
Expand All @@ -334,6 +337,7 @@
"uiDuplicatesInAppliedModsFound": "在应用的MOD中发现了重复的物品",
"uiApplyingWouldReplaceModFiles": "注意:应用此MOD将替换这些已应用的MOD文件。",
"uiSelectWhichFilesToBeReplacedWithThisMod": "选中的已应用文件将替换为此MOD",
"uiApplying": "Applying",
"uiNewCateGroup": "新建类别集",
"uiNameAlreadyExisted": "名称已存在!",
"uiNewCateGroupName": "新建类别集名称",
Expand Down Expand Up @@ -599,5 +603,4 @@
"uiItemsInQuickApplyList": "快捷应用列表中的物品",
"uiAddToQuickApplyList": "加入快捷应用列表",
"uiRemoveFromQuickApplyList": "从快捷应用列表移除"
}

}
4 changes: 4 additions & 0 deletions Language/EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@
"uiNewMods": "New Mods",
"uiNewMod": "New Mod",
"uiNew": "New",
"uiShowNew": "Show New",
"uiShowApplied": "Show Applied",
"uiUndo": "Undo",
"uiPreparing": "Preparing",
"uiDragDropFiles": "Drag and drop folders, .zip, .rar, .7z files\nand .ice files here\nOr use the \"Add Folders/Files\" buttons to select folders/files\nMay take some time\nto process large amount of files",
"uiAchiveCurrentlyNotSupported": "currently not supported. Open the archive file then drag the content in here instead",
Expand All @@ -334,6 +337,7 @@
"uiDuplicatesInAppliedModsFound": "Duplicate(s) in applied mods found",
"uiApplyingWouldReplaceModFiles": "Applying this mod would replace these applied mod files",
"uiSelectWhichFilesToBeReplacedWithThisMod": "Select which currently applied files bellow to be replaced with files in this mod",
"uiApplying": "Applying",
"uiNewCateGroup": "New Category Group",
"uiNameAlreadyExisted": "Name already existed!",
"uiNewCateGroupName": "New Category Group name",
Expand Down
6 changes: 5 additions & 1 deletion Language/JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@
"uiNewMods": "新しいMOD",
"uiNewMod": "新しいMOD",
"uiNew": "新しい",
"uiShowNew": "新着情報",
"uiShowApplied": "応用",
"uiUndo": "元に戻す",
"uiPreparing": "準備中",
"uiDragDropFiles": "フォルダ(.zip)(.rar)(.7z)ファイルのドラッグ&ドロップ\nおよび.iceファイルはこちら\nまたは、\"フォルダ/ファイルの追加\" ボタンを使って、フォルダやファイルを選択します\n大量のファイルの処理に時間がかかる場合があります",
"uiAchiveCurrentlyNotSupported": "現在、サポートされていませんアーカイブファイルを開き、代わりにコンテンツをここにドラッグしてください",
Expand All @@ -333,7 +336,8 @@
"uiPickAColor": "カラーを選ぶ",
"uiDuplicatesInAppliedModsFound": "適用されたMODの中で重複するものが見つかりました",
"uiApplyingWouldReplaceModFiles": "このMODを適用すると、これらの適用済みMODファイルが置き換えられます",
"uiSelectWhichFilesToBeReplacedWithThisMod": "Select which cuurently applied files to be replaced with files in this mod",
"uiSelectWhichFilesToBeReplacedWithThisMod": "現在適用されているファイルを、このMODのファイルと置き換える",
"uiApplying": "適用",
"uiNewCateGroup": "新カテゴリーグループ",
"uiNameAlreadyExisted": "名前はすでに存在しています!",
"uiNewCateGroupName": "新規カテゴリーグループ名",
Expand Down
7 changes: 2 additions & 5 deletions app_version_check/app_version.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "PSO2NGS Mod Manager",
"version": "2.8.12",
"version": "2.8.13",
"description": [
"Fixed a bug with Mod Sets when applying mods",
"Removed fixed mod preview panel",
"Code and performance optimization",
"More bug fixes",
"MOD適用時のMODセットのバグを修正",
"固定MODプレビューパネルを削除",
"MODセットエクスポート機能の追加",
"いくつかのバグを修正し、アイテム/Modの交換を改善しました",
"コードとパフォーマンスの最適化",
"その他のバグ修正"
],
"windows_file": "",
Expand Down
5 changes: 5 additions & 0 deletions lib/classes/mod_set_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class ModSet with ChangeNotifier {
notifyListeners();
}

void removeItem(Item item) {
setItems.remove(item);
notifyListeners();
}

void refresh() {
notifyListeners();
}
Expand Down
11 changes: 10 additions & 1 deletion lib/classes/sub_mod_class.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:path/path.dart' as p;
part 'sub_mod_class.g.dart';

@JsonSerializable()
class SubMod with ChangeNotifier{
class SubMod with ChangeNotifier {
SubMod(this.submodName, this.modName, this.itemName, this.category, this.location, this.applyStatus, this.applyDate, this.position, this.isNew, this.isFavorite, this.isSet, this.hasCmx,
this.cmxApplied, this.cmxStartPos, this.cmxEndPos, this.cmxFile, this.setNames, this.applyLocations, this.previewImages, this.previewVideos, this.appliedModFiles, this.modFiles);
String submodName;
Expand Down Expand Up @@ -44,6 +44,15 @@ class SubMod with ChangeNotifier{
}

//helpers
bool compareModFilesInList(List<String> modFileNames) {
for (var modFile in modFiles) {
if (!modFileNames.contains(modFile.modFileName)) {
return false;
}
}
return true;
}

List<Widget> getPreviewWidgets() {
List<Widget> widgets = [];
if (previewImages.isNotEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion lib/functions/apply_all_available_mods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Future<String> applyAllAvailableMods(context, Item item, Mod mod, SubMod submod)
}
}
if (toBeAppliedModFiles.isNotEmpty) {
final appliedFiles = await modFilesApply(context, toBeAppliedModFiles);
final appliedFiles = await modFilesApply(context, submod, toBeAppliedModFiles);
if (appliedFiles.where((element) => element.applyStatus).isNotEmpty) {
submod.applyDate = DateTime.now();
item.applyDate = DateTime.now();
Expand Down
14 changes: 10 additions & 4 deletions lib/functions/apply_mods_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:pso2_mod_manager/classes/mod_class.dart';
import 'package:pso2_mod_manager/classes/mod_file_class.dart';
import 'package:pso2_mod_manager/classes/sub_mod_class.dart';
import 'package:pso2_mod_manager/cmx/cmx_functions.dart';
import 'package:pso2_mod_manager/functions/icon_overlay.dart';
import 'package:pso2_mod_manager/functions/json_write.dart';
import 'package:pso2_mod_manager/functions/modfiles_apply.dart';
import 'package:pso2_mod_manager/global_variables.dart';
Expand All @@ -15,7 +16,7 @@ import 'package:pso2_mod_manager/widgets/snackbar.dart';

Future<bool> applyModsToTheGame(context, Item curItem, Mod curMod, SubMod curSubmod) async {
try {
await modFilesApply(context, curSubmod.modFiles).then((value) async {
await modFilesApply(context, curSubmod, curSubmod.modFiles).then((value) async {
if (curSubmod.modFiles.indexWhere((element) => element.applyStatus) != -1) {
curSubmod.applyDate = DateTime.now();
curItem.applyDate = DateTime.now();
Expand All @@ -36,7 +37,12 @@ Future<bool> applyModsToTheGame(context, Item curItem, Mod curMod, SubMod curSub
}
fileAppliedText += '${appliedModFiles.indexOf(element) + 1}. ${element.modFileName}\n';
}
ScaffoldMessenger.of(mainPageScaffoldKey.currentState!.context).showSnackBar(snackBarMessage(mainPageScaffoldKey.currentState!.context, '${curLangText!.uiSuccess}!', fileAppliedText.trim(), appliedModFiles.length * 1000));
ScaffoldMessenger.of(mainPageScaffoldKey.currentState!.context)
.showSnackBar(snackBarMessage(mainPageScaffoldKey.currentState!.context, '${curLangText!.uiSuccess}!', fileAppliedText.trim(), appliedModFiles.length * 1000));
}

if (markModdedItem) {
await applyOverlayedIcon(context, curItem);
}

modViewModsApplyRemoving.value = false;
Expand All @@ -60,7 +66,7 @@ Future<bool> applyModsToTheGame(context, Item curItem, Mod curMod, SubMod curSub
modViewModsApplyRemoving.value = false;
// ignore: use_build_context_synchronously
ScaffoldMessenger.of(mainPageScaffoldKey.currentState!.context).showSnackBar(snackBarMessage(mainPageScaffoldKey.currentState!.context, '${curLangText!.uiError}!', e.toString(), 5000));
return false;
}

return false;
return true;
}
25 changes: 22 additions & 3 deletions lib/functions/modfiles_apply.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:pso2_mod_manager/aqmInjection/aqm_removal.dart';
import 'package:pso2_mod_manager/classes/aqm_item_class.dart';

import 'package:pso2_mod_manager/classes/mod_file_class.dart';
import 'package:pso2_mod_manager/classes/sub_mod_class.dart';
import 'package:pso2_mod_manager/functions/apply_mod_file.dart';
import 'package:pso2_mod_manager/functions/checksum_check.dart';
import 'package:pso2_mod_manager/functions/modfile_applied_dup.dart';
Expand All @@ -17,7 +18,7 @@ import 'package:pso2_mod_manager/state_provider.dart';
// ignore: depend_on_referenced_packages
import 'package:path/path.dart' as p;

Future<List<ModFile>> modFilesApply(context, List<ModFile> modFiles) async {
Future<List<ModFile>> modFilesApply(context, SubMod? submod, List<ModFile> modFiles) async {
List<ModFile> alreadyAppliedModFiles = [];
List<ModFile> appliedModFiles = [];
// bool applyMods = true;
Expand Down Expand Up @@ -57,7 +58,7 @@ Future<List<ModFile>> modFilesApply(context, List<ModFile> modFiles) async {
}

if (alreadyAppliedModFiles.isNotEmpty) {
List<ModFile> modFilesToReplace = await duplicateAppliedDialog(context, alreadyAppliedModFiles);
List<ModFile> modFilesToReplace = await duplicateAppliedDialog(context, submod, alreadyAppliedModFiles);
if (modFilesToReplace.isNotEmpty) {
for (var modFile in modFilesToReplace) {
await modFileAppliedDupRestore(context, moddedItemsList, modFile);
Expand Down Expand Up @@ -119,7 +120,7 @@ Future<List<ModFile>> modFilesApply(context, List<ModFile> modFiles) async {
return appliedModFiles;
}

Future<List<ModFile>> duplicateAppliedDialog(context, List<ModFile> dupModFiles) async {
Future<List<ModFile>> duplicateAppliedDialog(context, SubMod? applyingSubmod, List<ModFile> dupModFiles) async {
var selectedList = List.generate(dupModFiles.length, (int index) => true);
List<ModFile> modFilesToReplace = dupModFiles.toList();
return await showDialog(
Expand All @@ -137,6 +138,24 @@ Future<List<ModFile>> duplicateAppliedDialog(context, List<ModFile> dupModFiles)
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Visibility(
visible: applyingSubmod != null,
child: Padding(
padding: const EdgeInsets.only(bottom: 5, top: 10),
child: Text(
'${curLangText!.uiApplying}:',
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
)),
),
Visibility(
visible: applyingSubmod != null,
child: Padding(
padding: const EdgeInsets.only(bottom: 10, left: 15),
child: Text(
'${applyingSubmod!.category} > ${applyingSubmod.itemName} > ${applyingSubmod.modName} > ${applyingSubmod.submodName}',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Theme.of(context).colorScheme.primary),
)),
),
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Text(
Expand Down
Loading

0 comments on commit ef9dc85

Please sign in to comment.