-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve view games, move some stuff into a service
- Loading branch information
1 parent
ef26554
commit e4e82f1
Showing
6 changed files
with
190 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { LoggerService, ParsersService } from '../services'; | ||
import { VDF_ListData, UserData, ControllerTemplates } from '../../models'; | ||
import * as _ from "lodash"; | ||
import { | ||
VDF_Manager, | ||
CategoryManager, | ||
ControllerManager, | ||
} from "../../lib"; | ||
import { controllerTypes } from '../../lib/controller-manager'; | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
|
||
@Injectable() | ||
export class ViewService { | ||
vdfData: VDF_ListData; | ||
controllerData: UserData; | ||
categoryData: UserData; | ||
controllerTemplateData: ControllerTemplates; | ||
status: {[k: string]: BehaviorSubject<boolean>} = { | ||
refreshingShortcuts: new BehaviorSubject(false), | ||
refreshingDetails: new BehaviorSubject(false) | ||
} | ||
constructor( | ||
private parsersService: ParsersService) { | ||
} | ||
|
||
private clearData() { | ||
this.vdfData = null; | ||
this.categoryData = {}; | ||
this.controllerData = {}; | ||
this.controllerTemplateData = {}; | ||
} | ||
|
||
async refreshGames(force?: boolean) { | ||
this.clearData(); | ||
this.status.refreshingShortcuts.next(true); | ||
this.status.refreshingDetails.next(true); | ||
let knownSteamDirectories = this.parsersService.getKnownSteamDirectories(); | ||
const vdfManager = new VDF_Manager(); | ||
const categoryManager = new CategoryManager(); | ||
const controllerManager = new ControllerManager(); | ||
await vdfManager.prepare(knownSteamDirectories); | ||
await vdfManager.read({ addedItems: false }); | ||
this.vdfData = vdfManager.vdfData; | ||
this.status.refreshingShortcuts.next(false); | ||
for(const steamDirectory in this.vdfData) { | ||
this.categoryData[steamDirectory] = {}; | ||
this.controllerData[steamDirectory] = {}; | ||
this.controllerTemplateData[steamDirectory] = {}; | ||
for(const userId in this.vdfData[steamDirectory]) { | ||
try { | ||
this.categoryData[steamDirectory][userId] = await categoryManager.readCategories(steamDirectory, userId); | ||
} catch (e) {} | ||
const configsetDir = ControllerManager.configsetDir(steamDirectory, userId); | ||
const localConfigPath = ControllerManager.localConfigPath(steamDirectory, userId); | ||
this.controllerData[steamDirectory][userId] = { | ||
configsets: controllerManager.readControllers(configsetDir), | ||
localConfig: controllerManager.readLocalConfig(localConfigPath), | ||
} | ||
} | ||
for(const controllerType of controllerTypes) { | ||
this.controllerTemplateData[steamDirectory][controllerType] = await ControllerManager.readTemplates(steamDirectory, controllerType) | ||
} | ||
} | ||
this.status.refreshingDetails.next(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.