cosmetix
[k8-i-v-a-n.git] / src / game / main.cpp
blob7d4e2ba28ed80c8596236ec74141516a9f211bfb
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 "ivancommon.h"
14 #include <iostream>
16 #include "game.h"
17 #include "database.h"
18 #include "feio.h"
19 #include "igraph.h"
20 #include "iconf.h"
21 #include "whandler.h"
22 #include "hscore.h"
23 #include "graphics.h"
24 #include "script.h"
25 #include "message.h"
26 #include "proto.h"
29 int Main (int argc, char *argv[]) {
30 if (argc > 1 && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v"))) {
31 std::cout << "Iter Vehemens ad Necem version " << IVAN_VERSION << std::endl;
32 return 0;
35 femath::SetSeed(time(0));
36 game::InitGlobalValueMap();
37 scriptsystem::Initialize();
38 databasesystem::Initialize();
39 game::InitLuxTable();
40 ivanconfig::Initialize();
41 igraph::Init();
42 game::CreateBusyAnimationCache();
43 globalwindowhandler::SetQuitMessageHandler(game::HandleQuitMessage);
44 msgsystem::Init();
45 protosystem::Initialize();
46 igraph::LoadMenu();
48 for(;;) {
49 int Select = iosystem::Menu(
50 igraph::GetMenuGraphic(),
51 v2(RES.X / 2, RES.Y / 2 - 20),
52 CONST_S("\r"),
53 CONST_S("Start Game\rContinue Game\rConfiguration\rHighscores\rQuit\r"),
54 LIGHT_GRAY,
55 CONST_S("Released under the GNU\rGeneral Public License\rMore info: see COPYING\r"),
56 CONST_S("IVAN v" IVAN_VERSION "\r"),
57 true);
58 switch (Select) {
59 case -1: return 0; // esc
60 case 0:
61 if (game::Init()) {
62 igraph::UnLoadMenu();
63 game::Run();
64 game::DeInit();
65 igraph::LoadMenu();
67 break;
68 case 1: {
69 festring LoadName = iosystem::ContinueMenu(WHITE, LIGHT_GRAY, game::GetSaveDir());
70 if (LoadName.GetSize()) {
71 LoadName.Resize(LoadName.GetSize()-4);
72 if (game::Init(LoadName)) {
73 igraph::UnLoadMenu();
74 game::Run();
75 game::DeInit();
76 igraph::LoadMenu();
79 break; }
80 case 2:
81 ivanconfig::Show();
82 break;
83 case 3: {
84 highscore HScore;
85 HScore.Draw();
86 break; }
87 case 4: return 0;
93 #ifdef WIN32
94 # include <windows.h>
95 int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) {
96 static char *argv[2];
98 argv[0] = strdup("ivan.exe");
99 argv[1] = NULL;
100 return Main(1, argv);
102 #endif