Changed: #1193 Removed nel configuration module, is used only QSettings.

This commit is contained in:
dnk-88 2011-03-17 10:56:41 +02:00
parent f4040f6c1b
commit 3e00576cc0
32 changed files with 664 additions and 1514 deletions

View file

@ -1,29 +0,0 @@
RootConfigFilename = "object_viewer_default.cfg";
SearchPaths = {
"/mnt/disk_d/NEL3D/texture", "/mnt/disk_d/NEL3D/SFX/maps", "/mnt/disk_d/NEL3D/Database_proto/Stuff/fyros/agent/actors/_textures"
};
GraphicsEnabled = 1;
SoundEnabled = 1;
GraphicsDriver = "OpenGL";
SoundDriver = "OpenAL";
SoundDevice = "";
LanguageCode = "en";
QtStyle = "";
FontName = "andbasr.ttf";
FontShadow = 1;
BackgroundColor = {
98, 98, 98
};
FogStart = 0.0000000000;
FogEnd = 10.0000000000;
FogColor = {
88, 88, 88
};
SoundAutoLoadSample = 1;
SoundMaxTrack = 48;
SoundEnableOccludeObstruct = 1;
SoundEnableReverb = 1;
SoundManualRolloff = 1;
SoundUseADPCM = 0;
SoundForceSoftware = 0;
CameraFocal = 75.0000000000;

View file

@ -1,156 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
// Config file for Object Viewer Qt ////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// This file is used to setup the Object Viewer tool.
//
//////////////////////////////////////////////////////////////////////////////
// NeL Qt ////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Root directory where we can find the client datas (zones, tiles, maps, ...)
// You must uncomment this line on GNU/Linux and comment the next one
//SearchPaths = { "/usr/local/share/games/nel_qt/" };
SearchPaths = { "data" };
// Which extensions to remap to what if needed (pairs of 2)
RemapExtensions = { "png", "tga", "dds", "tga"};
// The language code of the client
LanguageCode = "en";
// If changes to the config should be saved on exit
SaveConfig = 1;
//////////////////////////////////////////////////////////////////////////////
// Qt ////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
QtStyle = "Cleanlooks";
QtPalette = 0;
QtWindowState = "";
QtWindowGeometry = "";
//////////////////////////////////////////////////////////////////////////////
// Graphics //////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Use OpenGL or Direct3D (Windows)
GraphicsEnabled = 1;
GraphicsDrivers = { "OpenGL", "Direct3D" };
GraphicsDriver = "OpenGL";
// Resolution of the screen
// ScreenWidth = 1360;
// ScreenHeight = 768;
// ScreenDepth = 32;
// If 1, run in fullscreen mode, 0 for windowed
// Fullscreen = 0;
// Font name used for all text in the client (it can be a .ttf, .fon, .pfb)
FontName = "andbasr.ttf";
FontShadow = 1;
// Background color
BackgroundColor = { 151, 156, 182 };
// Bloom effect
BloomEffect = 1;
BloomSquare = 1;
BloomDensity = 120;
// Path where screenshots are saved
ScreenshotName = "nel_qt";
ScreenshotJPG = 1;
ScreenshotPNG = 1;
ScreenshotTGA = 0;
ScreenshotPath = "screenshots";
//////////////////////////////////////////////////////////////////////////////
// Environment ///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
CameraFocal = 75.0;
SunDirection = { -2.935, +0.107, -1.22 };
SunAmbient = { 190, 170, 150 };
SunDiffuse = { 255, 248, 255 };
SunSpecular = { 255, 255, 255};
// 1 if you want to see the fog
FogEnable = 1;
FogStart = 100.0; // in meter
FogEnd = 250.0; // in meter
FogColor = { 129, 136, 205 }; // { 147, 125, 114 };
/////////////////////////////////////////////////////////////
//// Vegetable Landscape Setup (for vegetable edition) //////
/////////////////////////////////////////////////////////////
VegetTileBank = ""; // this is optional, but obligatory for Vegetable Edit to work properly
VegetTileFarBank = ""; // this is optional, but obligatory for Vegetable Edit to work properly
VegetLandscapeZones = // this is optional, but obligatory for Vegetable Edit to work properly
{
"WARNING: Delete this string" // NOT DELETE
};
VegetLandscapeThreshold = 0.01; // this is optional
VegetLandscapeTileNear = 50.0; // this is optional
VegetLandscapeAmbient = {17, 54, 100, 255} ; // this is optional
VegetLandscapeDiffuse = {241, 226, 244, 255} ; // this is optional
VegetLandscapeSnapHeight = 1.70; // this is optional
VegetLandscapeMultiply = 1.5;
// veget setup
VegetTexture = ""; // this is optional, but important for Vegetable Edit to behave properly
VegetAmbient = {80, 80, 80}; // this is optional
VegetDiffuse = {255, 255, 255}; // this is optional. NB: works like veget_landscape_diffuse (ie maxLightFactor possible)
VegetLightDir = {0.0, 1.0, -1.0}; // this is optional
VegetWindDir = {1.0, 1.0, 0.0}; // this is optional
VegetWindFreq = 0.5; // this is optional
VegetWindPower = 5.0; // this is optional
VegetWindBendMin = 0.5; // this is optional
//////////////////////////////////////////////////////////////////////////////
// Time //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
FpsSmoothing = 64;
//////////////////////////////////////////////////////////////////////////////
// Sound /////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// The sound driver, choose between "Auto", "FMod", "DSound" and "OpenAl"
SoundEnabled = 1;
SoundDrivers = { "Auto", "OpenAL", "XAudio2", "FMod", "DSound" };
SoundDriver = "OpenAL";
SoundDevice = "";
SoundMaxTrack = 48;
SoundEnableOccludeObstruct = 1;
SoundEnableReverb = 1;
SoundManualRolloff = 1;
SoundUseADPCM = 0;
SoundForceSoftware = 0;
SoundAutoLoadSample = 1;
SoundPackedSheetPath = "/home/timon/sound";
SoundSamplePath = "/home/timon/sound";
//////////////////////////////////////////////////////////////////////////////
// Interface /////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Debug HUD /////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// end of file

View file

@ -71,7 +71,7 @@ public:
virtual void extensionsInitialized() = 0; virtual void extensionsInitialized() = 0;
/** /**
@\brief Called during a shutdown sequence in the same order as initialization @brief Called during a shutdown sequence in the same order as initialization
before the plugins get deleted in reverse order. before the plugins get deleted in reverse order.
@details This method should be used to disconnect from other plugins, @details This method should be used to disconnect from other plugins,
@ -80,7 +80,7 @@ public:
virtual void shutdown() { } virtual void shutdown() { }
/** /**
@\brief This method should be implemented to work properly NeL singletons. @brief This method should be implemented to work properly NeL singletons.
Called immediately after loading the plugin. Called immediately after loading the plugin.
@code @code
void Plugin::setNelContext(NLMISC::INelContext *nelContext) void Plugin::setNelContext(NLMISC::INelContext *nelContext)

View file

@ -54,7 +54,7 @@ void MenuManager::registerAction(QAction *action, const QString &id)
QMenu *MenuManager::menu(const QString &id) const QMenu *MenuManager::menu(const QString &id) const
{ {
QMenu *result = 0; QMenu *result = 0;
if (_menuMap.count(id) == 0) if (!_menuMap.contains(id))
nlwarning("QMenu %s not found", id.toStdString().c_str()); nlwarning("QMenu %s not found", id.toStdString().c_str());
else else
result = _menuMap.value(id); result = _menuMap.value(id);
@ -64,7 +64,7 @@ QMenu *MenuManager::menu(const QString &id) const
QAction *MenuManager::action(const QString &id) const QAction *MenuManager::action(const QString &id) const
{ {
QAction *result = 0; QAction *result = 0;
if (_actionMap.count(id) == 0) if (!_actionMap.contains(id))
nlwarning("QAction %s not found", id.toStdString().c_str()); nlwarning("QAction %s not found", id.toStdString().c_str());
else else
result = _actionMap.value(id); result = _actionMap.value(id);

View file

@ -31,6 +31,8 @@
namespace Core namespace Core
{ {
QString lastDir = ".";
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent) CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent)
: IOptionsPage(parent), : IOptionsPage(parent),
m_page(0) m_page(0)
@ -104,13 +106,14 @@ void CSearchPathsSettingsPage::applySearchPaths()
void CSearchPathsSettingsPage::addPath() void CSearchPathsSettingsPage::addPath()
{ {
QString newPath = QFileDialog::getExistingDirectory(m_page); QString newPath = QFileDialog::getExistingDirectory(m_page, "", lastDir);
if (!newPath.isEmpty()) if (!newPath.isEmpty())
{ {
QListWidgetItem *newItem = new QListWidgetItem; QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(newPath); newItem->setText(newPath);
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
m_ui.pathsListWidget->addItem(newItem); m_ui.pathsListWidget->addItem(newItem);
lastDir = newPath;
} }
checkEnabledButton(); checkEnabledButton();

View file

@ -1,28 +0,0 @@
/*
* Copyright (C) 2010 by authors
*
* This file is part of NEL QT.
* NEL QT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* NEL QT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NEL QT; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "stdpch.h"
#include "callback.h"
namespace NLQT
{
} /* namespace NLQT */
/* end of file */

View file

@ -1,327 +0,0 @@
/*
* Copyright (C) 2010 by authors
*
* This file is part of NEL QT.
* NEL QT is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* NEL QT is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NEL QT; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef NLQT_CALLBACK_H
#define NLQT_CALLBACK_H
#include <nel/misc/types_nl.h>
// STL includes
// NeL includes
#ifdef NL_COMP_GCC
// temporary fix for GCC 4.4 segmentation fault
# undef nlassert
# define nlassert(x)
#else
# include <nel/misc/debug.h>
#endif // NL_COMP_GCC
// Project includes
namespace NLQT
{
#define NLQT_CALLBACK_TEMPLATE \
/** \
* \brief NLQT_CALLBACK_ARGS_CLASS \
* \date 2009-03-03 18:09GMT \
* \author Jan Boon (Kaetemi) \
* Awesome callback template \
*/ \
template<typename TReturn NLQT_CALLBACK_ARGS_TYPENAME> \
class NLQT_CALLBACK_ARGS_CLASS \
{ \
/* Very simple reference counting callback base */ \
class CCallbackBase \
{ \
public: \
CCallbackBase() : m_RefCount(0) \
{ \
\
} \
\
virtual ~CCallbackBase() \
{ \
nlassert(!m_RefCount); \
} \
\
void refAdd() \
{ \
++m_RefCount; \
} \
\
void refRemove() \
{ \
--m_RefCount; \
if (!m_RefCount) \
delete this; \
} \
\
virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) = 0; \
\
virtual bool equals(const CCallbackBase *callbackBase) = 0; \
\
/* disable copy */ \
CCallbackBase(const CCallbackBase &); \
CCallbackBase &operator=(const CCallbackBase &); \
\
private: \
uint m_RefCount; \
}; \
\
typedef TReturn TCallbackFunction(NLQT_CALLBACK_ARGS_DECL); \
class CCallbackFunction : public CCallbackBase \
{ \
public: \
CCallbackFunction(TCallbackFunction *callbackFunction) : m_CallbackFunction(callbackFunction) \
{ \
nlassert(m_CallbackFunction); \
} \
\
virtual ~CCallbackFunction() \
{ \
m_CallbackFunction = NULL; \
} \
\
virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) \
{ \
return m_CallbackFunction(NLQT_CALLBACK_ARGS_IMPL); \
} \
\
virtual bool equals(const CCallbackBase *callbackBase) \
{ \
const CCallbackFunction *callbackFunction = \
dynamic_cast<const CCallbackFunction *>(callbackBase); \
if (!callbackFunction) return false; \
return m_CallbackFunction == callbackFunction->m_CallbackFunction; \
} \
\
private: \
TCallbackFunction *m_CallbackFunction; \
}; \
\
template<typename TClass> \
class CCallbackMethod : public CCallbackBase \
{ \
typedef TReturn (TClass::*TCallbackMethod)(NLQT_CALLBACK_ARGS_DECL); \
public: \
CCallbackMethod(TClass *callbackObject, TCallbackMethod callbackMethod) : m_CallbackObject(callbackObject), m_CallbackMethod(callbackMethod) \
{ \
nlassert(m_CallbackObject); \
nlassert(m_CallbackMethod); \
} \
\
virtual ~CCallbackMethod() \
{ \
m_CallbackObject = NULL; \
m_CallbackMethod = NULL; \
} \
\
virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) \
{ \
return (m_CallbackObject->*m_CallbackMethod)(NLQT_CALLBACK_ARGS_IMPL); \
} \
\
virtual bool equals(const CCallbackBase *callbackBase) \
{ \
const CCallbackMethod *callbackMethod = \
dynamic_cast<const CCallbackMethod *>(callbackBase); \
if (!callbackMethod) return false; \
return m_CallbackObject == callbackMethod->m_CallbackObject \
&& m_CallbackMethod == callbackMethod->m_CallbackMethod; \
} \
\
private: \
TClass *m_CallbackObject; \
TCallbackMethod m_CallbackMethod; \
}; \
\
public: \
CCallback() : m_CallbackBase(NULL) \
{ \
\
} \
\
CCallback(TCallbackFunction *callbackFunction) : m_CallbackBase(new CCallbackFunction(callbackFunction)) \
{ \
nlassert(m_CallbackBase); \
m_CallbackBase->refAdd(); \
} \
\
template<typename TClass> \
CCallback(TClass *callbackObject, TReturn (TClass::*callbackMethod)(NLQT_CALLBACK_ARGS_DECL)) : m_CallbackBase(new CCallbackMethod<TClass>(callbackObject, callbackMethod)) \
{ \
nlassert(m_CallbackBase); \
m_CallbackBase->refAdd(); \
} \
\
CCallback(const CCallback &callback) \
{ \
m_CallbackBase = callback.m_CallbackBase; \
if (m_CallbackBase) \
m_CallbackBase->refAdd(); \
} \
\
CCallback &operator=(const CCallback &callback) \
{ \
if (m_CallbackBase != callback.m_CallbackBase) \
{ \
if (m_CallbackBase) \
m_CallbackBase->refRemove(); \
m_CallbackBase = callback.m_CallbackBase; \
if (m_CallbackBase) \
m_CallbackBase->refAdd(); \
} \
return *this; \
} \
\
~CCallback() \
{ \
if (m_CallbackBase) \
{ \
m_CallbackBase->refRemove(); \
m_CallbackBase = NULL; \
} \
} \
\
TReturn callback(NLQT_CALLBACK_ARGS_DECL) \
{ \
nlassert(m_CallbackBase); \
return m_CallbackBase->callback(NLQT_CALLBACK_ARGS_IMPL); \
} \
\
TReturn operator()(NLQT_CALLBACK_ARGS_DECL) \
{ \
nlassert(m_CallbackBase); \
return m_CallbackBase->callback(NLQT_CALLBACK_ARGS_IMPL); \
} \
\
bool valid() const \
{ \
return m_CallbackBase != NULL; \
} \
\
operator bool() const \
{ \
return m_CallbackBase != NULL; \
} \
\
bool operator==(const CCallback &callback) \
{ \
return m_CallbackBase->equals(callback.m_CallbackBase); \
} \
\
private: \
CCallbackBase *m_CallbackBase; \
\
}; /* class CCallback */ \
template<typename TReturn, typename TArgsA = void, typename TArgsB = void, typename TArgsC = void, typename TArgsD = void, typename TArgsE = void, typename TArgsF = void, typename TArgsG = void, typename TDummy = void>
class CCallback;
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, void, void, void, void, void, void, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME
#define NLQT_CALLBACK_ARGS_DECL
#define NLQT_CALLBACK_ARGS_IMPL
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, void, void, void, void, void, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA
#define NLQT_CALLBACK_ARGS_IMPL argsA
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, void, void, void, void, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, void, void, void, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, void, void, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, void, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, TArgsF, void, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, TArgsF, TArgsG, void>
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF, typename TArgsG
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF, TArgsG argsG
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF, argsG
NLQT_CALLBACK_TEMPLATE
#undef NLQT_CALLBACK_ARGS_CLASS
#undef NLQT_CALLBACK_ARGS_TYPENAME
#undef NLQT_CALLBACK_ARGS_DECL
#undef NLQT_CALLBACK_ARGS_IMPL
#undef NLQT_CALLBACK_ARGS_CLASSNAME
#undef NLQT_CALLBACK_TEMPLATE
typedef CCallback<void> CEmptyCallback;
} /* namespace NLQT */
#endif /* #ifndef NLQT_CALLBACK_H */
/* end of file */

