Skip to content

Commit

Permalink
- added latest whisper placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyusung4698 committed Jul 28, 2020
1 parent e5e78f1 commit 70f1b21
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 21 deletions.
53 changes: 53 additions & 0 deletions overlay.babel
Original file line number Diff line number Diff line change
Expand Up @@ -4617,6 +4617,59 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>tooltip</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>de-DE</language>
<approved>false</approved>
</translation>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-ES</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-FR</language>
<approved>false</approved>
</translation>
<translation>
<language>ko-KR</language>
<approved>false</approved>
</translation>
<translation>
<language>pl-PL</language>
<approved>false</approved>
</translation>
<translation>
<language>pt-BR</language>
<approved>false</approved>
</translation>
<translation>
<language>ru-RU</language>
<approved>false</approved>
</translation>
<translation>
<language>th-TH</language>
<approved>false</approved>
</translation>
<translation>
<language>zh-CHS</language>
<approved>false</approved>
</translation>
<translation>
<language>zh-CHT</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<folder_node>
Expand Down
4 changes: 4 additions & 0 deletions src/app/modules/commands/commands.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ export class CommandsModule implements FeatureModule<CommandsFeatureSettings> {
throw new Error(`Hotkey: '${hotkey}' out of range.`);
}
}

public onLogLineAdd(line: string): void {
this.command.onLogLineAdd(line);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<mat-form-field>
<mat-label>{{'commands.text' | translate}}</mat-label>
<input matInput [(ngModel)]="command.text" (ngModelChange)="onChange()">
<ng-container matSuffix >
<button mat-icon-button>
<mat-icon [matTooltip]="'commands.tooltip' | translate" matTooltipPosition="left">help</mat-icon>
</button>
</ng-container>
</mat-form-field>
</div>
<div class="col-12">
Expand Down
31 changes: 21 additions & 10 deletions src/app/modules/commands/service/command.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { Observable, of, throwError } from 'rxjs';
import { flatMap } from 'rxjs/operators';
import { CommandsFeatureSettings } from '../commands-feature-settings';

interface CommandContext {
char?: string;
latest_whisper?: string;
}

@Injectable({
providedIn: 'root'
})
export class CommandService {
private readonly context: CommandContext = {};

constructor(
private readonly chat: ChatService,
Expand All @@ -18,22 +24,27 @@ export class CommandService {
if (command.includes('@char')) {
return this.event.getCharacter().pipe(
flatMap(character => {
if (character?.name?.length) {
command = command.replace('@char', character.name);
} else {
if (settings.characterName?.length) {
command = command.replace('@char', settings.characterName);
} else {
return throwError('character name was not set.');
}
const char = character?.name || settings.characterName;
if (!char?.length) {
return throwError('character name was not set.');
}
this.chat.send(command);
this.chat.send(command, {
...this.context,
char
});
return of(null);
})
);
} else {
this.chat.send(command);
this.chat.send(command, this.context);
return of(null);
}
}

public onLogLineAdd(line: string): void {
const message = this.chat.parse(line);
if (message?.from) {
this.context.latest_whisper = message.from;
}
}
}
2 changes: 2 additions & 0 deletions src/app/shared/module/material/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatSliderModule } from '@angular/material/slider';
import { MatTabsModule } from '@angular/material/tabs';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TranslateModule } from '@ngx-translate/core';
import { CardComponent, SelectListComponent } from './component';

Expand All @@ -35,6 +36,7 @@ const MODULES = [
MatTabsModule,
MatListModule,
MatProgressBarModule,
MatTooltipModule
];

@NgModule({
Expand Down
22 changes: 22 additions & 0 deletions src/app/shared/module/poe/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ import { OWUtils } from '@app/odk/ow-utils';
import { Subject } from 'rxjs';
import { concatMap, delay, distinctUntilChanged, flatMap, map, mergeMap, tap, windowTime } from 'rxjs/operators';

const MESSAGE_REGEXP = /@((?<from>from|de|von|от кого|)|(?<to>to|à|an|para|кому|)) (<.*?> )*(?<player>.*?):(?<message>.*)/;

interface ChatEvent {
message: string;
send: boolean;
}

export interface ChatMessage {
from?: string;
to?: string;
message: string;
}

@Injectable({
providedIn: 'root'
})
Expand All @@ -19,6 +27,20 @@ export class ChatService {
this.init();
}

public parse(line: string): ChatMessage {
const result = new RegExp(MESSAGE_REGEXP, 'gi').exec(line);
if (!result) {
return undefined;
}
const { groups } = result;
const { from, to, player, message } = groups;
return {
from: from ? player : undefined,
to: to ? player : undefined,
message
};
}

public send(text: string, context?: any): void {
const message = this.generateMessage(undefined, text, context);
this.queue$.next({ message, send: true });
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@
"commands": {
"execute-error": "An unexpected error occurred while executing the command.",
"name": "Commands",
"text": "Command"
"text": "Command",
"tooltip": "Following placeholders are available:\n@latest_whisper -> latest whisper player name\n@char -> your current player name"
},
"evaluate": {
"cancel": "Cancel?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/french.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "Une erreur inattendue s'est produite lors de l'exécution de la commande.",
"name": "Commande",
"text": "Commande"
"text": "Commande",
"tooltip": "Les espaces réservés suivants sont disponibles:\n@latest_whisper -> dernier nom de joueur chuchoté\n@char -> votre nom de joueur actuel"
},
"evaluate": {
"cancel": "Annuler?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/german.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "Beim Ausführen des Befehls ist ein unerwarteter Fehler aufgetreten.",
"name": "Befehle",
"text": "Befehl"
"text": "Befehl",
"tooltip": "Folgende Platzhalter stehen zur Verfügung:\n@latest_whisper -> Name des neuesten Flüsterspielers\n@char -> dein aktueller Spielername"
},
"evaluate": {
"cancel": "Abbrechen?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/korean.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "명령을 실행하는 중 예기치 않은 오류가 발생했습니다.",
"name": "명령어",
"text": "명령어"
"text": "명령어",
"tooltip": "다음과 같은 자리 표시자를 사용할 수 있습니다.\n@latest_whisper-> 최신 속삭임 플레이어 이름\n@char-> 현재 플레이어 이름"
},
"evaluate": {
"cancel": "취소?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/polish.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "Wystąpił nieoczekiwany błąd podczas wykonywania polecenia.",
"name": "Komendy",
"text": "Komenda"
"text": "Komenda",
"tooltip": "Dostępne są następujące symbole zastępcze:\n@latest_whisper -> nazwa ostatniego szeptanego gracza\n@char -> Twoja obecna nazwa gracza"
},
"evaluate": {
"cancel": "Anuluj?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/portuguese.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "Ocorreu um erro inesperado ao executar o comando.",
"name": "Comando",
"text": "Comando"
"text": "Comando",
"tooltip": "Os seguintes espaços reservados estão disponíveis:\n@latest_whisper -> nome do jogador mais recente do whisper\n@char -> seu nome de jogador atual"
},
"evaluate": {
"cancel": "Cancelar?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/russian.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "Произошла непредвиденная ошибка при выполнении команды.",
"name": "Команды",
"text": "Команда"
"text": "Команда",
"tooltip": "Доступны следующие заполнители:\n@latest_whisper -> последнее имя игрока шепотом\n@char -> ваше текущее имя игрока"
},
"evaluate": {
"cancel": "Отменить?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/simplified-chinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "执行命令时发生意外错误。",
"name": "命令",
"text": "命令"
"text": "命令",
"tooltip": "以下占位符可用:\n@latest_whisper->最新的耳语玩家名称\n@char->您当前的玩家名称"
},
"evaluate": {
"cancel": "取消?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/spanish.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "Se produjo un error inesperado al ejecutar el comando.",
"name": "Mando",
"text": "Mando"
"text": "Mando",
"tooltip": "Los siguientes marcadores de posición están disponibles:\n@latest_whisper -> último nombre de jugador susurro\n@char -> tu nombre de jugador actual"
},
"evaluate": {
"cancel": "¿Cancelar?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/thai.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "เกิดข้อผิดพลาดที่ไม่คาดคิดขณะดำเนินการคำสั่ง",
"name": "คำสั่ง",
"text": "คำสั่ง"
"text": "คำสั่ง",
"tooltip": "มีตัวแทนจำหน่ายดังต่อไปนี้:\n@latest_whisper -> ชื่อผู้เล่นกระซิบล่าสุด\n@char -> ชื่อผู้เล่นปัจจุบันของคุณ"
},
"evaluate": {
"cancel": "ยกเลิก?",
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/traditional-chinese.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@
"commands": {
"execute-error": "執行命令時發生意外錯誤。",
"name": "命令",
"text": "命令"
"text": "命令",
"tooltip": "以下佔位符可用:\n@latest_whisper->最新的耳語玩家名稱\n@char->您當前的玩家名稱"
},
"evaluate": {
"cancel": "取消?",
Expand Down
5 changes: 5 additions & 0 deletions src/styles/_material.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ mat-card {
min-width: auto;
}
}

.mat-tooltip {
white-space: pre-line;
background-color: $black-transparent;
}

0 comments on commit 70f1b21

Please sign in to comment.