mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Expose ShapePainterObject and TextEntryObject to emscripten build
This commit is contained in:
@@ -35,13 +35,13 @@ IF (NOT EMSCRIPTEN)
|
||||
ADD_SUBDIRECTORY(PhysicsBehavior)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(PlatformBehavior)
|
||||
ADD_SUBDIRECTORY(PrimitiveDrawing)
|
||||
IF (NOT EMSCRIPTEN)
|
||||
ADD_SUBDIRECTORY(PrimitiveDrawing)
|
||||
ADD_SUBDIRECTORY(SoundObject)
|
||||
ADD_SUBDIRECTORY(SystemInfo)
|
||||
ADD_SUBDIRECTORY(TextEntryObject)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(TextObject)
|
||||
ADD_SUBDIRECTORY(TextEntryObject)
|
||||
ADD_SUBDIRECTORY(TextObject)
|
||||
IF (NOT EMSCRIPTEN)
|
||||
ADD_SUBDIRECTORY(TileMapObject)
|
||||
ENDIF()
|
||||
|
@@ -25,7 +25,10 @@ void DeclarePrimitiveDrawingExtension(gd::PlatformExtension & extension)
|
||||
"CppPlatform/Extensions/primitivedrawingicon.png");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
ShapePainterObject::LoadEdittimeIcon();
|
||||
#endif
|
||||
|
||||
obj.SetIncludeFile("PrimitiveDrawing/ShapePainterObject.h");
|
||||
|
||||
obj.AddAction("Rectangle",
|
||||
|
@@ -27,7 +27,7 @@ This project is released under the MIT License.
|
||||
#include "ShapePainterObjectEditor.h"
|
||||
#endif
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
sf::Texture ShapePainterObject::edittimeIconImage;
|
||||
sf::Sprite ShapePainterObject::edittimeIcon;
|
||||
#endif
|
||||
@@ -59,7 +59,7 @@ RuntimeShapePainterObject::RuntimeShapePainterObject(RuntimeScene & scene, const
|
||||
ShapePainterObjectBase::operator=(shapePainterObject);
|
||||
}
|
||||
|
||||
void ShapePainterObjectBase::UnserializeFrom(const gd::SerializerElement & element)
|
||||
void ShapePainterObjectBase::DoUnserializeFrom(const gd::SerializerElement & element)
|
||||
{
|
||||
fillOpacity = element.GetChild("fillOpacity", 0, "FillOpacity").GetValue().GetInt();
|
||||
outlineSize = element.GetChild("outlineSize", 0, "OutlineSize").GetValue().GetInt();
|
||||
@@ -78,11 +78,11 @@ void ShapePainterObjectBase::UnserializeFrom(const gd::SerializerElement & eleme
|
||||
|
||||
void ShapePainterObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element)
|
||||
{
|
||||
ShapePainterObjectBase::UnserializeFrom(element);
|
||||
ShapePainterObjectBase::DoUnserializeFrom(element);
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void ShapePainterObjectBase::SerializeTo(gd::SerializerElement & element) const
|
||||
void ShapePainterObjectBase::DoSerializeTo(gd::SerializerElement & element) const
|
||||
{
|
||||
element.AddChild("fillOpacity").SetValue(fillOpacity);
|
||||
element.AddChild("outlineSize").SetValue(outlineSize);
|
||||
@@ -100,7 +100,7 @@ void ShapePainterObjectBase::SerializeTo(gd::SerializerElement & element) const
|
||||
|
||||
void ShapePainterObject::DoSerializeTo(gd::SerializerElement & element) const
|
||||
{
|
||||
ShapePainterObjectBase::SerializeTo(element);
|
||||
ShapePainterObjectBase::DoSerializeTo(element);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -127,7 +127,7 @@ bool RuntimeShapePainterObject::Draw( sf::RenderTarget& renderTarget )
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
/**
|
||||
* Render object at edittime
|
||||
*/
|
||||
@@ -145,21 +145,20 @@ void ShapePainterObject::LoadEdittimeIcon()
|
||||
|
||||
bool ShapePainterObject::GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const
|
||||
{
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
thumbnail = wxBitmap("CppPlatform/Extensions/primitivedrawingicon24.png", wxBITMAP_TYPE_ANY);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShapePainterObject::EditObject( wxWindow* parent, gd::Project & game, gd::MainFrameWrapper & mainFrameWrapper )
|
||||
{
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
ShapePainterObjectEditor dialog(parent, game, *this);
|
||||
dialog.ShowModal();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void RuntimeShapePainterObject::GetPropertyForDebugger(std::size_t propertyNb, gd::String & name, gd::String & value) const
|
||||
{
|
||||
if ( propertyNb == 0 ) {name = _("Fill color"); value = gd::String::From(GetFillColorR())+";"+gd::String::From(GetFillColorG())+";"+gd::String::From(GetFillColorB());}
|
||||
|
@@ -52,11 +52,6 @@ public:
|
||||
ShapePainterObjectBase();
|
||||
virtual ~ShapePainterObjectBase() {};
|
||||
|
||||
virtual void UnserializeFrom(const gd::SerializerElement & element);
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void SerializeTo(gd::SerializerElement & element) const;
|
||||
#endif
|
||||
|
||||
inline void SetOutlineSize(float size) { outlineSize = size; };
|
||||
inline float GetOutlineSize() const { return outlineSize; };
|
||||
|
||||
@@ -87,6 +82,13 @@ public:
|
||||
inline void SetCoordinatesAbsolute() { absoluteCoordinates = true; }
|
||||
inline void SetCoordinatesRelative() { absoluteCoordinates = false; }
|
||||
inline bool AreCoordinatesAbsolute() { return absoluteCoordinates; }
|
||||
|
||||
protected:
|
||||
virtual void DoUnserializeFrom(const gd::SerializerElement & element);
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void DoSerializeTo(gd::SerializerElement & element) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
//Fill color
|
||||
unsigned int fillColorR;
|
||||
@@ -115,7 +117,7 @@ public:
|
||||
virtual ~ShapePainterObject() {};
|
||||
virtual std::unique_ptr<gd::Object> Clone() const { return gd::make_unique<ShapePainterObject>(*this); }
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
virtual void DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout);
|
||||
virtual sf::Vector2f GetInitialInstanceDefaultSize(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout) const {return sf::Vector2f(32,32);};
|
||||
virtual bool GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const;
|
||||
@@ -129,9 +131,11 @@ private:
|
||||
#if defined(GD_IDE_ONLY)
|
||||
virtual void DoSerializeTo(gd::SerializerElement & element) const;
|
||||
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
static sf::Texture edittimeIconImage;
|
||||
static sf::Sprite edittimeIcon;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
class GD_EXTENSION_API RuntimeShapePainterObject : public RuntimeObject, public ShapePainterObjectBase
|
||||
|
@@ -25,7 +25,9 @@ void DeclareTextEntryObjectExtension(gd::PlatformExtension & extension)
|
||||
"CppPlatform/Extensions/textentry.png");
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
TextEntryObject::LoadEdittimeIcon();
|
||||
#endif
|
||||
obj.SetIncludeFile("TextEntryObject/TextEntryObject.h");
|
||||
|
||||
obj.AddAction("String",
|
||||
|
@@ -27,7 +27,7 @@ This project is released under the MIT License.
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
sf::Texture TextEntryObject::edittimeIconImage;
|
||||
sf::Sprite TextEntryObject::edittimeIcon;
|
||||
#endif
|
||||
@@ -71,7 +71,7 @@ void RuntimeTextEntryObject::Update(const RuntimeScene & scene)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
void TextEntryObject::DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout)
|
||||
{
|
||||
edittimeIcon.setPosition(instance.GetX(), instance.GetY());
|
||||
@@ -86,13 +86,13 @@ void TextEntryObject::LoadEdittimeIcon()
|
||||
|
||||
bool TextEntryObject::GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const
|
||||
{
|
||||
#if !defined(GD_NO_WX_GUI)
|
||||
thumbnail = wxBitmap("CppPlatform/Extensions/textentry.png", wxBITMAP_TYPE_ANY);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
void RuntimeTextEntryObject::GetPropertyForDebugger(std::size_t propertyNb, gd::String & name, gd::String & value) const
|
||||
{
|
||||
if ( propertyNb == 0 ) {name = _("Text in memory"); value = GetString();}
|
||||
|
@@ -34,14 +34,14 @@ public :
|
||||
virtual ~TextEntryObject() {};
|
||||
virtual std::unique_ptr<gd::Object> Clone() const { return gd::make_unique<TextEntryObject>(*this); }
|
||||
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
virtual void DrawInitialInstance(gd::InitialInstance & instance, sf::RenderTarget & renderTarget, gd::Project & project, gd::Layout & layout);
|
||||
virtual bool GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const;
|
||||
static void LoadEdittimeIcon();
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if defined(GD_IDE_ONLY)
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
static sf::Texture edittimeIconImage;
|
||||
static sf::Sprite edittimeIcon;
|
||||
#endif
|
||||
|
@@ -131,6 +131,8 @@ gd::PlatformExtension * CreateGDJSTextObjectExtension();
|
||||
gd::PlatformExtension * CreateGDJSAdMobObjectExtension();
|
||||
gd::PlatformExtension * CreateGDJSPanelSpriteObjectExtension();
|
||||
gd::PlatformExtension * CreateGDJSAnchorBehaviorExtension();
|
||||
gd::PlatformExtension * CreateGDJSPrimitiveDrawingExtension();
|
||||
gd::PlatformExtension * CreateGDJSTextEntryObjectExtension();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -171,6 +173,8 @@ JsPlatform::JsPlatform() :
|
||||
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSAdMobObjectExtension())); std::cout.flush();
|
||||
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSPanelSpriteObjectExtension())); std::cout.flush();
|
||||
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSAnchorBehaviorExtension())); std::cout.flush();
|
||||
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSPrimitiveDrawingExtension())); std::cout.flush();
|
||||
AddExtension(std::shared_ptr<gd::PlatformExtension>(CreateGDJSTextEntryObjectExtension())); std::cout.flush();
|
||||
#endif
|
||||
std::cout << "done." << std::endl;
|
||||
};
|
||||
|
Reference in New Issue
Block a user