redid set handling, again. did other stuff
[riven-wahrk.git] / src / card.cpp
blob92b1093433d173bbb933294b406736b7045eb60b
2 /*
3 * Riven-Wahrk - a reimplementation of the game Riven, by Cyan
4 * Copyright (C) 2009-2010 Tyler Genter <tylergenter@gmail.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <iostream>
22 #include "card.h"
23 #include "game.h"
25 using namespace riven;
27 static std::vector<card_t*> old_cards;
28 card_t *card_t::current;
31 card_t::card_t (int idIn) :
32 file_t (resource_t::CARD, idIn),
33 script (this, 4),
34 plst (idIn),
35 hotspot (idIn) {
37 id = idIn;
39 std::cout << "opening new card " << id << "\n";
41 current = this;
43 script.run_handler (handler_t::CardLoad);
44 script.run_handler (handler_t::DisplayUpdate);
45 script.run_handler (handler_t::CardOpen);
46 hotspot.mouseMove (game::mouseCoor.x, game::mouseCoor.y);
50 void card_t::close () {
51 std::cout << "closing card\n";
52 script.run_handler (handler_t::CardClose);
53 old_cards.push_back (this);
56 void card_t::deleteOldCards () {
58 std::vector<card_t*>::iterator iter = old_cards.begin();
59 while (iter != old_cards.end()) {
60 if (*iter != this) {
61 delete *iter;
62 iter = old_cards.erase (iter);
63 } else
64 iter++;