5
5
#include < QMessageBox>
6
6
#include < QProgressBar>
7
7
#include " ModManager.h"
8
- #include " bblauncher.h"
9
8
#include " modules/ui_ModManager.h"
10
9
11
10
std::filesystem::path ModInstallPath;
@@ -23,8 +22,8 @@ ModManager::ModManager(QWidget* parent) : QDialog(parent), ui(new Ui::ModManager
23
22
ui->RecModsLabel ->setTextInteractionFlags (Qt::TextBrowserInteraction);
24
23
ui->RecModsLabel ->setOpenExternalLinks (true );
25
24
26
- if (!std::filesystem::exists (ModPath)) {
27
- std::filesystem::create_directories (ModPath);
25
+ if (!std::filesystem::exists (Common:: ModPath)) {
26
+ std::filesystem::create_directories (Common:: ModPath);
28
27
}
29
28
30
29
if (!std::filesystem::exists (ModBackupPath)) {
@@ -42,10 +41,11 @@ ModManager::ModManager(QWidget* parent) : QDialog(parent), ui(new Ui::ModManager
42
41
&ModManager::DeactivateButton_isPressed);
43
42
connect (this , &ModManager::progressChanged, ui->progressBar , &QProgressBar::setValue);
44
43
45
- if (std::filesystem::exists (installPath.parent_path () / (game_serial + " -UPDATE" ))) {
46
- ModInstallPath = installPath.parent_path () / (game_serial + " -UPDATE" );
44
+ if (std::filesystem::exists (Common::installPath.parent_path () /
45
+ (Common::game_serial + " -UPDATE" ))) {
46
+ ModInstallPath = Common::installPath.parent_path () / (Common::game_serial + " -UPDATE" );
47
47
} else {
48
- ModInstallPath = installPath;
48
+ ModInstallPath = Common:: installPath;
49
49
}
50
50
}
51
51
@@ -59,7 +59,7 @@ void ModManager::ActivateButton_isPressed() {
59
59
60
60
bool hasconflict = false ;
61
61
const std::string ModName = ui->InactiveModList ->currentItem ()->text ().toStdString ();
62
- const std::string ModFolderString = (ModPath / ModName).string ();
62
+ const std::string ModFolderString = (Common:: ModPath / ModName).string ();
63
63
const std::filesystem::path ModFolderPath = std::filesystem::u8path (ModFolderString);
64
64
const std::string ModBackupString = (ModBackupPath / ModName).string ();
65
65
const std::filesystem::path ModBackupFolderPath = std::filesystem::u8path (ModBackupString);
@@ -82,7 +82,7 @@ void ModManager::ActivateButton_isPressed() {
82
82
for (const auto & entry : std::filesystem::directory_iterator (ModSourcePath)) {
83
83
if (entry.is_directory ()) {
84
84
auto relative_path = std::filesystem::relative (entry, ModSourcePath);
85
- std::string relative_path_string = PathToU8 (relative_path);
85
+ std::string relative_path_string = Common:: PathToU8 (relative_path);
86
86
if (std::find (BBFolders.begin (), BBFolders.end (), relative_path_string) ==
87
87
BBFolders.end ()) {
88
88
QMessageBox::warning (this , " Invalid Mod" ,
@@ -94,7 +94,7 @@ void ModManager::ActivateButton_isPressed() {
94
94
}
95
95
}
96
96
97
- std::ifstream ModInfoFile (ModPath / " ModifiedFiles.txt" , std::ios::binary);
97
+ std::ifstream ModInfoFile (Common:: ModPath / " ModifiedFiles.txt" , std::ios::binary);
98
98
while (std::getline (ModInfoFile, line)) {
99
99
lineCount++;
100
100
FileList.push_back (line);
@@ -104,7 +104,7 @@ void ModManager::ActivateButton_isPressed() {
104
104
for (const auto & entry : std::filesystem::recursive_directory_iterator (ModSourcePath)) {
105
105
if (!entry.is_directory ()) {
106
106
auto relative_path = std::filesystem::relative (entry, ModSourcePath);
107
- std::string relative_path_string = PathToU8 (relative_path);
107
+ std::string relative_path_string = Common:: PathToU8 (relative_path);
108
108
for (int i = 0 ; i < FileList.size (); i++) {
109
109
if (FileList[i].contains (relative_path_string)) {
110
110
hasconflict = true ;
@@ -130,13 +130,13 @@ void ModManager::ActivateButton_isPressed() {
130
130
for (const auto & entry : std::filesystem::recursive_directory_iterator (ModSourcePath)) {
131
131
if (!entry.is_directory ()) {
132
132
auto relative_path = std::filesystem::relative (entry, ModSourcePath);
133
- const auto u8_string = PathToU8 (relative_path) + " , " + ModName;
133
+ const auto u8_string = Common:: PathToU8 (relative_path) + " , " + ModName;
134
134
std::string relative_path_string{u8_string.begin (), u8_string.end ()};
135
135
FileList.push_back (relative_path_string);
136
136
}
137
137
}
138
138
139
- std::ofstream ModInfoFileSave (ModPath / " ModifiedFiles.txt" , std::ios::binary);
139
+ std::ofstream ModInfoFileSave (Common:: ModPath / " ModifiedFiles.txt" , std::ios::binary);
140
140
for (const auto & i : FileList)
141
141
ModInfoFileSave << i << " \n " ;
142
142
ModInfoFileSave.close ();
@@ -200,7 +200,7 @@ void ModManager::ActivateButton_isPressed() {
200
200
201
201
ui->FileTransferLabel ->setText (" Modified File List is being written" );
202
202
ui->progressBar ->setValue (0 );
203
- std::ifstream ActiveFile (ModPath / " ActiveMods.txt" , std::ios::binary);
203
+ std::ifstream ActiveFile (Common:: ModPath / " ActiveMods.txt" , std::ios::binary);
204
204
lineCount = 0 ;
205
205
while (std::getline (ActiveFile, line)) {
206
206
lineCount++;
@@ -211,7 +211,7 @@ void ModManager::ActivateButton_isPressed() {
211
211
ActiveFile.close ();
212
212
ActiveModList.push_back (ModName);
213
213
214
- std::ofstream ActiveFileSave (ModPath / " ActiveMods.txt" , std::ios::binary);
214
+ std::ofstream ActiveFileSave (Common:: ModPath / " ActiveMods.txt" , std::ios::binary);
215
215
for (const auto & l : ActiveModList)
216
216
ActiveFileSave << l << " \n " ;
217
217
ActiveFileSave.close ();
@@ -255,7 +255,7 @@ void ModManager::DeactivateButton_isPressed() {
255
255
return ;
256
256
}
257
257
258
- std::ifstream ConflictFile (ModPath / " ConflictMods.txt" , std::ios::binary);
258
+ std::ifstream ConflictFile (Common:: ModPath / " ConflictMods.txt" , std::ios::binary);
259
259
while (std::getline (ConflictFile, line)) {
260
260
lineCount++;
261
261
ConflictMods.push_back (line);
@@ -374,7 +374,7 @@ void ModManager::RefreshLists() {
374
374
std::vector<std::string> ActiveModList;
375
375
std::string line;
376
376
int lineCount = 0 ;
377
- std::ifstream ActiveFile (ModPath / " ActiveMods.txt" , std::ios::binary);
377
+ std::ifstream ActiveFile (Common:: ModPath / " ActiveMods.txt" , std::ios::binary);
378
378
379
379
ui->ActiveModList ->clear ();
380
380
ui->InactiveModList ->clear ();
@@ -391,9 +391,9 @@ void ModManager::RefreshLists() {
391
391
ui->ActiveModList ->addItems (ActiveModStringList);
392
392
393
393
std::vector<std::string> InactiveModFolders;
394
- for (auto & FolderEntry : std::filesystem::directory_iterator (ModPath)) {
394
+ for (auto & FolderEntry : std::filesystem::directory_iterator (Common:: ModPath)) {
395
395
if (FolderEntry.is_directory ()) {
396
- std::string Foldername = PathToU8 (FolderEntry.path ().filename ());
396
+ std::string Foldername = Common:: PathToU8 (FolderEntry.path ().filename ());
397
397
if (std::find (ActiveModList.begin (), ActiveModList.end (), Foldername) ==
398
398
ActiveModList.end ()) {
399
399
InactiveModFolders.push_back (Foldername);
@@ -424,7 +424,7 @@ void ModManager::ConflictAdd(std::string ModName) {
424
424
int lineCount = 0 ;
425
425
std::vector<std::string> ConflictMods;
426
426
427
- std::ifstream ConflictFile (ModPath / " ConflictMods.txt" , std::ios::binary);
427
+ std::ifstream ConflictFile (Common:: ModPath / " ConflictMods.txt" , std::ios::binary);
428
428
while (std::getline (ConflictFile, line)) {
429
429
lineCount++;
430
430
ConflictMods.push_back (line);
@@ -433,7 +433,7 @@ void ModManager::ConflictAdd(std::string ModName) {
433
433
434
434
ConflictMods.push_back (ModName);
435
435
436
- std::ofstream ConflictFileSave (ModPath / " ConflictMods.txt" , std::ios::binary);
436
+ std::ofstream ConflictFileSave (Common:: ModPath / " ConflictMods.txt" , std::ios::binary);
437
437
for (const auto & i : ConflictMods)
438
438
ConflictFileSave << i << " \n " ;
439
439
ConflictFileSave.close ();
@@ -444,7 +444,7 @@ void ModManager::ConflictRemove(std::string ModName) {
444
444
int lineCount = 0 ;
445
445
std::vector<std::string> ConflictMods;
446
446
447
- std::ifstream ConflictFile (ModPath / " ConflictMods.txt" , std::ios::binary);
447
+ std::ifstream ConflictFile (Common:: ModPath / " ConflictMods.txt" , std::ios::binary);
448
448
while (std::getline (ConflictFile, line)) {
449
449
lineCount++;
450
450
ConflictMods.push_back (line);
@@ -454,7 +454,7 @@ void ModManager::ConflictRemove(std::string ModName) {
454
454
auto itr = std::find (ConflictMods.begin (), ConflictMods.end (), ModName);
455
455
ConflictMods.erase (itr);
456
456
457
- std::ofstream ConflictFileSave (ModPath / " ConflictMods.txt" , std::ios::binary);
457
+ std::ofstream ConflictFileSave (Common:: ModPath / " ConflictMods.txt" , std::ios::binary);
458
458
for (const auto & i : ConflictMods)
459
459
ConflictFileSave << i << " \n " ;
460
460
ConflictFileSave.close ();
@@ -466,7 +466,7 @@ void ModManager::ActiveModRemove(std::string ModName) {
466
466
std::string line;
467
467
int lineCount = 0 ;
468
468
469
- std::ifstream ActiveFile (ModPath / " ActiveMods.txt" , std::ios::binary);
469
+ std::ifstream ActiveFile (Common:: ModPath / " ActiveMods.txt" , std::ios::binary);
470
470
while (std::getline (ActiveFile, line)) {
471
471
lineCount++;
472
472
ActiveModList.push_back (line);
@@ -477,16 +477,16 @@ void ModManager::ActiveModRemove(std::string ModName) {
477
477
if (itr != ActiveModList.end ())
478
478
ActiveModList.erase (itr);
479
479
480
- std::ofstream ActiveFileSave (ModPath / " ActiveMods.txt" , std::ios::binary);
480
+ std::ofstream ActiveFileSave (Common:: ModPath / " ActiveMods.txt" , std::ios::binary);
481
481
for (const auto & l : ActiveModList)
482
482
ActiveFileSave << l << " \n " ;
483
483
ActiveFileSave.close ();
484
484
485
- std::filesystem::remove (ModPath / " ModifiedFiles.txt" );
485
+ std::filesystem::remove (Common:: ModPath / " ModifiedFiles.txt" );
486
486
487
487
for (auto & FolderEntry : std::filesystem::directory_iterator (ModBackupPath)) {
488
488
if (FolderEntry.is_directory ()) {
489
- std::string Foldername = PathToU8 (FolderEntry.path ().filename ());
489
+ std::string Foldername = Common:: PathToU8 (FolderEntry.path ().filename ());
490
490
const std::string BackupModPathString = (ModBackupPath / Foldername).string ();
491
491
const std::filesystem::path BackupModPath =
492
492
std::filesystem::u8path (BackupModPathString);
@@ -499,7 +499,7 @@ void ModManager::ActiveModRemove(std::string ModName) {
499
499
std::filesystem::recursive_directory_iterator (BackupModPath)) {
500
500
if (!entry.is_directory ()) {
501
501
auto relative_path = std::filesystem::relative (entry, BackupModPath);
502
- const auto u8_string = PathToU8 (relative_path) + " , " + Foldername;
502
+ const auto u8_string = Common:: PathToU8 (relative_path) + " , " + Foldername;
503
503
std::string relative_path_string{u8_string.begin (), u8_string.end ()};
504
504
FileList.push_back (relative_path_string);
505
505
}
@@ -513,7 +513,7 @@ void ModManager::ActiveModRemove(std::string ModName) {
513
513
ui->progressBar ->setValue (0 );
514
514
for (auto & FolderEntry : std::filesystem::directory_iterator (ModUniquePath)) {
515
515
if (FolderEntry.is_directory ()) {
516
- std::string Foldername = PathToU8 (FolderEntry.path ().filename ());
516
+ std::string Foldername = Common:: PathToU8 (FolderEntry.path ().filename ());
517
517
const std::string UniqueModPathString = (ModUniquePath / Foldername).string ();
518
518
const std::filesystem::path UniqueModPath =
519
519
std::filesystem::u8path (UniqueModPathString);
@@ -524,7 +524,7 @@ void ModManager::ActiveModRemove(std::string ModName) {
524
524
for (const auto & entry : std::filesystem::recursive_directory_iterator (UniqueModPath)) {
525
525
if (!entry.is_directory ()) {
526
526
auto relative_path = std::filesystem::relative (entry, UniqueModPath);
527
- const auto u8_string = PathToU8 (relative_path) + " , " + Foldername;
527
+ const auto u8_string = Common:: PathToU8 (relative_path) + " , " + Foldername;
528
528
std::string relative_path_string{u8_string.begin (), u8_string.end ()};
529
529
FileList.push_back (relative_path_string);
530
530
}
@@ -535,7 +535,7 @@ void ModManager::ActiveModRemove(std::string ModName) {
535
535
}
536
536
537
537
ui->progressBar ->setValue (0 );
538
- std::ofstream ModInfoFileSave (ModPath / " ModifiedFiles.txt" , std::ios::binary);
538
+ std::ofstream ModInfoFileSave (Common:: ModPath / " ModifiedFiles.txt" , std::ios::binary);
539
539
for (const auto & i : FileList)
540
540
ModInfoFileSave << i << " \n " ;
541
541
ModInfoFileSave.close ();
0 commit comments