diff --git a/src/changelogwidget.cpp b/src/changelogwidget.cpp index b3cfc86..9eb86ca 100644 --- a/src/changelogwidget.cpp +++ b/src/changelogwidget.cpp @@ -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*\\(|$)"); @@ -61,7 +61,7 @@ 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)); } @@ -69,7 +69,7 @@ void ChangelogWidget::on_pushButton_clicked() { // 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)); } @@ -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."); diff --git a/src/main.cpp b/src/main.cpp index d326b7d..4aa4483 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,9 @@ #include int main(int argc, char *argv[]) { + #ifdef _WIN32 + setlocale(LC_ALL, ".UTF8") + #endif QApplication a(argc, argv); DirectoryDialog d; if (d.exec()) { diff --git a/src/pickerwidget.cpp b/src/pickerwidget.cpp index 1067827..eac1799 100644 --- a/src/pickerwidget.cpp +++ b/src/pickerwidget.cpp @@ -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 map = lcf::LMU_Reader::Load(to_map.toStdString()); + std::unique_ptr map = lcf::LMU_Reader::Load(to_map.toUtf8().data()); map_outgoing[to_id] = QList(); for (lcf::rpg::Event i : map->events) { for (lcf::rpg::EventPage j : i.pages) { @@ -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 connections_raw; - std::unique_ptr current_map = lcf::LMU_Reader::Load(QString(path + QString("/Map%1.lmu").arg(lcfops::paddedint(id, 4))).toStdString()); + std::unique_ptr 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; @@ -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 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) { + std::unique_ptr orig_db = lcf::LDB_Reader::Load((orig_path + "/RPG_RT.ldb").toUtf8().data(), "UTF-8"); + std::unique_ptr 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 @@ -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 maptree = lcf::LMT_Reader::Load(QString(work_path + "/RPG_RT.lmt").toStdString()); + std::unique_ptr maptree = lcf::LMT_Reader::Load(QString(work_path + "/RPG_RT.lmt").toUtf8().data()); log.append("|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|"); log.append(""); log.append("Developer:");