mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-29 00:23:31 -04:00
Don't update chat when context is lost, should fix most crashing on AMD/ATI cards
This commit is contained in:
parent
132967bf9d
commit
8571115dec
@ -36,17 +36,13 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
fontSize = (int)(14 * game.GuiChatScale);
|
||||
Utils.Clamp(ref fontSize, 8, 60);
|
||||
announcementFont = new Font(game.FontName, fontSize);
|
||||
ConstructWidgets();
|
||||
|
||||
int[] indices = new int[chatLines];
|
||||
for (int i = 0; i < indices.Length; i++)
|
||||
indices[i] = -1;
|
||||
Metadata = indices;
|
||||
SetInitialMessages();
|
||||
ContextRecreated();
|
||||
|
||||
game.Events.ChatReceived += ChatReceived;
|
||||
game.Events.ChatFontChanged += ChatFontChanged;
|
||||
game.Events.ColourCodeChanged += ColourCodeChanged;
|
||||
game.Graphics.ContextLost += ContextLost;
|
||||
game.Graphics.ContextRecreated += ContextRecreated;
|
||||
}
|
||||
|
||||
void ConstructWidgets() {
|
||||
@ -228,6 +224,8 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
|
||||
void ChatReceived(object sender, ChatEventArgs e) {
|
||||
MessageType type = e.Type;
|
||||
if (gfx.LostContext) return;
|
||||
|
||||
if (type == MessageType.Normal) {
|
||||
chatIndex++;
|
||||
if (game.ChatLines == 0) return;
|
||||
@ -251,15 +249,25 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
ContextLost();
|
||||
chatFont.Dispose();
|
||||
chatUrlFont.Dispose();
|
||||
announcementFont.Dispose();
|
||||
|
||||
game.Events.ChatReceived -= ChatReceived;
|
||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
||||
game.Events.ColourCodeChanged -= ColourCodeChanged;
|
||||
game.Graphics.ContextLost -= ContextLost;
|
||||
game.Graphics.ContextRecreated -= ContextRecreated;
|
||||
}
|
||||
|
||||
void ContextLost() {
|
||||
if (HandlesAllInput) {
|
||||
game.chatInInputBuffer = input.Text.ToString();
|
||||
game.CursorVisible = false;
|
||||
} else {
|
||||
game.chatInInputBuffer = null;
|
||||
}
|
||||
chatFont.Dispose();
|
||||
chatUrlFont.Dispose();
|
||||
announcementFont.Dispose();
|
||||
|
||||
normalChat.Dispose();
|
||||
input.DisposeFully();
|
||||
@ -268,10 +276,16 @@ namespace ClassicalSharp.Gui.Screens {
|
||||
bottomRight.Dispose();
|
||||
clientStatus.Dispose();
|
||||
announcement.Dispose();
|
||||
}
|
||||
|
||||
game.Events.ChatReceived -= ChatReceived;
|
||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
||||
game.Events.ColourCodeChanged -= ColourCodeChanged;
|
||||
void ContextRecreated() {
|
||||
ConstructWidgets();
|
||||
|
||||
int[] indices = new int[chatLines];
|
||||
for (int i = 0; i < indices.Length; i++)
|
||||
indices[i] = -1;
|
||||
Metadata = indices;
|
||||
SetInitialMessages();
|
||||
}
|
||||
|
||||
void ChatFontChanged(object sender, EventArgs e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user