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 eaf5f1179b
commit 0faea26198
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;
/**
@\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.
@details This method should be used to disconnect from other plugins,
@ -80,7 +80,7 @@ public:
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.
@code
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 *result = 0;
if (_menuMap.count(id) == 0)
if (!_menuMap.contains(id))
nlwarning("QMenu %s not found", id.toStdString().c_str());
else
result = _menuMap.value(id);
@ -64,7 +64,7 @@ QMenu *MenuManager::menu(const QString &id) const
QAction *MenuManager::action(const QString &id) const
{
QAction *result = 0;
if (_actionMap.count(id) == 0)
if (!_actionMap.contains(id))
nlwarning("QAction %s not found", id.toStdString().c_str());
else
result = _actionMap.value(id);

View file

@ -31,6 +31,8 @@
namespace Core
{
QString lastDir = ".";
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent)
: IOptionsPage(parent),
m_page(0)
@ -104,13 +106,14 @@ void CSearchPathsSettingsPage::applySearchPaths()
void CSearchPathsSettingsPage::addPath()
{
QString newPath = QFileDialog::getExistingDirectory(m_page);
QString newPath = QFileDialog::getExistingDirectory(m_page, "", lastDir);
if (!newPath.isEmpty())
{
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setText(newPath);
newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
m_ui.pathsListWidget->addItem(newItem);
lastDir = newPath;
}
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(!_Skeleton.empty())
{
_Skeleton.setTransformMode(NL3D::UTransformable::RotQuat);
// scale animated pos value with the CFG scale
pos *= _CharacterScalePos;
_Skeleton.setPos(pos);
@ -398,6 +399,7 @@ void CEntity::animatePlayList(NL3D::TAnimationTime time)
}
else
{
_Instance.setTransformMode(NL3D::UTransformable::RotQuat);
_Instance.setPos(pos);
_Instance.setRotQuat(current.getRot());
}

View file

@ -18,9 +18,12 @@
// Project includes
#include "stdpch.h"
#include "graphics_settings_page.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h"
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QStyleFactory>
#include <QtGui/QStyle>
@ -49,7 +52,7 @@ QString GraphicsSettingsPage::trName() const
QString GraphicsSettingsPage::category() const
{
return QLatin1String("ObjectViewer");
return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
}
QString GraphicsSettingsPage::trCategory() const
@ -62,13 +65,22 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
Modules::config().setAndCallback("GraphicsDrivers", CConfigCallback(this, &GraphicsSettingsPage::cfcbGraphicsDrivers));
m_ui.enableBloomCheckBox->setChecked(Modules::objView().getBloomEffect());
QSettings *settings = Core::ICore::instance()->settings();
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.bloomDensityHorizontalSlider->setValue(NL3D::CBloomEffect::instance().getDensityBloom());
m_ui.styleComboBox->addItems(QStyleFactory::keys());
m_ui.styleComboBox->setCurrentIndex(m_ui.styleComboBox->findText(Modules::config().getValue("QtStyle", std::string("")).c_str()));
m_ui.paletteCheckBox->setChecked(Modules::config().getValue("QtPalette", false));
QString style = settings->value(Constants::QT_STYLE, "").toString();
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.squareBloomCheckBox, SIGNAL(toggled(bool)), this, SLOT(setEnableSquareBloon(bool)));
@ -82,16 +94,19 @@ QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
void GraphicsSettingsPage::apply()
{
// save graphics settings to config file
Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString(m_ui.driverGraphComboBox->currentText().toStdString());
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("BloomEffect").setAsInt(m_ui.enableBloomCheckBox->isChecked());
Modules::config().getConfigFile().getVar("BloomSquare").setAsInt(m_ui.squareBloomCheckBox->isChecked());
Modules::config().getConfigFile().getVar("BloomDensity").setAsInt(m_ui.bloomDensityHorizontalSlider->value());
settings->setValue(Constants::GRAPHICS_DRIVER, m_ui.driverGraphComboBox->currentText());
Modules::config().getConfigFile().getVar("QtStyle").setAsString(m_ui.styleComboBox->currentText().toStdString());
Modules::config().getConfigFile().getVar("QtPalette").setAsInt(m_ui.paletteCheckBox->isChecked());
// save settings
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()));
if (m_ui.paletteCheckBox->isChecked())
@ -99,12 +114,12 @@ void GraphicsSettingsPage::apply()
else
QApplication::setPalette(Modules::mainWin().getOriginalPalette());
// save config file
Modules::config().getConfigFile().save();
settings->endGroup();
settings->sync();
}
void GraphicsSettingsPage::finish()
{
Modules::config().dropCallback("GraphicsDrivers");
}
void GraphicsSettingsPage::setEnableBloom(bool state)
@ -122,26 +137,4 @@ void GraphicsSettingsPage::setDensityBloom(int 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 */

