[Scummvm-cvs-logs] SF.net SVN: scummvm: [27090] web/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Jun 5 00:29:35 CEST 2007


Revision: 27090
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27090&view=rev
Author:   fingolfin
Date:     2007-06-04 15:29:34 -0700 (Mon, 04 Jun 2007)

Log Message:
-----------
Some cleanup to the screenshot handling code

Modified Paths:
--------------
    web/trunk/include/screenshots.php
    web/trunk/index.php
    web/trunk/screenshots.php

Modified: web/trunk/include/screenshots.php
===================================================================
--- web/trunk/include/screenshots.php	2007-06-04 22:16:17 UTC (rev 27089)
+++ web/trunk/include/screenshots.php	2007-06-04 22:29:34 UTC (rev 27090)
@@ -10,13 +10,6 @@
   return $file_root . "/screenshots/scummvm_" . $id . ".jpg";
 }
 
-function screenshot_thumb_from_full ($fname) {
-  $t = explode("scummvm_", $fname);
-  $t1 = explode(".", $t[1]);
-
-  return screenshot_thumb_path($t1[0]);
-}
-
 function screenshot_caption ($id) {
   global $file_root;
   return implode("", file($file_root."/screenshots/scummvm_".$id.".txt"));
@@ -68,23 +61,25 @@
 $scrcatnums = array();
 $tmp = get_files($file_root."/screenshots","png");
 foreach ($tmp as $image) {
-  array_push($screenshots,$image);
-  $cats = explode("_", $image);
-  $n = count($cats);
-  $t = explode(".", $cats[$n - 1]);
-  $num = $t[0];
 
-  if (!array_key_exists($cats[$n - 3], $scrcatnums) or
-      !array_key_exists($cats[$n - 2], $scrcatnums[$cats[$n - 3]])) {
-    $scrcatnums[$cats[$n - 3]][$cats[$n - 2]] = 0;
+  // Parse the ID of the schot in the file name, consisting of three numbers:
+  // 1) the "broad" category
+  // 2) the game
+  // 3) sequential number, used to distinguish shots of a single game
+  preg_match("/bigscummvm_(\d+)_(\d+)_(\d+).png/", $image, $cats);
+  $num = $cats[3];
+
+  // Push the three-number-id into an array (mainly used for selecting random screenshots)  
+  array_push($screenshots,$cats[1]."_".$cats[2]."_".$cats[3]);
+
+  // Update scrcatnums map
+  if (!array_key_exists($cats[1], $scrcatnums) or
+      !array_key_exists($cats[2], $scrcatnums[$cats[1]])) {
+    $scrcatnums[$cats[1]][$cats[2]] = 0;
   }
 
-  if ($scrcatnums[$cats[$n - 3]][$cats[$n - 2]] < $num + 1)
-    $scrcatnums[$cats[$n - 3]][$cats[$n - 2]] = $num + 1;
+  if ($scrcatnums[$cats[1]][$cats[2]] < $num + 1)
+    $scrcatnums[$cats[1]][$cats[2]] = $num + 1;
 }
-$screenshots_count = count($screenshots);
 
-$thumb_w = 256;
-$thumb_h = 192;
-
 ?>

Modified: web/trunk/index.php
===================================================================
--- web/trunk/index.php	2007-06-04 22:16:17 UTC (rev 27089)
+++ web/trunk/index.php	2007-06-04 22:29:34 UTC (rev 27090)
@@ -25,7 +25,7 @@
 if ($randPart < 6) {
   $randImg = rand(0, $lastLECshot - 1);
 } else {
-  $randImg = $lastLECshot + rand(0, $screenshots_count - $lastLECshot - 1);
+  $randImg = $lastLECshot + rand(0, count($screenshots) - $lastLECshot - 1);
 }
 
 echo '<script src="'.$file_root.'/screenshots.js" type="text/javascript"></script>';

Modified: web/trunk/screenshots.php
===================================================================
--- web/trunk/screenshots.php	2007-06-04 22:16:17 UTC (rev 27089)
+++ web/trunk/screenshots.php	2007-06-04 22:29:34 UTC (rev 27090)
@@ -44,7 +44,7 @@
 
 
   // Random screenshot
-  $randImg = rand(0, $screenshots_count - 1);
+  $randImg = rand(0, count($screenshots) - 1);
 ?>
 <br>
 <table border=0 width="100%">
@@ -66,13 +66,11 @@
 <tr><td width=280 height=37 colspan=4><img src="<?=$file_root?>/images/rs-top.png" alt=""></td></tr>
 <tr><td width=17 height=10 colspan=2><img src="<?=$file_root?>/images/rs-top-left.png" alt=""></td><td rowspan=2 width=256 height=192>
 <?php
-  $t = explode("scummvm_", $screenshots[$randImg]);
-  $t1 = explode(".", $t[1]);
-
-  echo "<a href=\"javascript:openWin('$file_root/screenshots/{$screenshots[$randImg]}','Screenshot:" . screenshot_caption($t1[0]) ."',640,483);\"\n";
+  $image = $screenshots[$randImg];
+  echo "<a href=\"javascript:openWin('$file_root/screenshots/bigscummvm_$image.png','Screenshot:" . screenshot_caption($image) ."',640,483);\"\n";
   echo "  onMouseOver=\"window.status='Click to View Full Size Image';return true;\"\n";
   echo "  onMouseOut=\"window.status='';return true;\">";
-  echo '<img align=right src="'.screenshot_thumb_from_full($screenshots[$randImg]).'" alt="Random Screenshot"';
+  echo '<img align=right src="'.screenshot_thumb_path($image).'" alt="Random Screenshot"';
   echo ' title="Click to view Full Size"></a>';
 ?>
 </td><td style="background:#a82709;" width=7 height=192 rowspan=2></td></tr>
@@ -130,7 +128,7 @@
 	'<table cellpadding="0" cellspacing="0"><tr><td align="center">'.
 	"<a href=\"javascript:openWin('./screenshots/bigscummvm_$image.png','Screenshot: " . screenshot_caption($image) . "',640,483);\">".
 	'<img src="'.screenshot_thumb_path($image).'" '.
-	'width="'.$thumb_w.'" height="'.$thumb_h.'" alt="Screenshot '.$c.'"></a>'.
+	'width=256 height=192 alt="Screenshot '.$c.'"></a>'.
 	'</td></tr><tr><td align="center">'.
 	screenshot_caption($image).
 	'</td></tr></table>',


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list