Skip to content

Commit

Permalink
- added stash folder support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyusung4698 committed Nov 8, 2020
1 parent 3275c13 commit 580fef4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface TradeHighlightWindowData {
stash?: string;
items: TradeHighlightItem[];
gridTop?: number;
gridTopFolder?: number;
gridSize?: number;
}

Expand All @@ -43,8 +44,8 @@ export class TradeHighlightWindowService {
return OWGames.getRunningGameInfo().pipe(
mergeMap(({ height }) => {
const width = this.poeWindow.calculateWidth(height);

data.gridTop = Math.round(height / 8.3);
data.gridTop = Math.round(height / 8.14);
data.gridTopFolder = Math.round(height / 6.43);
data.gridSize = Math.floor(width / 12);
for (let j = data.gridSize; j >= 1; --j) {
const fraction = width / j;
Expand Down
3 changes: 3 additions & 0 deletions src/app/modules/trade/trade-feature-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export interface TradeFeatureSettings extends FeatureSettings {
tradeStashFactor: {
[key: string]: number
};
tradeStashFolder: {
[key: string]: boolean
};
tradeSoundEnabled: boolean;
tradeSoundVolume: number;
tradeSound: string;
Expand Down
1 change: 1 addition & 0 deletions src/app/modules/trade/trade.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class TradeModule implements FeatureModule<TradeFeatureSettings> {
tradeMessageItemGone: 'Sorry, @itemname already gone. Good luck on your search.',
tradeMessageThanks: 'Thank you for the trade. Have a nice day and good luck.',
tradeStashFactor: {},
tradeStashFolder: {},
tradeWindowPinned: false,
tradeSoundEnabled: true,
tradeSoundVolume: 75,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
PoE Overlay - Trade Highlight - Stash: <span class="stash">{{data.stash || '-'}}</span>
</ng-container>
<ng-container ngProjectAs="controlsRight">
<mat-icon (click)="onFolderChange(data.stash)" [title]="'trade.stash-folder' | translate">
{{folder ? 'folder' : 'folder_open'}} </mat-icon>
<mat-icon (click)="onFactorChange(data.stash)" [title]="'trade.stash-size' | translate">
{{factor === 0.5 ? 'grid_on' : 'border_all'}} </mat-icon>
</ng-container>
</app-header>
<ng-container *ngIf="data.top && data.left">
<div class="grid" [style.top.px]="data.gridTop - 2" [style.width.px]="data.gridSize * 12"
[style.height.px]="data.gridSize * 12">
<div class="grid" [style.top.px]="(folder ? data.gridTopFolder : data.gridTop) - 2"
[style.width.px]="data.gridSize * 12" [style.height.px]="data.gridSize * 12">
<div class="inner">
<div class="highlight" [style.top.px]="data.gridSize * (data.top - 1) * factor - 0.25"
[style.left.px]="data.gridSize * (data.left - 1) * factor - 0.25"
Expand All @@ -19,7 +21,7 @@
</div>
</div>
</ng-container>
<app-background class="background" [inline]="true" [style.top.px]="data.gridTop + data.gridSize * 12">
<app-background class="background" [inline]="true" [style.top.px]="(folder ? data.gridTopFolder : data.gridTop) + data.gridSize * 12">
<div class="items">
<div class="item" *ngFor="let item of data.items">
<div class="name" (click)="onSearch(item.value || item.name)">{{item.name}}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class TradeHighlightWindowComponent implements OnInit, OnDestroy {
public data$ = new BehaviorSubject<TradeHighlightWindowData>(null);

public factor = TradeStashFactor.Normal;
public folder = false;

constructor(
private readonly window: TradeHighlightWindowService,
Expand All @@ -47,6 +48,15 @@ export class TradeHighlightWindowComponent implements OnInit, OnDestroy {
this.stash.highlight(item);
}

public onFolderChange(stash?: string): void {
this.folder = !this.folder;
if (stash) {
this.settings.update((settings: TradeFeatureSettings) => {
settings.tradeStashFolder[stash] = this.folder;
}).subscribe();
}
}

public onFactorChange(stash?: string): void {
this.factor = this.factor === TradeStashFactor.Quad
? TradeStashFactor.Normal : TradeStashFactor.Quad;
Expand All @@ -59,6 +69,7 @@ export class TradeHighlightWindowComponent implements OnInit, OnDestroy {

private updateData(data: TradeHighlightWindowData): void {
this.settings.get().subscribe((settings: TradeFeatureSettings) => {
this.folder = !!settings.tradeStashFolder[data.stash];
const factor = settings.tradeStashFactor[data.stash];
if (factor) {
this.factor = factor;
Expand Down

0 comments on commit 580fef4

Please sign in to comment.