View file

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

View file

@ -6,129 +6,21 @@
<rect>
<x>0</x>
<y>0</y>
<width>540</width>
<height>326</height>
<width>274</width>
<height>277</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</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">
<number>3</number>
</property>
<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>
<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">
<item row="0" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Bloom effect</string>
@ -172,6 +64,142 @@
</layout>
</widget>
</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>
</widget>
<resources>

View file

@ -49,6 +49,7 @@
#include "tune_mrm_dialog.h"
#include "tune_timer_dialog.h"
#include "camera_control.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "../core/imenu_manager.h"
@ -79,11 +80,18 @@ CMainWindow::CMainWindow(QWidget *parent)
setDockNestingEnabled(true);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// setup Qt style and palette from config file
_originalPalette = QApplication::palette();
Modules::config().setAndCallback("QtStyle", CConfigCallback(this, &CMainWindow::cfcbQtStyle));
Modules::config().setAndCallback("QtPalette", CConfigCallback(this, &CMainWindow::cfcbQtPalette));
Modules::config().setAndCallback("SoundEnabled", CConfigCallback(this, &CMainWindow::cfcbSoundEnabled));
QApplication::setStyle(QStyleFactory::create(settings->value(Constants::QT_STYLE, "").toString()));
if (settings->value(Constants::QT_PALETTE, true).toBool())
QApplication::setPalette(QApplication::style()->standardPalette());
else
QApplication::setPalette(_originalPalette);
_GraphicsViewport->init();
_isGraphicsInitialized = true;
@ -103,18 +111,16 @@ CMainWindow::CMainWindow(QWidget *parent)
setWindowIcon(QIcon(":/images/nel.png"));
QSettings settings("object_viewer_qt.ini", QSettings::IniFormat);
settings.beginGroup("WindowSettings");
restoreState(settings.value("QtWindowState").toByteArray());
restoreGeometry(settings.value("QtWindowGeometry").toByteArray());
settings.endGroup();
restoreState(settings->value("QtWindowState").toByteArray());
restoreGeometry(settings->value("QtWindowGeometry").toByteArray());
// 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.
_mainTimer = new QTimer(this);
connect(_mainTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
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);
connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
@ -129,16 +135,13 @@ CMainWindow::~CMainWindow()
nldebug("CMainWindow::~CMainWindow:");
// save state & geometry of window and widgets
QSettings settings("object_viewer_qt.ini", QSettings::IniFormat);
settings.beginGroup("WindowSettings");
settings.setValue("QtWindowState", saveState());
settings.setValue("QtWindowGeometry", saveGeometry());
settings.endGroup();
settings.setValue("TimerInterval", _mainTimer->interval());
Modules::config().dropCallback("SoundEnabled");
Modules::config().dropCallback("QtPalette");
Modules::config().dropCallback("QtStyle");
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
settings->setValue("QtWindowState", saveState());
settings->setValue("QtWindowGeometry", saveGeometry());
settings->setValue("TimerInterval", _mainTimer->interval());
settings->endGroup();
settings->sync();
delete _AnimationDialog;
delete _AnimationSetDialog;

View file

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

View file

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

View file

