Skip to content

Commit

Permalink
Gloom: Run as a Qt application
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 24240e1 commit 09e3244
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
18 changes: 15 additions & 3 deletions doomsday/apps/gloom/src/gloomapp.cpp
Expand Up @@ -30,6 +30,8 @@
#include <de/ScriptSystem>
#include <doomsday/DataBundle>

#include <QApplication>

using namespace de;
using namespace gloom;

Expand All @@ -52,8 +54,11 @@ DE_PIMPL(GloomApp)
{
// Windows will be closed; OpenGL context will be gone.
// Deinitalize everything.
winSys->main().glActivate();
world->glDeinit();
if (winSys->mainExists())
{
winSys->main().glActivate();
world->glDeinit();
}
world.reset();

self().glDeinit();
Expand All @@ -78,6 +83,12 @@ GloomApp::GloomApp(const StringList &args)
{
setMetadata("Deng Team", "dengine.net", "Gloom Test", "1.0");
setUnixHomeFolderName(".gloom");

const auto &amd = metadata();
qApp->setApplicationName (convert(amd.gets(APP_NAME)));
qApp->setApplicationVersion(convert(amd.gets(APP_VERSION)));
qApp->setOrganizationName (convert(amd.gets(ORG_NAME)));
qApp->setOrganizationDomain(convert(amd.gets(ORG_DOMAIN)));
}

void GloomApp::initialize()
Expand Down Expand Up @@ -126,7 +137,6 @@ void GloomApp::initialize()
});
}

DisplayMode_Init();
addInitPackage("net.dengine.gloom");
initSubsystems(App::DisablePlugins);

Expand Down Expand Up @@ -155,6 +165,8 @@ void GloomApp::initialize()

scriptSystem().importModule("bootstrap");
win->show();

Loop::get().audienceForIteration() += [this]() { qApp->processEvents(); };
}

QDir GloomApp::userDir() const
Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/gloom/src/gloomapp.h
Expand Up @@ -25,6 +25,7 @@
#include "appwindowsystem.h"

#include <QDir>
#include <QApplication>

class GloomApp : public de::BaseGuiApp
{
Expand Down
4 changes: 3 additions & 1 deletion doomsday/apps/gloom/src/main.cpp
Expand Up @@ -20,13 +20,15 @@
#include "mainwindow.h"
#include "utils.h"
#include <de/EscapeParser>
#include <QApplication>
#include <QMessageBox>
#include <QDebug>

using namespace de;

int main(int argc, char **argv)
{
QApplication qtApp(argc, argv);
GloomApp app(makeList(argc, argv));
try
{
Expand All @@ -38,7 +40,7 @@ int main(int argc, char **argv)
EscapeParser esc;
esc.parse(er.asText());
warning( "App init failed: %s", esc.plainText().c_str());
QMessageBox::critical(0, "test_gloom", convert("App init failed:\n" + esc.plainText()));
QMessageBox::critical(0, "Gloom", convert("App init failed:\n" + esc.plainText()));
return -1;
}

Expand Down

0 comments on commit 09e3244

Please sign in to comment.