2010-05-06 00:08:41 +00:00
|
|
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
|
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
|
|
//
|
|
|
|
// 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/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-08 23:37:43 +00:00
|
|
|
#include "nel/gui/interface_element.h"
|
2012-02-08 00:58:15 +00:00
|
|
|
#include "nel/misc/xml_auto_ptr.h"
|
2012-06-08 23:37:43 +00:00
|
|
|
#include "nel/gui/interface_options.h"
|
2010-05-06 00:08:41 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace NLMISC;
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
const CInterfaceOptionValue CInterfaceOptionValue::NullValue;
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
void CInterfaceOptionValue::init(const std::string &str)
|
|
|
|
{
|
|
|
|
_Str= str;
|
|
|
|
fromString(str, _Int);
|
|
|
|
fromString(str, _Float);
|
|
|
|
_Color= CInterfaceElement::convertColor (str.c_str());
|
2010-05-12 14:15:48 +00:00
|
|
|
_Boolean= CInterfaceElement::convertBool(str.c_str());
|
2010-05-06 00:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// CInterfaceOptions
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
CInterfaceOptions::CInterfaceOptions()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
CInterfaceOptions::~CInterfaceOptions()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
bool CInterfaceOptions::parse (xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
cur = cur->children;
|
|
|
|
bool ok = true;
|
|
|
|
while (cur)
|
|
|
|
{
|
|
|
|
if ( !stricmp((char*)cur->name,"param") )
|
|
|
|
{
|
|
|
|
CXMLAutoPtr ptr, val;
|
|
|
|
ptr = xmlGetProp (cur, (xmlChar*)"name");
|
|
|
|
val = xmlGetProp (cur, (xmlChar*)"value");
|
2011-06-05 16:06:00 +00:00
|
|
|
if (!ptr || !val)
|
2010-05-06 00:08:41 +00:00
|
|
|
{
|
|
|
|
nlinfo("param with no name or no value");
|
|
|
|
ok = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-05 15:52:40 +00:00
|
|
|
string name = NLMISC::toLower(string((const char*)ptr));
|
2010-05-06 00:08:41 +00:00
|
|
|
string value = (string((const char*)val));
|
|
|
|
_ParamValue[name].init(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur = cur->next;
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
|
|
|
|
{
|
|
|
|
_ParamValue= other._ParamValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
|
|
|
|
{
|
|
|
|
string sLwrParamName = strlwr (sParamName);
|
|
|
|
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (sLwrParamName);
|
|
|
|
if (it != _ParamValue.end())
|
|
|
|
return it->second;
|
|
|
|
else
|
|
|
|
return CInterfaceOptionValue::NullValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const
|
|
|
|
{
|
|
|
|
return getValue(sParamName).getValStr();
|
|
|
|
}
|
|
|
|
// ***************************************************************************
|
|
|
|
sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const
|
|
|
|
{
|
|
|
|
return getValue(sParamName).getValSInt32();
|
|
|
|
}
|
|
|
|
// ***************************************************************************
|
|
|
|
float CInterfaceOptions::getValFloat(const std::string &sParamName) const
|
|
|
|
{
|
|
|
|
return getValue(sParamName).getValFloat();
|
|
|
|
}
|
|
|
|
// ***************************************************************************
|
|
|
|
NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const
|
|
|
|
{
|
|
|
|
return getValue(sParamName).getValColor();
|
|
|
|
}
|
|
|
|
// ***************************************************************************
|
|
|
|
bool CInterfaceOptions::getValBool(const std::string &sParamName) const
|
|
|
|
{
|
|
|
|
return getValue(sParamName).getValBool();
|
|
|
|
}
|
|
|
|
|