Make configuration and log paths configurable

actorid
Jan-Peter Nilsson 14 years ago
parent 3a17aaa697
commit 7185eab18c

@ -6,7 +6,7 @@
using namespace OEngine::GUI;
void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging)
void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging, const std::string& logDir)
{
assert(wnd);
assert(mgr);
@ -21,13 +21,17 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
LogManager::initialise();
LogManager::setSTDOutputEnabled(logging);
std::string theLogFile = std::string(MYGUI_PLATFORM_LOG_FILENAME);
if(!logDir.empty())
theLogFile.insert(0, logDir);
// Set up OGRE platform. We might make this more generic later.
mPlatform = new OgrePlatform();
mPlatform->initialise(wnd, mgr);
mPlatform->initialise(wnd, mgr, "General", theLogFile);
// Create GUI
mGui = new Gui();
mGui->initialise();
mGui->initialise("core.xml", theLogFile);
}
void MyGUIManager::shutdown()

@ -23,11 +23,11 @@ namespace GUI
public:
MyGUIManager() : mPlatform(NULL), mGui(NULL) {}
MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false)
{ setup(wnd,mgr,logging); }
MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""))
{ setup(wnd,mgr,logging, logDir); }
~MyGUIManager() { shutdown(); }
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false);
void setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""));
void shutdown();
MyGUI::Gui *getGui() { return mGui; }

@ -28,12 +28,20 @@ void OgreRenderer::screenshot(const std::string &file)
}
bool OgreRenderer::configure(bool showConfig,
const std::string &cfgPath,
const std::string &logPath,
const std::string &pluginCfg,
bool _logging)
{
std::string theLogFile("Ogre.log");
std::string theCfgFile("ogre.cfg");
theLogFile.insert(0, logPath);
theCfgFile.insert(0, cfgPath);
// Set up logging first
new LogManager;
Log *log = LogManager::getSingleton().createLog("Ogre.log");
Log *log = LogManager::getSingleton().createLog(theLogFile);
logging = _logging;
if(logging)
@ -43,7 +51,7 @@ bool OgreRenderer::configure(bool showConfig,
// Disable logging
log->setDebugOutputEnabled(false);
mRoot = new Root(pluginCfg, "ogre.cfg", "");
mRoot = new Root(pluginCfg, theCfgFile, "");
// Show the configuration dialog and initialise the system, if the
// showConfig parameter is specified. The settings are stored in
@ -58,6 +66,21 @@ bool OgreRenderer::configure(bool showConfig,
return !result;
}
bool OgreRenderer::configure(bool showConfig,
const std::string &cfgPath,
const std::string &pluginCfg,
bool _logging)
{
return configure(showConfig, cfgPath, cfgPath, pluginCfg, _logging);
}
bool OgreRenderer::configure(bool showConfig,
const std::string &pluginCfg,
bool _logging)
{
return configure(showConfig, "", pluginCfg, _logging);
}
void OgreRenderer::createWindow(const std::string &title)
{
assert(mRoot);

@ -33,6 +33,19 @@ namespace Render
: mRoot(NULL), mWindow(NULL), mScene(NULL) {}
~OgreRenderer() { cleanup(); }
/** Configure the renderer. This will load configuration files and
set up the Root and logging classes. */
bool configure(bool showConfig, // Show config dialog box?
const std::string &cfgPath, // Path to directory where to store config files
const std::string &logPath, // Path to directory where to store log files
const std::string &pluginCfg, // plugin.cfg file
bool _logging); // Enable or disable logging
bool configure(bool showConfig, // Show config dialog box?
const std::string &cfgPath, // Path to directory where to store config files
const std::string &pluginCfg, // plugin.cfg file
bool _logging); // Enable or disable logging
/** Configure the renderer. This will load configuration files and
set up the Root and logging classes. */
bool configure(bool showConfig, // Show config dialog box?

Loading…
Cancel
Save