fixed win32
[riven-wahrk.git] / src / Game.cpp
blob68a2087c31299200c543349560409faabd559591
2 /*
4 * Riven-Wahrk - a reimplementation of the game Riven, by Cyan
5 * Copyright (C) 2009 Tyler Genter <tylergenter@gmail.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <iostream>
23 #include <string>
24 #include <stdlib.h>
26 #include "Game.h"
27 #include "Twav.h"
29 Game::Game () :
30 scene (this) {
32 zipMode = false;
33 insideCard = false;
34 ignoreMouseUp = false;
37 diskSets.readFile ("disks");
38 Set::init (&diskSets.lookup ("sets"));
39 set = Set::choose ();
41 loadStack (Stack::JSPIT);
43 var.loadGame ("sub.rvn");
45 card = new Card (this, 527);
46 mouseCoor.y = mouseCoor.x = 0;
50 void Game::loadStack (Stack::Name name) {
52 stackName = name;
53 stack = set->loadStack (Stack::JSPIT);
54 var.setStack (stack);
59 void Game::mouseMove (const Coor &coorIn) {
60 mouseCoor = coorIn;
61 if (insideCard) return;
62 insideCard = true;
63 card->mouseMove (mouseCoor);
64 insideCard = false;
67 void Game::mouseDown () {
68 if (insideCard) return;
69 insideCard = true;
70 Card *old = card;
71 card->mouseDown ();
72 if (old != card)
73 // we are at a new card, so ignore the next time we get a mouse
74 // up signal.
75 ignoreMouseUp = true;
76 insideCard = false;
79 void Game::mouseUp () {
80 if (insideCard) return;
81 if (ignoreMouseUp) {
82 ignoreMouseUp = false;
83 return;
85 insideCard = true;
86 card->mouseUp ();
87 insideCard = false;
91 #if 0
92 void Game::findSet (Stack *saveGame) {
94 File vers (saveGame, Resource::VERS, 1);
95 uint32_t version = vers.readULong (0);
97 Setting& s = diskSets.lookup ("sets");
98 for (int i=0; i<s.getLength(); i++) {
99 if (version == (uint32_t) (s[i]["save_ver"])) {
100 std::cout << "save game identified as "
101 << (const char*) s[i]["name"] << std::endl;
102 set = &(s[i]);
103 return;
106 set = NULL;
109 void Game::loadStack (Stack::Name stack) {
112 #endif
114 // have to identify which version to use.
115 // if a savegame is specified, use which ever
116 // version that requires. otherwise present a
117 // generic prompt asking to put in dvd or disk 1.
118 // do a checkAStack (if we are using cd's, copy a_spit
119 // to ~, otherwise just open the dvd's a_spit.) go to
120 // the card in save game, or go to main menu