Skip to content

Commit

Permalink
ability to undo excludes from preview
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartondock committed May 25, 2024
1 parent 275236b commit f993137
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lang/en-US/langStrings.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
"nothingWasFound": "Parser found nothing.",
"copiedToClipboard": "Configuration copied to clipboard",
"userExclusions": "User excluded:",
"excludedFileInfo__i": "[${index}/${total}]: ${filename}",
"excludedFileInfo__i": "[${index}/${total}]: ${filename}\n Excluded by \"${exceptionKey}\"",
"removingControllers__i": "Removing controller templates for parser: ${configTitle}",
"fetchingControllerTemplates": "Fetching controller templates"
},
Expand Down
4 changes: 2 additions & 2 deletions src/lib/file-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,12 @@ export class FileParser {
} else {
return extractedTitle == parsedConfig.files[j].extractedTitle;
}
}).map(x=>x[1]);
}).map(x=> {return {exceptionKey: x[0], ...x[1]}});

if(exceptionMatches.length) {
const exceptions = exceptionMatches[0];
if(exceptions && exceptions.exclude) {
parsedConfig.excluded.push(parsedConfig.files[j].filePath);
parsedConfig.excluded.push({exceptionKey: exceptions.exceptionKey, filePath: parsedConfig.files[j].filePath});
parsedConfig.files[j] = null;
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/parser.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface ParsedUserConfiguration {
missingUserAccounts: string[],
files: ParsedUserConfigurationFile[],
failed: string[],
excluded: string[]
excluded: {exceptionKey: string, filePath: string}[]
}

export interface ParserInputField {
Expand Down
1 change: 1 addition & 0 deletions src/models/preview.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export interface PreviewDataApps {

export interface PreviewDataUser {
username: string,
excluded: {exceptionKey: string, filePath: string}[],
apps: PreviewDataApps
}

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/parsers.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,8 @@ export class ParsersComponent implements AfterViewInit, OnDestroy {
this.loggerService.info(this.lang.info.excludedFileInfo__i.interpolate({
index: data.files.length+ data.failed.length + i + 1,
total: totalLength,
filename: data.excluded[i]
filename: data.excluded[i].filePath,
exceptionKey: data.excluded[i].exceptionKey
}));
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/components/preview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class PreviewComponent implements OnDestroy {
}
}
} = {};
excludePutBacks: {[exceptionKey: string]: boolean} = {};
exclusionCount: number = 0;

constructor(
Expand Down Expand Up @@ -539,11 +540,14 @@ export class PreviewComponent implements OnDestroy {
showExclusions() {
this.closeDetails();
this.closeListImages();
this.renderer.setStyle(this.elementRef.nativeElement, '--excludes-lower-width', '50%', RendererStyleFlags2.DashCase);
this.showExcludes = true;
}

cancelExcludes() {
this.showExcludes = false;
this.renderer.setStyle(this.elementRef.nativeElement, '--excludes-lower-width', '0%', RendererStyleFlags2.DashCase);

this.excludedAppIds = {};
this.exclusionCount = 0;
}
Expand Down Expand Up @@ -578,7 +582,12 @@ export class PreviewComponent implements OnDestroy {
excludeArtwork: false
})
}
const putBackKeys = Object.keys(this.excludePutBacks).filter(putBackKey=>this.excludePutBacks[putBackKey]);
for(const putBackKey of putBackKeys) {
this.userExceptionsService.putBack(putBackKey);
}
this.cancelExcludes();
this.generatePreviewData();
}

refreshImages(app: PreviewDataApp, artworkType?: ArtworkType) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/services/preview.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ export class PreviewService {
if (previewData[config.steamDirectory][userAccount.accountID] === undefined) {
previewData[config.steamDirectory][userAccount.accountID] = {
username: userAccount.name,
excluded: config.excluded,
apps: {}
};
}
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/services/user-exceptions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ export class UserExceptionsService {
});
}

putBack(exceptionKey: string) {
const newData = this.data.saved;
const currentEntry = newData.titles[exceptionKey]
if(currentEntry) {
if(currentEntry.commandLineArguments||currentEntry.newTitle||currentEntry.searchTitle||currentEntry.excludeArtwork) {
newData.titles[exceptionKey].exclude = false;
} else {
delete newData.titles[exceptionKey]
}
}
this.variableData.next({current: newData, saved: this.data.saved})
this.saveUserExceptions();
}

addExceptionById(exceptionId: string, extractedTitle: string, newException: UserExceptionData) {
let newData = this.data.saved;
const exceptionMatches = Object.keys(newData.titles).filter((exTitle: string) => {
Expand Down
40 changes: 31 additions & 9 deletions src/renderer/styles/preview.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@
--games-icon-height: 600px;
--details-width: 0%;
--list-images-width: 0%;
--excludes-lower-width: 0%;
--filters-width: 0%;
grid-area: route;
grid-template-areas:
"upperMenu upperMenu upperMenu upperMenu"
"excludes excludes excludes excludes"
"detailsUpper detailsUpper detailsUpper detailsUpper"
"listImagesUpper listImagesUpper listImagesUpper listImagesUpper"
"urls urls urls urls"
"filters entries detailsLower listImages"
"lowerMenu lowerMenu lowerMenu lowerMenu";
"upperMenu upperMenu upperMenu upperMenu upperMenu"
"excludes excludes excludes excludes excludes"
"detailsUpper detailsUpper detailsUpper detailsUpper detailsUpper"
"listImagesUpper listImagesUpper listImagesUpper listImagesUpper listImagesUpper"
"urls urls urls urls urls"
"filters entries detailsLower listImages excludesLower"
"lowerMenu lowerMenu lowerMenu lowerMenu lowerMenu";
grid-template-rows: auto auto auto auto auto 1fr auto;
grid-template-columns: var(--filters-width) auto var(--details-width) var(--list-images-width);
grid-template-columns: var(--filters-width) auto var(--details-width) var(--list-images-width) var(--excludes-lower-width);
.loadingSpinner {
&:before {
display: block;
Expand Down Expand Up @@ -315,6 +316,27 @@
}

}
.excludesLower {
@include webkitScrollbar(preview-scrollbar);
overflow-y: auto;
grid-area: excludesLower;
.title{
padding: 1em;
background-color: var(--color-preview-user-background);
color: var(--color-preview-text);
border-bottom: solid 1px var(--color-preview-user-background);
}
.currentExclude {
padding: 1em;
color: var(--color-preview-text);
border-top: solid 1px var(--color-preview-user-background);
border-bottom: solid 1px var(--color-preview-user-background);
&.isPutBack {
background-color: var(--color-ng-select-option-background-hover);
color: var(--color-ng-select-option-text-hover);
}
}
}
.detailsLower {
@include webkitScrollbar(preview-scrollbar);
grid-area: detailsLower;
Expand Down Expand Up @@ -428,7 +450,7 @@
.entries {
@include webkitScrollbar(preview-scrollbar);
overflow-y: auto;
&.detailsOpen,&.listImagesOpen {
&.detailsOpen,&.listImagesOpen, &.showExcludes {
::-webkit-scrollbar {
width: 0.75em;
}
Expand Down
22 changes: 20 additions & 2 deletions src/renderer/templates/preview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ <h1>Add your games to Steam</h1>

</ng-container>
</div>
<div class="excludesLower" *ngIf="showExcludes">
<div class="title">
<span>Put Back Titles</span>
</div>
<div class="currentExcludes">
<ng-container *ngFor="let steamDir of previewData | keys">
<ng-container *ngFor="let steamUser of previewData[steamDir] | keys">
<ng-container *ngFor="let currentExclude of previewData[steamDir][steamUser].excluded">
<div class="currentExclude"
(click)="excludePutBacks[currentExclude.exceptionKey]=!excludePutBacks[currentExclude.exceptionKey]"
[class.isPutBack]="excludePutBacks[currentExclude.exceptionKey]"
>{{currentExclude.filePath}}</div>
</ng-container>
</ng-container>
</ng-container>
</div>
</div>

<div class="urls" *ngIf="previewVariables.numberOfQueriedImages">
<div class="stopButton" (click)="stopImageRetrieving()">{{ lang.stopUrlRetrieving }}</div>
Expand Down Expand Up @@ -210,6 +227,7 @@ <h1>Add your games to Steam</h1>
*ngVar="{ hoverIndex: undefined, hoverType: undefined } as entries"
[class.detailsOpen]="!!this.detailsApp && showDetails"
[class.listImagesOpen]="!!currentApp && showListImages"
[class.showExcludes]="!!showExcludes"
(scroll)="onScroll()"
>
<ng-container *ngFor="let steamDir of previewData | keys">
Expand Down Expand Up @@ -637,7 +655,7 @@ <h1>Add your games to Steam</h1>
<div class="lowerRight">
<div class="button" (click)="exportSelection()" [attr.title]="'Export image choices'">{{ lang.exportSelections }}</div>
<div class="button" (click)="importSelection()" [attr.title]="'Import image choices'">{{ lang.importSelections }}</div>
<div class="button" (click)="showExclusions()">{{ "Exclude Games" }}</div>
<div class="button" (click)="showExclusions()" *ngIf="!showExcludes">{{ "Exclude Games" }}</div>
</div>
</ng-container>
<div
Expand Down Expand Up @@ -666,7 +684,7 @@ <h1>Add your games to Steam</h1>
<div class="button dangerousButton" (click)="remove()">{{ lang.removeAppList }}</div>
</div>
<div class="lowerRight">
<div class="button" (click)="showExclusions()">{{ "Exclude Games" }}</div>
<div class="button" (click)="showExclusions()" *ngIf="!showExcludes">{{ "Exclude Games" }}</div>
<div
class="button"
routerLink="/logger"
Expand Down

0 comments on commit f993137

Please sign in to comment.