nonhumans separation
[k8-i-v-a-n.git] / src / game / main.cpp
blobc410fdf724da217c9987846ef11e155ebf65dc88
1 /*
3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
6 * Public License
8 * See LICENSING which should be included
9 * along with this file for more details
12 #include <iostream>
14 #include "game.h"
15 #include "database.h"
16 #include "feio.h"
17 #include "igraph.h"
18 #include "iconf.h"
19 #include "whandler.h"
20 #include "hscore.h"
21 #include "graphics.h"
22 #include "script.h"
23 #include "message.h"
24 #include "proto.h"
27 int Main (int argc, char **argv) {
28 if (argc > 1 && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v"))) {
29 std::cout << "Iter Vehemens ad Necem version " << IVAN_VERSION << std::endl;
30 return 0;
33 femath::SetSeed(time(0));
34 game::InitGlobalValueMap();
35 scriptsystem::Initialize();
36 databasesystem::Initialize();
37 game::InitLuxTable();
38 ivanconfig::Initialize();
39 igraph::Init();
40 game::CreateBusyAnimationCache();
41 globalwindowhandler::SetQuitMessageHandler(game::HandleQuitMessage);
42 msgsystem::Init();
43 protosystem::Initialize();
44 igraph::LoadMenu();
46 for(;;) {
47 int Select = iosystem::Menu(
48 igraph::GetMenuGraphic(),
49 v2(RES.X / 2, RES.Y / 2 - 20),
50 CONST_S("\r"),
51 CONST_S("Start Game\rContinue Game\rConfiguration\rHighscores\rQuit\r"),
52 LIGHT_GRAY,
53 CONST_S("Released under the GNU\rGeneral Public License\rMore info: see COPYING\r"),
54 CONST_S("IVAN v" IVAN_VERSION "\r"),
55 true);
56 switch (Select) {
57 case -1: return 0; // esc
58 case 0:
59 if (game::Init()) {
60 igraph::UnLoadMenu();
61 game::Run();
62 game::DeInit();
63 igraph::LoadMenu();
65 break;
66 case 1: {
67 festring LoadName = iosystem::ContinueMenu(WHITE, LIGHT_GRAY, game::GetSaveDir());
68 if (LoadName.GetSize()) {
69 LoadName.Resize(LoadName.GetSize()-4);
70 if (game::Init(LoadName)) {
71 igraph::UnLoadMenu();
72 game::Run();
73 game::DeInit();
74 igraph::LoadMenu();
77 break; }
78 case 2:
79 ivanconfig::Show();
80 break;
81 case 3: {
82 highscore HScore;
83 HScore.Draw();
84 break; }
85 case 4: return 0;
91 #ifdef WIN32
92 # include <windows.h>
93 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) {
94 //return Main(argc, argv);
95 //FIXME:
96 static char *argv[2] = { "ivan.exe", NULL };
97 return Main(1, argv);
99 #endif