diff --git a/.gitignore b/.gitignore index c33b663..ed6877c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build/* +builds/* CMakeLists.txt.user third_party/bit7z/* third_party/liblcf/* diff --git a/src/changelogwidget.cpp b/src/changelogwidget.cpp index 769b118..b3cfc86 100644 --- a/src/changelogwidget.cpp +++ b/src/changelogwidget.cpp @@ -59,10 +59,20 @@ void ChangelogWidget::on_pushButton_clicked() { if (QStringList{"+", "*"}.contains(i.first(1))) { if (ex.match(i).hasMatch() && i.mid(2, 3) == "MAP" && i.contains("]")) { // map - z.addFileFromDisk(QString("Map%1.lmu").arg(i.split("[")[1].split("]")[0]).toStdString(), QString(work_dir + QString("/Map%1.lmu").arg(i.split("[")[1].split("]")[0])).toStdString()); + QString map_string = QString("Map%1.lmu").arg(i.split("[")[1].split("]")[0]); + try { + z.addFileFromDisk(map_string.toStdString(), QString(work_dir + map_string).toStdString()); + } catch (const minidocx::io_error& ex) { + QMessageBox::warning(this, "Warning", QString("Could not include file %1 in the zip file! It is already in the changelog. Add the file to the archive manually.").arg(map_string)); + } } else if (!ex.match(i).hasMatch() && i.split(" ").size() >= 2) { // file - z.addFileFromDisk(QString("%1/%2").arg(i.split(" ")[1]).arg(fileex.match(i).captured(1)).toStdString(), QString(work_dir + QString("/%1/%2").arg(i.split(" ")[1]).arg(fileex.match(i).captured(1))).toStdString()); + QString file_string = QString("%1/%2").arg(i.split(" ")[1]).arg(fileex.match(i).captured(1)); + try { + z.addFileFromDisk(file_string.toStdString(), QString(work_dir + file_string).toStdString()); + } catch (const minidocx::io_error& ex) { + QMessageBox::warning(this, "Warning", QString("Could not include file %1 in the zip file! It is already in the changelog. Add the file to the archive manually.").arg(file_string)); + } } } } diff --git a/src/pickerwidget.cpp b/src/pickerwidget.cpp index 87013bb..1067827 100644 --- a/src/pickerwidget.cpp +++ b/src/pickerwidget.cpp @@ -25,6 +25,7 @@ #include #include #include +#include PickerWidget::PickerWidget(QWidget *parent) : QDialog(parent), ui(new Ui::PickerWidget) { ui->setupUi(this); @@ -182,6 +183,9 @@ void PickerWidget::gendiff(QString orig_path, QString work_path) { // shared. only add them if the files actually differ QFileInfo a(orig_path + "/" + i); QFileInfo b(work_path + "/" + i); + if (!a.isFile() || !b.isFile()) { + break; + } if (a.lastModified() != b.lastModified()){ shared.push_back(i); } @@ -248,38 +252,42 @@ void PickerWidget::gendiff(QString orig_path, QString work_path) { } ui->treeWidget->sortItems(0, Qt::SortOrder::AscendingOrder); // get ldb data - std::unique_ptr orig_db = lcf::LDB_Reader::Load((orig_path + "/RPG_RT.ldb").toStdString()); - std::unique_ptr work_db = lcf::LDB_Reader::Load((work_path + "/RPG_RT.ldb").toStdString()); - // troops - dbdiff(orig_db->troops, work_db->troops, "Troop"); - // tilesets - dbdiff(orig_db->chipsets, work_db->chipsets, "Tileset"); - // terrains - dbdiff(orig_db->terrains, work_db->terrains, "Terrain"); - // states - dbdiff(orig_db->states, work_db->states, "State"); - // skills - dbdiff(orig_db->skills, work_db->skills, "Skill"); - // items - dbdiff(orig_db->items, work_db->items, "Item"); - // enemies - dbdiff(orig_db->classes, work_db->classes, "Enemy"); - // elements - dbdiff(orig_db->attributes, work_db->attributes, "Element"); - // classes - dbdiff(orig_db->classes, work_db->classes, "Class"); - // animation2 (battler animation) - dbdiff(orig_db->battleranimations, work_db->battleranimations, "BattlerAnim"); - // animations - dbdiff(orig_db->animations, work_db->animations, "Animation"); - // actors - dbdiff(orig_db->actors, work_db->actors, "Actor"); - // variables - dbdiff(orig_db->variables, work_db->variables, "V"); - // switches - dbdiff(orig_db->switches, work_db->switches, "S"); - // CEs - dbdiff(orig_db->commonevents, work_db->commonevents, "CE"); + std::unique_ptr orig_db = lcf::LDB_Reader::Load((orig_path + "/RPG_RT.ldb").toStdString(), "UTF-8"); + std::unique_ptr work_db = lcf::LDB_Reader::Load((work_path + "/RPG_RT.ldb").toStdString(), "UTF-8"); + if (orig_db == nullptr | work_db == nullptr) { + QMessageBox::warning(this, "Warning", "Could not read the database files! Database info will have to be included manually."); + } else { + // troops + dbdiff(orig_db->troops, work_db->troops, "Troop"); + // tilesets + dbdiff(orig_db->chipsets, work_db->chipsets, "Tileset"); + // terrains + dbdiff(orig_db->terrains, work_db->terrains, "Terrain"); + // states + dbdiff(orig_db->states, work_db->states, "State"); + // skills + dbdiff(orig_db->skills, work_db->skills, "Skill"); + // items + dbdiff(orig_db->items, work_db->items, "Item"); + // enemies + dbdiff(orig_db->classes, work_db->classes, "Enemy"); + // elements + dbdiff(orig_db->attributes, work_db->attributes, "Element"); + // classes + dbdiff(orig_db->classes, work_db->classes, "Class"); + // animation2 (battler animation) + dbdiff(orig_db->battleranimations, work_db->battleranimations, "BattlerAnim"); + // animations + dbdiff(orig_db->animations, work_db->animations, "Animation"); + // actors + dbdiff(orig_db->actors, work_db->actors, "Actor"); + // variables + dbdiff(orig_db->variables, work_db->variables, "V"); + // switches + dbdiff(orig_db->switches, work_db->switches, "S"); + // CEs + dbdiff(orig_db->commonevents, work_db->commonevents, "CE"); + } // yoink the maps and put them up top for (auto &i: ui->treeWidget->findItems("", Qt::MatchExactly, 1)) {