mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Minor changes in TileMap extension
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -35,6 +35,7 @@
|
||||
*.a
|
||||
*.so
|
||||
*.bc
|
||||
*.debhelper.log
|
||||
/Binaries/Output/Release_Linux/**
|
||||
!/Binaries/Output/Release_Linux/Start Game Develop.sh
|
||||
!/Binaries/Output/Release_Linux/CppPlatform/
|
||||
|
@@ -1,12 +0,0 @@
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
||||
dh_fixperms
|
@@ -7,6 +7,7 @@
|
||||
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
|
||||
#include <wx/wx.h> //Must be placed first, otherwise we get nice errors relative to "cannot convert 'const TCHAR*'..." in wx/msw/winundef.h
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#include "GDCore/Tools/Localization.h"
|
||||
#include "GDCore/BuiltinExtensions/SpriteExtension/SpriteObject.h"
|
||||
#include "GDCore/BuiltinExtensions/SpriteExtension/Animation.h"
|
||||
@@ -284,6 +285,12 @@ bool SpriteObject::RemoveAnimation(unsigned int nb)
|
||||
return true;
|
||||
}
|
||||
|
||||
void SpriteObject::SwapAnimations(unsigned int firstIndex, unsigned int secondIndex)
|
||||
{
|
||||
if ( firstIndex < animations.size() && secondIndex < animations.size() && firstIndex != secondIndex)
|
||||
std::swap(animations[firstIndex], animations[secondIndex]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function destroying an extension Object.
|
||||
* Game Develop does not delete directly extension object
|
||||
|
@@ -104,6 +104,11 @@ public :
|
||||
*/
|
||||
bool HasNoAnimations() const { return animations.empty(); }
|
||||
|
||||
/**
|
||||
* \brief Swap the position of two sprites
|
||||
*/
|
||||
void SwapAnimations(unsigned int firstIndex, unsigned int secondIndex);
|
||||
|
||||
/**
|
||||
* \brief Return a read-only reference to the vector containing all the animation of the object.
|
||||
*/
|
||||
|
@@ -25,7 +25,7 @@ freely, subject to the following restrictions:
|
||||
*/
|
||||
/**
|
||||
* Contributors to the extension:
|
||||
* Florian Rival ( Minor changes, added offsets, HTML5 port )
|
||||
* Florian Rival (Minor changes)
|
||||
*/
|
||||
|
||||
#include "GDCpp/ExtensionBase.h"
|
||||
|
@@ -208,13 +208,13 @@ void TileMapObjectEditor::OnTileInsertionModeChanged(wxCommandEvent& event)
|
||||
|
||||
void TileMapObjectEditor::OnClearLayerToolClicked(wxCommandEvent& event)
|
||||
{
|
||||
if(wxMessageBox(_("Are you sure to clear the whole layer ?"), _("Confirm"), wxYES_NO|wxICON_QUESTION|wxNO_DEFAULT, this) == wxYES)
|
||||
if(wxMessageBox(_("Are you sure you want to clear the whole layer ?"), _("Confirm"), wxYES_NO|wxICON_QUESTION|wxNO_DEFAULT, this) == wxYES)
|
||||
m_tileMapPanel->FillLayer(m_tileMapPanel->GetCurrentLayer(), -1);
|
||||
}
|
||||
|
||||
void TileMapObjectEditor::OnFillLayerToolClicked(wxCommandEvent& event)
|
||||
{
|
||||
if(wxMessageBox(_("Are you sure to fill the whole layer with that tile ?"), _("Confirm"), wxYES_NO|wxICON_QUESTION|wxNO_DEFAULT, this) == wxYES)
|
||||
if(wxMessageBox(_("Are you sure you want to fill the whole layer with that tile ?"), _("Confirm"), wxYES_NO|wxICON_QUESTION|wxNO_DEFAULT, this) == wxYES)
|
||||
m_tileMapPanel->FillLayer(m_tileMapPanel->GetCurrentLayer(), m_tileSetPanel->GetSelectedTile());
|
||||
}
|
||||
|
||||
|
@@ -89,9 +89,9 @@ void TileMapPanel::FillLayer(int layer, int tile)
|
||||
if(!m_tilemap)
|
||||
return;
|
||||
|
||||
for(int col = 0; col < m_tilemap->GetColumnsCount(); col++)
|
||||
for (int col = 0; col < m_tilemap->GetColumnsCount(); col++)
|
||||
{
|
||||
for(int row = 0; row < m_tilemap->GetRowsCount(); row++)
|
||||
for (int row = 0; row < m_tilemap->GetRowsCount(); row++)
|
||||
{
|
||||
m_tilemap->SetTile(layer, col, row, tile);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ void TileMapPanel::FillLayer(int layer, int tile)
|
||||
|
||||
void TileMapPanel::Update()
|
||||
{
|
||||
if(!m_tilemap || !m_tileset)
|
||||
if (!m_tilemap || !m_tileset)
|
||||
return;
|
||||
SetScrollRate(1, 1);
|
||||
SetVirtualSize(m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, m_tilemap->GetRowsCount() * m_tileset->tileSize.y);
|
||||
|
@@ -31,8 +31,9 @@ class TileMap;
|
||||
class TileSet;
|
||||
|
||||
/**
|
||||
* Proxy for the TileMap
|
||||
* Note: needed because the TileMap includes wxBitmap at edittime which is not avaible in the preview compilation.
|
||||
* \brief Lightweight proxy class for the TileMap
|
||||
* \note Needed because TileMap includes wx/bitmap.h which is not avaible when
|
||||
* compiling for runtime.
|
||||
*/
|
||||
class TileMapProxy
|
||||
{
|
||||
@@ -51,8 +52,9 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* Proxy for the TileSet
|
||||
* Note: needed for the same reason as the TileMap
|
||||
* \brief Lightweight proxy class for the TileSet
|
||||
* \note Needed because TileSet includes wx/bitmap.h which is not avaible when
|
||||
* compiling for runtime.
|
||||
*/
|
||||
class TileSetProxy
|
||||
{
|
||||
|
@@ -31,8 +31,9 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace TileMapExtension
|
||||
{
|
||||
sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
|
||||
{
|
||||
|
||||
sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
|
||||
{
|
||||
sf::VertexArray vertexArray(sf::Quads);
|
||||
int tileWidth = tileSet.tileSize.x;
|
||||
int tileHeight = tileSet.tileSize.y;
|
||||
@@ -77,10 +78,10 @@ namespace TileMapExtension
|
||||
std::cout << "Generated " << vertexs << " vertexes." << std::endl;
|
||||
|
||||
return vertexArray;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Polygon2d> GenerateHitboxes(TileSet &tileSet, TileMap &tileMap)
|
||||
{
|
||||
std::vector<Polygon2d> GenerateHitboxes(TileSet &tileSet, TileMap &tileMap)
|
||||
{
|
||||
std::vector<Polygon2d> hitboxes;
|
||||
int tileWidth = tileSet.tileSize.x;
|
||||
int tileHeight = tileSet.tileSize.y;
|
||||
@@ -109,5 +110,6 @@ namespace TileMapExtension
|
||||
std::cout << "Hitbox:OK" << std::endl;
|
||||
|
||||
return hitboxes;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -157,14 +157,14 @@ void TileSet::Generate()
|
||||
{
|
||||
m_dirty = true;
|
||||
|
||||
if(!m_tilesetTexture)
|
||||
if (!m_tilesetTexture)
|
||||
return;
|
||||
|
||||
std::cout << "Generating texture coords..." << std::endl;
|
||||
|
||||
//Calculates the number of rows and columns in the tileset
|
||||
int columns(0), rows(0);
|
||||
if(tileSize.x == 0 || tileSize.y == 0)
|
||||
if (tileSize.x == 0 || tileSize.y == 0)
|
||||
return;
|
||||
columns = (m_tilesetTexture->texture.getSize().x + tileSpacing.x) / (tileSize.x + tileSpacing.x);
|
||||
rows = (m_tilesetTexture->texture.getSize().y + tileSpacing.y) / (tileSize.y + tileSpacing.y);
|
||||
@@ -203,7 +203,7 @@ void TileSet::Generate()
|
||||
}
|
||||
|
||||
//Puts the default hitbox for new tiles (if there are more tiles than before)
|
||||
if(GetTilesCount() > m_hitboxes.size())
|
||||
if (GetTilesCount() > m_hitboxes.size())
|
||||
m_hitboxes.insert(m_hitboxes.end(), (GetTilesCount()-m_hitboxes.size()), TileHitbox::Rectangle(tileSize));
|
||||
|
||||
std::cout << "OK" << std::endl;
|
||||
@@ -213,7 +213,7 @@ void TileSet::Generate()
|
||||
void TileSet::ResetHitboxes()
|
||||
{
|
||||
m_hitboxes.clear();
|
||||
if(m_dirty)
|
||||
if (m_dirty)
|
||||
return;
|
||||
|
||||
m_hitboxes.assign(GetTilesCount(), TileHitbox::Rectangle(tileSize));
|
||||
@@ -325,7 +325,7 @@ void TileSet::UnserializeFrom(const gd::SerializerElement &element)
|
||||
tileSpacing.x = element.GetIntAttribute("tileSpacingX", 0);
|
||||
tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0);
|
||||
|
||||
if(element.HasChild("hitboxes"))
|
||||
if (element.HasChild("hitboxes"))
|
||||
{
|
||||
gd::SerializerElement &tilesElem = element.GetChild("hitboxes");
|
||||
tilesElem.ConsiderAsArrayOf("tileHitbox");
|
||||
|
@@ -137,7 +137,7 @@ void TileSetPanel::OnPaint(wxPaintEvent& event)
|
||||
|
||||
void TileSetPanel::OnLeftButtonPressed(wxMouseEvent& event)
|
||||
{
|
||||
if(!m_tileset || m_tileset->IsDirty())
|
||||
if (!m_tileset || m_tileset->IsDirty())
|
||||
return;
|
||||
|
||||
wxPoint mousePos = CalcUnscrolledPosition(event.GetPosition());
|
||||
@@ -145,7 +145,7 @@ void TileSetPanel::OnLeftButtonPressed(wxMouseEvent& event)
|
||||
//Select the tile
|
||||
int selectedCol, selectedRow;
|
||||
GetTileAt(mousePos, selectedCol, selectedRow);
|
||||
if(selectedCol >= m_tileset->GetColumnsCount() || selectedRow >= m_tileset->GetRowsCount())
|
||||
if (selectedCol >= m_tileset->GetColumnsCount() || selectedRow >= m_tileset->GetRowsCount())
|
||||
return;
|
||||
m_selectedCol = selectedCol;
|
||||
m_selectedRow = selectedRow;
|
||||
@@ -165,7 +165,7 @@ wxPoint TileSetPanel::GetPositionOfTile(int column, int row)
|
||||
|
||||
void TileSetPanel::GetTileAt(wxPoint position, int &tileCol, int &tileRow)
|
||||
{
|
||||
if(m_tileset->tileSize.x == 0 || m_tileset->tileSize.y == 0)
|
||||
if (m_tileset->tileSize.x == 0 || m_tileset->tileSize.y == 0)
|
||||
{
|
||||
tileCol = 0;
|
||||
tileRow = 0;
|
||||
|
Reference in New Issue
Block a user