Exemple #1
0
void player_dead_message(void)
{
	if (!(Game_mode & GM_CAPTURE))
	{
		if (Player_exploded) {
			if ( Players[Player_num].lives < 2 )    {
				int x, y, w, h, aw;
				gr_set_curfont( HUGE_FONT );
				gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw );
				w += 20;
				h += 8;
				x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2;
				y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2;
			
				gr_settransblend(14, GR_BLEND_NORMAL);
				gr_setcolor( BM_XRGB(0,0,0) );
				gr_rect( x, y, x+w, y+h );
				gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
			
				gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER );
			}
		
			gr_set_curfont( GAME_FONT );
			if (HUD_color == -1)
				HUD_color = BM_XRGB(0,28,0);
			gr_set_fontcolor( HUD_color, -1);
			gr_printf(0x8000, GHEIGHT-LINE_SPACING, TXT_PRESS_ANY_KEY);
		}
	}
	extern int player_spawn_timer;
	if (Game_mode & GM_CAPTURE)
	{
		if (Player_exploded) {
			if ( Players[Player_num].lives < 2 )    {
				int x, y, w, h, aw;
				gr_set_curfont( HUGE_FONT );
				gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw );
				w += 20;
				h += 8;
				x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2;
				y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2;
			
				gr_settransblend(14, GR_BLEND_NORMAL);
				gr_setcolor( BM_XRGB(0,0,0) );
				gr_rect( x, y, x+w, y+h );
				gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
			
				gr_printf(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER );
			}
		
			gr_set_curfont( GAME_FONT );
			if (HUD_color == -1)
				HUD_color = BM_XRGB(0,28,0);
			gr_set_fontcolor( HUD_color, -1);
			if (((player_spawn_timer + Netgame.RespawnTime*5) > f2i(Players[Player_num].time_level)) && force_respawn == 0) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "You must wait %d seconds to respawn.", (player_spawn_timer + (Netgame.RespawnTime*5)) - f2i(Players[Player_num].time_level));
			if (((player_spawn_timer + Netgame.RespawnTime*5) > f2i(Players[Player_num].time_level)) && force_respawn == 1) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "You will respawn in %d seconds.", (player_spawn_timer + (Netgame.RespawnTime*5)) - f2i(Players[Player_num].time_level));
			if ((player_spawn_timer + Netgame.RespawnTime*5) <= f2i(Players[Player_num].time_level)) gr_printf(0x8000, GHEIGHT-LINE_SPACING, "Press any key or button to respawn.");
		}
	}
}
Exemple #2
0
void ui_draw_scrollbar( UI_GADGET_SCROLLBAR * scrollbar )
{
	int x, y;

	if (scrollbar->status==0)
		return;

	scrollbar->status = 0;
	x = y = 0;
	ui_mouse_hide();
	gr_set_current_canvas( scrollbar->canvas );

	if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)scrollbar)
		gr_setcolor( CRED );
	else
		gr_setcolor( CGREY );

	gr_rect( 0, 0, scrollbar->width-1, scrollbar->fake_position-1 );
	gr_rect( 0, scrollbar->fake_position+scrollbar->fake_size, scrollbar->width-1, scrollbar->height-1);

	ui_draw_box_out(0, scrollbar->fake_position, scrollbar->width-1, scrollbar->fake_position+scrollbar->fake_size-1 );

	ui_mouse_show();

}
Exemple #3
0
static void con_draw(void)
{
	int i = 0, y = 0, done = 0;

	if (con_size <= 0)
		return;

	gr_set_current_canvas(NULL);
	gr_set_curfont(GAME_FONT);
	gr_setcolor(BM_XRGB(0,0,0));
	gr_settransblend(7, GR_BLEND_NORMAL);
	gr_rect(0,0,SWIDTH,(LINE_SPACING*(con_size))+FSPACY(1));
	gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
	y=FSPACY(1)+(LINE_SPACING*con_size);
	i+=con_scroll_offset;
	{
		cxx_con_interactive_print(&y);
		if (y<=0)
			done=1;
	}
	while (!done)
	{
		int w,h,aw;

		switch (con_buffer[CON_LINES_MAX-1-i].priority)
		{
			case CON_CRITICAL:
				gr_set_fontcolor(BM_XRGB(28,0,0),-1);
				break;
			case CON_URGENT:
				gr_set_fontcolor(BM_XRGB(54,54,0),-1);
				break;
			case CON_DEBUG:
			case CON_VERBOSE:
				gr_set_fontcolor(BM_XRGB(14,14,14),-1);
				break;
			case CON_HUD:
				gr_set_fontcolor(BM_XRGB(0,28,0),-1);
				break;
			default:
				gr_set_fontcolor(BM_XRGB(255,255,255),-1);
				break;
		}
		gr_get_string_size(con_buffer[CON_LINES_MAX-1-i].line,&w,&h,&aw);
		y-=h+FSPACY(1);
		gr_string(FSPACX(1),y,con_buffer[CON_LINES_MAX-1-i].line);
		i++;

		if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0)
			done=1;
	}
	gr_setcolor(BM_XRGB(0,0,0));
	gr_rect(0,0,SWIDTH,LINE_SPACING);
	gr_set_fontcolor(BM_XRGB(255,255,255),-1);
	gr_printf(FSPACX(1),FSPACY(1),"%s LOG", DESCENT_VERSION);
	gr_string(SWIDTH-FSPACX(110),FSPACY(1),"PAGE-UP/DOWN TO SCROLL");
}
void UI_WINDOW::render_tooltip(char *str)
{
	int str_w, str_h;

	gr_get_string_size(&str_w, &str_h, str);
	Assert(str_w < gr_screen.max_w_unscaled - 4 && str_h < gr_screen.max_h_unscaled - 4);

	if (ttx < 2)
		ttx = 2;

	if (tty < 2)
		tty = 2;

	if (ttx + str_w + 2 > gr_screen.max_w_unscaled)
		ttx = gr_screen.max_w_unscaled - str_w;

	if (tty + str_h + 2 > gr_screen.max_h_unscaled)
		tty = gr_screen.max_h_unscaled - str_h;

	gr_set_color_fast(&Color_black);
	gr_rect(ttx - 1, tty - 1, str_w + 2, str_h + 1, GR_RESIZE_MENU);

	gr_set_color_fast(&Color_bright_white);
	gr_string(ttx, tty, str, GR_RESIZE_MENU);
}
Exemple #5
0
void player_dead_message(void)
{
	if (Player_exploded) {
		if ( Players[Player_num].lives < 2 )    {
			int x, y, w, h, aw;
			gr_set_curfont( HUGE_FONT );
			gr_get_string_size( TXT_GAME_OVER, &w, &h, &aw );
			w += 20;
			h += 8;
			x = (grd_curcanv->cv_bitmap.bm_w - w ) / 2;
			y = (grd_curcanv->cv_bitmap.bm_h - h ) / 2;
		
			gr_settransblend(14, GR_BLEND_NORMAL);
			gr_setcolor( BM_XRGB(0,0,0) );
			gr_rect( x, y, x+w, y+h );
			gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
		
			gr_string(0x8000, (GHEIGHT - h)/2 + h/8, TXT_GAME_OVER );
		}
	
		gr_set_curfont( GAME_FONT );
		if (HUD_color == -1)
			HUD_color = BM_XRGB(0,28,0);
		gr_set_fontcolor( HUD_color, -1);
		gr_string(0x8000, GHEIGHT-LINE_SPACING, TXT_PRESS_ANY_KEY);
	}
}
Exemple #6
0
void ui_close_window( UI_WINDOW * wnd )
{

	ui_mouse_hide();

	ui_gadget_delete_all( wnd );

	if (W_BACKGROUND)
	{
		gr_bm_ubitblt(W_WIDTH, W_HEIGHT, W_X, W_Y, 0, 0, W_BACKGROUND, &(grd_curscreen->sc_canvas.cv_bitmap));
		gr_free_bitmap( W_BACKGROUND );
	} else
	{
		gr_set_current_canvas( NULL );
		gr_setcolor( CBLACK );
		gr_rect( W_X, W_Y, W_X+W_WIDTH-1, W_Y+W_HEIGHT-1 );
	}

	gr_free_sub_canvas( W_CANVAS );

	gr_set_current_canvas( W_OLDCANVAS );

	selected_gadget = NULL;

	remove_window( wnd );

	if (CurWindow==wnd)
		CurWindow = NULL;

	d_free( wnd );

	ui_mouse_show();
}
void debug_draw()
{
	int i;

	gr_clear();
	gr_set_font(FONT1);
	gr_set_color_fast( &Color_bright );
	gr_string( 0x8000, 3, "Debug Console" );

	gr_set_color_fast( &Color_normal );

	for (i=0; i<DROWS; i++ ) {
		gr_string( 0, i*16+16, debug_text[i] );
	}

	int t = timer_get_fixed_seconds() / (F1_0/3);
	if ( t & 1 ) {
		int w,h;
		char c;

		c = debug_text[debug_y][command_line_pos+1];
		debug_text[debug_y][command_line_pos+1] = 0;

		gr_get_string_size( &w, &h, debug_text[debug_y] );

		//gr_string( w, debug_y*16, "_" );
		gr_rect(w+1,debug_y*16+1+16,2,14);

		debug_text[debug_y][command_line_pos+1] = c;
	}

	gr_flip();
}
Exemple #8
0
UI_GADGET_INPUTBOX * ui_add_gadget_inputbox( UI_WINDOW * wnd, short x, short y, short length, short slength, char * text )
{
	int h, w, aw, f;
	UI_GADGET_INPUTBOX * inputbox;

	gr_get_string_size( NULL, &w, &h, &aw );

	inputbox = (UI_GADGET_INPUTBOX *)ui_gadget_add( wnd, 6, x, y, x+aw*slength-1, y+h-1+4 );

	f = 0;

	inputbox->text = malloc( length + 1);
	strncpy( inputbox->text, text, length );
	inputbox->position = strlen(inputbox->text);
	inputbox->oldposition = inputbox->position;
	inputbox->width = aw*slength;
	inputbox->height = h+4;
	inputbox->length = length;
	inputbox->slength = slength;
	inputbox->pressed = 0;
	inputbox->first_time = 1;

	gr_set_current_canvas( inputbox->canvas );
	gr_setcolor( CBLACK );
	gr_rect( 0, 0, inputbox->width-1, inputbox->height-1 );

	return inputbox;

}
Exemple #9
0
void ui_draw_box_in(int x1, int y1, int x2, int y2)
{

	gr_set_color_fast(&CWHITE);
	gr_rect(x1 + 2, y1 + 2, (x2 - 2) - (x1 + 2) + 1, (y2 - 2) - (y1 + 2) + 1);

	ui_draw_shad(x1 + 0, y1 + 0, x2 - 0, y2 - 0, &CGRAY, &CBRIGHT);
	ui_draw_shad(x1 + 1, y1 + 1, x2 - 1, y2 - 1, &CGRAY, &CBRIGHT);
}
Exemple #10
0
static void con_draw(void)
{
	int i = 0, y = 0;

	if (con_size <= 0)
		return;

	gr_set_default_canvas();
	auto &canvas = *grd_curcanv;
	auto &game_font = *GAME_FONT;
	gr_set_curfont(canvas, GAME_FONT);
	const uint8_t color = BM_XRGB(0, 0, 0);
	gr_settransblend(canvas, 7, GR_BLEND_NORMAL);
	const auto &&fspacy1 = FSPACY(1);
	const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT);
	y = fspacy1 + (line_spacing * con_size);
	gr_rect(canvas, 0, 0, SWIDTH, y, color);
	gr_settransblend(canvas, GR_FADE_OFF, GR_BLEND_NORMAL);
	i+=con_scroll_offset;

	gr_set_fontcolor(canvas, BM_XRGB(255, 255, 255), -1);
	y = cli_draw(y, line_spacing);

	const auto &&fspacx = FSPACX();
	const auto &&fspacx1 = fspacx(1);
	for (;;)
	{
		auto &b = con_buffer[CON_LINES_MAX - 1 - i];
		gr_set_fontcolor(canvas, get_console_color_by_priority(b.priority), -1);
		int w,h;
		gr_get_string_size(game_font, b.line, &w, &h, nullptr);
		y -= h + fspacy1;
		gr_string(canvas, game_font, fspacx1, y, b.line, w, h);
		i++;

		if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0)
			break;
	}
	gr_rect(canvas, 0, 0, SWIDTH, line_spacing, color);
	gr_set_fontcolor(canvas, BM_XRGB(255, 255, 255),-1);
	gr_printf(canvas, game_font, fspacx1, fspacy1, "%s LOG", DESCENT_VERSION);
	gr_string(canvas, game_font, SWIDTH - fspacx(110), fspacy1, "PAGE-UP/DOWN TO SCROLL");
}
Exemple #11
0
void ui_draw_inputbox( UI_DIALOG *dlg, UI_GADGET_INPUTBOX * inputbox )
{
	int w, h, aw;

#if 0  //ndef OGL
	if ((inputbox->status==1) || (inputbox->position != inputbox->oldposition))
#endif
	{
		gr_set_current_canvas( inputbox->canvas );

		gr_setcolor( CBLACK );
		gr_rect( 0, 0, inputbox->width-1, inputbox->height-1 );
		gr_get_string_size(inputbox->text, &w, &h, &aw  );
		
		if (dlg->keyboard_focus_gadget == (UI_GADGET *)inputbox)
		{
			if (inputbox->first_time)
			{
				gr_set_fontcolor( CBLACK, -1 );
				gr_setcolor( CRED );
				gr_rect(2, 2, 2 + w, 2 + h);
			}
			else
				gr_set_fontcolor( CRED, -1 );
		}
		else
			gr_set_fontcolor( CWHITE, -1 );

		inputbox->status = 0;

		gr_string( 2, 2, inputbox->text );

		//gr_setcolor( CBLACK );
		//gr_rect( 2+w, 0, inputbox->width-1, inputbox->height-1 );

		if (dlg->keyboard_focus_gadget == (UI_GADGET *)inputbox  && !inputbox->first_time )
		{
			gr_setcolor(CRED);
			Vline( 2,inputbox->height-3, 2+w+1 );
			Vline( 2,inputbox->height-3, 2+w+2 );
		}
	}
}
Exemple #12
0
void print_status_bar( char message[DIAGNOSTIC_MESSAGE_MAX] ) {
	int w,h,aw;

	gr_set_current_canvas( NULL );
	gr_set_curfont(editor_font);
	gr_set_fontcolor( CBLACK, CGREY );
	gr_get_string_size( message, &w, &h, &aw );
	gr_string( 4, 583, message );
	gr_set_fontcolor( CBLACK, CWHITE );
	gr_setcolor( CGREY );
	gr_rect( 4+w, 583, 799, 599 );
}
Exemple #13
0
void gr_clear_canvas(int color)
{
#ifdef OGLES
	if (grd_curcanv->cv_bitmap.bm_type == BM_OGLES) {
		ogles_clear_canvas_textures();
		if (&grd_curscreen->sc_canvas == grd_curcanv) {
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		}
	}
#endif
	gr_setcolor(color);
	gr_rect(0,0,WIDTH,HEIGHT);
}
Exemple #14
0
// draw overlay on the screen
void help_overlay_blit(int overlay_id)
{
	int idx, width, height;
	int plinecount = help_overlaylist[overlay_id].plinecount;
	int textcount = help_overlaylist[overlay_id].textcount;
	int rbracketcount = help_overlaylist[overlay_id].rbracketcount;
	int lbracketcount = help_overlaylist[overlay_id].lbracketcount;

	Assert(overlay_id >= 0 && overlay_id < MAX_HELP_OVERLAYS);

	// this draws each line of help text with white on black text (use the GR_640 index for the string)
	for (idx = 0; idx < textcount; idx++)
	{
		gr_set_color_fast(&Color_black);
		gr_get_string_size(&width, &height, help_overlaylist[overlay_id].textlist[GR_640][idx].string,
			strlen(help_overlaylist[overlay_id].textlist[GR_640][idx].string));
		gr_rect(help_overlaylist[overlay_id].textlist[gr_screen.res][idx].x_coord - 2 * HELP_PADDING,
			help_overlaylist[overlay_id].textlist[gr_screen.res][idx].y_coord - 3 * HELP_PADDING,
			width + 4 * HELP_PADDING, height + 4 * HELP_PADDING);
		gr_set_color_fast(&Color_bright_white);
		gr_printf(help_overlaylist[overlay_id].textlist[gr_screen.res][idx].x_coord,
			help_overlaylist[overlay_id].textlist[gr_screen.res][idx].y_coord,
			help_overlaylist[overlay_id].textlist[GR_640][idx].string);
	}

	// this draws each right bracket
	for (idx = 0; idx < rbracketcount; idx++)
	{
		gr_set_bitmap(help_right_bracket_bitmap);
		gr_bitmap(help_overlaylist[overlay_id].rbracketlist[gr_screen.res][idx].x_coord,
			help_overlaylist[overlay_id].rbracketlist[gr_screen.res][idx].y_coord);
	}

	// this draws each left bracket
	for (idx = 0; idx < lbracketcount; idx++)
	{
		gr_set_bitmap(help_left_bracket_bitmap);
		gr_bitmap(help_overlaylist[overlay_id].lbracketlist[gr_screen.res][idx].x_coord,
			help_overlaylist[overlay_id].lbracketlist[gr_screen.res][idx].y_coord);
	}

	// this draws each 2d line for the help screen
	//gr_set_color_fast(&Color_yellow);
	gr_set_color(255, 255, 0);
	for (idx = 0; idx < plinecount; idx++)
	{
		gr_pline_special(help_overlaylist[overlay_id].plinelist[gr_screen.res][idx].pvtx,
			help_overlaylist[overlay_id].plinelist[GR_640][idx].vtxcount, HELP_PLINE_THICKNESS);
	}
}
void dc_draw_cursor( SCP_string &cmd_string, int x, int y )
{
	int t;
	int w, h;	// gr_string width and height

	t = timer_get_fixed_seconds() / (F1_0/3);
	if ( t & 1 ) {
		gr_get_string_size( &w, &h, cmd_string.c_str() );

		w %= (DCOLS * Current_font->w);
		//gr_string( w, debug_y*16, "_" );
		gr_rect((x + (w + 1)), (y + (h + 1)), 2, Current_font->h, GR_RESIZE_NONE);
	}
}
Exemple #16
0
void dc_draw_cursor( SCP_string &cmd_string, int x, int y )
{
	int t;
	int w, h;	// gr_string width and height

	t = timer_get_fixed_seconds() / (F1_0/3);
	if ( t & 1 ) {
		gr_get_string_size( &w, &h, cmd_string.c_str() );

		w %= (DCOLS * col_width);
		//gr_string( w, debug_y*16, "_" );
		gr_rect(gr_screen.center_offset_x + (x + (w + 1)), gr_screen.center_offset_y + (y + (h + 1)), 2,
			fl2i(font::get_current_font()->getHeight()), GR_RESIZE_NONE);
	}
}
Exemple #17
0
void editor_sub_status( const char *format, ... )
{
	int w,h,aw;
	va_list ap;

	va_start(ap, format);
	vsprintf(sub_status_line, format, ap);
	va_end(ap);

	gr_set_current_canvas( NULL );
	gr_set_curfont(editor_font);
	gr_set_fontcolor( BM_XRGB(0,0,31), CGREY );
	gr_get_string_size( sub_status_line, &w, &h, &aw );
	gr_string( 500, 583, sub_status_line );
	gr_set_fontcolor( CBLACK, CWHITE );
	gr_setcolor( CGREY );
	gr_rect( 500+w, 583, 799, 599 );
}
// write out the current description in the bottom window
void techroom_render_desc(int xo, int yo, int ho)
{
	int y, z, len, font_height;
	char line[MAX_TEXT_LINE_LEN + 1];

	font_height = gr_get_font_height();

	y = 0;
	z = Text_offset;
	while (y + font_height <= ho) {
		if (z >= Text_size){
			break;
		}

		len = Text_line_size[z];
		if (len > MAX_TEXT_LINE_LEN){
			len = MAX_TEXT_LINE_LEN;
		}

		strncpy(line, Text_lines[z], len);
		line[len] = 0;
		gr_string(xo, yo + y, line, GR_RESIZE_MENU);

		y += font_height;
		z++;
	}

	// maybe output 'more' indicator
	if ( z < Text_size ) {
		// can be scrolled down
		int more_txt_x = Tech_desc_coords[gr_screen.res][0] + (Tech_desc_coords[gr_screen.res][2]/2) - 10;	// FIXME should move these to constants since they don't move
		int more_txt_y = Tech_desc_coords[gr_screen.res][1] + Tech_desc_coords[gr_screen.res][3];				// located below brief text, centered
		int w, h;
		gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
		gr_set_color_fast(&Color_black);
		gr_rect(more_txt_x-2, more_txt_y, w+3, h, GR_RESIZE_MENU);
		gr_set_color_fast(&Color_more_indicator);
		gr_string(more_txt_x, more_txt_y, XSTR("more", 1469), GR_RESIZE_MENU);  // base location on the input x and y?
	}

}
// draw overlay on the screen
void help_overlay_blit(int overlay_id, int resolution_index)
{
	int idx, width, height;
	int plinecount = help_overlaylist[overlay_id].plinecount;
	int textcount = help_overlaylist[overlay_id].textcount;
	int rbracketcount = help_overlaylist[overlay_id].rbracketcount;
	int lbracketcount = help_overlaylist[overlay_id].lbracketcount;

	Assert(overlay_id >= 0 && overlay_id < MAX_HELP_OVERLAYS);

	// this draws each line of help text with white on black text (use the first resolution index for the string)
	gr_set_font(help_overlaylist[overlay_id].fontlist.at(resolution_index));
	for (idx = 0; idx < textcount; idx++) {
		gr_set_color_fast(&Color_black);
		gr_get_string_size(&width, &height, help_overlaylist[overlay_id].textlist.at(0).at(idx).string, strlen(help_overlaylist[overlay_id].textlist.at(0).at(idx).string));
		gr_rect(help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).x_coord-2*HELP_PADDING, help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).y_coord-3*HELP_PADDING, width+4*HELP_PADDING, height+4*HELP_PADDING, GR_RESIZE_MENU);
		gr_set_color_fast(&Color_bright_white);
		gr_printf_menu(help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).x_coord, help_overlaylist[overlay_id].textlist.at(resolution_index).at(idx).y_coord, help_overlaylist[overlay_id].textlist.at(0).at(idx).string);
	}
	gr_set_font(FONT1);

	// this draws each right bracket
	for (idx = 0; idx < rbracketcount; idx++) {
		gr_set_bitmap(help_right_bracket_bitmap);
		gr_bitmap(help_overlaylist[overlay_id].rbracketlist.at(resolution_index).at(idx).x_coord, help_overlaylist[overlay_id].rbracketlist.at(resolution_index).at(idx).y_coord, GR_RESIZE_MENU);
	}

	// this draws each left bracket
	for (idx = 0; idx < lbracketcount; idx++) {
		gr_set_bitmap(help_left_bracket_bitmap);
		gr_bitmap(help_overlaylist[overlay_id].lbracketlist.at(resolution_index).at(idx).x_coord, help_overlaylist[overlay_id].lbracketlist.at(resolution_index).at(idx).y_coord, GR_RESIZE_MENU);
	}	

	// this draws each 2d line for the help screen
	//gr_set_color_fast(&Color_yellow);
	gr_set_color(255, 255, 0);
	for (idx = 0; idx<plinecount; idx++) {
		gr_pline_special(&help_overlaylist[overlay_id].plinelist.at(resolution_index).at(idx).vtx, HELP_PLINE_THICKNESS, GR_RESIZE_MENU);
	}
}
Exemple #20
0
UI_GADGET_LISTBOX * ui_add_gadget_listbox(UI_WINDOW *wnd, short x, short y, short w, short h, short numitems, char **list)
{
	int tw, th, taw, i;

	UI_GADGET_LISTBOX * listbox;

	gr_get_string_size("*", &tw, &th, &taw );

	i = h / th;
	h = i * th;

	listbox = (UI_GADGET_LISTBOX *)ui_gadget_add( wnd, 2, x, y, x+w-1, y+h-1 );

	listbox->list = list;
	listbox->width = w;
	listbox->height = h;
	listbox->num_items = numitems;
	listbox->num_items_displayed = i;
	listbox->first_item = 0;
	listbox->current_item = -1;
	listbox->last_scrolled = 0;
	listbox->textheight = th;
	listbox->dragging = 0;
	listbox->selected_item = -1;
	listbox->moved = 1;

	listbox->scrollbar = ui_add_gadget_scrollbar( wnd, x+w+3, y, 0, h, 0, numitems-i, 0, i );
	listbox->scrollbar->parent = (UI_GADGET *)listbox;

	gr_set_current_canvas( listbox->canvas );

	gr_setcolor(CBLACK);
	gr_rect( 0, 0, w-1, h-1);

	gr_draw_sunken_border( -2, -2, w+listbox->scrollbar->width+4, h+1);

	return listbox;

}
Exemple #21
0
void gr_palette_step_up(int r, int g, int b) {
	if (gr_palette_faded_out) return;
	
#ifdef OGLES
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	gr_setcolor(BM_XRGB(r, g, b));
	gr_rect(0, 0, grd_curscreen->sc_w - 1, grd_curscreen->sc_h - 1);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	return;
#else
	int i;
	ubyte *p, new_pallete[256 * 3];
	int temp;
	
	if ( (r==last_r) && (g==last_g) && (b==last_b) ) return;

	last_r = r;
	last_g = g;
	last_b = b;

	p=gr_palette;
	for (i=0; i<256; i++ )	{
		temp = (int)(*p++) + r + gr_palette_gamma;
		if (temp<0) temp=0;
		else if (temp>63) temp=63;
		new_pallete[3 * i] = temp;
		temp = (int)(*p++) + g + gr_palette_gamma;
		if (temp<0) temp=0;
		else if (temp>63) temp=63;
		new_pallete[3 * i + 1] = temp;
		temp = (int)(*p++) + b + gr_palette_gamma;
		if (temp<0) temp=0;
		else if (temp>63) temp=63;
		new_pallete[3 * i + 2] = temp;
	}
	gr_palette_apply(new_pallete);
#endif
}
Exemple #22
0
void ui_draw_inputbox( UI_GADGET_INPUTBOX * inputbox )
{
	int w, h, aw;

	if ((inputbox->status==1) || (inputbox->position != inputbox->oldposition))
	{
		ui_mouse_hide();
		gr_set_current_canvas( inputbox->canvas );

		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)inputbox)
		{
			if (inputbox->first_time)
				gr_set_fontcolor( CBLACK, CRED );
			else
				gr_set_fontcolor( CRED, CBLACK );
		}
		else
			gr_set_fontcolor( CWHITE, CBLACK );

		inputbox->status = 0;

		gr_string( 2, 2, inputbox->text );
		gr_get_string_size(inputbox->text, &w, &h, &aw  );

		gr_setcolor( CBLACK );
		gr_rect( 2+w, 0, inputbox->width-1, inputbox->height-1 );

		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)inputbox  && !inputbox->first_time )
		{
			gr_setcolor(CRED);
			Vline( 2,inputbox->height-3, 2+w+1 );
			Vline( 2,inputbox->height-3, 2+w+2 );
		}

		ui_mouse_show();
	}
}
Exemple #23
0
void show_netplayerinfo()
{
	int x=0, y=0, i=0, color=0;
	
	gr_set_current_canvas(NULL);
	gr_set_curfont(GAME_FONT);
	gr_set_fontcolor(255,-1);
	
	x=(SWIDTH/2)-FSPACX(120);
	y=(SHEIGHT/2)-FSPACY(84);
	
	gr_settransblend(14, GR_BLEND_NORMAL);
	gr_setcolor( BM_XRGB(0,0,0) );
	gr_rect((SWIDTH/2)-FSPACX(120),(SHEIGHT/2)-FSPACY(84),(SWIDTH/2)+FSPACX(120),(SHEIGHT/2)+FSPACY(84));
	gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL);
	
	// general game information
	y+=LINE_SPACING;
	gr_printf(0x8000,y,"%s",Netgame.game_name);
