Only cosmetic changes so that the files would follow
our style guide. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8211 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -49,48 +49,54 @@ static PtrVector<UserConfigParam, REF> all_params;
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
UserConfigParam::~UserConfigParam()
|
||||
{
|
||||
all_params.remove(this);
|
||||
}
|
||||
} // ~UserConfigParam
|
||||
|
||||
GroupUserConfigParam::GroupUserConfigParam(const char* groupName, const char* comment)
|
||||
// ============================================================================
|
||||
GroupUserConfigParam::GroupUserConfigParam(const char* group_name,
|
||||
const char* comment)
|
||||
{
|
||||
this->paramName = groupName;
|
||||
m_param_name = group_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // GroupUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GroupUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
const int children_amount = m_children.size();
|
||||
|
||||
// comments
|
||||
if(comment.size() > 0) stream << " <!-- " << comment.c_str();
|
||||
if(m_comment.size() > 0) stream << " <!-- " << m_comment.c_str();
|
||||
for(int n=0; n<children_amount; n++)
|
||||
{
|
||||
if(m_children[n]->comment.size() > 0)
|
||||
stream << L"\n " << m_children[n]->paramName.c_str() << L" : " << m_children[n]->comment.c_str();
|
||||
if(m_children[n]->m_comment.size() > 0)
|
||||
stream << L"\n " << m_children[n]->m_param_name.c_str()
|
||||
<< L" : " << m_children[n]->m_comment.c_str();
|
||||
}
|
||||
|
||||
|
||||
stream << L" -->\n <" << paramName.c_str() << "\n";
|
||||
stream << L" -->\n <" << m_param_name.c_str() << "\n";
|
||||
|
||||
// actual values
|
||||
for (int n=0; n<children_amount; n++)
|
||||
{
|
||||
stream << L" " << m_children[n]->paramName.c_str() << L"=\"" << m_children[n]->toString() << L"\"\n";
|
||||
stream << L" " << m_children[n]->m_param_name.c_str() << L"=\""
|
||||
<< m_children[n]->toString() << L"\"\n";
|
||||
}
|
||||
stream << L" />\n\n";
|
||||
}
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GroupUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if (child == NULL)
|
||||
{
|
||||
//std::cerr << "/!\\ User Config : Couldn't find parameter group " << paramName << std::endl;
|
||||
//std::cerr << "/!\\ User Config : Couldn't find parameter group "
|
||||
// << paramName << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,60 +106,71 @@ void GroupUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
m_children[n]->findYourDataInAnAttributeOf(child);
|
||||
}
|
||||
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GroupUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
}
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
irr::core::stringw GroupUserConfigParam::toString() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
} // toString
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void GroupUserConfigParam::addChild(UserConfigParam* child)
|
||||
{
|
||||
m_children.push_back(child);
|
||||
}
|
||||
} // addChild
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
IntUserConfigParam::IntUserConfigParam(int defaultValue, const char* paramName, const char* comment)
|
||||
// ============================================================================
|
||||
IntUserConfigParam::IntUserConfigParam(int default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
m_param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // IntUserConfigParam
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
IntUserConfigParam::IntUserConfigParam(int defaultValue, const char* paramName,
|
||||
GroupUserConfigParam* group, const char* comment)
|
||||
// ----------------------------------------------------------------------------
|
||||
IntUserConfigParam::IntUserConfigParam(int default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
m_param_name = param_name;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // IntUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IntUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value << L"\" />\n\n";
|
||||
}
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
stream << L" <" << m_param_name.c_str() << L" value=\"" << m_value
|
||||
<< L"\" />\n\n";
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
irr::core::stringw IntUserConfigParam::toString() const
|
||||
{
|
||||
irr::core::stringw tmp;
|
||||
tmp += m_value;
|
||||
return tmp;
|
||||
}
|
||||
} // toString
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IntUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if(child == NULL)
|
||||
{
|
||||
//std::cout << "Couldn't find int parameter " << paramName << std::endl;
|
||||
@@ -162,48 +179,51 @@ void IntUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
|
||||
child->get( "value", &m_value );
|
||||
//std::cout << "read int " << paramName << ", value=" << value << std::endl;
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void IntUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
node->get( m_param_name, &m_value );
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
// ============================================================================
|
||||
TimeUserConfigParam::TimeUserConfigParam(Time::TimeType default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = param_name;
|
||||
m_param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // TimeUserConfigParam
|
||||
|
||||
TimeUserConfigParam::TimeUserConfigParam(Time::TimeType defaultValue,
|
||||
const char* paramName,
|
||||
// ----------------------------------------------------------------------------
|
||||
TimeUserConfigParam::TimeUserConfigParam(Time::TimeType default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
m_param_name = param_name;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // TimeUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TimeUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
std::ostringstream o;
|
||||
o<<m_value;
|
||||
stream << L" <" << paramName.c_str() << L" value=\""
|
||||
<< core::stringw(o.str().c_str()) << L"\" />\n\n";
|
||||
}
|
||||
stream << L" <" << m_param_name.c_str() << L" value=\""
|
||||
<< core::stringw(o.str().c_str()) << L"\" />\n\n";
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
irr::core::stringw TimeUserConfigParam::toString() const
|
||||
{
|
||||
// irrString does not have a += with a 64-bit int type, so
|
||||
@@ -214,234 +234,272 @@ irr::core::stringw TimeUserConfigParam::toString() const
|
||||
std::ostringstream o;
|
||||
o<<m_value;
|
||||
return core::stringw(o.str().c_str());
|
||||
}
|
||||
} // toString
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TimeUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if(child == NULL)
|
||||
{
|
||||
//std::cout << "Couldn't find int parameter " << paramName << std::endl;
|
||||
//std::cout << "Couldn't find int parameter " << paramName <<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
child->get( "value", &m_value );
|
||||
//std::cout << "read int " << paramName << ", value=" << value << std::endl;
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void TimeUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
node->get( m_param_name, &m_value );
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
StringUserConfigParam::StringUserConfigParam(const char* defaultValue, const char* paramName, const char* comment)
|
||||
// ============================================================================
|
||||
StringUserConfigParam::StringUserConfigParam(const char* default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
m_param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
StringUserConfigParam::StringUserConfigParam(const char* defaultValue, const char* paramName,
|
||||
GroupUserConfigParam* group, const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
|
||||
this->paramName = paramName;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // StringUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
StringUserConfigParam::StringUserConfigParam(const char* default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
m_param_name = param_name;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // StringUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void StringUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value.c_str() << L"\" />\n\n";
|
||||
}
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
stream << L" <" << m_param_name.c_str() << L" value=\""
|
||||
<< m_value.c_str() << L"\" />\n\n";
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void StringUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &m_value );
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void StringUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
node->get( m_param_name, &m_value );
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
WStringUserConfigParam::WStringUserConfigParam(const core::stringw& defaultValue, const char* paramName, const char* comment)
|
||||
// ============================================================================
|
||||
WStringUserConfigParam::WStringUserConfigParam(const core::stringw& default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = paramName;
|
||||
param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // WStringUserConfigParam
|
||||
|
||||
WStringUserConfigParam::WStringUserConfigParam(const core::stringw& defaultValue, const char* paramName,
|
||||
GroupUserConfigParam* group, const char* comment)
|
||||
// ----------------------------------------------------------------------------
|
||||
WStringUserConfigParam::WStringUserConfigParam(const core::stringw& default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_param_name = param_name;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // WStringUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void WStringUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value << L"\" />\n\n";
|
||||
}
|
||||
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
stream << L" <" << m_param_name.c_str() << L" value=\"" << m_value
|
||||
<< L"\" />\n\n";
|
||||
} // write
|
||||
// ----------------------------------------------------------------------------
|
||||
void WStringUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &m_value );
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void WStringUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
node->get( m_param_name, &m_value );
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
BoolUserConfigParam::BoolUserConfigParam(bool defaultValue, const char* paramName, const char* comment)
|
||||
// ============================================================================
|
||||
BoolUserConfigParam::BoolUserConfigParam(bool default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
BoolUserConfigParam::BoolUserConfigParam(bool defaultValue, const char* paramName,
|
||||
GroupUserConfigParam* group, const char* comment)
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // BoolUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
BoolUserConfigParam::BoolUserConfigParam(bool default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_param_name = param_name;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // BoolUserConfigParam
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void BoolUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << (m_value ? L"true" : L"false" ) << L"\" />\n\n";
|
||||
}
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
stream << L" <" << m_param_name.c_str() << L" value=\""
|
||||
<< (m_value ? L"true" : L"false" ) << L"\" />\n\n";
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void BoolUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if(child == NULL) return;
|
||||
|
||||
std::string textValue = "";
|
||||
child->get( "value", &textValue );
|
||||
std::string text_value = "";
|
||||
child->get( "value", &text_value );
|
||||
|
||||
if(textValue == "true")
|
||||
if(text_value == "true")
|
||||
{
|
||||
m_value = true;
|
||||
}
|
||||
else if(textValue == "false")
|
||||
else if(text_value == "false")
|
||||
{
|
||||
m_value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unknown value for " << paramName << "; expected true or false\n";
|
||||
std::cerr << "Unknown value for " << m_param_name
|
||||
<< "; expected true or false\n";
|
||||
}
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void BoolUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
std::string textValue = "";
|
||||
node->get( paramName, &textValue );
|
||||
std::string text_value = "";
|
||||
node->get( m_param_name, &text_value );
|
||||
|
||||
if (textValue == "true")
|
||||
if (text_value == "true")
|
||||
{
|
||||
m_value = true;
|
||||
}
|
||||
else if (textValue == "false")
|
||||
else if (text_value == "false")
|
||||
{
|
||||
m_value = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unknown value for " << paramName << "; expected true or false\n";
|
||||
std::cerr << "Unknown value for " << m_param_name
|
||||
<< "; expected true or false\n";
|
||||
}
|
||||
}
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
irr::core::stringw BoolUserConfigParam::toString() const
|
||||
{
|
||||
return (m_value ? L"true" : L"false" );
|
||||
}
|
||||
} // toString
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
FloatUserConfigParam::FloatUserConfigParam(float defaultValue, const char* paramName, const char* comment)
|
||||
// ============================================================================
|
||||
FloatUserConfigParam::FloatUserConfigParam(float default_value,
|
||||
const char* param_name,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_param_name = param_name;
|
||||
all_params.push_back(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // FloatUserConfigParam
|
||||
|
||||
FloatUserConfigParam::FloatUserConfigParam(float defaultValue, const char* paramName,
|
||||
GroupUserConfigParam* group, const char* comment)
|
||||
// ----------------------------------------------------------------------------
|
||||
FloatUserConfigParam::FloatUserConfigParam(float default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment)
|
||||
{
|
||||
m_value = defaultValue;
|
||||
m_default_value = defaultValue;
|
||||
m_value = default_value;
|
||||
m_default_value = default_value;
|
||||
|
||||
this->paramName = paramName;
|
||||
m_param_name = param_name;
|
||||
group->addChild(this);
|
||||
if(comment != NULL) this->comment = comment;
|
||||
}
|
||||
if(comment != NULL) m_comment = comment;
|
||||
} // FloatUserConfigParam
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void FloatUserConfigParam::write(XMLWriter& stream) const
|
||||
{
|
||||
if(comment.size() > 0) stream << L" <!-- " << comment.c_str() << L" -->\n";
|
||||
stream << L" <" << paramName.c_str() << L" value=\"" << m_value << L"\" />\n\n";
|
||||
}
|
||||
if(m_comment.size() > 0) stream << L" <!-- " << m_comment.c_str()
|
||||
<< L" -->\n";
|
||||
stream << L" <" << m_param_name.c_str() << L" value=\"" << m_value
|
||||
<< L"\" />\n\n";
|
||||
} // write
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void FloatUserConfigParam::findYourDataInAChildOf(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
const XMLNode* child = node->getNode( m_param_name );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &m_value );
|
||||
}
|
||||
} // findYourDataInAChildOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void FloatUserConfigParam::findYourDataInAnAttributeOf(const XMLNode* node)
|
||||
{
|
||||
node->get( paramName, &m_value );
|
||||
}
|
||||
node->get( m_param_name, &m_value );
|
||||
} // findYourDataInAnAttributeOf
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
irr::core::stringw FloatUserConfigParam::toString() const
|
||||
{
|
||||
irr::core::stringw tmp;
|
||||
tmp += m_value;
|
||||
return tmp;
|
||||
}
|
||||
} // toString
|
||||
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
@@ -496,7 +554,7 @@ void UserConfig::addDefaultPlayer()
|
||||
// Set the name as the default name for all players.
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(username.c_str()) );
|
||||
|
||||
}
|
||||
} // addDefaultPlayer
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -60,21 +60,24 @@ class XMLWriter;
|
||||
class PlayerProfile;
|
||||
|
||||
/**
|
||||
* The base of a set of small utilities to enable quickly adding/removing stuff to/from config painlessly.
|
||||
*/
|
||||
* The base of a set of small utilities to enable quickly adding/removing
|
||||
* stuff to/from config painlessly.
|
||||
*/
|
||||
class UserConfigParam
|
||||
{
|
||||
friend class GroupUserConfigParam;
|
||||
protected:
|
||||
std::string paramName, comment;
|
||||
std::string m_param_name;
|
||||
std::string m_comment;
|
||||
public:
|
||||
virtual ~UserConfigParam();
|
||||
virtual ~UserConfigParam();
|
||||
virtual void write(XMLWriter& stream) const = 0;
|
||||
virtual void findYourDataInAChildOf(const XMLNode* node) = 0;
|
||||
virtual void findYourDataInAnAttributeOf(const XMLNode* node) = 0;
|
||||
virtual irr::core::stringw toString() const = 0;
|
||||
};
|
||||
}; // UserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class GroupUserConfigParam : public UserConfigParam
|
||||
{
|
||||
std::vector<UserConfigParam*> m_children;
|
||||
@@ -86,8 +89,9 @@ public:
|
||||
|
||||
void addChild(UserConfigParam* child);
|
||||
irr::core::stringw toString() const;
|
||||
};
|
||||
}; // GroupUserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class IntUserConfigParam : public UserConfigParam
|
||||
{
|
||||
int m_value;
|
||||
@@ -95,22 +99,27 @@ class IntUserConfigParam : public UserConfigParam
|
||||
|
||||
public:
|
||||
|
||||
IntUserConfigParam(int defaultValue, const char* paramName, const char* comment = NULL);
|
||||
IntUserConfigParam(int defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
IntUserConfigParam(int default_value, const char* param_name,
|
||||
const char* comment = NULL);
|
||||
IntUserConfigParam(int default_value, const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
irr::core::stringw toString() const;
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
operator int() const { return m_value; }
|
||||
int& operator++(int dummy) { m_value++; return m_value; }
|
||||
int& operator=(const int& v) { m_value = v; return m_value; }
|
||||
int& operator=(const IntUserConfigParam& v) { m_value = (int)v; return m_value; }
|
||||
};
|
||||
operator int() const { return m_value; }
|
||||
int& operator++(int dummy) { m_value++; return m_value; }
|
||||
int& operator=(const int& v) { m_value = v; return m_value; }
|
||||
int& operator=(const IntUserConfigParam& v)
|
||||
{ m_value = (int)v; return m_value; }
|
||||
}; // IntUserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class TimeUserConfigParam : public UserConfigParam
|
||||
{
|
||||
Time::TimeType m_value;
|
||||
@@ -118,9 +127,9 @@ class TimeUserConfigParam : public UserConfigParam
|
||||
|
||||
public:
|
||||
|
||||
TimeUserConfigParam(Time::TimeType defaultValue, const char* paramName,
|
||||
TimeUserConfigParam(Time::TimeType default_value, const char* param_name,
|
||||
const char* comment = NULL);
|
||||
TimeUserConfigParam(Time::TimeType defaultValue, const char* paramName,
|
||||
TimeUserConfigParam(Time::TimeType default_value, const char* param_name,
|
||||
GroupUserConfigParam* group, const char* comment=NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
@@ -134,9 +143,9 @@ public:
|
||||
{ m_value = v; return m_value; }
|
||||
Time::TimeType& operator=(const TimeUserConfigParam& v)
|
||||
{ m_value = (int)v; return m_value; }
|
||||
};
|
||||
|
||||
}; // TimeUserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class StringUserConfigParam : public UserConfigParam
|
||||
{
|
||||
std::string m_value;
|
||||
@@ -144,25 +153,30 @@ class StringUserConfigParam : public UserConfigParam
|
||||
|
||||
public:
|
||||
|
||||
StringUserConfigParam(const char* defaultValue, const char* paramName, const char* comment = NULL);
|
||||
StringUserConfigParam(const char* defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
StringUserConfigParam(const char* default_value, const char* param_name,
|
||||
const char* comment = NULL);
|
||||
StringUserConfigParam(const char* default_value, const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
|
||||
void revertToDefaults() { m_value = m_default_value; }
|
||||
|
||||
|
||||
irr::core::stringw toString() const { return m_value.c_str(); }
|
||||
|
||||
operator std::string() const { return m_value; }
|
||||
std::string& operator=(const std::string& v) { m_value = v; return m_value; }
|
||||
std::string& operator=(const StringUserConfigParam& v) { m_value = (std::string)v; return m_value; }
|
||||
operator std::string() const { return m_value; }
|
||||
std::string& operator=(const std::string& v)
|
||||
{ m_value = v; return m_value; }
|
||||
std::string& operator=(const StringUserConfigParam& v)
|
||||
{ m_value = (std::string)v; return m_value; }
|
||||
|
||||
const char* c_str() const { return m_value.c_str(); }
|
||||
};
|
||||
}; // StringUserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class WStringUserConfigParam : public UserConfigParam
|
||||
{
|
||||
stringw m_value;
|
||||
@@ -170,9 +184,13 @@ class WStringUserConfigParam : public UserConfigParam
|
||||
|
||||
public:
|
||||
|
||||
WStringUserConfigParam(const stringw& defaultValue, const char* paramName, const char* comment = NULL);
|
||||
WStringUserConfigParam(const stringw& defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
WStringUserConfigParam(const stringw& default_value,
|
||||
const char* param_name,
|
||||
const char* comment = NULL);
|
||||
WStringUserConfigParam(const stringw& default_value,
|
||||
const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
@@ -183,22 +201,24 @@ public:
|
||||
irr::core::stringw toString() const { return m_value; }
|
||||
|
||||
operator stringw() const { return m_value; }
|
||||
stringw& operator=(const stringw& v) { m_value = v; return m_value; }
|
||||
stringw& operator=(const WStringUserConfigParam& v) { m_value = (stringw)v; return m_value; }
|
||||
|
||||
stringw& operator=(const stringw& v) { m_value = v; return m_value; }
|
||||
stringw& operator=(const WStringUserConfigParam& v)
|
||||
{ m_value = (stringw)v; return m_value; }
|
||||
const wchar_t* c_str() const { return m_value.c_str(); }
|
||||
};
|
||||
}; // WStringUserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class BoolUserConfigParam : public UserConfigParam
|
||||
{
|
||||
bool m_value;
|
||||
bool m_default_value;
|
||||
|
||||
public:
|
||||
BoolUserConfigParam(bool defaultValue, const char* paramName, const char* comment = NULL);
|
||||
BoolUserConfigParam(bool defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
|
||||
|
||||
BoolUserConfigParam(bool default_value, const char* param_name,
|
||||
const char* comment = NULL);
|
||||
BoolUserConfigParam(bool default_value, const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
void findYourDataInAnAttributeOf(const XMLNode* node);
|
||||
@@ -208,17 +228,22 @@ public:
|
||||
|
||||
operator bool() const { return m_value; }
|
||||
bool& operator=(const bool& v) { m_value = v; return m_value; }
|
||||
bool& operator=(const BoolUserConfigParam& v) { m_value = (bool)v; return m_value; }
|
||||
};
|
||||
bool& operator=(const BoolUserConfigParam& v)
|
||||
{ m_value = (bool)v; return m_value; }
|
||||
}; // BoolUserConfigParam
|
||||
|
||||
// ============================================================================
|
||||
class FloatUserConfigParam : public UserConfigParam
|
||||
{
|
||||
float m_value;
|
||||
float m_default_value;
|
||||
|
||||
public:
|
||||
FloatUserConfigParam(float defaultValue, const char* paramName, const char* comment = NULL);
|
||||
FloatUserConfigParam(float defaultValue, const char* paramName, GroupUserConfigParam* group, const char* comment = NULL);
|
||||
FloatUserConfigParam(float default_value, const char* param_name,
|
||||
const char* comment = NULL);
|
||||
FloatUserConfigParam(float default_value, const char* param_name,
|
||||
GroupUserConfigParam* group,
|
||||
const char* comment = NULL);
|
||||
|
||||
void write(XMLWriter& stream) const;
|
||||
void findYourDataInAChildOf(const XMLNode* node);
|
||||
@@ -229,18 +254,21 @@ public:
|
||||
|
||||
operator float() const { return m_value; }
|
||||
float& operator=(const float& v) { m_value = v; return m_value; }
|
||||
float& operator=(const FloatUserConfigParam& v) { m_value = (float)v; return m_value; }
|
||||
};
|
||||
float& operator=(const FloatUserConfigParam& v)
|
||||
{ m_value = (float)v; return m_value; }
|
||||
}; // FloatUserConfigParam
|
||||
|
||||
const int ANIMS_NONE = 0;
|
||||
const int ANIMS_PLAYERS_ONLY = 1;
|
||||
const int ANIMS_ALL = 2;
|
||||
// ============================================================================
|
||||
enum AnimType {ANIMS_NONE = 0,
|
||||
ANIMS_PLAYERS_ONLY = 1,
|
||||
ANIMS_ALL = 2 };
|
||||
|
||||
/**
|
||||
* Using X-macros for setting-possible values is not very pretty, but it's a no-maintenance case :
|
||||
* when you want to add a new parameter, just add one signle line below and everything else automagically works
|
||||
* (including default value, saving to file, loading from file)
|
||||
*/
|
||||
/** Using X-macros for setting-possible values is not very pretty, but it's a
|
||||
* no-maintenance case :
|
||||
* when you want to add a new parameter, just add one signle line below and
|
||||
* everything else automagically works (including default value, saving to
|
||||
* file, loading from file)
|
||||
*/
|
||||
|
||||
#ifndef PARAM_PREFIX
|
||||
#define PARAM_PREFIX extern
|
||||
@@ -250,10 +278,10 @@ const int ANIMS_ALL = 2;
|
||||
#define PARAM_DEFAULT(X)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Contains all parameters that are stored in the user's config file
|
||||
* \ingroup config
|
||||
*/
|
||||
// ============================================================================
|
||||
/** \brief Contains all parameters that are stored in the user's config file
|
||||
* \ingroup config
|
||||
*/
|
||||
namespace UserConfigParams
|
||||
{
|
||||
// ---- Audio
|
||||
@@ -467,6 +495,7 @@ namespace UserConfigParams
|
||||
#undef PARAM_PREFIX
|
||||
#undef PARAM_SUFFIX
|
||||
|
||||
// ============================================================================
|
||||
/**
|
||||
* \brief Class for managing general STK user configuration data.
|
||||
* \ingroup config
|
||||
@@ -480,7 +509,8 @@ private:
|
||||
irr::core::stringw m_warning;
|
||||
|
||||
public:
|
||||
/** Create the user config object; does not actually load it, UserConfig::loadConfig needs to be called */
|
||||
/** Create the user config object; does not actually load it,
|
||||
* UserConfig::loadConfig needs to be called. */
|
||||
UserConfig();
|
||||
~UserConfig();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user