Esempio n. 1
0
void ui_draw_expo()
{
    int scale_exp, scale_elp;

    /*
     * Convert time values into logarithm scale.
     */
    scale_exp = FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(msec2scale(exposure));
    scale_elp = FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(msec2scale(elapsed));
    ui_show_hide_mouse();
    gfx_frame(FRAME_EXPO_LEFT - FRAME_EXPO_BORDER, FRAME_EXPO_TOP - FRAME_EXPO_BORDER, FRAME_EXPO_RIGHT + FRAME_EXPO_BORDER, FRAME_EXPO_BOTTOM + FRAME_EXPO_BORDER, FRAME_EXPO_BORDER, UI_LO_COLOR, UI_LO_COLOR, 0);
    gfx_rect(FRAME_EXPO_LEFT + FRAME_EXPO_WIDTH / 2, FRAME_EXPO_TOP - 1, FRAME_EXPO_RIGHT - 1, FRAME_EXPO_BOTTOM - 1, 0, GFX_FILL_RECT);
    gfx_rect(FRAME_EXPO_LEFT, FRAME_EXPO_TOP, FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH / 2, scale_exp, 0, GFX_FILL_RECT);
    gfx_rect(FRAME_EXPO_LEFT, scale_exp, FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH / 2, scale_elp, UI_LO_COLOR, GFX_FILL_RECT);
    gfx_rect(FRAME_EXPO_LEFT, scale_elp, FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH / 2, FRAME_EXPO_BOTTOM, UI_HI_COLOR, GFX_FILL_RECT);
    gfx_vline(FRAME_EXPO_TOP, FRAME_EXPO_BOTTOM, FRAME_EXPO_RIGHT, UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/2, FRAME_EXPO_RIGHT, FRAME_EXPO_TOP, UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/2, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM, UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/2, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(100), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/2, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(50), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/2, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(200), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/2, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(300), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/4, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(25), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/4, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(75), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/4, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(150), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/4, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(250), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/8, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(125), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/8, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(175), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/8, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(225), UI_HI_COLOR, GFX_COPY_PIXEL);
    gfx_hline(FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH/8, FRAME_EXPO_RIGHT, FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(275), UI_HI_COLOR, GFX_COPY_PIXEL);
    ui_show_hide_mouse();
}
static void
game_select_display_button(gfx_driver_t *gfx_driver, gfx_bitmap_font_t* font, rect_t box, const char* button_text, int focus)
{
	gfx_color_t black;
	gfx_color_t white;

	black = create_color_t(0, 0, 0);
	white = create_color_t(255, 255, 255);

	gfx_box_border(gfx_driver, gfx_rect(box.x, box.y, box.xl, box.yl), black);
	gfx_box_fill(gfx_driver, gfx_rect(box.x + 1, box.y + 1, box.xl - 2, box.yl - 2), white);
	gfx_box_text(gfx_driver, gfx_rect(box.x, box.y + 1, box.xl, box.yl), font, create_pixmap_color_t(black), create_pixmap_color_t(white), button_text, 1);
	if (focus != 0)
		gfx_box_border(gfx_driver, gfx_rect(box.x + 1, box.y + 1, box.xl - 2, box.yl - 2), black);
}
Esempio n. 3
0
void ui_draw_load()
{
    ui_show_hide_mouse();
    gfx_frame(FRAME_LOAD_LEFT - FRAME_LOAD_BORDER, FRAME_LOAD_TOP - FRAME_LOAD_BORDER, FRAME_LOAD_RIGHT + FRAME_LOAD_BORDER, FRAME_LOAD_BOTTOM + FRAME_LOAD_BORDER, FRAME_LOAD_BORDER, UI_LO_COLOR, UI_LO_COLOR, 0);
    gfx_rect(FRAME_LOAD_LEFT, FRAME_LOAD_TOP, FRAME_LOAD_RIGHT, FRAME_LOAD_BOTTOM, 0, GFX_FILL_RECT);
    ui_show_hide_mouse();
}
Esempio n. 4
0
void ui_update_load(int scanline)
{
    ui_show_hide_mouse();
    if (scanline > 0)
        gfx_hline(FRAME_LOAD_LEFT, FRAME_LOAD_RIGHT, scanline + FRAME_LOAD_TOP, UI_HI_COLOR, GFX_COPY_PIXEL);
    else
        gfx_rect(FRAME_LOAD_LEFT, FRAME_LOAD_TOP, FRAME_LOAD_RIGHT, FRAME_LOAD_BOTTOM, 0, GFX_FILL_RECT);
    ui_show_hide_mouse();
}
static void
gfx_box_text(gfx_driver_t *gfx_driver, rect_t box, gfx_bitmap_font_t* font, gfx_pixmap_color_t fgc, gfx_pixmap_color_t bgc, const char* text, int center)
{
	int width;
	int height;
	gfx_pixmap_t* pixmap;
	text_fragment_t *textsplits;
	int meas_width;
	int meas_height;
	int meas_line;
	int margin_x = 0;
	int margin_y = 0;
	int line_height;
	int last_offset;

	if (center != 0)
	{
		textsplits = gfxr_font_calculate_size(font, box.xl, text, &meas_width, &meas_height, &meas_line, &line_height, &last_offset, GFXR_FONT_FLAG_NO_NEWLINES | GFXR_FONT_FLAG_COUNT_WHITESPACE);
		if (textsplits != NULL)
		{
			free(textsplits);
		}

		margin_x = (box.xl - meas_width) / 2;
		margin_y = (box.yl - meas_height) / 2;
	}

	box.x *= gfx_driver->mode->xfact;
	box.y *= gfx_driver->mode->yfact;
	box.xl *= gfx_driver->mode->xfact;
	box.yl *= gfx_driver->mode->yfact;
	margin_x *= gfx_driver->mode->xfact;
	margin_y *= gfx_driver->mode->yfact;

	pixmap = gfxr_draw_font(font, text, strlen(text), &fgc, &fgc, NULL);
	if (pixmap != NULL)
	{
		pixmap->xoffset = 0;
		pixmap->yoffset = 0;

		gfx_xlate_pixmap(gfx_pixmap_alloc_data(pixmap, gfx_driver->mode), gfx_driver->mode, GFX_XLATE_FILTER_NONE);

		width = pixmap->index_xl * gfx_driver->mode->xfact;
		height = pixmap->index_yl * gfx_driver->mode->yfact;

		if (width > box.xl)
			width = box.xl;

		if (gfx_driver->draw_pixmap(gfx_driver, pixmap, GFX_NO_PRIORITY, gfx_rect(0, 0, width, height), gfx_rect(box.x + margin_x, box.y + margin_y, width, height), GFX_BUFFER_BACK) != GFX_OK)
		{
			GFXERROR("Error occured while drawing pixmap.\n");
		}

		gfx_free_pixmap(gfx_driver, pixmap);
	}
}
void
game_select_scan_info(gfx_driver_t *gfx_driver, gfx_bitmap_font_t* font_default, gfx_bitmap_font_t* font_small, char *name, int total)
{
	gfx_color_t black;
	gfx_color_t white;
	gfx_color_t grey;
	gfx_color_t blue;
	rect_t box;
	int error;
	char text[256];

	black = create_color_t(0, 0, 0);
	white = create_color_t(255, 255, 255);
	grey = create_color_t(85, 85, 85);
	blue = create_color_t(0, 0, 170);

	game_select_draw_bg(gfx_driver, font_default);

	/* window */
	game_select_display_window(gfx_driver, font_default, gfx_rect(GS_SCAN_WINDOW_LEFT, GS_SCAN_WINDOW_TOP, GS_SCAN_WINDOW_WIDTH, GS_SCAN_WINDOW_HEIGHT), "Scanning for Games");

	/* window text */
	gfx_box_text(gfx_driver, gfx_rect(GS_SCAN_WINDOW_LEFT + 6, GS_SCAN_WINDOW_TOP + 16, GS_SCAN_WINDOW_WIDTH - 11, 8), font_default, create_pixmap_color_t(black), create_pixmap_color_t(white), "Please wait, scanning for games...", 0);

	if (name) {
		snprintf(text, 256, "Adding: %s", name);
	
		gfx_box_text(gfx_driver, gfx_rect(GS_SCAN_WINDOW_LEFT + 6, GS_SCAN_WINDOW_TOP + 32, GS_SCAN_WINDOW_WIDTH - 11, 8), font_default, create_pixmap_color_t(black), create_pixmap_color_t(white), text, 0);
	}
	
	snprintf(text, 256, "Games found: %i", total);

	gfx_box_text(gfx_driver, gfx_rect(GS_SCAN_WINDOW_LEFT + 6, GS_SCAN_WINDOW_TOP + 48, GS_SCAN_WINDOW_WIDTH - 11, 8), font_default, create_pixmap_color_t(black), create_pixmap_color_t(white), text, 0);

	box = gfx_rect(0, 0, 320 * gfx_driver->mode->xfact, 200 * gfx_driver->mode->yfact);

	if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
	{
		GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
	}
}
static void
game_select_display_game_list(gfx_driver_t *gfx_driver, gfx_bitmap_font_t* font_default, gfx_bitmap_font_t* font_small, game_t *game_list, int game_count, int first_game, int selected_game, int focus_button)
{
	gfx_color_t black;
	gfx_color_t white;

	black = create_color_t(0, 0, 0);
	white = create_color_t(255, 255, 255);

	game_select_draw_bg(gfx_driver, font_default);

	/* window */
	game_select_display_window(gfx_driver, font_default, gfx_rect(GS_WINDOW_LEFT, GS_WINDOW_TOP, GS_WINDOW_WIDTH, GS_WINDOW_HEIGHT), "Play a Game");

	/* window text */
	gfx_box_text(gfx_driver, gfx_rect(GS_WINDOW_LEFT + 6, GS_WINDOW_TOP + 16, GS_WINDOW_WIDTH - 11, 8), font_default, create_pixmap_color_t(black), create_pixmap_color_t(white), "Select the game that you would like", 0);
	gfx_box_text(gfx_driver, gfx_rect(GS_WINDOW_LEFT + 6, GS_WINDOW_TOP + 24, GS_WINDOW_WIDTH - 11, 8), font_default, create_pixmap_color_t(black), create_pixmap_color_t(white), "to play.", 0);

	/* window list box */
	game_select_display_listbox(gfx_driver, font_small, gfx_rect(GS_WINDOW_LEFT + 5, GS_WINDOW_TOP + 39, GS_LISTBOX_WIDTH, GS_LISTBOX_HEIGHT), game_list, game_count, first_game, selected_game);

	/* window play button */
	game_select_display_button(gfx_driver, font_default, gfx_rect(GS_WINDOW_LEFT + GS_WINDOW_WIDTH - 69, GS_WINDOW_TOP + 39, 64, font_default->height + 1), "Play", focus_button == GS_BUTTON_PLAY);

	/* window quit button */
	game_select_display_button(gfx_driver, font_default, gfx_rect(GS_WINDOW_LEFT + GS_WINDOW_WIDTH - 69, GS_WINDOW_TOP + 39 + font_default->height + 5, 64, font_default->height + 1), "Quit", focus_button == GS_BUTTON_QUIT);
}
static void
game_select_display_window(gfx_driver_t *gfx_driver, gfx_bitmap_font_t* font, rect_t box, const char* title)
{
	gfx_color_t black;
	gfx_color_t white;
	gfx_color_t grey;

	black = create_color_t(0, 0, 0);
	white = create_color_t(255, 255, 255);
	grey = create_color_t(85, 85, 85);

	/* window border */
	gfx_box_border(gfx_driver, box, black);

	/* window fill */
	gfx_box_fill(gfx_driver, gfx_rect(box.x + 1, box.y + 1, box.xl - 1, box.yl - 1), white);

	/* window title */
	gfx_box_fill(gfx_driver, gfx_rect(box.x + 1, box.y + 1, box.xl - 1, font->height), grey);
	gfx_box_line(gfx_driver, gfx_rect(box.x, box.y + font->height + 1, box.xl, 0), black);
	gfx_box_text(gfx_driver, gfx_rect(box.x + 1, box.y + 2, box.xl - 1, font->height - 1), font, create_pixmap_color_t(white), create_pixmap_color_t(grey), title, 1);

	/* window shade */
	gfx_box_line(gfx_driver, gfx_rect(box.x + box.xl + 1, box.y + 3, 0, box.yl - 2), black);
	gfx_box_line(gfx_driver, gfx_rect(box.x + 3, box.y + box.yl + 1, box.xl - 2, 0), black);
}
static int
scummvm_set_static_buffer(struct _gfx_driver *drv, gfx_pixmap_t *pic, gfx_pixmap_t *priority)
{
	memcpy(S->visual[2], pic->data, S->xsize * S->ysize);
	/*gfx_crossblit_pixmap(drv->mode, pic, 0, rect, rect,
			S->visual[2], S->xsize,
			S->priority[1]->index_data,
			S->priority[1]->index_xl, 1, 0);*/

	gfx_copy_pixmap_box_i(S->priority[1], priority, gfx_rect(0, 0, S->xsize, S->ysize));

	return GFX_OK;
}
Esempio n. 10
0
void ui_update_expo(int exposure_time, int remaining_time)
{
    int elapsed_time = remaining_time > 0 ? exposure_time - remaining_time : 0;
    if (elapsed_time < 0)
        elapsed_time = 0;
    if (msec2scale(exposure_time) != msec2scale(exposure) || msec2scale(elapsed_time) != msec2scale(elapsed))
    {
        int scale_exp, scale_elp;

        /*
         * Convert time values into logarithm scale.
         */
        exposure = exposure_time;
        elapsed  = elapsed_time;
        scale_exp = FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(msec2scale(exposure));
        scale_elp = FRAME_EXPO_BOTTOM - EXPO_VERT_SCALE(msec2scale(elapsed));
        ui_show_hide_mouse();
        gfx_rect(FRAME_EXPO_LEFT, FRAME_EXPO_TOP, FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH / 2, scale_exp, 0, GFX_FILL_RECT);
        gfx_rect(FRAME_EXPO_LEFT, scale_exp, FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH / 2, scale_elp, UI_LO_COLOR, GFX_FILL_RECT);
        gfx_rect(FRAME_EXPO_LEFT, scale_elp, FRAME_EXPO_RIGHT - FRAME_EXPO_WIDTH / 2, FRAME_EXPO_BOTTOM, UI_HI_COLOR, GFX_FILL_RECT);
        ui_show_hide_mouse();
    }
}
Esempio n. 11
0
static void
game_select_draw_bg(gfx_driver_t *gfx_driver, gfx_bitmap_font_t* font)
{
	char title[255];
	gfx_color_t black;
	gfx_color_t white;
	gfx_color_t blue;

	black = create_color_t(0, 0, 0);
	white = create_color_t(255, 255, 255);
	blue = create_color_t(0, 0, 170);

	strcpy(title, "FreeSCI");
	strcat(title, " ");
	strcat(title, VERSION);

	/* menu bar */
	gfx_box_fill(gfx_driver, gfx_rect(0, 0, 320, font->height), white);
	gfx_box_line(gfx_driver, gfx_rect(0, font->height, 320, 0), black);
	gfx_box_text(gfx_driver, gfx_rect(0, 1, 320, font->height - 1), font, create_pixmap_color_t(black), create_pixmap_color_t(white), title, 1);

	/* background */
	gfx_box_fill(gfx_driver, gfx_rect(0, 10, 320, 190), blue);
}
Esempio n. 12
0
void export_wav(MusSong *song, CydWavetableEntry * entry, FILE *f, int channel)
{
	MusEngine mus;
	CydEngine cyd;
	
	cyd_init(&cyd, 44100, MUS_MAX_CHANNELS);
	cyd.flags |= CYD_SINGLE_THREAD;
	mus_init_engine(&mus, &cyd);
	mus.volume = song->master_volume;
	mus_set_fx(&mus, song);
	CydWavetableEntry * prev_entry = cyd.wavetable_entries; // save entries so they can be free'd
	cyd.wavetable_entries = entry;
	cyd_set_callback(&cyd, mus_advance_tick, &mus, song->song_rate);
	mus_set_song(&mus, song, 0);
	song->flags |= MUS_NO_REPEAT;
	
	if (channel >= 0)
	{
		// if channel is positive then only export that channel (mute other chans)
		
		for (int i = 0 ; i < MUS_MAX_CHANNELS ; ++i)
			mus.channel[i].flags |= MUS_CHN_DISABLED;
		
		mus.channel[channel].flags &= ~MUS_CHN_DISABLED;
	}
	else
	{
		for (int i = 0 ; i < MUS_MAX_CHANNELS ; ++i)
			mus.channel[i].flags &= ~MUS_CHN_DISABLED;
	}
	
	const int channels = 2;
	Sint16 buffer[2000 * channels];
	
	int last_percentage = -1;
	
	WaveWriter *ww = ww_create(f, cyd.sample_rate, 2);
	
	for (;;)
	{
		memset(buffer, 0, sizeof(buffer)); // Zero the input to cyd
		cyd_output_buffer_stereo(&cyd, (Uint8*)buffer, sizeof(buffer));
		
		if (cyd.samples_output > 0)
			ww_write(ww, buffer, cyd.samples_output);
		
		if (mus.song_position >= song->song_length) break;
		
		if (song->song_length != 0)
		{
			int percentage = (mus.song_position + (channel == -1 ? 0 : (channel * song->song_length))) * 100 / (song->song_length * (channel == -1 ? 1 : song->num_channels));
			
			if (percentage > last_percentage)
			{
				last_percentage = percentage;
				
				SDL_Rect area = {domain->screen_w / 2 - 140, domain->screen_h / 2 - 24, 280, 48};
				bevel(domain, &area, mused.slider_bevel, BEV_MENU);
				
				adjust_rect(&area, 8);
				area.h = 16;
				
				bevel(domain, &area, mused.slider_bevel, BEV_FIELD);
				
				adjust_rect(&area, 2);
				
				int t = area.w;
				area.w = area.w * percentage / 100;
				
				gfx_rect(domain, &area, colors[COLOR_PROGRESS_BAR]);
				
				area.y += 16 + 4 + 4;
				area.w = t;
				
				font_write_args(&mused.smallfont, domain, &area, "Exporting... Press ESC to abort.");
				
				SDL_Event e;
				
				while (SDL_PollEvent(&e))
				{
					if (e.type == SDL_QUIT || (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE))
					{
						goto abort;
					}
				}
				
				gfx_domain_flip(domain);
			}
		}
	}
	
abort:;
	
	ww_finish(ww);
	
	cyd.wavetable_entries = prev_entry;
	
	cyd_deinit(&cyd);
	
	song->flags &= ~MUS_NO_REPEAT;
}
Esempio n. 13
0
int
game_select_display(gfx_driver_t *gfx_driver, game_t *game_list, int game_count, gfx_bitmap_font_t* font_default, gfx_bitmap_font_t* font_small)
{
	int error;
	int cont;
	sci_event_t event;
	int focus_button = GS_BUTTON_PLAY;
	int selected_game = 0;
	int first_game = 0;
	int max_game;
	rect_t box;

	box = gfx_rect(0, 0, 320 * gfx_driver->mode->xfact, 200 * gfx_driver->mode->yfact);

	max_game = (int)(((double)GS_LISTBOX_CONTENTS_HEIGHT) / font_small->line_height);

	game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
	if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
	{
		GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
	}

	cont = 2;

	while (cont) 
	{
		event = game_select_gfxop_get_event(gfx_driver, SCI_EVT_KEYBOARD);

		if (event.type == SCI_EVT_KEYBOARD)
		{
			if (event.data == SCI_K_ENTER)
			{
				switch (focus_button)
				{
					case GS_BUTTON_PLAY:
						cont = 0;
						break;
					case GS_BUTTON_QUIT:
						cont = 0;
						selected_game = -1;
						break;
				}
			}
			else if ((event.buckybits & (SCI_K_TAB | SCI_EVM_RSHIFT)) || (event.buckybits & (SCI_K_TAB | SCI_EVM_LSHIFT)))
			{
				focus_button--;

				if (focus_button < GS_BUTTON_FIRST)
					focus_button = GS_BUTTON_LAST;

				game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
				if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
				{
					GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
				}
			}
			else if (event.data == SCI_K_TAB)
			{
				focus_button++;

				if (focus_button > GS_BUTTON_LAST)
					focus_button = GS_BUTTON_FIRST;

				game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
				if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
				{
					GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
				}
			}
			else if (event.data == SCI_K_ESC)
			{
				cont = 0;
				selected_game = -1;
			}
			else if (event.data == SCI_K_UP)
			{
				if (selected_game > 0)
				{
					selected_game--;

					focus_button = GS_BUTTON_PLAY;

					if (selected_game < first_game)
					{
						first_game = selected_game;
					}

					game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
					if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
					{
						GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
					}
				}
			}
			else if (event.data == SCI_K_DOWN)
			{
				if (selected_game < game_count - 1)
				{
					selected_game++;

					focus_button = GS_BUTTON_PLAY;

					if (selected_game - first_game + 1 > max_game)
					{
						first_game = selected_game - max_game + 1;
					}

					game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
					if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
					{
						GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
					}
				}
			}
			else if (event.data == SCI_K_PGUP)
			{
				selected_game -= (max_game - 1);
				if (selected_game < 0)
				{
					selected_game = 0;
				}

				focus_button = GS_BUTTON_PLAY;

				if (selected_game < first_game)
				{
					first_game = selected_game;
				}

				game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
				if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
				{
					GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
				}
			}
			else if (event.data == SCI_K_PGDOWN)
			{
				selected_game += max_game - 1;
				if (selected_game >= game_count)
				{
					selected_game = game_count - 1;
				}

				focus_button = GS_BUTTON_PLAY;

				if (selected_game - first_game + 1 > max_game)
				{
					first_game = selected_game - max_game + 1;
				}

				game_select_display_game_list(gfx_driver, font_default, font_small, game_list, game_count, first_game, selected_game, focus_button);
				if ((error = gfx_driver->update(gfx_driver, box, gfx_point(box.x, box.y), GFX_BUFFER_FRONT)))
				{
					GFXERROR("Error occured while updating region (%d,%d,%d,%d) in buffer %d\n", box.x, box.y, box.xl, box.yl, GFX_BUFFER_BACK);
				}
			}
		}

		game_select_gfxop_usleep(gfx_driver, 25000);
	}

	return selected_game;
}
Esempio n. 14
0
static void
game_select_display_listbox(gfx_driver_t *gfx_driver, gfx_bitmap_font_t* font, rect_t box, game_t *game_list, int game_count, int first_game, int selected_game)
{
	int max_game;
	int pos = 0;
	int cur;
	int center_x;
	gfx_color_t black;
	gfx_color_t white;

	center_x = box.x + (box.xl / 2) - 1;

	black = create_color_t(0, 0, 0);
	white = create_color_t(255, 255, 255);

	/* list box */
	gfx_box_border(gfx_driver, box, black);
	gfx_box_fill(gfx_driver, gfx_rect(box.x + 1, box.y + 1, box.xl - 2, box.yl - 2), white);
	gfx_box_line(gfx_driver, gfx_rect(box.x, box.y + 10, box.xl, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(box.x, box.y + box.yl - 10, box.xl, 0), black);

	/* list box scroll up */
	gfx_box_line(gfx_driver, gfx_rect(center_x, box.y + 2, 1, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(center_x - 1, box.y + 3, 3, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(center_x - 2, box.y + 4, 5, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(center_x - 3, box.y + 5, 7, 0), black);
	gfx_box_fill(gfx_driver, gfx_rect(center_x - 1, box.y + 6, 4, 3), black);

	/* list box scroll up */
	gfx_box_line(gfx_driver, gfx_rect(center_x, box.y + box.yl - 2, 1, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(center_x - 1, box.y + box.yl - 3, 3, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(center_x - 2, box.y + box.yl - 4, 5, 0), black);
	gfx_box_line(gfx_driver, gfx_rect(center_x - 3, box.y + box.yl - 5, 7, 0), black);
	gfx_box_fill(gfx_driver, gfx_rect(center_x - 1, box.y + box.yl - 8, 4, 3), black);

	/* list box content */
	max_game = (int)(((double)(box.yl - 21)) / font->line_height);
	for (cur = first_game; cur < game_count && (cur - first_game < max_game); cur++, pos++)
	{
		if (selected_game == cur)
			gfx_box_fill(gfx_driver, gfx_rect(box.x + 1, box.y + 11 + (pos * font->line_height), box.xl - 1, font->line_height), black);

		gfx_box_text(gfx_driver, gfx_rect(box.x + 1, box.y + 11 + (pos * font->line_height), box.xl - 1, font->line_height), font, create_pixmap_color_t((selected_game == cur) ? white : black), create_pixmap_color_t((selected_game == cur) ? black : white), game_list[cur].name, 0);
	}
}