Merge with develop

This commit is contained in:
kervala 2016-03-19 19:30:06 +01:00
parent 5670c0cd2b
commit 5109ae5443
8 changed files with 167 additions and 152 deletions

View file

@ -64,7 +64,7 @@ namespace NLGUI
uint getTextPos(uint nId) const; uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const; const ucstring &getTexture(uint i) const;
void setGrayed(uint i, bool g); void setGrayed(uint i, bool g);
const bool getGrayed(uint i) const; bool getGrayed(uint i) const;
void removeText(uint nPos); void removeText(uint nPos);
uint getNumTexts() const {return (uint)_Texts.size();} uint getNumTexts() const {return (uint)_Texts.size();}
void sortText(); void sortText();

View file

@ -321,7 +321,7 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
const bool CDBGroupComboBox::getGrayed(uint i) const bool CDBGroupComboBox::getGrayed(uint i) const
{ {
if(i<_Grayed.size()) if(i<_Grayed.size())
return _Grayed[i]; return _Grayed[i];

View file

@ -786,7 +786,7 @@ CInterface3DCharacter::~CInterface3DCharacter()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CInterface3DCharacter::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) bool CInterface3DCharacter::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{ {
if (!CInterfaceElement::parse(cur, parentGroup)) if (!CInterfaceElement::parse(cur, parentGroup))
return false; return false;
@ -808,7 +808,7 @@ bool CInterface3DCharacter::parse (xmlNodePtr cur, CInterface3DScene *parentGrou
_Char3D = new CCharacter3D; _Char3D = new CCharacter3D;
_Char3D->copyAnimation(copyAnim); _Char3D->copyAnimation(copyAnim);
_Char3D->init (parentGroup->getScene()); _Char3D->init (dynamic_cast<CInterface3DScene*>(parentGroup)->getScene());
_Char3D->setPos (pos.x, pos.y, pos.z); _Char3D->setPos (pos.x, pos.y, pos.z);
_Char3D->setRotEuler ( rot.x * ((float)(NLMISC::Pi / 180)), _Char3D->setRotEuler ( rot.x * ((float)(NLMISC::Pi / 180)),
rot.y * ((float)(NLMISC::Pi / 180)), rot.y * ((float)(NLMISC::Pi / 180)),
@ -1073,7 +1073,7 @@ CInterface3DIG::~CInterface3DIG()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) bool CInterface3DIG::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{ {
if (!CInterfaceElement::parse(cur, parentGroup)) if (!CInterfaceElement::parse(cur, parentGroup))
return false; return false;
@ -1095,8 +1095,8 @@ bool CInterface3DIG::parse (xmlNodePtr cur, CInterface3DScene *parentGroup)
setRotX (_Rot.x); setRotX (_Rot.x);
setRotY (_Rot.y); setRotY (_Rot.y);
setRotZ (_Rot.z); setRotZ (_Rot.z);
_IG->addToScene (*parentGroup->getScene(), CViewRenderer::getInstance()->getDriver() ); _IG->addToScene (*dynamic_cast<CInterface3DScene*>(parentGroup)->getScene(), CViewRenderer::getInstance()->getDriver() );
parentGroup->getScene()->setToGlobalInstanceGroup (_IG); dynamic_cast<CInterface3DScene*>(parentGroup)->getScene()->setToGlobalInstanceGroup (_IG);
return true; return true;
} }
@ -1235,7 +1235,7 @@ CInterface3DShape::~CInterface3DShape()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CInterface3DShape::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) bool CInterface3DShape::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{ {
if (!CInterfaceElement::parse(cur, parentGroup)) if (!CInterfaceElement::parse(cur, parentGroup))
return false; return false;
@ -1249,7 +1249,7 @@ bool CInterface3DShape::parse (xmlNodePtr cur, CInterface3DScene *parentGroup)
ptr = xmlGetProp (cur, (xmlChar*)"name"); ptr = xmlGetProp (cur, (xmlChar*)"name");
if (ptr) _Name = toLower((const char*)ptr); if (ptr) _Name = toLower((const char*)ptr);
_Instance = parentGroup->getScene()->createInstance(_Name); _Instance = dynamic_cast<CInterface3DScene*>(parentGroup)->getScene()->createInstance(_Name);
if (_Instance.empty()) if (_Instance.empty())
return false; return false;
@ -1385,7 +1385,7 @@ void CInterface3DShape::setName (const std::string &ht)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CInterface3DCamera::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) bool CInterface3DCamera::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{ {
if (!CInterfaceElement::parse(cur, parentGroup)) if (!CInterfaceElement::parse(cur, parentGroup))
return false; return false;
@ -1422,12 +1422,12 @@ CInterface3DLight::~CInterface3DLight()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CInterface3DLight::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) bool CInterface3DLight::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{ {
if (!CInterfaceElement::parse(cur, parentGroup)) if (!CInterfaceElement::parse(cur, parentGroup))
return false; return false;
_Light = parentGroup->getScene()->createPointLight(); _Light = dynamic_cast<CInterface3DScene*>(parentGroup)->getScene()->createPointLight();
CXMLAutoPtr ptr((const char*)xmlGetProp (cur, (xmlChar*)"pos")); CXMLAutoPtr ptr((const char*)xmlGetProp (cur, (xmlChar*)"pos"));
if (ptr) _Pos = convertVector(ptr); if (ptr) _Pos = convertVector(ptr);
@ -1514,7 +1514,7 @@ CInterface3DFX::~CInterface3DFX()
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CInterface3DFX::parse (xmlNodePtr cur, CInterface3DScene *parentGroup) bool CInterface3DFX::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{ {
if (!CInterfaceElement::parse(cur, parentGroup)) if (!CInterfaceElement::parse(cur, parentGroup))
return false; return false;

View file

@ -148,7 +148,7 @@ public:
CInterface3DCharacter(); CInterface3DCharacter();
virtual ~CInterface3DCharacter(); virtual ~CInterface3DCharacter();
virtual bool parse (xmlNodePtr cur, CInterface3DScene *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void checkCoords(); virtual void checkCoords();
@ -236,7 +236,7 @@ public:
virtual ~CInterface3DShape(); virtual ~CInterface3DShape();
virtual bool parse (xmlNodePtr cur, CInterface3DScene *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
NL3D::UInstance getShape() { return _Instance; } NL3D::UInstance getShape() { return _Instance; }
@ -295,7 +295,7 @@ public:
virtual ~CInterface3DIG(); virtual ~CInterface3DIG();
virtual bool parse (xmlNodePtr cur, CInterface3DScene *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
NL3D::UInstanceGroup *getIG() { return _IG; } NL3D::UInstanceGroup *getIG() { return _IG; }
@ -357,7 +357,7 @@ public:
_Dist = 0; _Dist = 0;
} }
virtual bool parse (xmlNodePtr cur, CInterface3DScene *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
float getFOV() { return _FOV; } float getFOV() { return _FOV; }
NLMISC::CVector getPos() { return _Pos; } NLMISC::CVector getPos() { return _Pos; }
NLMISC::CVector getTarget() { return _Target; } NLMISC::CVector getTarget() { return _Target; }
@ -436,7 +436,7 @@ public:
virtual ~CInterface3DLight(); virtual ~CInterface3DLight();
virtual bool parse (xmlNodePtr cur, CInterface3DScene *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
float getPosX() const { return _Pos.x; } float getPosX() const { return _Pos.x; }
float getPosY() const { return _Pos.y; } float getPosY() const { return _Pos.y; }
@ -498,7 +498,7 @@ public:
virtual ~CInterface3DFX(); virtual ~CInterface3DFX();
virtual bool parse (xmlNodePtr cur, CInterface3DScene *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void checkCoords(); virtual void checkCoords();

View file

@ -38,16 +38,19 @@ void CDisplaySettingsDetailsWidget::load()
{ {
CSystem &s = CSystem::GetInstance(); CSystem &s = CSystem::GetInstance();
landscapeSlider->setValue( getQuality( qualityToLandscapeThreshold, s.config.getFloat( "LandscapeThreshold" ) ) ); // landscape
landscapeSlider->setValue( std::min( landscapeSlider->value(), getQuality( qualityToZFar, s.config.getFloat( "Vision" ) ) ) ); landscapeSlider->setValue(getQualityPresetFloat("LandscapeTileNear"));
landscapeSlider->setValue( std::min( landscapeSlider->value(), getQuality( qualityToLandscapeTileNear, s.config.getFloat( "LandscapeTileNear" ) ) ) ); landscapeSlider->setValue(std::min(landscapeSlider->value(), getQualityPresetFloat("LandscapeThreshold")));
landscapeSlider->setValue( std::min( landscapeSlider->value(), getQuality( qualityToMicrovegetDensity, s.config.getFloat( "MicroVegetDensity" ) ) ) ); landscapeSlider->setValue(std::min(landscapeSlider->value(), getQualityPresetFloat("Vision")));
landscapeSlider->setValue(std::min(landscapeSlider->value(), getQualityPresetFloat("MicroVegetDensity")));
charactersSlider->setValue( getQuality( qualityToSkinNbMaxPoly, s.config.getInt( "SkinNbMaxPoly" ) ) ); // FX
charactersSlider->setValue( std::min( charactersSlider->value(), getQuality( qualityToNbMaxSkeletonNotCLod, s.config.getInt( "NbMaxSkeletonNotCLod" ) ) ) ); fxSlider->setValue(getQualityPresetInteger("FxNbMaxPoly"));
charactersSlider->setValue( std::min( charactersSlider->value(), getQuality( qualityToCharacterFarClip, s.config.getFloat( "CharacterFarClip" ) ) ) );
fxSlider->setValue( getQuality( qualityToFxNbMaxPoly, s.config.getInt( "FxNbMaxPoly" ) ) ); // characters
charactersSlider->setValue(getQualityPresetInteger("SkinNbMaxPoly"));
charactersSlider->setValue(std::min(charactersSlider->value(), getQualityPresetInteger("NbMaxSkeletonNotCLod")));
charactersSlider->setValue(std::min(charactersSlider->value(), getQualityPresetFloat("CharacterFarClip")));
int hdTextureInstalled = s.config.getInt("HDTextureInstalled"); int hdTextureInstalled = s.config.getInt("HDTextureInstalled");
if (hdTextureInstalled == 1) if (hdTextureInstalled == 1)
@ -70,38 +73,30 @@ void CDisplaySettingsDetailsWidget::save()
{ {
CSystem &s = CSystem::GetInstance(); CSystem &s = CSystem::GetInstance();
s.config.setFloat( "Vision", qualityToZFar[ landscapeSlider->value() ] ); // landscape
s.config.setFloat( "LandscapeTileNear", qualityToLandscapeTileNear[ landscapeSlider->value() ] ); setFloatPreset("LandscapeTileNear", landscapeSlider->value());
s.config.setFloat( "LandscapeThreshold", qualityToLandscapeThreshold[ landscapeSlider->value() ] ); setFloatPreset("LandscapeThreshold", landscapeSlider->value());
setFloatPreset("Vision", landscapeSlider->value());
setIntegerPreset("MicroVeget", landscapeSlider->value());
setFloatPreset("MicroVegetDensity", landscapeSlider->value());
if( landscapeSlider->value() > QUALITY_LOW ) // FX
s.config.setInt( "MicroVeget", 1 ); setIntegerPreset("FxNbMaxPoly", fxSlider->value());
else setIntegerPreset("Cloud", fxSlider->value());
s.config.setInt( "MicroVeget", 0 ); setFloatPreset("CloudQuality", fxSlider->value());
setIntegerPreset("CloudUpdate", fxSlider->value());
s.config.setFloat( "MicroVegetDensity", qualityToMicrovegetDensity[ landscapeSlider->value() ] ); setIntegerPreset("Shadows", fxSlider->value());
setIntegerPreset("FXAA", fxSlider->value());
setIntegerPreset("Bloom", fxSlider->value());
s.config.setInt( "SkinNbMaxPoly", qualityToSkinNbMaxPoly[ charactersSlider->value() ] ); setIntegerPreset("SquareBloom", fxSlider->value());
s.config.setInt( "NbMaxSkeletonNotCLod", qualityToNbMaxSkeletonNotCLod[ charactersSlider->value() ] ); setFloatPreset("DensityBloom", fxSlider->value());
s.config.setFloat( "CharacterFarClip", qualityToCharacterFarClip[ charactersSlider->value() ] );
s.config.setInt( "FxNbMaxPoly", qualityToFxNbMaxPoly[ fxSlider->value() ] );
if( fxSlider->value() > QUALITY_LOW )
{
s.config.setInt( "Shadows", 1 );
s.config.setInt( "Bloom", 1 );
s.config.setInt( "SquareBloom", 1 );
}
else
{
s.config.setInt( "Shadows", 0 );
s.config.setInt( "Bloom", 0 );
s.config.setInt( "SquareBloom", 0 );
}
// characters
setIntegerPreset("SkinNbMaxPoly", charactersSlider->value());
setIntegerPreset("NbMaxSkeletonNotCLod", charactersSlider->value());
setFloatPreset("CharacterFarClip", charactersSlider->value());
// misc
if( texturesSlider->value() == QUALITY_NORMAL ) if( texturesSlider->value() == QUALITY_NORMAL )
s.config.setInt( "HDEntityTexture", 1 ); s.config.setInt( "HDEntityTexture", 1 );
else if( texturesSlider->value() == QUALITY_LOW ) else if( texturesSlider->value() == QUALITY_LOW )
@ -144,71 +139,89 @@ void CDisplaySettingsDetailsWidget::onTexturesSliderChange( int value )
emit changed(); emit changed();
} }
const float CDisplaySettingsDetailsWidget::qualityToZFar[ QUALITY_STEP ] = float CDisplaySettingsDetailsWidget::getPresetFloat(const std::string &variable, sint preset)
{ {
200.0f, CSystem &s = CSystem::GetInstance();
400.0f,
500.0f,
800.0f
};
const float CDisplaySettingsDetailsWidget::qualityToLandscapeTileNear[ QUALITY_STEP ] = // preset name
std::string varName = variable + NLMISC::toString("_ps%d", preset);
return s.config.getFloat(varName.c_str());
}
int CDisplaySettingsDetailsWidget::getPresetInteger(const std::string &variable, sint preset)
{ {
20.0f, CSystem &s = CSystem::GetInstance();
100.0f,
150.0f,
200.0f
};
const float CDisplaySettingsDetailsWidget::qualityToLandscapeThreshold[ QUALITY_STEP ] = // preset name
std::string varName = variable + NLMISC::toString("_ps%d", preset);
return s.config.getInt(varName.c_str());
}
void CDisplaySettingsDetailsWidget::setFloatPreset(const std::string &variable, int preset)
{ {
100.0f, CSystem &s = CSystem::GetInstance();
1000.0f,
2000.0f,
3000.0f
};
// take value of the preset and set it to variable
s.config.setFloat(variable.c_str(), getPresetFloat(variable, preset));
}
const float CDisplaySettingsDetailsWidget::qualityToMicrovegetDensity[ QUALITY_STEP ] = void CDisplaySettingsDetailsWidget::setIntegerPreset(const std::string &variable, int preset)
{ {
10.0f, CSystem &s = CSystem::GetInstance();
30.0f,
80.0f,
100.0f
};
// take value of the preset and set it to variable
s.config.setInt(variable.c_str(), getPresetInteger(variable, preset));
}
const sint32 CDisplaySettingsDetailsWidget::qualityToSkinNbMaxPoly[ QUALITY_STEP ] = int CDisplaySettingsDetailsWidget::getQualityPresetFloat(const std::string &variable)
{ {
10000, CSystem &s = CSystem::GetInstance();
70000,
100000,
200000
};
const sint32 CDisplaySettingsDetailsWidget::qualityToNbMaxSkeletonNotCLod[ QUALITY_STEP ] = float value = s.config.getFloat(variable.c_str());
{
10,
50,
125,
255
};
const float CDisplaySettingsDetailsWidget::qualityToCharacterFarClip[ QUALITY_STEP ] = // ascending order
if (getPresetFloat(variable, 0) < getPresetFloat(variable, QUALITY_STEP-1))
{ {
50.0f, uint32 i = 0;
100.0f, while((i < QUALITY_STEP) && (getPresetFloat(variable, i) < value) )
200.0f, i++;
500.0f return i;
}; }
// descending order
else
{
uint32 i = 0;
while((i < QUALITY_STEP) && (getPresetFloat(variable, i) > value))
i++;
return i;
}
}
const sint32 CDisplaySettingsDetailsWidget::qualityToFxNbMaxPoly[ QUALITY_STEP ] = int CDisplaySettingsDetailsWidget::getQualityPresetInteger(const std::string &variable)
{ {
2000, CSystem &s = CSystem::GetInstance();
10000,
20000, float value = s.config.getFloat(variable.c_str());
50000
}; // ascending order
if (getPresetFloat(variable, 0) < getPresetFloat(variable, QUALITY_STEP-1))
{
uint32 i = 0;
while((i < QUALITY_STEP) && (getPresetFloat(variable, i) < value) )
i++;
return i;
}
// descending order
else
{
uint32 i = 0;
while((i < QUALITY_STEP) && (getPresetFloat(variable, i) > value))
i++;
return i;
}
}
QString CDisplaySettingsDetailsWidget::getQualityString( uint32 quality ) QString CDisplaySettingsDetailsWidget::getQualityString( uint32 quality )
{ {
@ -245,7 +258,7 @@ QString CDisplaySettingsDetailsWidget::getTextureQualityString( uint32 quality )
break; break;
case TEXQUALITY_HIGH: case TEXQUALITY_HIGH:
return tr( "High (128 MB)" ); return tr( "High (more than 128 MB)" );
break; break;
default: default:

View file

@ -58,30 +58,48 @@ private slots:
private: private:
/** /**
@brief Looks up and returns the "quality" ( see the enums on the top), that belongs to the specified value. @brief Looks up and returns the "quality" ( see the enums on the top), that belongs to the specified float value.
@param table - The lookup table you want to use. @param variable - The config variable.
@param value - The value that we want to look up.
@return Returns the "quality" that best fits the specified value. @return Returns the "quality" that best fits the specified value.
*/ */
template< typename T > int getQualityPresetFloat(const std::string &variable);
int getQuality( const T *table, T value )
{
if( table[ 0 ] < table[ QUALITY_STEP - 1 ] )
{
uint32 i = 0;
while( ( i < QUALITY_STEP ) && ( table[ i ] < value ) )
i++;
return i;
}
else
{
uint32 i = 0;
while( ( i < QUALITY_STEP ) && ( table[ i ] > value ) )
i++;
return i;
}
}
/**
@brief Looks up and returns the "quality" ( see the enums on the top), that belongs to the specified integer value.
@param variable - The config variable.
@return Returns the "quality" that best fits the specified value.
*/
int getQualityPresetInteger(const std::string &variable);
/**
@brief Return the float value of the variable depending on the preset.
@param variable - The config variable.
@param preset - The preset to use (0-3).
@return Returns the float value.
*/
float getPresetFloat(const std::string &variable, sint preset);
/**
@brief Return the integer value of the variable depending on the preset.
@param variable - The config variable.
@param preset - The preset to use (0-3).
@return Returns the integer value.
*/
int getPresetInteger(const std::string &variable, sint preset);
/**
@brief Define the float value of the variable depending on the predefined preset.
@param variable - The config variable.
@param preset - The preset to use (0-3).
*/
void setFloatPreset(const std::string &variable, int preset);
/**
@brief Define the integer value of the variable depending on the predefined preset.
@param variable - The config variable.
@param preset - The preset to use (0-3).
*/
void setIntegerPreset(const std::string &variable, int preset);
/** /**
@brief Retrieves the string that belongs to the specified quality. @brief Retrieves the string that belongs to the specified quality.
@ -97,22 +115,6 @@ private:
@return Returns a string describing the texture quality, Returns an empty string if an invalid value is specified. @return Returns a string describing the texture quality, Returns an empty string if an invalid value is specified.
*/ */
static QString getTextureQualityString( uint32 quality ); static QString getTextureQualityString( uint32 quality );
///////////////////////// Landscape values ///////////////////////
static const float qualityToZFar[ QUALITY_STEP ];
static const float qualityToLandscapeTileNear[ QUALITY_STEP ];
static const float qualityToLandscapeThreshold[ QUALITY_STEP ];
static const float qualityToMicrovegetDensity[ QUALITY_STEP ];
//////////////////////// Character values ////////////////////////
static const sint32 qualityToSkinNbMaxPoly[ QUALITY_STEP ];
static const sint32 qualityToNbMaxSkeletonNotCLod[ QUALITY_STEP ];
static const float qualityToCharacterFarClip[ QUALITY_STEP ];
/////////////////////// FX values ////////////////////////////////
static const sint32 qualityToFxNbMaxPoly[ QUALITY_STEP ];
}; };
#endif // DISPLAYSETTINGSDETAILSWIDGET_H #endif // DISPLAYSETTINGSDETAILSWIDGET_H