mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-29 08:32:46 -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);
|
fontSize = (int)(14 * game.GuiChatScale);
|
||||||
Utils.Clamp(ref fontSize, 8, 60);
|
Utils.Clamp(ref fontSize, 8, 60);
|
||||||
announcementFont = new Font(game.FontName, fontSize);
|
announcementFont = new Font(game.FontName, fontSize);
|
||||||
ConstructWidgets();
|
ContextRecreated();
|
||||||
|
|
||||||
int[] indices = new int[chatLines];
|
|
||||||
for (int i = 0; i < indices.Length; i++)
|
|
||||||
indices[i] = -1;
|
|
||||||
Metadata = indices;
|
|
||||||
SetInitialMessages();
|
|
||||||
|
|
||||||
game.Events.ChatReceived += ChatReceived;
|
game.Events.ChatReceived += ChatReceived;
|
||||||
game.Events.ChatFontChanged += ChatFontChanged;
|
game.Events.ChatFontChanged += ChatFontChanged;
|
||||||
game.Events.ColourCodeChanged += ColourCodeChanged;
|
game.Events.ColourCodeChanged += ColourCodeChanged;
|
||||||
|
game.Graphics.ContextLost += ContextLost;
|
||||||
|
game.Graphics.ContextRecreated += ContextRecreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstructWidgets() {
|
void ConstructWidgets() {
|
||||||
@ -228,6 +224,8 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
void ChatReceived(object sender, ChatEventArgs e) {
|
void ChatReceived(object sender, ChatEventArgs e) {
|
||||||
MessageType type = e.Type;
|
MessageType type = e.Type;
|
||||||
|
if (gfx.LostContext) return;
|
||||||
|
|
||||||
if (type == MessageType.Normal) {
|
if (type == MessageType.Normal) {
|
||||||
chatIndex++;
|
chatIndex++;
|
||||||
if (game.ChatLines == 0) return;
|
if (game.ChatLines == 0) return;
|
||||||
@ -251,15 +249,25 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
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) {
|
if (HandlesAllInput) {
|
||||||
game.chatInInputBuffer = input.Text.ToString();
|
game.chatInInputBuffer = input.Text.ToString();
|
||||||
game.CursorVisible = false;
|
game.CursorVisible = false;
|
||||||
} else {
|
} else {
|
||||||
game.chatInInputBuffer = null;
|
game.chatInInputBuffer = null;
|
||||||
}
|
}
|
||||||
chatFont.Dispose();
|
|
||||||
chatUrlFont.Dispose();
|
|
||||||
announcementFont.Dispose();
|
|
||||||
|
|
||||||
normalChat.Dispose();
|
normalChat.Dispose();
|
||||||
input.DisposeFully();
|
input.DisposeFully();
|
||||||
@ -268,10 +276,16 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
bottomRight.Dispose();
|
bottomRight.Dispose();
|
||||||
clientStatus.Dispose();
|
clientStatus.Dispose();
|
||||||
announcement.Dispose();
|
announcement.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
game.Events.ChatReceived -= ChatReceived;
|
void ContextRecreated() {
|
||||||
game.Events.ChatFontChanged -= ChatFontChanged;
|
ConstructWidgets();
|
||||||
game.Events.ColourCodeChanged -= ColourCodeChanged;
|
|
||||||
|
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) {
|
void ChatFontChanged(object sender, EventArgs e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user