Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Proto defaults #222

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "gmx.h"
#include "yyp.h"

#include <google/protobuf/text_format.h>

#include <QtWidgets>
#include <QFile>

Expand Down Expand Up @@ -182,6 +184,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), _ui(new Ui::MainW
connect(_ui->actionDebug, &QAction::triggered, pluginServer, &RGMPlugin::Debug);
connect(_ui->actionCreateExecutable, &QAction::triggered, pluginServer, &RGMPlugin::CreateExecutable);

openDefaultsProject();
openNewProject();
}

Expand Down Expand Up @@ -311,6 +314,18 @@ void MainWindow::openNewProject() {
openProject(std::move(newProject));
}

void MainWindow::openDefaultsProject() {
QString deafultProjectPath = "/path/to/default.egm";
_defaults_project = egm::LoadProject(deafultProjectPath.toStdString());

if (!_defaults_project) {
QMessageBox::warning(this, tr("Failed To Open Default Project"),
tr("There was a problem loading the egm defaults project from ") + deafultProjectPath,
QMessageBox::Ok);
return;
}
}

template <typename Editor>
TreeModel::EditorLauncher Launch(MainWindow *parent) {
struct EditorFactoryFactory {
Expand Down Expand Up @@ -466,6 +481,16 @@ void MainWindow::on_actionOpen_triggered() {
"(*.yyp);;GameMaker: Studio Projects (*.project.gmx);;Classic "
"GameMaker Files (*.gm81 *.gmk *.gm6 *.gmd);;All Files (*)"));
if (!fileName.isEmpty()) openFile(fileName);
std::cout<<fileName.toStdString()<<std::endl;
}

void MainWindow::on_actionSave_triggered() {
const QString &filter = "EGM (*.egm)";
const QString &fileName = QFileDialog::getSaveFileName(this, tr("Save Project"), "", filter);

if (!fileName.isEmpty()) {
egm::WriteProject(_project.get(), fileName.toStdString());
}
}

void MainWindow::on_actionPreferences_triggered() {
Expand Down
5 changes: 5 additions & 0 deletions MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class MainWindow : public QMainWindow {
void on_actionNew_triggered();
void on_actionOpen_triggered();
void on_actionClearRecentMenu_triggered();
void on_actionSave_triggered();
void on_actionPreferences_triggered();
void on_actionExit_triggered();

Expand Down Expand Up @@ -118,6 +119,7 @@ class MainWindow : public QMainWindow {
Ui::MainWindow *_ui;

std::unique_ptr<buffers::Project> _project;
std::unique_ptr<buffers::Project> _defaults_project;
QPointer<RecentFiles> _recentFiles;

static std::unique_ptr<EventData> _event_data;
Expand All @@ -126,6 +128,9 @@ class MainWindow : public QMainWindow {
void writeSettings();
void setTabbedMode(bool enabled);
static QFileInfo getEnigmaRoot();
// load an egm project and save it internally in _defaults_project, helpful for referring defaults during resource
// creation and also allow user to edit and save for future reference
void openDefaultsProject();
};

#endif // MAINWINDOW_H