@ -16,11 +16,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Project includes
#include "modules.h"
#include "stdpch.h"
#include "object_viewer.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
// STL includes
// Qt includes
#include <QtCore/QSettings>
// NeL includes
#include <nel/misc/debug.h>
@ -45,14 +49,6 @@
#include <nel/3d/scene_user.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
{
@ -66,11 +62,12 @@ CObjectViewer::CObjectViewer()
_CurrentInstance(""),
_BloomEffect(false)
{
loadConfig();
}
CObjectViewer::~CObjectViewer()
{
saveConfig();
}
void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
@ -78,12 +75,10 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
//H_AUTO2
nldebug("CObjectViewert::init");
loadConfig();
// create the driver
nlassert(!_Driver);
_Driver = UDriver::createDriver(0, _Direct3D, 0);
_Driver = NL3D::UDriver::createDriver(0, _Direct3D, 0);
nlassert(_Driver);
// initialize the window with config file values
@ -95,16 +90,16 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
_Driver->enableUsedTextureMemorySum();
_Light = ULight::createLight();
_Light = NL3D::ULight::createLight();
// set mode of the light
_Light->setMode(ULight::DirectionalLight);
_Light->setMode(NL3D::ULight::DirectionalLight);
// 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
_Light->setAmbiant(CRGBA(255, 255, 255));
_Light->setAmbiant(NLMISC::CRGBA(255, 255, 255));
// set and enable the 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);
_MouseListener = _Driver->create3dMouseListener();
_MouseListener->setMouseMode(U3dMouseListener::edit3d);
_MouseListener->setMouseMode(NL3D::U3dMouseListener::edit3d);
// set the cache size for the font manager(in bytes)
_Driver->setFontManagerMaxMemory(2097152);
@ -130,8 +125,8 @@ void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
NL3D::CBloomEffect::instance().setDriver(_Driver);
NL3D::CBloomEffect::instance().setScene(_Scene);
NL3D::CBloomEffect::instance().init(!_Direct3D);
NL3D::CBloomEffect::instance().setDensityBloom(Modules::config().getConfigFile().getVar("BloomDensity").asInt());
NL3D::CBloomEffect::instance().setSquareBloom(Modules::config().getConfigFile().getVar("BloomSquare").asBool());
NL3D::CBloomEffect::instance().setDensityBloom(uint8(_BloomDensity));
NL3D::CBloomEffect::instance().setSquareBloom(_BloomSquare);
NL3D::CDriverUser *driver = dynamic_cast<NL3D::CDriverUser *>(Modules::objView().getDriver());
_IDriver = driver->getDriver();
@ -145,8 +140,6 @@ void CObjectViewer::release()
//H_AUTO2
nldebug("CObjectViewer::release");
saveConfig();
// release text context
nlassert(_TextContext);
_Driver->deleteTextContext(_TextContext);
@ -232,7 +225,7 @@ void CObjectViewer::reloadTextures()
int tex;
for (tex = 0; tex < NL3D::IDRV_MAT_MAXTEXTURES; tex++)
{
ITexture *texture = material->getTexture(tex);
NL3D::ITexture *texture = material->getTexture(tex);
// Touch it!
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!
// empty bitmap
CBitmap bitmap;
NLMISC::CBitmap bitmap;
// copy the driver buffer to the bitmap
_Driver->getBuffer(bitmap);
// 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
if (jpg)
{
string newfilename = CFile::findNewFile(filename + ".jpg");
COFile outputFile(newfilename);
std::string newfilename = NLMISC::CFile::findNewFile(filename + ".jpg");
NLMISC::COFile outputFile(newfilename);
bitmap.writeJPG(outputFile, 100);
nlinfo("Screenshot '%s' saved", newfilename.c_str());
}
if (png)
{
string newfilename = CFile::findNewFile(filename + ".png");
COFile outputFile(newfilename);
std::string newfilename = NLMISC::CFile::findNewFile(filename + ".png");
NLMISC::COFile outputFile(newfilename);
bitmap.writePNG(outputFile, 24);
nlinfo("Screenshot '%s' saved", newfilename.c_str());
}
if (tga)
{
string newfilename = CFile::findNewFile(filename + ".tga");
COFile outputFile(newfilename);
std::string newfilename = NLMISC::CFile::findNewFile(filename + ".tga");
NLMISC::COFile outputFile(newfilename);
bitmap.writeTGA(outputFile, 24, false);
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)
{
std::string fileName = CFile::getFilenameWithoutExtension(meshFileName);
std::string fileName = NLMISC::CFile::getFilenameWithoutExtension(meshFileName);
if (_Entities.count(fileName) != 0)
return false;
CPath::addSearchPath(CFile::getPath(meshFileName), false, false);
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(meshFileName), false, false);
// 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 (Entity.empty()) return false;
CAABBox bbox;
NLMISC::CAABBox bbox;
Entity.getShapeAABBox(bbox);
setCamera(bbox , Entity, true);
_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;
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)
{
CPath::addSearchPath (CFile::getPath(igName));
UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(igName);
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(igName));
NL3D::UInstanceGroup *ig = NL3D::UInstanceGroup::createInstanceGroup(igName);
if (ig == 0)
return false;
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)
{
CVector pos(0.f, 0.f, 0.f);
CQuat quat(0.f, 0.f, 0.f, 0.f);
NLMISC::CVector pos(0.f, 0.f, 0.f);
NLMISC::CQuat quat(0.f, 0.f, 0.f, 0.f);
NL3D::UInstance inst;
inst.cast(entity);
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)
entity.setScale(1.f, 1.f, 1.f);
UCamera Camera = _Scene->getCam();
CVector max_radius = bbox.getHalfSize();
CVector center = bbox.getCenter();
NL3D::UCamera Camera = _Scene->getCam();
NLMISC::CVector max_radius = bbox.getHalfSize();
NLMISC::CVector center = bbox.getCenter();
entity.setPivot(center);
center += pos;
float fov = float(_CameraFocal * (float)Pi/180.0);
float radius = max(max(max_radius.x, max_radius.y), max_radius.z);
float fov = float(_CameraFocal * (float)NLMISC::Pi/180.0);
float radius = std::max(std::max(max_radius.x, max_radius.y), max_radius.z);
if (radius == 0.f) radius = 1.f;
float left, right, bottom, top, znear, zfar;
Camera.getFrustum(left, right, bottom, top, znear, zfar);
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);
@ -423,24 +416,16 @@ void CObjectViewer::updateAnimation(NL3D::TAnimationTime time)
void CObjectViewer::setBackgroundColor(NLMISC::CRGBA 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)
{
_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)
{
_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)
@ -466,26 +451,41 @@ void CObjectViewer::getListObjects(std::vector<std::string> &listObj)
void CObjectViewer::loadConfig()
{
// set background color from config
Modules::config().setAndCallback("BackgroundColor", CConfigCallback(this, &CObjectViewer::cfcbBackgroundColor));
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// set graphics driver from config
Modules::config().setAndCallback("GraphicsDriver",CConfigCallback(this,&CObjectViewer::cfcbGraphicsDriver));
QColor color;
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()
{
Modules::config().dropCallback("BackgroundColor");
Modules::config().dropCallback("GraphicsDriver");
Modules::config().dropCallback("CameraFocal");
Modules::config().dropCallback("FontName");
Modules::config().dropCallback("BloomEffect");
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
QColor color(_BackgroundColor.R, _BackgroundColor.G, _BackgroundColor.B, _BackgroundColor.A);
settings->setValue("BackgroundColor", color);
settings->endGroup();
settings->sync();
}
void CObjectViewer::deleteEntities()
@ -500,38 +500,4 @@ void CObjectViewer::deleteEntities()
_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 */

View file

@ -27,7 +27,6 @@
#include <map>
// NeL includes
#include <nel/misc/config_file.h>
#include <nel/misc/rgba.h>
#include <nel/3d/event_mouse_listener.h>
@ -231,13 +230,6 @@ private:
// Delete all entities
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;
NL3D::IDriver *_IDriver;
NL3D::CScene *_CScene;
@ -260,6 +252,8 @@ private:
bool _Direct3D;
bool _BloomEffect;
int _BloomDensity;
bool _BloomSquare;
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);
_autoReleaseObjects.clear();
Modules::release();
//Modules::release();
}
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)
{
#ifdef NL_OS_WINDOWS

View file

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

View file

@ -17,23 +17,22 @@
*/
// Project includes
#include "stdpch.h"
#include "setup_fog_dialog.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h"
// Qt includes
#include <QtGui/QWidget>
#include <QtGui/QColorDialog>
#include <QtCore/QSettings>
// NeL includes
#include <nel/misc/path.h>
#include <nel/3d/u_driver.h>
// Project includes
#include "modules.h"
using namespace NL3D;
using namespace NLMISC;
namespace NLQT
{
@ -42,10 +41,17 @@ CSetupFog::CSetupFog(QWidget *parent)
{
ui.setupUi(this);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// load fog value from config file
ui.startDoubleSpinBox->setValue(Modules::config().getValue("FogStart", 0.0));
ui.endDoubleSpinBox->setValue(Modules::config().getValue("FogEnd", 0.0));
colorFog = Modules::config().getValue("FogColor",CRGBA(0.0, 0.0, 0.0));
ui.startDoubleSpinBox->setValue(settings->value("FogStart", 0.0).toDouble());
ui.endDoubleSpinBox->setValue(settings->value("FogEnd", 0.0).toDouble());
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.colorPushButton, SIGNAL(clicked()), this, SLOT(setColor()));
@ -53,13 +59,17 @@ CSetupFog::CSetupFog(QWidget *parent)
CSetupFog::~CSetupFog()
{
// save fog value from config file
Modules::config().getConfigFile().getVar("FogStart").setAsFloat(ui.startDoubleSpinBox->value());
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);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
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()

View file

@ -18,11 +18,14 @@
// Project includes
#include "stdpch.h"
#include "sound_settings_page.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h"
// Qt includes
#include <QtCore/QSettings>
#include <QtGui/QWidget>
#include <QtGui/QFileDialog>
namespace NLQT
{
@ -45,7 +48,7 @@ QString SoundSettingsPage::trName() const
QString SoundSettingsPage::category() const
{
return QLatin1String("ObjectViewer");
return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
}
QString SoundSettingsPage::trCategory() const
@ -58,61 +61,69 @@ QWidget *SoundSettingsPage::createPage(QWidget *parent)
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
// setup config file callbacks and initialize values
Modules::config().setAndCallback("SoundDrivers", CConfigCallback(this, &SoundSettingsPage::cfcbSoundDrivers));
QSettings *settings = Core::ICore::instance()->settings();
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
m_ui.autoLoadSampleCheckBox->setChecked(Modules::config().getValue("SoundAutoLoadSample", true));
m_ui.enableOccludeObstructCheckBox->setChecked(Modules::config().getValue("SoundEnableOccludeObstruct", true));
m_ui.enableReverbCheckBox->setChecked(Modules::config().getValue("SoundEnableReverb", true));
m_ui.manualRolloffCheckBox->setChecked(Modules::config().getValue("SoundManualRolloff", true));
m_ui.forceSoftwareCheckBox->setChecked(Modules::config().getValue("SoundForceSoftware", false));
m_ui.useADPCMCheckBox->setChecked(Modules::config().getValue("SoundUseADPCM", false));
m_ui.maxTrackSpinBox->setValue(Modules::config().getValue("SoundMaxTrack", 48));
m_ui.autoLoadSampleCheckBox->setChecked(settings->value(Constants::SOUND_AUTO_LOAD_SAMPLE, true).toBool());
m_ui.enableOccludeObstructCheckBox->setChecked(settings->value(Constants::SOUND_ENABLE_OCCLUDE_OBSTRUCT, true).toBool());
m_ui.enableReverbCheckBox->setChecked(settings->value(Constants::SOUND_ENABLE_REVERB, true).toBool());
m_ui.manualRolloffCheckBox->setChecked(settings->value(Constants::SOUND_MANUAL_ROLL_OFF, true).toBool());
m_ui.forceSoftwareCheckBox->setChecked(settings->value(Constants::SOUND_FORCE_SOFTWARE, false).toBool());
m_ui.useADPCMCheckBox->setChecked(settings->value(Constants::SOUND_USE_ADCPM, false).toBool());
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;
}
void SoundSettingsPage::apply()
{
// save sound settings to config file
Modules::config().getConfigFile().getVar("SoundDriver").setAsString(m_ui.driverSndComboBox->currentText().toStdString());
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());
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// save config file
Modules::config().getConfigFile().save();
settings->setValue(Constants::SOUND_DRIVER, m_ui.driverSndComboBox->currentText());
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()
{
Modules::config().dropCallback("SoundDrivers");
}
void SoundSettingsPage::cfcbSoundDrivers(NLMISC::CConfigFile::CVar& var)
void SoundSettingsPage::setSheetPath()
{
while (m_ui.driverSndComboBox->count())
m_ui.driverSndComboBox->removeItem(0);
// 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)
QString path = QFileDialog::getExistingDirectory();
if (!path.isEmpty())
{
if (dn == m_ui.driverSndComboBox->itemText(i).toLower())
{
m_ui.driverSndComboBox->setCurrentIndex(i);
return;
m_ui.soundSheetPathLineEdit->setText(path);
}
}
void SoundSettingsPage::setSamplePath()
{
QString path = QFileDialog::getExistingDirectory();
if (!path.isEmpty())
{
m_ui.soundSamplePathLineEdit->setText(path);
}
}

View file

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

View file

@ -6,21 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>326</width>
<height>268</height>
<width>331</width>
<height>278</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="0">
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="driverSndLabel">
@ -50,53 +44,78 @@
<verstretch>0</verstretch>
</sizepolicy>
</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>
</item>
</layout>
</item>
<item row="1" column="0">
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="autoLoadSampleCheckBox">
<property name="text">
<string>SoundAutoLoadSample</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="enableOccludeObstructCheckBox">
<property name="text">
<string>SoundEnableOccludeObstruct</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="enableReverbCheckBox">
<property name="text">
<string>SoundEnableReverb</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="manualRolloffCheckBox">
<property name="text">
<string>SoundManualRolloff</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="forceSoftwareCheckBox">
<property name="text">
<string>SoundForceSoftware</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="useADPCMCheckBox">
<property name="text">
<string>SoundUseADPCM</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="7" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="maxTrackLabel">
@ -140,6 +159,40 @@
</layout>
</item>
<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">
<property name="orientation">
<enum>Qt::Vertical</enum>

View file

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

View file

@ -17,12 +17,19 @@
*/
// Project includes
#include "stdpch.h"
#include "vegetable_editor.h"
#include "modules.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
// Qt includes
#include <QtGui/QProgressDialog>
#include <QtGui/QMessageBox>
#include <QtGui/QColor>
#include <QtGui/QVector3D>
#include <QtCore/QSettings>
// NeL includes
#include <nel/3d/landscape_model.h>
@ -31,12 +38,8 @@
#include <nel/3d/driver.h>
#include <nel/3d/scene_user.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_landscape.h>
namespace NLQT
{
@ -258,7 +261,7 @@ bool CVegetableEditor::createVegetableLandscape()
return false;
}
}
Modules::objView().getScene()->setCoarseMeshManagerTexture(_CoarseMeshTexture.c_str());
return true;
}
@ -311,7 +314,7 @@ void CVegetableEditor::refreshVegetableLandscape(const NL3D::CTileVegetableDesc
}
}
void CVegetableEditor::setVegetableWindPower(float w)
void CVegetableEditor::setVegetableWindPower(double w)
{
_VegetableWindPower= w;
if(_VegetableLandscape)
@ -321,7 +324,7 @@ void CVegetableEditor::setVegetableWindPower(float w)
_VegetableWindBendMin);
}
void CVegetableEditor::setVegetableWindBendStart(float w)
void CVegetableEditor::setVegetableWindBendStart(double w)
{
_VegetableWindBendMin= w;
if(_VegetableLandscape)
@ -331,7 +334,7 @@ void CVegetableEditor::setVegetableWindBendStart(float w)
_VegetableWindBendMin);
}
void CVegetableEditor::setVegetableWindFrequency(float w)
void CVegetableEditor::setVegetableWindFrequency(double w)
{
_VegetableWindFreq= w;
if(_VegetableLandscape)
@ -540,222 +543,94 @@ void CVegetableEditor::loadConfig()
_VegetableSnapToGround = false;
// 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.
// --------------
// vegetable ambient
try
{
NLMISC::CConfigFile::CVar &color = Modules::config().getConfigFile().getVar("VegetAmbient");
_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");
color = settings->value("VegetAmbient", QColor(80, 80, 80)).value<QColor>();
_VegetableAmbient = NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha());
color = settings->value("VegetDiffuse", QColor(80, 80, 80)).value<QColor>();
// 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);
_VegetableDiffuse.R = R;
sint G = color.asInt(1) - _VegetableAmbient.G;
sint G = color.green() - _VegetableAmbient.G;
NLMISC::clamp(G, 0, 255);
_VegetableDiffuse.G = G;
sint B = color.asInt(2) - _VegetableAmbient.B;
sint B = color.blue() - _VegetableAmbient.B;
NLMISC::clamp(B, 0, 255);
_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
try
{
NLMISC::CConfigFile::CVar &var = Modules::config().getConfigFile().getVar("VegetWindDir");
_VegetableWindDir.x = var.asFloat(0);
_VegetableWindDir.y = var.asFloat(1);
_VegetableWindDir.z = var.asFloat(2);
}
catch (NLMISC::EUnknownVar &)
{
_VegetableWindDir.x = 0.5f;
_VegetableWindDir.y = 0.5f;
_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;
}
QVector3D vec;
vec = settings->value("VegetLightDir", QVector3D(0, 1, -1)).value<QVector3D>();
_VegetableLightDir = NLMISC::CVector(vec.x(), vec.y(), vec.z());
_VegetableLightDir.normalize();
vec = settings->value("VegetWindDir", QVector3D(0.5f, 0.5f, 0)).value<QVector3D>();
_VegetableWindDir = NLMISC::CVector(vec.x(), vec.y(), vec.z());
_VegetableWindFreq = settings->value("VegetWindFreq", 0.5).toDouble();
_VegetableWindPower = settings->value("VegetWindPower", 1).toDouble();
_VegetableWindBendMin = settings->value("VegetWindBendMin", 0).toDouble();
settings->endGroup();
}
void CVegetableEditor::loadLandscapeSetup()
{
// Load landscape setup
// --------------
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();
}
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
// 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
try
{
_VegetableTexture = Modules::config().getConfigFile().getVar("VegetTexture").asString();
}
catch (NLMISC::EUnknownVar &)
{
_VegetableTexture= "";
}
QStringList list = settings->value(Constants::VEGET_LANDSCAPE_ZONES).toStringList();
_VegetableLandscapeZoneNames.clear();
for (int i = 0; i < list.size(); ++i)
_VegetableLandscapeZoneNames.push_back(list[i].toStdString());
settings->endGroup();
}
void CVegetableEditor::saveConfig()
{
Modules::config().getConfigFile().getVar("VegetLandscapeThreshold").setAsFloat(_VegetableLandscapeThreshold);
Modules::config().getConfigFile().getVar("VegetLandscapeTileNear").setAsFloat(_VegetableLandscapeTileNear);
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.R, 0);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.G, 1);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.B, 2);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.A, 3);
settings->setValue("VegetLandscapeThreshold", _VegetableLandscapeThreshold);
settings->setValue("VegetLandscapeTileNear", _VegetableLandscapeTileNear);
Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse").setAsInt(_VegetableLandscapeDiffuse.R, 0);
Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse").setAsInt(_VegetableLandscapeDiffuse.G, 1);
Modules::config().getConfigFile().getVar("VegetLandscapeDiffuse").setAsInt(_VegetableLandscapeDiffuse.B, 2);
Modules::config().getConfigFile().getVar("VegetLandscapeAmbient").setAsInt(_VegetableLandscapeAmbient.A, 3);
QColor vAmbColor(_VegetableLandscapeAmbient.R, _VegetableLandscapeAmbient.G, _VegetableLandscapeAmbient.B, _VegetableLandscapeAmbient.A);
settings->setValue("VegetLandscapeAmbient", vAmbColor);
Modules::config().getConfigFile().getVar("VegetWindDir").setAsFloat(_VegetableWindDir.x, 0);
Modules::config().getConfigFile().getVar("VegetWindDir").setAsFloat(_VegetableWindDir.y, 1);
Modules::config().getConfigFile().getVar("VegetWindDir").setAsFloat(_VegetableWindDir.z, 2);
QColor vDifColor(_VegetableLandscapeDiffuse.R, _VegetableLandscapeDiffuse.G, _VegetableLandscapeDiffuse.B, _VegetableLandscapeDiffuse.A);
settings->setValue("VegetLandscapeDiffuse", vDifColor);
Modules::config().getConfigFile().getVar("VegetWindPower").setAsFloat(_VegetableWindPower);
Modules::config().getConfigFile().getVar("VegetWindFreq").setAsFloat(_VegetableWindFreq);
Modules::config().getConfigFile().getVar("VegetWindBendMin").setAsFloat(_VegetableWindBendMin);
QVector3D vec(_VegetableWindDir.x, _VegetableWindDir.y, _VegetableWindDir.z);
settings->setValue("VegetWindDir", vec);
settings->setValue("VegetWindPower", _VegetableWindPower);
settings->setValue("VegetWindFreq", _VegetableWindFreq);
settings->setValue("VegetWindBendMin", _VegetableWindBendMin);
settings->endGroup();
settings->sync();
}
} /* namespace NLQT */

