| 1 |
// Copyright © 2003 Rob Kaper <[email protected]> |
| 2 |
// 2010-2015 Sylvain Rochet <[email protected]> |
| 3 |
// |
| 4 |
// This program is free software; you can redistribute it and/or |
| 5 |
// modify it under the terms of the GNU General Public License |
| 6 |
// version 2 as published by the Free Software Foundation. |
| 7 |
// |
| 8 |
// This program is distributed in the hope that it will be useful, |
| 9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
// General Public License for more details. |
| 12 |
// |
| 13 |
// You should have received a copy of the GNU General Public License |
| 14 |
// along with this program; see the file COPYING. If not, see |
| 15 |
// <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
#include "config.h" |
| 18 |
|
| 19 |
#include "gameobject.h" |
| 20 |
#include "gameproperty.h" |
| 21 |
|
| 22 |
GameProperty::GameProperty(const std::string &key, GameObject *scope) |
| 23 |
{ |
| 24 |
m_key = key; |
| 25 |
m_scope = scope; |
| 26 |
m_changed = true; |
| 27 |
} |
| 28 |
|
| 29 |
std::string GameProperty::key() const |
| 30 |
{ |
| 31 |
return m_key; |
| 32 |
} |
| 33 |
|
| 34 |
GameObject *GameProperty::scope() |
| 35 |
{ |
| 36 |
return m_scope; |
| 37 |
} |
| 38 |
|
| 39 |
void GameProperty::setChanged(const bool &changed) |
| 40 |
{ |
| 41 |
m_changed = changed; |
| 42 |
} |
| 43 |
|
| 44 |
bool GameProperty::changed() const |
| 45 |
{ |
| 46 |
return m_changed; |
| 47 |
} |
| 48 |
|
| 49 |
GameIntProperty::GameIntProperty(const std::string &key, int value, GameObject *scope) : GameProperty(key, scope) |
| 50 |
{ |
| 51 |
m_value = value; |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
bool GameIntProperty::setValue(int value) |
| 56 |
{ |
| 57 |
if (m_value != value) |
| 58 |
{ |
| 59 |
m_value = value; |
| 60 |
m_changed = true; |
| 61 |
} |
| 62 |
return m_changed; |
| 63 |
} |
| 64 |
|
| 65 |
int GameIntProperty::value() |
| 66 |
{ |
| 67 |
return m_value; |
| 68 |
} |
| 69 |
|
| 70 |
GameStringProperty::GameStringProperty(const std::string &key, const std::string &value, GameObject *scope) : GameProperty(key, scope) |
| 71 |
{ |
| 72 |
m_value = value; |
| 73 |
} |
| 74 |
|
| 75 |
bool GameStringProperty::setValue(const std::string &value) |
| 76 |
{ |
| 77 |
if (m_value != value) |
| 78 |
{ |
| 79 |
m_value = value; |
| 80 |
m_changed = true; |
| 81 |
} |
| 82 |
return m_changed; |
| 83 |
} |
| 84 |
|
| 85 |
std::string GameStringProperty::value() const |
| 86 |
{ |
| 87 |
return m_value; |
| 88 |
} |
| 89 |
|
| 90 |
GameBoolProperty::GameBoolProperty(const std::string &key, const bool &value, GameObject *scope) : GameProperty(key, scope) |
| 91 |
{ |
| 92 |
m_value = value; |
| 93 |
} |
| 94 |
|
| 95 |
bool GameBoolProperty::setValue(const bool &value) |
| 96 |
{ |
| 97 |
if (m_value != value) |
| 98 |
{ |
| 99 |
m_value = value; |
| 100 |
m_changed = true; |
| 101 |
} |
| 102 |
return m_changed; |
| 103 |
} |
| 104 |
|
| 105 |
bool GameBoolProperty::value() const |
| 106 |
{ |
| 107 |
return m_value; |
| 108 |
} |