20130420
[gdash.git] / src / cave / object / caveobjectfill.cpp
blob7e9f466e830158b535205341cfc1936b1048bc5b
1 /*
2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
19 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include "config.h"
26 #include "cave/object/caveobjectfill.hpp"
28 #include "misc/printf.hpp"
31 /// Create a new fill object.
32 /// @param _start The starting coordinates of the fill.
33 /// @param _fill_element The inside of the area will be filled with this element.
34 CaveFill::CaveFill(CaveObject::Type _type, Coordinate _start, GdElementEnum _fill_element)
35 : CaveObject(_type),
36 start(_start),
37 fill_element(_fill_element) {
40 std::string CaveFill::get_coordinates_text() const {
41 return SPrintf("%d,%d") % start.x % start.y;
44 GdElementEnum CaveFill::get_characteristic_element() const {
45 return fill_element;
48 void CaveFill::create_drag(Coordinate current, Coordinate displacement) {
49 start = current;
52 void CaveFill::move(Coordinate current, Coordinate displacement) {
53 if (start == current) /* can only drag by the starting point */
54 start += displacement;
57 void CaveFill::move(Coordinate displacement) {
58 start += displacement;