Minor changes in TileMap extension

This commit is contained in:
Florian Rival
2014-09-15 18:58:08 +02:00
parent 8f8acbf891
commit 2b8ce73ae2
12 changed files with 131 additions and 126 deletions

1
.gitignore vendored
View File

@@ -35,6 +35,7 @@
*.a *.a
*.so *.so
*.bc *.bc
*.debhelper.log
/Binaries/Output/Release_Linux/** /Binaries/Output/Release_Linux/**
!/Binaries/Output/Release_Linux/Start Game Develop.sh !/Binaries/Output/Release_Linux/Start Game Develop.sh
!/Binaries/Output/Release_Linux/CppPlatform/ !/Binaries/Output/Release_Linux/CppPlatform/

View File

@@ -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

View File

@@ -7,6 +7,7 @@
#if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI) #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 #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 #endif
#include <algorithm>
#include "GDCore/Tools/Localization.h" #include "GDCore/Tools/Localization.h"
#include "GDCore/BuiltinExtensions/SpriteExtension/SpriteObject.h" #include "GDCore/BuiltinExtensions/SpriteExtension/SpriteObject.h"
#include "GDCore/BuiltinExtensions/SpriteExtension/Animation.h" #include "GDCore/BuiltinExtensions/SpriteExtension/Animation.h"
@@ -284,6 +285,12 @@ bool SpriteObject::RemoveAnimation(unsigned int nb)
return true; 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. * Function destroying an extension Object.
* Game Develop does not delete directly extension object * Game Develop does not delete directly extension object
@@ -303,4 +310,4 @@ gd::Object * CreateSpriteObject(std::string name)
return new SpriteObject(name); return new SpriteObject(name);
} }
} }

View File

@@ -104,6 +104,11 @@ public :
*/ */
bool HasNoAnimations() const { return animations.empty(); } 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. * \brief Return a read-only reference to the vector containing all the animation of the object.
*/ */
@@ -127,4 +132,4 @@ GD_CORE_API void DestroySpriteObject(gd::Object * object);
GD_CORE_API gd::Object * CreateSpriteObject(std::string name); GD_CORE_API gd::Object * CreateSpriteObject(std::string name);
} }
#endif // GDCORE_SPRITEOBJECT_H #endif // GDCORE_SPRITEOBJECT_H

View File

@@ -25,7 +25,7 @@ freely, subject to the following restrictions:
*/ */
/** /**
* Contributors to the extension: * Contributors to the extension:
* Florian Rival ( Minor changes, added offsets, HTML5 port ) * Florian Rival (Minor changes)
*/ */
#include "GDCpp/ExtensionBase.h" #include "GDCpp/ExtensionBase.h"
@@ -222,4 +222,4 @@ extern "C" ExtensionBase * GD_EXTENSION_API CreateGDExtension() {
extern "C" void GD_EXTENSION_API DestroyGDExtension(ExtensionBase * p) { extern "C" void GD_EXTENSION_API DestroyGDExtension(ExtensionBase * p) {
delete p; delete p;
} }
#endif #endif

View File

@@ -30,10 +30,10 @@ freely, subject to the following restrictions:
#include <wx/dcclient.h> #include <wx/dcclient.h>
#include <wx/dcmemory.h> #include <wx/dcmemory.h>
#include <wx/dcbuffer.h> #include <wx/dcbuffer.h>
#include <wx/textdlg.h> #include <wx/textdlg.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/config.h> #include <wx/config.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include "GDCore/Tools/Log.h" #include "GDCore/Tools/Log.h"
#include "GDCore/Tools/Localization.h" #include "GDCore/Tools/Localization.h"
@@ -208,13 +208,13 @@ void TileMapObjectEditor::OnTileInsertionModeChanged(wxCommandEvent& event)
void TileMapObjectEditor::OnClearLayerToolClicked(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); m_tileMapPanel->FillLayer(m_tileMapPanel->GetCurrentLayer(), -1);
} }
void TileMapObjectEditor::OnFillLayerToolClicked(wxCommandEvent& event) 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()); m_tileMapPanel->FillLayer(m_tileMapPanel->GetCurrentLayer(), m_tileSetPanel->GetSelectedTile());
} }

View File

