fixed not redrawing global border after changing custom graphics level set
[rocksndiamonds.git] / src / screens.c
index 8ec78ee60f455d7f0518bfd3517549040ca72c5f..4461c4b7995531a78b0545d2333b0b5f4ae0c4ce 100644 (file)
@@ -1252,14 +1252,6 @@ void DrawHeadline()
                    setup.internal.program_copyright);
 }
 
-int effectiveGameStatus()
-{
-  if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE)
-    return GAME_MODE_TITLE;
-
-  return game_status;
-}
-
 void DrawTitleScreenImage(int nr, boolean initial)
 {
   int graphic = getTitleScreenGraphic(nr, initial);
@@ -1316,6 +1308,14 @@ void DrawTitleScreenMessage(int nr, boolean initial)
   /* force TITLE font on title message screen */
   game_status = getTitleMessageGameMode(initial);
 
+  /* if chars *and* width set to "-1", automatically determine width */
+  if (tmi->chars == -1 && tmi->width == -1)
+    tmi->width = viewport.window[game_status].width;
+
+  /* if lines *and* height set to "-1", automatically determine height */
+  if (tmi->lines == -1 && tmi->height == -1)
+    tmi->height = viewport.window[game_status].height;
+
   /* if chars set to "-1", automatically determine by text and font width */
   if (tmi->chars == -1)
     tmi->chars = tmi->width / getFontWidth(tmi->font);
@@ -1328,6 +1328,14 @@ void DrawTitleScreenMessage(int nr, boolean initial)
   else
     tmi->height = tmi->lines * getFontHeight(tmi->font);
 
+  /* if x set to "-1", automatically determine by width and alignment */
+  if (tmi->x == -1)
+    tmi->x = -1 * ALIGNED_XPOS(0, tmi->width, tmi->align);
+
+  /* if y set to "-1", automatically determine by height and alignment */
+  if (tmi->y == -1)
+    tmi->y = -1 * ALIGNED_YPOS(0, tmi->height, tmi->valign);
+
   SetDrawBackgroundMask(REDRAW_ALL);
   SetWindowBackgroundImage(getTitleBackground(nr, initial, FALSE));
 
@@ -1434,6 +1442,7 @@ void DrawMainMenu()
 
   if (CheckTitleScreen(levelset_has_changed))
   {
+    game_status_last_screen = GAME_MODE_MAIN;
     game_status = GAME_MODE_TITLE;
 
     DrawTitleScreen();
@@ -1557,7 +1566,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     last_sound = SND_UNDEFINED;
     last_music = MUS_UNDEFINED;
 
-    if (game_status == GAME_MODE_INFO)
+    if (game_status_last_screen == GAME_MODE_INFO)
     {
       if (num_title_screens == 0)
       {
@@ -1572,6 +1581,11 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
       FadeOut(REDRAW_ALL);
     }
 
+    /* only required to update logic for redrawing global border */
+    ClearField();
+
+    ChangeViewportPropertiesIfNeeded();
+
     if (tci->is_image)
       DrawTitleScreenImage(tci->local_nr, tci->initial);
     else
@@ -1619,11 +1633,13 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
   }
   else if (button == MB_MENU_CHOICE)
   {
-    if (game_status == GAME_MODE_INFO && num_title_screens == 0)
+    if (game_status_last_screen == GAME_MODE_INFO && num_title_screens == 0)
     {
       FadeSetEnterScreen();
 
+      game_status = GAME_MODE_INFO;
       info_mode = INFO_MODE_MAIN;
+
       DrawInfoScreen();
 
       return;
@@ -1688,8 +1704,9 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
     /* force full menu screen redraw after displaying title screens */
     redraw_mask = REDRAW_ALL;
 
-    if (game_status == GAME_MODE_INFO)
+    if (game_status_last_screen == GAME_MODE_INFO)
     {
+      game_status = GAME_MODE_INFO;
       info_mode = INFO_MODE_MAIN;
 
       DrawInfoScreen();
@@ -2159,6 +2176,8 @@ static void DrawInfoScreen_Main()
 
   FadeOut(fade_mask);
 
+  ChangeViewportPropertiesIfNeeded();
+
   OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
 
   ClearField();
@@ -2662,6 +2681,9 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
 
 void DrawInfoScreen_TitleScreen()
 {
+  game_status_last_screen = GAME_MODE_INFO;
+  game_status = GAME_MODE_TITLE;
+
   DrawTitleScreen();
 }