Skip to content

Commit

Permalink
patch saving, part 3
Browse files Browse the repository at this point in the history
it works!! with that i'm pretty happy with where mossball is at right now. there will be more features down the line, like previews in the file picking section, but those improvements will trickle down from eidolist.

also fixed a bug where database removals didn't fetch the proper names.
  • Loading branch information
lumiscosity committed Oct 1, 2024
1 parent 5ab956d commit 6d2a411
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.16)

project(mossball VERSION 0.1 LANGUAGES CXX)
project(mossball VERSION 1.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
Expand Down
15 changes: 7 additions & 8 deletions src/changelogwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ void ChangelogWidget::on_pushButton_clicked() {
minidocx::Zip z;
z.open(out.toStdString(), minidocx::Zip::OpenMode::Create);

QRegularExpression ex("^[^ ]* [^ ]*\[.*$");
QRegularExpression fileex("(?:\\S+\\s+){1}(.+?)(?:\(|$)");
QRegularExpression ex("^[^ ]* [^ ]*\\[.*$");
QRegularExpression fileex("^(?:\\S+\\s+){2}(.*?)(?:\\s*\\(|$)");

for (QString i : ui->plainTextEdit->toPlainText().split("\n")) {
if (i.length() > 5) {
if (QStringList{"+", "*"}.contains(i.first(1))) {
auto temp1 = ex.match(i).hasMatch();
qWarning()<<temp1;
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());
} else if (!ex.match(i).hasMatch() && i.split(" ").size() >= 2) {
z.addFileFromDisk(QString("%1/%2").arg(i.split(" ")[1]).arg(fileex.match(i).captured()).toStdString(), QString(work_dir + QString("/%1/%2").arg(i.split(" ")[1]).arg(fileex.match(i).captured())).toStdString());
// file
auto temp2 = QString(work_dir + QString("/%1/%2").arg(i.split(" ")[1]).arg(fileex.match(i).captured(1)));
qDebug()<<temp2;
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());
}
}
}
Expand All @@ -81,9 +83,6 @@ void ChangelogWidget::on_pushButton_clicked() {
QMessageBox::critical(this, "Error", QString("An error occured while compiling: %1 \nEnsure that you haven't broken the changelog formatting and the the files detected are present in the work copy, then try again. In case of continued failure, please report the issue in Mossball's repository.").arg(ex.what()));
return;
}

QMessageBox::information(this, "Success", "Patch compiled successfully.");
this->close();
}
}

13 changes: 9 additions & 4 deletions src/pickerwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,27 @@ class PickerWidget : public QDialog {
if (orig.size() < work.size()) {
// note non-empty additions in new chunks
for (int i = orig.size(); i == work.size(); i++) {
if (work[i-1] != T()){
if (work[i-1] != T()) {
addModelItem(folder, lcfops::id_with_name(i-1, ToQString(work[i-1].name)), "+", 1);
}
}
} else if (orig.size() > work.size()) {
// note non-empty removals in removed chunks
for (int i = work.size(); i == orig.size(); i++) {
if (orig[i-1] != T()){
if (orig[i-1] != T()) {
addModelItem(folder, lcfops::id_with_name(i-1, ToQString(orig[i-1].name)), "i", 1);
}
}
}
// note additions for slots shared between both databases
for (int i = 0, total = (work.size() < orig.size() ? orig.size() - 1 : work.size() - 1); i <= total; ++i) {
if (orig[i] != work[i]){
addModelItem(folder, lcfops::id_with_name(i, ToQString(work[i].name)), lcfops::compare<T>(orig[i], work[i]), 1);
if (orig[i] != work[i]) {
QString comp = lcfops::compare<T>(orig[i], work[i]);
if (comp == "-") {
addModelItem(folder, lcfops::id_with_name(i, ToQString(orig[i].name)), comp, 1);
} else {
addModelItem(folder, lcfops::id_with_name(i, ToQString(work[i].name)), comp, 1);
}
}
}
}
Expand Down

0 comments on commit 6d2a411

Please sign in to comment.