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/>.
21 // A struct to hold an entire game definition
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"
42 const std::string GAMEFILE
= "game.xml";
46 std::string plugin_name
;
51 struct GamePresentation
63 std::vector
<std::string
> authors
;
64 std::string icon
; // why the hell did i provide for an icon?
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
;
101 class Game
: public EventReceiver
, public ScriptedClass
105 Game(GameData data
, std::string presentation
,
106 MediaLoader
& nmedia_loader
, PluginLoader
& nplugin_loader
);
109 void init(GameInit params
);
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
);
121 func
getConstructor();
124 std::string
getClassName();
125 std::vector
<std::string
> getClassFunctions();
127 Variant
* callFunction(std::string funcname
,
128 std::vector
<Variant
*> params
, ScriptVM
* script_vm
);
132 static Variant
* getCurrentGame(std::vector
<Variant
*>);
133 static GameData
parseXML(std::string path
, MediaLoader
&);
135 InputManager
* getInputManager();
138 MediaLoader
& media_loader
;
139 PluginLoader
& plugin_loader
;
142 AudioDevice
* audio_device
;
147 InputManager
* input_manager
;
151 std::string presentation
;
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
;