View file

@ -1,224 +0,0 @@
/*
Object Viewer Qt
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdpch.h"
#include "configuration.h"
// NeL includes
#include <nel/misc/debug.h>
#include <nel/misc/hierarchical_timer.h>
#include <nel/misc/config_file.h>
#include <nel/misc/path.h>
#include "modules.h"
using namespace std;
using namespace NLMISC;
namespace NLQT
{
CConfiguration::CConfiguration()
{
}
CConfiguration::~CConfiguration()
{
}
void CConfiguration::init()
{
nldebug("CConfiguration::init");
// verify data
nlassert(!ConfigCallbacks.size());
// load config
try
{
ConfigFile.load(NLQT_CONFIG_FILE);
}
catch(...)
{
nlerror("Error opening files object_viewer.cfg or object_viewer_default.cfg. Check this files");
}
// setup config file callback
Modules::config().setCallback("SearchPaths", CConfigCallback(this, &CConfiguration::cfcbSearchPaths));
}
void CConfiguration::release()
{
nldebug("CConfiguration::release");
Modules::config().dropCallback("SearchPaths");
// save and release the config file
if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool())
{
ConfigFile.save();
}
ConfigFile.clear();
// release the search paths etc
CPath::releaseInstance();
// verify data
nlassert(!ConfigCallbacks.size());
}
void CConfiguration::updateUtilities()
{
//H_AUTO2
CConfigFile::checkConfigFiles();
}
void CConfiguration::configSearchPaths()
{
cfcbSearchPaths(Modules::config().getConfigFile().getVar("SearchPaths"));
}
void CConfiguration::configRemapExtensions()
{
CConfigFile::CVar *var;
var = ConfigFile.getVarPtr("RemapExtensions");
uint varsize = var->size();
for (uint i = 0; i < varsize; i += 2)
CPath::remapExtension(var->asString(i), var->asString(i + 1), true);
}
void CConfiguration::setAndCallback(const std::string &varName, CConfigCallback configCallback)
{
ConfigCallbacks[varName] = configCallback;
ConfigFile.setCallback(varName, cbConfigCallback);
configCallback(*ConfigFile.getVarPtr(varName));
}
void CConfiguration::setCallback(const std::string &varName, CConfigCallback configCallback)
{
ConfigCallbacks[varName] = configCallback;
ConfigFile.setCallback(varName, cbConfigCallback);
}
void CConfiguration::dropCallback(const std::string &varName)
{
ConfigFile.setCallback(varName, NULL);
ConfigCallbacks.erase(varName);
}
float CConfiguration::getValue(const string &varName, float defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat();
CConfigFile::CVar varToCopy;
varToCopy.forceAsDouble((double)defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
double CConfiguration::getValue(const string &varName, double defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble();
CConfigFile::CVar varToCopy;
varToCopy.forceAsDouble(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
int CConfiguration::getValue(const string &varName, int defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt();
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
string CConfiguration::getValue(const string &varName, const string &defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString();
CConfigFile::CVar varToCopy;
varToCopy.forceAsString(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue)
{
if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString());
CConfigFile::CVar varToCopy;
varToCopy.forceAsString(defaultValue.toUtf8());
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
bool CConfiguration::getValue(const string &varName, bool defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool();
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue ? 1 : 0);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue)
{
if (ConfigFile.exists(varName))
{
return getValue(ConfigFile.getVar(varName), defaultValue);
}
else
{
// create a new value only if one doesn't exist
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue.R);
varToCopy.setAsInt(defaultValue.G, 1);
varToCopy.setAsInt(defaultValue.B, 2);
varToCopy.setAsInt(defaultValue.A, 3);
ConfigFile.insertVar(varName, varToCopy);
}
return defaultValue;
}
CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue)
{
if (var.size() >= 3)
{
if (var.size() > 4)
nlwarning("RGBA value in config value '%s' is too long, ignoring unused values");
return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255);
}
nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A);
return defaultValue;
}
void CConfiguration::cbConfigCallback(NLMISC::CConfigFile::CVar &var)
{
Modules::config().ConfigCallbacks[var.Name](var);
}
void CConfiguration::cfcbSearchPaths(NLMISC::CConfigFile::CVar &var)
{
uint varsize = var.size();
for (uint i = 0; i < varsize; ++i)
CPath::addSearchPath(var.asString(i), false, false);
}
} /* namespace NLQT */

View file

@ -1,97 +0,0 @@
/*
Object Viewer Qt
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <nel/misc/types_nl.h>
// STL includes
#include <map>
// NeL includes
#include <nel/misc/config_file.h>
#include <nel/misc/rgba.h>
#include <nel/misc/ucstring.h>
// Project includes
#include "callback.h"
#define NLQT_CONFIG_FILE "object_viewer.cfg"
namespace NLQT
{
typedef CCallback<void, NLMISC::CConfigFile::CVar &> CConfigCallback;
/**
@class CConfiguration
@date 2010-02-05 15:44GMT
@author Jan Boon (Kaetemi)
@brief Read / write settings from the configuration file
@details Load the configuration file, and then read/write settings.
As well as automatic reading of the search paths and their sets.
*/
class CConfiguration
{
public:
CConfiguration();
virtual ~CConfiguration();
void init();
void release();
void updateUtilities();
void configSearchPaths();
void configRemapExtensions();
void setAndCallback(const std::string &varName, CConfigCallback configCallback);
void setCallback(const std::string &varName, CConfigCallback configCallback);
void dropCallback(const std::string &varName);
float getValue(const std::string &varName, float defaultValue);
double getValue(const std::string &varName, double defaultValue);
int getValue(const std::string &varName, int defaultValue);
std::string getValue(const std::string &varName, const std::string &defaultValue);
ucstring getValue(const std::string &varName, const ucstring &defaultValue);
bool getValue(const std::string &varName, bool defaultValue);
NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue);
NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue);
inline NLMISC::CConfigFile &getConfigFile()
{
return ConfigFile;
}
private:
static void cbConfigCallback(NLMISC::CConfigFile::CVar &var);
void cfcbSearchPaths(NLMISC::CConfigFile::CVar &var);
CConfiguration(const CConfiguration &);
CConfiguration &operator=(const CConfiguration &);
NLMISC::CConfigFile ConfigFile;
std::map<std::string, CConfigCallback> ConfigCallbacks;
};/* class CConfiguration */
} /* namespace NLQT */
#endif // CONFIGURATION_H

View file

@ -391,6 +391,7 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
// If a skeleton model // If a skeleton model
if(!_Skeleton.empty()) if(!_Skeleton.empty())
{ {
_Skeleton.setTransformMode(NL3D::UTransformable::RotQuat);
// scale animated pos value with the CFG scale // scale animated pos value with the CFG scale
pos *= _CharacterScalePos; pos *= _CharacterScalePos;
_Skeleton.setPos(pos); _Skeleton.setPos(pos);
@ -398,6 +399,7 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
} }
else else
{ {
_Instance.setTransformMode(NL3D::UTransformable::RotQuat);
_Instance.setPos(pos); _Instance.setPos(pos);
_Instance.setRotQuat(current.getRot()); _Instance.setRotQuat(current.getRot());
} }

View file

