Add an action to change the tileset texture

This commit is contained in:
victorlevasseur
2014-09-07 17:33:09 +02:00
parent efabfe6dd8
commit 3870313cfb
4 changed files with 26 additions and 0 deletions
@@ -41,6 +41,7 @@
<resources>
<resources>
<resource alwaysLoaded="false" file="tiles_spritesheet.png" kind="image" name="tiles_spritesheet.png" smoothed="true" userAdded="true" />
<resource alwaysLoaded="false" file="../../../../n.png" kind="image" name="n.png" smoothed="true" userAdded="true" />
</resources>
<resourceFolders />
</resources>
+15
View File
@@ -167,6 +167,21 @@ void DeclareTileMapObjectExtension(gd::PlatformExtension & extension)
.MarkAsSimple()
.codeExtraInformation.SetFunctionName("LoadFromString").SetIncludeFile("TileMapObject/RuntimeTileMapObject.h");
obj.AddAction("ChangeTexture",
_("Change the tileset texture"),
_("Change the tileset texture."),
_("Change the tileset texture of _PARAM0_ to _PARAM1_"),
_("Tileset"),
"CppPlatform/Extensions/TileMapIcon24.png",
"res/TileMapIcon16.png")
.AddParameter("objectList", _("Tile Map Object"), "TileMap", false)
.AddParameter("string", _("The new texture name"))
.AddCodeOnlyParameter("currentScene", "")
.MarkAsSimple()
.codeExtraInformation.SetFunctionName("ChangeTexture").SetIncludeFile("TileMapObject/RuntimeTileMapObject.h");
#endif
}
@@ -217,6 +217,14 @@ void RuntimeTileMapObject::LoadFromString(const std::string &str)
needGeneration = true;
}
void RuntimeTileMapObject::ChangeTexture(const std::string &textureName, RuntimeScene &scene)
{
tileSet.Get().textureName = textureName;
tileSet.Get().LoadResources(*(scene.game));
tileSet.Get().Generate();
needGeneration = true;
}
namespace
{
/**
@@ -93,6 +93,8 @@ public :
std::string SaveAsString() const;
void LoadFromString(const std::string &str);
void ChangeTexture(const std::string &textureName, RuntimeScene &scene);
TileSetProxy tileSet;
TileMapProxy tileMap;