@@ -27,7 +27,7 @@ freely, subject to the following restrictions:
#include "TileMapPanel.h" #include "TileMapPanel.h"
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <wx/dcbuffer.h> #include <wx/dcbuffer.h>
#include "GDCore/IDE/CommonBitmapManager.h" #include "GDCore/IDE/CommonBitmapManager.h"
@@ -89,9 +89,9 @@ void TileMapPanel::FillLayer(int layer, int tile)
if(!m_tilemap) if(!m_tilemap)
return; 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); m_tilemap->SetTile(layer, col, row, tile);
} }
@@ -102,11 +102,11 @@ void TileMapPanel::FillLayer(int layer, int tile)
void TileMapPanel::Update() void TileMapPanel::Update()
{ {
if(!m_tilemap || !m_tileset) if (!m_tilemap || !m_tileset)
return; return;
SetScrollRate(1, 1); SetScrollRate(1, 1);
SetVirtualSize(m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, m_tilemap->GetRowsCount() * m_tileset->tileSize.y); SetVirtualSize(m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, m_tilemap->GetRowsCount() * m_tileset->tileSize.y);
Refresh(); Refresh();
} }
@@ -154,7 +154,7 @@ void TileMapPanel::OnPaint(wxPaintEvent& event)
{ {
if(m_tilemap->GetTile(layer, col, row) == -1) if(m_tilemap->GetTile(layer, col, row) == -1)
continue; continue;
dc.DrawBitmap(m_tileset->GetTileBitmap(m_tilemap->GetTile(layer, col, row)), GetPositionOfTile(col, row).x, GetPositionOfTile(col, row).y); dc.DrawBitmap(m_tileset->GetTileBitmap(m_tilemap->GetTile(layer, col, row)), GetPositionOfTile(col, row).x, GetPositionOfTile(col, row).y);
} }
} }
@@ -166,10 +166,10 @@ void TileMapPanel::OnPaint(wxPaintEvent& event)
dc.SetBrush(wxBrush(wxColour(128, 128, 255, 128))); dc.SetBrush(wxBrush(wxColour(128, 128, 255, 128)));
dc.SetPen(wxPen(wxColor(128, 128, 255, 255), 1)); dc.SetPen(wxPen(wxColor(128, 128, 255, 255), 1));
wxPoint topLeftPos(GetPositionOfTile(std::min(m_beginCol, m_endCol), wxPoint topLeftPos(GetPositionOfTile(std::min(m_beginCol, m_endCol),
std::min(m_beginRow, m_endRow))); std::min(m_beginRow, m_endRow)));
wxPoint bottomRightPos(GetPositionOfTile(std::max(m_beginCol + 1, m_endCol + 1), wxPoint bottomRightPos(GetPositionOfTile(std::max(m_beginCol + 1, m_endCol + 1),
std::max(m_beginRow + 1, m_endRow + 1))); std::max(m_beginRow + 1, m_endRow + 1)));
wxSize rectSize(bottomRightPos.x - topLeftPos.x, bottomRightPos.y - topLeftPos.y); wxSize rectSize(bottomRightPos.x - topLeftPos.x, bottomRightPos.y - topLeftPos.y);
@@ -301,4 +301,4 @@ void TileMapPanel::GetTileAt(wxPoint position, int &tileCol, int &tileRow)
{ {
tileCol = (int)(position.x / m_tileset->tileSize.x); tileCol = (int)(position.x / m_tileset->tileSize.x);
tileRow = (int)(position.y / m_tileset->tileSize.y); tileRow = (int)(position.y / m_tileset->tileSize.y);
} }

View File

