Exemplo n.º 1
0
 def test_tiles_to_objects(self):
     tiles_objects_array = tiles_to_objects(
         data_from_file('../maps/test.yaml').get('tiles'))
     new_tiles_objects_array = [[
         MapTile('curve_left', 180),
         MapTile('straight', 180)
     ], [MapTile('straight', 90),
         MapTile('asphalt', 0)]]
     for tile, new_tile in zip(
             np.array(tiles_objects_array).flat,
             np.array(new_tiles_objects_array).flat):
         self.assertEqual(tile.kind, new_tile.kind)
         self.assertEqual(tile.rotation, new_tile.rotation)
Exemplo n.º 2
0
 def insert_button_clicked(self):
     if len(self.copyBuffer) == 0:
         return
     self.editor.save(self.map)
     if self.drawState == 'copy':
         self.editor.copySelection(
             self.copyBuffer, self.mapviewer.tileSelection[0],
             self.mapviewer.tileSelection[1],
             MapTile(self.ui.delete_fill.currentData()))
     elif self.drawState == 'cut':
         self.editor.moveSelection(
             self.copyBuffer, self.mapviewer.tileSelection[0],
             self.mapviewer.tileSelection[1],
             MapTile(self.ui.delete_fill.currentData()))
     self.mapviewer.scene().update()
     self.update_layer_tree()
Exemplo n.º 3
0
 def delete_button_clicked(self):
     if not self.map.get_tile_layer().visible:
         return
     self.editor.save(self.map)
     self.editor.deleteSelection(self.mapviewer.tileSelection,
                                 MapTile(self.ui.delete_fill.currentData()))
     self.mapviewer.scene().update()
     self.update_layer_tree()
Exemplo n.º 4
0
 def selectionUpdate(self):
     selection = self.mapviewer.tileSelection
     filler = MapTile(self.ui.default_fill.currentData())
     tile_layer = self.map.get_tile_layer().data
     if self.drawState == 'brush':
         self.editor.save(self.map)
         self.editor.extendToFit(selection, selection[0], selection[1],
                                 MapTile(self.ui.delete_fill.currentData()))
         if selection[0] < 0:
             delta = -selection[0]
             selection[0] = 0
             selection[2] += delta
         if selection[1] < 0:
             delta = -selection[1]
             selection[3] += delta
         for i in range(max(selection[0], 0),
                        min(selection[2], len(tile_layer[0]))):
             for j in range(max(selection[1], 0),
                            min(selection[3], len(tile_layer))):
                 tile_layer[j][i] = copy.copy(filler)
     self.update_layer_tree()
     self.mapviewer.scene().update()
Exemplo n.º 5
0
def tiles_to_objects(tiles):
    tiles_objects_array = []
    for tile_string in tiles:
        tiles_object_string = []
        for tile in tile_string:
            if '/' in tile != -1:
                kind, rotate = tile.split('/')
                for angle, word in rotation_val.items():
                    if word == rotate:
                        tile = {'kind': kind, 'rotate': angle}
            else:
                tile = {'kind': tile, 'rotate': 0}
            tiles_object_string.append(MapTile(tile['kind'], tile['rotate']))
        tiles_objects_array.append(tiles_object_string)
    return tiles_objects_array
Exemplo n.º 6
0
 def trimClicked(self):
     self.editor.save(self.map)
     self.editor.trimBorders(True, True, True, True,
                             MapTile(self.ui.delete_fill.currentData()))
     self.mapviewer.scene().update()
     self.update_layer_tree()