add more chat persistence
This commit is contained in:
parent
f138654ccb
commit
c6021f798c
2 changed files with 13 additions and 2 deletions
|
@ -23,6 +23,7 @@ GUI.prototype.Chat = class {
|
||||||
};
|
};
|
||||||
|
|
||||||
let span;
|
let span;
|
||||||
|
let atBottom = this.element.scrollTop == this.element.scrollHeight;
|
||||||
|
|
||||||
if (message.type == 'server') {
|
if (message.type == 'server') {
|
||||||
span = this.gui.createElement(this.messageElement, 'span', {
|
span = this.gui.createElement(this.messageElement, 'span', {
|
||||||
|
@ -36,11 +37,16 @@ GUI.prototype.Chat = class {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (atBottom)
|
||||||
this.element.scrollTop = this.element.scrollHeight;
|
this.element.scrollTop = this.element.scrollHeight;
|
||||||
|
|
||||||
|
setTimeout(_ => {
|
||||||
|
span.classList.add('old');
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
setTimeout(_ => {
|
setTimeout(_ => {
|
||||||
this.messageElement.removeChild(span);
|
this.messageElement.removeChild(span);
|
||||||
}, 20000);
|
}, 200000);
|
||||||
}
|
}
|
||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
|
@ -59,12 +65,15 @@ GUI.prototype.Chat = class {
|
||||||
}
|
}
|
||||||
this.typing = false;
|
this.typing = false;
|
||||||
this.inputElement.blur();
|
this.inputElement.blur();
|
||||||
|
this.messageElement.classList.add('inactive');
|
||||||
this.inputElement.disabled = true;
|
this.inputElement.disabled = true;
|
||||||
game.input.locked = false;
|
game.input.locked = false;
|
||||||
} else {
|
} else {
|
||||||
this.typing = true;
|
this.typing = true;
|
||||||
this.inputElement.disabled = false;
|
this.inputElement.disabled = false;
|
||||||
this.inputElement.focus();
|
this.inputElement.focus();
|
||||||
|
this.messageElement.classList.remove('inactive');
|
||||||
|
this.element.scrollTop = this.element.scrollHeight;
|
||||||
game.input.locked = true;
|
game.input.locked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ canvas
|
||||||
color #8af
|
color #8af
|
||||||
&.server
|
&.server
|
||||||
color #68c
|
color #68c
|
||||||
|
^[2].inactive > span.old
|
||||||
|
display: none
|
||||||
input
|
input
|
||||||
font-family inherit
|
font-family inherit
|
||||||
font-size inherit
|
font-size inherit
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue