*/
#include <assert.h>
+#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
save_game_menu = new Menu();
game_menu = new Menu();
highscore_menu = new Menu();
+ contrib_menu = new Menu();
main_menu->set_pos(screen->w/2, 335);
- main_menu->additem(MN_ACTION,"Start Game",0,0);
- main_menu->additem(MN_GOTO,"Load Game",0,load_game_menu);
- main_menu->additem(MN_GOTO,"Options",0,options_menu);
+ main_menu->additem(MN_GOTO, "Start Game",0,load_game_menu);
+ main_menu->additem(MN_GOTO, "Contrib Levels",0,contrib_menu);
+ main_menu->additem(MN_GOTO, "Options",0,options_menu);
main_menu->additem(MN_ACTION,"Level editor",0,0);
main_menu->additem(MN_ACTION,"Credits",0,0);
main_menu->additem(MN_ACTION,"Quit",0,0);
+ contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0);
+ contrib_menu->additem(MN_HL,"",0,0);
+ contrib_menu->additem(MN_ACTION, "Some Levelset", 0, 0);
+ contrib_menu->additem(MN_ACTION, "Someother Levelset", 0, 0);
+ contrib_menu->additem(MN_ACTION, "Yet another Levelset", 0, 0);
+ contrib_menu->additem(MN_HL,"",0,0);
+ contrib_menu->additem(MN_BACK,"Back",0,0);
+
options_menu->additem(MN_LABEL,"Options",0,0);
options_menu->additem(MN_HL,"",0,0);
options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0);
options_controls_menu->additem(MN_HL,"",0,0);
options_controls_menu->additem(MN_BACK,"Back",0,0);
- load_game_menu->additem(MN_LABEL,"Load Game",0,0);
+ load_game_menu->additem(MN_LABEL,"Start Game",0,0);
load_game_menu->additem(MN_HL,"",0,0);
load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0);
load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0);
{
for(int i = 2; i < 7; ++i)
{
- char *tmp;
- slotinfo(&tmp,i-1);
- if(load && strlen(tmp) == strlen("Slot X - Free") )
- pmenu->item[i].kind = MN_DEACTIVE;
+ // FIXME: Insert a real savegame struct/class here instead of
+ // doing string vodoo
+ std::string tmp = slotinfo(i-1);
+
+ if(load && tmp.length() == strlen("Slot X - Free"))
+ pmenu->item[i].kind = MN_ACTION;
else
pmenu->item[i].kind = MN_ACTION;
- menu_item_change_text(&pmenu->item[i],tmp);
- free(tmp);
+ menu_item_change_text(&pmenu->item[i], tmp.c_str());
}
}
-void process_save_load_game_menu(int save)
+void process_save_game_menu()
+{
+ int slot = save_game_menu->check();
+ if (slot != -1)
+ savegame(slot - 1);
+}
+
+bool process_load_game_menu()
{
- int slot;
- switch (slot = (save ? save_game_menu->check() : load_game_menu->check()))
+ int slot = load_game_menu->check();
+
+ if(slot != -1)
{
- default:
- if(slot != -1)
+ // FIXME: Insert a real savegame struct/class here instead of
+ // doing string vodoo
+ std::string tmp = slotinfo(slot-1);
+ if (tmp.length() == strlen("Slot X - Free"))
+ {
+ gameloop("default", 1, ST_GL_PLAY);
+ show_menu = true;
+ Menu::set_current(main_menu);
+ }
+ else
{
- if(save)
+ if (game_started)
{
- savegame(slot - 1);
+ gameloop("default",slot - 1,ST_GL_LOAD_GAME);
+ show_menu = true;
+ Menu::set_current(main_menu);
}
else
{
- if (game_started)
- {
- gameloop("default",slot - 1,ST_GL_LOAD_GAME);
- show_menu = true;
- Menu::set_current(main_menu);
- }
- else
- loadgame(slot - 1);
+ loadgame(slot - 1);
}
- st_pause_ticks_stop();
}
- break;
+ st_pause_ticks_stop();
+ return true;
+ }
+ else
+ {
+ return false;
}
}
/* Set window manager stuff: */
- SDL_WM_SetCaption("Super Tux", "Super Tux");
+ SDL_WM_SetCaption("SuperTux " VERSION, "SuperTux");
}
else if (strcmp(argv[i], "--version") == 0)
{
/* Show version: */
-
- printf("Super Tux - version " VERSION "\n");
+ printf("SuperTux " VERSION "\n");
exit(0);
}
else if (strcmp(argv[i], "--disable-sound") == 0)
while (SDL_PollEvent(&event))
{
- menu_event(event);
+ menu_event(event);
if (event.type == SDL_QUIT)
{
/* Quit event - quit: */
/* Draw the high score: */
/*
- sprintf(str, "High score: %d", hs_score);
- text_drawf(&gold_text, str, 0, -40, A_HMIDDLE, A_BOTTOM, 1);
- sprintf(str, "by %s", hs_name);
- text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1);
+ sprintf(str, "High score: %d", hs_score);
+ text_drawf(&gold_text, str, 0, -40, A_HMIDDLE, A_BOTTOM, 1);
+ sprintf(str, "by %s", hs_name);
+ text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1);
*/
/* Don't draw menu, if quit is true */
{
switch (main_menu->check())
{
+#if 0
case 0:
+ // Quick Play
+ // FIXME: obsolete
done = 0;
i = 0;
if(level_subsets.num_items != 0)
quit = 1;
break;
case SDL_KEYDOWN: // key pressed
- /* Keypress... */
-
+ // Keypress...
key = event.key.keysym.sym;
if(key == SDLK_LEFT)
titletux.level_begin();
update_time = st_get_ticks();
break;
- case 1:
+#endif
+ case 0:
+ // Start Game, ie. goto the slots menu
update_load_save_game_menu(load_game_menu, true);
break;
+ case 1:
+ // Contrib Menu
+ break;
case 3:
done = 1;
quit = leveleditor(1);
}
else if(current_menu == load_game_menu)
{
- process_save_load_game_menu(false);
+ if (process_load_game_menu())
+ {
+ // reset tux
+ scroll_x = 0;
+ titletux.level_begin();
+ update_time = st_get_ticks();
+ }
+ }
+ else if(current_menu == contrib_menu)
+ {
+
}
mouse_cursor->draw();