From ec40df047c1b48fae0cd1184c41cb96383f6f0c4 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Mon, 11 May 2020 20:15:44 -0400 Subject: [PATCH 01/25] new state management with configuration title --- src/lib/vdf-added-items-file.ts | 83 +++++++++++++++++---------------- src/lib/vdf-manager.ts | 11 +++-- src/models/vdf-manager.model.ts | 2 +- 3 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/lib/vdf-added-items-file.ts b/src/lib/vdf-added-items-file.ts index 92fb7c75ec..95b91275b7 100644 --- a/src/lib/vdf-added-items-file.ts +++ b/src/lib/vdf-added-items-file.ts @@ -7,55 +7,60 @@ import * as fs from 'fs-extra'; import * as path from 'path'; export class VDF_AddedItemsFile { - private fileData: VDF_AddedItemsData = undefined; + private fileData: VDF_AddedItemsData = undefined; - constructor(private filepath: string) { } + constructor(private filepath: string) { } - get data() { - return this.fileData; - } + get data() { + return this.fileData; + } - set data(value: VDF_AddedItemsData) { - this.fileData = value; - } + set data(value: VDF_AddedItemsData) { + this.fileData = value; + } - get valid() { - return this.fileData !== undefined; - } + get valid() { + return this.fileData !== undefined; + } - get invalid() { - return !this.valid; - } + get invalid() { + return !this.valid; + } - read() { - return json.read(this.filepath, []).then((data) => { - this.fileData = {}; + read() { + return json.read(this.filepath, []).then((data) => { + this.fileData = {}; - for (let i = 0; i < data.length; i++) { - this.fileData[data[i]] = true; - } + for (let i = 0; i < data.length; i++) { + if(data[i].includes("_")) { + this.fileData[data[i].split('_')[0]] = data[i].split('_')[1]; //fileData[data[i]] was just set to true + } else { + this.fileData[data[i]] = '-legacy-'; + } + } - return this.data; - }); - } + return this.data; + }); + } - write() { - this.fileData = _.pickBy(this.fileData, item => item !== undefined); - let data = Object.keys(this.fileData); - return json.write(this.filepath, data); - } + write() { + this.fileData = _.pickBy(this.fileData, item => item !== undefined); + let app_ids = Object.keys(this.fileData).filter((app_id:string) => this.fileData[app_id]!=='-legacy-'); + let data = app_ids.map((app_id:string)=>app_id.concat('_',this.fileData[app_id])) //data was just keys + return json.write(this.filepath, data); + } - getItem(appId: string){ - return this.fileData[appId]; - } + getItem(appId: string){ + return this.fileData[appId]; + } - removeItem(appId: string){ - if (this.fileData[appId] !== undefined){ - this.fileData[appId] = undefined; - } + removeItem(appId: string){ + if (this.fileData[appId] !== undefined){ + this.fileData[appId] = undefined; } + } - addItem(appId: string){ - this.fileData[appId] = true; - } -} \ No newline at end of file + addItem(appId: string, configurationTitle: string) { + this.fileData[appId] = configurationTitle; // true -> configurationTitle + } +} diff --git a/src/lib/vdf-manager.ts b/src/lib/vdf-manager.ts index 87d3b8f7d2..543615d06a 100644 --- a/src/lib/vdf-manager.ts +++ b/src/lib/vdf-manager.ts @@ -1,4 +1,4 @@ -import { VDF_ListData, SteamDirectory, PreviewData, AppImages, VDF_ListItem } from "../models"; +import { VDF_ListData, SteamDirectory, PreviewData, PreviewDataApp, AppImages, VDF_ListItem } from "../models"; import { VDF_Error } from './vdf-error'; import { APP } from '../variables'; import * as vdf from './helpers/vdf'; @@ -120,9 +120,12 @@ export class VDF_Manager { if (listItem.shortcuts.invalid || listItem.addedItems.invalid || listItem.screenshots.invalid) return; let apps = previewData[steamDirectory][userId].apps; - let appIds = Object.keys(previewData[steamDirectory][userId].apps) + // I should use all the just app id entries for building extraneous, but then remove them from the file + let currentAppIds = Object.keys(previewData[steamDirectory][userId].apps) + let enabledParsers = Array.from(new Set(currentAppIds.map((appid:string)=> apps[appid].configurationTitle))); let addedAppIds = Object.keys(listItem.addedItems.data); - let extraneousAppIds = addedAppIds.filter((x:string) => appIds.indexOf(x)<0); + let addedAppIdsForCurrentParsers = addedAppIds.filter((appid:string) => listItem.addedItems.data[appid]==='-legacy-' || enabledParsers.indexOf(listItem.addedItems.data[appid])>=0); + let extraneousAppIds = addedAppIdsForCurrentParsers.filter((appid:string) => currentAppIds.indexOf(appid)<0); // should actually do addedfromenabled \diff newids listItem.screenshots.extraneous = extraneousAppIds; listItem.shortcuts.extraneous = extraneousAppIds; for (let appId in apps) { @@ -154,7 +157,7 @@ export class VDF_Manager { } - listItem.addedItems.addItem(appId); + listItem.addedItems.addItem(appId, app.configurationTitle); // added app.configurationTitle if (currentImage !== undefined && currentImage.imageProvider !== 'Steam') { listItem.screenshots.addItem({ appId: appId, title: app.title, url: currentImage.imageUrl }); } diff --git a/src/models/vdf-manager.model.ts b/src/models/vdf-manager.model.ts index ad7de75a9f..e23c8228e0 100644 --- a/src/models/vdf-manager.model.ts +++ b/src/models/vdf-manager.model.ts @@ -29,7 +29,7 @@ export interface VDF_ShortcutsItem { } export interface VDF_AddedItemsData { - [key: string]: true | undefined + [key: string]: string | undefined // true -> string (configuration title) } export type SteamDirectory = string; From 5b9b41508e3470a4ffc26fec51a58b84d013ef6f Mon Sep 17 00:00:00 2001 From: cbartondock Date: Mon, 11 May 2020 20:56:28 -0400 Subject: [PATCH 02/25] added setting for delete disabled shortcuts (or not) --- src/lang/english/langData.ts | 1 + src/lib/vdf-manager.ts | 8 +++--- src/models/language.model.ts | 1 + src/models/settings.model.ts | 25 ++++++++++--------- src/renderer/schemas/app-settings.schema.ts | 3 ++- src/renderer/services/preview.service.ts | 2 +- .../templates/settings.component.html | 7 +++--- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/lang/english/langData.ts b/src/lang/english/langData.ts index ddfffa4ef6..116930eef2 100644 --- a/src/lang/english/langData.ts +++ b/src/lang/english/langData.ts @@ -180,6 +180,7 @@ export const EnglishLang: languageContainer = { resetFuzzy_desc: 'Reset fuzzy list:', resetFuzzy_btn: 'Reset', showSteamImages: 'Show current Steam images', + deleteDisabledShortcuts: 'Remove shortcuts for disabled parsers', clearLogOnTest: 'Automatically clear log when before testing parser' }, placeholder: { diff --git a/src/lib/vdf-manager.ts b/src/lib/vdf-manager.ts index 543615d06a..94b6aca63d 100644 --- a/src/lib/vdf-manager.ts +++ b/src/lib/vdf-manager.ts @@ -114,7 +114,7 @@ export class VDF_Manager { } } - mergeData(previewData: PreviewData, images: AppImages, tallimages: AppImages, heroimages: AppImages, logoimages: AppImages) { + mergeData(previewData: PreviewData, images: AppImages, tallimages: AppImages, heroimages: AppImages, logoimages: AppImages, deleteDisabledShortcuts: boolean) { return Promise.resolve().then(() => { this.forEach((steamDirectory, userId, listItem) => { if (listItem.shortcuts.invalid || listItem.addedItems.invalid || listItem.screenshots.invalid) @@ -124,8 +124,10 @@ export class VDF_Manager { let currentAppIds = Object.keys(previewData[steamDirectory][userId].apps) let enabledParsers = Array.from(new Set(currentAppIds.map((appid:string)=> apps[appid].configurationTitle))); let addedAppIds = Object.keys(listItem.addedItems.data); - let addedAppIdsForCurrentParsers = addedAppIds.filter((appid:string) => listItem.addedItems.data[appid]==='-legacy-' || enabledParsers.indexOf(listItem.addedItems.data[appid])>=0); - let extraneousAppIds = addedAppIdsForCurrentParsers.filter((appid:string) => currentAppIds.indexOf(appid)<0); // should actually do addedfromenabled \diff newids + if(!deleteDisabledShortcuts) { + addedAppIds = addedAppIds.filter((appid:string) => listItem.addedItems.data[appid]==='-legacy-' || enabledParsers.indexOf(listItem.addedItems.data[appid])>=0); + } + let extraneousAppIds = addedAppIds.filter((appid:string) => currentAppIds.indexOf(appid)<0); // should actually do addedfromenabled \diff newids listItem.screenshots.extraneous = extraneousAppIds; listItem.shortcuts.extraneous = extraneousAppIds; for (let appId in apps) { diff --git a/src/models/language.model.ts b/src/models/language.model.ts index 137fcdb552..06b5405712 100644 --- a/src/models/language.model.ts +++ b/src/models/language.model.ts @@ -163,6 +163,7 @@ export interface languageStruct { resetFuzzy_desc: string, resetFuzzy_btn: string, showSteamImages: string, + deleteDisabledShortcuts: string, clearLogOnTest: string }, placeholder: { diff --git a/src/models/settings.model.ts b/src/models/settings.model.ts index 1df5969b55..582c3bd664 100644 --- a/src/models/settings.model.ts +++ b/src/models/settings.model.ts @@ -2,22 +2,23 @@ import { FuzzyListTimestamps } from "./fuzzy.model"; export interface PreviewSettings { retrieveCurrentSteamImages: boolean, + deleteDisabledShortcuts: boolean, imageZoomPercentage: number, preload: boolean, imageTypes: string[] } export interface AppSettings { - fuzzyMatcher: { - timestamps: FuzzyListTimestamps, - verbose: boolean, - filterProviders: boolean - }, - language: string, - offlineMode: boolean, - enabledProviders: string[], - previewSettings: PreviewSettings, - navigationWidth: number, - clearLogOnTest: boolean, - knownSteamDirectories: string[] + fuzzyMatcher: { + timestamps: FuzzyListTimestamps, + verbose: boolean, + filterProviders: boolean + }, + language: string, + offlineMode: boolean, + enabledProviders: string[], + previewSettings: PreviewSettings, + navigationWidth: number, + clearLogOnTest: boolean, + knownSteamDirectories: string[] } diff --git a/src/renderer/schemas/app-settings.schema.ts b/src/renderer/schemas/app-settings.schema.ts index 3a6caa3d6f..822e575374 100644 --- a/src/renderer/schemas/app-settings.schema.ts +++ b/src/renderer/schemas/app-settings.schema.ts @@ -25,6 +25,7 @@ export const appSettings = { default: {}, properties: { retrieveCurrentSteamImages: { type: 'boolean', default: true }, + deleteDisabledShortcuts: { type: 'boolean', default: true }, imageZoomPercentage: { type: 'number', default: 40, minimum: 30, maximum: 100 }, preload: { type: 'boolean', default: false }, } @@ -51,4 +52,4 @@ export const appSettings = { items: { type: 'string' } } } -}; \ No newline at end of file +}; diff --git a/src/renderer/services/preview.service.ts b/src/renderer/services/preview.service.ts index 2ef43e2559..16201e85f9 100644 --- a/src/renderer/services/preview.service.ts +++ b/src/renderer/services/preview.service.ts @@ -155,7 +155,7 @@ export class PreviewService { if (!remove) { this.loggerService.info(this.lang.info.mergingVDF_entries, { invokeAlert: true, alertTimeout: 3000 }); - return vdfManager.mergeData(this.previewData, this.appImages, this.appTallImages, this.appHeroImages, this.appLogoImages); + return vdfManager.mergeData(this.previewData, this.appImages, this.appTallImages, this.appHeroImages, this.appLogoImages, this.appSettings.previewSettings.deleteDisabledShortcuts); } else { this.loggerService.info(this.lang.info.removingVDF_entries, { invokeAlert: true, alertTimeout: 3000 }); diff --git a/src/renderer/templates/settings.component.html b/src/renderer/templates/settings.component.html index 78bdefd517..f91aa7f5c0 100644 --- a/src/renderer/templates/settings.component.html +++ b/src/renderer/templates/settings.component.html @@ -6,6 +6,7 @@ {{lang.text.offlineMode}} {{lang.text.clearLogOnTest}} {{lang.text.showSteamImages}} + {{lang.text.deleteDisabledShortcuts}}
@@ -68,7 +69,7 @@
Custom variables:
-
Force download
@@ -76,9 +77,9 @@
Configuration presets:
-
Force download
-
\ No newline at end of file +
From da0aff62cff131213f6ffcb634f51a9f049cc1f6 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 09:46:27 -0400 Subject: [PATCH 03/25] lets go --- CHANGELOG.md | 11 +++ README.md | 2 +- src/lang/english/langData.ts | 1 + src/lang/english/markdown/about.md | 11 +-- .../image-providers/available-providers.ts | 4 +- src/lib/image-providers/index.ts | 6 +- .../retrogaming-cloud.worker.ts | 75 ------------------- src/models/language.model.ts | 1 + src/models/preview.model.ts | 2 +- src/models/user-configuration.model.ts | 1 + .../modifiers/app-settings.modifier.ts | 4 +- .../schemas/user-configuration.schema.ts | 1 + src/renderer/services/parsers.service.ts | 7 +- 13 files changed, 36 insertions(+), 90 deletions(-) delete mode 100644 src/lib/image-providers/retrogaming-cloud.worker.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 7229e4d843..67c46c271a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Change Log All notable changes to this project will be documented in this file. +## 2.2.24 - 2020-05-12 +### Added +* Setting for whether or not to delete shortcuts from disabled parsers +* Google Images as a provider +* Ability to specify Launch Args in a JSON file +### Changed +* Removed retrogaming.cloud from list of image providers +* Changed structure of AddedItemsV2.json to include Parser ID +### Fixed +* A bunch of dead links in Readme and About Markdown + ## 2.2.23 - 2020-01-27 ### Added * Improved documentation for custom variables based on advice of a friend. diff --git a/README.md b/README.md index dbb710d400..8e116354ac 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Pull requests will still be reviewed and merged. # For casual users -Visit [Steam ROM Manager](https://frogthefrog.github.io/steam-rom-manager)'s github page for more information. +There are some helpful (albeit slightly outdated) tutorial videos to be found [here](https://github.com/doZennn/steam-rom-manager/tree/master/docs/videos). There is plenty of documentation available in the app's built in FAQ, and if you need further help there are expert users to be found on the [discord](https://discord.gg/nxxzBPJ). # For developers diff --git a/src/lang/english/langData.ts b/src/lang/english/langData.ts index 116930eef2..cebeb9f2e2 100644 --- a/src/lang/english/langData.ts +++ b/src/lang/english/langData.ts @@ -438,6 +438,7 @@ export const EnglishLang: languageContainer = { validationErrors: { parserType__md: '> Incorrect parser type!', configTitle__md: '> Configuration title is required!', + parserId__md: '> Parser Id is missing, something is horribly wrong.', parserInput: { noInput: 'No inputs are available!', inputNotAvailable__i: '"${name}" input is not available!', diff --git a/src/lang/english/markdown/about.md b/src/lang/english/markdown/about.md index a2483400ce..c9f0bdd757 100644 --- a/src/lang/english/markdown/about.md +++ b/src/lang/english/markdown/about.md @@ -8,17 +8,18 @@ In case you're having trouble with SRM, feel free to visit [Discord](https://dis * Official [Steam](http://steamcommunity.com/groups/steamrommanager) group. * Official [Discord](https://discord.gg/nxxzBPJ) group. -* Official [Github](https://github.com/FrogTheFrog/steam-rom-manager) repository. -* All releases can be downloaded from [here](https://github.com/FrogTheFrog/steam-rom-manager/releases). +* Official [Github](https://github.com/doZennn/steam-rom-manager) repository. +* All releases can be downloaded from [here](https://github.com/doZennn/steam-rom-manager/releases). ## Contributors - +* `FrogTheFrog` {.noWrap} - creator of SRM, no longer active. * `doZennn`{.noWrap} - helped before the initial release of SRM and many times after the release with various stuff. -* `HE Spoke`{.noWrap} - responsible for creating community around SRM. Creator of [Steam](http://steamcommunity.com/groups/steamrommanager) and [Discord](https://discord.gg/nxxzBPJ) groups. Also manages issues in [Github](https://github.com/FrogTheFrog/steam-rom-manager). +* `HE Spoke`{.noWrap} - responsible for creating community around SRM. Creator of [Steam](http://steamcommunity.com/groups/steamrommanager) and [Discord](https://discord.gg/nxxzBPJ) groups. Also manages issues in [Github](https://github.com/doZennn/steam-rom-manager). * `Choko`{.noWrap} - helps most users setup SRM in [Discord](https://discord.gg/nxxzBPJ). * `AlexDobeck`{.noWrap} - improved [retrogaming.cloud](http://retrogaming.cloud/) performance. +* `lontanadascienza` {.noWrap} - updated SRM to handle heroes, posters, logos. Some other stuff too. ## Credits * SRM icon created by [doZennn](https://www.reddit.com/user/dozennn) who's also the big boss of [SteamGridDB](http://www.steamgriddb.com/). -* Most icons were made by [Roundicons](https://www.flaticon.com/authors/roundicons) from [Flaticon](https://www.flaticon.com) (licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/)). \ No newline at end of file +* Most icons were made by [Roundicons](https://www.flaticon.com/authors/roundicons) from [Flaticon](https://www.flaticon.com) (licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/)). diff --git a/src/lib/image-providers/available-providers.ts b/src/lib/image-providers/available-providers.ts index cc61727851..cbad4fb5a8 100644 --- a/src/lib/image-providers/available-providers.ts +++ b/src/lib/image-providers/available-providers.ts @@ -1,4 +1,4 @@ export const availableProviders = [ - 'SteamGridDB', - 'retrogaming.cloud' + 'SteamGridDB' + //,'GoogleImages' ]; diff --git a/src/lib/image-providers/index.ts b/src/lib/image-providers/index.ts index 40bd99d5a3..7e9fc807ee 100644 --- a/src/lib/image-providers/index.ts +++ b/src/lib/image-providers/index.ts @@ -1,4 +1,4 @@ export const imageProviders = { - 'SteamGridDB': require('./steamgriddb.worker'), - 'retrogaming.cloud': require('./retrogaming-cloud.worker') -} \ No newline at end of file + 'SteamGridDB': require('./steamgriddb.worker'), + //'GoogleImages': require('./googleimages.worker') +} diff --git a/src/lib/image-providers/retrogaming-cloud.worker.ts b/src/lib/image-providers/retrogaming-cloud.worker.ts deleted file mode 100644 index e91b86215b..0000000000 --- a/src/lib/image-providers/retrogaming-cloud.worker.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { GenericProvider, GenericProviderManager, ProviderProxy } from "./generic-provider"; -import { xRequestWrapper } from "./x-request-wrapper"; -import * as Bluebird from 'bluebird'; - -class RetrogamingCloudProvider extends GenericProvider { - private xrw: xRequestWrapper; - - constructor(protected proxy: ProviderProxy) { - super(proxy); - this.xrw = new xRequestWrapper(proxy, true, 3, 3000); - } - - retrieveUrls() { - this.retrieveImageList().then((listData) => { - if (listData.length > 0) { - this.xrw.setSpecialErrors({ 404: { retryCount: 1, silent: true } }); - let promises: Bluebird[] = []; - for (let i = 0; i < listData.length; i++) { - if (this.proxy.filter && listData[i].name && !this.proxy.fuzzyMatcher.fuzzyEqual(this.proxy.title, listData[i].name, { removeBrackets: true, removeCharacters: true, replaceDiacritics: true })) - continue; - else { - if (listData[i].id !== undefined) - promises.push(this.retrieveMediaData(listData[i].id)); - if (listData[i].most_popular_media_url && (listData[i].most_popular_media_url as string).length > 0) { - this.proxy.image({ - imageProvider: 'retrogaming.cloud', - imageUrl: listData[i].most_popular_media_url, - imageUploader: listData[i].most_popular_media_created_by_name || undefined, - loadStatus: 'notStarted' - }); - } - } - } - return this.xrw.Bluebird.all(promises); - } - }).finally(() => { - this.proxy.completed(); - }); - } - - stopUrlDownload() { - this.xrw.cancel(); - } - - private retrieveImageList() { - return this.xrw.addPromise(this.xrw.get('http://retrogaming.cloud/api/v1/game', { name: `%${this.proxy.title}%` }).then((response) => { - return response != null ? (response.results || []) : []; - })); - } - - private retrieveMediaData(gameId: number) { - return this.xrw.addPromise(this.xrw.get(`http://retrogaming.cloud/api/v1/game/${gameId}/media`).then((response) => { - if (response !== null) { - let results = response.results || []; - - for (let i = 0; i < results.length; i++) { - if (results[i].url) { - this.proxy.image({ - imageProvider: 'retrogaming.cloud', - imageUrl: results[i].url, - imageUploader: results[i].created_by ? results[i].created_by.name : undefined, - loadStatus: 'notStarted' - }); - } - } - } - }).catch((error) => { - this.xrw.logError(error); - }).finally(() => { - return this.xrw.Bluebird.resolve(); - })); - } -} - -new GenericProviderManager(RetrogamingCloudProvider, 'retrogaming.cloud'); \ No newline at end of file diff --git a/src/models/language.model.ts b/src/models/language.model.ts index 06b5405712..be03bc4e3d 100644 --- a/src/models/language.model.ts +++ b/src/models/language.model.ts @@ -350,6 +350,7 @@ export interface languageStruct { validationErrors: { parserType__md: string, configTitle__md: string, + parserId__md: string, parserInput: { noInput: string, inputNotAvailable__i: string,//${name} diff --git a/src/models/preview.model.ts b/src/models/preview.model.ts index 88fe4eb968..ae36c692b7 100644 --- a/src/models/preview.model.ts +++ b/src/models/preview.model.ts @@ -3,7 +3,7 @@ import { Observable, BehaviorSubject } from "rxjs"; export type ImageDownloadStatus = 'notStarted' | 'downloading' | 'done' | 'failed'; export interface ImageContent { - imageProvider: 'SteamGridDB' | 'retrogaming.cloud' | 'ConsoleGrid' | 'Steam' | 'LocalStorage', + imageProvider: 'SteamGridDB' | 'GoogleImages' | 'Steam' | 'LocalStorage', imageUploader?: string, imageRes?: string, imageUrl: string, diff --git a/src/models/user-configuration.model.ts b/src/models/user-configuration.model.ts index 4c27997bcc..e272696767 100644 --- a/src/models/user-configuration.model.ts +++ b/src/models/user-configuration.model.ts @@ -1,6 +1,7 @@ export interface UserConfiguration { parserType: string, configTitle: string, + parserId: string, steamCategory: string, executableLocation: string, executableModifier: string, diff --git a/src/renderer/modifiers/app-settings.modifier.ts b/src/renderer/modifiers/app-settings.modifier.ts index 7709569300..49c9ffc551 100644 --- a/src/renderer/modifiers/app-settings.modifier.ts +++ b/src/renderer/modifiers/app-settings.modifier.ts @@ -7,8 +7,8 @@ export const appSettings: ValidatorModifier = { undefined: { 'version': { method: () => 0 }, 'enabledProviders': { - method: (oldValue) => Array.isArray(oldValue) ? oldValue.filter((val) => val !== "ConsoleGrid") : oldValue + method: (oldValue) => Array.isArray(oldValue) ? oldValue.filter((val) => val !== "ConsoleGrid" && val !== "retrogaming.cloud") : oldValue } } } -}; \ No newline at end of file +}; diff --git a/src/renderer/schemas/user-configuration.schema.ts b/src/renderer/schemas/user-configuration.schema.ts index a33f75d326..a1eb842a86 100644 --- a/src/renderer/schemas/user-configuration.schema.ts +++ b/src/renderer/schemas/user-configuration.schema.ts @@ -7,6 +7,7 @@ export const userConfiguration = { version: { type: 'number' }, parserType: { type: 'string', default: '', enum: availableParsers.concat('') }, configTitle: { type: 'string', default: '' }, + parserId: { type: 'string', default: '' }, steamCategory: { type: 'string', default: '' }, executableLocation: { type: 'string', default: '' }, executableModifier: { type: 'string', default: '"${exePath}"' }, diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index 90012dae33..eb7e3a882d 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -169,6 +169,8 @@ export class ParsersService { } case 'configTitle': return data ? null : this.lang.validationErrors.configTitle__md; + case 'parserId': + return data ? null : this.lang.validationErrors.parserId__md; case 'steamCategory': return this.validateVariableParserString(data || ''); case 'executableLocation': @@ -255,7 +257,7 @@ export class ParsersService { isConfigurationValid(config: UserConfiguration) { let simpleValidations: string[] = [ - 'parserType', 'configTitle', 'steamCategory', + 'parserType', 'configTitle', 'parserId', 'steamCategory', 'executableLocation', 'executableModifier', 'romDirectory', 'steamDirectory', 'startInDirectory', 'specifiedAccounts', 'titleFromVariable', 'titleModifier', 'executableArgs', @@ -321,6 +323,9 @@ export class ParsersService { let validatedConfigs: { saved: UserConfiguration, current: UserConfiguration }[] = []; let errorString: string = ''; for (let i = 0; i < data.length; i++) { + if(!data[i].parserId) { + data[i].parserId = Date.now().toString().concat(Math.floor(Math.random()*100000).toString()); + } if (this.validator.validate(data[i]).isValid()) validatedConfigs.push({ saved: data[i], current: null }); else From e9cea641eb5c75f2d517a12117fe1737ccb36ece Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 09:51:12 -0400 Subject: [PATCH 04/25] finished update user configurations mechanism --- src/renderer/services/parsers.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index eb7e3a882d..e852a45728 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -322,8 +322,10 @@ export class ParsersService { }).then((data) => { let validatedConfigs: { saved: UserConfiguration, current: UserConfiguration }[] = []; let errorString: string = ''; + let updateNeeded: boolean = false; for (let i = 0; i < data.length; i++) { if(!data[i].parserId) { + updatedNeeded = true; data[i].parserId = Date.now().toString().concat(Math.floor(Math.random()*100000).toString()); } if (this.validator.validate(data[i]).isValid()) @@ -340,6 +342,9 @@ export class ParsersService { })); } this.userConfigurations.next(validatedConfigs); + if(updateNeeded){ + this.saveUserConfigurations(); + } }).catch((error) => { this.loggerService.error(this.lang.error.readingConfiguration, { invokeAlert: true, alertTimeout: 5000 }); this.loggerService.error(error); From 2af35c545110721fb909e837db08ff869041cc4a Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 09:54:02 -0400 Subject: [PATCH 05/25] typo --- src/renderer/services/parsers.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index e852a45728..8ed403c5b3 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -325,7 +325,7 @@ export class ParsersService { let updateNeeded: boolean = false; for (let i = 0; i < data.length; i++) { if(!data[i].parserId) { - updatedNeeded = true; + updateNeeded = true; data[i].parserId = Date.now().toString().concat(Math.floor(Math.random()*100000).toString()); } if (this.validator.validate(data[i]).isValid()) @@ -342,7 +342,7 @@ export class ParsersService { })); } this.userConfigurations.next(validatedConfigs); - if(updateNeeded){ + if(updateNeeded) { this.saveUserConfigurations(); } }).catch((error) => { From ec69dd4788d994dacef30014d4a2bda3c157f937 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 10:15:16 -0400 Subject: [PATCH 06/25] still working on parser id --- src/renderer/services/parsers.service.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index 8ed403c5b3..b25637a7df 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -55,6 +55,11 @@ export class ParsersService { saveConfiguration(config: { saved: UserConfiguration, current: UserConfiguration }) { let userConfigurations = this.userConfigurations.getValue(); + if(config.saved.parserId){ + config.current.parserId = config.saved.parserId + } else { + config.current.parserId = this.newParserId() + } userConfigurations = userConfigurations.concat(_.cloneDeep(config)); this.userConfigurations.next(userConfigurations); this.saveUserConfigurations(); @@ -80,8 +85,10 @@ export class ParsersService { else userConfigurations[index] = { saved: userConfigurations[index].current, current: null }; } - else + else{ + config.parserId = userConfigurations[index].saved.parserId; userConfigurations[index] = { saved: config, current: null }; + } this.userConfigurations.next(userConfigurations); this.saveUserConfigurations(); @@ -89,6 +96,7 @@ export class ParsersService { setCurrentConfiguration(index: number, config: UserConfiguration) { let userConfigurations = this.userConfigurations.getValue(); + config.parserId = userConfigurations[index].saved.parserId; userConfigurations[index].current = config; this.userConfigurations.next(userConfigurations); } @@ -282,6 +290,10 @@ export class ParsersService { return true; } + private newParserId() { + return Date.now().toString().concat(Math.floor(Math.random()*100000).toString()); + } + private saveUserConfigurations() { return new Promise((resolve, reject) => { if (!this.savingIsDisabled) { @@ -326,7 +338,7 @@ export class ParsersService { for (let i = 0; i < data.length; i++) { if(!data[i].parserId) { updateNeeded = true; - data[i].parserId = Date.now().toString().concat(Math.floor(Math.random()*100000).toString()); + data[i].parserId = this.newParserId(); } if (this.validator.validate(data[i]).isValid()) validatedConfigs.push({ saved: data[i], current: null }); From 6319d7d518da0d62d9758c5c0092ab8d1ca07a4c Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 10:52:23 -0400 Subject: [PATCH 07/25] stuff might work --- src/renderer/services/parsers.service.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index b25637a7df..41f7b36d18 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -55,11 +55,7 @@ export class ParsersService { saveConfiguration(config: { saved: UserConfiguration, current: UserConfiguration }) { let userConfigurations = this.userConfigurations.getValue(); - if(config.saved.parserId){ - config.current.parserId = config.saved.parserId - } else { - config.current.parserId = this.newParserId() - } + config.saved.parserId = this.newParserId(); userConfigurations = userConfigurations.concat(_.cloneDeep(config)); this.userConfigurations.next(userConfigurations); this.saveUserConfigurations(); @@ -83,6 +79,7 @@ export class ParsersService { if (userConfigurations[index].current == null) return; else + userConfigurations[index].current.parserId = userConfigurations[index].saved.parserId; userConfigurations[index] = { saved: userConfigurations[index].current, current: null }; } else{ @@ -96,7 +93,6 @@ export class ParsersService { setCurrentConfiguration(index: number, config: UserConfiguration) { let userConfigurations = this.userConfigurations.getValue(); - config.parserId = userConfigurations[index].saved.parserId; userConfigurations[index].current = config; this.userConfigurations.next(userConfigurations); } From 0594211c49b065707af63b5db7b0cfa66f68929b Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 11:04:34 -0400 Subject: [PATCH 08/25] most things working; fixed duplicate hopefully --- CHANGELOG.md | 4 +--- src/lang/english/markdown/faq.md | 6 +++++- src/renderer/services/parsers.service.ts | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67c46c271a..8a33f8c31a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. -## 2.2.24 - 2020-05-12 +## 2.2.25 - 2020-05-12 ### Added * Setting for whether or not to delete shortcuts from disabled parsers -* Google Images as a provider -* Ability to specify Launch Args in a JSON file ### Changed * Removed retrogaming.cloud from list of image providers * Changed structure of AddedItemsV2.json to include Parser ID diff --git a/src/lang/english/markdown/faq.md b/src/lang/english/markdown/faq.md index 45d16b532a..597744bf11 100644 --- a/src/lang/english/markdown/faq.md +++ b/src/lang/english/markdown/faq.md @@ -101,4 +101,8 @@ Now parser can match any combination and is effectively case-insensitive. Techni ``` {*,*/*}/*/${title}.[nN][eE][sS] -``` \ No newline at end of file +``` + +## The Discord + +For further help, please see our [discord](https://discord.gg/nxxzBPJ). diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index 41f7b36d18..cc99e2c835 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -55,8 +55,9 @@ export class ParsersService { saveConfiguration(config: { saved: UserConfiguration, current: UserConfiguration }) { let userConfigurations = this.userConfigurations.getValue(); - config.saved.parserId = this.newParserId(); - userConfigurations = userConfigurations.concat(_.cloneDeep(config)); + let copy: { saved: UserConfiguration, current: UserConfiguration } = _.cloneDeep(config); + copy.saved.parserId = this.newParserId(); + userConfigurations = userConfigurations.concat(copy); this.userConfigurations.next(userConfigurations); this.saveUserConfigurations(); } From 965b200b1cff489ba58e5af23ebb97274f787241 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 11:37:23 -0400 Subject: [PATCH 09/25] fix validation issue for parser id --- src/renderer/components/parsers.component.ts | 4 +++- src/renderer/services/parsers.service.ts | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/parsers.component.ts b/src/renderer/components/parsers.component.ts index 6fec7eebf6..8dc2325aac 100644 --- a/src/renderer/components/parsers.component.ts +++ b/src/renderer/components/parsers.component.ts @@ -518,6 +518,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { private toClipboard() { let config = this.userForm.value as UserConfiguration; + config.parserId = this.configurationIndex===-1?'UNSAVED SO NO ID':this.parsersService.getParserId(this.configurationIndex); if (this.parsersService.isConfigurationValid(config)) { try { let text = ''; @@ -574,6 +575,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { private testForm() { let config = this.userForm.value as UserConfiguration; + config.parserId = this.configurationIndex===-1?'UNSAVED SO NO ID':this.parsersService.getParserId(this.configurationIndex); let successData: string = ''; let errorData: string = ''; @@ -604,7 +606,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { if (this.parsersService.isConfigurationValid(config)) { if (this.appSettings.clearLogOnTest) this.loggerService.clearLog(); - + success('Parser ID: '.concat(config.parserId)); this.parsersService.executeFileParser(config).then((dataArray) => { if (dataArray.parsedData.parsedConfigs.length > 0) { let data = dataArray.parsedData.parsedConfigs[0]; diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index cc99e2c835..f3c1029b93 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -286,6 +286,9 @@ export class ParsersService { return true; } + getParserId(configurationIndex: number) { + return this.userConfigurations.getValue()[configurationIndex].saved.parserId; + } private newParserId() { return Date.now().toString().concat(Math.floor(Math.random()*100000).toString()); From 0b7f88323f7b0b243f7a6d8d62ec4da1d92a5cb8 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 12:00:55 -0400 Subject: [PATCH 10/25] switched over to parser id for state management --- src/lang/english/markdown/about.md | 4 ++-- src/lib/file-parser.ts | 1 + src/lib/vdf-manager.ts | 7 +++---- src/models/parser.model.ts | 1 + src/models/preview.model.ts | 1 + src/renderer/services/preview.service.ts | 1 + 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/lang/english/markdown/about.md b/src/lang/english/markdown/about.md index c9f0bdd757..40a9f27ee8 100644 --- a/src/lang/english/markdown/about.md +++ b/src/lang/english/markdown/about.md @@ -12,12 +12,12 @@ In case you're having trouble with SRM, feel free to visit [Discord](https://dis * All releases can be downloaded from [here](https://github.com/doZennn/steam-rom-manager/releases). ## Contributors -* `FrogTheFrog` {.noWrap} - creator of SRM, no longer active. +* `FrogTheFrog`{.noWrap} - creator of SRM, no longer active. * `doZennn`{.noWrap} - helped before the initial release of SRM and many times after the release with various stuff. * `HE Spoke`{.noWrap} - responsible for creating community around SRM. Creator of [Steam](http://steamcommunity.com/groups/steamrommanager) and [Discord](https://discord.gg/nxxzBPJ) groups. Also manages issues in [Github](https://github.com/doZennn/steam-rom-manager). * `Choko`{.noWrap} - helps most users setup SRM in [Discord](https://discord.gg/nxxzBPJ). * `AlexDobeck`{.noWrap} - improved [retrogaming.cloud](http://retrogaming.cloud/) performance. -* `lontanadascienza` {.noWrap} - updated SRM to handle heroes, posters, logos. Some other stuff too. +* `lontanadascienza`{.noWrap} - updated SRM to handle heroes, posters, logos. Some other stuff too. ## Credits diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index a4abcceaa1..de3a9df286 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -145,6 +145,7 @@ export class FileParser { parsedConfigs.push({ configurationTitle: configs[i].configTitle, + parserId: configs[i].parserId, appendArgsToExecutable: configs[i].appendArgsToExecutable, shortcutPassthrough: configs[i].titleFromVariable.shortcutPassthrough, imageProviders: configs[i].imageProviders, diff --git a/src/lib/vdf-manager.ts b/src/lib/vdf-manager.ts index 94b6aca63d..49f77a6e26 100644 --- a/src/lib/vdf-manager.ts +++ b/src/lib/vdf-manager.ts @@ -120,14 +120,13 @@ export class VDF_Manager { if (listItem.shortcuts.invalid || listItem.addedItems.invalid || listItem.screenshots.invalid) return; let apps = previewData[steamDirectory][userId].apps; - // I should use all the just app id entries for building extraneous, but then remove them from the file let currentAppIds = Object.keys(previewData[steamDirectory][userId].apps) - let enabledParsers = Array.from(new Set(currentAppIds.map((appid:string)=> apps[appid].configurationTitle))); + let enabledParsers = Array.from(new Set(currentAppIds.map((appid:string)=> apps[appid].parserId))); let addedAppIds = Object.keys(listItem.addedItems.data); if(!deleteDisabledShortcuts) { addedAppIds = addedAppIds.filter((appid:string) => listItem.addedItems.data[appid]==='-legacy-' || enabledParsers.indexOf(listItem.addedItems.data[appid])>=0); } - let extraneousAppIds = addedAppIds.filter((appid:string) => currentAppIds.indexOf(appid)<0); // should actually do addedfromenabled \diff newids + let extraneousAppIds = addedAppIds.filter((appid:string) => currentAppIds.indexOf(appid)<0); listItem.screenshots.extraneous = extraneousAppIds; listItem.shortcuts.extraneous = extraneousAppIds; for (let appId in apps) { @@ -159,7 +158,7 @@ export class VDF_Manager { } - listItem.addedItems.addItem(appId, app.configurationTitle); // added app.configurationTitle + listItem.addedItems.addItem(appId, app.parserId); if (currentImage !== undefined && currentImage.imageProvider !== 'Steam') { listItem.screenshots.addItem({ appId: appId, title: app.title, url: currentImage.imageUrl }); } diff --git a/src/models/parser.model.ts b/src/models/parser.model.ts index 91cba870a9..aea63c0ef1 100644 --- a/src/models/parser.model.ts +++ b/src/models/parser.model.ts @@ -34,6 +34,7 @@ export interface ParsedUserConfigurationFile { export interface ParsedUserConfiguration { configurationTitle: string, + parserId: string, imageProviders: string[], steamDirectory: string, appendArgsToExecutable: boolean, diff --git a/src/models/preview.model.ts b/src/models/preview.model.ts index ae36c692b7..6f02106005 100644 --- a/src/models/preview.model.ts +++ b/src/models/preview.model.ts @@ -32,6 +32,7 @@ export interface PreviewDataApp { entryId: number, status: 'add' | 'skip' | 'remove', configurationTitle: string, + parserId: string, steamCategories: string[], imageProviders: string[], startInDirectory: string, diff --git a/src/renderer/services/preview.service.ts b/src/renderer/services/preview.service.ts index 16201e85f9..be37810c70 100644 --- a/src/renderer/services/preview.service.ts +++ b/src/renderer/services/preview.service.ts @@ -643,6 +643,7 @@ export class PreviewService { entryId: numberOfItems++, status: 'add', //TODO: change to this when "mark" feature is implemented: oldDataApp !== undefined ? oldDataApp.status : 'add', configurationTitle: config.configurationTitle, + parserId: config.parserId, steamCategories: file.steamCategories, startInDirectory: file.startInDirectory, imageProviders: config.imageProviders, From 13cbb90019118d99e0583ec62919aee1dcac4fe6 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 12:19:56 -0400 Subject: [PATCH 11/25] added number of titles info in a few places --- src/renderer/components/parsers.component.ts | 4 +++- src/renderer/templates/preview.component.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/parsers.component.ts b/src/renderer/components/parsers.component.ts index 8dc2325aac..d8a87e279a 100644 --- a/src/renderer/components/parsers.component.ts +++ b/src/renderer/components/parsers.component.ts @@ -607,6 +607,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { if (this.appSettings.clearLogOnTest) this.loggerService.clearLog(); success('Parser ID: '.concat(config.parserId)); + success(''); this.parsersService.executeFileParser(config).then((dataArray) => { if (dataArray.parsedData.parsedConfigs.length > 0) { let data = dataArray.parsedData.parsedConfigs[0]; @@ -641,7 +642,8 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { logSuccess(); logError(); this.loggerService.info(''); - + success(''); + success('Number of Titles: '.concat(data.files.length.toString())); for (let i = 0; i < data.files.length; i++) { success(''); success(this.lang.success.extractedTitle__i.interpolate({ diff --git a/src/renderer/templates/preview.component.html b/src/renderer/templates/preview.component.html index 7f8428e000..29b86b4d78 100644 --- a/src/renderer/templates/preview.component.html +++ b/src/renderer/templates/preview.component.html @@ -25,7 +25,7 @@
- {{previewData[steamDir][steamUser].username}} + {{previewData[steamDir][steamUser].username}} ({{previewData[steamDir][steamUser].apps.length}} titles)
@@ -153,4 +153,4 @@
{{lang.removeAppList}}
{{lang.stopUrlRetrieving}}
-
\ No newline at end of file +
From 37664625605b0d04ae5063bde4b9aa833916e027 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 12:43:25 -0400 Subject: [PATCH 12/25] keys pipe --- CHANGELOG.md | 4 +++- src/renderer/templates/preview.component.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a33f8c31a..0de98f8835 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file. ## 2.2.25 - 2020-05-12 ### Added * Setting for whether or not to delete shortcuts from disabled parsers +* Ability to see number of titles in preview and in test parser logs ### Changed -* Removed retrogaming.cloud from list of image providers +* Removed retrogaming.cloud from list of image providers (it is defunct) * Changed structure of AddedItemsV2.json to include Parser ID +* Added lontanadascienza as a contributor ### Fixed * A bunch of dead links in Readme and About Markdown diff --git a/src/renderer/templates/preview.component.html b/src/renderer/templates/preview.component.html index 29b86b4d78..d142549083 100644 --- a/src/renderer/templates/preview.component.html +++ b/src/renderer/templates/preview.component.html @@ -25,7 +25,7 @@
- {{previewData[steamDir][steamUser].username}} ({{previewData[steamDir][steamUser].apps.length}} titles) + {{previewData[steamDir][steamUser].username}} ({{(previewData[steamDir][steamUser].apps | keys).length}} titles)
From 4ded0a5c31272a550963ce8ba2def99991531b67 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 13:00:50 -0400 Subject: [PATCH 13/25] configuration title to parser id --- src/lib/vdf-added-items-file.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/vdf-added-items-file.ts b/src/lib/vdf-added-items-file.ts index 95b91275b7..4da48f8c21 100644 --- a/src/lib/vdf-added-items-file.ts +++ b/src/lib/vdf-added-items-file.ts @@ -60,7 +60,7 @@ export class VDF_AddedItemsFile { } } - addItem(appId: string, configurationTitle: string) { - this.fileData[appId] = configurationTitle; // true -> configurationTitle + addItem(appId: string, parserId: string) { + this.fileData[appId] = parserId; } } From 4512e4727c951a9fce57d513dcd16ddcb72dbc03 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 13:02:02 -0400 Subject: [PATCH 14/25] 2.2.25 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 241048ab2f..b58b98e3cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "steam-rom-manager", - "version": "2.2.23", + "version": "2.2.25", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0179752788..b25a931898 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "steam-rom-manager", - "version": "2.2.23", + "version": "2.2.25", "license": "GPL-3.0", "description": "An app for managing ROMs in Steam", "author": { From 0ab853072d51e1f4fb2cf047b47da6a161e72f76 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 13:15:00 -0400 Subject: [PATCH 15/25] made parserId optional as interface option (so presets don't have to have it) --- src/models/user-configuration.model.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/user-configuration.model.ts b/src/models/user-configuration.model.ts index e272696767..eceb37e105 100644 --- a/src/models/user-configuration.model.ts +++ b/src/models/user-configuration.model.ts @@ -1,7 +1,7 @@ export interface UserConfiguration { parserType: string, configTitle: string, - parserId: string, + parserId?: string, steamCategory: string, executableLocation: string, executableModifier: string, From f959cbdcfa740854e01f8f1d787284f619201c72 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 13:22:45 -0400 Subject: [PATCH 16/25] removed parser ID from schema for config presets hopefully --- src/models/user-configuration.model.ts | 2 +- src/renderer/schemas/config-presets.schema.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/user-configuration.model.ts b/src/models/user-configuration.model.ts index eceb37e105..e272696767 100644 --- a/src/models/user-configuration.model.ts +++ b/src/models/user-configuration.model.ts @@ -1,7 +1,7 @@ export interface UserConfiguration { parserType: string, configTitle: string, - parserId?: string, + parserId: string, steamCategory: string, executableLocation: string, executableModifier: string, diff --git a/src/renderer/schemas/config-presets.schema.ts b/src/renderer/schemas/config-presets.schema.ts index d82fae819a..546f4b09d3 100644 --- a/src/renderer/schemas/config-presets.schema.ts +++ b/src/renderer/schemas/config-presets.schema.ts @@ -7,7 +7,7 @@ export const configPresets = { "^.+$": (() => { let config = cloneDeep(userConfiguration); delete config.properties.version; - + delete config.properties.parserId; let addStrictValidation = (data: any) => { if (data['type'] === 'object') { if (data['properties'] !== undefined) { @@ -30,4 +30,4 @@ export const configPresets = { return config; })() } -}; \ No newline at end of file +}; From 98b0c1e42ad4949f8c0dfd8eda1e879b83886f0c Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 15:24:42 -0400 Subject: [PATCH 17/25] environment variables --- src/lib/file-parser.ts | 21 ++++++++++++++++++++- src/lib/replace-diacritics.ts | 6 +++--- src/models/app.model.ts | 5 +++-- src/models/parser.model.ts | 4 ++-- src/renderer/services/parsers.service.ts | 2 +- src/variables.ts | 7 ++++--- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index de3a9df286..1c02cb62a9 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -1,4 +1,4 @@ -import { UserConfiguration, ParsedUserConfiguration, ParsedData, ParsedUserConfigurationFile, ParsedDataWithFuzzy, userAccountData, ParserVariableData, AllVariables, CustomVariables } from '../models'; +import { UserConfiguration, ParsedUserConfiguration, ParsedData, ParsedUserConfigurationFile, ParsedDataWithFuzzy, userAccountData, ParserVariableData, AllVariables, EnvironmentVariables, CustomVariables } from '../models'; import { FuzzyService } from "../renderer/services"; import { VariableParser } from "./variable-parser"; import { APP } from '../variables'; @@ -198,6 +198,10 @@ export class FileParser { onlineImageQueries: undefined }); + // Variables on rom directory, start in path, executable path, steam directory too + configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : ''; let lastFile = parsedConfigs[i].files[parsedConfigs[i].files.length - 1]; let variableData = this.makeVariableData(configs[i], lastFile); @@ -496,6 +500,18 @@ export class FileParser { return { config, parsedConfig, resolvedGlobs, resolvedFiles }; }); } + private getEnvironmentVariable(variable: EnvironmentVariables) { + let output = variable as string; + switch (variable.toUpperCase()) { + case '/': + output = path.sep; + break; + case 'SRMDIR': + output = APP.srmpath; + break; + } + return output; + } private getVariable(variable: AllVariables, data: ParserVariableData) { const unavailable = 'undefined'; @@ -504,6 +520,9 @@ export class FileParser { case '/': output = path.sep; break; + case 'SRMDIR': + output = APP.srmpath; + break; case 'EXEDIR': output = data.executableLocation != undefined ? path.dirname(data.executableLocation) : unavailable; break; diff --git a/src/lib/replace-diacritics.ts b/src/lib/replace-diacritics.ts index c392169503..faf798abe3 100644 --- a/src/lib/replace-diacritics.ts +++ b/src/lib/replace-diacritics.ts @@ -7,11 +7,11 @@ declare global { } String.prototype.replaceDiacritics = function () { - return (this as String).replace(/[^A-Za-z0-9 ]/g, - function (char) { + return (this as String).replace(/[^A-Za-z0-9 ]/g, + function (char) { return diacriticList[char] || char; } ); } -export default undefined; \ No newline at end of file +export default undefined; diff --git a/src/models/app.model.ts b/src/models/app.model.ts index 8b60ac2b23..12d0f45c85 100644 --- a/src/models/app.model.ts +++ b/src/models/app.model.ts @@ -4,5 +4,6 @@ export interface GlobalContainer { lang: languageStruct, version: number, os: string, - arch: string -}; \ No newline at end of file + arch: string, + srmpath: string +}; diff --git a/src/models/parser.model.ts b/src/models/parser.model.ts index aea63c0ef1..f59ae4a0e9 100644 --- a/src/models/parser.model.ts +++ b/src/models/parser.model.ts @@ -84,9 +84,9 @@ export type NameVariables = 'EXENAME' | 'FILENAME'; export type ExtensionVariables = 'EXEEXT' | 'FILEEXT'; export type PathVariables = 'EXEPATH' | 'FILEPATH'; export type ParserVariables = 'TITLE' | 'FUZZYTITLE' | 'FINALTITLE'; -export type OtherVariables = '/'; +export type EnvironmentVariables = '/' | 'SRMDIR'; -export type AllVariables = DirectoryVariables | NameVariables | ExtensionVariables | PathVariables | ParserVariables | OtherVariables; +export type AllVariables = DirectoryVariables | NameVariables | ExtensionVariables | PathVariables | ParserVariables | EnvironmentVariables; export interface GenericParser { getParserInfo(): ParserInfo, diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index f3c1029b93..ba42ef68e1 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -179,7 +179,7 @@ export class ParsersService { case 'steamCategory': return this.validateVariableParserString(data || ''); case 'executableLocation': - return (data == null || data.length === 0 || this.validatePath(data || '')) ? null : this.lang.validationErrors.executable__md; + return (data == null || data.length === 0 || this.validateVariableParserString(data || '')) ? null : this.lang.validationErrors.executable__md; case 'romDirectory': return this.validatePath(data || '', true) ? null : this.lang.validationErrors.romDir__md; case 'steamDirectory': diff --git a/src/variables.ts b/src/variables.ts index ff89782214..e5cbab25df 100644 --- a/src/variables.ts +++ b/src/variables.ts @@ -7,6 +7,7 @@ export const languageManager = new LanguageManager(); export const APP: GlobalContainer = { lang: languageManager.getLanguage('English'), version: require('../package.json')['version'], - os: require('os-name')(os.platform(), os.release()), - arch: os.arch() -}; \ No newline at end of file + os: require('os-name')(os.platform(), os.release()), + arch: os.arch(), + srmpath: require('electron').remote.app.getAppPath() +}; From 5559468b69457609bbb599da3caeb9a62027bf18 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 16:23:00 -0400 Subject: [PATCH 18/25] process.env.PORTABLE --- src/lib/file-parser.ts | 4 ++-- src/models/app.model.ts | 2 +- src/renderer/services/parsers.service.ts | 7 ++++++- src/variables.ts | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index 1c02cb62a9..092f985269 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -507,7 +507,7 @@ export class FileParser { output = path.sep; break; case 'SRMDIR': - output = APP.srmpath; + output = APP.srmdir; break; } return output; @@ -521,7 +521,7 @@ export class FileParser { output = path.sep; break; case 'SRMDIR': - output = APP.srmpath; + output = APP.srmdir; break; case 'EXEDIR': output = data.executableLocation != undefined ? path.dirname(data.executableLocation) : unavailable; diff --git a/src/models/app.model.ts b/src/models/app.model.ts index 12d0f45c85..777b31dc7f 100644 --- a/src/models/app.model.ts +++ b/src/models/app.model.ts @@ -5,5 +5,5 @@ export interface GlobalContainer { version: number, os: string, arch: string, - srmpath: string + srmdir: string }; diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index ba42ef68e1..bc08ad3123 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -10,6 +10,7 @@ import { BehaviorSubject } from "rxjs"; import { APP } from '../../variables'; import * as json from "../../lib/helpers/json"; import * as paths from "../../paths"; +import * as path from 'path'; import * as schemas from '../schemas'; import * as modifiers from '../modifiers'; import * as fs from 'fs-extra'; @@ -179,7 +180,7 @@ export class ParsersService { case 'steamCategory': return this.validateVariableParserString(data || ''); case 'executableLocation': - return (data == null || data.length === 0 || this.validateVariableParserString(data || '')) ? null : this.lang.validationErrors.executable__md; + return (data == null || data.length === 0 || this.validateEnvironmentPath(data || '') ) ? null : this.lang.validationErrors.executable__md; case 'romDirectory': return this.validatePath(data || '', true) ? null : this.lang.validationErrors.romDir__md; case 'steamDirectory': @@ -260,6 +261,10 @@ export class ParsersService { } } + private validateEnvironmentPath(pathwithvar: string, checkForDirectory?:boolean) { + return this.validatePath(pathwithvar.replace(/\$\{srmdir\}/g, APP.srmdir).replace(/\$\{\/\}/g, path.sep),checkForDirectory) + } + isConfigurationValid(config: UserConfiguration) { let simpleValidations: string[] = [ 'parserType', 'configTitle', 'parserId', 'steamCategory', diff --git a/src/variables.ts b/src/variables.ts index e5cbab25df..c01aedd105 100644 --- a/src/variables.ts +++ b/src/variables.ts @@ -1,6 +1,7 @@ import { GlobalContainer } from "./models"; import { LanguageManager } from "./lib/language-manager"; import * as os from 'os'; +import * as process from 'process' export const languageManager = new LanguageManager(); @@ -9,5 +10,5 @@ export const APP: GlobalContainer = { version: require('../package.json')['version'], os: require('os-name')(os.platform(), os.release()), arch: os.arch(), - srmpath: require('electron').remote.app.getAppPath() + srmdir: process.env.PORTABLE_EXECUTABLE_DIR }; From 3f92057058cbc340e3220ed2f084c30c66e1322a Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 16:39:23 -0400 Subject: [PATCH 19/25] moved executable modification --- src/lib/file-parser.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index 092f985269..d6f7c31745 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -164,8 +164,12 @@ export class FileParser { parsedConfigs[i].failed.push(data[i].success[j].filePath); continue; } - + // Variables on rom directory, start in path, executable path, steam directory too + configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; let executableLocation = configs[i].executableLocation ? configs[i].executableLocation : data[i].success[j].filePath; + parsedConfigs[i].files.push({ steamCategories: undefined, executableLocation: executableLocation, @@ -198,11 +202,6 @@ export class FileParser { onlineImageQueries: undefined }); - // Variables on rom directory, start in path, executable path, steam directory too - configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : ''; - let lastFile = parsedConfigs[i].files[parsedConfigs[i].files.length - 1]; let variableData = this.makeVariableData(configs[i], lastFile); From 6d4d642381d978403ad46f52deec24accc6838a2 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 17:10:48 -0400 Subject: [PATCH 20/25] added environment variables to other fields --- src/lib/file-parser.ts | 11 ++++++++++- src/models/nested-form.model.ts | 4 +++- src/renderer/components/parsers.component.ts | 1 + src/renderer/services/parsers.service.ts | 6 +++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index d6f7c31745..684b6b8eb2 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -164,7 +164,16 @@ export class FileParser { parsedConfigs[i].failed.push(data[i].success[j].filePath); continue; } - // Variables on rom directory, start in path, executable path, steam directory too + // Parse environment variables on rom directory, start in path, executable path + configs[i].steamDirectory = vParser.setInput(configs[i].steamDirectory).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].romDirectory = vParser.setInput(configs[i].romDirectory).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].startInDirectory = vParser.setInput(configs[i].startInDirectory).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() }) : null; diff --git a/src/models/nested-form.model.ts b/src/models/nested-form.model.ts index ec0864640d..38ecc00857 100644 --- a/src/models/nested-form.model.ts +++ b/src/models/nested-form.model.ts @@ -89,6 +89,8 @@ export namespace NestedFormElement { onChange?: NestedInputChange; /** Optional */ onInfoClick?: NestedInputInfoClick; + /** Optional */ + highlight?: (input: string, tag: string) => string; constructor(init?: ObjectFields) { Object.assign(this, init); @@ -133,4 +135,4 @@ export namespace NestedFormElement { } export type NestedFormInputs = NestedFormElement.Input | /*NestedFormElement.Path | */ NestedFormElement.Select | NestedFormElement.Toggle; -export type NestedFormElements = NestedFormInputs | NestedFormElement.Group; \ No newline at end of file +export type NestedFormElements = NestedFormInputs | NestedFormElement.Group; diff --git a/src/renderer/components/parsers.component.ts b/src/renderer/components/parsers.component.ts index d8a87e279a..73dc656171 100644 --- a/src/renderer/components/parsers.component.ts +++ b/src/renderer/components/parsers.component.ts @@ -117,6 +117,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { }), executableLocation: new NestedFormElement.Path({ label: this.lang.label.executableLocation, + highlight: this.highlight.bind(this), onValidate: (self, path) => this.parsersService.validate(path[0] as keyof UserConfiguration, self.value), onInfoClick: (self, path) => { this.currentDoc.activePath = path.join(); diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index bc08ad3123..ce3534d591 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -182,11 +182,11 @@ export class ParsersService { case 'executableLocation': return (data == null || data.length === 0 || this.validateEnvironmentPath(data || '') ) ? null : this.lang.validationErrors.executable__md; case 'romDirectory': - return this.validatePath(data || '', true) ? null : this.lang.validationErrors.romDir__md; + return this.validateEnvironmentPath(data || '', true) ? null : this.lang.validationErrors.romDir__md; case 'steamDirectory': - return this.validatePath(data || '', true) ? null : this.lang.validationErrors.steamDir__md; + return this.validateEnvironmentPath(data || '', true) ? null : this.lang.validationErrors.steamDir__md; case 'startInDirectory': - return (data == null || data.length === 0 || this.validatePath(data || '', true)) ? null : this.lang.validationErrors.startInDir__md; + return (data == null || data.length === 0 || this.validateEnvironmentPath(data || '', true)) ? null : this.lang.validationErrors.startInDir__md; case 'specifiedAccounts': return this.validateVariableParserString(data || ''); case 'parserInputs': From 26c5b1c842fde492b27b0e338306fc53cba63364 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 17:23:37 -0400 Subject: [PATCH 21/25] hopefully fixed steam directory and rom directory --- src/lib/file-parser.ts | 36 ++++++++++++-------- src/renderer/components/parsers.component.ts | 3 ++ src/renderer/services/parsers.service.ts | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index 684b6b8eb2..9f4472f028 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -81,6 +81,24 @@ export class FileParser { return Promise.resolve().then(() => { let promises: Promise[] = []; + + // Parse environment variables on rom directory, start in path, executable path + configs[i].steamDirectory = vParser.setInput(configs[i].steamDirectory).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].romDirectory = vParser.setInput(configs[i].romDirectory).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].startInDirectory = vParser.setInput(configs[i].startInDirectory).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + + + + for (let i = 0; i < configs.length; i++) { let parser = this.getParserInfo(configs[i].parserType); @@ -164,19 +182,7 @@ export class FileParser { parsedConfigs[i].failed.push(data[i].success[j].filePath); continue; } - // Parse environment variables on rom directory, start in path, executable path - configs[i].steamDirectory = vParser.setInput(configs[i].steamDirectory).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - configs[i].romDirectory = vParser.setInput(configs[i].romDirectory).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - configs[i].startInDirectory = vParser.setInput(configs[i].startInDirectory).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; + let executableLocation = configs[i].executableLocation ? configs[i].executableLocation : data[i].success[j].filePath; parsedConfigs[i].files.push({ @@ -354,8 +360,8 @@ export class FileParser { for(let j=0; j < parsedConfigs[i].files.length; j++) { if(parsedConfigs[i].files[j].filePath.split('.').slice(-1)[0].toLowerCase()=='lnk') { shortcutPromises.push(getPath(parsedConfigs[i].files[j].filePath).then((actualPath: string)=>{ - parsedConfigs[i].files[j].modifiedExecutableLocation = "\"".concat(actualPath,"\""); - parsedConfigs[i].files[j].startInDirectory = path.dirname(actualPath); + parsedConfigs[i].files[j].modifiedExecutableLocation = "\"".concat(actualPath,"\""); + parsedConfigs[i].files[j].startInDirectory = path.dirname(actualPath); })) } } diff --git a/src/renderer/components/parsers.component.ts b/src/renderer/components/parsers.component.ts index 73dc656171..5c9d3238a5 100644 --- a/src/renderer/components/parsers.component.ts +++ b/src/renderer/components/parsers.component.ts @@ -137,6 +137,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { romDirectory: new NestedFormElement.Path({ directory: true, label: this.lang.label.romDirectory, + highlight: this.highlight.bind(this), onValidate: (self, path) => this.parsersService.validate(path[0] as keyof UserConfiguration, self.value), onInfoClick: (self, path) => { this.currentDoc.activePath = path.join(); @@ -146,6 +147,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { steamDirectory: new NestedFormElement.Path({ directory: true, label: this.lang.label.steamDirectory, + highlight: this.highlight.bind(this), onValidate: (self, path) => this.parsersService.validate(path[0] as keyof UserConfiguration, self.value), onInfoClick: (self, path) => { this.currentDoc.activePath = path.join(); @@ -155,6 +157,7 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { startInDirectory: new NestedFormElement.Path({ directory: true, label: this.lang.label.startInDirectory, + highlight: this.highlight.bind(this), isHidden: () => this.isHiddenMode(), onValidate: (self, path) => this.parsersService.validate(path[0] as keyof UserConfiguration, self.value), onInfoClick: (self, path) => { diff --git a/src/renderer/services/parsers.service.ts b/src/renderer/services/parsers.service.ts index ce3534d591..a894ae2be3 100644 --- a/src/renderer/services/parsers.service.ts +++ b/src/renderer/services/parsers.service.ts @@ -262,7 +262,7 @@ export class ParsersService { } private validateEnvironmentPath(pathwithvar: string, checkForDirectory?:boolean) { - return this.validatePath(pathwithvar.replace(/\$\{srmdir\}/g, APP.srmdir).replace(/\$\{\/\}/g, path.sep),checkForDirectory) + return this.validatePath(pathwithvar.replace(/\$\{srmdir\}/g, APP.srmdir).replace(/\$\{\/\}/g, path.sep), checkForDirectory) } isConfigurationValid(config: UserConfiguration) { From 468b2c2dcc9bf149f9b79606b0cbac2290be0575 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 17:29:54 -0400 Subject: [PATCH 22/25] pre parser added --- src/lib/file-parser.ts | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/file-parser.ts b/src/lib/file-parser.ts index 9f4472f028..8271579d9c 100644 --- a/src/lib/file-parser.ts +++ b/src/lib/file-parser.ts @@ -82,25 +82,25 @@ export class FileParser { return Promise.resolve().then(() => { let promises: Promise[] = []; - // Parse environment variables on rom directory, start in path, executable path - configs[i].steamDirectory = vParser.setInput(configs[i].steamDirectory).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - configs[i].romDirectory = vParser.setInput(configs[i].romDirectory).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - configs[i].startInDirectory = vParser.setInput(configs[i].startInDirectory).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - configs[i].executableLocation = vParser.setInput(configs[i].executableLocation).parse() ? vParser.replaceVariables((variable) => { - return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() - }) : null; - + let preParser = new VariableParser({ left: '${', right: '}' }); + for (let i = 0; i < configs.length; i++) { + let parser = this.getParserInfo(configs[i].parserType); + // Parse environment variables on rom directory, start in path, executable path + configs[i].steamDirectory = preParser.setInput(configs[i].steamDirectory).parse() ? preParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].romDirectory = preParser.setInput(configs[i].romDirectory).parse() ? preParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].startInDirectory = preParser.setInput(configs[i].startInDirectory).parse() ? preParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; + configs[i].executableLocation = preParser.setInput(configs[i].executableLocation).parse() ? preParser.replaceVariables((variable) => { + return this.getEnvironmentVariable(variable as EnvironmentVariables).trim() + }) : null; - for (let i = 0; i < configs.length; i++) { - let parser = this.getParserInfo(configs[i].parserType); steamDirectories.push({ directory: configs[i].steamDirectory, useCredentials: configs[i].userAccounts.useCredentials, data: [] }); @@ -360,8 +360,8 @@ export class FileParser { for(let j=0; j < parsedConfigs[i].files.length; j++) { if(parsedConfigs[i].files[j].filePath.split('.').slice(-1)[0].toLowerCase()=='lnk') { shortcutPromises.push(getPath(parsedConfigs[i].files[j].filePath).then((actualPath: string)=>{ - parsedConfigs[i].files[j].modifiedExecutableLocation = "\"".concat(actualPath,"\""); - parsedConfigs[i].files[j].startInDirectory = path.dirname(actualPath); + parsedConfigs[i].files[j].modifiedExecutableLocation = "\"".concat(actualPath,"\""); + parsedConfigs[i].files[j].startInDirectory = path.dirname(actualPath); })) } } From 59063e37150fc45f19f078d8f403dbb1ae3c5d4f Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 17:53:37 -0400 Subject: [PATCH 23/25] updated documentation to reflect environment variables --- src/lang/english/markdown/executable-location.md | 11 ++++++++++- src/lang/english/markdown/parser-variables.md | 7 +++++-- src/lang/english/markdown/rom-directory.md | 11 ++++++++++- src/lang/english/markdown/start-in-directory.md | 9 +++++++++ src/lang/english/markdown/steam-directory.md | 11 ++++++++++- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/lang/english/markdown/executable-location.md b/src/lang/english/markdown/executable-location.md index d016cc9fa3..1889ea1b89 100644 --- a/src/lang/english/markdown/executable-location.md +++ b/src/lang/english/markdown/executable-location.md @@ -8,4 +8,13 @@ In some cases you might want to run game from a some kind batch file which will ### So, how do I add files to Steam without default executable? -All files retrieved by a parser will be treated as executables instead. \ No newline at end of file +All files retrieved by a parser will be treated as executables instead. + +## Environment variables +These variables are pre parsed and can be used even in the Rom Directory, Steam Directory, Executable Location, and Start In Dir fields. +|Variable (case-insensitive)|Corresponding value| +|---:|:---| +|`${/}`|System specific directory separator: `\` or `/`| +|`${srmdir}`|Directory of portable SRM executable| + +The use of the variable `${srmdir}` is to make SRM fully portable, eg if you wanted to have the directory layout `D:\Games\Roms` and `D:\Games\PortableSRM\SRM.exe` then setting the field Roms Directory to be `${srmdir}${/}..${/}Roms` would allow you to move the Games directory somewhere else without breaking your setup. diff --git a/src/lang/english/markdown/parser-variables.md b/src/lang/english/markdown/parser-variables.md index 92004bfc39..a19fd6832b 100644 --- a/src/lang/english/markdown/parser-variables.md +++ b/src/lang/english/markdown/parser-variables.md @@ -91,8 +91,11 @@ file.dll file ``` -## Other variables - +## Environment variables +These variables are pre parsed and can be used even in the Rom Directory, Steam Directory, Executable Location, and Start In Dir fields. |Variable (case-insensitive)|Corresponding value| |---:|:---| |`${/}`|System specific directory separator: `\` or `/`| +|`${srmdir}`|Directory of portable SRM executable| + +The use of the variable `${srmdir}` is to make SRM fully portable, eg if you wanted to have the directory layout `D:\Games\Roms` and `D:\Games\PortableSRM\SRM.exe` then setting the field Roms Directory to be `${srmdir}${/}..${/}Roms` would allow you to move the Games directory somewhere else without breaking your setup. diff --git a/src/lang/english/markdown/rom-directory.md b/src/lang/english/markdown/rom-directory.md index 12e0c84750..33a9180fc0 100644 --- a/src/lang/english/markdown/rom-directory.md +++ b/src/lang/english/markdown/rom-directory.md @@ -1,3 +1,12 @@ # ROMs directory -Starting directory for game or app files. \ No newline at end of file +Starting directory for game or app files. + +## Environment variables +These variables are pre parsed and can be used even in the Rom Directory, Steam Directory, Executable Location, and Start In Dir fields. +|Variable (case-insensitive)|Corresponding value| +|---:|:---| +|`${/}`|System specific directory separator: `\` or `/`| +|`${srmdir}`|Directory of portable SRM executable| + +The use of the variable `${srmdir}` is to make SRM fully portable, eg if you wanted to have the directory layout `D:\Games\Roms` and `D:\Games\PortableSRM\SRM.exe` then setting the field Roms Directory to be `${srmdir}${/}..${/}Roms` would allow you to move the Games directory somewhere else without breaking your setup. diff --git a/src/lang/english/markdown/start-in-directory.md b/src/lang/english/markdown/start-in-directory.md index 23871d91f2..34b85aa810 100644 --- a/src/lang/english/markdown/start-in-directory.md +++ b/src/lang/english/markdown/start-in-directory.md @@ -9,3 +9,12 @@ This option allows you to specify any directory you want as a "Start In" directo ![Ner "Start In" directory](../../../assets/images/new-start-in-directory.png) {.fitImage .center} It is useful when you're using batch files to start emulator and a game, but emulator requires a specific "Start In" directory to work properly. + +## Environment variables +These variables are pre parsed and can be used even in the Rom Directory, Steam Directory, Executable Location, and Start In Dir fields. +|Variable (case-insensitive)|Corresponding value| +|---:|:---| +|`${/}`|System specific directory separator: `\` or `/`| +|`${srmdir}`|Directory of portable SRM executable| + +The use of the variable `${srmdir}` is to make SRM fully portable, eg if you wanted to have the directory layout `D:\Games\Roms` and `D:\Games\PortableSRM\SRM.exe` then setting the field Roms Directory to be `${srmdir}${/}..${/}Roms` would allow you to move the Games directory somewhere else without breaking your setup. diff --git a/src/lang/english/markdown/steam-directory.md b/src/lang/english/markdown/steam-directory.md index 3c1e0fa77c..e6f6b18221 100644 --- a/src/lang/english/markdown/steam-directory.md +++ b/src/lang/english/markdown/steam-directory.md @@ -4,4 +4,13 @@ Must be a valid Steam directory which contains Steam executable. In order for St ## How do I limit edited Steam accounts? -Enable **Show advanced options** and check **User accounts** option. \ No newline at end of file +Enable **Show advanced options** and check **User accounts** option. + +## Environment variables +These variables are pre parsed and can be used even in the Rom Directory, Steam Directory, Executable Location, and Start In Dir fields. +|Variable (case-insensitive)|Corresponding value| +|---:|:---| +|`${/}`|System specific directory separator: `\` or `/`| +|`${srmdir}`|Directory of portable SRM executable| + +The use of the variable `${srmdir}` is to make SRM fully portable, eg if you wanted to have the directory layout `D:\Games\Roms` and `D:\Games\PortableSRM\SRM.exe` then setting the field Roms Directory to be `${srmdir}${/}..${/}Roms` would allow you to move the Games directory somewhere else without breaking your setup. From 9d9f92f69a5f10ecc8a4a06e8a8b062947a5772d Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 17:55:20 -0400 Subject: [PATCH 24/25] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0de98f8835..9c0fcc5c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Added * Setting for whether or not to delete shortcuts from disabled parsers * Ability to see number of titles in preview and in test parser logs +* Environment variables ${/} and ${srmdir} that can be used even in steam directory, rom directory fields. ### Changed * Removed retrogaming.cloud from list of image providers (it is defunct) * Changed structure of AddedItemsV2.json to include Parser ID From d236adabd84f0a28937a54eae9dc6e0be34b8d97 Mon Sep 17 00:00:00 2001 From: cbartondock Date: Tue, 12 May 2020 22:12:25 -0400 Subject: [PATCH 25/25] Show whether running portable or not in logs --- src/lang/english/langData.ts | 7 ++++--- src/models/language.model.ts | 3 ++- src/renderer/components/parsers.component.ts | 6 +++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lang/english/langData.ts b/src/lang/english/langData.ts index cebeb9f2e2..57a3182853 100644 --- a/src/lang/english/langData.ts +++ b/src/lang/english/langData.ts @@ -179,9 +179,9 @@ export const EnglishLang: languageContainer = { selectLanguage: 'Select language:', resetFuzzy_desc: 'Reset fuzzy list:', resetFuzzy_btn: 'Reset', - showSteamImages: 'Show current Steam images', + showSteamImages: 'Show current Steam images by default', deleteDisabledShortcuts: 'Remove shortcuts for disabled parsers', - clearLogOnTest: 'Automatically clear log when before testing parser' + clearLogOnTest: 'Automatically clear log before testing parsers' }, placeholder: { noProviders: 'None' @@ -320,7 +320,8 @@ export const EnglishLang: languageContainer = { ] }, info: { - testStarting__i: 'Testing "${title}" parser (SRM version - ${version}).', + testStarting__i: 'Testing "${title}" parser (SRM version - ${version} ${portable}).', + opSys__i: 'Operating system is "${os}"', testCompleted: 'Parser test is completed.', nothingWasFound: 'Parser found nothing.', copiedToClipboard: 'Configuration copied to clipboard', diff --git a/src/models/language.model.ts b/src/models/language.model.ts index be03bc4e3d..61ce051296 100644 --- a/src/models/language.model.ts +++ b/src/models/language.model.ts @@ -232,7 +232,8 @@ export interface languageStruct { localIcons: string[] }, info: { - testStarting__i: string, //${title}, ${version} + testStarting__i: string, //${title}, ${version}, ${portable} + opSys__i: string, //${os} testCompleted: string, nothingWasFound: string, copiedToClipboard: string, diff --git a/src/renderer/components/parsers.component.ts b/src/renderer/components/parsers.component.ts index 5c9d3238a5..00fe4c231a 100644 --- a/src/renderer/components/parsers.component.ts +++ b/src/renderer/components/parsers.component.ts @@ -944,8 +944,12 @@ export class ParsersComponent implements AfterViewInit, OnDestroy { }); this.loggerService.info(this.lang.info.testStarting__i.interpolate({ title: config.configTitle || this.lang.text.noTitle, - version: APP.version + version: APP.version, + portable: APP.srmdir ? "Portable" : "Non-Portable" })); + this.loggerService.info(this.lang.info.opSys__i.interpolate({ + os: APP.os + })) this.router.navigateByUrl('/logger'); } else