From ab47ac88aab8afa74df12477df2595bd64bdd9c6 Mon Sep 17 00:00:00 2001 From: Nicklas Ronge Date: Sun, 14 Jun 2020 14:49:22 +0200 Subject: [PATCH] - added settings to header - added misc module - stash highlight - fixed error if ggg api is not reachable first time launching --- CHANGELOG.md | 11 +++++ manifest.json | 9 +++- src/app/app.module.ts | 4 +- src/app/core/annotation/annotation.service.ts | 9 ++++ src/app/core/config/hotkey.ts | 3 +- src/app/modules/misc/component/index.ts | 1 + .../misc-settings.component.html | 13 ++++++ .../misc-settings.component.scss | 0 .../misc-settings.component.spec.ts | 25 +++++++++++ .../misc-settings/misc-settings.component.ts | 13 ++++++ src/app/modules/misc/misc-feature-settings.ts | 5 +++ src/app/modules/misc/misc.module.ts | 45 +++++++++++++++++++ .../misc/service/misc-stash.service.ts | 42 +++++++++++++++++ .../trade-window/trade-window.component.html | 2 +- .../trade-window/trade-window.component.ts | 8 +++- .../component/header/header.component.html | 2 + .../component/header/header.component.scss | 7 +++ .../odk/component/header/header.component.ts | 8 ++++ .../module/poe/context/context.factory.ts | 11 ++++- .../shared/module/poe/stash/stash.service.ts | 31 +++++++++++++ src/assets/i18n/english.json | 2 +- src/assets/i18n/french.json | 2 +- src/assets/i18n/german.json | 2 +- src/assets/i18n/korean.json | 2 +- src/assets/i18n/polish.json | 2 +- src/assets/i18n/portuguese.json | 2 +- src/assets/i18n/russian.json | 2 +- src/assets/i18n/simplified-chinese.json | 2 +- src/assets/i18n/spanish.json | 2 +- src/assets/i18n/thai.json | 2 +- src/assets/i18n/traditional-chinese.json | 2 +- 31 files changed, 252 insertions(+), 19 deletions(-) create mode 100644 src/app/modules/misc/component/index.ts create mode 100644 src/app/modules/misc/component/misc-settings/misc-settings.component.html create mode 100644 src/app/modules/misc/component/misc-settings/misc-settings.component.scss create mode 100644 src/app/modules/misc/component/misc-settings/misc-settings.component.spec.ts create mode 100644 src/app/modules/misc/component/misc-settings/misc-settings.component.ts create mode 100644 src/app/modules/misc/misc-feature-settings.ts create mode 100644 src/app/modules/misc/misc.module.ts create mode 100644 src/app/modules/misc/service/misc-stash.service.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a1736d7..90003f4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 1.0.2 (x) + +- added misc module + - stash highlight on `alt+f` +- added trade module + - support for poe.app, poemap.live, poetrade, official trade + - view incoming/ outgoing trades + - invite/ trade player + - highlight item in stash +- fixed a first time launching error occuring if the GGG API could not be reached + ## 1.0.0 (2020-06-10) - added added a interactive introduction diff --git a/manifest.json b/manifest.json index 19b7d0f2..84edec45 100644 --- a/manifest.json +++ b/manifest.json @@ -105,7 +105,7 @@ "block_top_window_navigation": true, "disable_restore_animation": true, "disable_rightclick": true, - "transparent": true, + "transparent": true, "size": { "width": 1212, "height": 699 @@ -126,7 +126,7 @@ "height": 327 } }, - "annotation": { + "annotation": { "file": "dist/poe-overlay-overwolf/index.html", "in_game_only": true, "block_top_window_navigation": true, @@ -263,6 +263,11 @@ "bookmark6": { "title": "Open Bookmark 6", "action-type": "custom" + }, + "misc-stash-highlight": { + "title": "Highlight Item in Stash", + "action-type": "custom", + "default": "Alt+F" } }, "externally_connectable": { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8adc547c..d2209272 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -5,6 +5,7 @@ import { CommandsModule } from '@modules/commands/commands.module'; import { EvaluateModule } from '@modules/evaluate/evaluate.module'; import { InspectModule } from '@modules/inspect/inspect.module'; import { MarketModule } from '@modules/market/market.module'; +import { MiscModule } from '@modules/misc/misc.module'; import { ReplayModule } from '@modules/replay/replay.module'; import { TradeModule } from '@modules/trade/trade.module'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; @@ -29,10 +30,11 @@ import { LayoutModule } from './layout/layout.module'; // app EvaluateModule, MarketModule, - InspectModule, TradeModule, + InspectModule, CommandsModule, ReplayModule, + MiscModule, BookmarksModule ], providers: [{ provide: ErrorHandler, useClass: AppErrorHandler }], diff --git a/src/app/core/annotation/annotation.service.ts b/src/app/core/annotation/annotation.service.ts index e531560f..50015a26 100644 --- a/src/app/core/annotation/annotation.service.ts +++ b/src/app/core/annotation/annotation.service.ts @@ -44,6 +44,15 @@ const ANNOTATIONS: Annotation[] = [ } ] }, + // TODO + // { + // id: 'trade', + // children: [ + // { id: 'filter' }, + // { id: 'search' }, + // { id: 'reset' }, + // ] + // }, { id: 'evaluate', hotkey: Hotkey.Evaluate, diff --git a/src/app/core/config/hotkey.ts b/src/app/core/config/hotkey.ts index fd949fb1..239efb5f 100644 --- a/src/app/core/config/hotkey.ts +++ b/src/app/core/config/hotkey.ts @@ -15,5 +15,6 @@ export enum Hotkey { Bookmark3 = 'bookmark3', Bookmark4 = 'bookmark4', Bookmark5 = 'bookmark5', - Bookmark6 = 'bookmark6' + Bookmark6 = 'bookmark6', + MiscStasHighlight = 'misc-stash-highlight' } diff --git a/src/app/modules/misc/component/index.ts b/src/app/modules/misc/component/index.ts new file mode 100644 index 00000000..a114620e --- /dev/null +++ b/src/app/modules/misc/component/index.ts @@ -0,0 +1 @@ +export * from './misc-settings/misc-settings.component'; diff --git a/src/app/modules/misc/component/misc-settings/misc-settings.component.html b/src/app/modules/misc/component/misc-settings/misc-settings.component.html new file mode 100644 index 00000000..6908f7cb --- /dev/null +++ b/src/app/modules/misc/component/misc-settings/misc-settings.component.html @@ -0,0 +1,13 @@ +
+
+ + + {{'app.hotkey' | translate}} + + + keyboard + + + +
+
\ No newline at end of file diff --git a/src/app/modules/misc/component/misc-settings/misc-settings.component.scss b/src/app/modules/misc/component/misc-settings/misc-settings.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/modules/misc/component/misc-settings/misc-settings.component.spec.ts b/src/app/modules/misc/component/misc-settings/misc-settings.component.spec.ts new file mode 100644 index 00000000..723f9e1a --- /dev/null +++ b/src/app/modules/misc/component/misc-settings/misc-settings.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MiscSettingsComponent } from './misc-settings.component'; + +describe('MiscSettingsComponent', () => { + let component: MiscSettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MiscSettingsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MiscSettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/modules/misc/component/misc-settings/misc-settings.component.ts b/src/app/modules/misc/component/misc-settings/misc-settings.component.ts new file mode 100644 index 00000000..5020cd8c --- /dev/null +++ b/src/app/modules/misc/component/misc-settings/misc-settings.component.ts @@ -0,0 +1,13 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { FeatureSettingsComponent } from '@app/feature'; +import { MiscFeatureSettings } from '@modules/misc/misc-feature-settings'; + +@Component({ + selector: 'app-misc-settings', + templateUrl: './misc-settings.component.html', + styleUrls: ['./misc-settings.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class MiscSettingsComponent extends FeatureSettingsComponent { + public load(): void { } +} diff --git a/src/app/modules/misc/misc-feature-settings.ts b/src/app/modules/misc/misc-feature-settings.ts new file mode 100644 index 00000000..1dcd6b27 --- /dev/null +++ b/src/app/modules/misc/misc-feature-settings.ts @@ -0,0 +1,5 @@ +import { FeatureSettings } from '@app/feature'; + +export interface MiscFeatureSettings extends FeatureSettings { + todo?: boolean; +} diff --git a/src/app/modules/misc/misc.module.ts b/src/app/modules/misc/misc.module.ts new file mode 100644 index 00000000..97c41fac --- /dev/null +++ b/src/app/modules/misc/misc.module.ts @@ -0,0 +1,45 @@ +import { NgModule } from '@angular/core'; +import { Hotkey } from '@app/config'; +import { Feature, FeatureConfig, FeatureModule, FEATURE_MODULES } from '@app/feature'; +import { SharedModule } from '@shared/shared.module'; +import { MiscSettingsComponent } from './component'; +import { MiscFeatureSettings } from './misc-feature-settings'; +import { MiscStashService } from './service/misc-stash.service'; + + +@NgModule({ + providers: [{ provide: FEATURE_MODULES, useClass: MiscModule, multi: true }], + declarations: [ + MiscSettingsComponent + ], + imports: [SharedModule] +}) +export class MiscModule implements FeatureModule { + constructor(private readonly miscStash: MiscStashService) { } + + public getConfig(): FeatureConfig { + const config: FeatureConfig = { + name: 'misc.name', + component: MiscSettingsComponent, + default: {} + }; + return config; + } + + public getFeatures(): Feature[] { + const features: Feature[] = [ + { hotkey: Hotkey.MiscStasHighlight } + ]; + return features; + } + + public onKeyPressed(hotkey: Hotkey): void { + switch (hotkey) { + case Hotkey.MiscStasHighlight: + this.miscStash.highlight().subscribe(); + break; + default: + throw new Error(`Hotkey: '${hotkey}' out of range.`); + } + } +} diff --git a/src/app/modules/misc/service/misc-stash.service.ts b/src/app/modules/misc/service/misc-stash.service.ts new file mode 100644 index 00000000..1ab82155 --- /dev/null +++ b/src/app/modules/misc/service/misc-stash.service.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core'; +import { NotificationService } from '@app/notification'; +import { ItemClipboardResultCode, ItemClipboardService } from '@shared/module/poe/item/clipboard'; +import { ItemSectionType } from '@shared/module/poe/item/clipboard/section-parser'; +import { StashService } from '@shared/module/poe/stash'; +import { Observable, of, throwError } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +@Injectable({ + providedIn: 'root' +}) +export class MiscStashService { + constructor( + private readonly stash: StashService, + private readonly itemClipboard: ItemClipboardService, + private readonly notification: NotificationService) { } + + public highlight(): Observable { + return this.itemClipboard.copy({ + [ItemSectionType.Rartiy]: true + }).pipe( + flatMap(({ code, item }) => { + switch (code) { + case ItemClipboardResultCode.Success: + if (item.type?.length) { + this.stash.highlight(item.type); + } + break; + case ItemClipboardResultCode.Empty: + this.notification.show('clipboard.empty'); + break; + case ItemClipboardResultCode.ParserError: + this.notification.show('clipboard.parser-error'); + break; + default: + return throwError(`code: '${code}' out of range`); + } + return of(null); + }) + ); + } +} diff --git a/src/app/modules/trade/window/trade-window/trade-window.component.html b/src/app/modules/trade/window/trade-window/trade-window.component.html index 0d494192..6b864571 100644 --- a/src/app/modules/trade/window/trade-window/trade-window.component.html +++ b/src/app/modules/trade/window/trade-window/trade-window.component.html @@ -2,7 +2,7 @@ + (pinnedChange)="onPinnedChange($event)" (settingsToggle)="onSettingsToggle()"> keyboard_arrow_down diff --git a/src/app/modules/trade/window/trade-window/trade-window.component.ts b/src/app/modules/trade/window/trade-window/trade-window.component.ts index 3c779af6..d9495fbd 100644 --- a/src/app/modules/trade/window/trade-window/trade-window.component.ts +++ b/src/app/modules/trade/window/trade-window/trade-window.component.ts @@ -1,6 +1,7 @@ import { ChangeDetectionStrategy, Component, NgZone, OnDestroy, OnInit } from '@angular/core'; import { EventSubscription } from '@app/event'; import { FeatureSettingsService } from '@app/feature/feature-settings.service'; +import { SettingsWindowService } from '@layout/service'; import { TradeWindowData, TradeWindowService } from '@modules/trade/service'; import { TradeFeatureSettings } from '@modules/trade/trade-feature-settings'; import { TradeExchangeMessage } from '@shared/module/poe/trade/chat'; @@ -21,7 +22,8 @@ export class TradeWindowComponent implements OnInit, OnDestroy { constructor( private readonly window: TradeWindowService, private readonly ngZone: NgZone, - private readonly settings: FeatureSettingsService) { } + private readonly settings: FeatureSettingsService, + private readonly settingsWindow: SettingsWindowService) { } public ngOnInit(): void { this.data$.next(this.window.data$.get()); @@ -45,4 +47,8 @@ export class TradeWindowComponent implements OnInit, OnDestroy { settings.tradeWindowPinned = pinned ).subscribe(); } + + public onSettingsToggle(): void { + this.settingsWindow.toggle('trade.name').subscribe(); + } } diff --git a/src/app/shared/module/odk/component/header/header.component.html b/src/app/shared/module/odk/component/header/header.component.html index 9b86af77..c28bf79d 100644 --- a/src/app/shared/module/odk/component/header/header.component.html +++ b/src/app/shared/module/odk/component/header/header.component.html @@ -8,6 +8,8 @@ close push_pin + settings +
diff --git a/src/app/shared/module/odk/component/header/header.component.scss b/src/app/shared/module/odk/component/header/header.component.scss index 0d5423fa..faf2c1cb 100644 --- a/src/app/shared/module/odk/component/header/header.component.scss +++ b/src/app/shared/module/odk/component/header/header.component.scss @@ -14,6 +14,10 @@ $border-color: #1a1a1a; width: $icon-size; font-size: $icon-size; line-height: $icon-size; + + & + .mat-icon{ + margin-left: 3px; + } } } } @@ -48,12 +52,15 @@ $border-color: #1a1a1a; left: 10px; } + .settings, .pin { height: $icon-size - 3px; width: $icon-size - 3px; font-size: $icon-size - 3px; line-height: $icon-size - 3px; + } + .pin { will-change: transform, top; transition: transform ease-in-out 200ms, top ease-in 100ms; diff --git a/src/app/shared/module/odk/component/header/header.component.ts b/src/app/shared/module/odk/component/header/header.component.ts index 47b355ea..040b2803 100644 --- a/src/app/shared/module/odk/component/header/header.component.ts +++ b/src/app/shared/module/odk/component/header/header.component.ts @@ -40,6 +40,9 @@ export class HeaderComponent implements OnInit { @Input() public margin: number; + @Output() + public settingsToggle = new EventEmitter(); + public ngOnInit(): void { this.obtained$ = this.window.assureObtained() .pipe( @@ -68,4 +71,9 @@ export class HeaderComponent implements OnInit { this.pinned = !this.pinned; this.pinnedChange.next(this.pinned); } + + public onSettings(event: MouseEvent): void { + event.preventDefault(); + this.settingsToggle.next(); + } } diff --git a/src/app/shared/module/poe/context/context.factory.ts b/src/app/shared/module/poe/context/context.factory.ts index 691f7c7e..1d30b487 100644 --- a/src/app/shared/module/poe/context/context.factory.ts +++ b/src/app/shared/module/poe/context/context.factory.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { Observable, of } from 'rxjs'; +import { catchError, map } from 'rxjs/operators'; import { TradeLeaguesProvider } from '../trade/leagues/trade-leagues.provider'; import { Context } from './context'; @@ -12,6 +12,13 @@ export class ContextFactory { public create(context: Context): Observable { return this.leaguesProvider.provide(context.language).pipe( + catchError(error => { + console.error(`Could not establish a connection to the GGG API: ${error?.message ?? JSON.stringify(error)}`); + return of([ + { id: 'Standard', text: 'Standard' }, + { id: 'Hardcore', text: 'Hardcore' } + ]); + }), map(leagues => { const result: Context = { ...context, diff --git a/src/app/shared/module/poe/stash/stash.service.ts b/src/app/shared/module/poe/stash/stash.service.ts index 3fdd8805..8440a6c5 100644 --- a/src/app/shared/module/poe/stash/stash.service.ts +++ b/src/app/shared/module/poe/stash/stash.service.ts @@ -1,13 +1,44 @@ import { Injectable } from '@angular/core'; import { OWUtils } from '@app/odk/ow-utils'; +import { Subject } from 'rxjs'; +import { delay, mergeMap, tap } from 'rxjs/operators'; import { StashPriceTag } from './stash-price-tag'; +interface HighlightEvent { + term: string; +} + @Injectable({ providedIn: 'root' }) export class StashService { + private readonly queue$ = new Subject(); + + constructor() { + this.init(); + } + public copyPrice(tag: StashPriceTag): void { const content = `${tag.type} ${(tag.count ? `${tag.amount}/${tag.count}` : tag.amount)} ${tag.currency}`; OWUtils.placeOnClipboard(content); } + + public highlight(term: string): void { + this.queue$.next({ term }); + } + + private init(): void { + this.queue$.pipe( + mergeMap(event => OWUtils.getFromClipboard().pipe( + tap(() => OWUtils.placeOnClipboard(event.term)), + delay(10), + tap(() => OWUtils.sendKeyStroke('Ctrl+F')), + delay(175), + tap(() => OWUtils.sendKeyStroke('Ctrl+V')), + delay(75), + tap(text => OWUtils.placeOnClipboard(text)), + delay(10), + ), 1) + ).subscribe(); + } } diff --git a/src/assets/i18n/english.json b/src/assets/i18n/english.json index 7583e224..2e5892ba 100644 --- a/src/assets/i18n/english.json +++ b/src/assets/i18n/english.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Highlight", + "highlight": "Stash Highlight", "name": "Misc", "navigation": "Navigation", "navigations": { diff --git a/src/assets/i18n/french.json b/src/assets/i18n/french.json index 25072e83..8c38213c 100644 --- a/src/assets/i18n/french.json +++ b/src/assets/i18n/french.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Surbrillance", + "highlight": "Surbrillance Stash", "name": "Divers", "navigation": "Défilement", "navigations": { diff --git a/src/assets/i18n/german.json b/src/assets/i18n/german.json index 98e05c47..003478ab 100644 --- a/src/assets/i18n/german.json +++ b/src/assets/i18n/german.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Markieren", + "highlight": "Stash Highlight", "name": "Sonstiges", "navigation": "Navigation", "navigations": { diff --git a/src/assets/i18n/korean.json b/src/assets/i18n/korean.json index 523c0516..b48750f2 100644 --- a/src/assets/i18n/korean.json +++ b/src/assets/i18n/korean.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "가장 밝은 부분", + "highlight": "스 태쉬 하이라이트", "name": "기타", "navigation": "항해", "navigations": { diff --git a/src/assets/i18n/polish.json b/src/assets/i18n/polish.json index 9da50032..82eac6ff 100644 --- a/src/assets/i18n/polish.json +++ b/src/assets/i18n/polish.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Podświetl przedmiot", + "highlight": "Podświetl Skrytkę", "name": "Różne", "navigation": "Przełączanie pomiędzy zakładkami", "navigations": { diff --git a/src/assets/i18n/portuguese.json b/src/assets/i18n/portuguese.json index acfd0e63..a75e391a 100644 --- a/src/assets/i18n/portuguese.json +++ b/src/assets/i18n/portuguese.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Realçar", + "highlight": "Stash Highlight", "name": "Misc", "navigation": "Navegação", "navigations": { diff --git a/src/assets/i18n/russian.json b/src/assets/i18n/russian.json index d03fff6e..d6cc3eb4 100644 --- a/src/assets/i18n/russian.json +++ b/src/assets/i18n/russian.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Выделить", + "highlight": "Stash Highlight", "name": "Разное", "navigation": "Навигация", "navigations": { diff --git a/src/assets/i18n/simplified-chinese.json b/src/assets/i18n/simplified-chinese.json index b85ee57e..5c9aca11 100644 --- a/src/assets/i18n/simplified-chinese.json +++ b/src/assets/i18n/simplified-chinese.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "突出", + "highlight": "隐藏重点", "name": "杂项", "navigation": "导航", "navigations": { diff --git a/src/assets/i18n/spanish.json b/src/assets/i18n/spanish.json index b41769fd..4885c5c5 100644 --- a/src/assets/i18n/spanish.json +++ b/src/assets/i18n/spanish.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "Realce", + "highlight": "Stash Highlight", "name": "Misceláneos", "navigation": "Navegación", "navigations": { diff --git a/src/assets/i18n/thai.json b/src/assets/i18n/thai.json index 56b75b9f..201e0e8c 100644 --- a/src/assets/i18n/thai.json +++ b/src/assets/i18n/thai.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "ไฮไลท์", + "highlight": "ไฮไลต์ที่เก็บ", "name": "อื่น ๆ", "navigation": "การเดินเรือ", "navigations": { diff --git a/src/assets/i18n/traditional-chinese.json b/src/assets/i18n/traditional-chinese.json index 3d1ff962..5b830236 100644 --- a/src/assets/i18n/traditional-chinese.json +++ b/src/assets/i18n/traditional-chinese.json @@ -318,7 +318,7 @@ } }, "misc": { - "highlight": "突出", + "highlight": "隱藏重點", "name": "其它", "navigation": "導航", "navigations": {