C1: deny drops into black holes
[openc2e.git] / Engine.h
blob356642c4a854fdb37a4c521723e44902a47f199a
1 /*
2 * Engine.h
3 * openc2e
5 * Created by Alyssa Milburn on Tue Nov 28 2006.
6 * Copyright (c) 2006 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
20 #ifndef _ENGINE_H
21 #define _ENGINE_H
23 #include "caosVar.h"
24 #include <map>
25 #include <boost/filesystem/path.hpp>
27 class Backend;
28 class AudioBackend;
29 struct SomeEvent;
31 class Engine {
32 protected:
33 unsigned int tickdata;
34 unsigned int ticktimes[10];
35 unsigned int ticktimeptr;
36 unsigned int lasttimestamp;
38 bool w_down, a_down, s_down, d_down;
39 unsigned char *palette;
41 bool cmdline_enable_sound;
42 bool cmdline_norun;
43 std::vector<std::string> cmdline_bootstrap;
45 std::string gamename;
47 std::map<std::string, boost::shared_ptr<Backend> > possible_backends;
48 std::map<std::string, boost::shared_ptr<class AudioBackend> > possible_audiobackends;
49 std::string preferred_backend, preferred_audiobackend;
51 public:
52 std::map<caosVar, caosVar, caosVarCompare> eame_variables; // non-serialised
54 boost::shared_ptr<Backend> backend;
55 boost::shared_ptr<class AudioBackend> audio;
56 std::string getBackendName() { return preferred_backend; }
57 std::string getAudioBackendName() { return preferred_audiobackend; }
59 unsigned char *getPalette() { return palette; }
61 std::string getGameName() { return gamename; }
63 bool done;
64 bool dorendering, fastticks, refreshdisplay;
65 unsigned int version;
66 bool bmprenderer;
68 Engine();
69 ~Engine();
70 void setBackend(boost::shared_ptr<Backend> b);
71 std::string executeNetwork(std::string in);
72 bool needsUpdate();
73 void update();
74 bool tick();
75 void handleKeyboardScrolling();
76 void processEvents();
77 void handleResizedWindow(SomeEvent &event);
78 void handleMouseMove(SomeEvent &event);
79 void handleMouseButton(SomeEvent &event);
80 void handleKeyDown(SomeEvent &event);
81 void handleSpecialKeyDown(SomeEvent &event);
82 void handleSpecialKeyUp(SomeEvent &event);
84 void addPossibleBackend(std::string, boost::shared_ptr<Backend>);
85 void addPossibleAudioBackend(std::string, boost::shared_ptr<AudioBackend>);
87 bool parseCommandLine(int argc, char *argv[]);
88 bool initialSetup();
89 void shutdown();
91 bool noRun() { return cmdline_norun; }
93 boost::filesystem::path homeDirectory();
94 boost::filesystem::path storageDirectory();
97 extern Engine engine;
98 #endif
99 /* vim: set noet: */