/
Xsera.cpp
75 lines (62 loc) · 1.31 KB
/
Xsera.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <SDL/SDL.h>
#include "Apollo.h"
namespace XseraMain
{
void RunLoop ()
{
UpdateModeManager();
}
unsigned ToInt ( const std::string& value )
{
return atoi(value.c_str());
}
bool ToBool ( const std::string& value )
{
return value == "true";
}
float ToFloat ( const std::string& value )
{
return (float)atof(value.c_str());
}
void Startup ()
{
// do init stuff
InitModeManager();
ResourceManager::Init("Xsera");
// check machine power
CheckMachinePowerSanity();
Preferences::Load();
Graphics::Init(ToInt(Preferences::Get("Screen/Width")), ToInt(Preferences::Get("Screen/Height")), ToBool(Preferences::Get("Screen/Fullscreen")));
Sound::Init(ToInt(Preferences::Get("Audio/SamplingRate")), ToInt(Preferences::Get("Audio/Resolution")), ToInt(Preferences::Get("Audio/Channels")));
Sound::SetMusicVolume(ToFloat(Preferences::Get("Audio/MusicVolume")));
Sound::SetSoundVolume(ToFloat(Preferences::Get("Audio/SoundVolume")));
Graphics::BeginFrame();
Graphics::EndFrame();
LuaScript bootScript ("System/Boot");
#ifdef NDEBUG
SwitchMode("Xsera/Intro");
#else
SwitchMode("Xsera/MainMenu");
#endif
}
void MainLoop ()
{
while (true)
{
RunLoop();
SDL_Delay(1);
}
}
}
// standard setup functions
void Init ()
{
XseraMain::Startup();
}
void MainLoop ()
{
XseraMain::MainLoop();
}
void Shutdown ()
{
}