@ -18,9 +18,12 @@
// Project includes // Project includes
#include "stdpch.h" #include "stdpch.h"
#include "graphics_settings_page.h" #include "graphics_settings_page.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h" #include "modules.h"
// Qt includes // Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QStyleFactory> #include <QtGui/QStyleFactory>
#include <QtGui/QStyle> #include <QtGui/QStyle>
@ -49,7 +52,7 @@ QString GraphicsSettingsPage::trName() const
QString GraphicsSettingsPage::category() const QString GraphicsSettingsPage::category() const
{ {
return QLatin1String("ObjectViewer"); return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
} }
QString GraphicsSettingsPage::trCategory() const QString GraphicsSettingsPage::trCategory() const
@ -62,13 +65,22 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
m_page = new QWidget(parent); m_page = new QWidget(parent);
m_ui.setupUi(m_page); m_ui.setupUi(m_page);
Modules::config().setAndCallback("GraphicsDrivers", CConfigCallback(this, &GraphicsSettingsPage::cfcbGraphicsDrivers)); QSettings *settings = Core::ICore::instance()->settings();
m_ui.enableBloomCheckBox->setChecked(Modules::objView().getBloomEffect()); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
QString graphicsDriver = settings->value(Constants::GRAPHICS_DRIVER, "OpenGL").toString();
m_ui.driverGraphComboBox->setCurrentIndex(m_ui.driverGraphComboBox->findText(graphicsDriver));
m_ui.enableBloomCheckBox->setChecked(settings->value(Constants::ENABLE_BLOOM, false).toBool());
m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom()); m_ui.squareBloomCheckBox->setChecked(NL3D::CBloomEffect::instance().getSquareBloom());
m_ui.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom()); m_ui.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom());
m_ui.styleComboBox->addItems(QStyleFactory::keys()); m_ui.styleComboBox->addItems(QStyleFactory::keys());
m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(Modules::config().getValue("QtStyle", std::string("")).c_str())); QString style = settings->value(Constants::QT_STYLE, "").toString();
m_ui.paletteCheckBox->setChecked(Modules::config().getValue("QtPalette", false)); m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(style));
m_ui.paletteCheckBox->setChecked(settings->value(Constants::QT_PALETTE, true).toBool());
settings->endGroup();
connect(m_ui.enableBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableBloom(bool))); connect(m_ui.enableBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableBloom(bool)));
connect(m_ui.squareBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableSquareBloon(bool))); connect(m_ui.squareBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableSquareBloon(bool)));
@ -82,16 +94,19 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
void GraphicsSettingsPage::apply() void GraphicsSettingsPage::apply()
{ {
// save graphics settings to config file QSettings *settings = Core::ICore::instance()->settings();
Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString(m_ui.driverGraphComboBox->currentText().toStdString()); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("BloomEffect").setAsInt(m_ui.enableBloomCheckBox->isChecked()); settings->setValue(Constants::GRAPHICS_DRIVER, m_ui.driverGraphComboBox->currentText());
Modules::config().getConfigFile().getVar("BloomSquare").setAsInt(m_ui.squareBloomCheckBox->isChecked());
Modules::config().getConfigFile().getVar("BloomDensity").setAsInt(m_ui.bloomDensityHorizontalSlider->value());
Modules::config().getConfigFile().getVar("QtStyle").setAsString(m_ui.styleComboBox->currentText().toStdString()); // save settings
Modules::config().getConfigFile().getVar("QtPalette").setAsInt(m_ui.paletteCheckBox->isChecked()); settings->setValue(Constants::ENABLE_BLOOM, m_ui.enableBloomCheckBox->isChecked());
settings->setValue(Constants::ENABLE_SQUARE_BLOOM, m_ui.squareBloomCheckBox->isChecked());
settings->setValue(Constants::BLOOM_DENSITY, m_ui.bloomDensityHorizontalSlider->value());
settings->setValue(Constants::QT_STYLE, m_ui.styleComboBox->currentText());
settings->setValue(Constants::QT_PALETTE, m_ui.paletteCheckBox->isChecked());
// apply qt style and palette
QApplication::setStyle(QStyleFactory::create(m_ui.styleComboBox->currentText())); QApplication::setStyle(QStyleFactory::create(m_ui.styleComboBox->currentText()));
if (m_ui.paletteCheckBox->isChecked()) if (m_ui.paletteCheckBox->isChecked())
@ -99,12 +114,12 @@ void GraphicsSettingsPage::apply()
else else
QApplication::setPalette(Modules::mainWin().getOriginalPalette()); QApplication::setPalette(Modules::mainWin().getOriginalPalette());
// save config file settings->endGroup();
Modules::config().getConfigFile().save(); settings->sync();
} }
void GraphicsSettingsPage::finish() void GraphicsSettingsPage::finish()
{ {
Modules::config().dropCallback("GraphicsDrivers");
} }
void GraphicsSettingsPage::setEnableBloom(bool state) void GraphicsSettingsPage::setEnableBloom(bool state)
@ -122,26 +137,4 @@ void GraphicsSettingsPage::setDensityBloom(int density)
NL3D::CBloomEffect::instance().setDensityBloom(density); NL3D::CBloomEffect::instance().setDensityBloom(density);
} }
void GraphicsSettingsPage::cfcbGraphicsDrivers(NLMISC::CConfigFile::CVar &var)
{
while (m_ui.driverGraphComboBox->count())
m_ui.driverGraphComboBox->removeItem(0);
// load types graphics driver from the config file
for (uint i = 0; i < var.size(); ++i)
m_ui.driverGraphComboBox->addItem(var.asString(i).c_str());
// set graphics driver from the config file
QString value = Modules::config().getValue("GraphicsDriver", std::string("OpenGL")).c_str();
QString dn = value.toLower();
for (sint i = 0; i < m_ui.driverGraphComboBox->count(); ++i)
{
if (dn == m_ui.driverGraphComboBox->itemText(i).toLower())
{
m_ui.driverGraphComboBox->setCurrentIndex(i);
return;
}
}
}
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -24,8 +24,6 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include <nel/misc/config_file.h>
class QWidget; class QWidget;
namespace NLQT namespace NLQT
@ -55,8 +53,6 @@ private Q_SLOTS:
void setDensityBloom(int density); void setDensityBloom(int density);
private: private:
void cfcbGraphicsDrivers(NLMISC::CConfigFile::CVar &var);
QWidget *m_page; QWidget *m_page;
Ui::GraphicsSettingsPage m_ui; Ui::GraphicsSettingsPage m_ui;
}; };

View file

@ -6,129 +6,21 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>540</width> <width>274</width>
<height>326</height> <height>277</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout">
<property name="leftMargin"> <property name="margin">
<number>6</number> <number>6</number>
</property> </property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<item row="4" column="1"> <item row="0" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>283</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QGroupBox" name="qtStyleGroupBox">
<property name="title">
<string>Qt Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="styleComboBox"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="paletteCheckBox">
<property name="text">
<string>Use style's standard palette</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QGroupBox" name="graphicsGroupBox">
<property name="title">
<string>Graphics settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="driverGraphLabel">
<property name="text">
<string>Driver</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="driverGraphComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>Bloom effect</string> <string>Bloom effect</string>
@ -172,6 +64,142 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="graphicsGroupBox">
<property name="title">
<string>Graphics settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="driverGraphLabel">
<property name="text">
<string>Driver</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="driverGraphComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>OpenGL</string>
</property>
</item>
<item>
<property name="text">
<string>Direct3D</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="qtStyleGroupBox">
<property name="title">
<string>Qt Style</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="styleComboBox"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="paletteCheckBox">
<property name="text">
<string>Use style's standard palette</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="fontLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="fontSelectButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>283</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources> <resources>

View file

@ -49,6 +49,7 @@
#include "tune_mrm_dialog.h" #include "tune_mrm_dialog.h"
#include "tune_timer_dialog.h" #include "tune_timer_dialog.h"
#include "camera_control.h" #include "camera_control.h"
#include "object_viewer_constants.h"
#include "../core/icore.h" #include "../core/icore.h"
#include "../core/imenu_manager.h" #include "../core/imenu_manager.h"
@ -79,11 +80,18 @@ CMainWindow::CMainWindow(QWidget *parent)
setDockNestingEnabled(true); setDockNestingEnabled(true);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// setup Qt style and palette from config file // setup Qt style and palette from config file
_originalPalette = QApplication::palette(); _originalPalette = QApplication::palette();
Modules::config().setAndCallback("QtStyle", CConfigCallback(this, &CMainWindow::cfcbQtStyle));
Modules::config().setAndCallback("QtPalette", CConfigCallback(this, &CMainWindow::cfcbQtPalette)); QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString()));
Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled));
if (settings->value(Constants::QT_PALETTE, true).toBool())
QApplication::setPalette(QApplication::style()->standardPalette());
else
QApplication::setPalette(_originalPalette);
_GraphicsViewport->init(); _GraphicsViewport->init();
_isGraphicsInitialized = true; _isGraphicsInitialized = true;
@ -103,18 +111,16 @@ CMainWindow::CMainWindow(QWidget *parent)
setWindowIcon(QIcon(":/images/nel.png")); setWindowIcon(QIcon(":/images/nel.png"));
QSettings settings("object_viewer_qt.ini", QSettings::IniFormat); restoreState(settings->value("QtWindowState").toByteArray());
settings.beginGroup("WindowSettings"); restoreGeometry(settings->value("QtWindowGeometry").toByteArray());
restoreState(settings.value("QtWindowState").toByteArray());
restoreGeometry(settings.value("QtWindowGeometry").toByteArray());
settings.endGroup();
// As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed. // As a special case, a QTimer with a timeout of 0 will time out as soon as all the events in the window system's event queue have been processed.
// This can be used to do heavy work while providing a snappy user interface. // This can be used to do heavy work while providing a snappy user interface.
_mainTimer = new QTimer(this); _mainTimer = new QTimer(this);
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender())); connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
connect(_TuneTimerDialog, SIGNAL(changeInterval(int)), this, SLOT(setInterval(int))); connect(_TuneTimerDialog, SIGNAL(changeInterval(int)), this, SLOT(setInterval(int)));
_TuneTimerDialog->setInterval(settings.value("TimerInterval", 25).toInt()); _TuneTimerDialog->setInterval(settings->value("TimerInterval", 25).toInt());
settings->endGroup();
_statusBarTimer = new QTimer(this); _statusBarTimer = new QTimer(this);
connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
@ -129,16 +135,13 @@ CMainWindow::~CMainWindow()
nldebug("CMainWindow::~CMainWindow:"); nldebug("CMainWindow::~CMainWindow:");
// save state & geometry of window and widgets // save state & geometry of window and widgets
QSettings settings("object_viewer_qt.ini", QSettings::IniFormat); QSettings *settings = Core::ICore::instance()->settings();
settings.beginGroup("WindowSettings"); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
settings.setValue("QtWindowState", saveState()); settings->setValue("QtWindowState", saveState());
settings.setValue("QtWindowGeometry", saveGeometry()); settings->setValue("QtWindowGeometry", saveGeometry());
settings.endGroup(); settings->setValue("TimerInterval", _mainTimer->interval());
settings.setValue("TimerInterval", _mainTimer->interval()); settings->endGroup();
settings->sync();
Modules::config().dropCallback("SoundEnabled");
Modules::config().dropCallback("QtPalette");
Modules::config().dropCallback("QtStyle");
delete _AnimationDialog; delete _AnimationDialog;
delete _AnimationSetDialog; delete _AnimationSetDialog;

View file

@ -20,7 +20,6 @@
#include "stdpch.h" #include "stdpch.h"
#include "modules.h" #include "modules.h"
NLQT::CConfiguration *Modules::_configuration = NULL;
NLQT::CObjectViewer *Modules::_objectViewer = NULL; NLQT::CObjectViewer *Modules::_objectViewer = NULL;
NLQT::CMainWindow *Modules::_mainWindow = NULL; NLQT::CMainWindow *Modules::_mainWindow = NULL;
NLQT::CParticleEditor *Modules::_particleEditor = NULL; NLQT::CParticleEditor *Modules::_particleEditor = NULL;
@ -29,9 +28,6 @@ NLQT::CVegetableEditor *Modules::_vegetableEditor = NULL;
void Modules::init() void Modules::init()
{ {
if (_configuration == NULL) _configuration = new NLQT::CConfiguration;
config().init();
if (_objectViewer == NULL) _objectViewer = new NLQT::CObjectViewer; if (_objectViewer == NULL) _objectViewer = new NLQT::CObjectViewer;
if (_soundSystem == NULL) _soundSystem = new NLQT::CSoundSystem; if (_soundSystem == NULL) _soundSystem = new NLQT::CSoundSystem;
if (_particleEditor == NULL) _particleEditor = new NLQT::CParticleEditor; if (_particleEditor == NULL) _particleEditor = new NLQT::CParticleEditor;
@ -51,8 +47,4 @@ void Modules::release()
_soundSystem = NULL; _soundSystem = NULL;
delete _objectViewer; delete _objectViewer;
_objectViewer = NULL; _objectViewer = NULL;
config().release();
delete _configuration;
_configuration = NULL;
} }

View file

@ -20,7 +20,6 @@
#ifndef MODULES_H #ifndef MODULES_H
#define MODULES_H #define MODULES_H
#include "configuration.h"
#include "object_viewer.h" #include "object_viewer.h"
#include "particle_editor.h" #include "particle_editor.h"
#include "main_window.h" #include "main_window.h"
@ -37,10 +36,6 @@ public:
static void init(); static void init();
static void release(); static void release();
static NLQT::CConfiguration &config()
{
return *_configuration;
}
static NLQT::CObjectViewer &objView() static NLQT::CObjectViewer &objView()
{ {
return *_objectViewer; return *_objectViewer;
@ -63,7 +58,6 @@ public:
} }
private: private:
static NLQT::CConfiguration *_configuration;
static NLQT::CObjectViewer *_objectViewer; static NLQT::CObjectViewer *_objectViewer;
static NLQT::CMainWindow *_mainWindow; static NLQT::CMainWindow *_mainWindow;
static NLQT::CParticleEditor *_particleEditor; static NLQT::CParticleEditor *_particleEditor;

View file

