Exemplo n.º 1
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();
}
Exemplo n.º 2
0
void ui_draw_checkbox( UI_GADGET_CHECKBOX * checkbox )
{

	if ((checkbox->status==1) || (checkbox->position != checkbox->oldposition))
	{
		checkbox->status = 0;

		ui_mouse_hide();
		gr_set_current_canvas( checkbox->canvas );

		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)checkbox)
			gr_set_fontcolor( CRED, -1 );
		else
			gr_set_fontcolor( CBLACK, -1 );

		if (checkbox->position == 0 )
		{
			ui_draw_box_out( 0, 0, checkbox->width-1, checkbox->height-1 );
			if (checkbox->flag)
				ui_string_centered(  Middle(checkbox->width), Middle(checkbox->height), "X" );
			else
				ui_string_centered(  Middle(checkbox->width), Middle(checkbox->height), " " );
		} else {
			ui_draw_box_in( 0, 0, checkbox->width-1, checkbox->height-1 );
			if (checkbox->flag)
				ui_string_centered(  Middle(checkbox->width)+1, Middle(checkbox->height)+1, "X" );
			else
				ui_string_centered(  Middle(checkbox->width)+1, Middle(checkbox->height)+1, " " );
		}

		gr_ustring( checkbox->width+4, 2, checkbox->text );

		ui_mouse_show();
	}
}
Exemplo n.º 3
0
Arquivo: menubar.c Projeto: btb/d2x
void menu_show( MENU * menu )
{
	int i;

	ui_mouse_hide();

	gr_set_current_canvas(NULL);
	// Don't save background it if it's already drawn
	if (!menu->Displayed) 
	{
		// Save the background
		gr_bm_ubitblt(menu->w, menu->h, 0, 0, menu->x, menu->y, &(grd_curscreen->sc_canvas.cv_bitmap), menu->Background);

		// Draw the menu background
		gr_setcolor( CGREY );
		gr_urect( menu->x, menu->y, menu->x + menu->w - 1, menu->y + menu->h - 1 );
		if ( menu != &Menu[0] )
		{
			gr_setcolor( CBLACK );
			gr_ubox( menu->x, menu->y, menu->x + menu->w - 1, menu->y + menu->h - 1 );
		}
	}
		
	// Draw the items
	
	for (i=0; i< menu->NumItems; i++ )
		item_show( menu, i );

	ui_mouse_show();
	
	// Mark as displayed.
	menu->Displayed = 1;
}
Exemplo n.º 4
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();

}
Exemplo n.º 5
0
Arquivo: radio.c Projeto: btb/d1x
void ui_draw_radio( UI_GADGET_RADIO * radio )
{

	if ((radio->status==1) || (radio->position != radio->oldposition))
	{
		radio->status = 0;

		ui_mouse_hide();
		gr_set_current_canvas( radio->canvas );

		if (radio->flag)
			gr_set_fontcolor( CRED, -1 );
		else
			gr_set_fontcolor( CBLACK, -1 );

		if (radio->position == 0 )
		{
			ui_draw_box_out( 0, 0, radio->width-1, radio->height-1 );
			ui_string_centered(  Middle(radio->width), Middle(radio->height), "þ" );
		} else {
			ui_draw_box_in( 0, 0, radio->width-1, radio->height-1 );
			ui_string_centered(  Middle(radio->width)+1, Middle(radio->height)+1, "þ" );
		}

		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)radio)
			gr_set_fontcolor( CRED, CWHITE );
		else
			gr_set_fontcolor( CBLACK, CWHITE );

		gr_ustring( radio->width+4, 2, radio->text );

		ui_mouse_show();
	}
}
Exemplo n.º 6
0
int MacroPlayFast()
{
	if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
	{
		ui_mouse_hide();
		ui_play_events_fast(MacroNumEvents, RecordBuffer);
		MacroStatus = UI_STATUS_FASTPLAY;
	}
	return 1;
}
Exemplo n.º 7
0
void ui_wprintf( UI_WINDOW * wnd, char * format, ... )
{
	char buffer[1000];
	va_list args;

	va_start(args, format );
	vsprintf(buffer,format,args);

	gr_set_current_canvas( W_CANVAS );

	ui_mouse_hide();
	W_TEXT_X = gr_string( W_TEXT_X, W_TEXT_Y, buffer );
	ui_mouse_show();
}
Exemplo n.º 8
0
void ui_wprintf_at( UI_WINDOW * wnd, short x, short y, char * format, ... )
{
	char buffer[1000];
	va_list args;

	va_start(args, format );
	vsprintf(buffer,format,args);

	gr_set_current_canvas( W_CANVAS );

	ui_mouse_hide();
	gr_string( x, y, buffer );
	ui_mouse_show();

}
Exemplo n.º 9
0
Arquivo: menubar.c Projeto: btb/d2x
void menu_move_bar_to( MENU * menu, int number )
{
	int old_item;

	old_item = menu->CurrentItem;
	menu->CurrentItem = number;
	
	if (menu->Displayed && (number != old_item))
	{
		ui_mouse_hide();

		item_show( menu, old_item );
		item_show( menu, number );

		ui_mouse_show();
	}
}
Exemplo n.º 10
0
int medlisp_update_screen()
{
	int vn;

if (!render_3d_in_big_window)
	for (vn=0;vn<N_views;vn++)
		if (Views[vn]->ev_changed || (Update_flags & (UF_WORLD_CHANGED|UF_VIEWPOINT_MOVED|UF_ED_STATE_CHANGED))) {
			draw_world(Views[vn]->ev_canv,Views[vn],Cursegp,Big_depth);
			Views[vn]->ev_changed = 0;
		}

	if (Update_flags & (UF_WORLD_CHANGED|UF_GAME_VIEW_CHANGED|UF_ED_STATE_CHANGED)) {
		grs_canvas temp_canvas;
		grs_canvas *render_canv,*show_canv;
		
		if (render_3d_in_big_window) {
			
			gr_init_sub_canvas(&temp_canvas,canv_offscreen,0,0,
				LargeView.ev_canv->cv_bitmap.bm_w,LargeView.ev_canv->cv_bitmap.bm_h);

			render_canv = &temp_canvas;
			show_canv = LargeView.ev_canv;

		}
		else {
			render_canv	= VR_offscreen_buffer;
			show_canv	= Canv_editor_game;
		}

		gr_set_current_canvas(render_canv);
		render_frame(0);

		Assert(render_canv->cv_bitmap.bm_w == show_canv->cv_bitmap.bm_w &&
				 render_canv->cv_bitmap.bm_h == show_canv->cv_bitmap.bm_h);

		ui_mouse_hide();
		gr_bm_ubitblt(show_canv->cv_bitmap.bm_w,show_canv->cv_bitmap.bm_h,
						  0,0,0,0,&render_canv->cv_bitmap,&show_canv->cv_bitmap);
		ui_mouse_show();
	}

	Update_flags=UF_NONE;       //clear flags

	return 1;
}
Exemplo n.º 11
0
Arquivo: menubar.c Projeto: btb/d2x
void menu_hide( MENU * menu )
{

	// Can't hide if it's not already drawn
	if (!menu->Displayed) return;

	menu->Active = 0;
		
	// Restore the background
	ui_mouse_hide();

	gr_bm_ubitblt(menu->w, menu->h, menu->x, menu->y, 0, 0, menu->Background, &(grd_curscreen->sc_canvas.cv_bitmap));

	ui_mouse_show();
	
	// Mark as hidden.
	menu->Displayed = 0;
}
Exemplo n.º 12
0
void ui_draw_userbox( UI_GADGET_USERBOX * userbox )
{

	if ( userbox->status==1 )
	{
		userbox->status = 0;

		ui_mouse_hide();
		gr_set_current_canvas( userbox->canvas );

		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)userbox)
			gr_setcolor( CRED );
		else
			gr_setcolor( CBRIGHT );

		gr_box( -1, -1, userbox->width, userbox->height );

		ui_mouse_show();
	}
}
Exemplo n.º 13
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();
	}
}
Exemplo n.º 14
0
Arquivo: med.c Projeto: paud/d2x-xl
// ---------------------------------------------------------------------------------------------------
//this function is the editor. called when editor mode selected.  runs until
//game mode or exit selected
void editor(void)
{
	int w,h;
	grsBitmap * savedbitmap;
	editorView *new_cv;
        static int padnum=0;
	vmsMatrix	MouseRotMat,tempm;
	//@@short camera_objnum;			//a camera for viewing

	init_editor();

	InitCurve();

	RestoreEffectBitmapIcons();

	if (!SetScreenMode(SCREEN_EDITOR))	{
		SetScreenMode(SCREEN_GAME);
		gameStates.app.nFunctionMode=FMODE_GAME;			//force back into game
		return;
	}

	GrSetCurrentCanvas( NULL );
	GrSetCurFont(editor_font);

	//Editor renders into full (320x200) game screen 

	SetWarnFunc(med_show_warning);

	gameStates.input.keys.bRepeat = 1;		// Allow repeat in editor

//	_MARK_("start of editor");//Nuked to compile -KRB

	ui_mouse_hide();
	ui_reset_idleSeconds();
	gameData.objs.viewer = gameData.objs.console;
	slew_init(gameData.objs.console);
	UpdateFlags = UF_ALL;
	medlisp_update_screen();

	//set the wire-frame window to be the current view
	currentView = &LargeView;

	if (faded_in==0)
	{
		faded_in = 1;
		//gr_pal_fade_in( grdCurScreen->pal );
	}

	w = GameViewBox->canvas->cvBitmap.bmProps.w;
	h = GameViewBox->canvas->cvBitmap.bmProps.h;

	savedbitmap = GrCreateBitmap(w, h );

	GrBmUBitBlt( w, h, 0, 0, 0, 0, &GameViewBox->canvas->cvBitmap, savedbitmap );

	GrSetCurrentCanvas( GameViewBox->canvas );
	GrSetCurFont(editor_font);
	//GrSetColor( CBLACK );
	//gr_deaccent_canvas();
	//gr_grey_canvas();

	ui_mouse_show();

	GrSetCurFont(editor_font);
	ui_pad_goto(padnum);

	gamestate_restore_check();

	while (gameStates.app.nFunctionMode == FMODE_EDITOR) {

		GrSetCurFont(editor_font);
		info_display_all(EditorWindow);

		ModeFlag = 0;

		// Update the windows

		// Only update if there is no key waiting and we're not in
		// fast play mode.
		if (!KeyPeekKey()) //-- && (MacroStatus != UI_STATUS_FASTPLAY))
			medlisp_update_screen();

		//do editor stuff
		GrSetCurFont(editor_font);
		ui_mega_process();
		last_keypress &= ~KEYDBGGED;		//	mask off delete key bit which has no function in editor.
		ui_window_do_gadgets(EditorWindow);
		doRobot_window();
		doObject_window();
		do_wall_window();
		do_trigger_window();
		do_hostage_window();
		do_centers_window();
		check_wall_validity();
		Assert(gameData.walls.nWalls>=0);

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

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

		if ( ui_get_idleSeconds() > COMPRESS_INTERVAL ) 
			{
			med_compress_mine();
			ui_reset_idleSeconds();
			}
  
//	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
		TimedAutosave(mine_filename);
		set_editorTime_of_day();
		GrSetCurrentCanvas( GameViewBox->canvas );
	
		// Remove keys used for slew
		switch(last_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:
			last_keypress = 0;
		}
		if ((last_keypress&0xff)==KEY_LSHIFT) last_keypress=0;
		if ((last_keypress&0xff)==KEY_RSHIFT) last_keypress=0;
		if ((last_keypress&0xff)==KEY_LCTRL) last_keypress=0;
		if ((last_keypress&0xff)==KEY_RCTRL) last_keypress=0;
//		if ((last_keypress&0xff)==KEY_LALT) last_keypress=0;
//		if ((last_keypress&0xff)==KEY_RALT) last_keypress=0;

		GrSetCurFont(editor_font);
		menubar_do( last_keypress );

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

		if ( KeyFunction[ last_keypress ] != NULL )	{
			KeyFunction[last_keypress]();
			last_keypress = 0;
		}
		switch (last_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();
			break;
		case KEY_F1:
			render_3d_in_big_window = !render_3d_in_big_window;
			UpdateFlags |= UF_ALL;
			break;		
		default:
			{
			char kdesc[100];
			GetKeyDescription( kdesc, last_keypress );
			editor_status("Error: %s isn't bound to anything.", kdesc  );
			}
		}

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

		if (ModeFlag==1)
		{
			close_editor_screen();
			gameStates.app.nFunctionMode=FMODE_EXIT;
				GrFreeBitmap( savedbitmap );
			break;
		}

		if (ModeFlag==2) //-- && MacroStatus==UI_STATUS_NORMAL )
		{
			ui_mouse_hide();
			gameStates.app.nFunctionMode = FMODE_GAME;
			GrBmUBitBlt( w, h, 0, 0, 0, 0, savedbitmap, &GameViewBox->canvas->cvBitmap);
			GrFreeBitmap( savedbitmap );
			break;
		}

		if (ModeFlag==3) //-- && MacroStatus==UI_STATUS_NORMAL )
		{
//			med_compress_mine();						//will be called anyways before game.
			close_editor_screen();
			gameStates.app.nFunctionMode=FMODE_GAME;			//force back into game
			SetScreenMode(SCREEN_GAME);		//put up game screen
			GrFreeBitmap( savedbitmap );
			break;
		}

//		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GameViewBox) currentView=NULL;
//		if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)GroupViewBox) currentView=NULL;

		new_cv = currentView ;

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

		CalcFrameTime();
		if (slew_frame(0)) {		//do movement and check keys
			UpdateFlags |= UF_GAME_VIEW_CHANGED;
			if (Gameview_lockstep) {
				Cursegp = &gameData.segs.segments[gameData.objs.console->nSegment];
				med_create_new_segment_from_cursegp();
				UpdateFlags |= UF_ED_STATE_CHANGED;
			}
		}

		// DO TEXTURE STUFF
		texpage_do();
		objpage_do();


		// Process selection of Cursegp using mouse.
		if (LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && !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 tSegment to found list
			if (gameStates.input.keys.pressed[ KEY_LSHIFT ] || gameStates.input.keys.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,&gameData.objs.console->position.vPos);
				Cursegp = &gameData.segs.segments[Found_segs[0]];
				med_create_new_segment_from_cursegp();
				if (LockView_to_cursegp)
					setView_target_from_segment(Cursegp);
			}

			UpdateFlags |= UF_ED_STATE_CHANGED | UF_VIEWPOINT_MOVED;
		}

		if (GameViewBox->mouse_onme && GameViewBox->b1_dragging) {
			int	x, y;
			x = GameViewBox->b1_drag_x2;
			y = GameViewBox->b1_drag_y2;

			ui_mouse_hide();
			GrSetCurrentCanvas( GameViewBox->canvas );
			GrSetColor( 15 );
			GrRect( x-1, y-1, x+1, y+1 );
			ui_mouse_show();

		}
	
		// Set current tSegment and tSide by clicking on a polygon in game window.
		//	If ctrl pressed, also assign current texture map to that tSide.
		//if (GameViewBox->mouse_onme && (GameViewBox->b1_done_dragging || GameViewBox->b1_clicked)) {
		if ((GameViewBox->mouse_onme && GameViewBox->b1_clicked && !render_3d_in_big_window) ||
			(LargeViewBox->mouse_onme && LargeViewBox->b1_clicked && render_3d_in_big_window)) {

			int	xcrd,ycrd;
			int seg,tSide,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 (FindSegSideFace(xcrd,ycrd,&seg,&tSide,&face,&poly)) {


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

					CurObject_index = -seg-1;
					editor_status("Object %d selected.",CurObject_index);

					UpdateFlags |= UF_ED_STATE_CHANGED;
				}
				else {

					//	See if either shift key is down and, if so, assign texture map
					if (gameStates.input.keys.pressed[KEY_LSHIFT] || gameStates.input.keys.pressed[KEY_RSHIFT]) {
						Cursegp = &gameData.segs.segments[seg];
						Curside = tSide;
						AssignTexture();
						med_create_new_segment_from_cursegp();
						editor_status("Texture assigned");
					} else if (gameStates.input.keys.pressed[KEY_G])	{
						tmap = gameData.segs.segments[seg].sides[tSide].nBaseTex;
						texpage_grab_current(tmap);
						editor_status( "Texture grabbed." );
					} else if (gameStates.input.keys.pressed[ KEY_LAPOSTRO] ) {
						ui_mouse_hide();
						moveObject_to_mouse_click();
					} else {
						Cursegp = &gameData.segs.segments[seg];
						Curside = tSide;
						med_create_new_segment_from_cursegp();
						editor_status("Curseg and curside selected");
					}
				}

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

		}

		// Allow specification of LargeView using mouse
		if (gameStates.input.keys.pressed[ KEY_LCTRL ] || gameStates.input.keys.pressed[ KEY_RCTRL ]) {
			ui_mouse_hide();
			if ( (Mouse.dx!=0) && (Mouse.dy!=0) ) {
				GetMouseRotation( Mouse.dx, Mouse.dy, &MouseRotMat );
				VmMatMul(&tempm,&LargeView.ev_matrix,&MouseRotMat);
				LargeView.ev_matrix = tempm;
				LargeView.ev_changed = 1;
				LargeView_index = -1;			// say not one of the orthogonal views
			}
		} else  {
			ui_mouse_show();
		}

		if ( gameStates.input.keys.pressed[ KEY_Z ] ) {
			ui_mouse_hide();
			if ( Mouse.dy!=0 ) {
				currentView->evDist += Mouse.dy*10000;
				currentView->ev_changed = 1;
			}
		} else {
			ui_mouse_show();
		}

	}

//	_MARK_("end of editor");//Nuked to compile -KRB

	ClearWarnFunc(med_show_warning);

	//kill our camera tObject

	gameData.objs.viewer = gameData.objs.console;					//reset viewer
	//@@ReleaseObject(camera_objnum);

	padnum = ui_pad_get_current();

	close_editor();
	ui_close();


}
Exemplo n.º 15
0
void draw_world(grs_canvas *screen_canvas,editor_view *v,segment *mine_ptr,int depth)
{
	vms_vector viewer_position;

#if DOUBLE_BUFFER
	grs_canvas temp_canvas;

//	mprintf(0, "\n");

//	if ( screen_canvas == LargeViewBox->canvas ) {
//		CurrentBigCanvas ^= 1;
//
//		gr_set_current_canvas( BigCanvas[CurrentBigCanvas] );
//
//	} else {
		gr_init_sub_canvas(&temp_canvas,canv_offscreen,0,0,
			screen_canvas->cv_bitmap.bm_w,screen_canvas->cv_bitmap.bm_h);

		gr_set_current_canvas(&temp_canvas);
//	}
#else
	gr_set_current_canvas(screen_canvas);
#endif

	//mprintf(0, "\n");

	ui_mouse_hide();

	//g3_set_points(Segment_points,Vertices);

	viewer_position = v->ev_matrix.fvec;
	vm_vec_scale(&viewer_position,-v->ev_dist);

	vm_vec_add2(&viewer_position,&Ed_view_target);

	gr_clear_canvas(0);
	g3_start_frame();
	g3_set_view_matrix(&viewer_position,&v->ev_matrix,v->ev_zoom);

	render_start_frame();

	gr_setcolor(PLAINSEG_COLOR);

	// Draw all segments or only connected segments.
	// We might want to draw all segments if we have broken the mine into pieces.
	if (Draw_all_segments)
		draw_mine_all(Segments, Automap_test);
	else
		draw_mine(mine_ptr,depth);

	// Draw the found segments
	if (!Automap_test) {
		draw_warning_segments();
		draw_group_segments();
		draw_found_segments();
		draw_selected_segments();
		draw_special_segments();

		// Highlight group segment and side.
		if (current_group > -1)
		if (Groupsegp[current_group]) {
			gr_setcolor(GROUPSEG_COLOR);
			draw_segment(Groupsegp[current_group]);

			gr_setcolor(GROUPSIDE_COLOR);
			draw_seg_side(Groupsegp[current_group],Groupside[current_group]);
		}

		// Highlight marked segment and side.
		if (Markedsegp) {
			gr_setcolor(MARKEDSEG_COLOR);
			draw_segment(Markedsegp);

			gr_setcolor(MARKEDSIDE_COLOR);
			draw_seg_side(Markedsegp,Markedside);
		}

		// Highlight current segment and current side.
		gr_setcolor(CURSEG_COLOR);
		draw_segment(Cursegp);

		gr_setcolor(CURSIDE_COLOR);
		draw_seg_side(Cursegp,Curside);

		gr_setcolor(CUREDGE_COLOR);
		draw_side_edge(Cursegp,Curside,Curedge);

		// Draw coordinate axes if we are rendering the large view.
		if (Show_axes_flag)
			if (screen_canvas == LargeViewBox->canvas)
				draw_coordinate_axes();

		// Label the window
		gr_set_fontcolor((v==current_view)?CRED:CWHITE, -1 );
		if ( screen_canvas == LargeViewBox->canvas ) {
			gr_ustring( 5, 5, "USER VIEW" );
			switch (Large_view_index) {
				case 0: gr_ustring( 85, 5, "-- TOP");	break;
				case 1: gr_ustring( 85, 5, "-- FRONT");	break;
				case 2: gr_ustring( 85, 5, "-- RIGHT");	break;
			}			
		} else
#if ORTHO_VIEWS
		 else if ( screen_canvas == TopViewBox->canvas )
			gr_ustring( 5, 5, "TOP" );
		else if ( screen_canvas == FrontViewBox->canvas )
			gr_ustring( 5, 5, "FRONT" );
		else if ( screen_canvas == RightViewBox->canvas )
			gr_ustring( 5, 5, "RIGHT" );
#else
			Error("Ortho views have been removed, what gives?\n");
#endif

	}
Exemplo n.º 16
0
Arquivo: listbox.c Projeto: btb/d2x
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();

}
Exemplo n.º 17
0
UI_WINDOW * ui_open_window( short x, short y, short w, short h, int flags )
{
	UI_WINDOW * wnd;
	int sw, sh, req_w, req_h;

	wnd = (UI_WINDOW *)d_malloc(sizeof(UI_WINDOW));
	if (wnd==NULL) Error("Could not create window: Out of memory");

	W_NEXT = NULL;
	W_PREV = NULL;

	add_window_to_end( wnd );

	sw = grd_curscreen->sc_w;
	sh = grd_curscreen->sc_h;

// 	mouse_set_limits( 0,0, sw-1, sh-1 );

	req_w = w;
	req_h = h;

	if (flags & WIN_BORDER)
	{
		x -= BORDER_WIDTH;
		y -= BORDER_WIDTH;
		w += 2*BORDER_WIDTH;
		h += 2*BORDER_WIDTH;
	}

	if ( x < 0 ) x = 0;
	if ( (x+w-1) >= sw ) x = sw - w;
	if ( y < 0 ) y = 0;
	if ( (y+h-1) >= sh ) y = sh - h;

	W_X = x;
	W_Y = y;
	W_WIDTH = w;
	W_HEIGHT = h;
	W_OLDCANVAS = grd_curcanv;
	W_GADGET = NULL;
	wnd->keyboard_focus_gadget = NULL;

	ui_mouse_hide();

	if (flags & WIN_SAVE_BG)
	{
		W_BACKGROUND = gr_create_bitmap( w, h );
		gr_bm_ubitblt(w, h, 0, 0, x, y, &(grd_curscreen->sc_canvas.cv_bitmap), W_BACKGROUND );
	}
	else
		W_BACKGROUND = NULL;

	if (flags & WIN_BORDER)
	{
		W_CANVAS = gr_create_sub_canvas( &(grd_curscreen->sc_canvas), x+BORDER_WIDTH, y+BORDER_WIDTH, req_w, req_h );
		gr_set_current_canvas( NULL );
		ui_draw_frame( x, y, x+w-1, y+h-1 );
	}
	else
		W_CANVAS = gr_create_sub_canvas( &(grd_curscreen->sc_canvas), x, y, req_w, req_h );

	gr_set_current_canvas( W_CANVAS );

	if (flags & WIN_FILLED)
		ui_draw_box_out( 0, 0, req_w-1, req_h-1 );

	gr_set_fontcolor( CBLACK, CWHITE );

	selected_gadget = NULL;

	W_TEXT_X = 0;
	W_TEXT_Y = 0;

	return wnd;

}
Exemplo n.º 18
0
Arquivo: file.c Projeto: btb/d2x
int ui_get_filename( char * filename, char * Filespec, char * message  )
{
	char		ViewDir[PATH_MAX];
	char		InputText[PATH_MAX];
	char		*p;
	PHYSFS_file	*TempFile;
	int			NumFiles, NumDirs,i;
	char		**filename_list;
	char		**directory_list;
	char		Spaces[35];
	UI_WINDOW			*wnd;
	UI_GADGET_BUTTON	*Button1, *Button2, *HelpButton;
	UI_GADGET_LISTBOX	*ListBox1;
	UI_GADGET_LISTBOX	*ListBox2;
	UI_GADGET_INPUTBOX	*UserFile;
	int 				new_listboxes;

	if ((p = strrchr(filename, '/')))
	{
		*p++ = 0;
		strcpy(ViewDir, filename);
		strcpy(InputText, p);
	}
	else
	{
		strcpy(ViewDir, "");
		strcpy(InputText, filename);
	}

	filename_list = file_getfilelist(&NumFiles, Filespec, ViewDir);
	directory_list = file_getdirlist(&NumDirs, ViewDir);

	// Running out of memory may become likely in the future
	if (!filename_list && !directory_list)
		return 0;

	if (!filename_list)
	{
		PHYSFS_freeList(directory_list);
		return 0;
	}

	if (!directory_list)
	{
		PHYSFS_freeList(filename_list);
		return 0;
	}

	//ui_messagebox( -2,-2, 1,"DEBUG:0", "Ok" );
	for (i=0; i<35; i++)
		Spaces[i] = ' ';
	Spaces[34] = 0;

	wnd = ui_open_window( 200, 100, 400, 370, WIN_DIALOG );

	ui_wprintf_at( wnd, 10, 5, message );

	ui_wprintf_at( wnd, 20, 32,"N&ame" );
	UserFile  = ui_add_gadget_inputbox( wnd, 60, 30, PATH_MAX, 40, InputText );

	ui_wprintf_at( wnd, 20, 86,"&Files" );
	ui_wprintf_at( wnd, 210, 86,"&Dirs" );

	ListBox1 = ui_add_gadget_listbox(wnd,  20, 110, 125, 200, NumFiles, filename_list);
	ListBox2 = ui_add_gadget_listbox(wnd, 210, 110, 100, 200, NumDirs, directory_list);

	Button1 = ui_add_gadget_button( wnd,     20, 330, 60, 25, "Ok", NULL );
	Button2 = ui_add_gadget_button( wnd,    100, 330, 60, 25, "Cancel", NULL );
	HelpButton = ui_add_gadget_button( wnd, 180, 330, 60, 25, "Help", NULL );

	wnd->keyboard_focus_gadget = (UI_GADGET *)UserFile;

	Button1->hotkey = KEY_CTRLED + KEY_ENTER;
	Button2->hotkey = KEY_ESC;
	HelpButton->hotkey = KEY_F1;
	ListBox1->hotkey = KEY_ALTED + KEY_F;
	ListBox2->hotkey = KEY_ALTED + KEY_D;
	UserFile->hotkey = KEY_ALTED + KEY_A;

	ui_gadget_calc_keys(wnd);

	ui_wprintf_at( wnd, 20, 60, "%s", Spaces );
	ui_wprintf_at( wnd, 20, 60, "%s", ViewDir );

	new_listboxes = 0;

	while( 1 )
	{
		ui_mega_process();
		ui_window_do_gadgets(wnd);

		if ( Button2->pressed )
		{
			PHYSFS_freeList(filename_list);
			PHYSFS_freeList(directory_list);
			ui_close_window(wnd);
			return 0;
		}

		if ( HelpButton->pressed )
			ui_messagebox( -1, -1, 1, "Sorry, no help is available!", "Ok" );

		if (ListBox1->moved || new_listboxes)
		{
			if (ListBox1->current_item >= 0 )
				ui_inputbox_set_text(UserFile, filename_list[ListBox1->current_item]);
		}

		if (ListBox2->moved || new_listboxes)
		{
			if (ListBox2->current_item >= 0 )
				ui_inputbox_set_text(UserFile, directory_list[ListBox2->current_item]);
		}
		new_listboxes = 0;

		if (Button1->pressed || UserFile->pressed || (ListBox1->selected_item > -1 ) || (ListBox2->selected_item > -1 ))
		{
			ui_mouse_hide();

			if (ListBox2->selected_item > -1 )
				strcpy(UserFile->text, directory_list[ListBox2->selected_item]);

			strncpy(filename, ViewDir, PATH_MAX);

			p = UserFile->text;
			while (!strncmp(p, "..", 2))	// shorten the path manually
			{
				char *sep = strrchr(filename, '/');
				if (sep)
					*sep = 0;
				else
					*filename = 0;	// look directly in search paths

				p += 2;
				if (*p == '/')
					p++;
			}

			if (*filename && *p)
				strncat(filename, "/", PATH_MAX - strlen(filename));
			strncat(filename, p, PATH_MAX - strlen(filename));

			if (!PHYSFS_isDirectory(filename))
			{
				TempFile = PHYSFS_openRead(filename);
				if (TempFile)
				{
					// Looks like a valid filename that already exists!
					PHYSFS_close(TempFile);
					break;
				}
	
				// File doesn't exist, but can we create it?
				TempFile = PHYSFS_openWrite(filename);
				if (TempFile)
				{
					// Looks like a valid filename!
					PHYSFS_close(TempFile);
					PHYSFS_delete(filename);
					break;
				}
			}
			else
			{
				if (filename[strlen(filename) - 1] == '/')	// user typed a separator on the end
					filename[strlen(filename) - 1] = 0;
	
				strcpy(ViewDir, filename);
	
				//mprintf( 0, "----------------------------\n" );
				//mprintf( 0, "Full dir: '%s'\n", ViewDir );
	
				PHYSFS_freeList(filename_list);
				filename_list = file_getfilelist(&NumFiles, Filespec, ViewDir);
				if (!filename_list)
				{
					PHYSFS_freeList(directory_list);
					return 0;
				}

				ui_inputbox_set_text(UserFile, Filespec);

				PHYSFS_freeList(directory_list);
				directory_list = file_getdirlist(&NumDirs, ViewDir);
				if (!directory_list)
				{
					PHYSFS_freeList(filename_list);
					return 0;
				}

				ui_listbox_change(wnd, ListBox1, NumFiles, filename_list);
				ui_listbox_change(wnd, ListBox2, NumDirs, directory_list);
				new_listboxes = 0;

				ui_wprintf_at( wnd, 20, 60, "%s", Spaces );
				ui_wprintf_at( wnd, 20, 60, "%s", ViewDir );

				//i = TICKER;
				//while ( TICKER < i+2 );

			}

			ui_mouse_show();

		}

		vid_update();
	}

	//key_flush();

	ui_close_window(wnd);
	if (filename_list)
		PHYSFS_freeList(filename_list);
	if (directory_list)
		PHYSFS_freeList(directory_list);

	return 1;
}