FRESH AND RAW
[potpourri.git] / include / core / Game.h
bloba904182e4e371dd17c59313799fd43043a2397d9
1 // Copyright 2008 Brian Caine
3 // This file is part of Potpourri.
5 // Potpourri is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Potpourri is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTIBILITY of FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Potpourri. If not, see <http://www.gnu.org/licenses/>.
19 // NOTES:
21 // A struct to hold an entire game definition
23 #ifndef __GAME_H
24 #define __GAME_H
26 #include "Level.h"
27 #include "Actor.h"
29 #include "../plugins/graphics/Graphics.h"
30 #include "../plugins/script/ScriptVM.h"
31 #include "../plugins/audio/Audio.h"
32 #include "../plugins/input/InputManager.h"
34 #include "EventPipeline.h"
36 #include <string>
37 #include <vector>
38 #include <map>
40 namespace fragrant
42 const std::string GAMEFILE = "game.xml";
44 struct GameMedia
46 std::string plugin_name;
47 std::string name;
48 std::string contents;
51 struct GamePresentation
53 std::string name;
54 Pair<int> size;
55 bool net;
58 struct GameData
60 // meta
61 std::string name;
62 std::string version;
63 std::vector<std::string> authors;
64 std::string icon; // why the hell did i provide for an icon?
66 std::string base;
68 std::vector<GamePresentation> presentations;
69 std::map<std::string, std::string> controls;
71 std::string graphics_plugin;
72 std::string scripting_plugin;
73 std::string audio_plugin;
74 std::string input_plugin;
76 std::vector<std::string> extra_plugins;
78 std::vector<GameMedia> media;
80 std::vector<std::string> actors;
81 std::vector<std::string> levels;
83 void printData();
86 struct GameInit
88 GraphicsPair size;
89 int bpp;
91 int frequency;
92 int format;
93 int channels;
94 int chunksize;
97 class Level;
98 struct ActorData;
99 struct LevelData;
100 class MediaLoader;
101 class Game : public EventReceiver, public ScriptedClass
103 public:
105 Game(GameData data, std::string presentation,
106 MediaLoader& nmedia_loader, PluginLoader& nplugin_loader);
107 ~Game();
109 void init(GameInit params);
110 void run();
112 void raiseEvent(Event event);
114 Drawable* getGraphics(std::string name,
115 std::map<std::string, Variant*> params);
116 AudioSample* getAudio(std::string name);
117 std::string getFile(std::string name);
119 // script stuff
121 func getConstructor();
122 void destroy();
124 std::string getClassName();
125 std::vector<std::string> getClassFunctions();
127 Variant* callFunction(std::string funcname,
128 std::vector<Variant*> params, ScriptVM* script_vm);
130 // other stuff
132 static Variant* getCurrentGame(std::vector<Variant*>);
133 static GameData parseXML(std::string path, MediaLoader&);
135 InputManager* getInputManager();
137 private:
138 MediaLoader& media_loader;
139 PluginLoader& plugin_loader;
141 Display* display;
142 AudioDevice* audio_device;
144 Graphics graphics;
145 Audio audio;
146 ScriptVM* script_vm;
147 InputManager* input_manager;
149 Level* level;
151 std::string presentation;
152 GameData data;
154 std::map<std::string, LevelData> level_defs;
155 std::vector<ActorData> actor_defs;
157 std::map<std::string, Drawable*> graphic_samples;
158 std::map<std::string, AudioSample*> audio_samples;
160 static Game* current_game;
164 #endif