re-enabled OGRE in OpenCS; cleaned up startup

actorid
Marc Zinnschlag 11 years ago
parent c62a352956
commit 6ec86564d1

@ -9,15 +9,22 @@
#include <OgreRoot.h>
#include <OgreRenderWindow.h>
#include <components/ogreinit/ogreinit.hpp>
#include "model/doc/document.hpp"
#include "model/world/data.hpp"
CS::Editor::Editor()
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager)
CS::Editor::Editor (OgreInit::OgreInit& ogreInit)
: mDocumentManager (mCfgMgr), mViewManager (mDocumentManager),
mIpcServerName ("org.openmw.OpenCS")
{
mIpcServerName = "org.openmw.OpenCS";
Files::PathContainer dataDirs = readConfig();
setupDataFiles (dataDirs);
CSMSettings::UserSettings::instance().loadSettings ("opencs.cfg");
setupDataFiles();
ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string());
mNewGame.setLocalData (mLocal);
mFileDialog.setLocalData (mLocal);
@ -42,7 +49,16 @@ CS::Editor::Editor()
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::options_description desc("Syntax: opencs <options>\nAllowed options");
@ -58,6 +74,8 @@ void CS::Editor::setupDataFiles()
mCfgMgr.readConfiguration(variables, desc);
mDocumentManager.setResourceDir (variables["resources"].as<std::string>());
Files::PathContainer dataDirs, dataLocal;
if (!variables["data"].empty()) {
dataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
@ -83,23 +101,11 @@ void CS::Editor::setupDataFiles()
messageBox.exec();
QApplication::exit (1);
return;
}
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
mDocumentManager.setResourceDir (variables["resources"].as<std::string>());
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);
return dataDirs;
}
void CS::Editor::createGame()
@ -210,8 +216,6 @@ int CS::Editor::run()
if (mLocal.empty())
return 1;
// temporarily disable OGRE-integration (need to fix path problem first)
#if 0
// TODO: setting
Ogre::Root::getSingleton().setRenderSystem(Ogre::Root::getSingleton().getRenderSystemByName("OpenGL Rendering Subsystem"));
@ -228,7 +232,6 @@ int CS::Editor::run()
#endif
Ogre::RenderWindow* hiddenWindow = Ogre::Root::getSingleton().createRenderWindow("InactiveHidden", 1, 1, false, &params);
hiddenWindow->setActive(false);
#endif
mStartup.show();

@ -10,6 +10,8 @@
#include <components/files/configurationmanager.hpp>
#endif
#include <components/files/multidircollection.hpp>
#include "model/settings/usersettings.hpp"
#include "model/doc/documentmanager.hpp"
@ -20,6 +22,11 @@
#include "view/settings/usersettingsdialog.hpp"
namespace OgreInit
{
class OgreInit;
}
namespace CS
{
class Editor : public QObject
@ -37,7 +44,10 @@ namespace CS
boost::filesystem::path mLocal;
void setupDataFiles();
void setupDataFiles (const Files::PathContainer& dataDirs);
Files::PathContainer readConfig();
///< \return data paths
// not implemented
Editor (const Editor&);
@ -45,7 +55,7 @@ namespace CS
public:
Editor();
Editor (OgreInit::OgreInit& ogreInit);
bool makeIPCServer();
void connectToIPCServer();

@ -40,15 +40,9 @@ int main(int argc, char *argv[])
{
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.init("./opencsOgre.log"); // TODO log path?
#endif
Application application (argc, argv);
#ifdef Q_OS_MAC
QDir dir(QCoreApplication::applicationDirPath());
@ -66,12 +60,12 @@ int main(int argc, char *argv[])
QStringList libraryPaths;
libraryPaths << pluginsPath.path() << QCoreApplication::applicationDirPath();
mApplication.setLibraryPaths(libraryPaths);
application.setLibraryPaths(libraryPaths);
#endif
mApplication.setWindowIcon (QIcon (":./opencs.png"));
application.setWindowIcon (QIcon (":./opencs.png"));
CS::Editor editor;
CS::Editor editor (ogreInit);
if(!editor.makeIPCServer())
{

@ -43,26 +43,11 @@ toolbar->addTool (new SceneToolMode (toolbar));
toolbar->addTool (new SceneToolMode (toolbar));
layout2->addWidget (toolbar, 0);
// temporarily disable OGRE-integration (need to fix path problem first)
#if 0
CSVRender::SceneWidget* sceneWidget = new CSVRender::SceneWidget(this);
layout2->addWidget (sceneWidget, 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);

Loading…
Cancel
Save