Skip to content

Commit

Permalink
- added trade annotation
Browse files Browse the repository at this point in the history
- added trade incoming sound
  • Loading branch information
Kyusung4698 committed Jun 15, 2020
1 parent 5490976 commit 98e72c1
Show file tree
Hide file tree
Showing 45 changed files with 1,699 additions and 130 deletions.
6 changes: 6 additions & 0 deletions FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Quickly evaluate your items. Properties can be added and removed from the query

![Downloaded](img/feature_evaluate.jpg)

### Trade

Manage incoming and outgoing trade requests by sending messages, inviting players and initiating trades via simple clicks.

![Downloaded](img/feature_trade.jpg)

### Market

Filter the listings to find your perfect item on the market and finally request the item with a single click.
Expand Down
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": [
"src/assets/images"
"src/assets/images",
"src/assets/audio"
],
"styles": [
"src/styles.scss",
Expand Down
Binary file added img/feature_trade.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
835 changes: 835 additions & 0 deletions overlay.babel

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions src/app/core/annotation/annotation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ const ANNOTATIONS: Annotation[] = [
}
]
},
// TODO
// {
// id: 'trade',
// children: [
// { id: 'filter' },
// { id: 'search' },
// { id: 'reset' },
// ]
// },
{
id: 'trade',
children: [
{ id: 'init' },
{ id: 'incoming' },
{ id: 'highlight' },
{ id: 'outgoing' },
{ id: 'settings' }
]
},
{
id: 'evaluate',
hotkey: Hotkey.Evaluate,
Expand Down Expand Up @@ -83,6 +84,12 @@ const ANNOTATIONS: Annotation[] = [
hotkey: Hotkey.SettingsToggle,
skippable: true,
},
{
id: 'misc',
hotkey: Hotkey.MiscStashHighlight,
expressions: [AnnotationCondition.MiscStashHighlightExecuted],
skippable: true,
},
{
id: 'bookmarks',
hotkey: Hotkey.Bookmark1,
Expand Down
1 change: 1 addition & 0 deletions src/app/core/annotation/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum AnnotationCondition {
EvaluateClose,
CommandExecuted,
BookmarkOpened,
MiscStashHighlightExecuted
}

export interface AnnotationConditionMap {
Expand Down
39 changes: 39 additions & 0 deletions src/app/core/audio/audio.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { tap, throttleTime } from 'rxjs/operators';
import { AudioFile } from './audio';

interface AudioPlayEvent {
file: AudioFile;
volume: number;
}

@Injectable({
providedIn: 'root'
})
export class AudioService {
private readonly audio: HTMLAudioElement;
private readonly queue$ = new Subject<AudioPlayEvent>();

constructor() {
this.audio = document.createElement('audio');
this.init();
}

public play(file: AudioFile, volume: number = 1): void {
this.queue$.next({ file, volume });
}

private init(): void {
this.queue$.pipe(
throttleTime(500),
tap(event => {
this.audio.pause();
this.audio.src = event.file;
this.audio.currentTime = 0;
this.audio.volume = event.volume;
this.audio.play();
})
).subscribe();
}
}
3 changes: 3 additions & 0 deletions src/app/core/audio/audio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum AudioFile {
Notification = '/dist/poe-overlay-overwolf/assets/audio/notification.wav'
}
3 changes: 3 additions & 0 deletions src/app/core/audio/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './audio';
export * from './audio.service';

2 changes: 1 addition & 1 deletion src/app/core/config/hotkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export enum Hotkey {
Bookmark4 = 'bookmark4',
Bookmark5 = 'bookmark5',
Bookmark6 = 'bookmark6',
MiscStasHighlight = 'misc-stash-highlight'
MiscStashHighlight = 'misc-stash-highlight'
}
1 change: 1 addition & 0 deletions src/app/core/odk/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './ow-audio';
export * from './ow-file-listener';
export * from './ow-game-listener';
export * from './ow-games';
Expand Down
42 changes: 42 additions & 0 deletions src/app/core/odk/ow-audio-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Observable } from 'rxjs';
import { flatMap, shareReplay, delay } from 'rxjs/operators';
import { OWAudio } from './ow-audio';

export class OWAudioFile {
private id$: Observable<string>;

constructor(private readonly url: string) { }

public play(): Observable<void> {
return this.ensure().pipe(
flatMap(id => OWAudio.play(id))
);
}

public resume(): Observable<void> {
return this.ensure().pipe(
flatMap(id => OWAudio.resume(id))
);
}

public stop(): Observable<void> {
return this.ensure().pipe(
flatMap(id => OWAudio.stop(id))
);
}

public setVolume(volume: number): Observable<void> {
return this.ensure().pipe(
flatMap(() => OWAudio.setVolume(volume))
);
}

private ensure(): Observable<string> {
if (!this.id$) {
this.id$ = OWAudio.create(this.url).pipe(
shareReplay(1)
);
}
return this.id$;
}
}
74 changes: 74 additions & 0 deletions src/app/core/odk/ow-audio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { from, Observable } from 'rxjs';

export class OWAudio {

public static create(url: string): Observable<string> {
const promise = new Promise<string>((resolve, reject) => {
overwolf.media.audio.create(url, result => {
console.log(result);
if (result.success) {
resolve(result.id);
} else {
reject(result.error);
}
});
});
return from(promise);
}

public static play(id: string): Observable<void> {
const promise = new Promise<void>((resolve, reject) => {
overwolf.media.audio.play(id, result => {
console.log(result);
if (result.success) {
resolve();
} else {
reject(result.error);
}
});
});
return from(promise);
}

public static stop(id: string): Observable<void> {
const promise = new Promise<void>((resolve, reject) => {
overwolf.media.audio.stopById(id, result => {
console.log(result);
if (result.success) {
resolve();
} else {
reject(result.error);
}
});
});
return from(promise);
}

public static resume(id: string): Observable<void> {
const promise = new Promise<void>((resolve, reject) => {
overwolf.media.audio.resumeById(id, result => {
console.log(result);
if (result.success) {
resolve();
} else {
reject(result.error);
}
});
});
return from(promise);
}

public static setVolume(volume: number): Observable<void> {
const promise = new Promise<void>((resolve, reject) => {
overwolf.media.audio.setVolume(volume, result => {
console.log(result);
if (result.success) {
resolve();
} else {
reject(result.error);
}
});
});
return from(promise);
}
}
15 changes: 8 additions & 7 deletions src/app/modules/commands/service/command.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { OWGamesEvents } from '@app/odk';
import { ChatService } from '@shared/module/poe/chat';
import { EventInfo } from '@shared/module/poe/poe-event-info';
import { EventService } from '@shared/module/poe/event';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';

Expand All @@ -10,14 +9,16 @@ import { map, tap } from 'rxjs/operators';
})
export class CommandService {

constructor(private readonly chat: ChatService) { }
constructor(
private readonly chat: ChatService,
private readonly event: EventService) { }

public execute(command: string): Observable<void> {
// TODO: Error handling
return OWGamesEvents.getInfo<EventInfo>().pipe(
tap(info => {
if (info?.me?.character_name?.length > 2) {
command = command.replace('@char', info.me.character_name.slice(1, info.me.character_name.length - 1));
return this.event.getCharacter().pipe(
tap(character => {
if (character?.name.length) {
command = command.replace('@char', character.name);
}
this.chat.send(command);
}),
Expand Down
14 changes: 10 additions & 4 deletions src/app/modules/misc/misc.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { NgModule } from '@angular/core';
import { AnnotationCondition, AnnotationService } from '@app/annotation';
import { Hotkey } from '@app/config';
import { Feature, FeatureConfig, FeatureModule, FEATURE_MODULES } from '@app/feature';
import { SharedModule } from '@shared/shared.module';
import { flatMap } from 'rxjs/operators';
import { MiscSettingsComponent } from './component';
import { MiscFeatureSettings } from './misc-feature-settings';
import { MiscStashService } from './service/misc-stash.service';
Expand All @@ -15,7 +17,9 @@ import { MiscStashService } from './service/misc-stash.service';
imports: [SharedModule]
})
export class MiscModule implements FeatureModule<MiscFeatureSettings> {
constructor(private readonly miscStash: MiscStashService) { }
constructor(
private readonly miscStash: MiscStashService,
private readonly annotation: AnnotationService) { }

public getConfig(): FeatureConfig<MiscFeatureSettings> {
const config: FeatureConfig<MiscFeatureSettings> = {
Expand All @@ -28,15 +32,17 @@ export class MiscModule implements FeatureModule<MiscFeatureSettings> {

public getFeatures(): Feature[] {
const features: Feature[] = [
{ hotkey: Hotkey.MiscStasHighlight }
{ hotkey: Hotkey.MiscStashHighlight }
];
return features;
}

public onKeyPressed(hotkey: Hotkey): void {
switch (hotkey) {
case Hotkey.MiscStasHighlight:
this.miscStash.highlight().subscribe();
case Hotkey.MiscStashHighlight:
this.miscStash.highlight().pipe(
flatMap(() => this.annotation.update(AnnotationCondition.MiscStashHighlightExecuted, true))
).subscribe();
break;
default:
throw new Error(`Hotkey: '${hotkey}' out of range.`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="message" [class.incoming]="message.direction === 'incoming'" [class.toggled]="toggle$ | async"
[class.joined]="message.joined$ | async" (click)="toggle$.next(!toggle$.value)">
[class.joined]="message.joined$ | async" (click)="toggle$.next(!toggle$.value)"
[appAnnotation]="'trade.' + message.direction">
<div class="content">
<div class="action" *ngIf="(toggle$ | async) === false">
<mat-icon (click)="onWait($event)" *ngIf="visible['wait']">pan_tool</mat-icon>
Expand Down Expand Up @@ -31,7 +32,8 @@
<app-trade-message-action action="trade" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="item-highlight" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="item-highlight" [visible]="visible" (execute)="onActionExecute($event)"
appAnnotation="trade.highlight">
</app-trade-message-action>
<app-trade-message-action action="finished" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
Expand Down
Loading

0 comments on commit 98e72c1

Please sign in to comment.