void EventsListSerialization::UpdateInstructionsFromGD31x(gd::Project & project, std::vector < gd::Instruction > & list, bool instructionsAreActions) { for (unsigned int i = 0;i<list.size();++i) { gd::Instruction & instr = list[i]; const gd::InstructionMetadata & metadata = instructionsAreActions ? MetadataProvider::GetActionMetadata(project.GetCurrentPlatform(), instr.GetType()) : MetadataProvider::GetConditionMetadata(project.GetCurrentPlatform(), instr.GetType()); if (instr.GetType() == "VarScene" || instr.GetType() == "VarSceneTxt" || instr.GetType() == "VarGlobal" || instr.GetType() == "VarGlobalTxt" || instr.GetType() == "ModVarScene" || instr.GetType() == "ModVarSceneTxt" || instr.GetType() == "ModVarGlobal" || instr.GetType() == "ModVarGlobalTxt" ) { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 1 ) parameters.erase(parameters.begin()+0); instr.SetParameters(parameters); } if (instr.GetType() == "VarSceneDef" || instr.GetType() == "VarGlobalDef" || instr.GetType() == "VarObjetDef" ) { instr.SetParameter(1, gd::Expression("\""+instr.GetParameter(1).GetPlainString()+"\"")); } //UpdateInstructionsFromGD31x(project, instr.GetSubInstructions(), instructionsAreActions); } }
bool ChooseBehaviorTypeDialog::ChooseAndAddBehaviorToObject(wxWindow * parent, gd::Project & project, gd::Object * object, gd::Layout * layout, bool isGlobalObject) { gd::ChooseBehaviorTypeDialog dialog(parent, project); if ( dialog.ShowModal() == 1) { //Find behavior metadata std::shared_ptr<gd::PlatformExtension> extension = std::shared_ptr<gd::PlatformExtension> (); std::vector < std::shared_ptr<gd::PlatformExtension> > extensions = project.GetCurrentPlatform().GetAllPlatformExtensions(); for (std::size_t i = 0;i<extensions.size();++i) { std::vector<gd::String> behaviorsTypes = extensions[i]->GetBehaviorsTypes(); if ( find(behaviorsTypes.begin(), behaviorsTypes.end(), dialog.GetSelectedBehaviorType()) != behaviorsTypes.end() ) extension = extensions[i]; } gd::BehaviorMetadata metadata = extension->GetBehaviorMetadata(dialog.GetSelectedBehaviorType()); //Add behavior to object gd::String autoName = metadata.GetDefaultName(); for (std::size_t j = 2;object->HasBehaviorNamed(autoName);++j) autoName = metadata.GetDefaultName()+gd::String::From(j); object->AddNewBehavior(project, dialog.GetSelectedBehaviorType(), autoName); //Let the scene know about the new behavior if ( isGlobalObject && layout ) layout->UpdateBehaviorsSharedData(project); else //Scene pointer is NULL: Update shared data of all layouts { for (std::size_t i = 0;i<project.GetLayoutsCount();++i) project.GetLayout(i).UpdateBehaviorsSharedData(project); } for (std::size_t j = 0; j < project.GetUsedPlatforms().size();++j) project.GetUsedPlatforms()[j]->GetChangesNotifier().OnBehaviorAdded(project, isGlobalObject ? NULL : layout, *object, object->GetBehavior(autoName)); return true; } return false; }
void EventsListSerialization::UpdateInstructionsFromGD2x(gd::Project & project, std::vector < gd::Instruction > & list, bool instructionsAreActions) { for (unsigned int i = 0;i<list.size();++i) { gd::Instruction & instr = list[i]; const gd::InstructionMetadata & metadata = instructionsAreActions ? MetadataProvider::GetActionMetadata(project.GetCurrentPlatform(), instr.GetType()) : MetadataProvider::GetConditionMetadata(project.GetCurrentPlatform(), instr.GetType()); //Specific updates for some instructions if ( instr.GetType() == "LinkedObjects::LinkObjects" || instr.GetType() == "LinkedObjects::RemoveLinkBetween" ) { instr.SetParameter(1, instr.GetParameter(3)); instr.SetParameter(2, instr.GetParameter(4)); } else if (instr.GetType() == "LinkedObjects::RemoveAllLinksOf") { instr.SetParameter(1, instr.GetParameter(2)); } else if (instr.GetType() == "LinkedObjects::PickObjectsLinkedTo") { instr.SetParameter(1, instr.GetParameter(5)); instr.SetParameter(2, instr.GetParameter(3)); } else if (instr.GetType() == "PhysicsAutomatism::AddRevoluteJointBetweenObjects") { instr.SetParameter(4, instr.GetParameter(5)); instr.SetParameter(5, instr.GetParameter(6)); } else if (instr.GetType() == "PhysicsAutomatism::AddRevoluteJointBetweenObjects") { instr.SetParameter(4, instr.GetParameter(5)); instr.SetParameter(5, instr.GetParameter(6)); } else if (instr.GetType() == "FixCamera" || instr.GetType() == "CentreCamera") { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2); instr.SetParameters(parameters); } else if (instr.GetType() == "AjoutObjConcern" || instr.GetType() == "AjoutHasard") { instr.SetParameter(1, instr.GetParameter(3)); } else if (instr.GetType() == "SeDirige" || instr.GetType() == "EstTourne" ) { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2); if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2); instr.SetParameters(parameters); } else if (instr.GetType() == "Create") { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1); if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1); instr.SetParameters(parameters); } else if (instr.GetType() == "CreateByName") { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1); instr.SetParameters(parameters); } else if (instr.GetType() == "NbObjet") { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 2 ) parameters.erase(parameters.begin()+1); instr.SetParameters(parameters); } else if (instr.GetType() == "Distance") { std::vector< gd::Expression > parameters = instr.GetParameters(); if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2); if ( parameters.size() >= 3 ) parameters.erase(parameters.begin()+2); if ( parameters.size() >= 4 && (parameters[3].GetPlainString() == ">=" || parameters[3].GetPlainString() == ">") ) { instr.SetInverted(true); } else { instr.SetInverted(false); } instr.SetParameters(parameters); } //Common updates for some parameters const std::vector< gd::Expression > & parameters = instr.GetParameters(); for (unsigned int j = 0;j<parameters.size() && j<metadata.parameters.size();++j) { if ( metadata.parameters[j].type == "relationalOperator" || metadata.parameters[j].type == "operator" ) { if ( j == parameters.size()-1 ) { std::cout << "ERROR: No more parameters after a [relational]operator when trying to update an instruction from GD2.x"; } else { //Exchange parameters std::string op = parameters[j+1].GetPlainString(); instr.SetParameter(j+1, parameters[j] ); instr.SetParameter(j, gd::Expression(op)); } } } //UpdateInstructionsFromGD2x(project, instr.GetSubInstructions(), instructionsAreActions); } }
void LaunchResourceWorkerOnEvents(const gd::Project & project, gd::EventsList & events, gd::ArbitraryResourceWorker & worker) { //Get all extensions used std::vector< std::shared_ptr<gd::PlatformExtension> > allGameExtensions; std::vector<gd::String> usedExtensions = project.GetUsedExtensions(); for (std::size_t i = 0;i<usedExtensions.size();++i) { std::shared_ptr<gd::PlatformExtension> extension = project.GetCurrentPlatform().GetExtension(usedExtensions[i]); if ( extension != std::shared_ptr<gd::PlatformExtension>() ) allGameExtensions.push_back(extension); } for ( std::size_t j = 0;j < events.size() ;j++ ) { vector < gd::InstructionsList* > allActionsVectors = events[j].GetAllActionsVectors(); for (std::size_t i = 0;i<allActionsVectors.size();++i) { for ( std::size_t k = 0;k < allActionsVectors[i]->size() ;k++ ) { gd::String type = allActionsVectors[i]->Get( k ).GetType(); for (std::size_t e = 0;e<allGameExtensions.size();++e) { bool extensionHasAction = false; const std::map<gd::String, gd::InstructionMetadata> & allActions = allGameExtensions[e]->GetAllActions(); if ( allActions.find(type) != allActions.end() ) extensionHasAction = true; const vector < gd::String > & objects = allGameExtensions[e]->GetExtensionObjectsTypes(); for (std::size_t o = 0;o<objects.size();++o) { const std::map<gd::String, gd::InstructionMetadata> & allObjectsActions = allGameExtensions[e]->GetAllActionsForObject(objects[o]); if ( allObjectsActions.find(type) != allObjectsActions.end() ) extensionHasAction = true; } const vector < gd::String > & autos = allGameExtensions[e]->GetBehaviorsTypes(); for (std::size_t a = 0;a<autos.size();++a) { const std::map<gd::String, gd::InstructionMetadata> & allAutosActions = allGameExtensions[e]->GetAllActionsForBehavior(autos[a]); if ( allAutosActions.find(type) != allAutosActions.end() ) extensionHasAction = true; } if ( extensionHasAction ) { allGameExtensions[e]->ExposeActionsResources(allActionsVectors[i]->Get( k ), worker); break; } } } } vector < gd::InstructionsList* > allConditionsVector = events[j].GetAllConditionsVectors(); for (std::size_t i = 0;i<allConditionsVector.size();++i) { for ( std::size_t k = 0;k < allConditionsVector[i]->size() ;k++ ) { gd::String type = allConditionsVector[i]->Get( k ).GetType(); for (std::size_t e = 0;e<allGameExtensions.size();++e) { bool extensionHasCondition = false; const std::map<gd::String, gd::InstructionMetadata> & allConditions = allGameExtensions[e]->GetAllConditions(); if ( allConditions.find(type) != allConditions.end() ) extensionHasCondition = true; const vector < gd::String > & objects = allGameExtensions[e]->GetExtensionObjectsTypes(); for (std::size_t j = 0;j<objects.size();++j) { const std::map<gd::String, gd::InstructionMetadata> & allObjectsConditions = allGameExtensions[e]->GetAllConditionsForObject(objects[j]); if ( allObjectsConditions.find(type) != allObjectsConditions.end() ) extensionHasCondition = true; } const vector < gd::String > & autos = allGameExtensions[e]->GetBehaviorsTypes(); for (std::size_t j = 0;j<autos.size();++j) { const std::map<gd::String, gd::InstructionMetadata> & allAutosConditions = allGameExtensions[e]->GetAllConditionsForBehavior(autos[j]); if ( allAutosConditions.find(type) != allAutosConditions.end() ) extensionHasCondition = true; } if ( extensionHasCondition ) allGameExtensions[e]->ExposeConditionsResources(allConditionsVector[i]->Get( k ), worker); } } } if ( events[j].CanHaveSubEvents() ) LaunchResourceWorkerOnEvents(project, events[j].GetSubEvents(), worker); } return; }
PhysicsBehaviorEditor::PhysicsBehaviorEditor(wxWindow* parent, gd::Project & game_, gd::Layout * scene_, PhysicsBehavior & behavior_, gd::MainFrameWrapper & mainFrameWrapper_ ) : behavior(behavior_), game(game_), scene(scene_) { //(*Initialize(PhysicsBehaviorEditor) wxStaticBoxSizer* StaticBoxSizer2; wxFlexGridSizer* FlexGridSizer4; wxFlexGridSizer* FlexGridSizer10; wxFlexGridSizer* FlexGridSizer3; wxFlexGridSizer* FlexGridSizer5; wxFlexGridSizer* FlexGridSizer9; wxFlexGridSizer* FlexGridSizer2; wxFlexGridSizer* FlexGridSizer7; wxFlexGridSizer* FlexGridSizer8; wxBoxSizer* BoxSizer1; wxFlexGridSizer* FlexGridSizer13; wxFlexGridSizer* FlexGridSizer12; wxFlexGridSizer* FlexGridSizer6; wxStaticBoxSizer* StaticBoxSizer1; wxFlexGridSizer* FlexGridSizer1; wxFlexGridSizer* FlexGridSizer11; Create(parent, wxID_ANY, _("Edit the behavior"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY")); FlexGridSizer1 = new wxFlexGridSizer(0, 1, 0, 0); StaticBoxSizer1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Initial parameters")); FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0); FlexGridSizer2->AddGrowableCol(0); FlexGridSizer5 = new wxFlexGridSizer(0, 1, 0, 0); FlexGridSizer5->AddGrowableCol(0); StaticText11 = new wxStaticText(this, ID_STATICTEXT11, _("Shape of the collision mask"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT11")); FlexGridSizer5->Add(StaticText11, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer13 = new wxFlexGridSizer(0, 4, 0, 0); rectCheck = new wxRadioButton(this, ID_RADIOBUTTON1, _("Rectangle"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP, wxDefaultValidator, _T("ID_RADIOBUTTON1")); rectCheck->SetValue(true); FlexGridSizer13->Add(rectCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); circleCheck = new wxRadioButton(this, ID_RADIOBUTTON2, _("Circle"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON2")); FlexGridSizer13->Add(circleCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); polygonCheck = new wxRadioButton(this, ID_RADIOBUTTON3, _("Custom polygon"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_RADIOBUTTON3")); FlexGridSizer13->Add(polygonCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); polygonBt = new wxButton(this, ID_BUTTON3, _("Setup the shape..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON3")); FlexGridSizer13->Add(polygonBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer5->Add(FlexGridSizer13, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer5, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer11 = new wxFlexGridSizer(0, 3, 0, 0); staticCheck = new wxCheckBox(this, ID_CHECKBOX1, _("Static object"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1")); staticCheck->SetValue(false); FlexGridSizer11->Add(staticCheck, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); fixedRotationCheck = new wxCheckBox(this, ID_CHECKBOX3, _("Fixed rotation"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX3")); fixedRotationCheck->SetValue(false); FlexGridSizer11->Add(fixedRotationCheck, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer11, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); bulletCheck = new wxCheckBox(this, ID_CHECKBOX2, _("Comparable to a projectile (better collision handling, but slower)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX2")); bulletCheck->SetValue(false); FlexGridSizer2->Add(bulletCheck, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer7 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer7->AddGrowableCol(1); StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Mass density :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1")); FlexGridSizer7->Add(StaticText1, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); massDensityEdit = new wxTextCtrl(this, ID_TEXTCTRL1, _("1"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1")); FlexGridSizer7->Add(massDensityEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer7, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer8 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer8->AddGrowableCol(1); StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Friction :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2")); FlexGridSizer8->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); frictionEdit = new wxTextCtrl(this, ID_TEXTCTRL2, _("0.8"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2")); FlexGridSizer8->Add(frictionEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer8, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer12 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer12->AddGrowableCol(1); StaticText12 = new wxStaticText(this, ID_STATICTEXT12, _("Restitution ( Elasticity ) :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT12")); FlexGridSizer12->Add(StaticText12, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); restitutionEdit = new wxTextCtrl(this, ID_TEXTCTRL9, _("0"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL9")); FlexGridSizer12->Add(restitutionEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer12, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer9 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer9->AddGrowableCol(1); StaticText9 = new wxStaticText(this, ID_STATICTEXT9, _("Linear damping :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT9")); FlexGridSizer9->Add(StaticText9, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); linearDampingEdit = new wxTextCtrl(this, ID_TEXTCTRL7, _("0.1"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL7")); FlexGridSizer9->Add(linearDampingEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer9, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer10 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer10->AddGrowableCol(1); StaticText10 = new wxStaticText(this, ID_STATICTEXT10, _("Angular damping :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT10")); FlexGridSizer10->Add(StaticText10, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); angularDampingEdit = new wxTextCtrl(this, ID_TEXTCTRL8, _("0.1"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL8")); FlexGridSizer10->Add(angularDampingEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer2->Add(FlexGridSizer10, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); StaticBoxSizer1->Add(FlexGridSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer1->Add(StaticBoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticBoxSizer2 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Global parameters of physics engine")); FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0); FlexGridSizer4->AddGrowableCol(0); StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Gravity coordinates :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3")); FlexGridSizer4->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); BoxSizer1 = new wxBoxSizer(wxHORIZONTAL); gravityXEdit = new wxTextCtrl(this, ID_TEXTCTRL3, _("0"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL3")); BoxSizer1->Add(gravityXEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _(";"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4")); BoxSizer1->Add(StaticText4, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); gravityYEdit = new wxTextCtrl(this, ID_TEXTCTRL4, _("0"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL4")); BoxSizer1->Add(gravityYEdit, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer4->Add(BoxSizer1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); StaticText5 = new wxStaticText(this, ID_STATICTEXT5, _("Scale of the virtual world :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5")); FlexGridSizer4->Add(StaticText5, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer6 = new wxFlexGridSizer(0, 5, 0, 0); StaticText7 = new wxStaticText(this, ID_STATICTEXT7, _("1meter ="), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7")); FlexGridSizer6->Add(StaticText7, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); scaleXEdit = new wxTextCtrl(this, ID_TEXTCTRL5, _("0"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL5")); FlexGridSizer6->Add(scaleXEdit, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticText6 = new wxStaticText(this, ID_STATICTEXT6, _("( X axis );"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6")); FlexGridSizer6->Add(StaticText6, 1, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); scaleYEdit = new wxTextCtrl(this, ID_TEXTCTRL6, _("0"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL6")); FlexGridSizer6->Add(scaleYEdit, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticText8 = new wxStaticText(this, ID_STATICTEXT8, _("( Y axis )"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT8")); FlexGridSizer6->Add(StaticText8, 1, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer4->Add(FlexGridSizer6, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); StaticBoxSizer2->Add(FlexGridSizer4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer1->Add(StaticBoxSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticLine1 = new wxStaticLine(this, ID_STATICLINE1, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE1")); FlexGridSizer1->Add(StaticLine1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer3 = new wxFlexGridSizer(0, 3, 0, 0); okBt = new wxButton(this, ID_BUTTON1, _("Ok"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1")); FlexGridSizer3->Add(okBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); cancelBt = new wxButton(this, ID_BUTTON2, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2")); FlexGridSizer3->Add(cancelBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer1->Add(FlexGridSizer3, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0); SetSizer(FlexGridSizer1); FlexGridSizer1->Fit(this); FlexGridSizer1->SetSizeHints(this); Connect(ID_RADIOBUTTON1,wxEVT_COMMAND_RADIOBUTTON_SELECTED,(wxObjectEventFunction)&PhysicsBehaviorEditor::OnrectCheckSelect); Connect(ID_RADIOBUTTON2,wxEVT_COMMAND_RADIOBUTTON_SELECTED,(wxObjectEventFunction)&PhysicsBehaviorEditor::OncircleCheckSelect); Connect(ID_RADIOBUTTON3,wxEVT_COMMAND_RADIOBUTTON_SELECTED,(wxObjectEventFunction)&PhysicsBehaviorEditor::OnpolygonCheckSelect); Connect(ID_BUTTON3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PhysicsBehaviorEditor::OnpolygonBtClick); Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PhysicsBehaviorEditor::OnokBtClick); Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PhysicsBehaviorEditor::OncancelBtClick); //*) //Setup object datas rectCheck->SetValue(behavior.shapeType == PhysicsBehavior::Box); circleCheck->SetValue(behavior.shapeType == PhysicsBehavior::Circle); polygonCheck->SetValue(behavior.shapeType == PhysicsBehavior::CustomPolygon); polygonBt->Enable(polygonCheck->GetValue()); coordsVector = behavior.GetPolygonCoords(); positioning = behavior.polygonPositioning; polygonHeight = behavior.polygonHeight; polygonWidth = behavior.polygonWidth; automaticResizing = behavior.HasAutomaticResizing(); staticCheck->SetValue(!behavior.dynamic); fixedRotationCheck->SetValue(behavior.fixedRotation); massDensityEdit->SetValue(gd::String::From(behavior.massDensity)); bulletCheck->SetValue(behavior.isBullet); frictionEdit->SetValue(gd::String::From(behavior.averageFriction)); restitutionEdit->SetValue(gd::String::From(behavior.averageRestitution)); linearDampingEdit->SetValue(gd::String::From(behavior.linearDamping)); angularDampingEdit->SetValue(gd::String::From(behavior.angularDamping)); if ( game_.GetCurrentPlatform().GetName() == "GDevelop JS platform" ) { polygonCheck->Hide(); polygonBt->Hide(); } //Setup shared datas if ( !scene || scene->behaviorsInitialSharedDatas.find(behavior.GetName()) == scene->behaviorsInitialSharedDatas.end()) { gd::LogError(_("Unable to access to shared datas.")); return; } sharedDatas = std::dynamic_pointer_cast<ScenePhysicsDatas>(scene->behaviorsInitialSharedDatas[behavior.GetName()]); if ( sharedDatas == std::shared_ptr<ScenePhysicsDatas>() ) { gd::LogError(_("Unable to access to shared datas : Bad data type.")); return; } gravityXEdit->SetValue(gd::String::From(sharedDatas->gravityX)); gravityYEdit->SetValue(gd::String::From(sharedDatas->gravityY)); scaleXEdit->SetValue(gd::String::From(sharedDatas->scaleX)); scaleYEdit->SetValue(gd::String::From(sharedDatas->scaleY)); }