Exemplo n.º 1
0
void ExternalEvents::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("name", name);
    element.SetAttribute("associatedLayout", associatedScene);
    element.SetAttribute("lastChangeTimeStamp", (int)lastChangeTimeStamp);
    gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
}
Exemplo n.º 2
0
void AnalyticsSender::SendData(gd::String collection, SerializerElement & data)
{
    #if !defined(GD_NO_WX_GUI)
    //Check if we are allowed to send these data.
    bool sendInfo;
    wxConfigBase::Get()->Read("/Startup/SendInfo", &sendInfo, true);
    if (!sendInfo) return;

    data.SetAttribute("gdVersion", VersionWrapper::FullString());
    data.SetAttribute("os", gd::String(wxGetOsDescription()));
    data.SetAttribute("lang",
        gd::String(wxLocale::GetLanguageCanonicalName(LocaleManager::Get()->GetLanguage())));
    if (wxConfig::Get())
        data.SetAttribute("openingCount", wxConfig::Get()->ReadDouble("Startup/OpeningCount", 0));

    // Create request
    std::cout << "Sending analytics data..."; std::cout.flush();
    sf::Http Http;
    Http.setHost("http://api.keen.io");
    sf::Http::Request request;
    request.setMethod(sf::Http::Request::Post);
    request.setField("Content-Type", "application/json");
    request.setUri("/3.0/projects/"+projectId.ToLocale()+"/events/"+collection.ToLocale()+"?api_key="+writeKey.ToLocale());
    request.setBody(Serializer::ToJSON(data).ToSfString());

    // Send the request
    sf::Http::Response response = Http.sendRequest(request, sf::seconds(2));
    std::cout << "done (" << response.getStatus() << ")" << std::endl;
    #endif
}
Exemplo n.º 3
0
Arquivo: Layer.cpp Projeto: 4ian/GD
void Layer::SerializeTo(SerializerElement& element) const {
  element.SetAttribute("name", GetName());
  element.SetAttribute("visibility", GetVisibility());

  SerializerElement& camerasElement = element.AddChild("cameras");
  camerasElement.ConsiderAsArrayOf("camera");
  for (std::size_t c = 0; c < GetCameraCount(); ++c) {
    SerializerElement& cameraElement = camerasElement.AddChild("camera");
    cameraElement.SetAttribute("defaultSize", GetCamera(c).UseDefaultSize());
    cameraElement.SetAttribute("width", GetCamera(c).GetWidth());
    cameraElement.SetAttribute("height", GetCamera(c).GetHeight());

    cameraElement.SetAttribute("defaultViewport",
                               GetCamera(c).UseDefaultViewport());
    cameraElement.SetAttribute("viewportLeft", GetCamera(c).GetViewportX1());
    cameraElement.SetAttribute("viewportTop", GetCamera(c).GetViewportY1());
    cameraElement.SetAttribute("viewportRight", GetCamera(c).GetViewportX2());
    cameraElement.SetAttribute("viewportBottom", GetCamera(c).GetViewportY2());
  }

  SerializerElement& effectsElement = element.AddChild("effects");
  effectsElement.ConsiderAsArrayOf("effect");
  for (std::size_t i = 0; i < GetEffectsCount(); ++i) {
    SerializerElement& effectElement = effectsElement.AddChild("effect");
    GetEffect(i).SerializeTo(effectElement);
  }
}
Exemplo n.º 4
0
void ImageResource::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("alwaysLoaded", alwaysLoaded);
    element.SetAttribute("smoothed", smooth);
    element.SetAttribute("userAdded", IsUserAdded());
    element.SetAttribute("file", GetFile());
}
Exemplo n.º 5
0
std::vector<Splitter::SplitElement> Splitter::Split(
    SerializerElement& element,
    const std::set<gd::String>& tags,
    gd::String path) {
  std::vector<Splitter::SplitElement> elements;
  for (auto& child : element.GetAllChildren()) {
    auto& childElement = child.second;
    gd::String ref = path + pathSeparator + child.first;

    if (tags.find(ref) != tags.end()) {
      gd::String refName = childElement->GetStringAttribute(nameAttribute);
      SplitElement splitElement = {ref, refName, *childElement};
      elements.push_back(splitElement);

      SerializerElement refElement;
      refElement.SetAttribute("referenceTo", ref);
      refElement.SetAttribute("name", refName);
      *childElement = refElement;
    } else {
      auto newElements = Split(*childElement, tags, ref);
      elements.insert(elements.end(), newElements.begin(), newElements.end());
    }
  }

  return elements;
}
Exemplo n.º 6
0
void ImageResource::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("alwaysLoaded", alwaysLoaded);
    element.SetAttribute("smoothed", smooth);
    element.SetAttribute("userAdded", IsUserAdded());
    element.SetAttribute("file", GetFile()); //Keep the resource path in the current locale (but save it in UTF8 for compatibility on other OSes)
}
Exemplo n.º 7
0
void ExternalLayout::SerializeTo(SerializerElement & element) const
{
	element.SetAttribute("name", name);
	instances.SerializeTo(element.AddChild("instances"));
	#if !defined(GD_NO_WX_GUI)
	editionSettings.SerializeTo(element.AddChild("editionSettings"));
	element.SetAttribute("associatedLayout", associatedLayout);
	#endif
}
Exemplo n.º 8
0
void AnalyticsSender::SendNewGameCreated(gd::String platformName, gd::String templateName)
{
    #if !defined(GD_NO_WX_GUI)
    wxFileName templateFile = wxFileName::FileName(templateName);
    templateFile.MakeRelativeTo();

    SerializerElement data;
    data.SetAttribute("platform", platformName);
    data.SetAttribute("templateName", gd::String(templateFile.GetFullPath(wxPATH_UNIX)));
    SendData("new_game_creation", data);
    #endif
}
Exemplo n.º 9
0
void GroupEvent::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("name", name);
    element.SetAttribute("source", source);
    element.SetAttribute("creationTime", (int)creationTime);
    element.SetAttribute("colorR", (int)colorR);
    element.SetAttribute("colorG", (int)colorG);
    element.SetAttribute("colorB", (int)colorB);
    gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));

    gd::SerializerElement & parametersElement = element.AddChild("parameters");
    parametersElement.ConsiderAsArrayOf("parameter");
    for ( std::size_t i = 0;i < parameters.size();++i)
        parametersElement.AddChild("parameter").SetValue(parameters[i]);
}
Exemplo n.º 10
0
void EventsFunctionsExtension::SerializeTo(SerializerElement& element) const {
  element.SetAttribute("version", version);
  element.SetAttribute("extensionNamespace", extensionNamespace);
  element.SetAttribute("description", description);
  element.SetAttribute("name", name);
  element.SetAttribute("fullName", fullName);

  gd::SerializerElement& eventsFunctionsElement =
      element.AddChild("eventsFunctions");
  eventsFunctionsElement.ConsiderAsArrayOf("eventsFunction");
  for (const auto& eventsFunction : eventsFunctions) {
    eventsFunction->SerializeTo(
        eventsFunctionsElement.AddChild("eventsFunction"));
  }
}
Exemplo n.º 11
0
void WhileEvent::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("infiniteLoopWarning", infiniteLoopWarning);
    gd::EventsListSerialization::SaveConditions(whileConditions, element.AddChild("whileConditions"));
    gd::EventsListSerialization::SaveConditions(conditions, element.AddChild("conditions"));
    gd::EventsListSerialization::SaveActions(actions, element.AddChild("actions"));
    gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));
}
Exemplo n.º 12
0
void LayoutEditorCanvasOptions::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute( "grid", grid);
    element.SetAttribute( "snap", snap);
    element.SetAttribute( "gridWidth", gridWidth );
    element.SetAttribute( "gridHeight", gridHeight );
    element.SetAttribute( "gridOffsetX", gridOffsetX );
    element.SetAttribute( "gridOffsetY", gridOffsetY );
    element.SetAttribute( "gridR", gridR );
    element.SetAttribute( "gridG", gridG );
    element.SetAttribute( "gridB", gridB );
    element.SetAttribute( "zoomFactor", zoomFactor );
    element.SetAttribute( "windowMask", windowMask);
    element.SetAttribute( "associatedLayout", associatedLayout);
}
Exemplo n.º 13
0
void ResourceFolder::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("name", name);

    SerializerElement & resourcesElement = element.AddChild("resources");
    resourcesElement.ConsiderAsArrayOf("resource");
    for (std::size_t i = 0;i<resources.size();++i)
    {
        if ( resources[i] == std::shared_ptr<Resource>() ) continue;
        resourcesElement.AddChild("resource").SetAttribute("name", resources[i]->GetName());
    }
}
Exemplo n.º 14
0
void Variable::SerializeTo(SerializerElement & element) const
{
    if (!isStructure)
        element.SetAttribute("value", GetString());
    else
    {
        SerializerElement & childrenElement = element.AddChild("children");
        childrenElement.ConsiderAsArrayOf("variable");
        for (std::map<std::string, gd::Variable>::iterator i = children.begin(); i != children.end(); ++i)
        {
            SerializerElement & variableElement = childrenElement.AddChild("variable");
            variableElement.SetAttribute("name", i->first);
            i->second.SerializeTo(variableElement);
        }
    }
}
Exemplo n.º 15
0
void Object::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute( "name", GetName() );
    element.SetAttribute( "type", GetType() );
    objectVariables.SerializeTo(element.AddChild("variables"));

    SerializerElement & behaviorsElement = element.AddChild("behaviors");
    behaviorsElement.ConsiderAsArrayOf("behavior");
    std::vector < gd::String > allBehaviors = GetAllBehaviorNames();
    for (std::size_t i = 0;i<allBehaviors.size();++i)
    {
        SerializerElement & behaviorElement = behaviorsElement.AddChild("behavior");

        behaviorElement.SetAttribute( "type", GetBehavior(allBehaviors[i]).GetTypeName() );
        behaviorElement.SetAttribute( "name", GetBehavior(allBehaviors[i]).GetName() );
        GetBehavior(allBehaviors[i]).SerializeTo(behaviorElement);
    }

    DoSerializeTo(element);
}
Exemplo n.º 16
0
void Layout::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute( "name", GetName());
    element.SetAttribute( "mangledName", GetMangledName());
    element.SetAttribute( "r", (int)GetBackgroundColorRed() );
    element.SetAttribute( "v", (int)GetBackgroundColorGreen() );
    element.SetAttribute( "b", (int)GetBackgroundColorBlue() );
    element.SetAttribute( "title", GetWindowDefaultTitle());
    element.SetAttribute( "oglFOV", oglFOV );
    element.SetAttribute( "oglZNear", oglZNear );
    element.SetAttribute( "oglZFar", oglZFar );
    element.SetAttribute( "standardSortMethod", standardSortMethod);
    element.SetAttribute( "stopSoundsOnStartup", stopSoundsOnStartup);
    element.SetAttribute( "disableInputWhenNotFocused", disableInputWhenNotFocused);

    #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
    GetAssociatedLayoutEditorCanvasOptions().SerializeTo(element.AddChild("uiSettings"));
    #endif

    ObjectGroup::SerializeTo(GetObjectGroups(), element.AddChild("objectsGroups"));
    GetVariables().SerializeTo(element.AddChild("variables"));
    GetInitialInstances().SerializeTo(element.AddChild("instances"));
    SerializeObjectsTo(element.AddChild("objects"));
    gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));

    SerializerElement & layersElement = element.AddChild("layers");
    layersElement.ConsiderAsArrayOf("layer");
    for ( std::size_t j = 0;j < GetLayersCount();++j )
        GetLayer(j).SerializeTo(layersElement.AddChild("layer"));

    SerializerElement & behaviorDatasElement = element.AddChild("behaviorsSharedData");
    behaviorDatasElement.ConsiderAsArrayOf("behaviorSharedData");
    for (std::map<gd::String, std::shared_ptr<gd::BehaviorsSharedData> >::const_iterator it = behaviorsInitialSharedDatas.begin();
         it != behaviorsInitialSharedDatas.end();++it)
    {
        SerializerElement & dataElement = behaviorDatasElement.AddChild("behaviorSharedData");

        dataElement.SetAttribute("type", it->second->GetTypeName());
        dataElement.SetAttribute("name", it->second->GetName());
        it->second->SerializeTo(dataElement);
    }
}
Exemplo n.º 17
0
void SourceFile::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute("filename", filename);
    element.SetAttribute("language", language);
    element.SetAttribute("gdManaged", gdManaged);
}