@@ -31,8 +31,9 @@ class TileMap;
class TileSet; class TileSet;
/** /**
* Proxy for the TileMap * \brief Lightweight proxy class for the TileMap
* Note: needed because the TileMap includes wxBitmap at edittime which is not avaible in the preview compilation. * \note Needed because TileMap includes wx/bitmap.h which is not avaible when
* compiling for runtime.
*/ */
class TileMapProxy class TileMapProxy
{ {
@@ -51,8 +52,9 @@ private:
}; };
/** /**
* Proxy for the TileSet * \brief Lightweight proxy class for the TileSet
* Note: needed for the same reason as the TileMap * \note Needed because TileSet includes wx/bitmap.h which is not avaible when
* compiling for runtime.
*/ */
class TileSetProxy class TileSetProxy
{ {

View File

@@ -31,83 +31,85 @@ freely, subject to the following restrictions:
namespace TileMapExtension namespace TileMapExtension
{ {
sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
{
sf::VertexArray vertexArray(sf::Quads);
int tileWidth = tileSet.tileSize.x;
int tileHeight = tileSet.tileSize.y;
if(tileSet.IsDirty()) sf::VertexArray GenerateVertexArray(TileSet &tileSet, TileMap &tileMap)
return vertexArray; {
sf::VertexArray vertexArray(sf::Quads);
int vertexs = 0; int tileWidth = tileSet.tileSize.x;
int tileHeight = tileSet.tileSize.y;
for(int layer = 0; layer < 3; layer++)
{
for(int col = 0; col < tileMap.GetColumnsCount(); col++)
{
for(int row = 0; row < tileMap.GetRowsCount(); row++)
{
if(tileMap.GetTile(layer, col, row) == -1)
continue;
vertexs += 4;
TileTextureCoords coords = tileSet.GetTileTextureCoords(tileMap.GetTile(layer, col, row));
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, row * tileHeight), coords.topLeft);
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, (row + 1) * tileHeight), coords.bottomLeft);
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, (row + 1) * tileHeight), coords.bottomRight);
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, row * tileHeight), coords.topRight);
vertexArray.append(vertex);
}
}
}
}
std::cout << "Generated " << vertexs << " vertexes." << std::endl;
if(tileSet.IsDirty())
return vertexArray; return vertexArray;
}
std::vector<Polygon2d> GenerateHitboxes(TileSet &tileSet, TileMap &tileMap) int vertexs = 0;
for(int layer = 0; layer < 3; layer++)
{ {
std::vector<Polygon2d> hitboxes; for(int col = 0; col < tileMap.GetColumnsCount(); col++)
int tileWidth = tileSet.tileSize.x;
int tileHeight = tileSet.tileSize.y;
if(tileSet.IsDirty())
return hitboxes;
std::cout << "Generating Hitboxes" << std::endl;
for(int layer = 0; layer < 3; layer++)
{ {
for(int col = 0; col < tileMap.GetColumnsCount(); col++) for(int row = 0; row < tileMap.GetRowsCount(); row++)
{ {
for(int row = 0; row < tileMap.GetRowsCount(); row++) if(tileMap.GetTile(layer, col, row) == -1)
{ continue;
if(tileMap.GetTile(layer, col, row) == -1 || !tileSet.GetTileHitbox(tileMap.GetTile(layer, col, row)).collidable)
continue;
std::vector<Polygon2d>::iterator newHitboxIt = hitboxes.insert(hitboxes.begin(), tileSet.GetTileHitbox(tileMap.GetTile(layer, col, row)).hitbox); vertexs += 4;
std::cout << "Collision mask at " << col * tileWidth << ";" << row * tileHeight << std::endl;
newHitboxIt->Move(col * tileWidth, row * tileHeight); TileTextureCoords coords = tileSet.GetTileTextureCoords(tileMap.GetTile(layer, col, row));
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, row * tileHeight), coords.topLeft);
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f(col * tileWidth, (row + 1) * tileHeight), coords.bottomLeft);
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, (row + 1) * tileHeight), coords.bottomRight);
vertexArray.append(vertex);
}
{
sf::Vertex vertex(sf::Vector2f((col + 1) * tileWidth, row * tileHeight), coords.topRight);
vertexArray.append(vertex);
} }
} }
} }
std::cout << "Hitbox:OK" << std::endl;
return hitboxes;
} }
std::cout << "Generated " << vertexs << " vertexes." << std::endl;
return vertexArray;
}
std::vector<Polygon2d> GenerateHitboxes(TileSet &tileSet, TileMap &tileMap)
{
std::vector<Polygon2d> hitboxes;
int tileWidth = tileSet.tileSize.x;
int tileHeight = tileSet.tileSize.y;
if(tileSet.IsDirty())
return hitboxes;
std::cout << "Generating Hitboxes" << std::endl;
for(int layer = 0; layer < 3; layer++)
{
for(int col = 0; col < tileMap.GetColumnsCount(); col++)
{
for(int row = 0; row < tileMap.GetRowsCount(); row++)
{
if(tileMap.GetTile(layer, col, row) == -1 || !tileSet.GetTileHitbox(tileMap.GetTile(layer, col, row)).collidable)
continue;
std::vector<Polygon2d>::iterator newHitboxIt = hitboxes.insert(hitboxes.begin(), tileSet.GetTileHitbox(tileMap.GetTile(layer, col, row)).hitbox);
std::cout << "Collision mask at " << col * tileWidth << ";" << row * tileHeight << std::endl;
newHitboxIt->Move(col * tileWidth, row * tileHeight);
}
}
}
std::cout << "Hitbox:OK" << std::endl;
return hitboxes;
}
} }

