/* * Copyright 2007-2008 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ // Header include #include "MapEffect.h" // Sigmod includes #include "Macros.h" #include "Map.h" #include "Sigmod.h" Sigmod::MapEffect::MapEffect(const MapEffect& effect) : Object(effect.parent(), effect.id()) { *this = effect; } Sigmod::MapEffect::MapEffect(const Map* parent, const int id) : Object(parent, id), m_name(""), m_coordinate(0, 0), m_skin(-1), m_isGhost(false), m_script("", "") { } Sigmod::MapEffect::MapEffect(const MapEffect& effect, const Map* parent, const int id) : Object(parent, id) { *this = effect; } Sigmod::MapEffect::MapEffect(const QDomElement& xml, const Map* parent, const int id) : Object(parent, id) { LOAD_ID(); load(xml); } void Sigmod::MapEffect::validate() { TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(setCoordinate, coordinate); TEST(setSkin, skin); TEST_END(); } void Sigmod::MapEffect::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); LOAD(coordinate); LOAD(skin); LOAD(isGhost); LOAD(script); } QDomElement Sigmod::MapEffect::save() const { SAVE_CREATE(); SAVE(name); SAVE(coordinate); SAVE(skin); SAVE(isGhost); SAVE(script); return xml; } void Sigmod::MapEffect::setName(const QString& name) { CHECK(name); } void Sigmod::MapEffect::setCoordinate(const QPoint& coordinate) { if ((qobject_cast(parent())->width() <= coordinate.x()) || (qobject_cast(parent())->height() <= coordinate.y())) emit(error(bounds("coordinate"))); else CHECK(coordinate); } void Sigmod::MapEffect::setSkin(const int skin) { if (qobject_cast(sigmod())->skinIndex(skin) == INT_MAX) emit(error(bounds("skin"))); else CHECK(skin); } void Sigmod::MapEffect::setIsGhost(const bool isGhost) { CHECK(isGhost); } void Sigmod::MapEffect::setScript(const Script& script) { CHECK(script); } QString Sigmod::MapEffect::name() const { return m_name; } QPoint Sigmod::MapEffect::coordinate() const { return m_coordinate; } int Sigmod::MapEffect::skin() const { return m_skin; } bool Sigmod::MapEffect::isGhost() const { return m_isGhost; } Sigmod::Script Sigmod::MapEffect::script() const { return m_script; } Sigmod::MapEffect& Sigmod::MapEffect::operator=(const MapEffect& rhs) { if (this == &rhs) return *this; COPY(name); COPY(coordinate); COPY(skin); COPY(isGhost); COPY(script); return *this; }