mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
Cleanup file changes
This commit is contained in:
@@ -151,6 +151,7 @@ export class ChatBox implements AfterViewInit, OnDestroy {
|
|||||||
this.lastMessages.shift();
|
this.lastMessages.shift();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,14 +96,13 @@ CLASSES[MessageType.WhisperTo] = 'chat-line-whisper';
|
|||||||
CLASSES[MessageType.WhisperAnnouncement] = 'chat-line-whisper-announcement';
|
CLASSES[MessageType.WhisperAnnouncement] = 'chat-line-whisper-announcement';
|
||||||
CLASSES[MessageType.WhisperToAnnouncement] = 'chat-line-whisper-announcement';
|
CLASSES[MessageType.WhisperToAnnouncement] = 'chat-line-whisper-announcement';
|
||||||
|
|
||||||
|
|
||||||
export function createChatLogLineDOM(clickLabel: ClickHandler, clickName: ClickHandler): ChatLogLineDOM {
|
export function createChatLogLineDOM(clickLabel: ClickHandler, clickName: ClickHandler): ChatLogLineDOM {
|
||||||
const line: ChatLogLineDOM = {} as any;
|
const line: ChatLogLineDOM = {} as any;
|
||||||
|
|
||||||
line.root = element('div', 'chat-line', [
|
line.root = element('div', 'chat-line', [
|
||||||
element('span', 'chat-line-lead'),
|
element('span', 'chat-line-lead'),
|
||||||
line.time = element('span', 'chat-line-name', [
|
line.time = element('span', 'chat-line-name', [
|
||||||
textNode(`[`),
|
textNode('['),
|
||||||
line.timeContent = element(
|
line.timeContent = element(
|
||||||
'span', 'chat-line-time-content', [textNode('')], undefined),
|
'span', 'chat-line-time-content', [textNode('')], undefined),
|
||||||
line.index = element('span', 'chat-line-time-index', [line.indexText = textNode('')]),
|
line.index = element('span', 'chat-line-time-index', [line.indexText = textNode('')]),
|
||||||
@@ -111,7 +110,6 @@ export function createChatLogLineDOM(clickLabel: ClickHandler, clickName: ClickH
|
|||||||
]),
|
]),
|
||||||
line.label = element(
|
line.label = element(
|
||||||
'span', 'chat-line-label mr-1', [line.labelText = textNode('')], undefined, { click: () => clickLabel(line.entry) }),
|
'span', 'chat-line-label mr-1', [line.labelText = textNode('')], undefined, { click: () => clickLabel(line.entry) }),
|
||||||
|
|
||||||
line.prefixText = textNode(''),
|
line.prefixText = textNode(''),
|
||||||
line.name = element('span', 'chat-line-name', [
|
line.name = element('span', 'chat-line-name', [
|
||||||
textNode(`[`),
|
textNode(`[`),
|
||||||
@@ -164,7 +162,6 @@ function setNameColors(line: ChatLogLineDOM | undefined, colors?: string[] | nul
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateChatLogName(line: ChatLogLineDOM, { name, index }: ChatLogMessage) {
|
function updateChatLogName(line: ChatLogLineDOM, { name, index }: ChatLogMessage) {
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
line.name.style.display = 'inline';
|
line.name.style.display = 'inline';
|
||||||
replaceNodes(line.nameContent, name);
|
replaceNodes(line.nameContent, name);
|
||||||
@@ -204,6 +201,7 @@ function findUserIndex(users: IndexEntryUser[], id: number, crc: number | undefi
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,7 +594,6 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
}
|
}
|
||||||
return colors;
|
return colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeOutAutoClear() {
|
clearTimeOutAutoClear() {
|
||||||
if (this.autoClear) clearTimeout(this.autoClear);
|
if (this.autoClear) clearTimeout(this.autoClear);
|
||||||
this.autoClear = null;
|
this.autoClear = null;
|
||||||
@@ -622,7 +619,6 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
let colors: string[] | null = null;
|
let colors: string[] | null = null;
|
||||||
colors = this.getCharaterColors(message.id);
|
colors = this.getCharaterColors(message.id);
|
||||||
|
|
||||||
|
|
||||||
this.addEntryToList(this.local, GENERAL_CHAT_LIMIT, open && tab === 'local', entry);
|
this.addEntryToList(this.local, GENERAL_CHAT_LIMIT, open && tab === 'local', entry);
|
||||||
setNameColors(entry.dom, colors);
|
setNameColors(entry.dom, colors);
|
||||||
|
|
||||||
@@ -662,9 +658,9 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
this.messageCounter++;
|
this.messageCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private addEntryToList(list: ChatLogMessage[], limit: number, isOpen: boolean, entry: ChatLogMessage) {
|
private addEntryToList(list: ChatLogMessage[], limit: number, isOpen: boolean, entry: ChatLogMessage) {
|
||||||
let removedDom: ChatLogLineDOM | undefined;
|
let removedDom: ChatLogLineDOM | undefined;
|
||||||
|
|
||||||
while (list.length >= limit) {
|
while (list.length >= limit) {
|
||||||
const removed = list.shift();
|
const removed = list.shift();
|
||||||
|
|
||||||
@@ -677,6 +673,7 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
removed.dom = undefined;
|
removed.dom = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.push(entry);
|
list.push(entry);
|
||||||
|
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
@@ -685,13 +682,11 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
this.linesElement.appendChild(entry.dom.root);
|
this.linesElement.appendChild(entry.dom.root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
this.settings.chatlogClosed = !this.settings.chatlogClosed;
|
this.settings.chatlogClosed = !this.settings.chatlogClosed;
|
||||||
this.settingsService.saveBrowserSettings();
|
this.settingsService.saveBrowserSettings();
|
||||||
this.updateOpen();
|
this.updateOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
switchTab(tab: Tab) {
|
switchTab(tab: Tab) {
|
||||||
if (this.activeTab !== tab) {
|
if (this.activeTab !== tab) {
|
||||||
this.settings.chatlogTab = tab;
|
this.settings.chatlogTab = tab;
|
||||||
@@ -701,13 +696,11 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
this.updateTabs();
|
this.updateTabs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateTabs() {
|
private updateTabs() {
|
||||||
this.setActiveTab(this.localTab.nativeElement, this.activeTab === 'local');
|
this.setActiveTab(this.localTab.nativeElement, this.activeTab === 'local');
|
||||||
this.setActiveTab(this.partyTab.nativeElement, this.activeTab === 'party');
|
this.setActiveTab(this.partyTab.nativeElement, this.activeTab === 'party');
|
||||||
this.setActiveTab(this.whisperTab.nativeElement, this.activeTab === 'whisper');
|
this.setActiveTab(this.whisperTab.nativeElement, this.activeTab === 'whisper');
|
||||||
}
|
}
|
||||||
|
|
||||||
private setActiveTab(tab: HTMLElement, active: boolean) {
|
private setActiveTab(tab: HTMLElement, active: boolean) {
|
||||||
if (active) {
|
if (active) {
|
||||||
tab.classList.add('active');
|
tab.classList.add('active');
|
||||||
@@ -719,21 +712,17 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
tab.style.backgroundColor = this.inactiveBg;
|
tab.style.backgroundColor = this.inactiveBg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToEnd() {
|
scrollToEnd() {
|
||||||
// requestAnimationFrame(this.scrollHandler);
|
// requestAnimationFrame(this.scrollHandler);
|
||||||
this.scrollToEndAtFrame = true;
|
this.scrollToEndAtFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollHandler = () => {
|
scrollHandler = () => {
|
||||||
this.scrollingToEnd = true;
|
this.scrollingToEnd = true;
|
||||||
this.scroll.nativeElement.scrollTop = 99999;
|
this.scroll.nativeElement.scrollTop = 99999;
|
||||||
}
|
}
|
||||||
|
|
||||||
clickNameHandler = (message: ChatLogMessage) => {
|
clickNameHandler = (message: ChatLogMessage) => {
|
||||||
this.zone.run(() => this.nameClick.emit(message));
|
this.zone.run(() => this.nameClick.emit(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
clickLabel = (message: ChatLogMessage) => {
|
clickLabel = (message: ChatLogMessage) => {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
if (message.label) {
|
if (message.label) {
|
||||||
@@ -741,11 +730,9 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearList() {
|
private clearList() {
|
||||||
removeAllNodes(this.linesElement);
|
removeAllNodes(this.linesElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private regenerateList() {
|
private regenerateList() {
|
||||||
this.clearList();
|
this.clearList();
|
||||||
|
|
||||||
@@ -761,7 +748,6 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
lines.appendChild(entry.dom.root);
|
lines.appendChild(entry.dom.root);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
drag({ x, y, type, event }: AgDragEvent, resizeY: boolean, resizeX: boolean) {
|
drag({ x, y, type, event }: AgDragEvent, resizeY: boolean, resizeX: boolean) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
@@ -791,7 +777,6 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
this.scrollToEnd();
|
this.scrollToEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private setUnread(value: number) {
|
private setUnread(value: number) {
|
||||||
if (this.unread !== value) {
|
if (this.unread !== value) {
|
||||||
this.unread = value;
|
this.unread = value;
|
||||||
@@ -807,13 +792,11 @@ export class ChatLog implements AfterViewInit, OnDestroy, DoCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private findEntityFromMessages = (id: number): FakeEntity | undefined => {
|
private findEntityFromMessages = (id: number): FakeEntity | undefined => {
|
||||||
return findEntityFromMessages(id, this.whisper) ||
|
return findEntityFromMessages(id, this.whisper) ||
|
||||||
findEntityFromMessages(id, this.party) ||
|
findEntityFromMessages(id, this.party) ||
|
||||||
findEntityFromMessages(id, this.local);
|
findEntityFromMessages(id, this.local);
|
||||||
}
|
}
|
||||||
|
|
||||||
private findEntityFromMessagesByName = (name: string): FakeEntity | undefined => {
|
private findEntityFromMessagesByName = (name: string): FakeEntity | undefined => {
|
||||||
return findEntityFromMessagesByName(name, this.game.playerId, this.whisper) ||
|
return findEntityFromMessagesByName(name, this.game.playerId, this.whisper) ||
|
||||||
findEntityFromMessagesByName(name, this.game.playerId, this.party) ||
|
findEntityFromMessagesByName(name, this.game.playerId, this.party) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user