Skip to content

Commit

Permalink
Option to retain 'disc N' info in game title.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gemba committed Nov 26, 2024
1 parent 1c10b0c commit f4764a2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
;videoConvertExtension="mp4"
;symlink="false"
;brackets="true"
;keepDiscInfo="false"
;maxLength="10000"
;threads="2"
;pretend="false"
Expand Down
5 changes: 4 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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/<USER>/.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
Expand Down
31 changes: 30 additions & 1 deletion docs/CONFIGINI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand Down Expand Up @@ -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]`, `[<PLATFORM>]`

---

#### 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.
Expand Down Expand Up @@ -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]`, `[<PLATFORM>]`, `[<FRONTEND>]`
Expand Down
16 changes: 16 additions & 0 deletions src/scraperworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down
4 changes: 4 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -221,6 +222,7 @@ class RuntimeCfg : public QObject {
{"innerParenthesesReplace", QPair<QString, int>("str", CfgType::MAIN )},
{"interactive", QPair<QString, int>("bool", CfgType::MAIN | CfgType::PLATFORM | CfgType::SCRAPER )},
{"jpgQuality", QPair<QString, int>("int", CfgType::MAIN | CfgType::PLATFORM | CfgType::SCRAPER )},
{"keepDiscInfo", QPair<QString, int>("bool", CfgType::MAIN | CfgType::PLATFORM )},
{"lang", QPair<QString, int>("str", CfgType::MAIN | CfgType::PLATFORM )},
{"langPrios", QPair<QString, int>("str", CfgType::MAIN | CfgType::PLATFORM )},
{"launch", QPair<QString, int>("str", CfgType::MAIN | CfgType::PLATFORM | CfgType::FRONTEND )},
Expand Down

0 comments on commit f4764a2

Please sign in to comment.