More refactoring!

This commit is contained in:
Hamcha 2020-09-24 12:59:40 +02:00
parent 99d59507e6
commit d5d450d7f6
Signed by: hamcha
GPG key ID: 41467804B19A3315

View file

@ -137,7 +137,6 @@ func place_rect(a: Vector2, b: Vector2, id: int):
x_ord = Vector2(b.x, a.x) x_ord = Vector2(b.x, a.x)
if a.y > b.y: if a.y > b.y:
y_ord = Vector2(b.y, a.y) y_ord = Vector2(b.y, a.y)
var positions = []
for x in range(x_ord.x, x_ord.y+1): for x in range(x_ord.x, x_ord.y+1):
place_tile(layer, Vector2(x, a.y), id) place_tile(layer, Vector2(x, a.y), id)
place_tile(layer, Vector2(x, b.y), id) place_tile(layer, Vector2(x, b.y), id)
@ -169,7 +168,6 @@ func add_tile_tab(name: String, tilemap: TileMap):
var tileset := tilemap.tile_set var tileset := tilemap.tile_set
var ids := tileset.get_tiles_ids() var ids := tileset.get_tiles_ids()
for id in ids: for id in ids:
var tile_name := tileset.tile_get_name(id)
var tile_icon := make_tile_texture(tileset, id) var tile_icon := make_tile_texture(tileset, id)
tab.add_entry(id, group, tile_icon) tab.add_entry(id, group, tile_icon)
@ -196,7 +194,7 @@ func _item_selected(idx: int, tab: ItemList):
func _toggle_tile_input(enable: bool): func _toggle_tile_input(enable: bool):
input_lock = not enable input_lock = not enable
func _tile_selected(id: int, name: String, tilemap: TileMap): func _tile_selected(id: int, _name: String, tilemap: TileMap):
cursor_sprite.texture = make_tile_texture(tilemap.tile_set, id) cursor_sprite.texture = make_tile_texture(tilemap.tile_set, id)
placing_mode = PlacingMode.TILEMAP placing_mode = PlacingMode.TILEMAP
placing_layer = tilemap placing_layer = tilemap
@ -329,17 +327,17 @@ func tile_released(button: int, pos: Vector2):
match current_tool: match current_tool:
Tool.TILE_RECT: Tool.TILE_RECT:
if placing_layer != null: if placing_layer != null:
place_rect(pressed_pos, cursor_pos, get_active_tile()) place_rect(pressed_pos, pos, get_active_tile())
Tool.TILE_FILL: Tool.TILE_FILL:
if placing_layer != null: if placing_layer != null:
flood_fill(placing_layer, cursor_pos, get_active_tile()) flood_fill(placing_layer, pos, get_active_tile())
match button: match button:
BUTTON_LEFT: BUTTON_LEFT:
placing = false placing = false
BUTTON_RIGHT: BUTTON_RIGHT:
deleting = false deleting = false
func tile_mouse_move(from: Vector2, to: Vector2): func tile_mouse_move(_from: Vector2, to: Vector2):
match current_tool: match current_tool:
Tool.TILE_FREEHAND: Tool.TILE_FREEHAND:
if placing_layer != null: if placing_layer != null: