Exemple #1
0
//returns flag, true means quit menu
void do_option ( int select) 
{
	switch (select) {
		case MENU_NEW_GAME:
			do_new_game_menu();
			break;
		case MENU_GAME:
			break;
		case MENU_DEMO_PLAY:
			{ 
				char demo_file[16];
				if (newmenu_get_filename( TXT_SELECT_DEMO, "*.dem", demo_file, 1 ))	{
					newdemo_start_playback(demo_file);
				}
			}
			break;
		case MENU_LOAD_GAME:
#ifdef SHAREWARE
			do_load_game_menu();
#else
			state_restore_all(0);	
#endif
			break;
		#ifdef EDITOR
		case MENU_EDITOR:
			Function_mode = FMODE_EDITOR;
			init_cockpit();
			break;
		#endif
		case MENU_VIEW_SCORES:
			gr_palette_fade_out( gr_palette,32,0 );
			scores_view(-1);
			break;
		#ifdef SHAREWARE
		case MENU_ORDER_INFO:
			show_order_form();
			break;
		#endif
		case MENU_QUIT:
			#ifdef EDITOR
			if (! SafetyCheck()) break;
			#endif
			gr_palette_fade_out( gr_palette,32,0);
			Function_mode = FMODE_EXIT;
			break;
		case MENU_NEW_PLAYER:
			RegisterPlayer();		//1 == allow escape out of menu
			break;

		case MENU_HELP:
			do_show_help();
			break;

                #ifndef RELEASE

		case MENU_PLAY_SONG:	{
				int i;
				char * m[MAX_SONGS];

				for (i=0;i<MAX_SONGS;i++) {
					m[i] = Songs[i].filename;
				}
				i = newmenu_listbox( "Select Song", MAX_SONGS, m, 1, NULL );

				if ( i > -1 )	{
					songs_play_song( i, 0 );
				}
			}
			break;
		case MENU_LOAD_LEVEL: {
			newmenu_item m;
			char text[10]="";
			int new_level_num;

			m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text;

			newmenu_do( NULL, "Enter level to load", 1, &m, NULL );

			new_level_num = atoi(m.text);

			if (new_level_num!=0 && new_level_num>=Last_secret_level && new_level_num<=Last_level)	{
				gr_palette_fade_out( gr_palette, 32, 0 );
				StartNewGame(new_level_num);
			}

			break;
		}
                #endif


		case MENU_START_NETGAME:
#ifdef NETWORK
//temp!
#ifndef SHAREWARE
			load_mission(0);
#endif
                        read_player_file();
			network_start_game();
#endif
			break;
		case MENU_JOIN_NETGAME:
//temp!
#ifdef NETWORK
#ifndef SHAREWARE
			load_mission(0);
#endif
                        read_player_file();
			network_join_game();
#endif
			break;
#ifdef NETWORK
		case MENU_IPX_MULTIPLAYER:
			do_ipx_multi_player_menu();
			break;
		case MENU_KALI_MULTIPLAYER:
			do_kali_multi_player_menu();
			break;
#ifdef SUPPORTS_NET_IP
		case MENU_IP_MULTIPLAYER:
			do_ip_multi_player_menu();
			break;
		case MENU_IP_SERV_CONNECT:
			do_ip_serv_connect_menu();
			break;
		case MENU_MANUAL_IP_JOIN:
			do_ip_manual_join_menu();
			break;
#endif
		case MENU_START_SERIAL:
			com_main_menu();
			break;
		case MENU_MULTIPLAYER:
			do_multi_player_menu();
			break;
#endif //NETWORK
		case MENU_CONFIG:
			do_options_menu();
			break;
		case MENU_SHOW_CREDITS:
			gr_palette_fade_out( gr_palette,32,0);
			credits_show();	
			break;
		default:
			Error("Unknown option %d in do_option",select);
			break;
        }

}
Exemple #2
0
/**
 * Handle event in the main screen.
 * @param event
 * The event to handle.
 * @return
 * 1 if the event was handled, 0 otherwise.
 */
int intro_event(SDL_Event *event)
{
    if (!list_servers) {
        return 0;
    }

    if (event->type == SDL_MOUSEBUTTONDOWN && event->button.button == SDL_BUTTON_LEFT) {
        if (LIST_MOUSE_OVER(list_news, event->motion.x, event->motion.y)) {
            list_news->focus = 1;
            list_servers->focus = 0;
        } else if (LIST_MOUSE_OVER(list_servers, event->motion.x, event->motion.y)) {
            list_servers->focus = 1;
            list_news->focus = 0;
        }
    }

    if (button_event(&button_play, event)) {
        list_handle_enter(list_servers, event);
        return 1;
    } else if (button_event(&button_refresh, event)) {
        if (!ms_connecting(-1)) {
            cpl.state = ST_META;
        }

        return 1;
    } else if (button_event(&button_server, event)) {
        server_add_open();
        return 1;
    } else if (button_event(&button_settings, event)) {
        settings_open();
        return 1;
    } else if (button_event(&button_update, event)) {
        updater_open();
        return 1;
    } else if (button_event(&button_help, event)) {
        help_show("main screen");
        return 1;
    } else if (button_event(&button_credits, event)) {
        credits_show();
        return 1;
    } else if (button_event(&button_quit, event)) {
        exit(0);
        return 1;
    } else if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_TAB && list_news) {
        int news_focus = 0;

        if (list_servers->focus) {
            news_focus = 1;
        }

        list_news->focus = news_focus;
        list_servers->focus = !news_focus;
    } else if (list_handle_keyboard(list_news && list_news->focus ? list_news : list_servers, event)) {
        return 1;
    } else if (list_handle_mouse(list_news, event)) {
        return 1;
    } else if (list_handle_mouse(list_servers, event)) {
        return 1;
    }

    return 0;
}