Skip to content

Commit

Permalink
some progress, but annoying content bug reappeared predictably
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartondock committed Jun 10, 2024
1 parent 1049091 commit 6071a95
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 27 deletions.
61 changes: 42 additions & 19 deletions src/renderer/components/preview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, ChangeDetectionStrategy, ChangeDetectorRef, OnDestroy, Rende
import { ActivatedRoute } from '@angular/router';
import { Subscription, BehaviorSubject } from 'rxjs';
import { PreviewService, SettingsService, ImageProviderService, IpcService, UserExceptionsService } from "../services";
import { PreviewData, PreviewDataApp, PreviewDataApps, PreviewVariables, AppSettings, ImageContent, SelectItem, UserConfiguration, ArtworkViewType, ArtworkType, isArtworkType, ImageProviderType } from "../../models";
import { PreviewData, PreviewDataApp, PreviewDataApps, PreviewVariables, AppSettings, ImageContent, SelectItem, UserConfiguration, ArtworkViewType, ArtworkType, isArtworkType, ImageProviderType, UserExceptionData } from "../../models";
import { APP } from '../../variables';
import { FileSelector } from '../../lib';
import { artworkTypes, artworkViewTypes, artworkViewNames, artworkDimsDict } from '../../lib/artwork-types';
Expand Down Expand Up @@ -61,7 +61,7 @@ export class PreviewComponent implements OnDestroy {
detailsLoading: boolean = true;
showDetails: boolean = false;
detailsSearchText: string = '';
detailsDisplayTitle: string = '';
detailsException: UserExceptionData;

showExcludes: boolean = false;
excludedAppIds: {
Expand Down Expand Up @@ -394,6 +394,16 @@ export class PreviewComponent implements OnDestroy {
this.showDetails= true;
this.renderer.setStyle(this.elementRef.nativeElement, '--details-width', '50%', RendererStyleFlags2.DashCase);
this.changeDetectionRef.detectChanges()
const exceptionId = this.userExceptionsService.makeExceptionId(app.executableLocation, app.extractedTitle, app.parserType)
const existingException = this.userExceptionsService.getExceptionById(exceptionId);
this.detailsException = existingException ? _.cloneDeep(existingException) : {
newTitle: "",
searchTitle: "",
commandLineArguments: "",
excludeArtwork: false,
exclude: false,
timeStamp: undefined
}
this.detailsApp = {
appId: appId,
app: app,
Expand All @@ -403,14 +413,24 @@ export class PreviewComponent implements OnDestroy {
this.searchMatches(this.detailsApp.app.extractedTitle);
}

fixMatchSearch(sgdbId: string) {
this.detailsException.searchTitle = `\${gameid:${sgdbId}}`;
}

fixMatchTitle(sgdbId: string) {
this.detailsException.newTitle = this.matchFixDict[sgdbId].name;
}

fixMatch(sgdbId: string) {
this.matchFix = sgdbId;
this.fixMatchSearch(sgdbId);
this.fixMatchTitle(sgdbId);
}

clearDetails() {
this.detailsSearchText = '';
this.detailsDisplayTitle = '';
this.matchFix = '';
this.detailsException = undefined;
this.detailsApp = undefined;
}
closeDetails() {
Expand Down Expand Up @@ -463,34 +483,37 @@ export class PreviewComponent implements OnDestroy {
saveDetails() {
if(this.detailsApp) {
const {steamDirectory, userId, appId, app} = this.detailsApp;
const newTitle = this.detailsDisplayTitle || (this.matchFix ? this.matchFixDict[this.matchFix].name : "");
const {newTitle, searchTitle, commandLineArguments, excludeArtwork} = this.detailsException;
if(newTitle) {
this.previewData[steamDirectory][userId].apps[appId].title = newTitle;
if(superTypesMap[app.parserType] !== 'ArtworkOnly') {
const changedId = steam.generateAppId(app.executableLocation, newTitle);
this.previewData[steamDirectory][userId].apps[appId].changedId = changedId;
}
}
const newPool = this.matchFix ? `\$\{gameid:${this.matchFix}\}` : "";
if(newPool) {
if(commandLineArguments) {
this.previewData[steamDirectory][userId].apps[appId].argumentString = commandLineArguments;
}
if(searchTitle) {
for(const artworkType of artworkTypes) {
const oldPool = this.previewData[steamDirectory][userId].apps[appId].images[artworkType].imagePool;
this.previewData[steamDirectory][userId].apps[appId].images[artworkType].imagePool = newPool;
this.previewData[steamDirectory][userId].apps[appId].images[artworkType].imagePool = searchTitle;
this.previewData[steamDirectory][userId].apps[appId].images[artworkType].singleProviders.steam = undefined;
this.previewService.updateAppImages(newPool, oldPool, artworkType)
this.previewService.updateAppImages(searchTitle, oldPool, artworkType)
}
}

const exceptionId = this.userExceptionsService.makeExceptionId(app.executableLocation, app.extractedTitle, app.parserType);
this.userExceptionsService.addExceptionById(exceptionId, app.extractedTitle, {
newTitle: newTitle,
searchTitle: newPool,
timeStamp: Date.now(),
commandLineArguments: '',
exclude: false,
excludeArtwork: false
})
this.refreshAfterSavingDetails(steamDirectory,userId,appId);
if(newTitle||searchTitle||commandLineArguments||excludeArtwork) {
const exceptionId = this.userExceptionsService.makeExceptionId(app.executableLocation, app.extractedTitle, app.parserType);
this.userExceptionsService.addExceptionById(exceptionId, app.extractedTitle, {
newTitle: newTitle,
searchTitle: searchTitle,
commandLineArguments: commandLineArguments,
exclude: false,
excludeArtwork: false,
timeStamp: Date.now(),
})
this.refreshAfterSavingDetails(steamDirectory,userId,appId);
}
this.closeDetails();
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/styles/preview.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
--list-images-width: 0%;
--excludes-lower-width: 0%;
--filters-width: 0%;
--details-options-height: 330px;
grid-area: route;
grid-template-areas:
"upperMenu upperMenu upperMenu upperMenu upperMenu"
Expand Down Expand Up @@ -354,6 +355,11 @@
}

.detailsOptions {
position: fixed;
width: calc(var(--details-width) - 201px);
height: var(--details-options-height);
background-color: rgb(29,29,29);
opacity: 1;
padding: 1em 1em 0.5em 1em;
grid-area: detailsOptions;
.ngTextInput {
Expand Down Expand Up @@ -415,6 +421,7 @@
}
}
.appResults {
margin-top: calc(var(--details-options-height) + 2em);
grid-area: detailsList;
> .approw {
display: flex;
Expand Down Expand Up @@ -442,6 +449,15 @@
margin-left: 5em;
}
}
.appButtons {
margin-top: 1em;
margin-bottom: 2.5em;
.button {
@include button();
@include clickButtonColor(click-button);
margin-left: 1em;
}
}
}
}

Expand Down
50 changes: 42 additions & 8 deletions src/renderer/templates/preview.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,54 @@ <h1>Add your games to Steam</h1>
<div class="detailsOptions">
<div class="detailsException">
<div class="detailsExceptionSection">
<span>Title Override</span>
<span>Exceptions</span>
</div>
<div class="detailsExceptionField">
<div class="detailsExceptionText">
<ng-text-input
class="ngTextInput"
placeholder="Override Display Title (Optional)"
[(ngModel)]="detailsDisplayTitle"
placeholder="New Display Title (Optional)"
[(ngModel)]="detailsException.newTitle"
></ng-text-input>
</div>
<div class="detailsExceptionButton"
(click)="detailsDisplayTitle=detailsApp.app.extractedTitle"
(click)="detailsException.newTitle=detailsApp.app.extractedTitle"
>Use Original</div>
</div>
<div class="detailsExceptionField">
<div class="detailsExceptionText">
<ng-text-input
class="ngTextInput"
placeholder="New Image Search Title (Optional)"
[(ngModel)]="detailsException.searchTitle"
></ng-text-input>
</div>
<div class="detailsExceptionButton"
(click)="detailsException.searchTitle=detailsApp.app.extractedTitle"
>Use Original</div>
</div>
<div class="detailsExceptionField">
<div class="detailsExceptionText">
<ng-text-input
class="ngTextInput"
placeholder="New Commandline Arguments (Optional)"
[(ngModel)]="detailsException.commandLineArguments"
></ng-text-input>
</div>
</div>
<div class="detailsExceptionField">
<div class="detailsExceptionText">
<ng-toggle-button
class="ngToggleButton"
[(ngModel)]="detailsException.excludeArtwork"
>Local Artwork Only</ng-toggle-button>
</div>
</div>
<div class="detailsExceptionSection">
<span>Search SteamGridDB</span>
</div>
</div>
<div class="detailsExceptionSection">
<span>Fix Artwork and Title</span>
</div>

<div class="detailsSearch">
<ng-text-input
class="ngTextInput"
Expand All @@ -112,9 +142,13 @@ <h1>Add your games to Steam</h1>
<div class="approw" [class.selected]="matchFix == sgdbId" (click)="fixMatch(sgdbId)">
<div class="app" [style.backgroundImage]="setDetailsBackgroundImage(sgdbId) | cssUrl | safeStyle"></div>
<div class="apptitle">
<span>{{ matchFixDict[sgdbId].name }}</span>
<span>{{ matchFixDict[sgdbId].name }} <a class="button" href="https://www.steamgriddb.com/game/{{sgdbId}}">(SGDB)</a></span>
</div>
</div>
<div class="appButtons">
<div class="button" (click)="fixMatchSearch(sgdbId)">Search Title Only</div>
<div class="button" (click)="fixMatchTitle(sgdbId)">Display Title Only</div>
</div>
</ng-container>
</div>
</ng-container>
Expand Down

0 comments on commit 6071a95

Please sign in to comment.