forked from mirror/openmw-tes3mp
added OpenMW runner
This commit is contained in:
parent
a9df3b53fd
commit
1b4ab6e130
7 changed files with 110 additions and 1 deletions
|
@ -5,7 +5,7 @@ opencs_units (. editor)
|
|||
set (CMAKE_BUILD_TYPE DEBUG)
|
||||
|
||||
opencs_units (model/doc
|
||||
document operation saving documentmanager loader
|
||||
document operation saving documentmanager loader runner
|
||||
)
|
||||
|
||||
opencs_units_noqt (model/doc
|
||||
|
|
|
@ -2367,6 +2367,16 @@ bool CSMDoc::Document::isBlacklisted (const CSMWorld::UniversalId& id)
|
|||
return mBlacklist.isBlacklisted (id);
|
||||
}
|
||||
|
||||
void CSMDoc::Document::startRunning (const std::string& profile,
|
||||
const std::string& startupInstruction)
|
||||
{
|
||||
mRunner.start();
|
||||
}
|
||||
|
||||
void CSMDoc::Document::stopRunning()
|
||||
{
|
||||
mRunner.stop();
|
||||
}
|
||||
|
||||
void CSMDoc::Document::progress (int current, int max, int type)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "state.hpp"
|
||||
#include "saving.hpp"
|
||||
#include "blacklist.hpp"
|
||||
#include "runner.hpp"
|
||||
|
||||
class QAbstractItemModel;
|
||||
|
||||
|
@ -54,6 +55,7 @@ namespace CSMDoc
|
|||
Saving mSaving;
|
||||
boost::filesystem::path mResDir;
|
||||
Blacklist mBlacklist;
|
||||
Runner mRunner;
|
||||
|
||||
// It is important that the undo stack is declared last, because on desctruction it fires a signal, that is connected to a slot, that is
|
||||
// using other member variables. Unfortunately this connection is cut only in the QObject destructor, which is way too late.
|
||||
|
@ -115,6 +117,11 @@ namespace CSMDoc
|
|||
|
||||
bool isBlacklisted (const CSMWorld::UniversalId& id) const;
|
||||
|
||||
void startRunning (const std::string& profile,
|
||||
const std::string& startupInstruction = "");
|
||||
|
||||
void stopRunning();
|
||||
|
||||
signals:
|
||||
|
||||
void stateChanged (int state, CSMDoc::Document *document);
|
||||
|
|
35
apps/opencs/model/doc/runner.cpp
Normal file
35
apps/opencs/model/doc/runner.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
|
||||
#include "runner.hpp"
|
||||
|
||||
|
||||
CSMDoc::Runner::Runner()
|
||||
{
|
||||
connect (&mProcess, SIGNAL (finished (int, QProcess::ExitStatus)),
|
||||
this, SLOT (finished (int, QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::start()
|
||||
{
|
||||
QString path = "openmw";
|
||||
#ifdef Q_OS_WIN
|
||||
path.append(QString(".exe"));
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
path = dir.absoluteFilePath(name);
|
||||
#else
|
||||
path.prepend(QString("./"));
|
||||
#endif
|
||||
|
||||
mProcess.start (path);
|
||||
emit runStateChanged (true);
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::stop()
|
||||
{
|
||||
mProcess.kill();
|
||||
}
|
||||
|
||||
void CSMDoc::Runner::finished (int exitCode, QProcess::ExitStatus exitStatus)
|
||||
{
|
||||
emit runStateChanged (false);
|
||||
}
|
33
apps/opencs/model/doc/runner.hpp
Normal file
33
apps/opencs/model/doc/runner.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef CSM_DOC_RUNNER_H
|
||||
#define CSM_DOC_RUNNER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Runner : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QProcess mProcess;
|
||||
|
||||
public:
|
||||
|
||||
Runner();
|
||||
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
|
||||
void runStateChanged (bool running);
|
||||
|
||||
private slots:
|
||||
|
||||
void finished (int exitCode, QProcess::ExitStatus exitStatus);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -239,6 +239,16 @@ void CSVDoc::View::setupDebugMenu()
|
|||
QAction *profiles = new QAction (tr ("Debug Profiles"), this);
|
||||
connect (profiles, SIGNAL (triggered()), this, SLOT (addDebugProfilesSubView()));
|
||||
debug->addAction (profiles);
|
||||
|
||||
debug->addSeparator();
|
||||
|
||||
QAction *run = new QAction (tr ("Run OpenMW"), this);
|
||||
connect (run, SIGNAL (triggered()), this, SLOT (run()));
|
||||
debug->addAction (run);
|
||||
|
||||
QAction *stop = new QAction (tr ("Shutdown OpenMW"), this);
|
||||
connect (stop, SIGNAL (triggered()), this, SLOT (stop()));
|
||||
debug->addAction (stop);
|
||||
}
|
||||
|
||||
void CSVDoc::View::setupUi()
|
||||
|
@ -603,3 +613,13 @@ void CSVDoc::View::loadErrorLog()
|
|||
{
|
||||
addSubView (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_LoadErrorLog, 0));
|
||||
}
|
||||
|
||||
void CSVDoc::View::run()
|
||||
{
|
||||
mDocument->startRunning ("", "");
|
||||
}
|
||||
|
||||
void CSVDoc::View::stop()
|
||||
{
|
||||
mDocument->stopRunning();
|
||||
}
|
|
@ -201,6 +201,10 @@ namespace CSVDoc
|
|||
void toggleShowStatusBar (bool show);
|
||||
|
||||
void loadErrorLog();
|
||||
|
||||
void run();
|
||||
|
||||
void stop();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue