Skip to content

Commit

Permalink
- added customizable messages
Browse files Browse the repository at this point in the history
- added saveable stash factors
  • Loading branch information
Kyusung4698 committed Jun 14, 2020
1 parent d758c50 commit 10f2bcf
Show file tree
Hide file tree
Showing 32 changed files with 1,419 additions and 236 deletions.
837 changes: 821 additions & 16 deletions overlay.babel

Large diffs are not rendered by default.

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
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import { concat, forkJoin } from 'rxjs';
import { flatMap } from 'rxjs/operators';
import { AnnotationWindowService, LauncherWindowService, NotificationWindowService, SettingsWindowService } from '../../service';

const logs = [
`2020/06/04 16:17:19 325004765 acf [INFO Client 3172] @To MamaBetra: Hi, I'd like to buy your 34 Orb of Alchemy for my 10 Chaos Orb in Standard.`,
`2020/06/04 16:16:57 324981828 acf [INFO Client 3172] @To Ana_Ivanovic: Hi, I would like to buy your Chimeric Vise Fingerless Silk Gloves listed for 1 chaos in Standard (stash tab "mapz"; position: left 3, top 13)`,
`2020/06/04 16:16:57 324981828 acf [INFO Client 3172] @To Ana_Ivanovic: Hi, I would like to buy your Chimeric Vise Fingerless Silk Gloves listed for 1 chaos in Standard (stash tab "mapz"; position: left 3, top 13) offer 2c`
];

@Component({
selector: 'app-background-window',
template: '',
Expand Down Expand Up @@ -96,15 +90,7 @@ export class BackgroundWindowComponent implements OnInit, OnDestroy {
private onKeyPressed(event: OnPressedEvent): void {
switch (event.name) {
case Hotkey.SettingsToggle:
const log = logs.pop();
if (log) {
this.modules.forEach(module => {
if (module.onLogLineAdd) {
module.onLogLineAdd(log);
}
});
}
// this.settingsWindow.toggle().subscribe();
this.settingsWindow.toggle().subscribe();
break;
default:
for (const module of this.modules) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div [class]="'message ' + message.direction" (click)="toggle = !toggle">
<div class="message" [class.incoming]="message.direction === 'incoming'" [class.toggled]="toggle"
(click)="toggle = !toggle">
<div class="content">
<ng-container [ngSwitch]="message.type">
<app-trade-message-item *ngSwitchCase="'item'" [message]="message"></app-trade-message-item>
Expand All @@ -8,24 +9,31 @@
</ng-container>
</div>
<div class="actions" *ngIf="toggle">
<app-trade-message-action action="wait" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="wait" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="interested" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="interested" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="resend" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="resend" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="whisper" [visible]="visible" [title]="message.whispers | tradeWhisperTitle"
<app-trade-message-action action="whisper" [visible]="visible" [title]="' @' + message.name + (message.whispers | tradeWhisperTitle)"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="invite" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="invite" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="trade" [visible]="visible" (execute)="onActionExecute($event)">
<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>
<app-trade-message-action action="finished" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="finished" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
<app-trade-message-action action="item-gone" [visible]="visible" (execute)="onActionExecute($event)">
<app-trade-message-action action="item-gone" [visible]="visible" [title]="' @' + message.name"
(execute)="onActionExecute($event)">
</app-trade-message-action>
</div>
<div class="dismiss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
app-trade-message {
&:nth-child(even) {
.message {
background: adjust-color($black-transparent, $alpha: 0.25);
background: adjust-color($black-transparent, $alpha: -0.2);
}
}

Expand All @@ -26,26 +26,28 @@

.message {
position: relative;
cursor: pointer;
display: flex;
width: 300px;
flex-direction: column;
border-left: 6px solid;
background: adjust-color($black-transparent, $alpha: 0.3);
cursor: pointer;
padding: $gutter-half $gutter;
width: 300px;
background: $black-transparent;
border-left: 6px solid;
border-color: adjust-color($color: $purple, $alpha: -0.2);

&.incoming {
border-color: adjust-color($color: $orange, $alpha: -0.2);
}

&.outgoing {
border-color: adjust-color($color: $purple, $alpha: -0.2);
&:hover,
&.toggled {
background: $black;
}

.dismiss {
position: absolute;
top: -6px;
right: -2px;
right: -6px;
display: none;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { NotificationService } from '@app/notification';
import { OWGamesEvents } from '@app/odk';
import { TradeMessageAction, TradeMessageActionState } from '@modules/trade/class';
import { TradeHighlightWindowService } from '@modules/trade/service';
import { TradeFeatureSettings } from '@modules/trade/trade-feature-settings';
import { ChatService } from '@shared/module/poe/chat';
import { EventInfo } from '@shared/module/poe/poe-event-info';
import { TradeExchangeMessage, TradeItemMessage, TradeMapMessage, TradeParserType, TradeWhisperDirection } from '@shared/module/poe/trade/chat';
import { of, throwError } from 'rxjs';
import { TradeBulkMessage, TradeExchangeMessage, TradeItemMessage, TradeMapMessage, TradeParserType, TradeWhisperDirection } from '@shared/module/poe/trade/chat';
import { Observable, of, throwError } from 'rxjs';
import { catchError, flatMap, map } from 'rxjs/operators';

@Component({
Expand All @@ -23,6 +24,9 @@ export class TradeMessageComponent implements OnInit {
@Input()
public message: TradeExchangeMessage;

@Input()
public settings: TradeFeatureSettings;

@Output()
public dismiss = new EventEmitter<void>();

Expand All @@ -37,13 +41,13 @@ export class TradeMessageComponent implements OnInit {
this.visible[TradeMessageAction.Trade] = true;
this.visible[TradeMessageAction.Whisper] = true;
if (this.message.direction === TradeWhisperDirection.Incoming) {
this.visible[TradeMessageAction.Wait] = type === TradeParserType.TradeItem;
this.visible[TradeMessageAction.Wait] = true;
this.visible[TradeMessageAction.ItemGone] = true;
this.visible[TradeMessageAction.ItemHighlight] = type === TradeParserType.TradeItem || type === TradeParserType.TradeMap;
this.visible[TradeMessageAction.ItemHighlight] = type === TradeParserType.TradeItem;
} else {
this.visible[TradeMessageAction.Resend] = true;
this.visible[TradeMessageAction.Finished] = true;
this.visible[TradeMessageAction.ItemHighlight] = type === TradeParserType.TradeMap;
// this.visible[TradeMessageAction.ItemHighlight] = type === TradeParserType.TradeMap;
}
}

Expand All @@ -59,15 +63,21 @@ export class TradeMessageComponent implements OnInit {
this.chat.invite(this.message.name);
break;
case TradeMessageAction.Wait:
this.wait();
this.createMessageContext().subscribe(context => {
this.chat.whisper(this.message.name, this.settings.tradeMessageWait, context);
});
this.visible[TradeMessageAction.Wait] = false;
this.visible[TradeMessageAction.Interested] = true;
break;
case TradeMessageAction.Interested:
this.chat.whisper(this.message.name, 'interested');
this.createMessageContext().subscribe(context => {
this.chat.whisper(this.message.name, this.settings.tradeMessageStillInterested, context);
});
break;
case TradeMessageAction.ItemGone:
this.chat.whisper(this.message.name, 'item gone');
this.createMessageContext().subscribe(context => {
this.chat.whisper(this.message.name, this.settings.tradeMessageItemGone, context);
});
this.close();
break;
case TradeMessageAction.Resend:
Expand All @@ -86,7 +96,9 @@ export class TradeMessageComponent implements OnInit {
this.chat.whisper(this.message.name);
break;
case TradeMessageAction.Finished:
this.chat.whisper(this.message.name, 'thanks');
this.createMessageContext().subscribe(context => {
this.chat.whisper(this.message.name, this.settings.tradeMessageThanks, context);
});
this.kick();
this.close();
break;
Expand Down Expand Up @@ -151,19 +163,48 @@ export class TradeMessageComponent implements OnInit {
}
}

private wait(): void {
OWGamesEvents.getInfo<EventInfo>().pipe(
private createMessageContext(): Observable<any> {
const context = {
zone: 'unknown',
itemname: 'unknown',
price: 'unknown'
};

switch (this.message.type) {
case TradeParserType.TradeItem:
{
const message = this.message as TradeItemMessage;
context.itemname = message.itemName;
if (message.price && message.currencyType) {
context.price = `${message.price} ${message.currencyType}`;
}
}
break;
case TradeParserType.TradeBulk:
{
const message = this.message as TradeBulkMessage;
context.itemname = `${message.count1} × ${message.type1}`;
context.price = `${message.count2} × ${message.type2}`;
}
break;
case TradeParserType.TradeMap:
{
const message = this.message as TradeMapMessage;
context.itemname = message.maps1.maps.join(', ');
context.price = message.maps2.maps.join(', ');
}
break;
}

return OWGamesEvents.getInfo<EventInfo>().pipe(
catchError(() => of(null)),
map((info: EventInfo) => {
const context = { location: 'unknown' };
if (info?.match_info?.current_zone?.length > 2) {
const zone = info.match_info.current_zone;
context.location = zone.slice(1, zone.length - 1);
context.zone = zone.slice(1, zone.length - 1);
}
return context;
})
).subscribe(context => {
this.chat.whisper(this.message.name, 'wait @location', context);
});
);
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
<p>trade-settings works!</p>
<app-card [title]="'trade.name' | translate">
<div class="row">
<div class="col-12">
<mat-slide-toggle [checked]="settings.tradeEnabled" (change)="settings.tradeEnabled = $event.checked"
(change)="onChange()">
{{'trade.enabled' | translate}}
</mat-slide-toggle>
</div>
</div>
<div class="row">
<div class="col-6">
<mat-form-field>
<mat-label>{{'trade.message.wait' | translate}}</mat-label>
<input matInput [(ngModel)]="settings.tradeMessageWait" (ngModelChange)="onChange()">
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field>
<mat-label>{{'trade.message.still-interested' | translate}}</mat-label>
<input matInput [(ngModel)]="settings.tradeMessageStillInterested" (ngModelChange)="onChange()">
</mat-form-field>
</div>
</div>
<div class="row">
<div class="col-6">
<mat-form-field>
<mat-label>{{'trade.message.item-gone' | translate}}</mat-label>
<input matInput [(ngModel)]="settings.tradeMessageItemGone" (ngModelChange)="onChange()">
</mat-form-field>
</div>
<div class="col-6">
<mat-form-field>
<mat-label>{{'trade.message.thanks' | translate}}</mat-label>
<input matInput [(ngModel)]="settings.tradeMessageThanks" (ngModelChange)="onChange()">
</mat-form-field>
</div>
</div>
</app-card>
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ import { TradeFeatureSettings } from '@modules/trade/trade-feature-settings';
})
export class TradeSettingsComponent extends FeatureSettingsComponent<TradeFeatureSettings> {
public load(): void { }

public onChange(): void {
this.save();
}
}
Loading

0 comments on commit 10f2bcf

Please sign in to comment.