#ifndef SHAREWARE
	y+=LINE_SPACING;
	gr_printf(0x8000,y,"%s - lvl: %i",Netgame.mission_title,Netgame.levelnum);
#endif
	
	x+=FSPACX(8);
	y+=LINE_SPACING*2;
	gr_printf(x,y,"game mode: %s",GMNames[Netgame.gamemode]);
	y+=LINE_SPACING;
	gr_printf(x,y,"difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty));
	y+=LINE_SPACING;
	gr_printf(x,y,"level time: %i:%02i:%02i",Players[Player_num].hours_level,f2i(Players[Player_num].time_level) / 60 % 60,f2i(Players[Player_num].time_level) % 60);
	y+=LINE_SPACING;
	gr_printf(x,y,"total time: %i:%02i:%02i",Players[Player_num].hours_total,f2i(Players[Player_num].time_total) / 60 % 60,f2i(Players[Player_num].time_total) % 60);
	y+=LINE_SPACING;
	if (Netgame.KillGoal)
		gr_printf(x,y,"Kill goal: %d",Netgame.KillGoal*5);
	
	// player information (name, kills, ping, game efficiency)
	y+=LINE_SPACING*2;
	gr_printf(x,y,"player");
	if (Game_mode & GM_MULTI_COOP)
		gr_printf(x+FSPACX(8)*7,y,"score");
	else
	{
		gr_printf(x+FSPACX(8)*7,y,"kills");
		gr_printf(x+FSPACX(8)*12,y,"deaths");
	}
	gr_printf(x+FSPACX(8)*18,y,"ping");
	gr_printf(x+FSPACX(8)*23,y,"efficiency");
	
	// process players table
	for (i=0; i<MAX_PLAYERS; i++)
	{
		if (!Players[i].connected)
			continue;
		
		y+=LINE_SPACING;
		
		if (Game_mode & GM_TEAM)
			color=get_team(i);
		else
			color=i;
		gr_set_fontcolor(BM_XRGB(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 );
		gr_printf(x,y,"%s\n",Players[i].callsign);
		if (Game_mode & GM_MULTI_COOP)
			gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].score);
		else
		{
			gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].net_kills_total);
			gr_printf(x+FSPACX(8)*12,y,"%-6d",Players[i].net_killed_total);
		}
		
		gr_printf(x+FSPACX(8)*18,y,"%-6d",Netgame.players[i].ping);
		if (i != Player_num)
			gr_printf(x+FSPACX(8)*23,y,"%d/%d",kill_matrix[Player_num][i],kill_matrix[i][Player_num]);
	}
	
	y+=LINE_SPACING*2+(LINE_SPACING*(MAX_PLAYERS-N_players));
	
	// printf team scores
	if (Game_mode & GM_TEAM)
	{
		gr_set_fontcolor(255,-1);
		gr_printf(x,y,"team");
		gr_printf(x+FSPACX(8)*8,y,"score");
		y+=LINE_SPACING;
		gr_set_fontcolor(BM_XRGB(player_rgb[get_team(0)].r,player_rgb[get_team(0)].g,player_rgb[get_team(0)].b),-1 );
		gr_printf(x,y,"%s:",Netgame.team_name[0]);
		gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[0]);
		y+=LINE_SPACING;
		gr_set_fontcolor(BM_XRGB(player_rgb[get_team(1)].r,player_rgb[get_team(1)].g,player_rgb[get_team(1)].b),-1 );
		gr_printf(x,y,"%s:",Netgame.team_name[1]);
		gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[1]);
		y+=LINE_SPACING*2;
	}
}
void UI_LISTBOX::draw()
{
	int i, x1, y1, stop;
	int w1, h1;

	UI_GADGET::draw();
	gr_set_font(my_wnd->f_id);

	if (uses_bmaps) {
		if (disabled_flag) {
			if ( bmap_ids[LBOX_DISABLED] >= 0 ) {
				gr_set_bitmap(bmap_ids[LBOX_DISABLED]);
				gr_bitmap(x, y);
			}

		} else {
			if ( bmap_ids[LBOX_NORMAL] >= 0 ) {
				gr_set_bitmap(bmap_ids[LBOX_NORMAL]);
				gr_bitmap(x, y);
			}
		}

	} else {
		gr_set_color_fast(&CBLACK);
		gr_set_clip( x, y, w, h );
		ui_rect( 0, 0, w-1, h-1 );
		gr_reset_clip();		
		if (has_scrollbar) {
			ui_draw_sunken_border( x-2, y-2, x+w+scrollbar.w+4, y+h+1 );

		} else {
			ui_draw_sunken_border( x-2, y-2, x+w+4, y+h+1 );
		}
	}

	stop = first_item+num_items_displayed;
	if (stop>num_items) stop = num_items;

	x1 = y1 = 0;
	gr_set_clip( x, y, w, h );

	for ( i=first_item; i<stop; i++ ) {
		gr_get_string_size( &w1, &h1,list[i] );

		if (check_list)
			w1 += 18;

		if (i !=current_item) {
/*
			if ((current_item == -1) && (my_wnd->selected_gadget == this ) && (i == first_item)  )	{
				if ( !uses_bmaps ) {
					gr_set_color_fast( &CBLACK );
					gr_rect( x1, y1, w1+2, h1 );
				}
				current_item = first_item;
				gr_set_color_fast( &CBRIGHT_GREEN );
			} else {
				if ( !uses_bmaps ) {
					gr_set_color_fast( &CBLACK );
					gr_rect( x1, y1, w1+2, h1 );
				}
				gr_set_color_fast( &CWHITE );
			}
*/
			if (!uses_bmaps) {
				gr_set_color_fast( &CBLACK );
				gr_rect( x1, y1, w1+2, h1 );
			}

			gr_set_color_fast(&CWHITE);

		} else {
			if (my_wnd->selected_gadget == this) {
				gr_set_color_fast( &CGRAY );
				gr_rect( x1, y1, w1+2, h1 );
				gr_set_color_fast( &CBRIGHT_GREEN );

			} else {
				gr_set_color_fast( &CGRAY );
				gr_rect( x1, y1, w1+2, h1 );
				gr_set_color_fast( &CBLACK );
			}
		}

		if ( check_list )	{
			if ( check_list[i] )	{
				gr_string( x1+2, y1, "X" );
			}

			gr_string( x1+16, y1, list[i] );

		} else
			gr_string( x1+2, y1, list[i] );

		if (i==current_item)
			gr_set_color_fast( &CGRAY );
		else
			gr_set_color_fast( &CBLACK );

		if ( !uses_bmaps ) {
			ui_rect( x1+w1+2, y1, w-1, y1+h1-1 );
			ui_rect( x1, y1, x1+1, y1+h1-1 );
		}

		y1 += h1;
	}

	if (stop < num_items_displayed-1 && !uses_bmaps) {
		gr_set_color_fast(&CBLACK);
		ui_rect( x1, y1, w-1, h-1 );
	}
}
Exemple #25
0
void ui_rect(int x1, int y1, int x2, int y2)
{
	gr_rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
}
Exemple #26
0
void ui_draw_listbox( UI_GADGET_LISTBOX * listbox )
{
	int i, x, y, stop;
	int w, h,  aw;

	//if (listbox->current_item<0)
	//    listbox->current_item=0;
	//if (listbox->current_item>=listbox->num_items)
	//    listbox->current_item = listbox->num_items-1;
	//if (listbox->first_item<0)
	//   listbox->first_item=0;
	//if (listbox->first_item>(listbox->num_items-listbox->num_items_displayed))
	//    listbox->first_item=(listbox->num_items-listbox->num_items_displayed);

	if ((listbox->status!=1) && !listbox->moved )
		return;

	stop = listbox->first_item+listbox->num_items_displayed;
	if (stop>listbox->num_items) stop = listbox->num_items;

	listbox->status = 0;

	x = y = 0;
	ui_mouse_hide();
	gr_set_current_canvas( listbox->canvas );

	for (i= listbox->first_item; i< stop; i++ )
	{
		if (i !=listbox->current_item)
		{
			if ((listbox->current_item == -1) && (CurWindow->keyboard_focus_gadget == (UI_GADGET *)listbox) && (i == listbox->first_item)  )
				gr_set_fontcolor( CRED, CBLACK );
			else
				gr_set_fontcolor( CWHITE, CBLACK );
		}
		else
		{
			if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)listbox)
				gr_set_fontcolor( CRED, CGREY );
			else
				gr_set_fontcolor( CBLACK, CGREY );
		}
		gr_string(x + 2, y, listbox->list[i]);
		gr_get_string_size(listbox->list[i], &w, &h, &aw);

		if (i==listbox->current_item)
			gr_setcolor( CGREY );
		else
			gr_setcolor( CBLACK );

		if (x + w + 2 < listbox->width - 1)
			gr_rect(x + w + 2, y, listbox->width - 1, y + h - 1);
		gr_rect( x, y, x+1, y+h-1 );

		y += h;
	}

	if (stop < listbox->num_items_displayed-1 )
	{
		gr_setcolor(CBLACK);
		gr_rect( x, y, listbox->width-1, listbox->height-1 );
	}

	//gr_ubox( -1, -1, listbox->width, listbox->height);
	ui_mouse_show();

}
Exemple #27
0
void ui_draw_listbox( UI_DIALOG *dlg, UI_GADGET_LISTBOX * listbox )
{
	int i, x, y, stop;
	int w, h,  aw;

	//if (listbox->current_item<0)
	//    listbox->current_item=0;
	//if (listbox->current_item>=listbox->num_items)
	//    listbox->current_item = listbox->num_items-1;
	//if (listbox->first_item<0)
	//   listbox->first_item=0;
	//if (listbox->first_item>(listbox->num_items-listbox->num_items_displayed))
	//    listbox->first_item=(listbox->num_items-listbox->num_items_displayed);

#if 0  //ndef OGL
	if ((listbox->status!=1) && !listbox->moved )
		return;
#endif

	gr_set_current_canvas( listbox->canvas );
	
	w = listbox->width;
	h = listbox->height;

	gr_setcolor(CBLACK);
	gr_rect( 0, 0, w-1, h-1);
	
	gr_draw_sunken_border( -2, -2, w+listbox->scrollbar->width+4, h+1);
	
	stop = listbox->first_item+listbox->num_items_displayed;
	if (stop>listbox->num_items) stop = listbox->num_items;

	listbox->status = 0;

	x = y = 0;

	for (i= listbox->first_item; i< stop; i++ )
	{
		if (i==listbox->current_item)
			gr_setcolor( CGREY );
		else
			gr_setcolor( CBLACK );
		
		gr_rect(x, y, listbox->width - 1, y + h - 1);

		if (i !=listbox->current_item)
		{
			if ((listbox->current_item == -1) && (dlg->keyboard_focus_gadget == (UI_GADGET *)listbox) && (i == listbox->first_item)  )
				gr_set_fontcolor( CRED, -1 );
			else
				gr_set_fontcolor( CWHITE, -1 );
		}
		else
		{
			if (dlg->keyboard_focus_gadget == (UI_GADGET *)listbox)
				gr_set_fontcolor( CRED, -1 );
			else
				gr_set_fontcolor( CBLACK, -1 );
		}
		gr_string(x + 2, y, listbox->list[i]);
		gr_get_string_size(listbox->list[i], &w, &h, &aw);

		y += h;
	}

	if (stop < listbox->num_items_displayed-1 )
	{
		gr_setcolor(CBLACK);
		gr_rect( x, y, listbox->width-1, listbox->height-1 );
	}

	//gr_ubox( -1, -1, listbox->width, listbox->height);
}
void UI_INPUTBOX::draw()
{
	int invis, w1, h1, tw, th;
	int text_x, text_y;

	if (hidden){
		return;
	}

	w1 = w;
	h1 = h;
	invis = flags & UI_INPUTBOX_FLAG_INVIS;

	gr_set_font(my_wnd->f_id);
	gr_reset_clip();
	if (!invis && !(flags & UI_INPUTBOX_FLAG_NO_BACK)) {
		// draw the entire text box region
		ui_draw_sunken_border( x-2, y-2, x+w+1, y+h+1 );
		gr_set_color_fast( &CBLACK );
		gr_rect( 0, 0, w, h, GR_RESIZE_MENU );
		w1 -= 4;
		h1 -= 4;
		gr_set_clip( x + 1, y + 1, w1 + 1, h1 + 1, GR_RESIZE_MENU );
	} else {
		gr_set_clip( x - 1, y - 1, w1 + 1, h1 + 1, GR_RESIZE_MENU );
	}

	if (flags & UI_INPUTBOX_FLAG_PASSWD){
		gr_get_string_size(&tw, &th, passwd_text);
	} else {
		gr_get_string_size(&tw, &th, text);
	}

	if (!disabled_flag && !(flags & UI_INPUTBOX_FLAG_NO_BACK)) {
		gr_set_color_fast( &CBLACK );

		// color the background behind the text	
		gr_rect( 0, 0, tw + 1, th, GR_RESIZE_MENU_NO_OFFSET );
	}

	if	( (my_wnd->selected_gadget == this) || disabled_flag ) {		
		gr_set_color_fast(text_color);
	} else {
		gr_set_color_fast(&CWHITE);
	}

	// coords of where to draw the text
	text_x = 1;
	text_y = 1;
	if(flags & UI_INPUTBOX_FLAG_TEXT_CEN){
		// if we fit within the text area, draw it centered
		if(tw <= w1 - 5){
			text_x += (w1 - tw)/2;
		}		
	}

	// draw the text
	if (flags & UI_INPUTBOX_FLAG_PASSWD){
		gr_string(text_x, text_y, passwd_text, GR_RESIZE_MENU);
	} else {
		gr_string(text_x, text_y, text, GR_RESIZE_MENU);
	}

	// draw the "cursor"
	if (!disabled_flag) {
		if (my_wnd->selected_gadget == this) {
			if (cursor_first_frame == -1) {
				gr_set_color_fast(text_color);
				ui_vline(1, h1, text_x + tw + 4);
				ui_vline(1, h1, text_x + tw + 5);
			} else {
				// draw animating cursor
				int time_delta = timer_get_milliseconds() - cursor_elapsed_time;

				if ( (time_delta / 1000.0f) > (1.0f / cursor_fps) ) {
					// advance frame
					cursor_elapsed_time += time_delta;
					cursor_current_frame++;
					if (cursor_current_frame >= cursor_nframes) {
						cursor_current_frame = 0;
					}
				}

				// draw current frame
				gr_set_bitmap(cursor_first_frame + cursor_current_frame);
				gr_bitmap(text_x + tw + 4, 1, GR_RESIZE_MENU_NO_OFFSET);
			}
		}
	}

	gr_reset_clip();
}
// do
void fiction_viewer_do_frame(float frametime)
{
	int i, k, w, h;

	// make sure we exist
	if (!Fiction_viewer_inited)
	{
		fiction_viewer_exit();
		return;
	}

	// process keys
	k = Fiction_viewer_window.process() & ~KEY_DEBUGGED;	

	switch (k)
	{
		case KEY_ESC:
			common_music_close();
			gameseq_post_event(GS_EVENT_MAIN_MENU);
			return;
	}

	// process button presses
	for (i = 0; i < NUM_FVW_BUTTONS; i++)
		if (Fiction_viewer_buttons[Fiction_viewer_ui][gr_screen.res][i].button.pressed())
			fiction_viewer_button_pressed(i);
	
	common_music_do();

	// clear
	GR_MAYBE_CLEAR_RES(Fiction_viewer_bitmap);
	if (Fiction_viewer_bitmap >= 0)
	{
		gr_set_bitmap(Fiction_viewer_bitmap);
		gr_bitmap(0, 0, GR_RESIZE_MENU);
	} 
	
	// draw the window
	Fiction_viewer_window.draw();		

	// render the briefing text
	brief_render_text(Top_fiction_viewer_text_line, Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][0], Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][1], Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][3], frametime);

	// maybe output the "more" indicator
	if ((Fiction_viewer_text_max_lines + Top_fiction_viewer_text_line) < Num_brief_text_lines[0])
	{
		use_std_font();

		// can be scrolled down
		int more_txt_x = Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][0] + (Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][2]/2) - 10;
		int more_txt_y = Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][1] + Fiction_viewer_text_coordinates[Fiction_viewer_ui][gr_screen.res][3];				// located below text, centered

		gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
		gr_set_color_fast(&Color_black);
		gr_rect(more_txt_x-2, more_txt_y, w+3, h, GR_RESIZE_MENU);
		gr_set_color_fast(&Color_more_indicator);
		gr_string(more_txt_x, more_txt_y, XSTR("more", 1469), GR_RESIZE_MENU);  // base location on the input x and y?

		use_fv_font();
	}

	gr_flip();
}
Exemple #30
0
// Handler for the main editor dialog
int editor_handler(UI_DIALOG *dlg, d_event *event, void *data)
{
	editor_view *new_cv;
	int keypress = 0;
	int rval = 0;

	if (event->type == EVENT_KEY_COMMAND)
		keypress = event_key_get(event);
	else if (event->type == EVENT_WINDOW_CLOSE)
	{
		close_editor();
		EditorWindow = NULL;
		return 0;
	}
	
	// Update the windows

	if (event->type == EVENT_UI_DIALOG_DRAW)
	{
		gr_set_curfont(editor_font);

		// Draw status box
		gr_set_current_canvas( NULL );
		gr_setcolor( CGREY );
		gr_rect(STATUS_X,STATUS_Y,STATUS_X+STATUS_W-1,STATUS_Y+STATUS_H-1);			//0, 582, 799, 599 );
		
		medlisp_update_screen();
		calc_frame_time();
		texpage_do(event);
		objpage_do(event);
		ui_pad_draw(EditorWindow, PAD_X, PAD_Y);

		print_status_bar(status_line);
		TimedAutosave(mine_filename);	// shows the time, hence here
		set_editor_time_of_day();
		return 1;
	}
	
	if ((selected_gadget == (UI_GADGET *)GameViewBox && !render_3d_in_big_window) ||
		(selected_gadget == (UI_GADGET *)LargeViewBox && render_3d_in_big_window))
		switch (event->type)
		{
			case EVENT_MOUSE_BUTTON_UP:
			case EVENT_MOUSE_BUTTON_DOWN:
				break;
			case EVENT_MOUSE_MOVED:
				if (!keyd_pressed[ KEY_LCTRL ] && !keyd_pressed[ KEY_RCTRL ])
					break;
			case EVENT_JOYSTICK_BUTTON_UP:
			case EVENT_JOYSTICK_BUTTON_DOWN:
			case EVENT_JOYSTICK_MOVED:
			case EVENT_KEY_COMMAND:
			case EVENT_KEY_RELEASE:
			case EVENT_IDLE:
				kconfig_read_controls(event, 1);

				if (slew_frame(0))
				{		//do movement and check keys
					Update_flags |= UF_GAME_VIEW_CHANGED;
					if (Gameview_lockstep)
					{
						Cursegp = &Segments[ConsoleObject->segnum];
						med_create_new_segment_from_cursegp();
						Update_flags |= UF_ED_STATE_CHANGED;
					}

					rval = 1;
				}
				break;
				
			default:
				break;
		}

	//do non-essential stuff in idle event
	if (event->type == EVENT_IDLE)
	{
		check_wall_validity();
		Assert(Num_walls>=0);

		if (Gameview_lockstep) {
			static segment *old_cursegp=NULL;
			static int old_curside=-1;

			if (old_cursegp!=Cursegp || old_curside!=Curside) {
				SetPlayerFromCursegMinusOne();
				old_cursegp = Cursegp;
				old_curside = Curside;
			}
		}

		if ( event_get_idle_seconds() > COMPRESS_INTERVAL ) 
		{
			med_compress_mine();
			event_reset_idle_seconds();
		}

	//	Commented out because it occupies about 25% of time in twirling the mine.
	// Removes some Asserts....
	//		med_check_all_vertices();
		clear_editor_status();		// if enough time elapsed, clear editor status message
	}

	gr_set_current_canvas( GameViewBox->canvas );
	
	// Remove keys used for slew
	switch(keypress)
	{
		case KEY_PAD9:
		case KEY_PAD7:
		case KEY_PADPLUS:
		case KEY_PADMINUS:
		case KEY_PAD8:
		case KEY_PAD2:
		case KEY_LBRACKET:
		case KEY_RBRACKET:
		case KEY_PAD1:
		case KEY_PAD3:
		case KEY_PAD6:
		case KEY_PAD4:
			keypress = 0;
	}
	if ((keypress&0xff)==KEY_LSHIFT) keypress=0;
	if ((keypress&0xff)==KEY_RSHIFT) keypress=0;
	if ((keypress&0xff)==KEY_LCTRL) keypress=0;
	if ((keypress&0xff)==KEY_RCTRL) keypress=0;
//		if ((keypress&0xff)==KEY_LALT) keypress=0;
//		if ((keypress&0xff)==KEY_RALT) keypress=0;

	//=================== DO FUNCTIONS ====================

	if ( KeyFunction[ keypress ] != NULL )
	{
		KeyFunction[keypress]();
		keypress = 0;
		rval = 1;
	}

	switch (keypress)
	{
		case 0:
		case KEY_Z:
		case KEY_G:
		case KEY_LALT:
		case KEY_RALT:
		case KEY_LCTRL:
		case KEY_RCTRL:
		case KEY_LSHIFT:
		case KEY_RSHIFT:
		case KEY_LAPOSTRO:
			break;
		case KEY_SHIFTED + KEY_L:
			ToggleLighting();
			rval = 1;
			break;
		case KEY_F1:
			render_3d_in_big_window = !render_3d_in_big_window;
			Update_flags |= UF_ALL;
			rval = 1;
			break;			
		default:
			if (!rval)
			{
				char kdesc[100];
				GetKeyDescription( kdesc, keypress );
				editor_status_fmt("Error: %s isn't bound to anything.", kdesc  );
			}
	}

	//================================================================

	if (ModeFlag)
	{
		ui_close_dialog(EditorWindow);
		return 0;
	}

//		if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) current_view=NULL;
//		if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) current_view=NULL;

	new_cv = current_view;

#if ORTHO_VIEWS
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)LargeViewBox) new_cv=&LargeView;
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)TopViewBox)	new_cv=&TopView;
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)FrontViewBox) new_cv=&FrontView;
	if (EditorWindow->keyboard_focus_gadget == (UI_GADGET *)RightViewBox) new_cv=&RightView;
