Skip to content

Commit

Permalink
Merge pull request #250 from Kyusung4698/develop
Browse files Browse the repository at this point in the history
0.5.18
  • Loading branch information
Kyusung4698 committed Feb 19, 2020
2 parents c9d9730 + f632835 commit 28c8bde
Show file tree
Hide file tree
Showing 28 changed files with 8,233 additions and 8,078 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.5.18 (2020-02-19)

- add double click tray to open settings (#247)
- add browser use same scale as app (#214)
- add stack size amount to exchange rate (#227)
- update pseudo config (#230)
- update data to 3.9.2f
- fix blurry text after drag-drop (#214)

## 0.5.17 (2020-02-16)

- add `escape` to close browser (#222)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PoE Overlay 0.5.17
# PoE Overlay 0.5.18

An Overlay for Path of Exile. The ***core aspect*** is to blend in with the game. Built with Electron and Angular.

Expand Down Expand Up @@ -81,9 +81,9 @@ These instructions will set you up to run and enjoy the overlay.

1. Head over to [Releases](https://github.com/Kyusung4698/PoE-Overlay/releases) and download the latest zip
2. Extract zip
3. Run `poe-overlay 0.5.17.exe`
3. Run `poe-overlay 0.5.18.exe`
4. Start Path of Exile
5. Wait until you can see `PoE Overlay 0.5.17` in the bottom left corner
5. Wait until you can see `PoE Overlay 0.5.18` in the bottom left corner
6. Hit `f7` and set `Language` and `League` to meet your game settings

#### Shortcuts
Expand Down
3 changes: 2 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ function createTray(): Tray {

const menu = Menu.buildFromTemplate(items);
tray.setToolTip(`PoE-Overlay: ${version}`);
tray.setContextMenu(menu);
tray.setContextMenu(menu);
tray.on('double-click', () => win.webContents.send('show-user-settings'))
return tray;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": {
"name": "Kyusung4698"
},
"version": "0.5.17",
"version": "0.5.18",
"scripts": {
"postinstall": "npm run ng:cc && npm run electron:deps",
"ng:cc": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
Expand Down
7 changes: 6 additions & 1 deletion src/app/core/service/input/browser.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class BrowserService {
autoHideMenuBar: true,
width: 1400,
height: 800,
backgroundColor: '#0F0F0F'
backgroundColor: '#0F0F0F',
show: false
});

const close = win.close.bind(win);
Expand All @@ -50,6 +51,10 @@ export class BrowserService {
parent.setEnabled(true);
this.dialogs.remove(close);
});
win.once('ready-to-show', () => {
win.webContents.zoomFactor = parent.webContents.zoomFactor;
win.show();
});
win.loadURL(url);
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/app/core/service/input/shortcut.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, NgZone } from '@angular/core';
import { ElectronProvider } from '@app/provider';
import { VisibleFlag } from '@app/type/app.type';
import { GlobalShortcut, IpcRenderer } from 'electron';
import { IpcRenderer, Remote } from 'electron';
import { Observable, Subject } from 'rxjs';

export interface Shortcut {
Expand All @@ -16,16 +16,15 @@ export interface Shortcut {
})
export class ShortcutService {
private readonly ipcRenderer: IpcRenderer;
private readonly globalShortcut: GlobalShortcut;
private readonly remote: Remote;
private readonly shortcuts: Shortcut[] = [];

constructor(
private readonly ngZone: NgZone,
electronProvider: ElectronProvider) {
this.ipcRenderer = electronProvider.provideIpcRenderer();

const remote = electronProvider.provideRemote();
this.globalShortcut = remote.globalShortcut;
this.remote = electronProvider.provideRemote();
}

public add(accelerator: string, passive: boolean = false, active: VisibleFlag = VisibleFlag.Game): Observable<void> {
Expand Down Expand Up @@ -74,7 +73,7 @@ export class ShortcutService {
});
this.ipcRenderer.sendSync('register-shortcut', shortcut.accelerator);
} else {
this.globalShortcut.register(shortcut.accelerator, () => {
this.remote.globalShortcut.register(shortcut.accelerator, () => {
this.ngZone.run(() => shortcut.callback.next());
});
}
Expand All @@ -85,7 +84,7 @@ export class ShortcutService {
this.ipcRenderer.removeAllListeners(`shortcut-${shortcut.accelerator}`);
this.ipcRenderer.sendSync('unregister-shortcut', shortcut.accelerator);
} else {
this.globalShortcut.unregister(shortcut.accelerator);
this.remote.globalShortcut.unregister(shortcut.accelerator);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
<div appDrag=".cdk-overlay-pane">
<app-item-frame [item]="data.item" [language]="data.language" [queryItem]="queryItem"
(queryItemChange)="onQueryItemChange($event)" [separator]="true"
[modifier]="data.settings.evaluateModifierRange / 100"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,38 @@
<div class="factors">
<div *ngIf="(inverse$ | async) === false; else inverse">
<div class="factor">
<span class="amount">1.00&nbsp;</span>
<span class="amount-column">
<span class="amount">{{1 | number:'1.2-2'}}&nbsp;</span>
<span class="amount"
*ngIf="result.rate.factor > 1">{{result.rate.factor | number:'1.2-2'}}&nbsp;</span>
</span>
<mat-icon class="clickable switch" [title]="'evaluate.switch' | translate"
(click)="inverse$.next(!inverse$.value)">compare_arrows
</mat-icon>
<app-currency-frame class="clickable" (click)="onAmountClick()" [amount]="result.rate.amount" [currency]="result.rate.currency">
<span class="amount-column">
<span class="amount clickable" (click)="onAmountClick(result.rate.amount)">
{{result.rate.amount | number:'1.2-2'}}&nbsp;</span>
<span class="amount clickable"
(click)="onAmountClick(result.rate.amount * result.rate.factor)"
*ngIf="result.rate.factor > 1">
{{result.rate.amount * result.rate.factor | number:'1.2-2'}}&nbsp;</span>
</span>
<app-currency-frame class="clickable" [currency]="result.rate.currency">
</app-currency-frame>
</div>
</div>
<ng-template #inverse>
<div class="factor">
<span class="amount">{{result.rate.inverseAmount | number:'1.2-2'}}&nbsp;</span>
<span class="amount-column">
<span class="amount">{{result.rate.inverseAmount | number:'1.2-2'}}&nbsp;</span>
</span>
<mat-icon class="clickable switch" [title]="'evaluate.switch' | translate"
(click)="inverse$.next(!inverse$.value)">compare_arrows
</mat-icon>
<app-currency-frame [amount]="1" [currency]="result.rate.currency">
<span class="amount-column">
<span class="amount">{{1 | number:'1.2-2'}}&nbsp;</span>
</span>
<app-currency-frame [currency]="result.rate.currency">
</app-currency-frame>
</div>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
display: flex;
align-items: center;

.amount {
color: $light-grey;
.amount-column {
display: flex;
flex-direction: column;

.amount {
color: $light-grey;
line-height: 15px;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from
import { BrowserService } from '@app/service';
import { EvaluateResult } from '@modules/evaluate/type/evaluate.type';
import { SnackBarService } from '@shared/module/material/service';
import { ItemExchangeRateResult, ItemExchangeRateService } from '@shared/module/poe/service';
import { ItemExchangeRateResult, ItemExchangeRateService, PriceTagType } from '@shared/module/poe/service';
import { Currency, Item, ItemRarity } from '@shared/module/poe/type';
import { BehaviorSubject } from 'rxjs';

Expand Down Expand Up @@ -68,10 +68,11 @@ export class EvaluateExchangeRateComponent {
}
}

public onAmountClick(): void {
public onAmountClick(amount: number): void {
this.evaluateResult.next({
amount: this.result$.value.rate.amount,
amount,
currency: this.result$.value.rate.currency,
type: PriceTagType.Exact
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output
import { BrowserService } from '@app/service';
import { EvaluateResult } from '@modules/evaluate/type/evaluate.type';
import { SnackBarService } from '@shared/module/material/service';
import { ItemSearchAnalyzeResult, ItemSearchAnalyzeService, ItemSearchResult, ItemSearchService } from '@shared/module/poe/service';
import { ItemSearchAnalyzeResult, ItemSearchAnalyzeService, ItemSearchResult, ItemSearchService, PriceTagType } from '@shared/module/poe/service';
import { Currency, Item } from '@shared/module/poe/type';
import { ItemSearchIndexed, ItemSearchOptions } from '@shared/module/poe/type/search.type';
import { BehaviorSubject, Subject } from 'rxjs';
import { debounceTime, takeUntil, tap } from 'rxjs/operators';
import { EvaluateUserSettings, EvaluateResultView } from '../evaluate-settings/evaluate-settings.component';
import { EvaluateResultView, EvaluateUserSettings } from '../evaluate-settings/evaluate-settings.component';

const SEARCH_DEBOUNCE_TIME = 500;

Expand Down Expand Up @@ -115,7 +115,7 @@ export class EvaluateSearchComponent implements OnInit {

public onAmountSelect(amount: number): void {
const currency = this.result$.value.currency;
this.evaluateResult.next({ amount, currency });
this.evaluateResult.next({ amount, currency, type: PriceTagType.Exact });
}

private registerSearchOnChange(): void {
Expand Down
8 changes: 4 additions & 4 deletions src/app/modules/evaluate/service/evaluate.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { SnackBarService } from '@shared/module/material/service';
import { ItemClipboardResultCode, ItemClipboardService, StashService } from '@shared/module/poe/service';
import { ItemClipboardResultCode, ItemClipboardService, StashService, PriceTagType } from '@shared/module/poe/service';
import { Language } from '@shared/module/poe/type';
import { Observable, of, throwError } from 'rxjs';
import { catchError, flatMap } from 'rxjs/operators';
Expand Down Expand Up @@ -31,15 +31,15 @@ export class EvaluateService {
}

if (!this.stash.hovering(point)) {
this.stash.copyPrice(evaluate.amount, evaluate.currency);
this.stash.copyPrice(evaluate.amount, evaluate.currency, evaluate.type);
return this.snackbar.info('evaluate.tag.outside-stash');
}

if ((result.item.note || '').length > 0) {
this.stash.copyPrice(evaluate.amount, evaluate.currency);
this.stash.copyPrice(evaluate.amount, evaluate.currency, evaluate.type);
return this.snackbar.info('evaluate.tag.note');
}
return this.stash.tagPrice(evaluate.amount, evaluate.currency, result.rawPoint);
return this.stash.tagPrice(evaluate.amount, evaluate.currency, result.rawPoint, evaluate.type);
})
);
case ItemClipboardResultCode.Empty:
Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/evaluate/type/evaluate.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { PriceTagType } from '@shared/module/poe/service';
import { Currency } from '@shared/module/poe/type';

export interface EvaluateResult {
currency: Currency;
amount: number;
type: PriceTagType;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div cdkDrag cdkDragRootElement=".cdk-overlay-pane" cdkDragHandle>
<div appDrag=".cdk-overlay-pane">
<app-item-frame class="map-frame" [item]="data.item" [properties]="properties" [separator]="true" modifier="0"
modifierMaxRange="true">
<ng-container ngProjectAs="properties">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { DragDirective } from './drag.directive';
import { ElementRef } from '@angular/core';

describe('DragDirective', () => {
it('should create an instance', () => {
const directive = new DragDirective(new ElementRef<HTMLElement>(document.createElement('div')));
expect(directive).toBeTruthy();
});
});
98 changes: 98 additions & 0 deletions src/app/shared/module/material/directive/drag.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';
import { Point } from '@app/type';

@Directive({
selector: '[appDrag]'
})
export class DragDirective implements OnInit, OnDestroy {
private element: HTMLElement;

private pressed = false;
private dragging = false;

private pointerPosition: Point;
private position: Point;

@Input('appDrag')
public rootElementSelector: string;

constructor(private readonly elementRef: ElementRef<HTMLElement>) { }

public ngOnInit(): void {
if (this.rootElementSelector) {
this.element = getClosestMatchingAncestor(this.elementRef.nativeElement, this.rootElementSelector);
}
this.element = this.element || this.elementRef.nativeElement;
this.element.addEventListener('mousedown', this.mousedown, true);
this.element.addEventListener('mouseup', this.mouseup, true);
this.element.addEventListener('mousemove', this.mousemove, true);
}

public ngOnDestroy(): void {
this.element.removeEventListener('mousedown', this.mousedown);
this.element.removeEventListener('mouseup', this.mouseup);
this.element.removeEventListener('mousemove', this.mousemove);
}

private mousedown = (event: MouseEvent) => {
this.pressed = true;
this.pointerPosition = {
x: event.pageX,
y: event.pageY,
};
this.position = {
x: +this.element.style['margin-left'].replace('px', ''),
y: +this.element.style['margin-top'].replace('px', ''),
};
};

private mouseup = () => {
this.pressed = false;
this.dragging = false;
};

private mousemove = (event: MouseEvent) => {
if (!this.pressed) {
return;
}

if (!this.dragging) {
const distanceX = Math.abs(event.pageX - this.pointerPosition.x);
const distanceY = Math.abs(event.pageY - this.pointerPosition.y);

const isOverThreshold = distanceX + distanceY >= 5;
if (isOverThreshold) {
this.dragging = true;
}
}

if (!this.dragging) {
return;
}

const delta: Point = {
x: event.pageX - this.pointerPosition.x,
y: event.pageY - this.pointerPosition.y,
};

this.element.style['margin-left'] = `${this.position.x + delta.x}px`;
this.element.style['margin-top'] = `${this.position.y + delta.y}px`;
};
}

/** Gets the closest ancestor of an element that matches a selector. */
function getClosestMatchingAncestor(element: HTMLElement, selector: string) {
let currentElement = element.parentElement as HTMLElement | null;

while (currentElement) {
// IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
if (currentElement.matches ? currentElement.matches(selector) :
(currentElement as any).msMatchesSelector(selector)) {
return currentElement;
}

currentElement = currentElement.parentElement;
}

return null;
}
Loading

0 comments on commit 28c8bde

Please sign in to comment.