wxVariant wxPointProperty::ChildChanged(wxVariant& thisValue, int childIndex, wxVariant& childValue) const { Point& point = PointRefFromVariant(thisValue); switch ( childIndex ) { case 0: point.X = childValue.GetInteger(); break; case 1: point.Y = childValue.GetInteger(); break; } wxVariant newVariant; newVariant << point; return newVariant; }
wxVariant wxSizeProperty::ChildChanged(wxVariant& thisValue, int childIndex, wxVariant& childValue) const { Size& size = SizeRefFromVariant(thisValue); switch ( childIndex ) { case 0: size.Width = childValue.GetInteger(); break; case 1: size.Height = childValue.GetInteger(); break; } wxVariant newVariant; newVariant << size; return newVariant; }
wxString MOPGThingTypeProperty::ValueToString(wxVariant &value, int argFlags) const { // Get value as integer int type = value.GetInteger(); ThingType* tt = theGameConfiguration->thingType(type); return S_FMT("%d: %s", type, CHR(tt->getName())); }
std::string ScalarSelectionDialog::GetValueString(const wxVariant& variant, std::type_index type, int precision) { std::string result; if (!variant.IsNull()) { if (IsFloat(type)) { std::stringstream strstream; if (precision > 0) { strstream << std::setprecision(precision) << std::fixed << variant.GetDouble(); } else { strstream << std::fixed << variant.GetDouble(); } auto tmpStr = strstream.str(); size_t last_not_zero = tmpStr.find_last_not_of('0'); result = tmpStr.substr(0, last_not_zero == std::string::npos ? last_not_zero : last_not_zero+1); } else if (IsIntegral(type)) { result = std::to_string(variant.GetInteger()); } } return result; }
wxString MOPGActionSpecialProperty::ValueToString(wxVariant &value, int argFlags) const { // Get value as integer int special = value.GetInteger(); if (special == 0) return "0: None"; else { ActionSpecial* as = theGameConfiguration->actionSpecial(special); return S_FMT("%d: %s", special, CHR(as->getName())); } }
// ----------------------------------------------------------------------- wxVariant WxGUIStringInfoProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const { CGUIStringRenderInfo& string_info = CGUIStringRenderInfoRefFromVariant(thisValue); switch ( childIndex ) { case 0: string_info.m_fFontScale = childValue.GetDouble(); break; case 1: string_info.m_uFontID = childValue.GetInteger(); break; case 2: string_info.m_aColor << childValue; break; } wxVariant newVariant; newVariant << string_info; return newVariant; }
wxString MOPGAngleProperty::ValueToString(wxVariant &value, int argFlags) const { int angle = value.GetInteger(); switch (angle) { case 0: return "0: East"; break; case 45: return "45: Northeast"; break; case 90: return "90: North"; break; case 135: return "135: Northwest"; break; case 180: return "180: West"; break; case 225: return "225: Southwest"; break; case 270: return "270: South"; break; case 315: return "315: Southeast"; break; default: return S_FMT("%d", angle); break; } }
wxVariant luObjectProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const { luGameObjProps obj; obj << thisValue; switch ( childIndex ) { case PROP_NAME: { obj.name = childValue.GetString(); break; } //case PROP_TYPE: { obj.type = childValue.GetString(); break; } case PROP_POS: { obj.pos = gkVector3RefFromVariant(childValue); break; } case PROP_SCALE: { obj.scale = gkVector3RefFromVariant(childValue); break; } case PROP_FRONT: { obj.front = gkVector3RefFromVariant(childValue); break; } case PROP_UP: { obj.up = gkVector3RefFromVariant(childValue); break; } case PROP_DIM: { obj.dim = gkVector3RefFromVariant(childValue); break; } case PROP_FLAGS: { obj.flags = childValue.GetInteger(); break; } case PROP_STATE: { obj.state = childValue.GetInteger(); break; } } return thisValue << obj; }