From 693edeb159f3ebd31721d5b72e492d719e95e7a2 Mon Sep 17 00:00:00 2001 From: Greg Williamson Date: Tue, 17 Nov 2020 11:16:28 -0500 Subject: [PATCH] fix build (#197) updates submodule and fixes build after libEGM API changes --- Editors/BackgroundEditor.cpp | 8 ++++---- Editors/SoundEditor.cpp | 8 ++++---- MainWindow.cpp | 18 ++++-------------- MainWindow.h | 1 - Submodules/enigma-dev | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Editors/BackgroundEditor.cpp b/Editors/BackgroundEditor.cpp index 6ccd52180..c0ed359ba 100644 --- a/Editors/BackgroundEditor.cpp +++ b/Editors/BackgroundEditor.cpp @@ -76,11 +76,11 @@ void BackgroundEditor::on_actionLoadImage_triggered() { if (dialog->exec() && dialog->selectedFiles().size() > 0) { QString fName = dialog->selectedFiles()[0]; - if (fName.endsWith("Background.gmx")) { - Background* bkg = gmx::LoadBackground(fName.toStdString()); - if (bkg != nullptr) { + if (fName.endsWith("Background.gmx") || fName.endsWith(".bkg")) { + std::optional bkg = egm::LoadResource(fName.toStdString()); + if (bkg.has_value()) { // QString lastData = GetModelData(Background::kImageFieldNumber).toString(); - ReplaceBuffer(bkg); + ReplaceBuffer(&bkg.value()); // QString newData = GetModelData(Background::kImageFieldNumber).toString(); // TODO: Copy data into our egm and reset the path // SetModelData(Background::kImageFieldNumber, lastData); diff --git a/Editors/SoundEditor.cpp b/Editors/SoundEditor.cpp index 406790c73..0bd82eed9 100644 --- a/Editors/SoundEditor.cpp +++ b/Editors/SoundEditor.cpp @@ -114,11 +114,11 @@ void SoundEditor::on_loadButton_clicked() { if (dialog->exec() && dialog->selectedFiles().size() > 0) { QString fName = dialog->selectedFiles()[0]; - if (fName.endsWith("Sound.gmx")) { - Sound* snd = gmx::LoadSound(fName.toStdString()); - if (snd != nullptr) { + if (fName.endsWith("Sound.gmx") || fName.endsWith(".spr")) { + std::optional snd = egm::LoadResource(fName.toStdString()); + if (snd.has_value()) { // QString lastData = GetModelData(Sound::kDataFieldNumber).toString(); - ReplaceBuffer(snd); + ReplaceBuffer(&snd.value()); // QString newData = GetModelData(Sound::kDataFieldNumber).toString(); // TODO: Copy data into our egm and reset the path // SetModelData(Sound::kDataFieldNumber, lastData); diff --git a/MainWindow.cpp b/MainWindow.cpp index fd57d8749..a6fc240d4 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -101,7 +101,7 @@ QFileInfo MainWindow::getEnigmaRoot() { return EnigmaRoot; } -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), _ui(new Ui::MainWindow), egm(nullptr) { +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), _ui(new Ui::MainWindow){ if (!EnigmaRoot.filePath().isEmpty()) { _event_data = std::make_unique(ParseEventFile((EnigmaRoot.absolutePath() + "/events.ey").toStdString())); @@ -114,7 +114,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), _ui(new Ui::MainW _event_data = std::make_unique(ParseEventFile(ss)); } - egm = egm::EGM(_event_data.get()); + egm::LibEGMInit(_event_data.get()); ArtManager::Init(); @@ -304,18 +304,8 @@ void MainWindow::updateWindowMenu() { void MainWindow::openFile(QString fName) { QFileInfo fileInfo(fName); - const QString suffix = fileInfo.suffix(); - - std::unique_ptr loadedProject = nullptr; - if (suffix == "egm") { - loadedProject = egm.LoadEGM(fName.toStdString()); - } else if (suffix == "gm81" || suffix == "gmk" || suffix == "gm6" || suffix == "gmd") { - loadedProject = gmk::LoadGMK(fName.toStdString(), _event_data.get()); - } else if (suffix == "gmx") { - loadedProject = gmx::LoadGMX(fName.toStdString(), _event_data.get()); - } else if (suffix == "yyp") { - loadedProject = yyp::LoadYYP(fName.toStdString(), _event_data.get()); - } + + std::unique_ptr loadedProject = egm::LoadProject(fName.toStdString()); if (!loadedProject) { QMessageBox::warning(this, tr("Failed To Open Project"), tr("There was a problem loading the project: ") + fName, diff --git a/MainWindow.h b/MainWindow.h index 1c7353206..4b946813c 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -115,7 +115,6 @@ class MainWindow : public QMainWindow { QPointer _recentFiles; static std::unique_ptr _event_data; - egm::EGM egm; void openSubWindow(buffers::TreeNode *item); void readSettings(); diff --git a/Submodules/enigma-dev b/Submodules/enigma-dev index f82929201..06d67399b 160000 --- a/Submodules/enigma-dev +++ b/Submodules/enigma-dev @@ -1 +1 @@ -Subproject commit f829292014cc870cf05a7484b26496612742279d +Subproject commit 06d67399bc1917e873476350f43729904d56623d