View file

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

View file

@ -23,9 +23,9 @@
// Project includes
#include "modules.h"
#define NL_VEGETABLE_EDIT_WIND_MAX_POWER 10.f
#define NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY 10.f
#define NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART 1.f
#define NL_VEGETABLE_EDIT_WIND_MAX_POWER 10.0
#define NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY 10.0
#define NL_VEGETABLE_EDIT_WIND_MAX_BENDSTART 1.0
namespace NLQT
{
@ -43,15 +43,15 @@ CVegetableLandscapePage::CVegetableLandscapePage(QWidget *parent)
connect(_ui.diffuseColorWidget, SIGNAL(colorChanged(NLMISC::CRGBA)), this, SLOT(setColorDiffuse(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);
_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);
_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);
_ui.frequencyHorizontalSlider->setValue(int(frequency * _ui.frequencyHorizontalSlider->maximum() / NL_VEGETABLE_EDIT_WIND_MAX_FREQUENCY));

View file

@ -18,19 +18,21 @@
// Project includes
#include "stdpch.h"
#include "vegetable_settings_page.h"
#include "object_viewer_constants.h"
#include "../core/icore.h"
#include "modules.h"
// Qt includes
#include <QtGui/QWidget>
#include <QtCore/QSettings>
#include <QtGui/QMessageBox>
#include <QtGui/QFileDialog>
// NeL includes
#include <nel/misc/config_file.h>
namespace NLQT
{
QString LastDir = ".";
VegetableSettingsPage::VegetableSettingsPage(QObject *parent)
: IOptionsPage(parent),
m_page(0)
@ -49,7 +51,7 @@ QString VegetableSettingsPage::trName() const
QString VegetableSettingsPage::category() const
{
return QLatin1String("ObjectViewer");
return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
}
QString VegetableSettingsPage::trCategory() const
@ -62,23 +64,21 @@ QWidget *VegetableSettingsPage::createPage(QWidget *parent)
m_page = new QWidget(parent);
m_ui.setupUi(m_page);
m_ui.tileBankLineEdit->setText(Modules::config().getConfigFile().getVar("VegetTileBank").asString().c_str());
m_ui.tileFarBankLineEdit->setText(Modules::config().getConfigFile().getVar("VegetTileFarBank").asString().c_str());
m_ui.vegetTextureLineEdit->setText(Modules::config().getConfigFile().getVar("VegetTexture").asString().c_str());
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
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
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);
}
settings->endGroup();
connect(m_ui.tileBankToolButton, SIGNAL(clicked()), this, SLOT(setTileBank()));
connect(m_ui.tileFarBankToolButton, SIGNAL(clicked()), this, SLOT(setTileFarBank()));
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.removeZoneToolButton, SIGNAL(clicked()), this, SLOT(removeZone()));
@ -87,21 +87,22 @@ QWidget *VegetableSettingsPage::createPage(QWidget *parent)
void VegetableSettingsPage::apply()
{
Modules::config().getConfigFile().getVar("VegetTileBank").setAsString(m_ui.tileBankLineEdit->text().toStdString());
Modules::config().getConfigFile().getVar("VegetTileFarBank").setAsString(m_ui.tileFarBankLineEdit->text().toStdString());
Modules::config().getConfigFile().getVar("VegetTexture").setAsString(m_ui.vegetTextureLineEdit->text().toStdString());
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
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)
{
std::string str = m_ui.zonesListWidget->item(i)->text().toStdString();
list.push_back(str);
}
list.push_back(m_ui.zonesListWidget->item(i)->text());
Modules::config().getConfigFile().getVar("VegetLandscapeZones").Type = NLMISC::CConfigFile::CVar::T_STRING;
Modules::config().getConfigFile().getVar("VegetLandscapeZones").setAsString(list);
settings->setValue(Constants::VEGET_LANDSCAPE_ZONES, list);
Modules::config().getConfigFile().save();
settings->endGroup();
settings->sync();
}
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()
{
QStringList fileNames = QFileDialog::getOpenFileNames(0,
tr("Add zone files"), ".",
tr("Add zone files"), LastDir,
tr("Zonel files (*.zonel *.zone);;"));
if (!fileNames.isEmpty())

View file

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

View file

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