rnd-20030120-3-src
[rocksndiamonds.git] / src / screens.c
index 67b8bd2326956c5f4cbf86ed837e4fedc436ffb6..09e068a3be0235efdcbf4a8d65e7992a5eff14d6 100644 (file)
@@ -71,7 +71,10 @@ static void HandleChooseTree(int, int, int, int, int, TreeInfo **);
 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
 static int setup_mode = SETUP_MODE_MAIN;
 
+#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
 static Bitmap *scrollbar_bitmap[4];
+#endif
+
 
 static void drawCursorExt(int xpos, int ypos, int color, int graphic)
 {
@@ -132,7 +135,7 @@ static void ToggleFullscreenIfNeeded()
     setup.fullscreen = video.fullscreen_enabled;
 
     /* redraw background to newly created backbuffer */
-    BlitBitmap(new_graphic_info[IMG_MENU_FRAME].bitmap, backbuffer,
+    BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer,
               0,0, WIN_XSIZE,WIN_YSIZE, 0,0);
 
     /* restore old door content */
@@ -151,10 +154,13 @@ void DrawMainMenu()
 
   UnmapAllGadgets();
   FadeSounds();
+
   KeyboardAutoRepeatOn();
   ActivateJoystick();
+
   SetDrawDeactivationMask(REDRAW_NONE);
-  SetBackgroundBitmap(new_graphic_info[IMG_MENU_BACKGROUND].bitmap);
+  SetDrawBackgroundMask(REDRAW_FIELD);
+
   audio.sound_deactivated = FALSE;
 
   /* needed if last screen was the playing screen, invoked from level editor */
@@ -195,10 +201,11 @@ void DrawMainMenu()
   GetPlayerConfig();
   LoadLevel(level_nr);
 
-  SetBackgroundBitmap(new_graphic_info[IMG_MENU_BACKGROUND].bitmap);
+  SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
   ClearWindow();
 
   DrawHeadline();
+
   DrawText(SX + 32,    SY + 2*32, name_text, FS_BIG, FC_GREEN);
   DrawText(SX + 6*32,  SY + 2*32, setup.player_name, FS_BIG, FC_RED);
   DrawText(SX + 32,    SY + 3*32, "Level:", FS_BIG, FC_GREEN);
@@ -1001,6 +1008,7 @@ void DrawHelpScreenElText(int start)
   int xstart = SX + 56, ystart = SY + 65 + 2 * 32, ystep = TILEY + 4;
   int ybottom = SYSIZE - 20;
 
+  SetMainBackgroundImage(IMG_BACKGROUND_INFO);
   ClearWindow();
   DrawHeadline();
 
@@ -1124,6 +1132,7 @@ void DrawHelpScreen()
     helpscreen_step[i] = helpscreen_frame[i] = 0;
   helpscreen_musicpos = 0;
   helpscreen_state = 0;
+
   DrawHelpScreenElText(0);
   DrawHelpScreenElAction(0);
 
@@ -1255,6 +1264,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
   CloseDoor(DOOR_CLOSE_2);
 
   ClearWindow();
+
   HandleChooseTree(0,0, 0,0, MB_MENU_INITIALIZE, ti_ptr);
   MapChooseTreeGadgets(*ti_ptr);
 
@@ -1569,6 +1579,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
 void DrawChooseLevel()
 {
+  SetMainBackgroundImage(IMG_BACKGROUND_LEVEL_SERIES);
+
   DrawChooseTree(&leveldir_current);
 }
 
@@ -1596,7 +1608,9 @@ static void drawHallOfFameList(int first_entry, int highlight_position)
 {
   int i;
 
+  SetMainBackgroundImage(IMG_BACKGROUND_HALL_OF_FAME);
   ClearWindow();
+
   DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
   DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
 
@@ -2001,6 +2015,7 @@ static void DrawSetupScreen_Generic()
 
   UnmapAllGadgets();
   CloseDoor(DOOR_CLOSE_2);
+
   ClearWindow();
 
   if (setup_mode == SETUP_MODE_MAIN)
@@ -2177,6 +2192,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
 void DrawSetupScreen_Input()
 {
   ClearWindow();
+
   DrawText(SX+16, SY+16, "Setup Input", FS_BIG, FC_YELLOW);
 
   initCursor(0, IMG_BALL_BLUE);
@@ -2746,6 +2762,8 @@ void DrawSetupScreen()
 {
   DeactivateJoystick();
 
+  SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
+
   if (setup_mode == SETUP_MODE_INPUT)
     DrawSetupScreen_Input();
   else if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
@@ -2829,10 +2847,10 @@ static struct
 
 static struct
 {
-#if 0
-  int gfx_unpressed, gfx_pressed;
-#else
+#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   Bitmap **gfx_unpressed, **gfx_pressed;
+#else
+  int gfx_unpressed, gfx_pressed;
 #endif
   int x, y;
   int width, height;
@@ -2842,10 +2860,10 @@ static struct
 } scrollbar_info[NUM_SCREEN_SCROLLBARS] =
 {
   {
-#if 0
-    IMG_SCROLLBAR_BLUE, IMG_SCROLLBAR_RED,
-#else
+#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
     &scrollbar_bitmap[0], &scrollbar_bitmap[1],
+#else
+    IMG_SCROLLBAR_BLUE, IMG_SCROLLBAR_RED,
 #endif
     SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS,
     SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE,
@@ -2881,12 +2899,12 @@ static void CreateScreenScrollbuttons()
 
     gfx_unpressed = scrollbutton_info[i].gfx_unpressed;
     gfx_pressed   = scrollbutton_info[i].gfx_pressed;
-    gd_bitmap_unpressed = new_graphic_info[gfx_unpressed].bitmap;
-    gd_bitmap_pressed   = new_graphic_info[gfx_pressed].bitmap;
-    gd_x1 = new_graphic_info[gfx_unpressed].src_x;
-    gd_y1 = new_graphic_info[gfx_unpressed].src_y;
-    gd_x2 = new_graphic_info[gfx_pressed].src_x;
-    gd_y2 = new_graphic_info[gfx_pressed].src_y;
+    gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
+    gd_bitmap_pressed   = graphic_info[gfx_pressed].bitmap;
+    gd_x1 = graphic_info[gfx_unpressed].src_x;
+    gd_y1 = graphic_info[gfx_unpressed].src_y;
+    gd_x2 = graphic_info[gfx_pressed].src_x;
+    gd_y2 = graphic_info[gfx_pressed].src_y;
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
                      GDI_CUSTOM_TYPE_ID, i,
@@ -2917,7 +2935,7 @@ static void CreateScreenScrollbars()
   for (i=0; i<NUM_SCREEN_SCROLLBARS; i++)
   {
     Bitmap *gd_bitmap_unpressed, *gd_bitmap_pressed;
-#if 0
+#if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
     int gfx_unpressed, gfx_pressed;
 #endif
     int gd_x1, gd_x2, gd_y1, gd_y2;
@@ -2933,22 +2951,22 @@ static void CreateScreenScrollbars()
 
     event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS;
 
-#if 0
-    gfx_unpressed = scrollbar_info[i].gfx_unpressed;
-    gfx_pressed   = scrollbar_info[i].gfx_pressed;
-    gd_bitmap_unpressed = new_graphic_info[gfx_unpressed].bitmap;
-    gd_bitmap_pressed   = new_graphic_info[gfx_pressed].bitmap;
-    gd_x1 = new_graphic_info[gfx_unpressed].src_x;
-    gd_y1 = new_graphic_info[gfx_unpressed].src_y;
-    gd_x2 = new_graphic_info[gfx_pressed].src_x;
-    gd_y2 = new_graphic_info[gfx_pressed].src_y;
-#else
+#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
     gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed;
     gd_bitmap_pressed   = *scrollbar_info[i].gfx_pressed;
     gd_x1 = 0;
     gd_y1 = 0;
     gd_x2 = 0;
     gd_y2 = 0;
+#else
+    gfx_unpressed = scrollbar_info[i].gfx_unpressed;
+    gfx_pressed   = scrollbar_info[i].gfx_pressed;
+    gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap;
+    gd_bitmap_pressed   = graphic_info[gfx_pressed].bitmap;
+    gd_x1 = graphic_info[gfx_unpressed].src_x;
+    gd_y1 = graphic_info[gfx_unpressed].src_y;
+    gd_x2 = graphic_info[gfx_pressed].src_x;
+    gd_y2 = graphic_info[gfx_pressed].src_y;
 #endif
 
     gi = CreateGadget(GDI_CUSTOM_ID, id,
@@ -2979,39 +2997,26 @@ static void CreateScreenScrollbars()
 
 void CreateScreenGadgets()
 {
+#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   int i;
 
   for (i=0; i<4; i++)
   {
     scrollbar_bitmap[i] = CreateBitmap(TILEX, TILEY, DEFAULT_DEPTH);
 
-#if defined(TARGET_X11_NATIVE)
     /* copy pointers to clip mask and GC */
     scrollbar_bitmap[i]->clip_mask =
-      new_graphic_info[IMG_SCROLLBAR_BLUE + i].clip_mask;
+      graphic_info[IMG_SCROLLBAR_BLUE + i].clip_mask;
     scrollbar_bitmap[i]->stored_clip_gc =
-      new_graphic_info[IMG_SCROLLBAR_BLUE + i].clip_gc;
-#endif
+      graphic_info[IMG_SCROLLBAR_BLUE + i].clip_gc;
 
-    BlitBitmap(new_graphic_info[IMG_SCROLLBAR_BLUE + i].bitmap,
+    BlitBitmap(graphic_info[IMG_SCROLLBAR_BLUE + i].bitmap,
               scrollbar_bitmap[i],
-              new_graphic_info[IMG_SCROLLBAR_BLUE + i].src_x,
-              new_graphic_info[IMG_SCROLLBAR_BLUE + i].src_y,
+              graphic_info[IMG_SCROLLBAR_BLUE + i].src_x,
+              graphic_info[IMG_SCROLLBAR_BLUE + i].src_y,
               TILEX, TILEY, 0, 0);
-
-#ifdef TARGET_SDL
-    SDL_SetColorKey(scrollbar_bitmap[i]->surface, SDL_SRCCOLORKEY,
-                   SDL_MapRGB(scrollbar_bitmap[i]->surface->format,
-                              0x00, 0x00, 0x00));
-    if ((scrollbar_bitmap[i]->surface_masked =
-        SDL_DisplayFormat(scrollbar_bitmap[i]->surface)) == NULL)
-    {
-      SetError("SDL_DisplayFormat(): %s", SDL_GetError());
-      Error(ERR_EXIT, "CreateScreenGadgets() failed: %s", GetError());
-    }
-    SDL_SetColorKey(scrollbar_bitmap[i]->surface, 0, 0);
-#endif
   }
+#endif
 
   CreateScreenScrollbuttons();
   CreateScreenScrollbars();
@@ -3021,16 +3026,16 @@ void FreeScreenGadgets()
 {
   int i;
 
+#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
   for (i=0; i<4; i++)
   {
-#if defined(TARGET_X11_NATIVE)
     /* prevent freeing clip mask and GC twice */
     scrollbar_bitmap[i]->clip_mask = None;
     scrollbar_bitmap[i]->stored_clip_gc = None;
-#endif
 
     FreeBitmap(scrollbar_bitmap[i]);
   }
+#endif
 
   for (i=0; i<NUM_SCREEN_GADGETS; i++)
     FreeGadget(screen_gadget[i]);