示例#1
0
// Draws the game menu together with the selection box
void RedrawMenu(MENU *m)
{
	// Redraw menu
	SDL_BlitSurface(title, NULL, gamescreen, NULL);

	MPrint(m->header, m->y, m->col, 252);

	if(!m->menu) return;

	for(int i = 0; i < m->num; i++)
		MPrint((m->menu + i)->text, (m->menu + i)->y, (m->menu + i)->col, 252);

	int x1, y1, x2, y2;

	// Put selection box
	x1 = (320 - (strlen((m->menu + m->sel)->text) * 8)) / 2 - 8;
	y1 = m->menu->y + m->sel * 10 - 1;
	x2 = x1 + (strlen((m->menu + m->sel)->text) * 8) + 15;
	y2 = y1 + 8;

	PutBox(x1, y1, x2, y2, 83);
}
示例#2
0
void ac_EnterPassword()
{
	SDL_Event event;
	MENU *m = &PasswordMenu;
	char pass[16];

	m->num = 51;
	m->sel = 0;
	memset(pass, 0, sizeof(pass));

	done = 0;
	while(!done) {
		while(SDL_PollEvent(&event))
			if(event.type == SDL_KEYDOWN) {
				if(event.key.keysym.sym == SDLK_LEFT) {
					if(m->sel > 0) {
						m->sel--;
						PlaySound(0);
					} else {
						m->sel = m->num - 1;
					}
				} else if(event.key.keysym.sym == SDLK_RIGHT) {
					if(m->sel < m->num - 1) {
						m->sel++;
						PlaySound(0);
					} else {
						m->sel = 0;
					}
				} else if(event.key.keysym.sym == SDLK_LCTRL) {
					if(strlen(pass) < 5) {
						strncat(pass, PassChars + m->sel, 1);
					}
				} else if(event.key.keysym.sym == SDLK_LALT) {
					if(strlen(pass) != 0) {
						pass[strlen(pass) - 1] = 0;
					}
				} else if(event.key.keysym.sym == SDLK_RETURN) {
					int i;

					if((i = check_pass(pass)) != -1 &&
					   (pass[4] == '1' || pass[4] == '2')) {
						PlayGame(NORMAL, i, 0, pass[4] & 3);
						CheckForRecord();
					} else {
						PlaySound(1);
						MPrint("INVALID PASSWORD!!", 190, 255, 252);
						BlitAndWait(50);
					}
					done = 1;
				} else if(event.key.keysym.sym == SDLK_ESCAPE) {
					done = 1;
				}
			}

		SDL_BlitSurface(title, NULL, gamescreen, NULL);
		MPrint(m->header, m->y, m->col, 252);

		DrawLetters(m->sel);
		MPrint(pass, 150, 255, 252);
		PutBox(158, 123, 168, 135, 83);
		PutBox(134, 148, 184, 160, 83);

		MPrint("PRESS LEFT/RIGHT TO SELECT", 170, 255, 252);
		MPrint("<START> TO CONFIRM", 180, 255, 252);

		BlitAndWait(1);
	}

	done = 0;
}
示例#3
0
void OSDRegion::RestoreBox(DWORD x, DWORD y, DWORD w, DWORD h, void *data )
{
	PutBox(x, y, w, h, data, false, OSD_1555);
}