X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=307350325c759bfecd14640cc8027f120e3ca1f6;hb=e5367ee42312c8835125438511d8479aa2daa094;hp=f176e13e37537924810553446e64f5d0609bf9ac;hpb=80aa0e4b2b060112407417a9d2896395023a21cc;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index f176e13e..30735032 100644 --- a/src/init.c +++ b/src/init.c @@ -5313,6 +5313,7 @@ void Execute_Command(char *command) #if DEBUG #if defined(TARGET_SDL) +#if !defined(TARGET_SDL2) else if (strEqual(command, "SDL_ListModes")) { SDL_Rect **modes; @@ -5347,6 +5348,7 @@ void Execute_Command(char *command) exit(0); } #endif +#endif #endif else @@ -5642,6 +5644,91 @@ void InitGfx() font_height = getFontHeight(FC_RED); + + + + + + + + +#if 0 + Delay(1000); + +#if 0 + Bitmap new_bitmap; + printf("::: MARK 1.1\n"); + new_bitmap.surface = SDL_LoadBMP("TEST.bmp"); + printf("::: MARK 1.2\n"); +#endif + + char *filename = getCustomImageFilename("RocksFontSmall.pcx"); + + printf("::: FILENAME == '%s'\n", filename); + +#if 1 + Bitmap *new_bitmap = LoadImage(filename); +#else +#if 1 + Bitmap *new_bitmap = CreateBitmapStruct(); + SDL_Surface *sdl_image_tmp; + sdl_image_tmp = IMG_Load(filename); + new_bitmap->surface = SDL_DisplayFormat(sdl_image_tmp); + +#else + SDL_Surface *sdl_image_tmp = IMG_Load(filename); + SDL_Surface *sdl_image = SDL_DisplayFormat(sdl_image_tmp); +#endif +#endif + + // SDL_Surface *image = SDL_LoadBMP("TEST.bmp"); + // SDL_LoadBMP("TEST.bmp"); + + // bitmap_font_initial->surface = SDL_LoadBMP("TEST.bmp"); + +#if 0 + printf("::: MARK 1 [%08x, %08xd]\n", + (unsigned int)bitmap_font_initial->surface, + (unsigned int)backbuffer->surface); +#endif + + // SDL_BlitSurface(image, NULL, backbuffer->surface, NULL); + // SDL_BlitSurface(new_bitmap.surface, NULL,backbuffer->surface, NULL); + SDL_BlitSurface(new_bitmap->surface, NULL,backbuffer->surface, NULL); + // SDL_BlitSurface(sdl_image, NULL,backbuffer->surface, NULL); + // SDL_BlitSurface(bitmap_font_initial->surface, NULL,backbuffer->surface, NULL); + +#if 0 + printf("::: MARK 1 [%08x, %08xd, %08xd]\n", + (unsigned int)bitmap_font_initial->surface, + (unsigned int)backbuffer->surface, + (unsigned int)image); +#endif + + extern SDL_Window *sdl_window; + SDL_UpdateWindowSurface(sdl_window); + +#if 1 +#if 0 + SDL_BlitSurface(bitmap_font_initial->surface, NULL,backbuffer->surface, NULL); +#endif + // SDL_UpdateWindowSurface(sdl_window); + + Delay(1000); + exit(0); +#endif +#endif + + + + + + + + + + + #if 1 DrawInitText(getWindowTitleString(), 20, FC_YELLOW); #else @@ -6274,6 +6361,59 @@ void KeyboardAutoRepeatOffUnlessAutoplay() KeyboardAutoRepeatOff(); } +void DisplayExitMessage(char *format, va_list ap) +{ + int font_1 = FC_RED; + int font_2 = FC_YELLOW; + int font_3 = FC_BLUE; + int font_width = getFontWidth(font_2); + int font_height = getFontHeight(font_2); + int sx = SX; + int sy = SY; + int sxsize = WIN_XSIZE - 2 * sx; + int sysize = WIN_YSIZE - 2 * sy; + int line_length = sxsize / font_width; + int max_lines = sysize / font_height; + int num_lines_printed; + + gfx.sx = sx; + gfx.sy = sy; + gfx.sxsize = sxsize; + gfx.sysize = sysize; + + sy = 20; + + ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); + + DrawTextSCentered(sy, font_1, "Fatal error:"); + sy += 3 * font_height;; + + num_lines_printed = + DrawTextBufferVA(sx, sy, format, ap, font_2, + line_length, line_length, max_lines, + 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); + sy += (num_lines_printed + 3) * font_height; + + DrawTextSCentered(sy, font_1, "For details, see the following error file:"); + sy += 3 * font_height; + + num_lines_printed = + DrawTextBuffer(sx, sy, program.error_filename, font_2, + line_length, line_length, max_lines, + 0, BLIT_ON_BACKGROUND, TRUE, TRUE, FALSE); + + DrawTextSCentered(SYSIZE - 20, font_3, "Press any key or button to exit"); + + redraw_mask = REDRAW_ALL; + + BackToFront(); + + /* deactivate toons on error message screen */ + setup.toons = FALSE; + + WaitForEventToContinue(); +} + /* ========================================================================= */ /* OpenAll() */ @@ -6336,7 +6476,7 @@ void OpenAll() InitVideoDisplay(); InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen); - InitEventFilter(FilterMouseMotionEvents); + InitEventFilter(FilterEvents); print_timestamp_time("[init video stuff]"); @@ -6432,15 +6572,28 @@ void CloseAllAndExit(int exit_value) FreeAllImages(); #if defined(TARGET_SDL) +#if defined(TARGET_SDL2) + // !!! TODO !!! + // set a flag to tell the network server thread to quit and wait for it + // using SDL_WaitThread() +#else if (network_server) /* terminate network server */ SDL_KillThread(server_thread); +#endif #endif CloseVideoDisplay(); ClosePlatformDependentStuff(); if (exit_value != 0) - NotifyUserAboutErrorFile(); + { + /* fall back to default level set (current set may have caused an error) */ + SaveLevelSetup_LastSeries_Deactivate(); + + /* tell user where to find error log file which may contain more details */ + // (error notification now directly displayed on screen inside R'n'D + // NotifyUserAboutErrorFile(); /* currently only works for Windows */ + } exit(exit_value); }