[Scummvm-git-logs] scummvm-web master -> ef9abdef7f443741cef8fb6e53ced955344d386b

SupSuper noreply at scummvm.org
Sun Mar 6 08:56:27 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-web' repo located at https://github.com/scummvm/scummvm-web .

Summary:
ef9abdef7f WEB: Automatically determine filemask for screenshots (#212)


Commit: ef9abdef7f443741cef8fb6e53ced955344d386b
    https://github.com/scummvm/scummvm-web/commit/ef9abdef7f443741cef8fb6e53ced955344d386b
Author: Daniel (supsuper at gmail.com)
Date: 2022-03-06T08:56:24Z

Commit Message:
WEB: Automatically determine filemask for screenshots (#212)

Add "variant_id" column to screenshots spreadsheet

Changed paths:
    include/OrmObjects/Screenshot.php
    include/OrmObjects/ScreenshotQuery.php
    schema.xml


diff --git a/include/OrmObjects/Screenshot.php b/include/OrmObjects/Screenshot.php
index 182d5a15..3eab6bbf 100644
--- a/include/OrmObjects/Screenshot.php
+++ b/include/OrmObjects/Screenshot.php
@@ -20,13 +20,11 @@ class Screenshot extends BaseScreenshot
     public function getFiles()
     {
         if (!$this->files) {
-            foreach (glob("./" . DIR_SCREENSHOTS . "/" . $this->getGame()->getEngine()->getId() . "/" . $this->getGame()->getId() . "/*") as $file) {
-                if (\strpos($file, "_full.") !== false) {
-                    continue;
-                }
-                // Remove the base folder and extension
+            foreach (glob("./" . DIR_SCREENSHOTS . "/" . $this->getGame()->getEngine()->getId() . "/" . $this->getGame()->getId() . "/" . $this->getFileMask()) as $file) {
+                // Remove the base folder
                 $name = str_replace("./" . DIR_SCREENSHOTS . "/", "", $file);
-                $name = \substr($name, 0, \strlen($name) - 4);
+                // Remove the suffix, eg. "_full.png"
+                $name = \substr($name, 0, \strlen($name) - 9);
                 $this->files[] = [
                     'filename' => $name,
                     'caption' => $this->getCaption(),
@@ -88,6 +86,20 @@ class Screenshot extends BaseScreenshot
         return htmlspecialchars($name);
     }
 
+    public function getFileMask()
+    {
+        $mask = $this->getGame()->getId() . "_";
+        if ($this->getPlatform()) {
+            $mask .= $this->getPlatform()->getId() . "_";
+        }
+        if ($this->getLanguage()) {
+            $mask .= $this->getLanguage() . "_";
+        }
+        $mask .= $this->getVariantId() . "_";
+        $mask .= "*_full.*";
+        return $mask;
+    }
+
     public function __toString()
     {
         return $this->getCaption();
diff --git a/include/OrmObjects/ScreenshotQuery.php b/include/OrmObjects/ScreenshotQuery.php
index b5ce42de..e380f6fc 100644
--- a/include/OrmObjects/ScreenshotQuery.php
+++ b/include/OrmObjects/ScreenshotQuery.php
@@ -26,7 +26,7 @@ class ScreenshotQuery extends BaseScreenshotQuery
             $con = Propel::getServiceContainer()->getReadConnection(ScreenshotTableMap::DATABASE_NAME);
         }
 
-        $sql = 'SELECT id, variant, platform_id, language, auto_id FROM screenshot ORDER BY RANDOM() LIMIT 1';
+        $sql = 'SELECT id, variant, platform_id, language, variant_id, auto_id FROM screenshot ORDER BY RANDOM() LIMIT 1';
         try {
             $stmt = $con->prepare($sql);
             $stmt->execute();
diff --git a/schema.xml b/schema.xml
index 1701faef..cef08646 100644
--- a/schema.xml
+++ b/schema.xml
@@ -69,6 +69,7 @@
     <column name="variant" type="varchar" size="255" />
     <column name="platform_id" type="varchar" size="24" required="true"/>
     <column name="language" type="varchar" size="8" required="true"/>
+    <column name="variant_id" type="integer"/>
     <foreign-key foreignTable="game" onDelete="CASCADE">
       <reference local="id" foreign="id"/>
     </foreign-key>




More information about the Scummvm-git-logs mailing list