@ -16,11 +16,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
// Project includes
#include "modules.h"
#include "stdpch.h" #include "stdpch.h"
#include "object_viewer.h" #include "object_viewer.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
// STL includes // Qt includes
#include <QtCore/QSettings>
// NeL includes // NeL includes
#include <nel/misc/debug.h> #include <nel/misc/debug.h>
@ -45,14 +49,6 @@
#include <nel/3d/scene_user.h> #include <nel/3d/scene_user.h>
#include <nel/3d/bloom_effect.h> #include <nel/3d/bloom_effect.h>
// Project includes
#include "modules.h"
#include "configuration.h"
using namespace std;
using namespace NLMISC;
using namespace NL3D;
namespace NLQT namespace NLQT
{ {
@ -66,11 +62,12 @@ CObjectViewer::CObjectViewer()
_CurrentInstance(""), _CurrentInstance(""),
_BloomEffect(false) _BloomEffect(false)
{ {
loadConfig();
} }
CObjectViewer::~CObjectViewer() CObjectViewer::~CObjectViewer()
{ {
saveConfig();
} }
void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h) void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
@ -78,12 +75,10 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
//H_AUTO2 //H_AUTO2
nldebug("CObjectViewert::init"); nldebug("CObjectViewert::init");
loadConfig();
// create the driver // create the driver
nlassert(!_Driver); nlassert(!_Driver);
_Driver = UDriver::createDriver(0, _Direct3D, 0); _Driver = NL3D::UDriver::createDriver(0, _Direct3D, 0);
nlassert(_Driver); nlassert(_Driver);
// initialize the window with config file values // initialize the window with config file values
@ -95,16 +90,16 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
_Driver->enableUsedTextureMemorySum(); _Driver->enableUsedTextureMemorySum();
_Light = ULight::createLight(); _Light = NL3D::ULight::createLight();
// set mode of the light // set mode of the light
_Light->setMode(ULight::DirectionalLight); _Light->setMode(NL3D::ULight::DirectionalLight);
// set position of the light // set position of the light
_Light->setPosition(CVector(-20.f, 30.f, 10.f)); _Light->setPosition(NLMISC::CVector(-20.f, 30.f, 10.f));
// white light // white light
_Light->setAmbiant(CRGBA(255, 255, 255)); _Light->setAmbiant(NLMISC::CRGBA(255, 255, 255));
// set and enable the light // set and enable the light
_Driver->setLight(0, *_Light); _Driver->setLight(0, *_Light);
@ -117,7 +112,7 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0); NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0);
_MouseListener = _Driver->create3dMouseListener(); _MouseListener = _Driver->create3dMouseListener();
_MouseListener->setMouseMode(U3dMouseListener::edit3d); _MouseListener->setMouseMode(NL3D::U3dMouseListener::edit3d);
// set the cache size for the font manager(in bytes) // set the cache size for the font manager(in bytes)
_Driver->setFontManagerMaxMemory(2097152); _Driver->setFontManagerMaxMemory(2097152);
@ -130,8 +125,8 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
NL3D::CBloomEffect::instance().setDriver(_Driver); NL3D::CBloomEffect::instance().setDriver(_Driver);
NL3D::CBloomEffect::instance().setScene(_Scene); NL3D::CBloomEffect::instance().setScene(_Scene);
NL3D::CBloomEffect::instance().init(!_Direct3D); NL3D::CBloomEffect::instance().init(!_Direct3D);
NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt()); NL3D::CBloomEffect::instance().setDensityBloom(uint8(_BloomDensity));
NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool()); NL3D::CBloomEffect::instance().setSquareBloom(_BloomSquare);
NL3D::CDriverUser *driver = dynamic_cast<NL3D::CDriverUser *>(Modules::objView().getDriver()); NL3D::CDriverUser *driver = dynamic_cast<NL3D::CDriverUser *>(Modules::objView().getDriver());
_IDriver = driver->getDriver(); _IDriver = driver->getDriver();
@ -145,8 +140,6 @@ void CObjectViewer::release()
//H_AUTO2 //H_AUTO2
nldebug("CObjectViewer::release"); nldebug("CObjectViewer::release");
saveConfig();
// release text context // release text context
nlassert(_TextContext); nlassert(_TextContext);
_Driver->deleteTextContext(_TextContext); _Driver->deleteTextContext(_TextContext);
@ -232,7 +225,7 @@ void CObjectViewer::reloadTextures()
int tex; int tex;
for (tex = 0; tex < NL3D::IDRV_MAT_MAXTEXTURES; tex++) for (tex = 0; tex < NL3D::IDRV_MAT_MAXTEXTURES; tex++)
{ {
ITexture *texture = material->getTexture(tex); NL3D::ITexture *texture = material->getTexture(tex);
// Touch it! // Touch it!
if (texture) if (texture)
@ -250,30 +243,30 @@ void CObjectViewer::saveScreenshot(const std::string &nameFile, bool jpg, bool p
// FIXME: create screenshot path if it doesn't exist! // FIXME: create screenshot path if it doesn't exist!
// empty bitmap // empty bitmap
CBitmap bitmap; NLMISC::CBitmap bitmap;
// copy the driver buffer to the bitmap // copy the driver buffer to the bitmap
_Driver->getBuffer(bitmap); _Driver->getBuffer(bitmap);
// create the file name // create the file name
string filename = std::string("./") + nameFile; std::string filename = std::string("./") + nameFile;
// write the bitmap as a jpg, png or tga to the file // write the bitmap as a jpg, png or tga to the file
if (jpg) if (jpg)
{ {
string newfilename = CFile::findNewFile(filename + ".jpg"); std::string newfilename = NLMISC::CFile::findNewFile(filename + ".jpg");
COFile outputFile(newfilename); NLMISC::COFile outputFile(newfilename);
bitmap.writeJPG(outputFile, 100); bitmap.writeJPG(outputFile, 100);
nlinfo("Screenshot '%s' saved", newfilename.c_str()); nlinfo("Screenshot '%s' saved", newfilename.c_str());
} }
if (png) if (png)
{ {
string newfilename = CFile::findNewFile(filename + ".png"); std::string newfilename = NLMISC::CFile::findNewFile(filename + ".png");
COFile outputFile(newfilename); NLMISC::COFile outputFile(newfilename);
bitmap.writePNG(outputFile, 24); bitmap.writePNG(outputFile, 24);
nlinfo("Screenshot '%s' saved", newfilename.c_str()); nlinfo("Screenshot '%s' saved", newfilename.c_str());
} }
if (tga) if (tga)
{ {
string newfilename = CFile::findNewFile(filename + ".tga"); std::string newfilename = NLMISC::CFile::findNewFile(filename + ".tga");
COFile outputFile(newfilename); NLMISC::COFile outputFile(newfilename);
bitmap.writeTGA(outputFile, 24, false); bitmap.writeTGA(outputFile, 24, false);
nlinfo("Screenshot '%s' saved", newfilename.c_str()); nlinfo("Screenshot '%s' saved", newfilename.c_str());
} }
@ -281,25 +274,25 @@ void CObjectViewer::saveScreenshot(const std::string &nameFile, bool jpg, bool p
bool CObjectViewer::loadMesh(const std::string &meshFileName, const std::string &skelFileName) bool CObjectViewer::loadMesh(const std::string &meshFileName, const std::string &skelFileName)
{ {
std::string fileName = CFile::getFilenameWithoutExtension(meshFileName); std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(meshFileName);
if (_Entities.count(fileName) != 0) if (_Entities.count(fileName) != 0)
return false; return false;
CPath::addSearchPath(CFile::getPath(meshFileName), false, false); NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(meshFileName), false, false);
// create instance of the mesh character // create instance of the mesh character
UInstance Entity = _Scene->createInstance(meshFileName); NL3D::UInstance Entity = _Scene->createInstance(meshFileName);
// if we can't create entity, skip it // if we can't create entity, skip it
if (Entity.empty()) return false; if (Entity.empty()) return false;
CAABBox bbox; NLMISC::CAABBox bbox;
Entity.getShapeAABBox(bbox); Entity.getShapeAABBox(bbox);
setCamera(bbox , Entity, true); setCamera(bbox , Entity, true);
_MouseListener->setMatrix(_Scene->getCam().getMatrix()); _MouseListener->setMatrix(_Scene->getCam().getMatrix());
USkeleton Skeleton = _Scene->createSkeleton(skelFileName); NL3D::USkeleton Skeleton = _Scene->createSkeleton(skelFileName);
// TODO: remade at typedef std::map<std::string, *CEntity> CEntities; // TODO: remade at typedef std::map<std::string, *CEntity> CEntities;
EIT eit = (_Entities.insert (make_pair (fileName, CEntity()))).first; EIT eit = (_Entities.insert (make_pair (fileName, CEntity()))).first;
@ -322,8 +315,8 @@ bool CObjectViewer::loadMesh(const std::string &meshFileName, const std::string
bool CObjectViewer::loadInstanceGroup(const std::string &igName) bool CObjectViewer::loadInstanceGroup(const std::string &igName)
{ {
CPath::addSearchPath (CFile::getPath(igName)); NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(igName));
UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(igName); NL3D::UInstanceGroup *ig = NL3D::UInstanceGroup::createInstanceGroup(igName);
if (ig == 0) if (ig == 0)
return false; return false;
ig->addToScene(*_Scene, _Driver); ig->addToScene(*_Scene, _Driver);
@ -334,8 +327,8 @@ bool CObjectViewer::loadInstanceGroup(const std::string &igName)
void CObjectViewer::setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z) void CObjectViewer::setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z)
{ {
CVector pos(0.f, 0.f, 0.f); NLMISC::CVector pos(0.f, 0.f, 0.f);
CQuat quat(0.f, 0.f, 0.f, 0.f); NLMISC::CQuat quat(0.f, 0.f, 0.f, 0.f);
NL3D::UInstance inst; NL3D::UInstance inst;
inst.cast(entity); inst.cast(entity);
if (!inst.empty()) if (!inst.empty())
@ -346,28 +339,28 @@ void CObjectViewer::setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, b
// fix scale (some shapes have a different value) // fix scale (some shapes have a different value)
entity.setScale(1.f, 1.f, 1.f); entity.setScale(1.f, 1.f, 1.f);
UCamera Camera = _Scene->getCam(); NL3D::UCamera Camera = _Scene->getCam();
CVector max_radius = bbox.getHalfSize(); NLMISC::CVector max_radius = bbox.getHalfSize();
CVector center = bbox.getCenter(); NLMISC::CVector center = bbox.getCenter();
entity.setPivot(center); entity.setPivot(center);
center += pos; center += pos;
float fov = float(_CameraFocal * (float)Pi/180.0); float fov = float(_CameraFocal * (float)NLMISC::Pi/180.0);
float radius = max(max(max_radius.x, max_radius.y), max_radius.z); float radius = std::max(std::max(max_radius.x, max_radius.y), max_radius.z);
if (radius == 0.f) radius = 1.f; if (radius == 0.f) radius = 1.f;
float left, right, bottom, top, znear, zfar; float left, right, bottom, top, znear, zfar;
Camera.getFrustum(left, right, bottom, top, znear, zfar); Camera.getFrustum(left, right, bottom, top, znear, zfar);
float dist = radius / (tan(fov/2)); float dist = radius / (tan(fov/2));
CVector eye(center); NLMISC::CVector eye(center);
CVector ax(quat.getAxis()); NLMISC::CVector ax(quat.getAxis());
if (ax.isNull() || ax == CVector::I) if (ax.isNull() || ax == NLMISC::CVector::I)
{ {
ax = CVector::J; ax = NLMISC::CVector::J;
} }
else if (ax == -CVector::K) else if (ax == -NLMISC::CVector::K)
{ {
ax = -CVector::J; ax = -NLMISC::CVector::J;
} }
eye -= ax * (dist+radius); eye -= ax * (dist+radius);
@ -423,24 +416,16 @@ void CObjectViewer::updateAnimation(NL3D::TAnimationTime time)
void CObjectViewer::setBackgroundColor(NLMISC::CRGBA backgroundColor) void CObjectViewer::setBackgroundColor(NLMISC::CRGBA backgroundColor)
{ {
_BackgroundColor = backgroundColor; _BackgroundColor = backgroundColor;
// config file variable changes
Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.R, 0);
Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.G, 1);
Modules::config().getConfigFile().getVar("BackgroundColor").setAsInt(_BackgroundColor.B, 2);
} }
void CObjectViewer::setGraphicsDriver(bool Direct3D) void CObjectViewer::setGraphicsDriver(bool Direct3D)
{ {
_Direct3D = Direct3D; _Direct3D = Direct3D;
if (_Direct3D) Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("Direct3D");
else Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString("OpenGL");
} }
void CObjectViewer::setSizeViewport(uint16 w, uint16 h) void CObjectViewer::setSizeViewport(uint16 w, uint16 h)
{ {
_Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000); _Scene->getCam().setPerspective(_CameraFocal * (float)NLMISC::Pi/180.f, (float)w/h, 0.1f, 1000);
} }
void CObjectViewer::setCurrentObject(const std::string &name) void CObjectViewer::setCurrentObject(const std::string &name)
@ -466,26 +451,41 @@ void CObjectViewer::getListObjects(std::vector<std::string> &listObj)
void CObjectViewer::loadConfig() void CObjectViewer::loadConfig()
{ {
// set background color from config QSettings *settings = Core::ICore::instance()->settings();
Modules::config().setAndCallback("BackgroundColor", CConfigCallback(this, &CObjectViewer::cfcbBackgroundColor)); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// set graphics driver from config QColor color;
Modules::config().setAndCallback("GraphicsDriver",CConfigCallback(this,&CObjectViewer::cfcbGraphicsDriver)); color = settings->value("BackgroundColor", QColor(80, 80, 80)).value<QColor>();
_BackgroundColor = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha());
Modules::config().setAndCallback("CameraFocal",CConfigCallback(this,&CObjectViewer::cfcbCameraFocal)); _Direct3D = false; //_Driver = OpenGL;
Modules::config().setAndCallback("FontName",CConfigCallback(this,&CObjectViewer::cfcbFontName)); #ifdef NL_OS_WINDOWS
QString driver = settings->value(Constants::GRAPHICS_DRIVER, "OpenGL").toString();
if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D;
else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL;
else nlwarning("Invalid driver specified, defaulting to OpenGL");
#endif
Modules::config().setAndCallback("BloomEffect",CConfigCallback(this,&CObjectViewer::cfcbBloomEffect)); _CameraFocal = settings->value("CameraFocal", 75).toInt();
_FontName = settings->value(Constants::FONT, "andbasr.ttf").toString().toStdString();
_BloomEffect = settings->value(Constants::ENABLE_BLOOM, false).toBool();
_BloomDensity = settings->value(Constants::BLOOM_DENSITY, 0).toInt();
_BloomSquare = settings->value(Constants::ENABLE_SQUARE_BLOOM, false).toBool();
settings->endGroup();
} }
void CObjectViewer::saveConfig() void CObjectViewer::saveConfig()
{ {
Modules::config().dropCallback("BackgroundColor"); QSettings *settings = Core::ICore::instance()->settings();
Modules::config().dropCallback("GraphicsDriver"); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().dropCallback("CameraFocal");
Modules::config().dropCallback("FontName"); QColor color(_BackgroundColor.R, _BackgroundColor.G, _BackgroundColor.B, _BackgroundColor.A);
Modules::config().dropCallback("BloomEffect"); settings->setValue("BackgroundColor", color);
settings->endGroup();
settings->sync();
} }
void CObjectViewer::deleteEntities() void CObjectViewer::deleteEntities()
@ -500,38 +500,4 @@ void CObjectViewer::deleteEntities()
_ListIG.clear(); _ListIG.clear();
} }
void CObjectViewer::cfcbBackgroundColor(NLMISC::CConfigFile::CVar &var)
{
// read variable from config file
_BackgroundColor = CRGBA(var.asInt(0), var.asInt(1), var.asInt(2));
}
void CObjectViewer::cfcbGraphicsDriver(NLMISC::CConfigFile::CVar &var)
{
// Choose driver opengl to work correctly under Linux example
_Direct3D = false; //_Driver = OpenGL;
#ifdef NL_OS_WINDOWS
std::string driver = var.asString();
if (driver == "Direct3D") _Direct3D = true; //m_Driver = Direct3D;
else if (driver == "OpenGL") _Direct3D = false; //m_Driver = OpenGL;
else nlwarning("Invalid driver specified, defaulting to OpenGL");
#endif
}
void CObjectViewer::cfcbCameraFocal(NLMISC::CConfigFile::CVar &var)
{
_CameraFocal = var.asFloat();
}
void CObjectViewer::cfcbFontName(NLMISC::CConfigFile::CVar &var)
{
_FontName = var.asString();
}
void CObjectViewer::cfcbBloomEffect(NLMISC::CConfigFile::CVar &var)
{
_BloomEffect = var.asBool();
}
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -27,7 +27,6 @@
#include <map> #include <map>
// NeL includes // NeL includes
#include <nel/misc/config_file.h>
#include <nel/misc/rgba.h> #include <nel/misc/rgba.h>
#include <nel/3d/event_mouse_listener.h> #include <nel/3d/event_mouse_listener.h>
@ -231,13 +230,6 @@ private:
// Delete all entities // Delete all entities
void deleteEntities(); void deleteEntities();
// Load background color from config file, intended for CConfiguration.
void cfcbBackgroundColor(NLMISC::CConfigFile::CVar &var);
void cfcbGraphicsDriver(NLMISC::CConfigFile::CVar &var);
void cfcbCameraFocal(NLMISC::CConfigFile::CVar &var);
void cfcbFontName(NLMISC::CConfigFile::CVar &var);
void cfcbBloomEffect(NLMISC::CConfigFile::CVar &var);
NLMISC::CRGBA _BackgroundColor; NLMISC::CRGBA _BackgroundColor;
NL3D::IDriver *_IDriver; NL3D::IDriver *_IDriver;
NL3D::CScene *_CScene; NL3D::CScene *_CScene;
@ -260,6 +252,8 @@ private:
bool _Direct3D; bool _Direct3D;
bool _BloomEffect; bool _BloomEffect;
int _BloomDensity;
bool _BloomSquare;
std::string _CurrentInstance; std::string _CurrentInstance;

View file

@ -0,0 +1,62 @@
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef OBJECT_VIEWER_CONSTANTS_H
#define OBJECT_VIEWER_CONSTANTS_H
namespace NLQT
{
namespace Constants
{
const char * const OBJECT_VIEWER_PLUGIN = "ObjectViewer";
//mainwindow
const char * const MAIN_WINDOW = "ObjectViewer.MainWindow";
//settings
const char * const OBJECT_VIEWER_SECTION = "ObjectViewer";
const char * const GRAPHICS_DRIVER = "GraphicsDriver";
const char * const ENABLE_BLOOM = "EnableBloom";
const char * const ENABLE_SQUARE_BLOOM = "EnableSquareBloom";
const char * const BLOOM_DENSITY = "BloomDensity";
const char * const QT_STYLE = "QtStyle";
const char * const QT_PALETTE = "QtPalette";
const char * const FONT = "Font";
const char * const SOUND_ENABLE = "SoundEnable";
const char * const SOUND_DRIVER = "SoundDriver";
const char * const SOUND_DEVICE = "SoundDevice";
const char * const SOUND_AUTO_LOAD_SAMPLE = "SoundAutoLoadSample";
const char * const SOUND_ENABLE_OCCLUDE_OBSTRUCT = "SoundEnableOccludeObstruct";
const char * const SOUND_ENABLE_REVERB = "SoundEnableReverb";
const char * const SOUND_MANUAL_ROLL_OFF = "SoundManualRolloff";
const char * const SOUND_FORCE_SOFTWARE = "SoundForceSoftware";
const char * const SOUND_USE_ADCPM = "SoundUseADPCM";
const char * const SOUND_MAX_TRACK = "SoundMaxTrack";
const char * const SOUND_PACKED_SHEET_PATH = "SoundPackedSheetPath";
const char * const SOUND_SAMPLE_PATH = "SoundSamplePath";
const char * const VEGET_TILE_BANK = "VegetTileBank";
const char * const VEGET_TILE_FAR_BANK = "VegetTileFarBank";
const char * const VEGET_TEXTURE = "VegetTexture";
const char * const VEGET_LANDSCAPE_ZONES = "VegetLandscapeZones";
const char * const COARSE_MESH_TEXTURE = "CoarseMeshTexture";
} // namespace Constants
} // namespace NLQT
#endif // OBJECT_VIEWER_CONSTANTS_H

View file

@ -22,7 +22,7 @@ ObjectViewerPlugin::~ObjectViewerPlugin()
} }
qDeleteAll(_autoReleaseObjects); qDeleteAll(_autoReleaseObjects);
_autoReleaseObjects.clear(); _autoReleaseObjects.clear();
Modules::release(); //Modules::release();
} }
bool ObjectViewerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString) bool ObjectViewerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
@ -41,6 +41,11 @@ void ObjectViewerPlugin::extensionsInitialized()
{ {
} }
void ObjectViewerPlugin::shutdown()
{
Modules::release();
}
void ObjectViewerPlugin::setNelContext(NLMISC::INelContext *nelContext) void ObjectViewerPlugin::setNelContext(NLMISC::INelContext *nelContext)
{ {
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS

View file

@ -35,6 +35,7 @@ public:
bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString); bool initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString);
void extensionsInitialized(); void extensionsInitialized();
void shutdown();
void setNelContext(NLMISC::INelContext *nelContext); void setNelContext(NLMISC::INelContext *nelContext);

