本文整理汇总了C++中gd::Project::GetCurrentPlatform方法的典型用法代码示例。如果您正苦于以下问题:C++ Project::GetCurrentPlatform方法的具体用法?C++ Project::GetCurrentPlatform怎么用?C++ Project::GetCurrentPlatform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Project
的用法示例。
在下文中一共展示了Project::GetCurrentPlatform方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
}
示例2: ChooseAndAddBehaviorToObject
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;
}
示例3: if
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
{
//.........这里部分代码省略.........
示例4: LaunchResourceWorkerOnEvents
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;
}
示例5: wxFlexGridSizer
//.........这里部分代码省略.........
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));
}