Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: チャット画面 / チャットパレットのアイコンから画像変更画面を開く #128

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/component/chat-input/chat-input.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="table" [ngClass]="{ 'direct-message': isDirect }">
<div class="table-cell imagebox">
<img *ngIf="0 < imageFile.url.length" class="image" [src]="imageFile.url | safe: 'resourceUrl'" />
<img (click)="openCharacterImageChange()" *ngIf="0 < imageFile.url.length" class="image" [src]="imageFile.url | safe: 'resourceUrl'" />
</div>
<div class="table-cell">
<div>
Expand All @@ -24,7 +24,7 @@
</div>
<div>
<form>
<textarea class="chat-input" placeholder="Enterで送信 Shift+Enterで改行" [(ngModel)]="text"
<textarea class="chat-input" placeholder="Enterで送信 Shift+Enterで改行 アイコンクリックで画像変更" [(ngModel)]="text"
[ngModelOptions]="{standalone: true}" (input)="onInput()" (keydown.enter)="sendChat($event)"
#textArea></textarea>
<button type="submit" (click)="sendChat(null)">SEND</button>
Expand Down
25 changes: 24 additions & 1 deletion src/app/component/chat-input/chat-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { TextViewComponent } from 'component/text-view/text-view.component';
import { ChatMessageService } from 'service/chat-message.service';
import { PanelOption, PanelService } from 'service/panel.service';
import { PointerDeviceService } from 'service/pointer-device.service';
import { FileSelecterComponent } from 'component/file-selecter/file-selecter.component';
import { ModalService } from 'service/modal.service';
import { PeerCursorComponent } from 'component/peer-cursor/peer-cursor.component';

@Component({
selector: 'chat-input',
Expand Down Expand Up @@ -84,7 +87,8 @@ export class ChatInputComponent implements OnInit, OnDestroy {
private ngZone: NgZone,
public chatMessageService: ChatMessageService,
private panelService: PanelService,
private pointerDeviceService: PointerDeviceService
private pointerDeviceService: PointerDeviceService,
private modalService: ModalService
) { }

ngOnInit(): void {
Expand Down Expand Up @@ -231,6 +235,25 @@ export class ChatInputComponent implements OnInit, OnDestroy {
});
}

openCharacterImageChange() {
let object = ObjectStore.instance.get(this.sendFrom);
if(!object) return;

this.modalService.open<string>(FileSelecterComponent, { isAllowedEmpty: true }).then(value => {
if(object instanceof PeerCursor) {
if(!object.image || !value) return;
object.imageIdentifier = value;
}
else if(object instanceof GameCharacter) {
if(!object.imageDataElement || !value) return;
let element = object.imageDataElement.getFirstElementByName('imageIdentifier');
if(!element) return;
element.value = value;
} else return;
});

}

private allowsChat(gameCharacter: GameCharacter): boolean {
switch (gameCharacter.location.name) {
case 'table':
Expand Down