diff --git a/config.ini.example b/config.ini.example index 058b82f5..9a77f27b 100644 --- a/config.ini.example +++ b/config.ini.example @@ -51,6 +51,7 @@ ;videoConvertExtension="mp4" ;symlink="false" ;brackets="true" +;keepDiscInfo="false" ;maxLength="10000" ;threads="2" ;pretend="false" diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 27944e81..14d432a8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,9 @@ humans](https://keepachangelog.com). parentheses in gamelist title. See [`innerBracketsReplace`](CONFIGINI.md#innerbracketsreplace) for examples. Thanks for the suggestion, @retrobit. +- Added: Option to retain disc numbering from game filename, when no other + bracket information is requested. See + [`keepDiscInfo`](CONFIGINI.md#keepdiscinfo) for details. Thanks, @maxexcloo! - Added: [Platform 'Fujitsu FM-Towns'](https://github.com/Gemba/skyscraper/pull/95/files). Manually update your `peas.json` and `platformid_map.csv` to make use of it. @@ -19,7 +22,7 @@ humans](https://keepachangelog.com). home directory screen messages. Thanks for highlighting it on the Mac, @cdaters - Updated: A downloaded `whdload.xml` file for platform Amiga will be not - downloaded again until the server indicates. Manually removing + downloaded again until the server indicates. However, manually removing `/home//.skyscraper/whdload_cached_etag.txt` will force a new download. - Fixed: Performing Ctrl-C in `--cache edit` mode will now dismiss any changes made instead of persisting them diff --git a/docs/CONFIGINI.md b/docs/CONFIGINI.md index 8cc1dd9b..75d455a2 100644 --- a/docs/CONFIGINI.md +++ b/docs/CONFIGINI.md @@ -93,6 +93,7 @@ This is an alphabetical index of all configuration options including the section | [inputFolder](CONFIGINI.md#inputfolder) | Y | Y | | | | [interactive](CONFIGINI.md#interactive) | Y | Y | | Y | | [jpgQuality](CONFIGINI.md#jpgquality) | Y | Y | | Y | +| [keepDiscInfo](CONFIGINI.md#keepdiscinfo) | Y | Y | | | | [lang](CONFIGINI.md#lang) | Y | Y | | | | [langPrios](CONFIGINI.md#langprios) | Y | Y | | | | [launch](CONFIGINI.md#launch) | Y | Y | Y | | @@ -548,6 +549,34 @@ Same as [innerBracketsReplace](#innerbracketsreplace) but for parentheses `)(` --- +#### keepDiscInfo + +Only in use when the option `brackets` is set to `false` for gamelist creation: +If you set `keepDiscInfo="true"`, Skyscraper attempts to retain the "Disc N (of +M)" part in the resulting game title in the gamelist. Currently the term 'disc' +is identified in the filename in English. German, French, Italian. +Any disc information is first searched in parentheses e.g., (Disc 1 of 4) and then in +brackets e.g., [Disc 1]. Any suffix after the disc number like "of 4" is also +kept. + +!!! tip + + If the emulator supports multi disc loading with an `*.m3u` or `*.cue` file you should use it, as it will remove gamelist clutter. Another option is to define a custom game title for each of the filenames with disc information via Skyscraper's [import function](IMPORT.md). The latter option allows you to define any "Disc N of M" display style in your gamelist. + +!!! note + + The option keepDiscInfo is not applicable if you use a [name template](#nametemplate). + +**Example(s)** + +Filename: `Stupid Invaders v1.001 (2001)(Ubi Soft)(US)(Disc 1 of 2)[!].chd` +Resulting game title: `Stupid Invaders (Disc 1 of 2)` + +Default value: `false` +Allowed in sections: `[main]`, `[]` + +--- + #### maxLength Sets the maximum length of returned game descriptions. This is a convenience option if you feel like game descriptions are too long. By default it is set to 2500. @@ -617,7 +646,7 @@ Enable this option to force Skyscraper to use the file name (excluding extension !!! tip - If you set `forceFilename="true"` and your filenames contain bracket notes such as `(this)` or `[that]` at the end, these will be combined with whatever bracket notes are at the end of the titles returned from the sources. This can cause some confusion. For instance, if you have the filename `Gran Turismo 2 (USA) (Arcade Mode)` and the cached title is `Gran Turismo 2 (Arcade Mode)`, then the gamelist name will become `Gran Turismo 2 (Arcade Mode)(USA)(Arcade Mode)`. You can disable them altogether with the `brackets="no"` option. + If you set `forceFilename="true"` and your filenames contain bracket notes such as `(this)` or `[that]` at the end, these will be combined with whatever bracket notes are at the end of the titles returned from the sources. This can cause some confusion. For instance, if you have the filename `Gran Turismo 2 (USA) (Arcade Mode)` and the cached title is `Gran Turismo 2 (Arcade Mode)`, then the gamelist name will become `Gran Turismo 2 (Arcade Mode)(USA)(Arcade Mode)`. You can disable them altogether with the `brackets="false"` option. Default value: `false` Allowed in sections: `[main]`, `[]`, `[]` diff --git a/src/scraperworker.cpp b/src/scraperworker.cpp index f618cedf..0626cea6 100644 --- a/src/scraperworker.cpp +++ b/src/scraperworker.cpp @@ -396,6 +396,22 @@ void ScraperWorker::run() { if (config.brackets) { game.title.append( StrTools::xmlUnescape(parenthesesInfo % bracketInfo)); + } else if (config.keepDiscInfo) { + QRegularExpressionMatch match; + QString discRe = "dis(k|c|co|que)\\s?\\d{1,2}"; + QRegularExpression re = QRegularExpression( + "(\\(" % discRe % "(\\)|.+\\)))", + QRegularExpression::CaseInsensitiveOption); + match = re.match(parenthesesInfo); + if (match.hasMatch()) { + game.title.append(" " % match.captured(1)); + } else { + re.setPattern("(\\[" % discRe % "(\\]|.+\\]))"); + match = re.match(bracketInfo); + if (match.hasMatch()) { + game.title.append(" " % match.captured(1)); + } + } } } output.append("Platform: '\033[1;32m" + game.platform + diff --git a/src/settings.cpp b/src/settings.cpp index 1c4e245b..7d060b4c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -374,6 +374,10 @@ void RuntimeCfg::applyConfigIni(CfgType type, QSettings *settings, config->interactive = v; continue; } + if (k == "keepDiscInfo") { + config->keepDiscInfo = v; + continue; + } if (k == "mediaFolderHidden") { QStringList allowedFe({"emulationstation", "retrobat"}); if (allowedFe.contains(config->frontend)) { diff --git a/src/settings.h b/src/settings.h index 11a8fe85..b59e3a6d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -81,6 +81,7 @@ struct Settings { int totalFiles = 0; int maxLength = 2500; bool brackets = true; + bool keepDiscInfo = false; bool refresh = false; QString cacheOptions = ""; bool cacheResize = true; @@ -221,6 +222,7 @@ class RuntimeCfg : public QObject { {"innerParenthesesReplace", QPair("str", CfgType::MAIN )}, {"interactive", QPair("bool", CfgType::MAIN | CfgType::PLATFORM | CfgType::SCRAPER )}, {"jpgQuality", QPair("int", CfgType::MAIN | CfgType::PLATFORM | CfgType::SCRAPER )}, + {"keepDiscInfo", QPair("bool", CfgType::MAIN | CfgType::PLATFORM )}, {"lang", QPair("str", CfgType::MAIN | CfgType::PLATFORM )}, {"langPrios", QPair("str", CfgType::MAIN | CfgType::PLATFORM )}, {"launch", QPair("str", CfgType::MAIN | CfgType::PLATFORM | CfgType::FRONTEND )},