reset chat lines too
authornemo
Mon, 14 Nov 2011 17:56:44 -0500
changeset 6379 ef4288298e57
parent 6378 b812bfcfeb49
child 6380 1ff5ad1d771b
reset chat lines too
hedgewars/uCaptions.pas
hedgewars/uChat.pas
hedgewars/uStore.pas
--- a/hedgewars/uCaptions.pas	Mon Nov 14 23:46:23 2011 +0200
+++ b/hedgewars/uCaptions.pas	Mon Nov 14 17:56:44 2011 -0500
@@ -44,7 +44,7 @@
 
 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 begin
-    if (Captions[Group].Tex <> nil) and (Captions[Group].Text <> s) then
+    if Captions[Group].Text <> s then
         begin
         FreeTexture(Captions[Group].Tex);
         Captions[Group].Tex:= nil
@@ -69,7 +69,7 @@
 begin
 for Group:= Low(TCapGroup) to High(TCapGroup) do
     begin
-    if Captions[Group].Tex <> nil then FreeTexture(Captions[Group].Tex);
+    FreeTexture(Captions[Group].Tex);
     Captions[Group].Tex:= RenderStringTex(Captions[Group].Text, Captions[Group].Color, fntBig)
     end
 end;
--- a/hedgewars/uChat.pas	Mon Nov 14 23:46:23 2011 +0200
+++ b/hedgewars/uChat.pas	Mon Nov 14 17:56:44 2011 -0500
@@ -24,6 +24,7 @@
 
 procedure initModule;
 procedure freeModule;
+procedure ReloadLines;
 
 procedure AddChatString(s: shortstring);
 procedure DrawChat;
@@ -72,15 +73,15 @@
 cl.s:= str;
 
 if isInput then
-begin
+    begin
     color:= colors[#6];
     str:= UserNick + '> ' + str + '_'
-end
+    end
 else
-begin
+    begin
     color:= colors[str[1]];
     delete(str, 1, 1)
-end;
+    end;
 
 font:= CheckCJKFont(str, fnt16);
 w:= 0; h:= 0; // avoid compiler hints
@@ -99,6 +100,14 @@
 SDL_FreeSurface(resSurface)
 end;
 
+// For uStore texture recreation
+procedure ReloadLines;
+var i: LongWord;
+begin
+    SetLine(InputStr, InputStr.s, true);
+    for i:= 0 to MaxStrIndex do SetLine(Strs[i], Strs[i].s, false)
+end;
+
 procedure AddChatString(s: shortstring);
 begin
 if not ChatReady then
@@ -370,20 +379,14 @@
     missedCount:= 0;
 
     inputStr.Tex := nil;
-    for i:= 0 to MaxStrIndex do
-    begin
-        Strs[i].Tex := nil;
-    end;
+    for i:= 0 to MaxStrIndex do Strs[i].Tex := nil;
 end;
 
 procedure freeModule;
 var i: ShortInt;
 begin
     FreeTexture(InputStr.Tex);
-    for i:= 0 to MaxStrIndex do
-    begin
-        FreeTexture(Strs[i].Tex);
-    end;
+    for i:= 0 to MaxStrIndex do FreeTexture(Strs[i].Tex);
 end;
 
 end.
--- a/hedgewars/uStore.pas	Mon Nov 14 23:46:23 2011 +0200
+++ b/hedgewars/uStore.pas	Mon Nov 14 17:56:44 2011 -0500
@@ -21,7 +21,7 @@
 
 unit uStore;
 interface
-uses sysutils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions;
+uses sysutils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat;
 
 procedure initModule;
 procedure freeModule;
@@ -1043,6 +1043,7 @@
 
         ResetLand;
         ReloadCaptions;
+        ReloadLines;
 
         UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT)
         end;