Skip to content

Commit

Permalink
add in copy and paste of controller config directories and titles
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartondock committed Apr 19, 2024
1 parent 3b3487f commit afd9b45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/lib/controller-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))))
Expand All @@ -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']
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/templates/view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
<div class="infoLabel">
<span>{{controllerType.toUpperCase()}}</span>
</div>
<div class="infoArea">
<div class="infoArea" (click)=toClipboard(currentControllers[controllerType].title)>
<span>{{currentControllers[controllerType].title}}</span>
</div>
<div class="infoArea">
<span>{{currentControllers[controllerType].templateType}} ({{currentControllers[controllerType].mappingId}})</span>
<div class="infoArea" (click)=toClipboard(currentControllers[controllerType].templatePath)>
<span>{{currentControllers[controllerType].templatePath}}</span>
</div>
</div>
</div>
Expand Down

0 comments on commit afd9b45

Please sign in to comment.