WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
Driver_GlobalObjects.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef WORLDSIM_DRIVER_GLOBAL_OBJECTS_HPP
3 #define WORLDSIM_DRIVER_GLOBAL_OBJECTS_HPP
4 
5 // GLOBAL RNG //////////////////////////////////////////////////////////////////////////////////////////////
6 
7 #include <Math/Random/RandomLehmer.hpp>
8 // use this to seed all RNGs instead of time(NULL)
9 RandomLehmer SEEDER;
10 
11 RandomLehmer globalRandom; // global rng. Maybe should be replaced with static class functions.
12 RandomLehmer RNG_TEST; // for testing
13 
14 #include <Math/Random/GlobalRandom.hpp>
15 /* No need for a globalRandom object. Just use Random:: */
16 
17 // MISC GLOBAL OBJECTS (SHOULD PROBABLY BE ORGANISED) //////////////////////////////////////////////////////
18 
20 
21 #include <Game/Language/NameGenerator.cpp>
22 NameGenerator globalNameGen;
23 
24 #include <Game/Language/NameGeneratorWord.cpp>
25 NameGeneratorWord gNameGeneratorWord;
26 
27 #include <Game/Calendar/Calendar.hpp>
28 Calendar globalCalendar;
29 
30 #include <Graphics/Colour/Colour.hpp> // loading raw colours
31 #include <Graphics/Colour/ColourManager.hpp> // loading raw colours
32 ColourManager <unsigned char> colourManager;
33 
34 #include "TextureManager.hpp"
36 
37  // VECTOR OF MESSAGES FOR THE PLAYER TO READ (Really should be an object)
38 #include <string>
39 #include <Container/Vector/Vector.hpp>
40 Vector <std::string> vConsoleMessage;
41 
42 inline void consoleMessage(std::string s)
43 {
44  vConsoleMessage.push(s);
45 }
46 
47 inline void Console (std::string s)
48 {
49  vConsoleMessage.push(s);
50 }
51 
52 #include <Graphics/Font/Font.hpp>
53 
54 // This is the global font for now.
55 Wildcat::Font font8x8;
56 Wildcat::Font font8x8White; // My code currently only allows colour on white font.
57 
58 #include <Device/Mouse/Mouse.hpp>
60 #include <Device/Keyboard/Keyboard.hpp>
61 Keyboard globalKeyboard;
62 
63 #include <System/Time/Timer.hpp>
70 /* Use this for checking algo speeds. */
71 Timer debugTimer;
72 
73  // DYNAMICALLY GENERATED HEADER FILE WITH STRING WHICH COUNTS COMPILATIONS.
74 #include "CompileCount.hpp"
75 
76 #include "Creature_Generator.cpp"
78 
79 #include <File/SaveFileManager.hpp>
80  // Class for managing world save files.
81 SaveFileManager saveFileManager;
82 
83 #include <Device/Display/DisplayInterface.hpp>
84 #include <Device/Display/DisplayInterfaceManager.hpp>
85 /* Global display interface manager, to handle all rendering called by driver. */
86 DisplayInterfaceManager displayInterfaceManager;
87 
88 #include <Device/Mouse/MouseInterface.hpp>
89 #include <Device/Mouse/MouseInterfaceManager.hpp>
90 /* Global mouse interface manager. To handle all objects that recieve mouse events. */
91 MouseInterfaceManager mouseInterfaceManager;
92 
93 
94 #include <Device/Keyboard/KeyboardInterface.hpp>
95 #include <Device/Keyboard/KeyboardInterfaceManager.hpp>
96 /* Global keyboard interface manager. To handle all objects that recieve keyboard events. */
97 KeyboardInterfaceManager keyboardInterfaceManager;
98 
99 #include <Graphics/GUI/GUI_Manager.hpp>
100 #include <Graphics/GUI/GUI.hpp>
101 /* GUI manager. Manages all GUI controls. */
102 GUI_Manager globalGuiManager;
103 
104 
105 #include <Interface/LogicTick/LogicTickInterface.hpp>
106 #include <Interface/LogicTick/LogicTickManager.hpp>
107 LogicTickManager logicTickManager;
108 
109 #include <Interface/IdleTick/IdleTickInterface.hpp>
110 #include <Interface/IdleTick/IdleTickManager.hpp>
111 IdleTickManager idleManager;
112 
113 // Runs on application exit
114 #include "Driver_QuitChecker.hpp"
116 
117 //Stolen from https://codereview.stackexchange.com/questions/226/formatter-class
118 // This allows you to pass multiple datatypes as an std::string.
119 // Use like this: function( Stream() << "Error Recieved" << 42 << " " << some_code << " '" << some_msg << "'");
120 // Should be moved into Wildcat
121 class Stream
122 {
123  public:
124  std::stringstream ss_;
125  // Build a string by chaining << operators.
126  template<class Field> Stream& operator<<(Field f)
127  {
128  ss_ << f;
129  return *this;
130  }
131  // This is a custom typecast to std::string. (C++11)
132  operator std::string() const { return ss_.str(); }
133 };
134 
135 
136 #endif
Definition: Driver_GlobalObjects.hpp:121
void Console(std::string s)
Definition: Driver_GlobalObjects.hpp:47
Definition: TextureManager.hpp:17
Definition: Creature_Generator.hpp:15
RandomLehmer SEEDER
Definition: Driver_GlobalObjects.hpp:9
NameGeneratorWord gNameGeneratorWord
Definition: Driver_GlobalObjects.hpp:25
RandomLehmer globalRandom
Definition: Driver_GlobalObjects.hpp:11
GUI_Manager globalGuiManager
Definition: Driver_GlobalObjects.hpp:102
Wildcat::Font font8x8White
Definition: Driver_GlobalObjects.hpp:56
ColourManager< unsigned char > colourManager
Definition: Driver_GlobalObjects.hpp:32
Mouse globalMouse
Definition: Driver_GlobalObjects.hpp:59
NameGenerator globalNameGen
Definition: Driver_GlobalObjects.hpp:22
Wildcat::Font font8x8
Definition: Driver_GlobalObjects.hpp:55
Vector< std::string > vConsoleMessage
Definition: Driver_GlobalObjects.hpp:40
Creature_Generator creatureGenerator
Definition: Driver_GlobalObjects.hpp:77
Stream & operator<<(Field f)
Definition: Driver_GlobalObjects.hpp:126
Keyboard globalKeyboard
Definition: Driver_GlobalObjects.hpp:61
Timer logicRateTimer
Definition: Driver_GlobalObjects.hpp:66
Timer debugTimer
Definition: Driver_GlobalObjects.hpp:71
Timer physicsRateTimer
Definition: Driver_GlobalObjects.hpp:67
Calendar globalCalendar
Definition: Driver_GlobalObjects.hpp:28
RandomLehmer RNG_TEST
Definition: Driver_GlobalObjects.hpp:12
void consoleMessage(std::string s)
Definition: Driver_GlobalObjects.hpp:42
KeyboardInterfaceManager keyboardInterfaceManager
Definition: Driver_GlobalObjects.hpp:97
Timer frameRateTimer
Definition: Driver_GlobalObjects.hpp:64
Timer animationTimer
Definition: Driver_GlobalObjects.hpp:68
TextureManager textureManager
Definition: Driver_GlobalObjects.hpp:35
LogicTickManager logicTickManager
Definition: Driver_GlobalObjects.hpp:107
Definition: Driver_QuitChecker.hpp:10
MouseInterfaceManager mouseInterfaceManager
Definition: Driver_GlobalObjects.hpp:91
Timer pollRateTimer
Definition: Driver_GlobalObjects.hpp:65
IdleTickManager idleManager
Definition: Driver_GlobalObjects.hpp:111
QuitChecker quitChecker
Definition: Driver_GlobalObjects.hpp:115
Timer playerKeypressTimer
Definition: Driver_GlobalObjects.hpp:69
DisplayInterfaceManager displayInterfaceManager
Definition: Driver_GlobalObjects.hpp:86
std::stringstream ss_
Definition: Driver_GlobalObjects.hpp:124
SaveFileManager saveFileManager
Definition: Driver_GlobalObjects.hpp:81