Skip to content

Commit

Permalink
Trade chat macro WIP, path issue to resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
versedi committed Jun 12, 2020
1 parent ef2482e commit 4aa51ed
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# PoE Overlay (Community Fork)

PoE Overlay is a tool for Path of Exile. The ***core aspect*** is to blend in with the game. Built with Electron and Angular.
No Overwolf, no tracking, no shit. Everyone can commit and is free to fork and built uppon.

<!-- TOC -->
- [Community Development](#community-development)
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CommandModule } from '@modules/command/command.module';
import { EvaluateModule } from '@modules/evaluate/evaluate.module';
import { MapModule } from '@modules/map/map.module';
import { MiscModule } from '@modules/misc/misc.module';
import { TradeModule } from '@modules/trade/trade.module';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { AppTranslationsLoader } from './app-translations.loader';
import { AppComponent } from './app.component';
Expand Down Expand Up @@ -42,6 +43,7 @@ const routes: Routes = [
CommandModule,
MapModule,
MiscModule,
TradeModule,
BookmarkModule
],
bootstrap: [AppComponent]
Expand Down
1 change: 1 addition & 0 deletions src/app/modules/trade/component/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './trade-settings/trade-settings.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div class="row">
<div class="col-md-12 col-lg-12">
<app-card [title]="'trade.chat-settings' | translate">
<div class="row">
<div class="col">
<mat-slide-toggle [checked]="settings.tradeChatReadClientFile"
(change)="settings.tradeChatReadClientFile = $event.checked">
{{'trade.chat-read-client-file' | translate}}
</mat-slide-toggle>
<mat-form-field>
<mat-label>{{'trade.chat-client-file-path' | translate}}</mat-label>
<input type="text" matInput [(ngModel)]="settings.tradeChatClientFilePath">
</mat-form-field>
</div>
</div>
</app-card>
</div>
</div>
<app-card [title]="'trade.chat-settings-keybinds' | translate">
<div class="row">
<div class="col-md-6 col-lg-4">

<div class="row">
<div class="col">
<app-accelerator [label]="'trade.chat-invite-last-keybinding' | translate"
[(value)]="settings.chatInviteLastKeybinding">
</app-accelerator>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-4">
<app-accelerator [label]="'trade.chat-reply-message-keybinding' | translate"
[(value)]="settings.chatReplyMessageKeybinding">
</app-accelerator>
</div>
<div class="col-md-6 col-lg-4 f-grow">
<mat-form-field>
<mat-label>{{'trade.chat-reply-message' | translate}}</mat-label>
<input type="text" matInput [(ngModel)]="settings.chatReplyMessage">
</mat-form-field>
</div>
</div>
</app-card>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateFakeLoader, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { SharedModule } from '@shared/shared.module';
import { TradeSettingsComponent } from './trade-settings.component';


describe('MiscSettingsComponent', () => {
let component: TradeSettingsComponent;
let fixture: ComponentFixture<TradeSettingsComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: () => new TranslateFakeLoader()
}
})
],
declarations: [TradeSettingsComponent]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TradeSettingsComponent);
component = fixture.componentInstance;
component.settings = {} as any;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { UserSettings, UserSettingsComponent } from 'src/app/layout/type';
import { EnumValues } from '@app/class';

export interface TradeUserSettings extends UserSettings {
tradeChatReadClientFile: boolean;
tradeChatClientFilePath: string;
chatReplyMessage: string;
chatReplyMessageKeybinding: string;
chatInviteLastKeybinding: string;
}

