diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-17 17:15:36 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-17 17:15:36 -0400 |
commit | af9488a0a557e79dbf69c0b433e90a44fedb06a8 (patch) | |
tree | 85cadaeb3c553bf21660862da3f5980a6c8bda91 /tools | |
parent | 42c18bdf3bcb61da246e218985cd498dbc24541e (diff) | |
download | therapy-af9488a0a557e79dbf69c0b433e90a44fedb06a8.tar.gz therapy-af9488a0a557e79dbf69c0b433e90a44fedb06a8.tar.bz2 therapy-af9488a0a557e79dbf69c0b433e90a44fedb06a8.zip |
Fixed bug with placing entities in map editor
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mapedit/src/widget.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tools/mapedit/src/widget.cpp b/tools/mapedit/src/widget.cpp index cb10489..3b96281 100644 --- a/tools/mapedit/src/widget.cpp +++ b/tools/mapedit/src/widget.cpp | |||
@@ -234,8 +234,8 @@ void MapeditWidget::OnClick(wxMouseEvent& event) | |||
234 | { | 234 | { |
235 | if (addingEntity != nullptr) | 235 | if (addingEntity != nullptr) |
236 | { | 236 | { |
237 | int x = (event.GetPosition().x + vX) / scale - (addingEntity->getWidth() / 2); | 237 | int x = (event.GetPosition().x + vX - EDITOR_SPACING_X*scale) / scale - (addingEntity->getWidth() / 2); |
238 | int y = (event.GetPosition().y + vY) / scale - (addingEntity->getHeight() / 2); | 238 | int y = (event.GetPosition().y + vY - EDITOR_SPACING_Y*scale) / scale - (addingEntity->getHeight() / 2); |
239 | 239 | ||
240 | auto data = std::make_shared<MapObjectEntry>(); | 240 | auto data = std::make_shared<MapObjectEntry>(); |
241 | data->object = addingEntity; | 241 | data->object = addingEntity; |
@@ -255,8 +255,8 @@ void MapeditWidget::OnClick(wxMouseEvent& event) | |||
255 | addingEntity = nullptr; | 255 | addingEntity = nullptr; |
256 | } else if (movingEntity != nullptr) | 256 | } else if (movingEntity != nullptr) |
257 | { | 257 | { |
258 | int x = (event.GetPosition().x + vX) / scale - (movingEntity->object->getWidth() / 2); | 258 | int x = (event.GetPosition().x + vX - EDITOR_SPACING_X*scale) / scale - (movingEntity->object->getWidth() / 2); |
259 | int y = (event.GetPosition().y + vY) / scale - (movingEntity->object->getHeight() / 2); | 259 | int y = (event.GetPosition().y + vY - EDITOR_SPACING_Y*scale) / scale - (movingEntity->object->getHeight() / 2); |
260 | auto oldPos = movingEntity->position; | 260 | auto oldPos = movingEntity->position; |
261 | MapObjectEntry* me = movingEntity; | 261 | MapObjectEntry* me = movingEntity; |
262 | 262 | ||
@@ -273,8 +273,8 @@ void MapeditWidget::OnClick(wxMouseEvent& event) | |||
273 | frame->SetIsAddingEntity(false); | 273 | frame->SetIsAddingEntity(false); |
274 | movingEntity = nullptr; | 274 | movingEntity = nullptr; |
275 | } else { | 275 | } else { |
276 | int x = (event.GetPosition().x + vX) / scale; | 276 | int x = (event.GetPosition().x + vX - EDITOR_SPACING_X*scale) / scale; |
277 | int y = (event.GetPosition().y + vY) / scale; | 277 | int y = (event.GetPosition().y + vY - EDITOR_SPACING_Y*scale) / scale; |
278 | 278 | ||
279 | if (selectedEntity) | 279 | if (selectedEntity) |
280 | { | 280 | { |
@@ -307,8 +307,8 @@ void MapeditWidget::OnClick(wxMouseEvent& event) | |||
307 | 307 | ||
308 | if (isSettingPos) | 308 | if (isSettingPos) |
309 | { | 309 | { |
310 | int x = (event.GetPosition().x + vX) / scale - (PLAYER_WIDTH[currentPlayer] / 2); | 310 | int x = (event.GetPosition().x + vX - EDITOR_SPACING_X*scale) / scale - (PLAYER_WIDTH[currentPlayer] / 2); |
311 | int y = (event.GetPosition().y + vY) / scale - (PLAYER_HEIGHT[currentPlayer] / 2); | 311 | int y = (event.GetPosition().y + vY - EDITOR_SPACING_Y*scale) / scale - (PLAYER_HEIGHT[currentPlayer] / 2); |
312 | auto oldPos = map->getWorld()->getStartingPosition(); | 312 | auto oldPos = map->getWorld()->getStartingPosition(); |
313 | auto oldSMap = map->getWorld()->getStartingMap(); | 313 | auto oldSMap = map->getWorld()->getStartingMap(); |
314 | 314 | ||
@@ -344,8 +344,8 @@ void MapeditWidget::OnRightClick(wxMouseEvent& event) | |||
344 | vX *= vXX; | 344 | vX *= vXX; |
345 | vY *= vYX; | 345 | vY *= vYX; |
346 | 346 | ||
347 | int x = (event.GetPosition().x + vX) / scale; | 347 | int x = (event.GetPosition().x + vX - EDITOR_SPACING_X*scale) / scale; |
348 | int y = (event.GetPosition().y + vY) / scale; | 348 | int y = (event.GetPosition().y + vY - EDITOR_SPACING_Y*scale) / scale; |
349 | 349 | ||
350 | if ((x > selectedEntity->position.first) && (x < selectedEntity->position.first + selectedEntity->object->getWidth()) | 350 | if ((x > selectedEntity->position.first) && (x < selectedEntity->position.first + selectedEntity->object->getWidth()) |
351 | && (y > selectedEntity->position.second) && (y < selectedEntity->position.second + selectedEntity->object->getHeight())) | 351 | && (y > selectedEntity->position.second) && (y < selectedEntity->position.second + selectedEntity->object->getHeight())) |