Beispiel #1
0
void PropertySet::LoadFromConfig()
{
	ConfVarTable *op = g_conf.ed_objproperties.GetTable(GetTypeName());
	for( int i = 0; i < GetCount(); ++i )
	{
		ObjectProperty *prop = GetProperty(i);
		switch( prop->GetType() )
		{
		case ObjectProperty::TYPE_INTEGER:
			prop->SetIntValue(
				__min(prop->GetIntMax(), __max(prop->GetIntMin(),
					op->GetNum(prop->GetName(), prop->GetIntValue())->GetInt()
			)));
			break;
		case ObjectProperty::TYPE_FLOAT:
			prop->SetFloatValue(
				__min(prop->GetFloatMax(), __max(prop->GetFloatMin(),
					op->GetNum(prop->GetName(), prop->GetFloatValue())->GetFloat()
			)));
			break;
		case ObjectProperty::TYPE_STRING:
			prop->SetStringValue(op->GetStr(prop->GetName(), prop->GetStringValue().c_str())->Get());
			break;
		case ObjectProperty::TYPE_MULTISTRING:
			prop->SetCurrentIndex(
				__min((int) prop->GetListSize() - 1, __max(0,
					op->GetNum(prop->GetName(), (int) prop->GetCurrentIndex())->GetInt()
			)));
			break;
		default:
			assert(false);
		} // end of switch( prop->GetType() )
	}
}
Beispiel #2
0
void PropertySet::SaveToConfig()
{
	ConfVarTable *op = g_conf.ed_objproperties.GetTable(GetTypeName());
	for( int i = 0; i < GetCount(); ++i )
	{
		ObjectProperty *prop = GetProperty(i);
		switch( prop->GetType() )
		{
		case ObjectProperty::TYPE_INTEGER:
			op->SetNum(prop->GetName(), prop->GetIntValue());
			break;
		case ObjectProperty::TYPE_FLOAT:
			op->SetNum(prop->GetName(), prop->GetFloatValue());
			break;
		case ObjectProperty::TYPE_STRING:
			op->SetStr(prop->GetName(), prop->GetStringValue());
			break;
		case ObjectProperty::TYPE_MULTISTRING:
			op->SetNum(prop->GetName(), (int) prop->GetCurrentIndex());
			break;
		default:
			assert(false);
		} // end of switch( prop->GetType() )
	}}