@Component({
selector: 'app-trade-settings',
templateUrl: './trade-settings.component.html',
styleUrls: ['./trade-settings.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TradeSettingsComponent implements UserSettingsComponent {
@Input()
public settings: TradeUserSettings;

public load(): void {
// stub
}
}
46 changes: 46 additions & 0 deletions src/app/modules/trade/service/trade-chat.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Injectable } from '@angular/core';
import { BrowserService } from '@app/service';
import { SnackBarService } from '@shared/module/material/service';
import { ItemClipboardResultCode, ItemClipboardService } from '@shared/module/poe/service';
import { ItemExternalService } from '@shared/module/poe/service/item/item-external.service';
import { ItemSection, Language } from '@shared/module/poe/type';
import { Observable, of, throwError } from 'rxjs';
import { catchError, flatMap } from 'rxjs/operators';


@Injectable({
providedIn: 'root'
})
export class TradeChatService {

constructor(
private readonly itemClipboard: ItemClipboardService,
private readonly itemExternalService: ItemExternalService,
private readonly browser: BrowserService,
private readonly snackbar: SnackBarService) {
}

public open(external: boolean): Observable<void> {
return this.itemClipboard.copy({
[ItemSection.Rartiy]: true
}).pipe(
flatMap(({ code, item }) => {
switch (code) {
case ItemClipboardResultCode.Success:
const url = this.itemExternalService.getDbUrl(item);
this.browser.open(url, external);
return of(null);
case ItemClipboardResultCode.Empty:
return this.snackbar.warning('clipboard.empty');
case ItemClipboardResultCode.ParserError:
return this.snackbar.warning('clipboard.parser-error');
default:
return throwError(`code: '${code}' out of range`);
}
}),
catchError(() => {
return this.snackbar.error('clipboard.parser-error');
})
);
}
}
60 changes: 60 additions & 0 deletions src/app/modules/trade/trade.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { NgModule } from '@angular/core';
import { FEATURE_MODULES } from '@app/token';
import { Feature, FeatureModule } from '@app/type';
import { SharedModule } from '@shared/shared.module';
import { UserSettingsFeature } from 'src/app/layout/type';
import { TradeSettingsComponent, TradeUserSettings } from './component';
import { TradeChatService } from './service/trade-chat.service';

@NgModule({
providers: [{ provide: FEATURE_MODULES, useClass: TradeModule, multi: true }],
declarations: [TradeSettingsComponent],
imports: [SharedModule]
})
export class TradeModule implements FeatureModule {

constructor(private readonly chat: TradeChatService) { }

public getSettings(): UserSettingsFeature {
const defaultSettings: TradeUserSettings = {
tradeChatClientFilePath: "C:\\Program Files (x86)\\Grinding Gear Games\\Path of Exile\\Logs\\Client.txt",
tradeChatReadClientFile: false,
chatInviteLastKeybinding: 'Alt + F1',
chatReplyMessageKeybinding: 'ALT + F2',
chatReplyMessage: 'Be right back, Im inside a map.',
};
return {
name: 'trade.name',
component: TradeSettingsComponent,
defaultSettings
};
}

public getFeatures(settings: TradeUserSettings): Feature[] {
const features: Feature[] = [
{
name: 'chat-read-client-file',
accelerator: settings.tradeChatReadClientFile ? '1' : '0',
},
{
name: 'chat-client-file-path',
accelerator: settings.tradeChatClientFilePath,
},
];

return features;
}

public run(feature: string, _: TradeUserSettings): void {
switch (feature) {
case 'chat-read-client-file':
this.chat.open(feature === 'chat-read-client-file').subscribe();
break;
case 'chat-client-file-path':
this.chat.open(feature === 'chat-client-file-path').subscribe();
break;
default:
break;
}
}
}
13 changes: 12 additions & 1 deletion src/assets/i18n/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,19 @@
"league": "League",
"open-settings": "Open Settings",
"relaunch-app": "Relaunch App",
"read-client-file": "Read Client.txt file",
"save": "Save",
"ui-language": "UI Language",
"zoom": "Zoom"
},
"trade": {
"name": "Trade Chat",
"chat-reply-message": "Text that you want to reply with",
"chat-reply-message-keybinding": "Keybind you want to use the reply",
"chat-read-client-file": "Read Client.txt from your PoE directory (may affect performance on HDD drives)",
"chat-client-file-path": "Path to Client.txt in your PoE directory",
"chat-settings": "Chat related trading settings",
"chat-invite-last-keybinding": "Key to invite last messenger to party",
"chat-settings-keybinds": "Settings for trading related chat keybinds"
}
}
}
10 changes: 10 additions & 0 deletions src/assets/i18n/polish.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,15 @@
"save": "Zapisz",
"ui-language": "Język programu",
"zoom": "Powiększenie"
},
"trade": {
"name": "Trade Chat",
"chat-reply-message": "Treść wiadomości, którą będziesz wysyłał",
"chat-reply-message-keybinding": "Klawisz, którym chcesz odpowiedzieć",
"chat-read-client-file": "Odczytuj plik Client.txt z folderu z grą PoE (może wpływać na wydajność w przypadku dysków HDD)",
"chat-client-file-path": "Scieżka do pliku Client.txt w Twoim folderze z grą",
"chat-settings": "Ustawienia dotyczące czatu marketowego",
"chat-invite-last-keybinding": "Klawisz, by zaprosić autora ostatniej wiadomości do party",
"chat-settings-keybinds": "Przypisania klawiszy w czacie marketowym"
}
}

0 comments on commit 4aa51ed

Please sign in to comment.