Example #1
0
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Object* object)
{
	if (object)
	{
		if (event.GetPropertyName() == "Name")
		{
			object->setName(event.GetValue().GetString().c_str());
		}
		else if (event.GetPropertyName() == "Description")
		{
			object->setDescription(event.GetValue().GetString().c_str());
		}

		switch (object->getType())
		{
			case OT_BUILDING: onPropertyChanging(event, static_cast<Building*>(object)); break;
			case OT_JUNCTION: onPropertyChanging(event, static_cast<Junction*>(object)); break;
			case OT_PLANT: onPropertyChanging(event, static_cast<Plant*>(object)); break;
			case OT_ROUTE: onPropertyChanging(event, static_cast<Route*>(object)); break;
			case OT_WATER_OBJECT: onPropertyChanging(event, static_cast<WaterObject*>(object)); break;
		}

		City::getSingleton().updateViews(object);
	}
}
Example #2
0
int ArchesModel::OnPropertyGridChange(wxPropertyGridInterface *grid, wxPropertyGridEvent& event) {
    if ("ArchesCount" == event.GetPropertyName()) {
        ModelXml->DeleteAttribute("parm1");
        ModelXml->AddAttribute("parm1", wxString::Format("%d", event.GetPropertyValue().GetLong()));
        SetFromXml(ModelXml, zeroBased);
        AdjustStringProperties(grid, parm1);
        return 3;
    } else if ("ArchesNodes" == event.GetPropertyName()) {
        ModelXml->DeleteAttribute("parm2");
        ModelXml->AddAttribute("parm2", wxString::Format("%d", event.GetPropertyValue().GetLong()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if ("ArchesLights" == event.GetPropertyName()) {
        ModelXml->DeleteAttribute("parm3");
        ModelXml->AddAttribute("parm3", wxString::Format("%d", event.GetPropertyValue().GetLong()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if ("ArchesArc" == event.GetPropertyName()) {
        ModelXml->DeleteAttribute("arc");
        ModelXml->AddAttribute("arc", wxString::Format("%d", event.GetPropertyValue().GetLong()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if ("ArchesStart" == event.GetPropertyName()) {
        ModelXml->DeleteAttribute("Dir");
        ModelXml->AddAttribute("Dir", event.GetValue().GetLong() == 0 ? "L" : "R");
        SetFromXml(ModelXml, zeroBased);
        return 3;
    }

    return Model::OnPropertyGridChange(grid, event);
}
Example #3
0
bool ObjectsPropgridHelper::OnPropertyChanged(gd::Object * object, gd::Layout * layout, wxPropertyGridEvent& event)
{
    if ( !grid || !object ) return false;

    auto readEnumPropertyString = [&event](std::map<gd::String, gd::PropertyDescriptor> properties) {
        const std::vector<gd::String> & choices = properties[event.GetProperty()->GetLabel()].GetExtraInfo();

        unsigned int id = event.GetPropertyValue().GetLong();
        if (id < choices.size()) {
            return gd::String(choices[id]);
        }

        return gd::String("");
    };

    if ( event.GetPropertyName().substr(0,10) == "AUTO_PROP:" )
    {
        gd::String autoName = event.GetPropertyName().substr(10);
        if ( !object->HasBehaviorNamed(autoName))
        {
            event.Veto();
            return false;
        }

        gd::Behavior & behavior = object->GetBehavior(autoName);
        gd::String value = event.GetPropertyValue().GetString();

        //Special case for enums.
        if (wxEnumProperty * enumProperty = dynamic_cast<wxEnumProperty*>(event.GetProperty()))
            value = readEnumPropertyString(behavior.GetProperties(project));

        if (!behavior.UpdateProperty(event.GetProperty()->GetLabel(), value, project))
        {
            event.Veto();
            return false;
        }
    }
    else if ( event.GetPropertyName().substr(0,8) == "OBJ_PROP" )
    {
        gd::String value = event.GetPropertyValue().GetString();

        //Special case for enums.
        if (wxEnumProperty * enumProperty = dynamic_cast<wxEnumProperty*>(event.GetProperty()))
            value = readEnumPropertyString(object->GetProperties(project));

        if (!object->UpdateProperty(event.GetProperty()->GetLabel(), value, project))
        {
            event.Veto();
            return false;
        }
    }

    return false;
}
Example #4
0
void ProjectPropertiesPnl::OnPropertyChanged(wxPropertyGridEvent& event)
{
    if (project) project->OnChangeInPropertyGrid(propertyGrid, event);

    if ( event.GetPropertyName() == _("Name of the project") && associatedTree != NULL)
        associatedTree->SetItemText(associatedTreeItem, event.GetProperty()->GetValue());

    if ( event.GetPropertyName() == _("Activate the use of C++ source files") && associatedProjectManager != NULL)
        associatedProjectManager->Refresh();

    if (project) project->SetDirty();
}
Example #5
0
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Map* map)
{
	if (event.GetPropertyName() == "Name")
	{
		map->setName(event.GetValue().GetString().c_str());
	}
	else if (event.GetPropertyName() == "Texture")
	{
		map->setTexture(wxFileNameFromPath(event.GetValue().GetString()).c_str());
	}

	City::getSingleton().updateViews(map);
}
Example #6
0
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Building* object)
{
	if (event.GetPropertyName() == "Height")
	{
		object->setHeight(event.GetValue().GetDouble());
	}
	else if (event.GetPropertyName() == "Number")
	{
		object->setNumber(event.GetValue().GetLong());
	}
	else if (event.GetPropertyName() == "Texture")
	{
		object->setTexture(wxFileNameFromPath(event.GetValue().GetString()).c_str());
	}
}
void LayoutEditorPropertiesPnl::OnPropertyChanged(wxPropertyGridEvent& event)
{
    if ( layoutEditorCanvas && displayInstancesProperties )
    {
        std::vector<InitialInstance*> selectedInitialInstances = layoutEditorCanvas->GetSelection();

        //In case "Custom size" property is checked, we do some extra work : Setting the custom width/height
        //of instances at their original width/height
        if ( event.GetPropertyName() == _("Custom size?") && grid->GetProperty(_("Custom size?"))->GetValue().GetBool() )
        {
            for (std::size_t i = 0;i<selectedInitialInstances.size();++i)
            {
                sf::Vector2f size = layoutEditorCanvas->GetInitialInstanceSize(*selectedInitialInstances[i]);
                selectedInitialInstances[i]->SetCustomWidth(size.x);
                selectedInitialInstances[i]->SetCustomHeight(size.y);
            }
        }

        instancesHelper.OnPropertyChanged(selectedInitialInstances, event);
    }
    if ( object )
    {
        if ( objectsHelper.OnPropertyChanged(object, &layout, event) ){
            wxCommandEvent refreshEvent(refreshEventType);
            wxPostEvent(grid, refreshEvent);
            //Refresh(); Can trigger a crash
        }
    }
}
Example #8
0
//-----------------------------------------------------------------------------
void Property::OnChange (wxPropertyGridEvent &event)
{
	wxPGProperty *id = event.GetProperty();
	PX2_UNUSED(id);

	const wxString &name = event.GetPropertyName();
	std::string stdName = std::string(name);
	wxVariant variant = event.GetPropertyValue();

	if (name != wxString(mName.c_str()))
		return;

	if (variant.IsNull())
		return;

	if (!mData)
		return;

	if (mType == PT_INT)
	{
		*((int*)mData) = wxPGVariantToInt(variant);
	}
	else if (mType == PT_FLOAT)
	{
		double value = 0;
		wxPGVariantToDouble(variant, &value);
		*((float*)mData) = (float)value;
	}
	else if (mType == PT_BOOL)
	{
		bool value = (bool)(event.GetPropertyValueAsBool()!=0);
		*((bool*)mData) = value;
	}
	else if (mType == PT_BOOLCHECK)
	{
		bool value = (bool)(event.GetPropertyValueAsBool()!=0);
		*((bool*)mData) = value;
	}
	else if (PT_COLOR3FLOAT3 == mType)
	{
		wxString strColor = event.GetPropertyValueAsString();
		wxColor color = StringToColor(strColor);

		Float3 float3Color((float)color.Red()/255.0f, (float)color.Green()/255.0f,
			(float)color.Blue()/255.0f);

		*((Float3*)mData) = float3Color;
	}
	else if (PT_FLOAT3 == mType)
	{
		*((Float3*)mData) = Float3FromVariant(variant);
	}
	else if (mType == PT_STRING)
	{
		std::string value;
		wxString wxValue = event.GetPropertyValueAsString();
		value = std::string(wxValue.ToAscii());
		*((std::string*)mData) = value;
	}
}
void ProjectWindow::OnPropertyChanged( wxPropertyGridEvent& evt )
{ 
   if (!mSelectedAssetDef || !mSelectedAsset)
      return;

   wxString name = evt.GetPropertyName();
   wxVariant val = evt.GetPropertyValue();
   wxString strVal = val.GetString();

   if (name.StartsWith("TextureAsset"))
   {
      long intVal = val.GetInteger();
      //strVal = mTextureAssetChoices.GetLabel(intVal);
   }

   // Set Value.
   mSelectedAsset->setDataField(Torque::StringTableLink->insert(name), NULL, strVal);

   // Save the asset
   mSelectedAsset->saveAsset();

   // Refresh textures if it's a MaterialAsset.
   if (mSelectedMaterialAsset)
      mSelectedMaterialAsset->loadTextures();

   // Refresh Scene.
   Torque::Scene.refresh();

   // Reload object properties.
   mAssetsInspector->Inspect(mSelectedAssetDef);
}
Example #10
0
void Properties::onPropertyChanging(wxPropertyGridEvent& event, Database* database)
{
	if (event.GetPropertyName() == "Name")
	{
		database->setName(event.GetValue().GetString().c_str());
	}
}
//-----------------------------------------------------------------------------
void EMFloatProperty::OnChange (wxPropertyGridEvent &event)
{
	wxPGProperty *prop = event.GetProperty();
	const wxString &wxName = event.GetPropertyName();
	wxVariant var = prop->GetValue();

	if (var.IsNull())
		return;

	float fValue = (float)(var.GetDouble());

	if (mPropertyInVal == prop)
	{
		mPoint->InVal = fValue;
	}
	else if (mPropertyOutVal == prop)
	{
		mPoint->OutVal = fValue;
	}
	else if (mPropertyArriveTangent == prop)
	{
		mPoint->ArriveTangent = fValue;
	}
	else if (mPropertyLeaveTangent == prop)
	{
		mPoint->LeaveTangent = fValue;
	}
	else if (mInterpMode == prop)
	{
		int val = var.GetInteger();
		mPoint->InterpMode = (InterpCurveMode)val;
	}
}
void
ObjectPropertyEditor::OnPropertyChanged(wxPropertyGridEvent& e)
{
    // Skip parent properties
    if (e.GetPropertyPtr()->GetParentingType() != 0)
        return;

    // Skip if no current selected object
    Fairy::ObjectPtr object = mCurrentObject.lock();
    if (!object)
        return;

    Ogre::String propertyName = AS_STRING(e.GetPropertyName());
    Ogre::String propertyValue = AS_STRING(e.GetPropertyValueAsString());

	if(propertyName == "position" || propertyName == "scale")
	{
		Ogre::Vector3 vValue = Ogre::StringConverter::parseVector3(propertyValue);
		object->setProperty(propertyName,vValue);
	}
	else if(propertyName == "orientation")
	{
		Ogre::Quaternion qValue = Ogre::StringConverter::parseQuaternion(propertyValue);
		object->setProperty(propertyName,qValue);
	}
	else if(propertyName == "actor name")
	{
		m_Frame->ClearAllSelectorObject();
		m_Frame->GetActorSettingEditor()->SetCurrentObject(Ogre::String(propertyValue.c_str()));
		return;
	}

    mPropertiesViewer->Freeze();

    const Fairy::PropertyList& properties = object->getProperties();
    for (Fairy::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it)
    {
        const Fairy::PropertyDef& propertyDef = *it;
        Fairy::uint propertyFlags = object->getPropertyFlags(propertyDef.name);
        wxPGId id = mPropertiesViewer->GetPropertyByName(propertyDef.name.c_str());
        assert(id.IsOk());
        if (!id.IsOk())
            continue;
        if (propertyFlags & Fairy::PF_READONLY)
        {
            if (mPropertiesViewer->IsPropertyEnabled(id))
                mPropertiesViewer->DisableProperty(id);
        }
        else
        {
            if (!mPropertiesViewer->IsPropertyEnabled(id))
                mPropertiesViewer->EnableProperty(id);
        }
    }

    mPropertiesViewer->Thaw();
}
//---------------------------------------------------------
void CParameters_Control::On_PG_Changed(wxPropertyGridEvent &event)
{
	_Set_Parameter(event.GetPropertyName());

	if( event.GetProperty() )
	{
		m_pPG->SelectProperty(event.GetProperty());
	}

	event.Skip();
}
Example #14
0
void DlgViewports::OnPropsChange(wxPropertyGridEvent& e) {

	nau::render::Viewport *elem = RENDERMANAGER->getViewport(m_Active).get();
	const wxString& name = e.GetPropertyName();
	unsigned int dotLocation = name.find_first_of(wxT("."),0);
	std::string topProp = std::string(name.substr(0,dotLocation).mb_str());
	std::string prop = std::string(name.substr(dotLocation+1,name.size()-dotLocation-1).mb_str());

	PropertyManager::updateProp(m_PG, topProp, Viewport::GetAttribs(), (AttributeValues *)elem);
	notifyUpdate(PROPS_CHANGED,m_Active,topProp);
}
Example #15
0
void DlgScenes::OnPropsChange( wxPropertyGridEvent& e) {

	std::shared_ptr<IScene> &scene = RENDERMANAGER->getScene(m_Active);
	const wxString& name = e.GetPropertyName();
	unsigned int dotLocation = name.find_first_of(wxT("."), 0);
	std::string topProp = std::string(name.substr(0, dotLocation).mb_str());
	std::string prop = std::string(name.substr(dotLocation + 1, name.size() - dotLocation - 1).mb_str());

	PropertyManager::updateProp(m_PG, topProp, IScene::Attribs, (AttributeValues *)scene.get());

}
Example #16
0
void Properties::onPropertyChanging(wxPropertyGridEvent& event, MapView* mapView)
{
	if (event.GetPropertyName() == "Orthographic")
	{
		mapView->setIsOrthographic(event.GetValue().GetBool());
	}
	else if (event.GetPropertyName() == "Scale")
	{
		double scale = event.GetValue().GetDouble();

		if (scale < 0.1)
		{
			scale = 0.1;
		}
		else if (scale > 10.0)
		{
			scale = 10.0;
		}

		mapView->setScale(scale);
		mapView->update();
	}
}
Example #17
0
void Properties::onPropertyChanging(wxPropertyGridEvent& event, RouteView* view)
{
	if (event.GetPropertyName() == "Segments")
	{
		unsigned short value = (unsigned short)event.GetValue().GetLong();

		if (value < view->getRoute()->getPointCount())
		{
			value = view->getRoute()->getPointCount();
		}

		view->setSegments(value);
	}
}
//-----------------------------------------------------------------------------
void EMFloat3Property::OnChange (wxPropertyGridEvent &event)
{
	wxPGProperty *prop = event.GetProperty();
	const wxString &wxName = event.GetPropertyName();
	wxVariant var = prop->GetValue();

	PX2_UNUSED(wxName);

	if (var.IsNull())
		return;

	if (mPropertyInVal == prop)
	{
		float fValue = (float)(var.GetDouble());

		mPoint->InVal = fValue;

		if (mPropertyInVal)
			mPropertyInVal->SetValue(fValue);
	}
	else if (mPropertyOutVal == prop)
	{
		if (mIsColor)
		{
			wxColor color =  wxANY_AS(var.GetAny(), wxColor);

			Float3 float3Color((float)color.Red()/255.0f, (float)color.Green()/255.0f,
				(float)color.Blue()/255.0f);

			mPoint->OutVal = float3Color;
		}
		else
		{
			mPoint->OutVal = Float3RefFromVariant(var);
		}
	}
	else if (mPropertyArriveTangent == prop)
	{
		mPoint->ArriveTangent = Float3RefFromVariant(var);
	}
	else if (mPropertyLeaveTangent == prop)
	{
		mPoint->LeaveTangent = Float3RefFromVariant(var);
	}
	else if (mInterpMode == prop)
	{
		int val = var.GetInteger();
		mPoint->InterpMode = (InterpCurveMode)val;
	}
}
Example #19
0
void
ObjectPropertyEditor::OnPropertyChanged(wxPropertyGridEvent& e)
{
    // Skip parent properties
    if (e.GetPropertyPtr()->GetParentingType() != 0)
        return;

    // Skip if no current selected object
    WX::ObjectPtr object = mCurrentObject.lock();
    if (!object)
        return;

    WX::String propertyName = AS_STRING(e.GetPropertyName());
    WX::String propertyValue = AS_STRING(e.GetPropertyValueAsString());

    WX::Variant oldValue = object->getProperty(propertyName);
    object->setPropertyAsString(propertyName, propertyValue);
    mSceneManipulator->_fireObjectPropertyChanged(object, propertyName, this);
    WX::Variant newValue = object->getProperty(propertyName);

    WX::ModifyObjectPropertyOperator* op = new WX::ModifyObjectPropertyOperator(mSceneManipulator);
    op->add(object->getName(), propertyName, oldValue, newValue);
    mSceneManipulator->getOperatorManager()->addOperator(op);

    mPropertiesViewer->Freeze();

    const WX::PropertyList& properties = object->getProperties();
    for (WX::PropertyList::const_iterator it = properties.begin(); it != properties.end(); ++it)
    {
        const WX::PropertyDef& propertyDef = *it;
        WX::uint propertyFlags = object->getPropertyFlags(propertyDef.name);
        wxPGId id = mPropertiesViewer->GetPropertyByName(propertyDef.name.c_str());
        assert(id.IsOk());
        if (!id.IsOk())
            continue;
        if (propertyFlags & WX::PF_READONLY)
        {
            if (mPropertiesViewer->IsPropertyEnabled(id))
                mPropertiesViewer->DisableProperty(id);
        }
        else
        {
            if (!mPropertiesViewer->IsPropertyEnabled(id))
                mPropertiesViewer->EnableProperty(id);
        }
    }

    mPropertiesViewer->Thaw();
}
Example #20
0
int TreeModel::OnPropertyGridChange(wxPropertyGridInterface *grid, wxPropertyGridEvent& event) {
    if (event.GetPropertyName() == "TreeStyle") {
        ModelXml->DeleteAttribute("DisplayAs");
        wxPGProperty *p = grid->GetPropertyByName("TreeDegrees");
        if (p != nullptr) {
            degrees = p->GetValue().GetLong();
        }
        switch (event.GetPropertyValue().GetLong()) {
            case 0:
                ModelXml->AddAttribute("DisplayAs", wxString::Format("Tree %d", degrees > 1 ? (int)degrees : 180));
                break;
            case 1:
                ModelXml->AddAttribute("DisplayAs", "Tree Flat");
                break;
            case 2:
                ModelXml->AddAttribute("DisplayAs", "Tree Ribbon");
                break;
        }
        SetFromXml(ModelXml, zeroBased);
        if (p != nullptr) {
            p->Enable(treeType == 0);
        }
        p = grid->GetPropertyByName("TreeRotation");
        if (p != nullptr) {
            p->Enable(treeType == 0);
        }
        return 3;
    } else if (event.GetPropertyName() == "TreeDegrees") {
        ModelXml->DeleteAttribute("DisplayAs");
        ModelXml->AddAttribute("DisplayAs", wxString::Format("Tree %d", (int)event.GetPropertyValue().GetLong()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if (event.GetPropertyName() == "TreeRotation") {
        ModelXml->DeleteAttribute("TreeRotation");
        ModelXml->AddAttribute("TreeRotation", wxString::Format("%f", (float)event.GetPropertyValue().GetDouble()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if (event.GetPropertyName() == "TreeSpiralRotations") {
        ModelXml->DeleteAttribute("TreeSpiralRotations");
        ModelXml->AddAttribute("TreeSpiralRotations", wxString::Format("%f", (float)event.GetPropertyValue().GetDouble()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if (event.GetPropertyName() == "TreeBottomTopRatio") {
        ModelXml->DeleteAttribute("TreeBottomTopRatio");
        ModelXml->AddAttribute("TreeBottomTopRatio", wxString::Format("%f", (float)event.GetPropertyValue().GetDouble()));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    } else if (event.GetPropertyName() == "TreePerspective") {
        ModelXml->DeleteAttribute("TreePerspective");
        ModelXml->AddAttribute("TreePerspective", wxString::Format("%f", (float)(event.GetPropertyValue().GetDouble()/10.0)));
        SetFromXml(ModelXml, zeroBased);
        return 3;
    }
    return MatrixModel::OnPropertyGridChange(grid, event);
}
Example #21
0
//-----------------------------------------------------------------------------
void Property::OnChange (wxPropertyGridEvent &event)
{
	wxPGProperty *property = event.GetProperty();
	const wxString &name = event.GetPropertyName();
	std::string stdName = std::string(name);
	wxAny anyValue = property->GetValue();

	if (name != wxString(mName.c_str()))
		return;

	if (!mData)
		return;

	if (mType == PT_INT)
	{
		*((int*)mData) = wxANY_AS(anyValue, int);
	}
void InitialInstancesPropgridHelper::OnPropertySelected(const std::vector<gd::InitialInstance*> & selectedInitialInstances, wxPropertyGridEvent& event)
{
    if ( grid == NULL ) return;

    if ( event.GetColumn() == 1) //Manage button-like properties
    {
        if ( selectedInitialInstances.empty() ) return;

        if ( event.GetPropertyName() ==  "INSTANCE_VARIABLES" )
        {
            gd::ChooseVariableDialog dialog(NULL, selectedInitialInstances[0]->GetVariables(), true);
            dialog.ShowModal();

            grid->SetPropertyLabel("INSTANCE_VARIABLES", _("Variables") + " ("
                + gd::String::From(selectedInitialInstances[0]->GetVariables().Count()) + ")");
        }
    }
}
void CompilersModifiedDlg::OnValueChanged(wxPropertyGridEvent& event)
{
    event.Skip();
    wxString newCompiler = event.GetProperty()->GetValueAsString();
    wxString oldCompiler = event.GetPropertyName();
    
    m_table.erase( oldCompiler );
    m_table[ oldCompiler ] = newCompiler;
    
    m_enableOKButton = true;
    wxStringMap_t::iterator iter = m_table.begin();
    for(; iter != m_table.end(); ++iter ) {
        if ( iter->second == SELECT_COMPILER ) {
            m_enableOKButton = false;
            break;
        }
    }
}
//-----------------------------------------------------------------------------
void MovableTransProperty::OnChange (wxPropertyGridEvent &event)
{
	if (!mProperty)
		return;

	wxPGProperty *id = event.GetProperty();
	const wxString &name = event.GetPropertyName();
	std::string stdName = std::string(name);
	wxVariant variant = id->GetValue();

	if (0 == id)
		return;

	if (variant.IsNull())
		return;

	APoint value;

	if (mPropertyTranslate == id)
	{
		value = APointRefFromVariant(variant);
		mTrans->SetTranslate(value);
	}
	else if (mPropertyRotation == id)
	{
		value = APointRefFromVariant(variant);
		mTrans->SetRotate(Matrix3f().MakeEulerXYZ(
			value.X(), value.Y(), value.Z()));
	}
	else if (mPropertyScale == id)
	{
		value = APointRefFromVariant(variant);
		if (value.X()!=0.0f && value.Y()!=0.0f && value.Z()!=0.0f)
		{
			mTrans->SetScale(value);
		}
	}

	Event *ent = 0;
	ent = EditEventSpace::CreateEventX(EditEventSpace::ObjectTransformChanged);
	ent->SetData<Object*>(mObject);
	EventWorld::GetSingleton().BroadcastingLocalEvent(ent);
}
/* MapObjectPropsPanel::onPropertyChanged
 * Called when a property value is changed
 *******************************************************************/
void MapObjectPropsPanel::onPropertyChanged(wxPropertyGridEvent& e)
{
	// Ignore if no auto apply
	if (no_apply || !mobj_props_auto_apply)
	{
		e.Skip();
		return;
	}

	// Find property
	string name = e.GetPropertyName();
	for (unsigned a = 0; a < properties.size(); a++)
	{
		if (properties[a]->getPropName() == name)
		{
			// Found, apply value
			theMapEditor->mapEditor().beginUndoRecordLocked("Modify Properties", true, false, false);
			properties[a]->applyValue();
			theMapEditor->mapEditor().endUndoRecord();
			return;
		}
	}
}
Example #26
0
void ChannelInspectorT::OnPropertyGridChanging(wxPropertyGridEvent& Event)
{
    if (m_ModelDoc==NULL) return;

    const ArrayT<unsigned int>& Selection=m_ModelDoc->GetSelection(CHAN);
    if (Selection.Size()!=1) return;

    // Changing a property by pressing ENTER doesn't change the selection. In consequence the property refresh below does not result in
    // any change since selected properties are not updated (because the user could be in the process of editing a value).
    // Since the user is definitely finished editing this property we can safely clear the selection.
    // ClearSelection();

    const unsigned int ChanNr  =Selection[0];
    const wxString     PropName=Event.GetPropertyName();

    m_IsRecursiveSelfNotify=true;
    bool ok=true;

    if (PropName=="Name")
    {
        ok=m_Parent->SubmitCommand(new CommandRenameT(m_ModelDoc, CHAN, ChanNr, Event.GetValue().GetString()));
    }
    else if (PropName.StartsWith("Joints."))
    {
        ok=m_Parent->SubmitCommand(new CommandUpdateChannelT(m_ModelDoc, ChanNr, Event.GetProperty()->GetIndexInParent(), Event.GetValue().GetBool()));
    }
    else
    {
        // Changing child properties (e.g. "Pos.x" to "5") also generates events for the composite parent (e.g. "Pos" to "(5, 0, 0)")!
        // That is, if the following line is uncommented, it produces false warnings as well:
        // wxMessageBox("Unknown property label \""+Name+"\".", "Warning", wxOK | wxICON_ERROR);
    }

    wxASSERT(Event.CanVeto());    // EVT_PG_CHANGING events can be vetoed (as opposed to EVT_PG_CHANGED events).
    if (!ok) Event.Veto();
    m_IsRecursiveSelfNotify=false;
}
void
FairySkillEditDialog::OnPropertyChanged(wxPropertyGridEvent& e)
{
	unsigned short numOfEffectInfos = mSkill->getNumAnimationEffectInfos();
	unsigned short numOfRibbons = mSkill->getNumAnimationRibbons();
	unsigned short numOfSounds = mSkill->getNumAnimationSounds();
    unsigned short unmOfLights = mSkill->getNumAnimationSceneLightInfos();

	// Skip parent properties
	if (e.GetPropertyPtr()->GetParentingType() != 0)
		return;

	wxPGId id = e.GetPropertyPtr()->GetId();
	wxPGId parentId = mPropertiesViewer->GetPropertyParent(id);

	WX::String propertyName = e.GetPropertyName().c_str();
	WX::String propertyValue = e.GetPropertyValueAsString().c_str();

	if (propertyName == "AttachTime")
	{
		float inputValue = Ogre::StringConverter::parseReal(propertyValue);

		float outputTime = inputValue / ( mDObject->getCurrentAnimationLength() * mFramePerSecond );

		if ( outputTime >= 1.0f )
		{
			wxMessageBox(_("Wrong parameter!"));
			return;
		}
		propertyValue = Ogre::StringConverter::toString(outputTime);
	}
	else if (propertyName == "HitTime" || propertyName == "BreakTime" || propertyName == "ShakeTime")
	{
		Ogre::StringVector valueArray = Ogre::StringUtil::split(propertyValue);

		propertyValue.clear();

		for (size_t i=0; i<valueArray.size(); ++i)
		{
			float inputValue = Ogre::StringConverter::parseReal(valueArray[i]);

			float outputTime = inputValue / ( mDObject->getCurrentAnimationLength() * mFramePerSecond );

			if ( outputTime >= 1.0f )
			{
				wxMessageBox(_("Wrong parameter!"));
				return;
			}

			propertyValue += Ogre::StringConverter::toString(outputTime);
			propertyValue += " ";
		}
	}
	
	unsigned short index = mPropertiesViewer->GetPropertyIndex(parentId);

	if ( index == 0 )
	{
		mSkill->setParameter(propertyName, propertyValue);
	}
	else if ( index > 0 && index <= numOfEffectInfos )
	{
		mSkill->getAnimationEffectInfo(index-1)->setParameter(propertyName, propertyValue);
	}
	else if ( index > numOfEffectInfos && index <= (numOfEffectInfos + numOfRibbons) )
	{
		mSkill->getAnimationRibbon(index-numOfEffectInfos-1)->setParameter(propertyName, propertyValue);
	}
	else if ( index > numOfEffectInfos + numOfRibbons && index <= (numOfEffectInfos + numOfRibbons + numOfSounds) )
	{
		mSkill->getAnimationSound(index-numOfEffectInfos-numOfRibbons-1)->setParameter(propertyName, propertyValue);
	}
    else if ( index > numOfEffectInfos + numOfRibbons + numOfSounds
        && index <= (numOfEffectInfos + numOfRibbons + numOfSounds + unmOfLights) )
    {
        mSkill->getAnimationSceneLightInfo(index-numOfEffectInfos-numOfRibbons-numOfSounds-1)->setParameter(propertyName, propertyValue);
    }

	// 更新模板
	WX::Skill *skill = WX::EffectManager::getSingleton().getSkill(mSkill->getSkillName());

	*skill = *mSkill;
}
Example #28
0
void AudioPrefsDialog::OnPGChanged(wxPropertyGridEvent& event)
{
	bug_fun();
	bug_var(event.GetPropertyName().ToStdString());
	bug_var(event.GetProperty()->GetValue().GetString().ToStdString());
}
Example #29
0
void 
DlgPass::OnProcessPGChange( wxPropertyGridEvent& e)
{
	Pass *p = getPass();

	wxString name,subname,value;
	std::string mat,lib;
	name = e.GetPropertyName();
	int index;
	index = e.GetPropertyValue().GetInteger();

	if (name == wxT("Camera")) {
		value = m_pgCamList.GetLabel(index);
		p->setCamera(std::string(value.mb_str()));	
	}
	else if (name == wxT("Viewport")) {
		if (index == 0)
			p->setViewport(RENDERMANAGER->getCamera(p->getCameraName())->getViewport());
		else {
			value = m_pgViewportList.GetLabel(index-1);
			p->setViewport(RENDERMANAGER->getViewport(std::string(value.mb_str())));
		}
	}
	else if (name == wxT("Use Render Target")) {
		p->enableRenderTarget(0 != e.GetPropertyValue().GetBool());
	}
	else if (name == wxT("Render Target")) {
		value = e.GetPropertyValue().GetString();
		if (value == wxT("None")) {
			p->setRenderTarget(NULL);
			m_PG->SetPropertyValue(wxT("Viewport"),wxT("From Camera"));
			m_PG->EnableProperty(wxT("Viewport"));
		}
		else {
			m_PG->SetPropertyValue(wxT("Viewport"), wxT("From Render Target"));
			m_PG->DisableProperty(wxT("Viewport"));
			p->setRenderTarget(RESOURCEMANAGER->getRenderTarget(std::string(value.mb_str())));
		}
	}
	//else if (name == wxT("Clear Color")) 
	//	p->setPropb(Pass::COLOR_CLEAR, (0 != e.GetPropertyValue().GetBool()));
	//else if (name == wxT("Clear Depth"))
	//	p->setPropb(Pass::DEPTH_CLEAR, (0 != e.GetPropertyValue().GetBool()));
	
	else if (name.substr(0,6) == wxT("Lights")) {

		subname = name.substr(7,std::string::npos);
		bool b = 0 != e.GetPropertyValue().GetBool();
		if (b)
			p->addLight(std::string(subname.mb_str()));
		else
			p->removeLight(std::string(subname.mb_str()));
	}
	else if (name.substr(0,6) == wxT("Scenes")) {

		subname = name.substr(7,std::string::npos);
		bool b = 0 != e.GetPropertyValue().GetBool();
		if (b)
			p->addScene(std::string(subname.mb_str()));
		else
			p->removeScene(std::string(subname.mb_str()));
	}
	else if (name.substr(0,13) == wxT("Material Maps")) { // Material Maps

		subname = name.substr(14, std::string::npos);
		if (subname == wxT("*"))
			value = m_pgMaterialListPlus.GetLabel(e.GetPropertyValue().GetInteger());
		else
			value = m_pgMaterialList.GetLabel(e.GetPropertyValue().GetInteger());
		mat = std::string(value.AfterLast(':').mb_str());
		lib = std::string(value.BeforeFirst(':').mb_str());

		if (subname == wxT("*")) {
			if (mat == "*") {
				p->remapAll(lib);
				updateMats(p);
			}
			else if (value != wxT("None")) {
				p->remapAll(lib,mat);
				updateMats(p);
			}
		}
		else
			p->remapMaterial(std::string(subname.c_str()),lib,mat);
	}
	else
		PropertyManager::updateProp(m_PG, name.ToStdString(), Pass::Attribs, (AttributeValues *)p);

	//else if (name.substr(0,10) == wxT("Parameters")) {

	//	subname = name.substr(11, std::string::npos);
	//	p->setParam(std::string(subname.mb_str()), (float)(e.GetPropertyValue().GetDouble()));
	//
	//} 
}
Example #30
0
bool ObjectsPropgridHelper::OnPropertySelected(gd::Object * object, gd::Layout * layout, wxPropertyGridEvent& event)
{
    if ( !grid || !object ) return false;

    //Check if the object is global
    bool globalObject = false;
    for (std::size_t i = 0;i<project.GetObjectsCount();++i)
    {
        if ( &project.GetObject(i) == object )
        {
            globalObject = true;
            break;
        }
    }

    if ( event.GetColumn() == 1) //Manage button-like properties
    {
        if ( event.GetPropertyName() == _("Edit") )
        {
            object->EditObject(grid, project, mainFrameWrapper);
            for ( std::size_t j = 0; j < project.GetUsedPlatforms().size();++j)
                project.GetUsedPlatforms()[j]->GetChangesNotifier().OnObjectEdited(project, globalObject ? NULL : layout, *object);

            //Reload resources : Do not forget to switch the working directory.
            wxString oldWorkingDir = wxGetCwd();
            if ( wxDirExists(wxFileName::FileName(project.GetProjectFile()).GetPath()))
                wxSetWorkingDirectory(wxFileName::FileName(project.GetProjectFile()).GetPath());

            if (layout) object->LoadResources(project, *layout);

            wxSetWorkingDirectory(oldWorkingDir);
        }
        else if ( event.GetPropertyName() == _("Help"))
        {
            auto metadata = gd::MetadataProvider::GetObjectMetadata(project.GetCurrentPlatform(),
                object->GetType());

            gd::HelpFileAccess::Get()->OpenPage(metadata.GetHelpUrl());
        }
        else if ( event.GetPropertyName() == _("Variables") )
        {
            gd::ChooseVariableDialog dialog(grid, object->GetVariables(), true);
            dialog.SetAssociatedObject(&project, layout, object);
            if ( dialog.ShowModal() == 1 )
            {
                for ( std::size_t j = 0; j < project.GetUsedPlatforms().size();++j)
                    project.GetUsedPlatforms()[j]->GetChangesNotifier().OnObjectVariablesChanged(project, globalObject ? NULL : layout, *object);

                //Update the grid:
                if ( grid->GetProperty("OBJECT_VARIABLES_CATEGORY") != NULL)
                    grid->SetPropertyLabel("OBJECT_VARIABLES_CATEGORY",
                        _("Object variables") + " (" + gd::String::From(object->GetVariables().Count()) + ")");
            }
        }
        else if ( event.GetPropertyName() == "AUTO_ADD" )
        {
            return gd::ChooseBehaviorTypeDialog::ChooseAndAddBehaviorToObject(grid, project,
                object, layout, globalObject);
        }
        else if ( event.GetPropertyName() == "AUTO_REMOVE" )
        {
            //Create behavior array
            wxArrayString behaviorsStr;

            //Fill array
            std::vector <gd::String> behaviors = object->GetAllBehaviorNames();
            for (std::size_t i = 0;i<behaviors.size();++i)
                behaviorsStr.Add(object->GetBehavior(behaviors[i]).GetName());

            int selection = wxGetSingleChoiceIndex(_("Choose the behavior to delete"), _("Choose the behavior to delete"), behaviorsStr);
            if ( selection == -1 ) return false;

            object->RemoveBehavior(behaviors[selection]);
            UpdateBehaviorsSharedData(project, globalObject ? NULL : layout);

            for ( std::size_t j = 0; j < project.GetUsedPlatforms().size();++j)
                project.GetUsedPlatforms()[j]->GetChangesNotifier().OnBehaviorDeleted(project, globalObject ? NULL : layout, *object, behaviors[selection]);

            return true;
        }
        else if ( event.GetPropertyName().substr(0,12) == "AUTO_RENAME:" )
        {
            event.Veto();
            gd::String oldName = event.GetPropertyName().substr(12);
            if ( !object->HasBehaviorNamed(oldName)) return true;

            gd::Behavior & behavior = object->GetBehavior(oldName);

            gd::String newName = wxGetTextFromUser(_("Enter a new name for the behavior"), _("Rename a behavior"), behavior.GetName());
            if ( newName == behavior.GetName() || object->HasBehaviorNamed(newName) || newName.empty() ) return false;

            object->RenameBehavior(oldName, newName);
            UpdateBehaviorsSharedData(project, globalObject ? NULL : layout);

            for ( std::size_t j = 0; j < project.GetUsedPlatforms().size();++j)
                project.GetUsedPlatforms()[j]->GetChangesNotifier().OnBehaviorRenamed(project, globalObject ? NULL : layout, *object, behavior, oldName);

            return true;
        }
        else if ( event.GetPropertyName().substr(0,5) == "AUTO:" )
        {
            event.Veto();
            gd::String autoName = event.GetPropertyName().substr(5);
            if ( !object->HasBehaviorNamed(autoName)) return true;

            gd::Behavior & behavior = object->GetBehavior(autoName);

            behavior.EditBehavior(grid, project, layout, mainFrameWrapper); //EditBehavior always need a valid layout!
            for ( std::size_t j = 0; j < project.GetUsedPlatforms().size();++j)
                project.GetUsedPlatforms()[j]->GetChangesNotifier().OnBehaviorEdited(project, globalObject ? NULL : layout, *object, behavior);
        }
    }

    return false;
}