Package arcmap :: Module mapcontroller :: Class MapController
[hide private]
[frames] | no frames]

Class MapController

source code

MapController is the command and control center for the program. It manages communication between the other modules and controls the tilemap.

Instance Methods [hide private]
 
__init__(self) source code
 
setThumbnailSource(self, source) source code
 
getThumbnail(self, largest) source code
 
getParallaxes(self) source code
 
setParallaxes(self, parallaxes) source code
graphics.RGBA
getBGColor(self)
Returns: Map's background color
source code
 
setBGColor(self, color) source code
 
getShapes(self) source code
 
setShapes(self, shapes) source code
 
addShape(self, shape) source code
 
removeShape(self, shape) source code
bool
hasMap(self)
Returns: True if there is a map to edit
source code
str
open(self, fileName)
Opens a file
source code
 
close(self) source code
 
new(self, tileSize, width, height)
Creates a new map of the given width, height, and tile dimentions
source code
 
save(self) source code
 
mapTileSize(self) source code
 
mapWidth(self) source code
 
mapHeight(self) source code
 
mapLayers(self) source code
 
resize(self, width, height, xOffset, yOffset) source code
 
selectLayer(self, index) source code
int
selectedLayer(self)
Returns: the currently selected layer
source code
bool
mapLayerVisibility(self, index)
Returns: True if the layer at index is visible
source code
 
setMapLayerVisibility(self, index, v) source code
 
setLayerName(self, index, name) source code
string
getFileName(self)
Returns: the name of the file currently loaded
source code
 
setFileName(self, fileName) source code
 
addListener(self, listener)
Brief Description
source code
(cairo.ImageSurface, int)
openTileSet(self, fileName)
Opens an image file and adds it to the list of open images
source code
 
drawShapes(self, context)
Draws the shapes in the map to the given context
source code
 
addLayer(self, layerName, visible) source code
 
removeLayer(self, index) source code
 
swapLayers(self, firstIndex, secondIndex) source code
 
setSelection(self, index, x1, y1, x2, y2)
Sets the tile selection.
source code
 
addTile(self, x, y, z, ix, iy, ii)
Adds a tile to the currently selected layer.
source code
 
removeTile(self, x, y, z)
Removes a tile from the selected layer...
source code
[(string, bool)]
getLayerInfo(self)
Returns: names of layers and whether or not they are visible
source code
 
drawTile(self, tile, context, x, y) source code
cairo.ImageSurface[]
drawLayers(self)
Draws layers from tile data
source code
bool
unsaved(self)
Returns: true if the map has unsaved changes, false otherwise
source code
 
notifyModification(self, modified)
Notify the controller (and all of its listeners) of a modification to the map.
source code
 
setToplevel(self, widget) source code
 
getToplevel(self)
This function is here so that dialogs can get a reference to the main window to calculate their position.
source code
 
undo(self) source code
 
redo(self) source code
 
addUndoAction(self, action) source code
Method Details [hide private]

getBGColor(self)

source code 
Returns: graphics.RGBA
Map's background color

setBGColor(self, color)

source code 
Parameters:
  • color (graphics.RGBA) - the new color

addShape(self, shape)

source code 
Parameters:
  • shape (shapes.Shape) - the shape to add to the map

removeShape(self, shape)

source code 
Parameters:
  • shape (shapes.Shape) - the shape to remove

hasMap(self)

source code 
Returns: bool
True if there is a map to edit

open(self, fileName)

source code 

Opens a file

Parameters:
  • fileName (str) - the path of the file to open
Returns: str
Returns a string saying why the file could not be opened, or None

new(self, tileSize, width, height)

source code 

Creates a new map of the given width, height, and tile dimentions

Parameters:
  • tileSize (int) - size of a tile in pixels
  • width (int) - width of map in tiles
  • height (int) - height of map in tiles

selectLayer(self, index)

source code 
Parameters:
  • index (int) - index of layer to select

selectedLayer(self)

source code 
Returns: int
the currently selected layer

mapLayerVisibility(self, index)

source code 
Returns: bool
True if the layer at index is visible

getFileName(self)

source code 
Returns: string
the name of the file currently loaded

addListener(self, listener)

source code 

Brief Description

Parameters:
  • listener (MapListener) - Placeholder

openTileSet(self, fileName)

source code 

Opens an image file and adds it to the list of open images

Parameters:
  • fileName (string) - the name of the file to open
Returns: (cairo.ImageSurface, int)
the opened image and its index

drawShapes(self, context)

source code 

Draws the shapes in the map to the given context

Parameters:
  • context (cairo.Context) - context to draw on

addLayer(self, layerName, visible)

source code 
Parameters:
  • layerName (string) - name for the new layer
  • visible (bool) - True if the layer is visible

removeLayer(self, index)

source code 
Parameters:
  • index (int) - the index of the layer to remove

swapLayers(self, firstIndex, secondIndex)

source code 
Parameters:
  • firstIndex (int) - first layer index
  • secondIndex (int) - second layer index

setSelection(self, index, x1, y1, x2, y2)

source code 

Sets the tile selection. x1 must be less than x2. y1 must be less than y2.

Parameters:
  • index (int) - index of tile set
  • x1 (int) - left edge, in tiles
  • y1 (int) - top edge, in tiles
  • x2 (int) - right edge, in tiles
  • y2 (int) - bottom edge, in tiles

addTile(self, x, y, z, ix, iy, ii)

source code 

Adds a tile to the currently selected layer.
@type x: int
@param x: x-coordinate of tile
@type y: int
@param y: y-coordinate of tile
@type z: int
@param z: layer of the tile
@type ix: int
@param ix: x-coordinate of the image for the tile
@type iy: int
@param iy: y-coordinate of the image for the tile
@type ii: int
@param ii: image index
@rtype: (int, int, int)
@return: The x-coordinate, y-coordinate, and index of the image of the
    tile that used to be at the coordinates (x, y, z), or None if there
        was no tile there before

removeTile(self, x, y, z)

source code 

Removes a tile from the selected layer
@type x: int
@param x: the x-coordinate of the tile to remove
@type y: int
@param y: the y-coordinate of the tile to remove
@rtype: (int, int, int)
@return: The x-coordinate, y-coordinate, and index of the image of the
    tile that used to be at the coordinates (x, y, z), or None if there
        was no tile there before

getLayerInfo(self)

source code 
Returns: [(string, bool)]
names of layers and whether or not they are visible

drawTile(self, tile, context, x, y)

source code 
Parameters:
  • tile (Tile) - tile to draw
  • context (cairo.Context) - context to draw on
  • x (int) - x-coordinate of tile
  • y (int) - y-coordinate of tile

drawLayers(self)

source code 

Draws layers from tile data

Returns: cairo.ImageSurface[]
the layers of the map as 32-bit bitmaps

unsaved(self)

source code 
Returns: bool
true if the map has unsaved changes, false otherwise

notifyModification(self, modified)

source code 

Notify the controller (and all of its listeners) of a modification to the map.

Parameters:
  • modified (bool) - True if the map has been modified, False if it no longer has unsaved changes