Navigation Menu

Skip to content

Commit

Permalink
Don't always pointlessly recreate all chat log textures when you pres…
Browse files Browse the repository at this point in the history
…s enter/escape. (Thanks Cheessee)
  • Loading branch information
UnknownShadow200 committed Nov 13, 2017
1 parent cd3713d commit b30d19d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ClassicalSharp/2D/Screens/ChatScreen.cs
Expand Up @@ -68,7 +68,7 @@ public class ChatScreen : Screen {
.SetLocation(Anchor.LeftOrTop, Anchor.BottomOrRight, 10, hud.BottomOffset + 15);
normalChat.Init();

clientStatus = new TextGroupWidget(game, game.Chat.ClientStatus.Length, chatFont, chatUrlFont)
clientStatus = new TextGroupWidget(game, game.Chat.ClientStatus.Length, chatFont, chatUrlFont)
.SetLocation(Anchor.LeftOrTop, Anchor.BottomOrRight, 10, hud.BottomOffset + 15);
clientStatus.Init();

Expand Down Expand Up @@ -254,7 +254,7 @@ public class ChatScreen : Screen {
}

public override void Dispose() {
ContextLost();
ContextLost();
chatFont.Dispose();
chatUrlFont.Dispose();
announcementFont.Dispose();
Expand Down Expand Up @@ -342,8 +342,7 @@ public class ChatScreen : Screen {
public override bool HandlesKeyDown(Key key) {
suppressNextPress = false;
if (HandlesAllInput) { // text input bar
if (key == game.Mapping(KeyBind.SendChat) || key == Key.KeypadEnter
|| key == game.Mapping(KeyBind.PauseOrExit)) {
if (key == game.Mapping(KeyBind.SendChat) || key == Key.KeypadEnter || key == game.Mapping(KeyBind.PauseOrExit)) {
SetHandlesAllInput(false);
game.CursorVisible = false;
game.Camera.RegrabMouse();
Expand All @@ -354,16 +353,19 @@ public class ChatScreen : Screen {
input.EnterInput();
altText.SetActive(false);

chatIndex = game.Chat.Log.Count - chatLines;
ScrollHistory();
// Do we need to move all chat down?
int resetIndex = game.Chat.Log.Count - chatLines;
if (chatIndex != resetIndex) {
chatIndex = resetIndex;
ScrollHistory();
}
} else if (key == Key.PageUp) {
chatIndex -= chatLines;
ScrollHistory();
} else if (key == Key.PageDown) {
chatIndex += chatLines;
ScrollHistory();
} else if (game.Server.SupportsFullCP437 &&
key == game.Input.Keys[KeyBind.ExtInput]) {
} else if (game.Server.SupportsFullCP437 && key == game.Input.Keys[KeyBind.ExtInput]) {
altText.SetActive(!altText.Active);
} else {
input.HandlesKeyDown(key);
Expand Down

0 comments on commit b30d19d

Please sign in to comment.