View file

@ -17,23 +17,22 @@
*/ */
// Project includes
#include "stdpch.h" #include "stdpch.h"
#include "setup_fog_dialog.h" #include "setup_fog_dialog.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h"
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QColorDialog> #include <QtGui/QColorDialog>
#include <QtCore/QSettings>
// NeL includes // NeL includes
#include <nel/misc/path.h> #include <nel/misc/path.h>
#include <nel/3d/u_driver.h> #include <nel/3d/u_driver.h>
// Project includes
#include "modules.h"
using namespace NL3D;
using namespace NLMISC;
namespace NLQT namespace NLQT
{ {
@ -42,10 +41,17 @@ CSetupFog::CSetupFog(QWidget *parent)
{ {
ui.setupUi(this); ui.setupUi(this);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// load fog value from config file // load fog value from config file
ui.startDoubleSpinBox->setValue(Modules::config().getValue("FogStart", 0.0)); ui.startDoubleSpinBox->setValue(settings->value("FogStart", 0.0).toDouble());
ui.endDoubleSpinBox->setValue(Modules::config().getValue("FogEnd", 0.0)); ui.endDoubleSpinBox->setValue(settings->value("FogEnd", 0.0).toDouble());
colorFog = Modules::config().getValue("FogColor",CRGBA(0.0, 0.0, 0.0));
QColor color = settings->value("FogColor", QColor(80, 80, 80)).value<QColor>();
colorFog = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha());
settings->endGroup();
connect(ui.applyPushButton, SIGNAL(clicked()), this, SLOT(apply())); connect(ui.applyPushButton, SIGNAL(clicked()), this, SLOT(apply()));
connect(ui.colorPushButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(ui.colorPushButton, SIGNAL(clicked()), this, SLOT(setColor()));
@ -53,13 +59,17 @@ CSetupFog::CSetupFog(QWidget *parent)
CSetupFog::~CSetupFog() CSetupFog::~CSetupFog()
{ {
// save fog value from config file QSettings *settings = Core::ICore::instance()->settings();
Modules::config().getConfigFile().getVar("FogStart").setAsFloat(ui.startDoubleSpinBox->value()); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("FogEnd").setAsFloat(ui.endDoubleSpinBox->value());
Modules::config().getConfigFile().getVar("FogColor").setAsInt(colorFog.R, 0);
Modules::config().getConfigFile().getVar("FogColor").setAsInt(colorFog.G, 1);
Modules::config().getConfigFile().getVar("FogColor").setAsInt(colorFog.B, 2);
settings->setValue("FogStart", ui.startDoubleSpinBox->value());
settings->setValue("FogEnd", ui.endDoubleSpinBox->value());
QColor color(colorFog.R, colorFog.G, colorFog.B, colorFog.A);
settings->setValue("FogColor", color);
settings->endGroup();
settings->sync();
} }
void CSetupFog::apply() void CSetupFog::apply()

View file

@ -18,11 +18,14 @@
// Project includes // Project includes
#include "stdpch.h" #include "stdpch.h"
#include "sound_settings_page.h" #include "sound_settings_page.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h" #include "modules.h"
// Qt includes // Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QFileDialog>
namespace NLQT namespace NLQT
{ {
@ -45,7 +48,7 @@ QString SoundSettingsPage::trName() const
QString SoundSettingsPage::category() const QString SoundSettingsPage::category() const
{ {
return QLatin1String("ObjectViewer"); return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
} }
QString SoundSettingsPage::trCategory() const QString SoundSettingsPage::trCategory() const
@ -58,62 +61,70 @@ QWidget *SoundSettingsPage::createPage(QWidget *parent)
m_page = new QWidget(parent); m_page = new QWidget(parent);
m_ui.setupUi(m_page); m_ui.setupUi(m_page);
// setup config file callbacks and initialize values QSettings *settings = Core::ICore::instance()->settings();
Modules::config().setAndCallback("SoundDrivers", CConfigCallback(this, &SoundSettingsPage::cfcbSoundDrivers)); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
QString soundDriver = settings->value(Constants::SOUND_DRIVER, "Auto").toString();
m_ui.driverSndComboBox->setCurrentIndex(m_ui.driverSndComboBox->findText(soundDriver));
// load settings from the config file // load settings from the config file
m_ui.autoLoadSampleCheckBox->setChecked(Modules::config().getValue("SoundAutoLoadSample", true)); m_ui.autoLoadSampleCheckBox->setChecked(settings->value(Constants::SOUND_AUTO_LOAD_SAMPLE, true).toBool());
m_ui.enableOccludeObstructCheckBox->setChecked(Modules::config().getValue("SoundEnableOccludeObstruct", true)); m_ui.enableOccludeObstructCheckBox->setChecked(settings->value(Constants::SOUND_ENABLE_OCCLUDE_OBSTRUCT, true).toBool());
m_ui.enableReverbCheckBox->setChecked(Modules::config().getValue("SoundEnableReverb", true)); m_ui.enableReverbCheckBox->setChecked(settings->value(Constants::SOUND_ENABLE_REVERB, true).toBool());
m_ui.manualRolloffCheckBox->setChecked(Modules::config().getValue("SoundManualRolloff", true)); m_ui.manualRolloffCheckBox->setChecked(settings->value(Constants::SOUND_MANUAL_ROLL_OFF, true).toBool());
m_ui.forceSoftwareCheckBox->setChecked(Modules::config().getValue("SoundForceSoftware", false)); m_ui.forceSoftwareCheckBox->setChecked(settings->value(Constants::SOUND_FORCE_SOFTWARE, false).toBool());
m_ui.useADPCMCheckBox->setChecked(Modules::config().getValue("SoundUseADPCM", false)); m_ui.useADPCMCheckBox->setChecked(settings->value(Constants::SOUND_USE_ADCPM, false).toBool());
m_ui.maxTrackSpinBox->setValue(Modules::config().getValue("SoundMaxTrack", 48)); m_ui.maxTrackSpinBox->setValue(settings->value(Constants::SOUND_MAX_TRACK, 48).toInt());
m_ui.soundSamplePathLineEdit->setText(settings->value(Constants::SOUND_SAMPLE_PATH, "").toString());
m_ui.soundSheetPathLineEdit->setText(settings->value(Constants::SOUND_PACKED_SHEET_PATH, "").toString());
connect(m_ui.soundSamplePathButton, SIGNAL(clicked()), this, SLOT(setSamplePath()));
connect(m_ui.soundSheetPathButton, SIGNAL(clicked()), this, SLOT(setSheetPath()));
settings->endGroup();
return m_page; return m_page;
} }
void SoundSettingsPage::apply() void SoundSettingsPage::apply()
{ {
// save sound settings to config file QSettings *settings = Core::ICore::instance()->settings();
Modules::config().getConfigFile().getVar("SoundDriver").setAsString(m_ui.driverSndComboBox->currentText().toStdString()); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("SoundAutoLoadSample").setAsInt(m_ui.autoLoadSampleCheckBox->isChecked());
Modules::config().getConfigFile().getVar("SoundEnableOccludeObstruct").setAsInt(m_ui.enableOccludeObstructCheckBox->isChecked());
Modules::config().getConfigFile().getVar("SoundEnableReverb").setAsInt(m_ui.enableReverbCheckBox->isChecked());
Modules::config().getConfigFile().getVar("SoundManualRolloff").setAsInt(m_ui.manualRolloffCheckBox->isChecked());
Modules::config().getConfigFile().getVar("SoundForceSoftware").setAsInt(m_ui.forceSoftwareCheckBox->isChecked());
Modules::config().getConfigFile().getVar("SoundUseADPCM").setAsInt(m_ui.useADPCMCheckBox->isChecked());
Modules::config().getConfigFile().getVar("SoundMaxTrack").setAsInt(m_ui.maxTrackSpinBox->value());
// save config file settings->setValue(Constants::SOUND_DRIVER, m_ui.driverSndComboBox->currentText());
Modules::config().getConfigFile().save(); settings->setValue(Constants::SOUND_AUTO_LOAD_SAMPLE, m_ui.autoLoadSampleCheckBox->isChecked());
settings->setValue(Constants::SOUND_ENABLE_OCCLUDE_OBSTRUCT, m_ui.enableOccludeObstructCheckBox->isChecked());
settings->setValue(Constants::SOUND_ENABLE_REVERB, m_ui.enableReverbCheckBox->isChecked());
settings->setValue(Constants::SOUND_MANUAL_ROLL_OFF, m_ui.manualRolloffCheckBox->isChecked());
settings->setValue(Constants::SOUND_FORCE_SOFTWARE, m_ui.forceSoftwareCheckBox->isChecked());
settings->setValue(Constants::SOUND_USE_ADCPM, m_ui.useADPCMCheckBox->isChecked());
settings->setValue(Constants::SOUND_MAX_TRACK, m_ui.maxTrackSpinBox->value());
settings->setValue(Constants::SOUND_SAMPLE_PATH, m_ui.soundSamplePathLineEdit->text());
settings->setValue(Constants::SOUND_PACKED_SHEET_PATH, m_ui.soundSheetPathLineEdit->text());
settings->endGroup();
settings->sync();
} }
void SoundSettingsPage::finish() void SoundSettingsPage::finish()
{ {
Modules::config().dropCallback("SoundDrivers");
} }
void SoundSettingsPage::cfcbSoundDrivers(NLMISC::CConfigFile::CVar& var) void SoundSettingsPage::setSheetPath()
{ {
while (m_ui.driverSndComboBox->count()) QString path = QFileDialog::getExistingDirectory();
m_ui.driverSndComboBox->removeItem(0); if (!path.isEmpty())
// load types sound driver from the config file
for (uint i = 0; i < var.size(); ++i)
m_ui.driverSndComboBox->addItem(var.asString(i).c_str());
// set sound driver from the config file
QString value = Modules::config().getValue("SoundDriver",std::string("Auto")).c_str();
QString dn = value.toLower();
for (sint i = 0; i < m_ui.driverSndComboBox->count(); ++i)
{ {
if (dn == m_ui.driverSndComboBox->itemText(i).toLower()) m_ui.soundSheetPathLineEdit->setText(path);
{
m_ui.driverSndComboBox->setCurrentIndex(i);
return;
} }
} }
void SoundSettingsPage::setSamplePath()
{
QString path = QFileDialog::getExistingDirectory();
if (!path.isEmpty())
{
m_ui.soundSamplePathLineEdit->setText(path);
}
} }
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -26,9 +26,6 @@
// Qt includes // Qt includes
#include <QtCore/QObject> #include <QtCore/QObject>
// NeL includes
#include <nel/misc/config_file.h>
class QWidget; class QWidget;
namespace NLQT namespace NLQT
@ -52,9 +49,11 @@ public:
virtual void apply(); virtual void apply();
virtual void finish(); virtual void finish();
private: private Q_SLOTS:
void cfcbSoundDrivers(NLMISC::CConfigFile::CVar &var); void setSheetPath();
void setSamplePath();
private:
QWidget *m_page; QWidget *m_page;
Ui::SoundSettingsPage m_ui; Ui::SoundSettingsPage m_ui;
}; };

View file

@ -6,21 +6,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>326</width> <width>331</width>
<height>268</height> <height>278</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin"> <item row="0" column="0" colspan="3">
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="driverSndLabel"> <widget class="QLabel" name="driverSndLabel">
@ -50,53 +44,78 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
<item>
<property name="text">
<string>OpenAL</string>
</property>
</item>
<item>
<property name="text">
<string>XAudio2</string>
</property>
</item>
<item>
<property name="text">
<string>FMod</string>
</property>
</item>
<item>
<property name="text">
<string>DSound</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="autoLoadSampleCheckBox"> <widget class="QCheckBox" name="autoLoadSampleCheckBox">
<property name="text"> <property name="text">
<string>SoundAutoLoadSample</string> <string>SoundAutoLoadSample</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="enableOccludeObstructCheckBox"> <widget class="QCheckBox" name="enableOccludeObstructCheckBox">
<property name="text"> <property name="text">
<string>SoundEnableOccludeObstruct</string> <string>SoundEnableOccludeObstruct</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="enableReverbCheckBox"> <widget class="QCheckBox" name="enableReverbCheckBox">
<property name="text"> <property name="text">
<string>SoundEnableReverb</string> <string>SoundEnableReverb</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="manualRolloffCheckBox"> <widget class="QCheckBox" name="manualRolloffCheckBox">
<property name="text"> <property name="text">
<string>SoundManualRolloff</string> <string>SoundManualRolloff</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="forceSoftwareCheckBox"> <widget class="QCheckBox" name="forceSoftwareCheckBox">
<property name="text"> <property name="text">
<string>SoundForceSoftware</string> <string>SoundForceSoftware</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="useADPCMCheckBox"> <widget class="QCheckBox" name="useADPCMCheckBox">
<property name="text"> <property name="text">
<string>SoundUseADPCM</string> <string>SoundUseADPCM</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="7" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLabel" name="maxTrackLabel"> <widget class="QLabel" name="maxTrackLabel">
@ -140,6 +159,40 @@
</layout> </layout>
</item> </item>
<item row="8" column="0"> <item row="8" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>SoundPackedSheetPath</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="soundSheetPathLineEdit"/>
</item>
<item row="8" column="2">
<widget class="QToolButton" name="soundSheetPathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>SoundSamplePath</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="soundSamplePathLineEdit"/>
</item>
<item row="9" column="2">
<widget class="QToolButton" name="soundSamplePathButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="10" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

View file

@ -18,6 +18,11 @@
#include "stdpch.h" #include "stdpch.h"
#include "sound_system.h" #include "sound_system.h"
// Project includes
#include "modules.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
// NeL includes // NeL includes
#include <nel/sound/u_audio_mixer.h> #include <nel/sound/u_audio_mixer.h>
#include <nel/sound/u_listener.h> #include <nel/sound/u_listener.h>
@ -26,8 +31,8 @@
#include <nel/3d/u_particle_system_sound.h> #include <nel/3d/u_particle_system_sound.h>
#include <nel/misc/path.h> #include <nel/misc/path.h>
// Project includes // Qt includes
#include "modules.h" #include <QtCore/QSettings>
namespace NLQT namespace NLQT
{ {
@ -73,23 +78,28 @@ void CSoundSystem::init ()
try try
{ {
// init audiomixer // init audiomixer
_PackedSheetPath = Modules::config().getValue("SoundPackedSheetPath", std::string("")); QSettings *settings = Core::ICore::instance()->settings();
_SamplePath = Modules::config().getValue("SoundSamplePath", std::string("")); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
_PackedSheetPath = settings->value(Constants::SOUND_PACKED_SHEET_PATH, "").toString().toStdString();
_SamplePath = settings->value(Constants::SOUND_SAMPLE_PATH, "").toString().toStdString();
_AudioMixer->setSamplePath(_SamplePath); _AudioMixer->setSamplePath(_SamplePath);
_AudioMixer->setPackedSheetOption(_PackedSheetPath, true); _AudioMixer->setPackedSheetOption(_PackedSheetPath, true);
std::vector<std::string> devices; std::vector<std::string> devices;
_AudioMixer->initDriver(Modules::config().getValue("SoundDriver", std::string("Auto"))); _AudioMixer->initDriver(settings->value(Constants::SOUND_DRIVER, "Auto").toString().toStdString());
_AudioMixer->getDevices(devices); _AudioMixer->getDevices(devices);
NLSOUND::UAudioMixer::CInitInfo audioInfo; NLSOUND::UAudioMixer::CInitInfo audioInfo;
audioInfo.AutoLoadSample = Modules::config().getValue("SoundAutoLoadSample", true); audioInfo.AutoLoadSample = settings->value(Constants::SOUND_AUTO_LOAD_SAMPLE, true).toBool();
audioInfo.EnableOccludeObstruct = Modules::config().getValue("SoundEnableOccludeObstruct", true); audioInfo.EnableOccludeObstruct = settings->value(Constants::SOUND_ENABLE_OCCLUDE_OBSTRUCT, true).toBool();
audioInfo.EnableReverb = Modules::config().getValue("SoundEnableReverb", true); audioInfo.EnableReverb = settings->value(Constants::SOUND_ENABLE_REVERB, true).toBool();
audioInfo.ManualRolloff = Modules::config().getValue("SoundManualRolloff", true); audioInfo.ManualRolloff = settings->value(Constants::SOUND_MANUAL_ROLL_OFF, true).toBool();
audioInfo.ForceSoftware = Modules::config().getValue("SoundForceSoftware", false); audioInfo.ForceSoftware = settings->value(Constants::SOUND_FORCE_SOFTWARE, false).toBool();
audioInfo.MaxTrack = Modules::config().getValue("SoundMaxTrack", 48); audioInfo.MaxTrack = settings->value(Constants::SOUND_MAX_TRACK, 48).toInt();
audioInfo.UseADPCM = Modules::config().getValue("SoundUseADPCM", false); audioInfo.UseADPCM = settings->value(Constants::SOUND_USE_ADCPM, false).toBool();
_AudioMixer->initDevice(Modules::config().getValue("SoundDevice", std::string("")), audioInfo, NULL); _AudioMixer->initDevice(settings->value(Constants::SOUND_DEVICE, "").toString().toStdString(), audioInfo, NULL);
_AudioMixer->setLowWaterMark(1); _AudioMixer->setLowWaterMark(1);
settings->endGroup();
} }
catch(NLMISC::Exception &e) catch(NLMISC::Exception &e)
{ {

View file

@ -17,12 +17,19 @@
*/ */
// Project includes
#include "stdpch.h" #include "stdpch.h"
#include "vegetable_editor.h" #include "vegetable_editor.h"
#include "modules.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
// Qt includes // Qt includes
#include <QtGui/QProgressDialog> #include <QtGui/QProgressDialog>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QColor>
#include <QtGui/QVector3D>
#include <QtCore/QSettings>
// NeL includes // NeL includes
#include <nel/3d/landscape_model.h> #include <nel/3d/landscape_model.h>
@ -31,12 +38,8 @@
#include <nel/3d/driver.h> #include <nel/3d/driver.h>
#include <nel/3d/scene_user.h> #include <nel/3d/scene_user.h>
#include <nel/3d/scene.h> #include <nel/3d/scene.h>
//#include <nel/3d/u_landscape.h>
// Project includes
#include "modules.h"
#include <nel/3d/u_camera.h> #include <nel/3d/u_camera.h>
//#include <nel/3d/u_landscape.h>
namespace NLQT namespace NLQT
{ {
@ -258,7 +261,7 @@ bool CVegetableEditor::createVegetableLandscape()
return false; return false;
} }
} }
Modules::objView().getScene()->setCoarseMeshManagerTexture(_CoarseMeshTexture.c_str());
return true; return true;
} }
@ -311,7 +314,7 @@ void CVegetableEditor::refreshVegetableLandscape(const NL3D::CTileVegetableDesc
} }
} }
void CVegetableEditor::setVegetableWindPower(float w) void CVegetableEditor::setVegetableWindPower(double w)
{ {
_VegetableWindPower= w; _VegetableWindPower= w;
if(_VegetableLandscape) if(_VegetableLandscape)
@ -321,7 +324,7 @@ void CVegetableEditor::setVegetableWindPower(float w)
_VegetableWindBendMin); _VegetableWindBendMin);
} }
void CVegetableEditor::setVegetableWindBendStart(float w) void CVegetableEditor::setVegetableWindBendStart(double w)
{ {
_VegetableWindBendMin= w; _VegetableWindBendMin= w;
if(_VegetableLandscape) if(_VegetableLandscape)
@ -331,7 +334,7 @@ void CVegetableEditor::setVegetableWindBendStart(float w)
_VegetableWindBendMin); _VegetableWindBendMin);
} }
void CVegetableEditor::setVegetableWindFrequency(float w) void CVegetableEditor::setVegetableWindFrequency(double w)
{ {
_VegetableWindFreq= w; _VegetableWindFreq= w;
if(_VegetableLandscape) if(_VegetableLandscape)
@ -540,222 +543,94 @@ void CVegetableEditor::loadConfig()
_VegetableSnapToGround = false; _VegetableSnapToGround = false;
// Load Landscape params. // Load Landscape params.
// --------------
// threshold
try
{
_VegetableLandscapeThreshold = Modules::config().getConfigFile().getVar("VegetLandscapeThreshold").asFloat();
// clamp to avoid divide/0.
_VegetableLandscapeThreshold = std::max(_VegetableLandscapeThreshold, 0.001f);
}
catch (NLMISC::EUnknownVar &)
{
_VegetableLandscapeThreshold = 0.003f;
}
// tilenear
try
{
_VegetableLandscapeTileNear = Modules::config().getConfigFile().getVar("VegetLandscapeTileNear").asFloat();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableLandscapeTileNear= 50;
}
// ambient
try
{
NLMISC::CConfigFile::CVar &color = Modules::config().getConfigFile().getVar("VegetLandscapeAmbient");
_VegetableLandscapeAmbient.R = color.asInt(0);
_VegetableLandscapeAmbient.G = color.asInt(1);
_VegetableLandscapeAmbient.B = color.asInt(2);
_VegetableLandscapeAmbient.A = color.asInt(3);
}
catch (NLMISC::EUnknownVar &)
{
_VegetableLandscapeAmbient.set(80, 80, 80, 255);
}
// diffuse
try
{
NLMISC::CConfigFile::CVar &color= Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse");
_VegetableLandscapeDiffuse.R = color.asInt(0);
_VegetableLandscapeDiffuse.G = color.asInt(1);
_VegetableLandscapeDiffuse.B = color.asInt(2);
_VegetableLandscapeDiffuse.A = color.asInt(3);
}
catch (NLMISC::EUnknownVar &)
{
_VegetableLandscapeDiffuse.set(255, 255, 255, 255);
}
// Snapping
try
{
_VegetableSnapHeight = Modules::config().getConfigFile().getVar("VegetLandscapeSnapHeight").asFloat();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableSnapHeight = 1.70f;
}
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
_VegetableLandscapeThreshold = std::max(settings->value("VegetLandscapeThreshold", 0.003).toDouble(), 0.001);
_VegetableLandscapeTileNear = settings->value("VegetLandscapeTileNear", 50).toDouble();
QColor color;
color = settings->value("VegetLandscapeAmbient", QColor(80, 80, 80)).value<QColor>();
_VegetableLandscapeAmbient = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha());
color = settings->value("VegetLandscapeDiffuse", QColor(255, 255, 255)).value<QColor>();
_VegetableLandscapeDiffuse = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha());
_VegetableSnapHeight = settings->value("VegetLandscapeSnapHeight", 1.70f).toFloat();
// Load Vegetable params. // Load Vegetable params.
// --------------
// vegetable ambient color = settings->value("VegetAmbient", QColor(80, 80, 80)).value<QColor>();
try _VegetableAmbient = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha());
{
NLMISC::CConfigFile::CVar &color = Modules::config().getConfigFile().getVar("VegetAmbient"); color = settings->value("VegetDiffuse", QColor(80, 80, 80)).value<QColor>();
_VegetableAmbient.R = color.asInt(0);
_VegetableAmbient.G = color.asInt(1);
_VegetableAmbient.B = color.asInt(2);
}
catch (NLMISC::EUnknownVar &)
{
_VegetableAmbient.set(80, 80, 80, 255);
}
// vegetable diffuse
try
{
NLMISC::CConfigFile::CVar &color = Modules::config().getConfigFile().getVar("VegetDiffuse");
// setup to behave correclty ie as maxLightFactor: // setup to behave correclty ie as maxLightFactor:
sint R = color.asInt(0) - _VegetableAmbient.R; sint R = color.red() - _VegetableAmbient.R;
NLMISC::clamp(R, 0, 255); NLMISC::clamp(R, 0, 255);
_VegetableDiffuse.R = R; _VegetableDiffuse.R = R;
sint G = color.asInt(1) - _VegetableAmbient.G; sint G = color.green() - _VegetableAmbient.G;
NLMISC::clamp(G, 0, 255); NLMISC::clamp(G, 0, 255);
_VegetableDiffuse.G = G; _VegetableDiffuse.G = G;
sint B = color.asInt(2) - _VegetableAmbient.B; sint B = color.blue() - _VegetableAmbient.B;
NLMISC::clamp(B, 0, 255); NLMISC::clamp(B, 0, 255);
_VegetableDiffuse.B = B; _VegetableDiffuse.B = B;
}
catch (NLMISC::EUnknownVar &)
{
sint R = 255 - _VegetableAmbient.R;
NLMISC::clamp(R, 0, 255);
_VegetableDiffuse.R = R;
sint G = 255 - _VegetableAmbient.G;
NLMISC::clamp(G, 0, 255);
_VegetableDiffuse.G = G;
sint B = 255 - _VegetableAmbient.B;
NLMISC::clamp(B, 0, 255);
_VegetableDiffuse.B = B;
}
// vegetable lightDir
try
{
NLMISC::CConfigFile::CVar &var = Modules::config().getConfigFile().getVar("VegetLightDir");
_VegetableLightDir.x = var.asFloat(0);
_VegetableLightDir.y = var.asFloat(1);
_VegetableLightDir.z = var.asFloat(2);
_VegetableLightDir.normalize();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableLightDir.set(0, 1, -1);
_VegetableLightDir.normalize();
}
// windDir QVector3D vec;
try vec = settings->value("VegetLightDir", QVector3D(0, 1, -1)).value<QVector3D>();
{ _VegetableLightDir = NLMISC::CVector(vec.x(), vec.y(), vec.z());
NLMISC::CConfigFile::CVar &var = Modules::config().getConfigFile().getVar("VegetWindDir"); _VegetableLightDir.normalize();
_VegetableWindDir.x = var.asFloat(0);
_VegetableWindDir.y = var.asFloat(1); vec = settings->value("VegetWindDir", QVector3D(0.5f, 0.5f, 0)).value<QVector3D>();
_VegetableWindDir.z = var.asFloat(2); _VegetableWindDir = NLMISC::CVector(vec.x(), vec.y(), vec.z());
}
catch (NLMISC::EUnknownVar &) _VegetableWindFreq = settings->value("VegetWindFreq", 0.5).toDouble();
{ _VegetableWindPower = settings->value("VegetWindPower", 1).toDouble();
_VegetableWindDir.x = 0.5f; _VegetableWindBendMin = settings->value("VegetWindBendMin", 0).toDouble();
_VegetableWindDir.y = 0.5f; settings->endGroup();
_VegetableWindDir.z = 0;
}
// windFreq
try
{
_VegetableWindFreq = Modules::config().getConfigFile().getVar("VegetWindFreq").asFloat();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableWindFreq= 0.5;
}
// windPower
try
{
_VegetableWindPower = Modules::config().getConfigFile().getVar("VegetWindPower").asFloat();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableWindPower= 1;
}
// windBendMin
try
{
_VegetableWindBendMin = Modules::config().getConfigFile().getVar("VegetWindBendMin").asFloat();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableWindBendMin= 0;
}
} }
void CVegetableEditor::loadLandscapeSetup() void CVegetableEditor::loadLandscapeSetup()
{ {
// Load landscape setup QSettings *settings = Core::ICore::instance()->settings();
// -------------- settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
try
{
// tileBank setup.
_VegetableLandscapeTileBank = Modules::config().getConfigFile().getVar("VegetTileBank").asString();
_VegetableLandscapeTileFarBank = Modules::config().getConfigFile().getVar("VegetTileFarBank").asString();
// zone list.
_VegetableLandscapeZoneNames.clear();
NLMISC::CConfigFile::CVar &zones = Modules::config().getConfigFile().getVar("VegetLandscapeZones");
for (uint i=0; i<(uint)zones.size(); i++)
_VegetableLandscapeZoneNames.push_back(zones.asString(i).c_str());
}
catch (NLMISC::EUnknownVar &)
{
_VegetableLandscapeTileBank.clear();
_VegetableLandscapeTileFarBank.clear();
_VegetableLandscapeZoneNames.clear();
}
// Load Vegetable params. _VegetableLandscapeTileBank = settings->value(Constants::VEGET_TILE_BANK, "").toString().toStdString();
// -------------- _VegetableLandscapeTileFarBank = settings->value(Constants::VEGET_TILE_FAR_BANK, "").toString().toStdString();
_CoarseMeshTexture = settings->value(Constants::COARSE_MESH_TEXTURE, "").toString().toStdString();
_VegetableTexture = settings->value(Constants::VEGET_TEXTURE, "").toString().toStdString();
// vegetable texture QStringList list = settings->value(Constants::VEGET_LANDSCAPE_ZONES).toStringList();
try _VegetableLandscapeZoneNames.clear();
{ for (int i = 0; i < list.size(); ++i)
_VegetableTexture = Modules::config().getConfigFile().getVar("VegetTexture").asString(); _VegetableLandscapeZoneNames.push_back(list[i].toStdString());
} settings->endGroup();
catch (NLMISC::EUnknownVar &)
{
_VegetableTexture= "";
}
} }
void CVegetableEditor::saveConfig() void CVegetableEditor::saveConfig()
{ {
Modules::config().getConfigFile().getVar("VegetLandscapeThreshold").setAsFloat(_VegetableLandscapeThreshold); QSettings *settings = Core::ICore::instance()->settings();
Modules::config().getConfigFile().getVar("VegetLandscapeTileNear").setAsFloat(_VegetableLandscapeTileNear); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.R, 0); settings->setValue("VegetLandscapeThreshold", _VegetableLandscapeThreshold);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.G, 1); settings->setValue("VegetLandscapeTileNear", _VegetableLandscapeTileNear);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.B, 2);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.A, 3);
Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse").setAsInt(_VegetableLandscapeDiffuse.R, 0); QColor vAmbColor(_VegetableLandscapeAmbient.R, _VegetableLandscapeAmbient.G, _VegetableLandscapeAmbient.B, _VegetableLandscapeAmbient.A);
Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse").setAsInt(_VegetableLandscapeDiffuse.G, 1); settings->setValue("VegetLandscapeAmbient", vAmbColor);
Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse").setAsInt(_VegetableLandscapeDiffuse.B, 2);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.A, 3);
Modules::config().getConfigFile().getVar("VegetWindDir").setAsFloat(_VegetableWindDir.x, 0); QColor vDifColor(_VegetableLandscapeDiffuse.R, _VegetableLandscapeDiffuse.G, _VegetableLandscapeDiffuse.B, _VegetableLandscapeDiffuse.A);
Modules::config().getConfigFile().getVar("VegetWindDir").setAsFloat(_VegetableWindDir.y, 1); settings->setValue("VegetLandscapeDiffuse", vDifColor);
Modules::config().getConfigFile().getVar("VegetWindDir").setAsFloat(_VegetableWindDir.z, 2);
Modules::config().getConfigFile().getVar("VegetWindPower").setAsFloat(_VegetableWindPower); QVector3D vec(_VegetableWindDir.x, _VegetableWindDir.y, _VegetableWindDir.z);
Modules::config().getConfigFile().getVar("VegetWindFreq").setAsFloat(_VegetableWindFreq); settings->setValue("VegetWindDir", vec);
Modules::config().getConfigFile().getVar("VegetWindBendMin").setAsFloat(_VegetableWindBendMin);
settings->setValue("VegetWindPower", _VegetableWindPower);
settings->setValue("VegetWindFreq", _VegetableWindFreq);
settings->setValue("VegetWindBendMin", _VegetableWindBendMin);
settings->endGroup();
settings->sync();
} }
} /* namespace NLQT */ } /* namespace NLQT */