#endif
	if (new_cv != current_view ) {
		current_view->ev_changed = 1;
		new_cv->ev_changed = 1;
		current_view = new_cv;
	}

	// DO TEXTURE STUFF
	if (texpage_do(event))
		rval = 1;
	
	if (objpage_do(event))
		rval = 1;


	// Process selection of Cursegp using mouse.
	if (GADGET_PRESSED(LargeViewBox) && !render_3d_in_big_window) 
	{
		int	xcrd,ycrd;
		xcrd = LargeViewBox->b1_drag_x1;
		ycrd = LargeViewBox->b1_drag_y1;

		find_segments(xcrd,ycrd,LargeViewBox->canvas,&LargeView,Cursegp,Big_depth);	// Sets globals N_found_segs, Found_segs

		// If shift is down, then add segment to found list
		if (keyd_pressed[ KEY_LSHIFT ] || keyd_pressed[ KEY_RSHIFT ])
			subtract_found_segments_from_selected_list();
		else
			add_found_segments_to_selected_list();

		Found_seg_index = 0;	
	
		if (N_found_segs > 0) {
			sort_seg_list(N_found_segs,Found_segs,&ConsoleObject->pos);
			Cursegp = &Segments[Found_segs[0]];
			med_create_new_segment_from_cursegp();
			if (Lock_view_to_cursegp)
				set_view_target_from_segment(Cursegp);
		}

		Update_flags |= UF_ED_STATE_CHANGED | UF_VIEWPOINT_MOVED;
	}

	if ((event->type == EVENT_UI_USERBOX_DRAGGED) && (ui_event_get_gadget(event) == (UI_GADGET *)GameViewBox))
	{
		int	x, y;
		x = GameViewBox->b1_drag_x2;
		y = GameViewBox->b1_drag_y2;

		gr_set_current_canvas( GameViewBox->canvas );
		gr_setcolor( 15 );
		gr_rect( x-1, y-1, x+1, y+1 );
	}
	
	// Set current segment and side by clicking on a polygon in game window.
	//	If ctrl pressed, also assign current texture map to that side.
	//if (GameViewBox->mouse_onme && (GameViewBox->b1_done_dragging || GameViewBox->b1_clicked)) {
	if ((GADGET_PRESSED(GameViewBox) && !render_3d_in_big_window) ||
		(GADGET_PRESSED(LargeViewBox) && render_3d_in_big_window))
	{
		int	xcrd,ycrd;
		int seg,side,face,poly,tmap;

		if (render_3d_in_big_window) {
			xcrd = LargeViewBox->b1_drag_x1;
			ycrd = LargeViewBox->b1_drag_y1;
		}
		else {
			xcrd = GameViewBox->b1_drag_x1;
			ycrd = GameViewBox->b1_drag_y1;
		}

		//Int3();

		if (find_seg_side_face(xcrd,ycrd,&seg,&side,&face,&poly)) {


			if (seg<0) {							//found an object

				Cur_object_index = -seg-1;
				editor_status_fmt("Object %d selected.",Cur_object_index);

				Update_flags |= UF_ED_STATE_CHANGED;
			}
			else {

				//	See if either shift key is down and, if so, assign texture map
				if (keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) {
					Cursegp = &Segments[seg];
					Curside = side;
					AssignTexture();
					med_create_new_segment_from_cursegp();
					editor_status("Texture assigned");
				} else if (keyd_pressed[KEY_G])	{
					tmap = Segments[seg].sides[side].tmap_num;
					texpage_grab_current(tmap);
					editor_status( "Texture grabbed." );
				} else if (keyd_pressed[ KEY_LAPOSTRO] ) {
					move_object_to_mouse_click();
				} else {
					Cursegp = &Segments[seg];
					Curside = side;
					med_create_new_segment_from_cursegp();
					editor_status("Curseg and curside selected");
				}
			}

			Update_flags |= UF_ED_STATE_CHANGED;
		}
		else 
			editor_status("Click on non-texture ingored");

	}

	// Allow specification of LargeView using mouse
	if (event->type == EVENT_MOUSE_MOVED && (keyd_pressed[ KEY_LCTRL ] || keyd_pressed[ KEY_RCTRL ]))
	{
		int dx, dy, dz;

		event_mouse_get_delta(event, &dx, &dy, &dz);
		if ((dx != 0) && (dy != 0))
		{
			vms_matrix	MouseRotMat,tempm;
			
			GetMouseRotation( dx, dy, &MouseRotMat );
			vm_matrix_x_matrix(&tempm,&LargeView.ev_matrix,&MouseRotMat);
			LargeView.ev_matrix = tempm;
			LargeView.ev_changed = 1;
			Large_view_index = -1;			// say not one of the orthogonal views
			rval = 1;
		}
	}

	if (event->type == EVENT_MOUSE_MOVED)
	{
		int dx, dy, dz;

		event_mouse_get_delta(event, &dx, &dy, &dz);
		if (dz != 0)
		{
			current_view->ev_dist += dz*10000;
			current_view->ev_changed = 1;
		}
	}
	
	return rval;
}