Exemplo n.º 1
0
Arquivo: Menu.c Projeto: tobynet/clcl
/*
 * menu_create_datainfo - メニュー情報にデータを展開
 */
static BOOL menu_create_datainfo(DATA_INFO *set_di,
								MENU_ITEM_INFO *mii, int menu_index, int *id,
								const int step, const int min, const int max)
{
	DATA_INFO *di;
	DATA_INFO *cdi;
	MENU_ITEM_INFO *cmi;
	TCHAR buf[BUF_SIZE * 2];
	TCHAR tmp[BUF_SIZE];
	TCHAR *p;
	int cnt;
	int i, j;
	int m, n;

	// 初期位置移動
	for (m = 0; set_di != NULL && min > 0 && m < min - 1; set_di = set_di->next, m++)
		;
	if (step < 0) {
		// 降順
		for (di = set_di, i = 0, n = m; di != NULL && (max <= 0 || n < max); di = di->next, i++, n++)
			;
		i += menu_index - 1;
	} else {
		// 昇順
		i = menu_index;
	}

	for (di = set_di,j = 0; di != NULL && (max <= 0 || m < max); di = di->next, i += step, m++) {
		(mii + i)->id = ID_MENUITEM_DATA + ((*id)++);
		(mii + i)->item = (LPCTSTR)(mii + i);
		(mii + i)->set_di = di;

		switch (di->type) {
		case TYPE_FOLDER:
			// 階層表示
			(mii + i)->flag = MF_POPUP | MF_OWNERDRAW;
			(mii + i)->show_di = di;

			for (cdi = di->child, cnt = 0; cdi != NULL; cdi = cdi->next, cnt++)
				;
			// メニュー項目情報の確保
			if ((cmi = mem_calloc(sizeof(MENU_ITEM_INFO) * cnt)) == NULL) {
				return FALSE;
			}
			(mii + i)->mii = cmi;
			(mii + i)->mii_cnt = cnt;
			menu_create_datainfo(di->child, cmi, 0, id, step, 0, 0);
			break;

		case TYPE_ITEM:
			// アイテム
			(mii + i)->flag = MF_OWNERDRAW;
			(mii + i)->show_di = format_get_priority_highest(di);
			break;

		case TYPE_DATA:
			// データ
			(mii + i)->flag = MF_OWNERDRAW;
			(mii + i)->show_di = di;
			break;
		}

		// メニューに表示するタイトルを取得
		format_get_menu_title((mii + i)->show_di);
		// タイトルを設定
		if (di->title != NULL) {
			if (lstrcmp(di->title, TEXT("-")) == 0) {
				// 区切り
				(mii + i)->id = 0;
				(mii + i)->flag = MF_SEPARATOR | MF_OWNERDRAW;
				(mii + i)->item = (LPCTSTR)(mii + i);
				continue;
			} else if (option.menu_intact_item_title == 0) {
				menu_create_text(j++, di->title, buf);
				(mii + i)->text = alloc_copy(buf);
			} else {
				(mii + i)->text = alloc_copy(di->title);
			}

		} else if ((mii + i)->show_di->menu_title != NULL) {
			menu_create_text(j++, (mii + i)->show_di->menu_title, buf);
			(mii + i)->text = alloc_copy(buf);

		} else if ((mii + i)->show_di->format_name != NULL) {
			// 形式名
			p = tmp;
			*(p++) = TEXT('(');
			lstrcpyn(p, (mii + i)->show_di->format_name, BUF_SIZE - 3);
			p += lstrlen(p);
			*(p++) = TEXT(')');
			*(p++) = TEXT('\0');
			menu_create_text(j++, tmp, buf);
			(mii + i)->text = alloc_copy(buf);
			(mii + i)->show_format = TRUE;

		} else {
			(mii + i)->text = alloc_copy(TEXT(""));
		}

		if (option.menu_show_hotkey == 1) {
			// ホットキー取得
			(mii + i)->hkey = menu_get_keyname(di->op_modifiers, di->op_virtkey);
		}

		if (option.menu_show_icon == 1) {
			// メニューに表示するアイコンを取得
			format_get_menu_icon((mii + i)->show_di);
			if ((mii + i)->show_di->menu_icon == NULL) {
				(mii + i)->icon = (di->type == TYPE_FOLDER) ? icon_menu_folder : icon_menu_default;
			} else {
				(mii + i)->icon = (mii + i)->show_di->menu_icon;
			}
			(mii + i)->free_icon = FALSE;

			// メニューに表示するビットマップを取得
			if (option.menu_show_bitmap == 1) {
				format_get_menu_bitmap((mii + i)->show_di);
			}
			(mii + i)->show_bitmap = (option.menu_show_bitmap == 1 &&
				(mii + i)->show_di->menu_bitmap != NULL) ? TRUE : FALSE;
		}
	}
	return TRUE;
}
Exemplo n.º 2
0
/*
 * show the manual pages
 */