View file

@ -140,23 +140,23 @@ public:
void refreshVegetableLandscape(const NL3D::CTileVegetableDesc &tvdesc); void refreshVegetableLandscape(const NL3D::CTileVegetableDesc &tvdesc);
/// Get vegetable Wind wetup. /// Get vegetable Wind wetup.
float getVegetableWindPower() const double getVegetableWindPower() const
{ {
return _VegetableWindPower; return _VegetableWindPower;
} }
float getVegetableWindBendStart() const double getVegetableWindBendStart() const
{ {
return _VegetableWindBendMin; return _VegetableWindBendMin;
} }
float getVegetableWindFrequency() const double getVegetableWindFrequency() const
{ {
return _VegetableWindFreq; return _VegetableWindFreq;
} }
/// Set vegetable Wind wetup (updat view if possible) /// Set vegetable Wind wetup (updat view if possible)
void setVegetableWindPower(float w); void setVegetableWindPower(double w);
void setVegetableWindBendStart(float w); void setVegetableWindBendStart(double w);
void setVegetableWindFrequency(float w); void setVegetableWindFrequency(double w);
void setVegetableAmbientLight(const NLMISC::CRGBA &ambient); void setVegetableAmbientLight(const NLMISC::CRGBA &ambient);
void setVegetableDiffuseLight(const NLMISC::CRGBA &diffuse); void setVegetableDiffuseLight(const NLMISC::CRGBA &diffuse);
@ -236,11 +236,12 @@ private:
std::string _VegetableLandscapeTileBank; std::string _VegetableLandscapeTileBank;
std::string _VegetableLandscapeTileFarBank; std::string _VegetableLandscapeTileFarBank;
std::vector<std::string> _VegetableLandscapeZoneNames; std::vector<std::string> _VegetableLandscapeZoneNames;
std::string _CoarseMeshTexture;
// Misc. // Misc.
float _VegetableLandscapeThreshold; double _VegetableLandscapeThreshold;
float _VegetableLandscapeTileNear; double _VegetableLandscapeTileNear;
float _VegetableLandscapeMultiply; double _VegetableLandscapeMultiply;
NLMISC::CRGBA _VegetableLandscapeAmbient; NLMISC::CRGBA _VegetableLandscapeAmbient;
NLMISC::CRGBA _VegetableLandscapeDiffuse; NLMISC::CRGBA _VegetableLandscapeDiffuse;
std::string _VegetableTexture; std::string _VegetableTexture;
@ -249,9 +250,9 @@ private:
NLMISC::CVector _VegetableLightDir; NLMISC::CVector _VegetableLightDir;
// Vegetable wind. // Vegetable wind.
NLMISC::CVector _VegetableWindDir; NLMISC::CVector _VegetableWindDir;
float _VegetableWindFreq; double _VegetableWindFreq;
float _VegetableWindPower; double _VegetableWindPower;
float _VegetableWindBendMin; double _VegetableWindBendMin;
bool _VegetableEnabled; bool _VegetableEnabled;

