Skip to content

Commit

Permalink
empty titles will now be failed + ability to fail files that do not h…
Browse files Browse the repository at this point in the history
…ave custom variable
  • Loading branch information
FrogTheFrog committed Nov 9, 2017
1 parent 731c76e commit a17a9f6
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.

## 2.2.6 - 2017-11-09

### Added

* Titles, not found in `customVariables.json` can now be failed (skipped). Useful for MAME and similar emulators.

### Fixed

* Empty titles (with a length of a 0) will now be failed (skipped) by a parser.

## 2.2.5 - 2017-11-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "steam-rom-manager",
"version": "2.2.5",
"version": "2.2.6",
"license": "GPL-3.0",
"description": "An app for managing ROMs in Steam",
"author": {
Expand All @@ -23,7 +23,7 @@
"icon": "./src/assets/icons/win.ico"
},
"portable": {
"artifactName": "${productName} ${version} (portable).${ext}"
"artifactName": "${productName}-portable-${version}.${ext}"
},
"linux": {
"category": "Utility",
Expand Down
1 change: 1 addition & 0 deletions src/lang/english/langData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ export const EnglishLang: languageContainer = {
skipWithMissingDataDir: 'Skip found accounts with missing data directories',
useCredentials: 'Use account credentials',
tryToMatchTitle: 'Enabled',
skipFileIfVariableWasNotFound: 'Skip file if variable was not found',
caseInsensitiveVariables: 'Case-insensitive variables',
fuzzy_use: 'Use fuzzy matching',
fuzzy_removeCharacters: 'Aggressive matching',
Expand Down
18 changes: 15 additions & 3 deletions src/lib/file-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,18 @@ export class FileParser {
missingUserAccounts: filteredAccounts.missing,
steamDirectory: configs[i].steamDirectory,
files: [],
failed: []
failed: _.cloneDeep(data[i].failed)
});

for (let j = 0; j < data[i].success.length; j++) {
let fuzzyTitle = data[i].success[j].fuzzyTitle || data[i].success[j].extractedTitle;

// Fail empty titles
if (fuzzyTitle.length === 0) {
parsedConfigs[i].failed.push(data[i].success[j].filePath);
continue;
}

let executableLocation = configs[i].executableLocation ? configs[i].executableLocation : data[i].success[j].filePath;

parsedConfigs[i].files.push({
Expand Down Expand Up @@ -189,8 +196,6 @@ export class FileParser {
})) : [];
}

parsedConfigs[i].failed = _.cloneDeep(data[i].failed);

localImagePromises.push(this.resolveFieldGlobs('localImages', configs[i], parsedConfigs[i], vParser).then((data) => {
for (let j = 0; j < data.parsedConfig.files.length; j++) {
data.parsedConfig.files[j].resolvedLocalImages = data.resolvedGlobs[j];
Expand Down Expand Up @@ -246,6 +251,13 @@ export class FileParser {
if (found)
break;
}
if (config.titleFromVariable.skipFileIfVariableWasNotFound && !found)
data.success[i].extractedTitle = '';
}
}
else if (config.titleFromVariable.skipFileIfVariableWasNotFound) {
for (let i = 0; i < data.success.length; i++) {
data.success[i].extractedTitle = '';
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/fuzzy-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ export class FuzzyMatcher {
}

private matchFromList(input: string, removeCharacters: boolean, removeBrackets: boolean) {
if (input.length === 0){
return { output: input, matched: false };
}
// Check if title contains ", The..."
if (/,\s*the/i.test(input)) {
else if (/,\s*the/i.test(input)) {
let modifiedInput = input.replace(/(.*?),\s*(.*)/i, '$2 $1');
modifiedInput = this.modifyString(modifiedInput, removeCharacters, removeBrackets);
let matches = this.performMatching(modifiedInput);
Expand Down
1 change: 1 addition & 0 deletions src/models/language.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export interface languageStruct {
skipWithMissingDataDir: string,
useCredentials: string,
tryToMatchTitle: string,
skipFileIfVariableWasNotFound: string,
caseInsensitiveVariables: string,
fuzzy_use: string,
fuzzy_removeCharacters: string,
Expand Down
1 change: 1 addition & 0 deletions src/models/user-configuration.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface UserConfiguration {
parserInputs: { [inputKey: string]: string },
titleFromVariable: {
limitToGroups: string,
skipFileIfVariableWasNotFound: boolean,
caseInsensitiveVariables: boolean,
tryToMatchTitle: boolean
},
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/parsers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export class ParsersComponent implements AfterViewInit, OnDestroy {
caseInsensitiveVariables: new NestedFormElement.Toggle({
text: this.lang.text.caseInsensitiveVariables
}),
skipFileIfVariableWasNotFound: new NestedFormElement.Toggle({
text: this.lang.text.skipFileIfVariableWasNotFound
}),
tryToMatchTitle: new NestedFormElement.Toggle({
text: this.lang.text.tryToMatchTitle
})
Expand Down
1 change: 1 addition & 0 deletions src/renderer/schemas/user-configuration.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const userConfiguration = {
default: {},
properties: {
limitToGroups: { type: 'string', default: '' },
skipFileIfVariableWasNotFound: { type: 'boolean', default: false },
caseInsensitiveVariables: { type: 'boolean', default: false },
tryToMatchTitle: { type: 'boolean', default: false }
}
Expand Down

0 comments on commit a17a9f6

Please sign in to comment.