Skip to content

Commit

Permalink
Merge pull request #735 from Hyve747/trade
Browse files Browse the repository at this point in the history
Trade
  • Loading branch information
Kyusung4698 authored Jun 14, 2020
2 parents 0315e66 + 15f81d0 commit da7d4cf
Show file tree
Hide file tree
Showing 111 changed files with 3,478 additions and 203 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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, poe.trade, official trade
- view incoming/ outgoing trades
- invite/ trade player
- highlight items 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
Expand Down
22 changes: 20 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -126,7 +126,7 @@
"height": 327
}
},
"annotation": {
"annotation": {
"file": "dist/poe-overlay-overwolf/index.html",
"in_game_only": true,
"block_top_window_navigation": true,
Expand All @@ -150,6 +150,19 @@
"width": 1212,
"height": 699
}
},
"tradehighlight": {
"file": "dist/poe-overlay-overwolf/index.html",
"in_game_only": true,
"block_top_window_navigation": true,
"disable_restore_animation": true,
"disable_rightclick": true,
"transparent": true,
"resizable": true,
"size": {
"width": 1212,
"height": 699
}
}
},
"game_targeting": {
Expand Down Expand Up @@ -250,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": {
Expand Down
976 changes: 917 additions & 59 deletions overlay.babel

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.1",
"scripts": {
"watch": "ng build --watch",
"watch:prod": "ng build --watch --prod",
"lint": "ng lint --fix",
"test": "ng test",
"prepack": "ng build --prod",
Expand Down
1 change: 1 addition & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<app-launcher-window *ngSwitchCase="'launcher'"></app-launcher-window>
<app-annotation-window *ngSwitchCase="'annotation'"></app-annotation-window>
<app-trade-window *ngSwitchCase="'trade'"></app-trade-window>
<app-trade-highlight-window *ngSwitchCase="'tradehighlight'"></app-trade-highlight-window>
<div *ngSwitchDefault>Could not match window with name: {{window.name}}</div>
</ng-container>
</ng-container>
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 }],
Expand Down
9 changes: 9 additions & 0 deletions src/app/core/annotation/annotation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ const ANNOTATIONS: Annotation[] = [
}
]
},
// TODO
// {
// id: 'trade',
// children: [
// { id: 'filter' },
// { id: 'search' },
// { id: 'reset' },
// ]
// },
{
id: 'evaluate',
hotkey: Hotkey.Evaluate,
Expand Down
1 change: 1 addition & 0 deletions src/app/core/assets/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class AssetService {
this.import(Asset.StatsLocal, 'stats-local.json'),
this.import(Asset.Words, 'words.json'),
this.import(Asset.Maps, 'maps.json'),
this.import(Asset.TradeRegex, 'trade-regex.json'),
];
return forkJoin(tasks).pipe(
map(() => true)
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/assets/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export enum Asset {
Stats = 'stats',
StatsLocal = 'StatsLocal',
Words = 'Words',
Maps = 'Maps'
Maps = 'Maps',
TradeRegex = 'TradeRegex'
}
3 changes: 2 additions & 1 deletion src/app/core/config/hotkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export enum Hotkey {
Bookmark3 = 'bookmark3',
Bookmark4 = 'bookmark4',
Bookmark5 = 'bookmark5',
Bookmark6 = 'bookmark6'
Bookmark6 = 'bookmark6',
MiscStasHighlight = 'misc-stash-highlight'
}
3 changes: 2 additions & 1 deletion src/app/core/config/window-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export enum WindowName {
Replay = 'replay',
Launcher = 'launcher',
Annotation = 'annotation',
Trade = 'trade'
Trade = 'trade',
TradeHighlight = 'tradehighlight'
}
9 changes: 8 additions & 1 deletion src/app/core/feature/feature-settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UiLanguage } from '@app/config';
import { EventEmitter } from '@app/event';
import { Language } from '@data/poe/schema';
import { Observable } from 'rxjs';
import { flatMap } from 'rxjs/operators';
import { flatMap, tap } from 'rxjs/operators';
import { FeatureModule } from './feature-module';
import { FeatureSettings } from './feature-settings';
import { FeatureSettingsStorageService } from './feature-settings-storage.service';
Expand Down Expand Up @@ -32,6 +32,13 @@ export class FeatureSettingsService {
return this.featureSettingsStorageService.put(settings);
}

public update(updateFn: (settings: FeatureSettings) => void): Observable<FeatureSettings> {
return this.get().pipe(
tap(settings => updateFn(settings)),
flatMap(settings => this.put(settings))
);
}

public init(modules: FeatureModule<FeatureSettings>[]): Observable<FeatureSettings> {
return this.get().pipe(
flatMap(settings => {
Expand Down
1 change: 1 addition & 0 deletions src/app/core/helper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './roman';
34 changes: 34 additions & 0 deletions src/app/core/helper/roman.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* https://github.com/joshleaves/roman-numerals/ */
export class Roman {
public static toArabic(input: string): number {
const roman = input.toUpperCase().match(/^(M{0,3})(CM|DC{0,3}|CD|C{0,3})(XC|LX{0,3}|XL|X{0,3})(IX|VI{0,3}|IV|I{0,3})$/);
if (!roman) {
throw new Error('toArabic expects a valid roman number');
}

let arabic = 0;
arabic += roman[1].length * 1000;
if (roman[2] === 'CM') {
arabic += 900;
} else if (roman[2] === 'CD') {
arabic += 400;
} else {
arabic += roman[2].length * 100 + (roman[2][0] === 'D' ? 400 : 0);
}
if (roman[3] === 'XC') {
arabic += 90;
} else if (roman[3] === 'XL') {
arabic += 40;
} else {
arabic += roman[3].length * 10 + (roman[3][0] === 'L' ? 40 : 0);
}
if (roman[4] === 'IX') {
arabic += 9;
} else if (roman[4] === 'IV') {
arabic += 4;
} else {
arabic += roman[4].length * 1 + (roman[4][0] === 'V' ? 4 : 0);
}
return arabic;
}
}
5 changes: 4 additions & 1 deletion src/app/core/odk/ow-games-events-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ export class OWGamesEventsListener {
private readonly delegate: OWGamesEventListenerDelegate,
private readonly requiredFeatures: string[]) { }

public start(): Observable<boolean> {
public start(passive: boolean): Observable<boolean> {
this.unregisterEvents();
this.registerEvents();
if (passive) {
return of(true);
}
return this.setRequiredFeatures();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@ export class BackgroundWindowComponent implements OnInit, OnDestroy {
const path = info.executionPath.split('/');
path.pop();
const log = `${path.join('/')}/logs/Client.txt`;
console.log(log);
this.log.start(log);

forkJoin([
this.annotationWindow.open(info.width, info.height),
this.notificationWindow.open(info.width, info.height)
]).pipe(
flatMap(() => this.events.start()),
flatMap(() => this.events.start(false)),
).subscribe(result => {
this.settings.get().subscribe(settings => {
this.modules.forEach(module => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class SettingsWindowComponent implements OnInit, AfterViewInit, OnDestroy
this.settings$ = this.settings.get();
this.features = this.modules.map(x => x.getConfig());
this.queueSubscription = this.settingsQueue.pipe(
throttleTime(500),
throttleTime(500, undefined, { trailing: true, leading: false }),
flatMap(settings => this.settings.put(settings))
).subscribe();
this.dataSubscription = this.window.data$.on(({ activeFeature }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, OnDestroy, OnInit, Output, TemplateRef, ViewChild } from '@angular/core';
import { environment } from '@env/environment';
import { ChatService } from '@shared/module/poe/chat';
import { TradeFetchResultEntry, TradeFetchService } from '@shared/module/poe/trade';
import { TradeExchangeRequest, TradeExchangeResponse, TradeExchangeService } from '@shared/module/poe/trade/exchange';
Expand Down Expand Up @@ -104,13 +103,7 @@ export class MarketExchangeComponent implements OnInit, OnDestroy {
let copy = whisper.slice();
copy = copy.replace('{0}', `${event.itemAmount}`);
copy = copy.replace('{1}', `${event.valueAmount}`);

if (environment.production) {
this.chat.send(copy);
} else {
console.log(copy);
this.chat.send('/dnd');
}
this.chat.send(copy);
}

private clear(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, OnDestroy, OnInit, Output, TemplateRef, ViewChild } from '@angular/core';
import { environment } from '@env/environment';
import { ChatService } from '@shared/module/poe/chat';
import { TradeFetchEntryListing, TradeFetchResultEntry, TradeFetchService, TradeSearchRequest, TradeSearchResponse, TradeSearchService } from '@shared/module/poe/trade';
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
Expand Down Expand Up @@ -108,12 +107,7 @@ export class MarketItemSearchComponent implements OnInit, OnDestroy {
}

public onSend(listing: TradeFetchEntryListing): void {
if (environment.production) {
this.chat.send(listing.whisper);
} else {
console.log(listing.whisper);
this.chat.send('/dnd');
}
this.chat.send(listing.whisper);
}

private clear(): void {
Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/market/service/market-window.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { WindowName } from '@app/config';
import { OWGames, OWWindow } from '@app/odk';
import { WindowService } from '@shared/module/poe/window';
import { Observable, of } from 'rxjs';
import { flatMap } from 'rxjs/operators';

Expand All @@ -10,7 +11,7 @@ import { flatMap } from 'rxjs/operators';
export class MarketWindowService {
private readonly window: OWWindow;

constructor() {
constructor(private readonly poeWindow: WindowService) {
this.window = new OWWindow(WindowName.Market);
}

Expand All @@ -22,7 +23,7 @@ export class MarketWindowService {
}
return OWGames.getRunningGameInfo().pipe(
flatMap(({ height }) => {
const width = Math.round(height / 1.622);
const width = this.poeWindow.calculateWidth(height);
return this.window.changeSize(width * 2, height).pipe(
flatMap(() => this.window.changePosition(0, 0))
);
Expand Down
1 change: 1 addition & 0 deletions src/app/modules/misc/component/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './misc-settings/misc-settings.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="row">
<div class="col-md-6">
<app-card [title]="'misc.highlight' | translate">
<mat-form-field>
<mat-label>{{'app.hotkey' | translate}}</mat-label>
<input matInput [value]="'misc-stash-highlight' | hotkey" readonly>
<a matSuffix [href]="'misc-stash-highlight' | hotkeyUrl">
<mat-icon> keyboard </mat-icon>
</a>
</mat-form-field>
</app-card>
</div>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -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<MiscSettingsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MiscSettingsComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(MiscSettingsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -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<MiscFeatureSettings> {
public load(): void { }
}
5 changes: 5 additions & 0 deletions src/app/modules/misc/misc-feature-settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FeatureSettings } from '@app/feature';

export interface MiscFeatureSettings extends FeatureSettings {
todo?: boolean;
}
Loading

0 comments on commit da7d4cf

Please sign in to comment.