View file

@ -23,9 +23,9 @@
// Project includes // Project includes
#include "modules.h" #include "modules.h"
#define NL_VEGETABLE_EDIT_WIND_MAX_POWER 10.f #define NL_VEGETABLE_EDIT_WIND_MAX_POWER 10.0
#define NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY 10.f #define NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY 10.0
#define NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART 1.f #define NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART 1.0
namespace NLQT namespace NLQT
{ {
@ -43,15 +43,15 @@ CVegetableLandscapePage::CVegetableLandscapePage(QWidget *parent)
connect(_ui.diffuseColorWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setColorDiffuse(NLMISC::CRGBA))); connect(_ui.diffuseColorWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setColorDiffuse(NLMISC::CRGBA)));
connect(_ui.ambientColorwidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setColorAmbient(NLMISC::CRGBA))); connect(_ui.ambientColorwidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setColorAmbient(NLMISC::CRGBA)));
float windPower = Modules::veget().getVegetableWindPower(); double windPower = Modules::veget().getVegetableWindPower();
NLMISC::clamp(windPower, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER); NLMISC::clamp(windPower, 0, NL_VEGETABLE_EDIT_WIND_MAX_POWER);
_ui.powerHorizontalSlider->setValue(int(windPower * _ui.powerHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_POWER)); _ui.powerHorizontalSlider->setValue(int(windPower * _ui.powerHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_POWER));
float bendStar = Modules::veget().getVegetableWindBendStart(); double bendStar = Modules::veget().getVegetableWindBendStart();
NLMISC::clamp(bendStar, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART); NLMISC::clamp(bendStar, 0, NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART);
_ui.bendStartHorizontalSlider->setValue(int(bendStar * _ui.bendStartHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART)); _ui.bendStartHorizontalSlider->setValue(int(bendStar * _ui.bendStartHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART));
float frequency = Modules::veget().getVegetableWindFrequency(); double frequency = Modules::veget().getVegetableWindFrequency();
NLMISC::clamp(frequency, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY); NLMISC::clamp(frequency, 0, NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY);
_ui.frequencyHorizontalSlider->setValue(int(frequency * _ui.frequencyHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY)); _ui.frequencyHorizontalSlider->setValue(int(frequency * _ui.frequencyHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY));

