summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Olsson <carl.olsson@gmail.com>2015-02-11 21:40:50 +1000
committerCarl Olsson <carl.olsson@gmail.com>2015-02-11 21:40:50 +1000
commitc613fb121b292d7abf601634b2db42c966f4a4ff (patch)
tree74d2e986182750a409df609111b891192cd47bb5
parent573ae5dd926df0dbd63b787945ace0fa76f08976 (diff)
Moved wrapper function to TileMapEditor.
-rw-r--r--scene/2d/tile_map.cpp5
-rw-r--r--scene/2d/tile_map.h1
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp16
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.h1
4 files changed, 12 insertions, 11 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 77558bd7b4..0b123bfa1c 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -439,10 +439,6 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo
}
-void TileMap::_set_cell(Point2 pos,int p_tile,bool p_flip_x,bool p_flip_y,bool p_transpose) {
- set_cell(floor(pos.x), floor(pos.y), p_tile, p_flip_x, p_flip_y, p_transpose);
-}
-
int TileMap::get_cell(int p_x,int p_y) const {
PosKey pk(p_x,p_y);
@@ -834,7 +830,6 @@ void TileMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("_set_cell","pos","tile","flip_x","flip_y","transpose"),&TileMap::_set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
ObjectTypeDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped);
ObjectTypeDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped);
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index fb366ab7e8..2809cdb378 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -169,7 +169,6 @@ public:
bool get_center_y() const;
void set_cell(int p_x,int p_y,int p_tile,bool p_flip_x=false,bool p_flip_y=false,bool p_transpose=false);
- void _set_cell(Point2 pos,int p_tile,bool p_flip_x=false,bool p_flip_y=false,bool p_transpose=false);
int get_cell(int p_x,int p_y) const;
bool is_cell_x_flipped(int p_x,int p_y) const;
bool is_cell_y_flipped(int p_x,int p_y) const;
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 7250f198d6..1dcf948505 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -90,6 +90,11 @@ void TileMapEditor::set_selected_tile(int p_tile) {
}
}
+void TileMapEditor::_set_cell_shortened(const Point2& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose) {
+ ERR_FAIL_COND(!node);
+ node->set_cell(floor(p_pos.x), floor(p_pos.y), p_value, p_flip_h, p_flip_v, p_transpose);
+}
+
void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose,bool p_with_undo) {
ERR_FAIL_COND(!node);
@@ -104,8 +109,8 @@ void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bo
if (p_with_undo) {
- undo_redo->add_do_method(node,"_set_cell",Point2(p_pos),p_value,p_flip_h,p_flip_v,p_transpose);
- undo_redo->add_undo_method(node,"_set_cell",Point2(p_pos),prev_val,prev_flip_h,prev_flip_v,prev_transpose);
+ undo_redo->add_do_method(this,"_set_cell_shortened",Point2(p_pos),p_value,p_flip_h,p_flip_v,p_transpose);
+ undo_redo->add_undo_method(this,"_set_cell_shortened",Point2(p_pos),prev_val,prev_flip_h,prev_flip_v,prev_transpose);
} else {
node->set_cell(p_pos.x,p_pos.y,p_value,p_flip_h,p_flip_v,p_transpose);
@@ -275,8 +280,8 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
for(Map<Point2i,CellOp>::Element *E=paint_undo.front();E;E=E->next()) {
Point2i p=E->key();
- undo_redo->add_do_method(node,"_set_cell",Point2(p),node->get_cell(p.x,p.y),node->is_cell_x_flipped(p.x,p.y),node->is_cell_y_flipped(p.x,p.y),node->is_cell_transposed(p.x,p.y));
- undo_redo->add_undo_method(node,"_set_cell",Point2(p),E->get().idx,E->get().xf,E->get().yf,E->get().tr);
+ undo_redo->add_do_method(this,"_set_cell_shortened",Point2(p),node->get_cell(p.x,p.y),node->is_cell_x_flipped(p.x,p.y),node->is_cell_y_flipped(p.x,p.y),node->is_cell_transposed(p.x,p.y));
+ undo_redo->add_undo_method(this,"_set_cell_shortened",Point2(p),E->get().idx,E->get().xf,E->get().yf,E->get().tr);
}
undo_redo->commit_action();
@@ -316,7 +321,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
Point2i p=E->key();
//undo_redo->add_do_method(node,"set_cell",p.x,p.y,node->get_cell(p.x,p.y),node->is_cell_x_flipped(p.x,p.y),node->is_cell_y_flipped(p.x,p.y),node->is_cell_transposed(p.x,p.y));
_set_cell(p,TileMap::INVALID_CELL,false,false,false,true);
- undo_redo->add_undo_method(node,"_set_cell",Point2(p),E->get().idx,E->get().xf,E->get().yf,E->get().tr);
+ undo_redo->add_undo_method(this,"_set_cell_shortened",Point2(p),E->get().idx,E->get().xf,E->get().yf,E->get().tr);
}
undo_redo->commit_action();
@@ -714,6 +719,7 @@ void TileMapEditor::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_canvas_mouse_exit"),&TileMapEditor::_canvas_mouse_exit);
ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
ObjectTypeDB::bind_method(_MD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
+ ObjectTypeDB::bind_method(_MD("_set_cell_shortened","pos","tile","flip_x","flip_y","transpose"),&TileMapEditor::_set_cell_shortened,DEFVAL(false),DEFVAL(false),DEFVAL(false));
}
diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h
index eb3205a15c..525315a8f1 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.h
+++ b/tools/editor/plugins/tile_map_editor_plugin.h
@@ -100,6 +100,7 @@ class TileMapEditor : public VBoxContainer {
void _menu_option(int p_option);
void _set_cell(const Point2i& p_pos, int p_value, bool p_flip_h=false, bool p_flip_v=false, bool p_transpose=false, bool p_with_undo=false);
+ void _set_cell_shortened(const Point2& p_pos, int p_value, bool p_flip_h=false, bool p_flip_v=false, bool p_transpose=false);
void _canvas_mouse_enter();
void _canvas_mouse_exit();