Skip to content

Commit

Permalink
try to fix the windows thing again
Browse files Browse the repository at this point in the history
  • Loading branch information
lumiscosity committed Nov 30, 2024
1 parent 2f7c9b0 commit 40527ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/changelogwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ void ChangelogWidget::set_text(QString text) {
void ChangelogWidget::on_pushButton_clicked() {
QString out = QFileDialog::getSaveFileName(this, "Select save location", "", "Archive (*.zip)");
if (!out.isEmpty()) {
auto c = ui->plainTextEdit->toPlainText().toStdString();
auto c = ui->plainTextEdit->toPlainText().toUtf8().data();
// create an archive from all the files and the changelog
// i don't actually trust people to not remove stuff after the treeview step, so we treat the changelog as the file list instead
// this does pose some annoyances with filenames, which can contain spaces, but we have a fallback

try {
minidocx::Zip z;
z.open(out.toStdString(), minidocx::Zip::OpenMode::Create);
z.open(out.toUtf8().data(), minidocx::Zip::OpenMode::Create);

QRegularExpression ex("^[^ ]* [^ ]*\\[.*$");
QRegularExpression fileex("^(?:\\S+\\s+){2}(.*?)(?:\\s*\\(|$)");
Expand All @@ -61,15 +61,15 @@ void ChangelogWidget::on_pushButton_clicked() {
// map
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());
z.addFileFromDisk(map_string.toUtf8().data(), QString(work_dir + map_string).toUtf8().data());
} 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
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());
z.addFileFromDisk(file_string.toUtf8().data(), QString(work_dir + file_string).toUtf8().data());
} 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));
}
Expand All @@ -79,8 +79,8 @@ void ChangelogWidget::on_pushButton_clicked() {
}

z.addFileFromString("changelog.txt", c);
z.addFileFromDisk("/RPG_RT.lmt", work_dir.toStdString() + "/RPG_RT.lmt");
z.addFileFromDisk("/RPG_RT.ldb", work_dir.toStdString() + "/RPG_RT.ldb");
z.addFileFromDisk("/RPG_RT.lmt", (work_dir + "/RPG_RT.lmt").toUtf8().data());
z.addFileFromDisk("/RPG_RT.ldb", (work_dir + "/RPG_RT.ldb").toUtf8().data());

z.close();
QMessageBox::information(this, "Success", "Patch compiled successfully.");
Expand Down
3 changes: 3 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include <QApplication>

int main(int argc, char *argv[]) {
#ifdef _WIN32
setlocale(LC_ALL, ".UTF8")
#endif
QApplication a(argc, argv);

Check failure on line 28 in src/main.cpp

View workflow job for this annotation

GitHub Actions / Windows

syntax error: missing ';' before identifier 'QApplication'
DirectoryDialog d;
if (d.exec()) {
Expand Down
12 changes: 6 additions & 6 deletions src/pickerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool PickerWidget::is_oneway(int from_id, int to_id, QString to_map) {
return !map_outgoing[to_id].contains(from_id);
} else {
// find and cache the destination id of every transfer in the map
std::unique_ptr<lcf::rpg::Map> map = lcf::LMU_Reader::Load(to_map.toStdString());
std::unique_ptr<lcf::rpg::Map> map = lcf::LMU_Reader::Load(to_map.toUtf8().data());
map_outgoing[to_id] = QList<int>();
for (lcf::rpg::Event i : map->events) {
for (lcf::rpg::EventPage j : i.pages) {
Expand Down Expand Up @@ -97,7 +97,7 @@ void PickerWidget::addModelItem(QString folder, QString name, QString type, int

void PickerWidget::genmapmeta(QStringList &bgm, QStringList &connections, QString path, int id) {
QList<lcfops::connection_info> connections_raw;
std::unique_ptr<lcf::rpg::Map> current_map = lcf::LMU_Reader::Load(QString(path + QString("/Map%1.lmu").arg(lcfops::paddedint(id, 4))).toStdString());
std::unique_ptr<lcf::rpg::Map> current_map = lcf::LMU_Reader::Load(QString(path + QString("/Map%1.lmu").arg(lcfops::paddedint(id, 4))).toUtf8().data());
for (lcf::rpg::Event i : current_map->events) {
for (lcf::rpg::EventPage j : i.pages) {
int last_teleport = 0;
Expand Down Expand Up @@ -252,9 +252,9 @@ void PickerWidget::gendiff(QString orig_path, QString work_path) {
}
ui->treeWidget->sortItems(0, Qt::SortOrder::AscendingOrder);
// get ldb data
std::unique_ptr<lcf::rpg::Database> orig_db = lcf::LDB_Reader::Load((orig_path + "/RPG_RT.ldb").toStdString(), "UTF-8");
std::unique_ptr<lcf::rpg::Database> work_db = lcf::LDB_Reader::Load((work_path + "/RPG_RT.ldb").toStdString(), "UTF-8");
if (orig_db == nullptr | work_db == nullptr) {
std::unique_ptr<lcf::rpg::Database> orig_db = lcf::LDB_Reader::Load((orig_path + "/RPG_RT.ldb").toUtf8().data(), "UTF-8");
std::unique_ptr<lcf::rpg::Database> work_db = lcf::LDB_Reader::Load((work_path + "/RPG_RT.ldb").toUtf8().data(), "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
Expand Down Expand Up @@ -300,7 +300,7 @@ void PickerWidget::gendiff(QString orig_path, QString work_path) {
QString PickerWidget::genlog(QString orig_path, QString work_path) {
// create log header
QStringList log;
std::unique_ptr<lcf::rpg::TreeMap> maptree = lcf::LMT_Reader::Load(QString(work_path + "/RPG_RT.lmt").toStdString());
std::unique_ptr<lcf::rpg::TreeMap> maptree = lcf::LMT_Reader::Load(QString(work_path + "/RPG_RT.lmt").toUtf8().data());
log.append("|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|");
log.append("");
log.append("Developer:");
Expand Down

0 comments on commit 40527ec

Please sign in to comment.