View file

@ -18,19 +18,21 @@
// Project includes // Project includes
#include "stdpch.h" #include "stdpch.h"
#include "vegetable_settings_page.h" #include "vegetable_settings_page.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h" #include "modules.h"
// Qt includes // Qt includes
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtCore/QSettings>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
// NeL includes
#include <nel/misc/config_file.h>
namespace NLQT namespace NLQT
{ {
QString LastDir = ".";
VegetableSettingsPage::VegetableSettingsPage(QObject *parent) VegetableSettingsPage::VegetableSettingsPage(QObject *parent)
: IOptionsPage(parent), : IOptionsPage(parent),
m_page(0) m_page(0)
@ -49,7 +51,7 @@ QString VegetableSettingsPage::trName() const
QString VegetableSettingsPage::category() const QString VegetableSettingsPage::category() const
{ {
return QLatin1String("ObjectViewer"); return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
} }
QString VegetableSettingsPage::trCategory() const QString VegetableSettingsPage::trCategory() const
@ -62,23 +64,21 @@ QWidget *VegetableSettingsPage::createPage(QWidget *parent)
m_page = new QWidget(parent); m_page = new QWidget(parent);
m_ui.setupUi(m_page); m_ui.setupUi(m_page);
m_ui.tileBankLineEdit->setText(Modules::config().getConfigFile().getVar("VegetTileBank").asString().c_str()); QSettings *settings = Core::ICore::instance()->settings();
m_ui.tileFarBankLineEdit->setText(Modules::config().getConfigFile().getVar("VegetTileFarBank").asString().c_str()); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
m_ui.vegetTextureLineEdit->setText(Modules::config().getConfigFile().getVar("VegetTexture").asString().c_str());
m_ui.zonesListWidget->clear(); m_ui.tileBankLineEdit->setText(settings->value(Constants::VEGET_TILE_BANK, "").toString());
m_ui.tileFarBankLineEdit->setText(settings->value(Constants::VEGET_TILE_FAR_BANK, "").toString());
m_ui.vegetTextureLineEdit->setText(settings->value(Constants::VEGET_TEXTURE, "").toString());
m_ui.coarseLineEdit->setText(settings->value(Constants::COARSE_MESH_TEXTURE, "").toString());
m_ui.zonesListWidget->addItems(settings->value(Constants::VEGET_LANDSCAPE_ZONES).toStringList());
// load vegetable landscape zone paths from config file settings->endGroup();
NLMISC::CConfigFile::CVar &var = Modules::config().getConfigFile().getVar("VegetLandscapeZones");
for (uint i = 0; i < var.size(); ++i)
{
m_ui.zonesListWidget->addItem(var.asString(i).c_str());
m_ui.zonesListWidget->item(i)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
}
connect(m_ui.tileBankToolButton, SIGNAL(clicked()), this, SLOT(setTileBank())); connect(m_ui.tileBankToolButton, SIGNAL(clicked()), this, SLOT(setTileBank()));
connect(m_ui.tileFarBankToolButton, SIGNAL(clicked()), this, SLOT(setTileFarBank())); connect(m_ui.tileFarBankToolButton, SIGNAL(clicked()), this, SLOT(setTileFarBank()));
connect(m_ui.vegetTexToolButton, SIGNAL(clicked()), this, SLOT(setTextureVegetable())); connect(m_ui.vegetTexToolButton, SIGNAL(clicked()), this, SLOT(setTextureVegetable()));
connect(m_ui.coarseToolButton, SIGNAL(clicked()), this, SLOT(setCoarseMeshTexture()));
connect(m_ui.addZoneToolButton, SIGNAL(clicked()), this, SLOT(addZone())); connect(m_ui.addZoneToolButton, SIGNAL(clicked()), this, SLOT(addZone()));
connect(m_ui.removeZoneToolButton, SIGNAL(clicked()), this, SLOT(removeZone())); connect(m_ui.removeZoneToolButton, SIGNAL(clicked()), this, SLOT(removeZone()));
@ -87,21 +87,22 @@ QWidget *VegetableSettingsPage::createPage(QWidget *parent)
void VegetableSettingsPage::apply() void VegetableSettingsPage::apply()
{ {
Modules::config().getConfigFile().getVar("VegetTileBank").setAsString(m_ui.tileBankLineEdit->text().toStdString()); QSettings *settings = Core::ICore::instance()->settings();
Modules::config().getConfigFile().getVar("VegetTileFarBank").setAsString(m_ui.tileFarBankLineEdit->text().toStdString()); settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("VegetTexture").setAsString(m_ui.vegetTextureLineEdit->text().toStdString());
std::vector<std::string> list; settings->setValue(Constants::VEGET_TILE_BANK, m_ui.tileBankLineEdit->text());
settings->setValue(Constants::VEGET_TILE_FAR_BANK, m_ui.tileFarBankLineEdit->text());
settings->setValue(Constants::COARSE_MESH_TEXTURE, m_ui.coarseLineEdit->text());
settings->setValue(Constants::VEGET_TEXTURE, m_ui.vegetTextureLineEdit->text());
QStringList list;
for (sint i = 0; i < m_ui.zonesListWidget->count(); ++i) for (sint i = 0; i < m_ui.zonesListWidget->count(); ++i)
{ list.push_back(m_ui.zonesListWidget->item(i)->text());
std::string str = m_ui.zonesListWidget->item(i)->text().toStdString();
list.push_back(str);
}
Modules::config().getConfigFile().getVar("VegetLandscapeZones").Type = NLMISC::CConfigFile::CVar::T_STRING; settings->setValue(Constants::VEGET_LANDSCAPE_ZONES, list);
Modules::config().getConfigFile().getVar("VegetLandscapeZones").setAsString(list);
Modules::config().getConfigFile().save(); settings->endGroup();
settings->sync();
} }
void VegetableSettingsPage::finish() void VegetableSettingsPage::finish()
@ -141,10 +142,21 @@ void VegetableSettingsPage::setTextureVegetable()
} }
} }
void VegetableSettingsPage::setCoarseMeshTexture()
{
QString fileName = QFileDialog::getOpenFileName(0, tr("Set Coarse Mesh texture"),
m_ui.vegetTextureLineEdit->text(),
tr("Texture file (*.tga *.png *.jpg *.dds);;"));
if (!fileName.isEmpty())
{
m_ui.coarseLineEdit->setText(fileName);
}
}
void VegetableSettingsPage::addZone() void VegetableSettingsPage::addZone()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames(0, QStringList fileNames = QFileDialog::getOpenFileNames(0,
tr("Add zone files"), ".", tr("Add zone files"), LastDir,
tr("Zonel files (*.zonel *.zone);;")); tr("Zonel files (*.zonel *.zone);;"));
if (!fileNames.isEmpty()) if (!fileNames.isEmpty())

View file

@ -48,10 +48,11 @@ public:
virtual void apply(); virtual void apply();
virtual void finish(); virtual void finish();
public Q_SLOTS: private Q_SLOTS:
void setTileBank(); void setTileBank();
void setTileFarBank(); void setTileFarBank();
void setTextureVegetable(); void setTextureVegetable();
void setCoarseMeshTexture();
void addZone(); void addZone();
void removeZone(); void removeZone();

View file

@ -95,7 +95,7 @@
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Coarse mesh texture</string> <string>Coarse mesh texture</string>
@ -105,14 +105,14 @@
<item row="3" column="1" colspan="2"> <item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="coarseLineEdit"> <widget class="QLineEdit" name="coarseLineEdit">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="3"> <item row="3" column="3">
<widget class="QToolButton" name="coarseToolButton"> <widget class="QToolButton" name="coarseToolButton">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>...</string> <string>...</string>