Beispiel #1
0
/*
 * check if one key is pressed
 */
static void mw_keys_loop ()
{
    if (GT_MP_PTPM && mw_check_players () >= 2 && keyb_gamekeys.state[BCK_pause] && !keyb_gamekeys.old[BCK_pause]) {
        /* min 2 players are ready for the game and
         * the start key has pressed */
        bman.state = GS_ready;
        bman.updatestatusbar = 1; // force an update
    }

    if (GT_MP_PTPM && mw_check_players () < 2 && keyb_gamekeys.state[BCK_pause] && !keyb_gamekeys.old[BCK_pause]) {
        font_gfxdraw (20,20,"There are not enough configured players", 0, COLOR_brown, 0x1000);
        font_gfxdraw (20,40,"(each player needs to press Ctrl to select the role)", 0, COLOR_brown, 0x1000);
    }

    if (keyb_gamekeys.state[BCK_fullscreen]  && !keyb_gamekeys.old[BCK_fullscreen]) {
        /* Switch Fullscreen */
        SDL_WM_ToggleFullScreen(gfx.screen);
        gfx.fullscreen = !gfx.fullscreen;
        bman.updatestatusbar = 1; // force an update
        bman.updatestatusbar = 1;
    }

    if (keyb_gamekeys.state[BCK_esc] && !keyb_gamekeys.old[BCK_esc]) {
        /* ESCAPE key was pressed */
        net_game_send_delplayer (bman.p_nr);
        bman.state = GS_startup;
    }

    if (((IS_LPLAYER2) && keyb_gamekeys.state[BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_drop])
            || ((!IS_LPLAYER2) && keyb_gamekeys.state[BCPK_drop] && !keyb_gamekeys.old[BCPK_drop])) {
        /* player 1 want to select a new gfx */
        playermenu_selgfx (bman.p_nr);
        bman.updatestatusbar = 1;
        keyb_loop (NULL);	// to reload the current keys
    }

    if (IS_LPLAYER2 && keyb_gamekeys.state[BCPK_max + BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_max + BCPK_drop]) {
        /* player 2 want to select a new gfx */
        playermenu_selgfx (bman.p2_nr);
        bman.updatestatusbar = 1;
        keyb_loop (NULL);	// to reload the current keys
    }

    if (keyb_gamekeys.state[BCK_mapmenu] && !keyb_gamekeys.old[BCK_mapmenu] && GT_MP_PTPM) {
        /* mapmenu */
        mapmenu ();
        bman.updatestatusbar = 1;
        keyb_loop (NULL);	// to reload the current keys
    }

    if (keyb_gamekeys.state[BCK_help] && !keyb_gamekeys.old[BCK_help]) {
        /* playermenu */
        help (HP_keyboard0);
        bman.updatestatusbar = 1;
        keyb_loop (NULL);	// to reload the current keys
    }


    if (keyb_gamekeys.state[BCK_playermenu] && !keyb_gamekeys.old[BCK_playermenu]) {
        /* playermenu */
        playermenu ();
        bman.updatestatusbar = 1;
        keyb_loop (NULL);	// to reload the current keys
    }
};
Beispiel #2
0
/* singleplayer menü with some options you can make */
void
single_menu ()
{
    int i,
		p,
		eventstate = 0,
        done = 0,
		second_player = 0;
    _charlist nrplayerlist[MAX_PLAYERS + 1];
    _charlist *selnrplayer = &nrplayerlist[bman.ai_players];
	_menu *menu;
	_menuitem *aiplayer = NULL;
	SDL_Event event;

    /* fill in the nrplayerlist */
    for (p = 0, i = 0; p < MAX_PLAYERS + 1; i++) {
        sprintf (nrplayerlist[i].text, "%d", p);
        if (p < MAX_PLAYERS - 1)
            nrplayerlist[i].next = &nrplayerlist[i + 1];
        else
            nrplayerlist[i].next = NULL;
        p++;
    }
	
	game_resetdata ();
	
	menu = menu_new ("Single Game", 380,240);
	
	menu_create_text (menu, "numpl", 20, 50, 12, 2, COLOR_yellow, "Number of\nAI Players");
	aiplayer = menu_create_list (menu, "AI Players", 40, 90, 50, 100, nrplayerlist, &selnrplayer, 3);
	
	menu_create_button (menu,"Change Playernames" ,160, 50, 210, 4);

	menu_create_bool (menu, "Use Second Player", 160, 90, 210, &second_player, 5);

	menu_create_button (menu, "Game Options", 180, 130, 150, 6);
	menu_create_button (menu, "Map Options", 180, 170, 150, 7);
	menu_create_button (menu, "Main Menu", 30, 220, 150, 1);
	menu_create_button (menu, "Start", 220, 220, 150, 2);
	
	menu_focus_id (menu, 2);
	menu->looprunning = 1;
	menu_draw (menu);
	
	do {
		gfx_blitdraw ();
		eventstate = s_fetchevent (&event);

		done = menu_event_loop (menu, &event, eventstate);

		if (done > 0 && menu->focus->id == 6) {
			done = 0;
			mapgamesetting ();
		}
		
		if (done > 0 && menu->focus->id == 7) {
			done = 0;
			mapmenu ();
		}
		
		if (done > 0 && menu->focus->id == 4) {
			done = 0;
			playernamemenu ();
		}
		
		if (done > 0 && menu->focus->id == 3)
			done = 0;
		
		s_calctimesync ();
	} while (!done); 
	
	bman.ai_players = selnrplayer - &nrplayerlist[0];
	
	if (menu->focus->id == 2)
		single_playergame (second_player, bman.ai_players);

	menu_delete (menu);
};