View File

@@ -26,11 +26,11 @@ freely, subject to the following restrictions:
#include "TileSet.h" #include "TileSet.h"
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#ifdef GD_IDE_ONLY #ifdef GD_IDE_ONLY
#include <wx/file.h> #include <wx/file.h>
#include <wx/filefn.h> #include <wx/filefn.h>
#include <wx/filename.h> #include <wx/filename.h>
#endif #endif
#include <GDCore/CommonTools.h> #include <GDCore/CommonTools.h>
@@ -91,8 +91,8 @@ void TileHitbox::UnserializeFrom(const gd::SerializerElement &element, sf::Vecto
hitbox.vertices.clear(); hitbox.vertices.clear();
std::string defaultPolygonStr = "0;0|" std::string defaultPolygonStr = "0;0|"
+ gd::ToString(defaultTileSize.x) + ";0|" + gd::ToString(defaultTileSize.x) + ";0|"
+ gd::ToString(defaultTileSize.x) + ";" + gd::ToString(defaultTileSize.y) + "|" + gd::ToString(defaultTileSize.x) + ";" + gd::ToString(defaultTileSize.y) + "|"
+ "0;" + gd::ToString(defaultTileSize.y); + "0;" + gd::ToString(defaultTileSize.y);
std::string polygonStr = element.GetStringAttribute("polygon", defaultPolygonStr); std::string polygonStr = element.GetStringAttribute("polygon", defaultPolygonStr);
@@ -157,14 +157,14 @@ void TileSet::Generate()
{ {
m_dirty = true; m_dirty = true;
if(!m_tilesetTexture) if (!m_tilesetTexture)
return; return;
std::cout << "Generating texture coords..." << std::endl; std::cout << "Generating texture coords..." << std::endl;
//Calculates the number of rows and columns in the tileset //Calculates the number of rows and columns in the tileset
int columns(0), rows(0); int columns(0), rows(0);
if(tileSize.x == 0 || tileSize.y == 0) if (tileSize.x == 0 || tileSize.y == 0)
return; return;
columns = (m_tilesetTexture->texture.getSize().x + tileSpacing.x) / (tileSize.x + tileSpacing.x); columns = (m_tilesetTexture->texture.getSize().x + tileSpacing.x) / (tileSize.x + tileSpacing.x);
rows = (m_tilesetTexture->texture.getSize().y + tileSpacing.y) / (tileSize.y + tileSpacing.y); 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) //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)); m_hitboxes.insert(m_hitboxes.end(), (GetTilesCount()-m_hitboxes.size()), TileHitbox::Rectangle(tileSize));
std::cout << "OK" << std::endl; std::cout << "OK" << std::endl;
@@ -213,7 +213,7 @@ void TileSet::Generate()
void TileSet::ResetHitboxes() void TileSet::ResetHitboxes()
{ {
m_hitboxes.clear(); m_hitboxes.clear();
if(m_dirty) if (m_dirty)
return; return;
m_hitboxes.assign(GetTilesCount(), TileHitbox::Rectangle(tileSize)); 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.x = element.GetIntAttribute("tileSpacingX", 0);
tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0); tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0);
if(element.HasChild("hitboxes")) if (element.HasChild("hitboxes"))
{ {
gd::SerializerElement &tilesElem = element.GetChild("hitboxes"); gd::SerializerElement &tilesElem = element.GetChild("hitboxes");
tilesElem.ConsiderAsArrayOf("tileHitbox"); tilesElem.ConsiderAsArrayOf("tileHitbox");

View File

@@ -34,7 +34,7 @@ freely, subject to the following restrictions:
#include "GDCore/Tools/HelpFileAccess.h" #include "GDCore/Tools/HelpFileAccess.h"
#include "GDCpp/Project.h" #include "GDCpp/Project.h"
TileSetConfigurationEditor::TileSetConfigurationEditor(wxWindow* parent, TileSet &tileSet_, gd::Project & game_, gd::MainFrameWrapper & mainFrameWrapper) : TileSetConfigurationEditor::TileSetConfigurationEditor(wxWindow* parent, TileSet &tileSet_, gd::Project & game_, gd::MainFrameWrapper & mainFrameWrapper) :
TileSetConfigurationEditorBase(parent), TileSetConfigurationEditorBase(parent),
tileSet(tileSet_), tileSet(tileSet_),
game(game_), game(game_),
@@ -44,16 +44,16 @@ TileSetConfigurationEditor::TileSetConfigurationEditor(wxWindow* parent, TileSet
resourcesEditorPnl->Refresh(); resourcesEditorPnl->Refresh();
m_auimgr->AddPane( resourcesEditorPnl, wxAuiPaneInfo().Name( "ResourcesEditor" ) m_auimgr->AddPane( resourcesEditorPnl, wxAuiPaneInfo().Name( "ResourcesEditor" )
.Left() .Left()
.CloseButton(false) .CloseButton(false)
.Caption(_( "Images bank's editor" )) .Caption(_( "Images bank's editor" ))
.MaximizeButton( true ) .MaximizeButton( true )
.MinimizeButton( false ) .MinimizeButton( false )
.CaptionVisible(true) .CaptionVisible(true)
.MinSize(50, 50) .MinSize(50, 50)
.BestSize(230,100) .BestSize(230,100)
.Show(true) .Show(true)
); );
m_auimgr->Update(); m_auimgr->Update();

View File

@@ -32,7 +32,7 @@ freely, subject to the following restrictions:
wxDEFINE_EVENT(TILE_SELECTION_CHANGED, TileSelectionEvent); wxDEFINE_EVENT(TILE_SELECTION_CHANGED, TileSelectionEvent);
TileSetPanel::TileSetPanel(wxWindow* parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) : TileSetPanel::TileSetPanel(wxWindow* parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style) :
wxScrolledWindow(parent, id, pos, size, style), wxScrolledWindow(parent, id, pos, size, style),
m_tileset(NULL), m_tileset(NULL),
m_selectedCol(0), m_selectedCol(0),
@@ -59,7 +59,7 @@ int TileSetPanel::GetSelectedTile() const
{ {
if(!m_tileset || m_tileset->IsDirty()) if(!m_tileset || m_tileset->IsDirty())
return -1; return -1;
return m_tileset->GetTileIDFromCell(m_selectedCol, m_selectedRow); return m_tileset->GetTileIDFromCell(m_selectedCol, m_selectedRow);
} }
@@ -137,7 +137,7 @@ void TileSetPanel::OnPaint(wxPaintEvent& event)
void TileSetPanel::OnLeftButtonPressed(wxMouseEvent& event) void TileSetPanel::OnLeftButtonPressed(wxMouseEvent& event)
{ {
if(!m_tileset || m_tileset->IsDirty()) if (!m_tileset || m_tileset->IsDirty())
return; return;
wxPoint mousePos = CalcUnscrolledPosition(event.GetPosition()); wxPoint mousePos = CalcUnscrolledPosition(event.GetPosition());
@@ -145,7 +145,7 @@ void TileSetPanel::OnLeftButtonPressed(wxMouseEvent& event)
//Select the tile //Select the tile
int selectedCol, selectedRow; int selectedCol, selectedRow;
GetTileAt(mousePos, 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; return;
m_selectedCol = selectedCol; m_selectedCol = selectedCol;
m_selectedRow = selectedRow; m_selectedRow = selectedRow;
@@ -165,7 +165,7 @@ wxPoint TileSetPanel::GetPositionOfTile(int column, int row)
void TileSetPanel::GetTileAt(wxPoint position, int &tileCol, int &tileRow) 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; tileCol = 0;
tileRow = 0; tileRow = 0;
@@ -174,4 +174,4 @@ void TileSetPanel::GetTileAt(wxPoint position, int &tileCol, int &tileRow)
tileCol = (int)(position.x / (m_tileset->tileSize.x + m_tileset->tileSpacing.x)); tileCol = (int)(position.x / (m_tileset->tileSize.x + m_tileset->tileSpacing.x));
tileRow = (int)(position.y / (m_tileset->tileSize.y + m_tileset->tileSpacing.y)); tileRow = (int)(position.y / (m_tileset->tileSize.y + m_tileset->tileSpacing.y));
} }