fixed global border for score info page
[rocksndiamonds.git] / src / tools.c
index 6a998afb360639bb7611ac472c06ff6b0c7bf497..464a4fb14a797c4f4818481d2b2ef041cda3bf6b 100644 (file)
@@ -512,6 +512,10 @@ static void DrawMaskedBorderExt_Rect(int x, int y, int width, int height,
   Bitmap *src_bitmap = getGlobalBorderBitmapFromStatus(global.border_status);
   Bitmap *dst_bitmap = gfx.masked_border_bitmap_ptr;
 
+  // may happen for "border.draw_masked.*" with undefined "global.border.*"
+  if (src_bitmap == NULL)
+    return;
+
   if (x == -1 && y == -1)
     return;
 
@@ -1118,7 +1122,8 @@ Bitmap *getGlobalBorderBitmapFromStatus(int status)
   int graphic =
     (status == GAME_MODE_MAIN ||
      status == GAME_MODE_PSEUDO_TYPENAME       ? IMG_GLOBAL_BORDER_MAIN :
-     status == GAME_MODE_SCORES                        ? IMG_GLOBAL_BORDER_SCORES :
+     status == GAME_MODE_SCORES ||
+     status == GAME_MODE_SCOREINFO             ? IMG_GLOBAL_BORDER_SCORES :
      status == GAME_MODE_EDITOR                        ? IMG_GLOBAL_BORDER_EDITOR :
      status == GAME_MODE_PLAYING               ? IMG_GLOBAL_BORDER_PLAYING :
      IMG_GLOBAL_BORDER);
@@ -1490,8 +1495,9 @@ int getGraphicAnimationFrameXY(int graphic, int lx, int ly)
     int ysize = MAX(1, g->anim_frames / xsize);
     int xoffset = g->anim_start_frame % xsize;
     int yoffset = g->anim_start_frame % ysize;
-    int x = (lx + xoffset + xsize) % xsize;
-    int y = (ly + yoffset + ysize) % ysize;
+    // may be needed if screen field is significantly larger than playfield
+    int x = (lx + xoffset + SCR_FIELDX * xsize) % xsize;
+    int y = (ly + yoffset + SCR_FIELDY * ysize) % ysize;
     int sync_frame = y * xsize + x;
 
     return sync_frame % g->anim_frames;
@@ -1499,14 +1505,19 @@ int getGraphicAnimationFrameXY(int graphic, int lx, int ly)
   else if (graphic_info[graphic].anim_mode & ANIM_RANDOM_STATIC)
   {
     struct GraphicInfo *g = &graphic_info[graphic];
-    int x = (lx + lev_fieldx) % lev_fieldx;
-    int y = (ly + lev_fieldy) % lev_fieldy;
+    // may be needed if screen field is significantly larger than playfield
+    int x = (lx + SCR_FIELDX * lev_fieldx) % lev_fieldx;
+    int y = (ly + SCR_FIELDY * lev_fieldy) % lev_fieldy;
     int sync_frame = GfxRandomStatic[x][y];
 
     return sync_frame % g->anim_frames;
   }
+  else
+  {
+    int sync_frame = (IN_LEV_FIELD(lx, ly) ? GfxFrame[lx][ly] : -1);
 
-  return getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]);
+    return getGraphicAnimationFrame(graphic, sync_frame);
+  }
 }
 
 void getGraphicSourceBitmap(int graphic, int tilesize, Bitmap **bitmap)
@@ -2517,6 +2528,11 @@ void DrawScreenGraphic(int x, int y, int graphic, int frame)
   }
 }
 
+void DrawLevelGraphic(int x, int y, int graphic, int frame)
+{
+  DrawScreenGraphic(SCREENX(x), SCREENY(y), graphic, frame);
+}
+
 void DrawScreenElement(int x, int y, int element)
 {
   int mask_mode = NO_MASKING;
@@ -9939,6 +9955,16 @@ void ChangeViewportPropertiesIfNeeded(void)
   }
 }
 
+void OpenURL(char *url)
+{
+  SDL_OpenURL(url);
+}
+
+void OpenURLFromHash(SetupFileHash *hash, int hash_key)
+{
+  OpenURL(getHashEntry(hash, int2str(hash_key, 0)));
+}
+
 
 // ============================================================================
 // tests