mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00

* Tilemaps made with [LDtk](https://ldtk.io/), a modern 2D level editor, can be now used directly. Make sure to save your map made in LDtk as a JSON file, create a new Tilemap object in GDevelop and in the Tilemap field, choose the LDtk file. * Tilesets used by the LDtk Tilemap are automatically imported in your game - you don't need to import them separately. * For more information, read about the [Tilemap object on the wiki](https://wiki.gdevelop.io/gdevelop5/objects/tilemap). Co-authored-by: Davy Hélard <davy.helard@gmail.com> Co-authored-by: Florian Rival <Florian.Rival@gmail.com>
79 lines
2.5 KiB
C++
79 lines
2.5 KiB
C++
/**
|
|
|
|
GDevelop - Text Object Extension
|
|
Copyright (c) 2008-2016 Florian Rival (Florian.Rival@gmail.com)
|
|
This project is released under the MIT License.
|
|
*/
|
|
|
|
#include "GDCore/Tools/Localization.h"
|
|
#include "GDCore/CommonTools.h"
|
|
#include "GDCore/Project/InitialInstance.h"
|
|
#include "GDCore/Project/Object.h"
|
|
#include "GDCore/Serialization/SerializerElement.h"
|
|
#include "TextObject.h"
|
|
|
|
#if defined(GD_IDE_ONLY)
|
|
#include "GDCore/IDE/AbstractFileSystem.h"
|
|
#include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
|
|
#endif
|
|
|
|
using namespace std;
|
|
|
|
TextObject::TextObject()
|
|
: text("Text"),
|
|
characterSize(20),
|
|
fontName(""),
|
|
smoothed(true),
|
|
bold(false),
|
|
italic(false),
|
|
underlined(false),
|
|
colorR(0),
|
|
colorG(0),
|
|
colorB(0),
|
|
textAlignment("left")
|
|
{
|
|
}
|
|
|
|
TextObject::~TextObject(){};
|
|
|
|
void TextObject::DoUnserializeFrom(gd::Project& project,
|
|
const gd::SerializerElement& element) {
|
|
SetString(element.GetChild("string", 0, "String").GetValue().GetString());
|
|
SetFontName(element.GetChild("font", 0, "Font").GetValue().GetString());
|
|
SetTextAlignment(element.GetChild("textAlignment").GetValue().GetString());
|
|
SetCharacterSize(element.GetChild("characterSize", 0, "CharacterSize")
|
|
.GetValue()
|
|
.GetInt());
|
|
SetColor(element.GetChild("color", 0, "Color").GetIntAttribute("r", 255),
|
|
element.GetChild("color", 0, "Color").GetIntAttribute("g", 255),
|
|
element.GetChild("color", 0, "Color").GetIntAttribute("b", 255));
|
|
|
|
smoothed = element.GetBoolAttribute("smoothed");
|
|
bold = element.GetBoolAttribute("bold");
|
|
italic = element.GetBoolAttribute("italic");
|
|
underlined = element.GetBoolAttribute("underlined");
|
|
}
|
|
|
|
#if defined(GD_IDE_ONLY)
|
|
void TextObject::DoSerializeTo(gd::SerializerElement& element) const {
|
|
element.AddChild("string").SetValue(GetString());
|
|
element.AddChild("font").SetValue(GetFontName());
|
|
element.AddChild("textAlignment").SetValue(GetTextAlignment());
|
|
element.AddChild("characterSize").SetValue(GetCharacterSize());
|
|
element.AddChild("color")
|
|
.SetAttribute("r", (int)GetColorR())
|
|
.SetAttribute("g", (int)GetColorG())
|
|
.SetAttribute("b", (int)GetColorB());
|
|
|
|
element.SetAttribute("smoothed", smoothed);
|
|
element.SetAttribute("bold", bold);
|
|
element.SetAttribute("italic", italic);
|
|
element.SetAttribute("underlined", underlined);
|
|
}
|
|
|
|
void TextObject::ExposeResources(
|
|
gd::ArbitraryResourceWorker& worker) {
|
|
worker.ExposeFont(fontName);
|
|
}
|
|
#endif
|