forked from teamnwah/openmw-tes3coop
re-enabled OGRE in OpenCS; cleaned up startup
This commit is contained in:
parent
c62a352956
commit
6ec86564d1
4 changed files with 41 additions and 49 deletions
|
@ -9,15 +9,22 @@
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
#include <OgreRenderWindow.h>
|
#include <OgreRenderWindow.h>
|
||||||
|
|
||||||
|
#include <components/ogreinit/ogreinit.hpp>
|
||||||
|
|
||||||
#include "model/doc/document.hpp"
|
#include "model/doc/document.hpp"
|
||||||
#include "model/world/data.hpp"
|
#include "model/world/data.hpp"
|
||||||
|
|
||||||
CS::Editor::Editor()
|
CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
|
||||||
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager)
|
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager),
|
||||||
|
mIpcServerName ("org.openmw.OpenCS")
|
||||||
{
|
{
|
||||||
mIpcServerName = "org.openmw.OpenCS";
|
Files::PathContainer dataDirs = readConfig();
|
||||||
|
|
||||||
setupDataFiles();
|
setupDataFiles (dataDirs);
|
||||||
|
|
||||||
|
CSMSettings::UserSettings::instance().loadSettings ("opencs.cfg");
|
||||||
|
|
||||||
|
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
|
||||||
|
|
||||||
mNewGame.setLocalData (mLocal);
|
mNewGame.setLocalData (mLocal);
|
||||||
mFileDialog.setLocalData (mLocal);
|
mFileDialog.setLocalData (mLocal);
|
||||||
|
@ -42,7 +49,16 @@ CS::Editor::Editor()
|
||||||
this, SLOT (createNewGame (const boost::filesystem::path&)));
|
this, SLOT (createNewGame (const boost::filesystem::path&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CS::Editor::setupDataFiles()
|
void CS::Editor::setupDataFiles (const Files::PathContainer& dataDirs)
|
||||||
|
{
|
||||||
|
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
|
||||||
|
{
|
||||||
|
QString path = QString::fromStdString(iter->string());
|
||||||
|
mFileDialog.addFiles(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Files::PathContainer CS::Editor::readConfig()
|
||||||
{
|
{
|
||||||
boost::program_options::variables_map variables;
|
boost::program_options::variables_map variables;
|
||||||
boost::program_options::options_description desc("Syntax: opencs <options>\nAllowed options");
|
boost::program_options::options_description desc("Syntax: opencs <options>\nAllowed options");
|
||||||
|
@ -58,6 +74,8 @@ void CS::Editor::setupDataFiles()
|
||||||
|
|
||||||
mCfgMgr.readConfiguration(variables, desc);
|
mCfgMgr.readConfiguration(variables, desc);
|
||||||
|
|
||||||
|
mDocumentManager.setResourceDir (variables["resources"].as<std::string>());
|
||||||
|
|
||||||
Files::PathContainer dataDirs, dataLocal;
|
Files::PathContainer dataDirs, dataLocal;
|
||||||
if (!variables["data"].empty()) {
|
if (!variables["data"].empty()) {
|
||||||
dataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
dataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||||
|
@ -83,23 +101,11 @@ void CS::Editor::setupDataFiles()
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
|
|
||||||
QApplication::exit (1);
|
QApplication::exit (1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
||||||
|
|
||||||
mDocumentManager.setResourceDir (variables["resources"].as<std::string>());
|
return dataDirs;
|
||||||
|
|
||||||
for (Files::PathContainer::const_iterator iter = dataDirs.begin(); iter != dataDirs.end(); ++iter)
|
|
||||||
{
|
|
||||||
|
|
||||||
QString path = QString::fromStdString(iter->string());
|
|
||||||
mFileDialog.addFiles(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
//load the settings into the userSettings instance.
|
|
||||||
const QString settingFileName = "opencs.cfg";
|
|
||||||
CSMSettings::UserSettings::instance().loadSettings(settingFileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CS::Editor::createGame()
|
void CS::Editor::createGame()
|
||||||
|
@ -210,8 +216,6 @@ int CS::Editor::run()
|
||||||
if (mLocal.empty())
|
if (mLocal.empty())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// temporarily disable OGRE-integration (need to fix path problem first)
|
|
||||||
#if 0
|
|
||||||
// TODO: setting
|
// TODO: setting
|
||||||
Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName("OpenGL Rendering Subsystem"));
|
Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName("OpenGL Rendering Subsystem"));
|
||||||
|
|
||||||
|
@ -228,7 +232,6 @@ int CS::Editor::run()
|
||||||
#endif
|
#endif
|
||||||
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms);
|
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, ¶ms);
|
||||||
hiddenWindow->setActive(false);
|
hiddenWindow->setActive(false);
|
||||||
#endif
|
|
||||||
|
|
||||||
mStartup.show();
|
mStartup.show();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <components/files/multidircollection.hpp>
|
||||||
|
|
||||||
#include "model/settings/usersettings.hpp"
|
#include "model/settings/usersettings.hpp"
|
||||||
#include "model/doc/documentmanager.hpp"
|
#include "model/doc/documentmanager.hpp"
|
||||||
|
|
||||||
|
@ -20,6 +22,11 @@
|
||||||
|
|
||||||
#include "view/settings/usersettingsdialog.hpp"
|
#include "view/settings/usersettingsdialog.hpp"
|
||||||
|
|
||||||
|
namespace OgreInit
|
||||||
|
{
|
||||||
|
class OgreInit;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CS
|
namespace CS
|
||||||
{
|
{
|
||||||
class Editor : public QObject
|
class Editor : public QObject
|
||||||
|
@ -37,7 +44,10 @@ namespace CS
|
||||||
|
|
||||||
boost::filesystem::path mLocal;
|
boost::filesystem::path mLocal;
|
||||||
|
|
||||||
void setupDataFiles();
|
void setupDataFiles (const Files::PathContainer& dataDirs);
|
||||||
|
|
||||||
|
Files::PathContainer readConfig();
|
||||||
|
///< \return data paths
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Editor (const Editor&);
|
Editor (const Editor&);
|
||||||
|
@ -45,7 +55,7 @@ namespace CS
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Editor();
|
Editor (OgreInit::OgreInit& ogreInit);
|
||||||
|
|
||||||
bool makeIPCServer();
|
bool makeIPCServer();
|
||||||
void connectToIPCServer();
|
void connectToIPCServer();
|
||||||
|
|
|
@ -40,15 +40,9 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE (resources);
|
Q_INIT_RESOURCE (resources);
|
||||||
|
|
||||||
// TODO: Ogre startup shouldn't be here, but it currently has to:
|
|
||||||
// SceneWidget destructor will delete the created render window, which would be called _after_ Root has shut down :(
|
|
||||||
|
|
||||||
Application mApplication (argc, argv);
|
|
||||||
// temporarily disable OGRE-integration (need to fix path problem first)
|
|
||||||
#if 0
|
|
||||||
OgreInit::OgreInit ogreInit;
|
OgreInit::OgreInit ogreInit;
|
||||||
ogreInit.init("./opencsOgre.log"); // TODO log path?
|
|
||||||
#endif
|
Application application (argc, argv);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QDir dir(QCoreApplication::applicationDirPath());
|
QDir dir(QCoreApplication::applicationDirPath());
|
||||||
|
@ -66,12 +60,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
QStringList libraryPaths;
|
QStringList libraryPaths;
|
||||||
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
|
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
|
||||||
mApplication.setLibraryPaths(libraryPaths);
|
application.setLibraryPaths(libraryPaths);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mApplication.setWindowIcon (QIcon (":./opencs.png"));
|
application.setWindowIcon (QIcon (":./opencs.png"));
|
||||||
|
|
||||||
CS::Editor editor;
|
CS::Editor editor (ogreInit);
|
||||||
|
|
||||||
if(!editor.makeIPCServer())
|
if(!editor.makeIPCServer())
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,26 +43,11 @@ toolbar->addTool (new SceneToolMode (toolbar));
|
||||||
toolbar->addTool (new SceneToolMode (toolbar));
|
toolbar->addTool (new SceneToolMode (toolbar));
|
||||||
layout2->addWidget (toolbar, 0);
|
layout2->addWidget (toolbar, 0);
|
||||||
|
|
||||||
// temporarily disable OGRE-integration (need to fix path problem first)
|
|
||||||
#if 0
|
|
||||||
CSVRender::SceneWidget* sceneWidget = new CSVRender::SceneWidget(this);
|
CSVRender::SceneWidget* sceneWidget = new CSVRender::SceneWidget(this);
|
||||||
|
|
||||||
layout2->addWidget (sceneWidget, 1);
|
layout2->addWidget (sceneWidget, 1);
|
||||||
|
|
||||||
layout->insertLayout (0, layout2, 1);
|
layout->insertLayout (0, layout2, 1);
|
||||||
#endif
|
|
||||||
/// \todo replace with rendering widget
|
|
||||||
QPalette palette2 (palette());
|
|
||||||
palette2.setColor (QPalette::Background, Qt::white);
|
|
||||||
QLabel *placeholder = new QLabel ("Here goes the 3D scene", this);
|
|
||||||
placeholder->setAutoFillBackground (true);
|
|
||||||
placeholder->setPalette (palette2);
|
|
||||||
placeholder->setAlignment (Qt::AlignHCenter);
|
|
||||||
|
|
||||||
layout2->addWidget (placeholder, 1);
|
|
||||||
|
|
||||||
layout->insertLayout (0, layout2, 1);
|
|
||||||
|
|
||||||
|
|
||||||
CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this);
|
CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue