コード例 #1
0
static void display_win32_alert(const char *message, int error)
{
	window	*wind;

	// Handle Descent's windows properly
	if ((wind = window_get_front()))
	{
		const d_event event{EVENT_WINDOW_DEACTIVATED};
		WINDOW_SEND_EVENT(wind);
	}

	int fullscreen = (grd_curscreen && gr_check_fullscreen());
	if (fullscreen)
		gr_toggle_fullscreen();

	MessageBox(NULL, message, error?"Sorry, a critical error has occurred.":"Attention!", error?MB_OK|MB_ICONERROR:MB_OK|MB_ICONWARNING);

	if ((wind = window_get_front()))
	{
		const d_event event{EVENT_WINDOW_ACTIVATED};
		WINDOW_SEND_EVENT(wind);
	}
	
	if (!error && fullscreen)
		gr_toggle_fullscreen();
}
コード例 #2
0
ファイル: menu.c プロジェクト: Ringdingcoder/d1x
void change_res()
{
 //edited 05/27/99 Matt Mueller - ingame fullscreen changing
 newmenu_item m[11];
 u_int32_t modes[11];
 int i=0, mc=0, num_presets=0;
 char customres[16];
#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
 int fullscreenc;
#endif
 //end edit -MM
 u_int32_t screen_mode = 0;
 int screen_width = 0;
 int screen_height = 0;
 int vr_mode = VR_NONE;
 int screen_compatible = 0;
 int use_double_buffer = 0;
 
//changed 6/15/1999 by Owen Evans to fix some platform-related problems
#ifdef __MSDOS__
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x100"; m[mc].value=(Game_screen_mode==SM(320,100)); m[mc].group=0; modes[mc] = SM(320,100); mc++;
#endif
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value=(Game_screen_mode==SM(320,200)); m[mc].group=0; modes[mc] = SM(320,200); mc++;
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x240"; m[mc].value=(Game_screen_mode==SM(320,240)); m[mc].group=0; modes[mc] = SM(320,240); mc++;
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x400"; m[mc].value=(Game_screen_mode==SM(320,400)); m[mc].group=0; modes[mc] = SM(320,400); mc++;
//#ifndef __LINUX__ - heh?  640x400 is perfectly fine on linux
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x400"; m[mc].value=(Game_screen_mode==SM(640,400)); m[mc].group=0; modes[mc] = SM(640,400); mc++;
//#endif
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value=(Game_screen_mode==SM(640,480)); m[mc].group=0; modes[mc] = SM(640,480); mc++;
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value=(Game_screen_mode==SM(800,600)); m[mc].group=0; modes[mc] = SM(800,600); mc++;
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value=(Game_screen_mode==SM(1024,768)); m[mc].group=0; modes[mc] = SM(1024,768); mc++;
//end section - OE
 num_presets = mc;
 for (i=0; i<mc; i++)
	 if (m[mc].value)
		 break;
 m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value=(i==mc); m[mc].group=0; modes[mc] = 0; mc++;
 sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode));
 m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len=11; modes[mc] = 0; mc++;

// m[mc].type = NM_TYPE_CHECK; m[mc].text = "No Doublebuffer"; m[mc].value = use_double_buffer;

 //added 05/27/99 Matt Mueller - ingame fullscreen changing
#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
 fullscreenc=mc;m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen();mc++;
#endif
 //end addition -MM


   i=newmenu_do1( NULL, "Screen Resolution", mc, m, &change_res_poll, 0);

  //added 05/27/99 Matt Mueller - ingame fullscreen changing
#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
   if (m[fullscreenc].value != gr_check_fullscreen()){
	   gr_toggle_fullscreen();
        Game_screen_mode = -1;
   }
#endif
  //end addition -MM
   
  for(i=0;(m[i].value==0)&&(i<num_presets);i++);
  if (modes[i]==0){
	  char *h=strchr(customres, 'x');
	  if (!h) 
		  return;
	  screen_mode = SM(atoi(customres), atoi(h+1));
  }else{
	  screen_mode = modes[i];
  }

  screen_width = SM_W(screen_mode);
  screen_height = SM_H(screen_mode);
  if (screen_height<=0 || screen_width<=0)
	  return;

  switch(screen_mode)
   {
    case SM(320,100)://19:
           screen_compatible = 0;
           use_double_buffer = 0;
           break;
	case SM(320,200)://SM_320x200C:
           screen_compatible = 1;
           use_double_buffer = 0;
           break;
	default:
           screen_compatible = 0;
           use_double_buffer = 1;
           break;
   }
#ifdef __MSDOS__
  if ( FindArg( "-nodoublebuffer" ) )
#endif
   use_double_buffer = 0;

//added 6/15/1999 by Owen Evans to eliminate unneccesary mode modification
	if (Game_screen_mode == screen_mode)
		return;
//      gr_set_mode(Game_screen_mode);
//end section - OE

        VR_offscreen_buffer = 0;        //Disable VR (so that VR_Screen_mode doesnt mess us up
        Game_screen_mode = screen_mode;
        Game_window_w=screen_width;
        Game_window_h=screen_height;
        game_init_render_buffers(screen_mode, screen_width, screen_height, use_double_buffer, vr_mode, screen_compatible);
        

        mprintf( (0, "\nInitializing palette system..." ));
        gr_use_palette_table( "PALETTE.256" );
        mprintf( (0, "\nInitializing font system..." ));
        gamefont_init();        // must load after palette data loaded.


  reset_palette_add();
  init_cockpit();
  last_drawn_cockpit[0]=-1;
  last_drawn_cockpit[1]=-1;
//  init_gauges();

   vr_reset_display();
}
コード例 #3
0
// Default event handler for everything except the editor
window_event_result standard_handler(const d_event &event)
{
	int key;

	if (Quitting)
	{
		window *wind = window_get_front();
		if (!wind)
			return window_event_result::ignored;	// finished quitting
	
		if (wind == Game_wind)
		{
			int choice;
			Quitting = 0;
			choice=nm_messagebox( NULL, 2, TXT_YES, TXT_NO, TXT_ABORT_GAME );
			if (choice != 0)
				return window_event_result::handled;	// aborted quitting
			else
			{
				CGameArg.SysAutoDemo = false;
				Quitting = 1;
			}
		}
		
		// Close front window, let the code flow continue until all windows closed or quit cancelled
		if (!window_close(wind))
		{
			Quitting = 0;
			return window_event_result::handled;
		}
		
		return window_event_result::deleted;	// tell the event system we deleted some window
	}

	switch (event.type)
	{
		case EVENT_MOUSE_BUTTON_DOWN:
		case EVENT_MOUSE_BUTTON_UP:
			// No window selecting
			// We stay with the current one until it's closed/hidden or another one is made
			// Not the case for the editor
			break;

		case EVENT_KEY_COMMAND:
			key = event_key_get(event);

			switch (key)
			{
#ifdef macintosh
				case KEY_COMMAND + KEY_SHIFTED + KEY_3:
#endif
				case KEY_PRINT_SCREEN:
				{
					gr_set_current_canvas(NULL);
					save_screen_shot(0);
					return window_event_result::handled;
				}

				case KEY_ALTED+KEY_ENTER:
				case KEY_ALTED+KEY_PADENTER:
					if (Game_wind)
						if (Game_wind == window_get_front())
							return window_event_result::ignored;
					gr_toggle_fullscreen();
					return window_event_result::handled;

#if defined(__APPLE__) || defined(macintosh)
				case KEY_COMMAND+KEY_Q:
					// Alt-F4 already taken, too bad
					Quitting = 1;
					return window_event_result::handled;
#endif
				case KEY_SHIFTED + KEY_ESC:
					con_showup();
					return window_event_result::handled;
			}
			break;

		case EVENT_WINDOW_DRAW:
		case EVENT_IDLE:
			//see if redbook song needs to be restarted
			RBACheckFinishedHook();
			return window_event_result::handled;

		case EVENT_QUIT:
#if DXX_USE_EDITOR
			if (SafetyCheck())
#endif
				Quitting = 1;
			return window_event_result::handled;

		default:
			break;
	}

	return window_event_result::ignored;
}
コード例 #4
0
ファイル: messagebox.c プロジェクト: CDarrow/DXX-Retro
void display_mac_alert(char *message, int error)
{
	window	*wind;
	d_event	event;
	int		fullscreen;
	bool	osX = FALSE;
	uint 	response;
	int16_t itemHit;

	// Handle Descent's windows properly
	if ((wind = window_get_front()))
		WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED);

	if (grd_curscreen && (fullscreen = gr_check_fullscreen()))
		gr_toggle_fullscreen();
	
	osX = ( Gestalt(gestaltSystemVersion, (long *) &response) == noErr)
		&& (response >= 0x01000 );

    ShowCursor();

	if (osX)
	{
#ifdef TARGET_API_MAC_CARBON
		DialogRef	alert;
		CFStringRef	error_text = CFSTR("Sorry, a critical error has occurred.");
		CFStringRef	text = NULL;

		text = CFStringCreateWithCString(CFAllocatorGetDefault(), message, kCFStringEncodingMacRoman);
		if (!text)
		{
			if (wind) WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
			return;
		}

		if (CreateStandardAlert(error ? kAlertStopAlert : kAlertNoteAlert, error ? error_text : text, error ? text : NULL, 0, &alert) != noErr)
		{
			CFRelease(text);
			if (wind) WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
			return;
		}
		
		RunStandardAlert(alert, 0, &itemHit);
		CFRelease(text);
#endif
	}
	else
	{
		// This #if guard removes both compiler warnings
		// and complications if we didn't link the (older) Mac OS X SDK that actually supports the following.
#if !defined(MAC_OS_X_VERSION_MAX_ALLOWED) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4)
		Str255 	error_text = "\pSorry, a critical error has occurred.";
		Str255 	text;
		
		CopyCStringToPascal(message, text);
		StandardAlert(error ? kAlertStopAlert : kAlertNoteAlert, error ? error_text : text, error ? text : NULL, 0, &itemHit);
#endif
	}

	if ((wind = window_get_front()))
		WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
	
	if (grd_curscreen && !error && fullscreen)
		gr_toggle_fullscreen();
}
コード例 #5
0
ファイル: gr.c プロジェクト: gameplayer22/d1x
int gr_init(int mode)
{
    int retcode,t,glt=0;
    // Only do this function once!
    if (gr_installed==1)
        return -1;


#ifdef OGL_RUNTIME_LOAD
    ogl_init_load_library();
#endif

#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
    if (FindArg("-gl_voodoo")) {
        ogl_voodoohack=1;
        gr_toggle_fullscreen();
    }
    if (FindArg("-fullscreen"))
        gr_toggle_fullscreen();
#endif
    if ((glt=FindArg("-gl_alttexmerge")))
        ogl_alttexmerge=1;
    if ((t=FindArg("-gl_stdtexmerge")))
        if (t>=glt)//allow overriding of earlier args
            ogl_alttexmerge=0;

    if ((glt=FindArg("-gl_16bittextures")))
        ogl_rgba_format=GL_RGB5_A1;

    if ((glt=FindArg("-gl_mipmap"))) {
        GL_texmagfilt=GL_LINEAR;
        GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST;
    }
    if ((glt=FindArg("-gl_trilinear"))) {
        GL_texmagfilt=GL_LINEAR;
        GL_texminfilt=GL_LINEAR_MIPMAP_LINEAR;
    }
    if ((t=FindArg("-gl_simple"))) {
        if (t>=glt) { //allow overriding of earlier args
            glt=t;
            GL_texmagfilt=GL_NEAREST;
            GL_texminfilt=GL_NEAREST;
        }
    }
    if ((t=FindArg("-gl_texmagfilt")) || (t=FindArg("-gl_texmagfilter"))) {
        if (t>=glt)//allow overriding of earlier args
            GL_texmagfilt=ogl_atotexfilti(Args[t+1],0);
    }
    if ((t=FindArg("-gl_texminfilt")) || (t=FindArg("-gl_texminfilter"))) {
        if (t>=glt)//allow overriding of earlier args
            GL_texminfilt=ogl_atotexfilti(Args[t+1],1);
    }
    GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt);

    if ((t=FindArg("-gl_anisotropy")) || (t=FindArg("-gl_anisotropic"))) {
        GL_texanisofilt=atof(Args[t+1]);
    }

    mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i anisotropic:%f\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps,GL_texanisofilt));


    if ((t=FindArg("-gl_vidmem"))) {
        ogl_mem_target=atoi(Args[t+1])*1024*1024;
    }
    if ((t=FindArg("-gl_reticle"))) {
        gl_reticle=atoi(Args[t+1]);
    }
    //printf("ogl_mem_target=%i\n",ogl_mem_target);

    ogl_init();//platform specific initialization

    ogl_init_texture_list_internal();

    MALLOC( grd_curscreen,grs_screen,1 );
    memset( grd_curscreen, 0, sizeof(grs_screen));
    grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL;

    // Set the mode.
    if ((retcode=gr_set_mode(mode)))
    {
        return retcode;
    }
    grd_curscreen->sc_canvas.cv_color = 0;
    grd_curscreen->sc_canvas.cv_drawmode = 0;
    grd_curscreen->sc_canvas.cv_font = NULL;
    grd_curscreen->sc_canvas.cv_font_fg_color = 0;
    grd_curscreen->sc_canvas.cv_font_bg_color = 0;
    gr_set_current_canvas( &grd_curscreen->sc_canvas );

    gr_installed = 1;

    atexit(gr_close);

    return 0;
}