Added a ton of stuff, including the beginnings of a new UI system
[ne.git] / src / main.cpp
blob15c2beffc199b47a2ec62a7817e4acec10c58a2b
1 /************************************************************************
2 This file is part of NE.
4 NE is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 NE is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with NE. If not, see <http://www.gnu.org/licenses/>.
16 ************************************************************************/
18 #include "backend/input.h"
19 #include "backend/video.h"
20 #include "backend/shapes.h"
21 #include "mods/list.h"
22 #include "ui/menu.h"
23 #include "ui/label.h"
25 #include <time.h>
26 #include <iostream>
27 #include <sstream>
28 #include <string>
29 #include <stdlib.h>
31 int exit_func(void*) {
32 return 1;
35 int main(int argc, char **argv)
37 v_init();
38 i_init();
40 int width = 1024;
41 int height = 768;
42 int full = 0;
44 // parse args
46 const char *usage = "USAGE:\n\t%s [-w WIDTH] [-h HEIGHT] [-f]\n";
48 std::stringstream ss;
49 for (int i=1; i<argc; i++)
50 ss << argv[i] << " ";
52 std::string arg_s;
53 while (ss >> arg_s) {
54 if (arg_s == "-w")
55 ss >> width;
56 else if (arg_s == "-h")
57 ss >> height;
58 else if (arg_s == "-f")
59 full = 1;
60 else {
61 printf(usage, argv[0]);
62 return 1;
67 srand(time(0));
69 v_setup(width, height, full);
71 shapes_init();
73 Menu main_menu("Main Menu");
75 int mod_started = 0;
76 int mod_count = 0;
78 for (struct mod* curr_mod = mod_list; curr_mod->runfunc != 0; curr_mod++) {
79 Label *l = new Label(curr_mod->name);
80 l->setCallback(curr_mod->runfunc);
81 l->setSize(Vec3f(15,2.5,1));
82 float c = 1.0 - 0.25 * (mod_count%2);
83 l->setColor(c,c,1);
84 main_menu.addChild(l);
85 mod_count++;
88 Label *l = new Label("Quit");
89 l->setCallback(exit_func);
90 l->setSize(Vec3f(15.0, 2.5, 1.0));
91 l->setColor(1.0, 0.0, 0.0);
92 main_menu.addChild(l);
94 std::cout << "Counted " << mod_count << " mods" << std::endl;
96 while (main_menu.run() == 0) {
97 main_menu.setMode(Menu::OVERLAY);
99 std::cout << "Exiting normally" << std::endl;
101 return 0;