diff --git a/src/lib/controller-manager.ts b/src/lib/controller-manager.ts index 90e5fade70..fab35eb246 100644 --- a/src/lib/controller-manager.ts +++ b/src/lib/controller-manager.ts @@ -64,9 +64,16 @@ export class ControllerManager { return list; } + static templatesUserDir(steamDirectory: string) { + return path.join(steamDirectory, 'steamapps', 'workshop', 'content', '241100') + } + + static templatesValveDir(steamDirectory: string) { + return path.join(steamDirectory, 'controller_base','templates') + } // Manage Templates static readTemplates(steamDirectory: string, controllerType: string) { - let templateDirUser = path.join(steamDirectory, 'steamapps', 'workshop', 'content', '241100') + let templateDirUser = this.templatesUserDir(steamDirectory); let filesUser = glob.sync('*/*', { dot: true, cwd: templateDirUser, absolute: true }); let parsedTemplatesUser: ControllerTemplate[] = filesUser.filter((f: string) => fs.lstatSync(f).isFile()) .map((f: string) => Object.assign({ mappingId: f.split(path.sep).slice(-2)[0] }, genericParser.parse(fs.readFileSync(f, 'utf-8')))) @@ -83,7 +90,7 @@ export class ControllerManager { })); parsedTemplatesUser.sort((a, b) => a.title.localeCompare(b.title)); - let templateDirValve = path.join(steamDirectory, 'controller_base', 'templates') + let templateDirValve = this.templatesValveDir(steamDirectory); let filesValve = glob.sync('*.vdf', { dot: true, cwd: templateDirValve, absolute: true }); let parsedTemplatesValve: ControllerTemplate[] = filesValve.map((f: string) => Object.assign({ mappingId: path.basename(f) }, genericParser.parse(fs.readFileSync(f, 'utf-8')))) .filter((x: any) => !!x['controller_mappings'] diff --git a/src/renderer/components/view.component.ts b/src/renderer/components/view.component.ts index 726ba9d56b..26c6e6b6b7 100644 --- a/src/renderer/components/view.component.ts +++ b/src/renderer/components/view.component.ts @@ -124,8 +124,7 @@ export class ViewComponent implements OnDestroy { if(appTemplates.length && appTemplates[0].title) { this.currentControllers[controllerType] = { title: appTemplates[0].title, - mappingId: mappingId, - templateType: appController.template ? 'Template' : 'Workshop' + templatePath: appController.template ? path.join(ControllerManager.templatesValveDir(steamDir),mappingId) : path.join(ControllerManager.templatesUserDir(steamDir), mappingId) } } } diff --git a/src/renderer/templates/view.component.html b/src/renderer/templates/view.component.html index fc4b39d075..07a3f353ac 100644 --- a/src/renderer/templates/view.component.html +++ b/src/renderer/templates/view.component.html @@ -91,11 +91,11 @@