void help (int showpage)
{
    int page = showpage, menuselect = 2, y = 0;
    char title[255];
    _menu *menu;

    menu_displaytext ("Please Wait", "Loading GFX Data");

    if (page < 0 || page >= HP_max)
        page = 0;

    while (menuselect != -1 && menuselect != 1 && bman.state != GS_quit) {
        if (page == HP_howto0) {
            sprintf (title, "How To Play (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);
            menu_create_text (menu, "help", 5, 55, 53, 20, COLOR_brown,
                              "The goal of the game is to be the last one, "
                              "who is alive. You can drop bombs which will explode after "
                              "a certain time and destroy everything in horizontal and vertical "
                              "direction. So you can remove stones or kill other players. But take care. "
                              "Don't kill yourself otherwise the game will be over for you. During the "
                              "game you will find diffrenent powerups to raise your skills. If you are "
                              "running faster than your opponent and you have many bombs, you can catch "
                              "him within lots of bombs and he has no chance to escape.");

            menu_create_image (menu, "img", 450, 255, 0, gfx.players[0].menu_image, NULL);

            menu_create_text (menu, "help", 5, 255, 45, 10, COLOR_brown,
                              "You will get points for every player you have killed. "
                              "If you win the game, you can earn additional points "
                              "depending on how many players played the game. ");
        } else if (page == HP_powerup0) {
            sprintf (title, "Powerups (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);

            y = 50;

            menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown,
                              "In the game you will find some diffend kind of powerups. "
                              "There are the powerups who give you more power for the whole game "
                              "and the special powerups which will hold only for a certain time.");
            y += 75;

            menu_create_label (menu, "Permanent Powerups", -1, y, 2, COLOR_yellow);
            y += (5 + font[2].size.y);

            menu_create_image (menu, "bomb", 5, y, 0, gfx.menu_field[FT_bomb], NULL);
            menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown,
                              "Give you another bomb to drop. Maximum number of bombs is %d.", MAX_BOMBS);
            y += 40;

            menu_create_image (menu, "fire", 5, y, 1, gfx.menu_field[FT_fire], NULL);
            menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown,
                              "The range of your bombs will be increased. Maximum range is %d.", MAX_RANGE);
            y += 40;

            menu_create_image (menu, "shoe", 5, y, 1, gfx.menu_field[FT_shoe], NULL);
            menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown,
                              "This will make your player run faster. The maximum speed will be %1.2f.", MAX_SPEED);
            y += 40;

            menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown,
                              "Depends how the game is set up, you'll lose "
                              "these powerups if you die. Other players can collect them. "
                              "In the deathmatch mode you can keep the powerups you collected, "
                              "but this depends on the Game if you drop them or not.");
            y += 40;
        } else if (page == HP_powerup1) {
            sprintf (title, "Powerups (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);

            y = 45;

            menu_create_label (menu, "Special Powerups", -1, y, 2, COLOR_yellow);
            y += (5 + font[2].size.y);

            menu_create_image (menu, "kick", 5, y, 1, gfx.menu_field[FT_sp_kick], NULL);
            menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown,
                              "Allowes you to kick some bombs around the level. This will hold "
                              "just a short time of %d seconds. The maximum distance you can "
                              "kick the bombs is %d fields.", SPECIAL_KICK_TIME, SPECIAL_KICK_MAXDIST);
            y += 70;

            menu_create_image (menu, "push", 5, y, 1, gfx.menu_field[FT_sp_push], NULL);
            menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown,
                              "Push bombs one field, as long as nothing is behind this bomb.");
            y += 40;

            menu_create_image (menu, "droprow", 5, y, 1, gfx.menu_field[FT_sp_row], NULL);
            menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown,
                              "You can drop a row of that many bombs you have still left to drop.");
            y += 40;

            menu_create_image (menu, "dropliquid", 5, y, 1, gfx.menu_field[FT_sp_liquid], NULL);
            menu_create_text (menu, "help", 55, y, 48, 10, COLOR_brown,
                              "The bomb you push now won't stop moving untill they explode.");
            y += 40;

            menu_create_image (menu, "dropliquid", 5, y, 1, gfx.menu_field[FT_sp_moved], NULL);
            menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown,
                              "The bomb you push will stop moving on the next border or bomb.");
            y += 40;

            menu_create_image (menu, "dropltrigger", 5, y, 1, gfx.menu_field[FT_sp_trigger], NULL);
            menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown,
                              "You will be able to drop triggered bombs. Use "
                              "the special key to let all your bombs explode. "
                              "at the time where you want it.");
            y += 40;
        } else if (page == HP_powerup2) {
            sprintf (title, "Powerups (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);

            y = 45;

            menu_create_label (menu, "Death Item", -1, y, 2, COLOR_yellow);
            y += (5 + font[2].size.y);

            menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown,
                              "In the game you will find another type of item to collect. "
                              "This item is not a powerup at all. If you collect it you will "
                              "get a random illness. This illness will hold for %dseconds. "
                              "If you have contact to another player the other player will "
                              "get all the illnesses you have too.", ILL_TIMEOUT);
            y += 110;

            menu_create_image (menu, "pwdeath", 12, y+8, 1, gfx.menu_field[FT_death], NULL);
            menu_create_text (menu, "help", 55, y, 45, 10, COLOR_brown,
                              "This will make your player ill. We have at the moment %d diffrent "
                              "types of illnesses for you to collect. To make the game more", PI_max);
            y += 3*font[0].size.y;
            menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown,
                              "interesting we won't put here a list of all types there are.");
        } else if (page == HP_keyboard0) {
            sprintf (title, "Keyboard (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);

            y = 50;

            menu_create_label (menu, "During a Game", -1, y, 2, COLOR_yellow);
            y += font[2].size.y;

            menu_create_image (menu, "img", 450, 100, 0, gfx.players[7].menu_image, NULL);

            menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown,
                              "Arrow Keys - Moving of the Player\n"
                              "STRG/CTRL  - Dropping bombs\n"
                              "Shift      - Special Use Key\n"
                              "F4         - Start the Game (only Server)\n"
                              "F8         - Fullscreen (not in Windows)\n"
                              "Return     - Send Entered Text Message\n"
                              "ESC        - Exit Game\n");
            y += 7*font[0].size.y;

            menu_create_label (menu, "Player Selection", -1, y, 2, COLOR_yellow);
            y += font[2].size.y;

            menu_create_text (menu, "help", 5, y, 53, 10, COLOR_brown,
                              "Left/Right - Select and Deselect a Player\n"
                              "F1	        - Mini Help Screen\n"
                              "F2         - Player Screen\n"
                              "F3         - Map and Game Settings\n"
                              "F4         - Start the Game if at last 2 Players\n"
                              "             are selected. (only Server)\n"
                              "ESC        - Exit Game\n");
        } else if (page == HP_credit0) {
            sprintf (title, "About BomberClone (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);

            menu_create_image (menu, "img", 15, 60, 0, gfx.players[4].menu_image, NULL);
            menu_create_text (menu, "help", 75, 50, 45, 10, COLOR_brown,
                              "If you have any problems or questions with the game you can send your questions "
                              "to the mailinglist or directly to me. Bugfixes should be send to the SourceForge "
                              "Projects page about BomberClone.");

            menu_create_label (menu, "WWW",-1, 140, 2, COLOR_yellow);
            menu_create_text (menu, "help", -1, 165, 53, 10, COLOR_brown, "http://www.bomberclone.de");

            menu_create_label (menu, "EMail",-1, 185, 2, COLOR_yellow);
            menu_create_text (menu, "help", -1, 210, 53, 10, COLOR_brown, "*****@*****.**");

            menu_create_label (menu, "Project Page",-1, 230, 2, COLOR_yellow);
            menu_create_text (menu, "help", -1, 255, 53, 10, COLOR_brown, "http://sourceforge.net/projects/bomberclone");
        } else if (page == HP_credit1) {
            sprintf (title, "People (%d/%d)", page + 1, HP_max);
            menu = menu_new (title, 500, 400);

            menu_create_image (menu, "img", 250, 100, 0, gfx.players[6].menu_image, NULL);

            y = 50;
            menu_create_label (menu, "Coding:", 5, y, 2, COLOR_yellow);
            y += font[2].size.y;
            menu_create_text (menu, "help", 50, y, 53, 10, COLOR_brown,
                              "  Steffen Pohle\n"
                              "Patrick Wilczek\n");

            y = 100;
            menu_create_label (menu, "GFX:", 425, y, 2, COLOR_yellow);
            y += font[2].size.y;
            menu_create_text (menu, "help", 325, y, 53, 10, COLOR_brown,
                              "TekkRat\n"
                              "Martijn de Boer\n"
                              "Steffen Pohle\n"
                              "Patrick Wilczek\n");

            y = 140;
            menu_create_label (menu, "Sound/Music:", 5, y, 2, COLOR_yellow);
            y += font[2].size.y;
            menu_create_text (menu, "help", 50, y, 53, 10, COLOR_brown,
                              "Henrik_Enqvist\n"
                              "Cerror\n"
                              "Martijn de Boer\n");

            y = 240;
            menu_create_label (menu, "Thanks To:", -1, y, 2, COLOR_yellow);
            y += font[2].size.y;
            menu_create_text (menu, "help", -1, y, 53, 10, COLOR_brown,
                              "kitutou(coding/fixing), thaphool(tilesets), ob1kenewb(coding/fixing), "
                              "TeKkraT(website,gfx), caccola(tilesets), Digital_D(music), "
                              "dcdillon(coding), Psycho(music),\nNiklas Sj\xf6sv\xe4rd(music)");

        } else break;

        if (page > 0) menu_create_button (menu, "Previous Page", 20, 370, 150, 0);
        else if (menuselect == 0)
            menuselect = 2;
        menu_create_button (menu, "Main Menu", -1, 370, 150, 1);
        if (page < HP_max-1) menu_create_button (menu, "Next Page", 350, 370, 150, 2);

        menu_focus_id (menu, menuselect);
        menuselect = menu_loop (menu);
        if (menuselect == 0 && page > 0)
            page--;
        if (menuselect == 2 && page < HP_max - 1)
            page++;
        menu_delete (menu);
    }
};
Exemplo n.º 3
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);
};