Mercurial > fife-parpg
changeset 340:7e5717105212
* Added setId to Layer, Map, Object and Camera
* Added setCellGrid to Layer
* LayerTool now supports changing layer IDs and cellgrids on existing layers
* LayerTool can now create layers with hexagonal tilegrids
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 24 Aug 2009 23:08:53 +0000 |
parents | 0fd74235b34d |
children | 3a268cf93752 |
files | clients/editor/plugins/LayerTool.py engine/core/model/metamodel/object.h engine/core/model/structures/layer.h engine/core/model/structures/layer.i engine/core/model/structures/map.h engine/core/model/structures/map.i engine/core/view/camera.h engine/core/view/camera.i |
diffstat | 8 files changed, 52 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/clients/editor/plugins/LayerTool.py Mon Aug 24 18:52:49 2009 +0000 +++ b/clients/editor/plugins/LayerTool.py Mon Aug 24 23:08:53 2009 +0000 @@ -350,7 +350,7 @@ self._widget = pychan.loadXML('gui/layereditor.xml') # TODO: Add access method for adopted grid types? - self._widget.findChild(name="gridBox").items = ['square']#, 'hex'] # Hex does not work? + self._widget.findChild(name="gridBox").items = ['square', 'hexagonal'] # TODO: Ditto for pather? self._widget.findChild(name="pathingBox").items = ['cell_edges_only', 'cell_edges_and_diagonals', 'freeform'] @@ -358,7 +358,7 @@ if layer: cg = layer.getCellGrid() cgtype = 0 - if cg.getType() == 'hex': + if cg.getType() == 'hexagonal': cgtype = 1 self._widget.distributeData({ @@ -423,24 +423,24 @@ if grid_type == 0: grid_type = "square" else: - grid_type = "hex" + grid_type = "hexagonal" # Set up layer layer = self.layer cellgrid = None - if not self.layer: - # TODO: FIFE currently does not support setting layer ID and cellgrid after the layer has been created - cellgrid = self.model.getCellGrid(grid_type) - if not cellgrid: - print "Invalid grid type" - return + + cellgrid = self.model.getCellGrid(grid_type) + if not cellgrid: + print "Invalid grid type" + return - cellgrid.setRotation(rotation) - cellgrid.setXScale(x_scale) - cellgrid.setYScale(y_scale) - cellgrid.setXShift(x_offset) - cellgrid.setYShift(y_offset) + cellgrid.setRotation(rotation) + cellgrid.setXScale(x_scale) + cellgrid.setYScale(y_scale) + cellgrid.setXShift(x_offset) + cellgrid.setYShift(y_offset) + if not self.layer: try: layer = self.map.createLayer(str(layerId), cellgrid) @@ -448,12 +448,12 @@ print 'The layer ' + str(layerId) + ' already exists!' return else: - cellgrid = layer.getCellGrid() - cellgrid.setRotation(rotation) - cellgrid.setXScale(x_scale) - cellgrid.setYScale(y_scale) - cellgrid.setXShift(x_offset) - cellgrid.setYShift(y_offset) + layer.setCellGrid(cellgrid) + try: + layer.setId(str(layerId)) + except fife.NameClash: + print 'The layer ' + str(layerId) + ' already exists!' + return layer.setPathingStrategy(pathing)
--- a/engine/core/model/metamodel/object.h Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/model/metamodel/object.h Mon Aug 24 23:08:53 2009 +0000 @@ -68,6 +68,10 @@ const std::string& getId() const { return m_id; } const std::string& getNamespace() const { return m_namespace; } + /** Sets the identifier for this object. + */ + void setId(const std::string& id) { m_id = id; } + /** Adds new action with given id. In case there is action already * with given id, returns it instead of new object * Action instances are managed by object
--- a/engine/core/model/structures/layer.h Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/model/structures/layer.h Mon Aug 24 23:08:53 2009 +0000 @@ -103,17 +103,25 @@ /** Get the id of this layer. */ - const std::string& getId() { return m_id; } + const std::string& getId() const { return m_id; } + + /** Sets the identifier for this layer. + */ + void setId(const std::string& id) { m_id = id; } /** Get the map this layer is contained in */ Map* getMap() const { return m_map; } - /** Get the Cellgrid as set in the constructor + /** Get the Cellgrid * @return a valid cellgrid */ CellGrid* getCellGrid() const { return m_grid; } + /** Set the Cellgrid + */ + void setCellGrid(CellGrid* grid) { m_grid = grid; } + /** Get the instance tree. * @return this layers instance tree. */
--- a/engine/core/model/structures/layer.i Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/model/structures/layer.i Mon Aug 24 23:08:53 2009 +0000 @@ -58,9 +58,11 @@ Layer(const std::string& identifier, Map* map, CellGrid* geometry); ~Layer(); - const std::string& getId(); + const std::string& getId() const; + void setId(const std::string& id); - CellGrid* getCellGrid() const { return m_grid; } + CellGrid* getCellGrid() const; + void setCellGrid(CellGrid* grid); Map* getMap(); bool hasInstances() const;
--- a/engine/core/model/structures/map.h Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/model/structures/map.h Mon Aug 24 23:08:53 2009 +0000 @@ -94,7 +94,11 @@ /** Get the identifier for this map. */ - const std::string& getId() { return m_id; } + const std::string& getId() const { return m_id; } + + /** Sets the identifier for this map. + */ + void setId(const std::string& id) { m_id = id; } /** Add a Layer to this Map. Map owns the returned pointer to the new Layer, so don't delete it! */
--- a/engine/core/model/structures/map.i Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/model/structures/map.i Mon Aug 24 23:08:53 2009 +0000 @@ -54,7 +54,8 @@ Map(const std::string& identifier, TimeProvider* tp_master=NULL); ~Map(); - const std::string& getId(); + const std::string& getId() const; + void setId(const std::string& id); Layer* createLayer(const std::string& identifier, CellGrid* grid); void deleteLayer(Layer* index);
--- a/engine/core/view/camera.h Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/view/camera.h Mon Aug 24 23:08:53 2009 +0000 @@ -81,7 +81,11 @@ /** Gets the identifier for this camera. */ - const std::string& getId() { return m_id; } + const std::string& getId() const { return m_id; } + + /** Sets the identifier for this camera. + */ + void setId(const std::string& id) { m_id = id; } /** Sets tilt for the camera. * e.g. overhead camera has tilt 0, while traditional isometric camera has tilt 45
--- a/engine/core/view/camera.i Mon Aug 24 18:52:49 2009 +0000 +++ b/engine/core/view/camera.i Mon Aug 24 23:08:53 2009 +0000 @@ -35,7 +35,8 @@ class Camera: public IRendererContainer { public: ~Camera(); - const std::string& getId(); + const std::string& getId() const; + void setId(const std::string& id); void setTilt(double tilt); double getTilt() const; void setRotation(double rotation);