forked from Kyusung4698/PoE-Overlay
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trade chat macro WIP, path issue to resolve
- Loading branch information
Showing
11 changed files
with
242 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './trade-settings/trade-settings.component'; |
45 changes: 45 additions & 0 deletions
45
src/app/modules/trade/component/trade-settings/trade-settings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
3 changes: 3 additions & 0 deletions
3
src/app/modules/trade/component/trade-settings/trade-settings.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/app/modules/trade/component/trade-settings/trade-settings.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/app/modules/trade/component/trade-settings/trade-settings.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters