diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-27 16:24:12 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-27 16:24:12 +0300 |
commit | a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0 (patch) | |
tree | bd1e6b6a1cdb42b5e6d4489158d438fe8c05f533 /src/listeners | |
parent | af0ae4d0b7c56d540639bb1f4ba7cc458ec718c1 (diff) | |
download | plus-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.gz plus-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.bz2 plus-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.tar.xz plus-a6f6dc9c2db87ed852cac1f8a3047f9b1d3efac0.zip |
Add StatListener.
Diffstat (limited to 'src/listeners')
-rw-r--r-- | src/listeners/statlistener.cpp | 38 | ||||
-rw-r--r-- | src/listeners/statlistener.h | 42 |
2 files changed, 80 insertions, 0 deletions
diff --git a/src/listeners/statlistener.cpp b/src/listeners/statlistener.cpp new file mode 100644 index 000000000..420eb90db --- /dev/null +++ b/src/listeners/statlistener.cpp @@ -0,0 +1,38 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 2 of the License, or + * 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 <http://www.gnu.org/licenses/>. + */ + +#include "listeners/statlistener.h" + +#include "debug.h" + +defineListener(StatListener) + +void StatListener::distributeEvent(const int id, + const int oldVal1, + const int oldVal2) +{ + FOR_EACH (std::vector<StatListener*>::iterator, + it, mListeners) + { + StatListener *const listener = *it; + if (listener) + listener->statChanged(id, oldVal1, oldVal2); + } +} diff --git a/src/listeners/statlistener.h b/src/listeners/statlistener.h new file mode 100644 index 000000000..157dd9346 --- /dev/null +++ b/src/listeners/statlistener.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 2 of the License, or + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef LISTENERS_STATLISTENER_H +#define LISTENERS_STATLISTENER_H + +#include "listeners/baselistener.hpp" + +#include "localconsts.h" + +class StatListener +{ + public: + virtual void statChanged(const int id, + const int oldVal1, + const int oldVal2) = 0; + + static void distributeEvent(const int id, + const int oldVal1, + const int oldVal2); + + defineListenerHeader(StatListener) +}; + +#endif // LISTENERS_STATLISTENER_H |