fixed win32
[riven-wahrk.git] / src / Stack.h
blob5375f451bf58e2c79462bd297ad06c6fa52e0334
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 #ifndef _STACK_H_
23 #define _STACK_H_
25 #include <iostream>
26 #include <string>
27 #include <vector>
28 #include <list>
29 #include <exception>
30 #include "libconfig.h++"
31 #include <stdint.h>
33 #include "Common.h"
34 #include "Mohawk.h"
37 using namespace libconfig;
39 class Game;
41 // riven is divided up into stacks (one corresponds to each island),
42 // with each stack being split up into different resource types (image,
43 // script, movie) and those split up into different numbers.
47 class ChangeStack : public std::exception {
48 uint32_t stack, hi, lo;
50 public:
51 ChangeStack (uint16_t stackIn, uint16_t hiIn, uint16_t loIn) :
52 stack (stackIn),
53 hi (hiIn),
54 lo (loIn) {
57 void handle (Game *game);
62 class Stack {
64 friend class File;
66 Mohawk *mohawk1, *mohawk2;
68 public:
70 enum Name { ASPIT=0, BSPIT, GSPIT, JSPIT, OSPIT, PSPIT, RSPIT, TSPIT };
72 Stack (const std::string &fileName);
73 Stack (const std::string &file1, const std::string &file2);
74 ~Stack ();
76 // for the given type and id, this returns the name of the mohawk
77 // that contains it, and offset is set to its offset in the mohawk
78 std::string getFileLoc (uint32_t type, int id, uint32_t &offset);
82 // a set is the set of disks (or one disk). the 5 cd's are a set, as well as
83 // the one dvd.
85 class Set {
87 // static vector<Set*> *sets; // all of the sets
88 static std::list<Set> sets;
90 struct Disk {
91 std::string path;
92 Setting *disk;
95 Setting *config;
96 std::list<Disk> disks; // all the disks that belong to this set
98 static void scanDisks (); // scans all the disks, updating all sets
100 // returns true and adds the disk to vector<Disk> disks if the disk belongs
101 // to this set, returns false otherwise
102 bool diskBelong (const std::string &path);
104 // returns the id of the disk for the given stack
105 std::string getDiskId (Stack::Name stack);
107 // returns the name of the disk with the given id
108 std::string getName (const std::string &id);
110 // returns a pointer to the disk with the given id, or NULL if such a disk
111 // isn't inserted/mounted
112 Disk *findDisk (const std::string &id);
114 Set (Setting *con);
116 public:
117 static void init (Setting *setsConfig);
118 static Set *choose () {
119 return & (sets.front ());
122 Stack *loadStack (char name);
123 Stack *loadStack (Stack::Name name);
125 // returns true if this set should be visible in the gui
126 // (like when a disk is inserted for this set, or
127 // files are installed. otherwise don't confuse the user).
128 bool isVisible ();
130 // returns the name of this set, as it should be displayed to the user
131 std::string getName ();
133 // sets can be installed to the hard drive
134 // some sets (like cd's) are required to have
135 // a minimal install, since journals and credits have to
136 // always be accessible. sets like the dvd don't need
137 // a minimal, but can have a full install
139 // NONE: no files installed
140 // MINIMAL: journals, sounds, credits installed
141 // FULL: everything is installed
142 enum InstallType { NONE, MINIMAL, FULL };
144 // returns true if this set needs a minimal install to work (such as 5 cd set)
145 bool needMinInstall ();
147 InstallType getInstallType ();
149 // does minimal install, full install, or deletes the install
150 // returns true if succesful
151 bool doInstall (InstallType type);
153 // get disk usage for this set (in MB)
154 int installedSize ();
160 #endif