Refactor text color variable names, export 2 color values to Lua
authorWuzzy <Wuzzy2@mail.ru>
Wed, 08 Aug 2018 14:38:54 +0200
changeset 13647 3d14950641a4
parent 13646 007813b81f1b
child 13648 690cc84e9fd6
Refactor text color variable names, export 2 color values to Lua
ChangeLog.txt
hedgewars/uCommandHandlers.pas
hedgewars/uConsts.pas
hedgewars/uGame.pas
hedgewars/uGears.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsUtils.pas
hedgewars/uScript.pas
hedgewars/uStats.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uTouch.pas
--- a/ChangeLog.txt	Wed Aug 08 14:10:32 2018 +0200
+++ b/ChangeLog.txt	Wed Aug 08 14:38:54 2018 +0200
@@ -98,6 +98,7 @@
  + New global: AMMO_INFINITE. Value for infinite ammo count for AddAmmo and other functions
  + New global: cMaxHogHealth. Maximum possible hedgehog health
  + New global: EXPLForceDraw. Flag for Explode function, forces land removal even with gfSolidLand on
+ + New globals: capcolDefault, capcolSetting: Default caption colors
  * Changed global: lfCurrentHog becomes lfCurHogCrate
  * Fixed variable: TotalRounds was -1 (instead of 0) in first real round after hog placement phase
  * AI sometimes intentionally shot hedgehogs with aihDoesntMatter set
--- a/hedgewars/uCommandHandlers.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uCommandHandlers.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -610,12 +610,12 @@
 if autoCameraOn then
     begin
     FollowGear:= nil;
-    AddCaption(trmsg[sidAutoCameraOff], cLightGrayColor, capgrpVolume);
+    AddCaption(trmsg[sidAutoCameraOff], capcolSetting, capgrpVolume);
     autoCameraOn:= false
     end
 else
     begin
-    AddCaption(trmsg[sidAutoCameraOn], cLightGrayColor, capgrpVolume);
+    AddCaption(trmsg[sidAutoCameraOn], capcolSetting, capgrpVolume);
     bShowFinger:= true;
     if not CurrentHedgehog^.Unplaced then
         FollowGear:= CurrentHedgehog^.Gear;
--- a/hedgewars/uConsts.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uConsts.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -73,10 +73,13 @@
     cNearBlackColorChannels : TSDL_Color = (r:$00; g:$00; b:$10; a:$FF);
 
     cWhiteColor           : Longword = $FFFFFFFF; // white
-    cYellowColor          : Longword = $FFFFFF00; // yellow
-    cLightGrayColor       : Longword = $FFCCCCCC; // light gray
     cNearBlackColor       : Longword = $FF000010; // nearly black
 
+    capcolDefault         : Longword = $FFFFFFFF; // default caption color
+    capcolSetting         : Longword = $FFCCCCCC; // caption color for changing client setting like volume or auto camera
+
+    cCentralMessageColor  : Longword = $FFFFFF00; // color of message in center of screen like quit or pause
+
 {$WARNINGS OFF}
     cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue:   3006477107); // 1.4
     cBombsSpeed   : hwFloat = (isNegative: false; QWordValue:    429496729);
--- a/hedgewars/uGame.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uGame.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -87,22 +87,22 @@
         j:= Volume;
         i:= ChangeVolume(cVolumeDelta);
         if (not cIsSoundEnabled) or (isAudioMuted and (j<>i)) then
-            AddCaption(trmsg[sidMute], cLightGrayColor, capgrpVolume)
+            AddCaption(trmsg[sidMute], capcolSetting, capgrpVolume)
         else if not isAudioMuted then
             begin
             s:= ansistring(inttostr(i));
-            AddCaption(FormatA(trmsg[sidVolume], s), cLightGrayColor, capgrpVolume)
+            AddCaption(FormatA(trmsg[sidVolume], s), capcolSetting, capgrpVolume)
             end
         end
     else if cMuteToggle then
         begin
         MuteAudio;
         if isAudioMuted then
-            AddCaption(trmsg[sidMute], cLightGrayColor, capgrpVolume)
+            AddCaption(trmsg[sidMute], capcolSetting, capgrpVolume)
         else
             begin
             s:= ansistring(inttostr(GetVolumePercent()));
-            AddCaption(FormatA(trmsg[sidVolume], s), cLightGrayColor, capgrpVolume);
+            AddCaption(FormatA(trmsg[sidVolume], s), capcolSetting, capgrpVolume);
             end;
         cMuteToggle:= false;
         end;
--- a/hedgewars/uGears.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uGears.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -344,9 +344,9 @@
                 i:= cSuddenDTurns - TotalRounds;
                 s:= ansistring(inttostr(i));
                 if i = 1 then
-                    AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
+                    AddCaption(trmsg[sidRoundSD], capcolDefault, capgrpGameState)
                 else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then
-                    AddCaption(FormatA(trmsg[sidRoundsSD], s), cWhiteColor, capgrpGameState);
+                    AddCaption(FormatA(trmsg[sidRoundsSD], s), capcolDefault, capgrpGameState);
                 end;
             end;
             if bBetweenTurns
@@ -995,19 +995,19 @@
             // health crate is smaller than the other crates
             FollowGear^.Radius := cCaseHealthRadius;
             FollowGear^.Health := content;
-            AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo);
+            AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
             end;
         AmmoCrate:
             begin
             FollowGear^.Pos := posCaseAmmo;
             FollowGear^.AmmoType := TAmmoType(content);
-            AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo);
+            AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
             end;
         UtilityCrate:
             begin
             FollowGear^.Pos := posCaseUtility;
             FollowGear^.AmmoType := TAmmoType(content);
-            AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo);
+            AddCaption(GetEventString(eidNewUtilityPack), capColDefault, capgrpAmmoInfo);
             end;
     end;
 
@@ -1034,17 +1034,17 @@
             FollowGear^.Pos := FollowGear^.Pos + posCaseHealth;
             // health crate is smaller than the other crates
             FollowGear^.Radius := cCaseHealthRadius;
-            AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo);
+            AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
             end;
         AmmoCrate:
             begin
             FollowGear^.Pos := FollowGear^.Pos + posCaseAmmo;
-            AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo);
+            AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
             end;
         UtilityCrate:
             begin
             FollowGear^.Pos := FollowGear^.Pos + posCaseUtility;
-            AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo);
+            AddCaption(GetEventString(eidNewUtilityPack), capcolDefault, capgrpAmmoInfo);
             end;
     end;
 
@@ -1081,7 +1081,7 @@
     Ammoz[amTardis].SkipTurns:= 9999;
     Ammoz[amTardis].Probability:= 0;
 
-    AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
+    AddCaption(trmsg[sidSuddenDeath], capcolDefault, capgrpGameState);
     ScriptCall('onSuddenDeath');
     playSound(sndSuddenDeath);
     StopMusic;
--- a/hedgewars/uGearsHandlersMess.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -1653,7 +1653,7 @@
         AllInactive := false;
         if Gear^.Timer = 0 then
             begin
-            AddCaption(GetEventString(eidRoundStart), cWhiteColor, capgrpGameState);
+            AddCaption(GetEventString(eidRoundStart), capcolDefault, capgrpGameState);
             end
         end;
     gtATFinishGame:
@@ -3393,7 +3393,7 @@
                         end
                 end;
         s:= ansistring(Gear^.Hedgehog^.Name);
-        AddCaption(FormatA(GetEventString(eidKamikaze), s), cWhiteColor, capgrpMessage);
+        AddCaption(FormatA(GetEventString(eidKamikaze), s), capcolDefault, capgrpMessage);
         uStats.HedgehogSacrificed(Gear^.Hedgehog);
         AfterAttack;
         HHGear^.Message:= HHGear^.Message or gmDestroy;
@@ -4150,7 +4150,7 @@
             dec(Gear^.Health)
             end;
         s:= ansistring(inttostr(Gear^.Health));
-        AddCaption(formatA(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
+        AddCaption(formatA(trmsg[sidRemaining], s), capcolDefault, capgrpAmmostate);
         end;
 
     if (HHGear <> nil) and ((HHGear^.Message and gmLJump) <> 0) and ((Gear^.State and gsttmpFlag) = 0) then
@@ -4479,7 +4479,7 @@
             dec(Gear^.FlightTime)
             end;
         s:= ansistring(inttostr(Gear^.FlightTime));
-        AddCaption(formatA(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
+        AddCaption(formatA(trmsg[sidRemaining], s), capcolDefault, capgrpAmmostate);
         end;
 
     if HHGear^.Message and (gmUp or gmPrecise or gmLeft or gmRight) <> 0 then
@@ -5890,7 +5890,7 @@
                 RecountTeamHealth(resgear^.Hedgehog^.Team);
                 resgear^.Hedgehog^.Effects[heResurrected]:= 1;
                 s:= ansistring(resgear^.Hedgehog^.Name);
-                AddCaption(FormatA(GetEventString(eidResurrected), s), cWhiteColor, capgrpMessage);
+                AddCaption(FormatA(GetEventString(eidResurrected), s), capcolDefault, capgrpMessage);
                 // only make hat-less hedgehogs look like zombies, preserve existing hats
 
                 if resgear^.Hedgehog^.Hat = 'NoHat' then
@@ -6116,7 +6116,7 @@
             begin
             RestoreHog(HH);
             s:= ansistring(HH^.Name);
-            AddCaption(FormatA(GetEventString(eidTimeTravelEnd), s), cWhiteColor, capgrpMessage)
+            AddCaption(FormatA(GetEventString(eidTimeTravelEnd), s), capcolDefault, capgrpMessage)
             end
         end;
 
--- a/hedgewars/uGearsHedgehog.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -621,7 +621,7 @@
         if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) and ((GameFlags and gfMultiWeapon) = 0) then
             begin
             s:= ansistring(inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1));
-            AddCaption(formatA(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate);
+            AddCaption(formatA(trmsg[sidRemaining], s), capcolDefault, capgrpAmmostate);
             end;
 
         if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks)
@@ -1262,7 +1262,7 @@
         begin
         Gear^.FlightTime:= 0;
         s:= ansistring(CurrentHedgehog^.Name);
-        AddCaption(FormatA(GetEventString(eidHomerun), s), cWhiteColor, capgrpMessage);
+        AddCaption(FormatA(GetEventString(eidHomerun), s), capcolDefault, capgrpMessage);
         PlaySound(sndHomerun)
         end;
     end
@@ -1304,7 +1304,7 @@
         if (GameFlags and gfInfAttack = 0) then
             begin
             s:= Hedgehog^.Name;
-            AddCaption(FormatA(GetEventString(eidTimeout), s), cWhiteColor, capgrpMessage);
+            AddCaption(FormatA(GetEventString(eidTimeout), s), capcolDefault, capgrpMessage);
             end;
         end;
     isCursorVisible:= false;
@@ -1473,9 +1473,9 @@
                 // Death message
                 s:= ansistring(Gear^.Hedgehog^.Name);
                 if Gear^.Hedgehog^.King then
-                    AddCaption(FormatA(GetEventString(eidKingDied), s), cWhiteColor, capgrpMessage)
+                    AddCaption(FormatA(GetEventString(eidKingDied), s), capcolDefault, capgrpMessage)
                 else
-                    AddCaption(FormatA(GetEventString(eidDied), s), cWhiteColor, capgrpMessage);
+                    AddCaption(FormatA(GetEventString(eidDied), s), capcolDefault, capgrpMessage);
                 end;
             end
         else
@@ -1485,7 +1485,7 @@
 
             // Gone message
             s:= ansistring(Gear^.Hedgehog^.Name);
-            AddCaption(FormatA(GetEventString(eidGone), s), cWhiteColor, capgrpMessage);
+            AddCaption(FormatA(GetEventString(eidGone), s), capcolDefault, capgrpMessage);
             end
         end;
     exit
--- a/hedgewars/uGearsUtils.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uGearsUtils.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -190,7 +190,7 @@
                                     if Gear^.Hedgehog^.Effects[hePoisoned] = 0 then
                                         begin
                                         s:= ansistring(Gear^.Hedgehog^.Name);
-                                        AddCaption(FormatA(GetEventString(eidPoisoned), s), cWhiteColor, capgrpMessage);
+                                        AddCaption(FormatA(GetEventString(eidPoisoned), s), capcolDefault, capgrpMessage);
                                         uStats.HedgehogPoisoned(Gear, AttackingHog)
                                         end;
                                     Gear^.Hedgehog^.Effects[hePoisoned] := 5;
@@ -734,9 +734,9 @@
                             Gear^.State := Gear^.State and (not gstHHDriven);
                             s:= ansistring(Gear^.Hedgehog^.Name);
                             if Gear^.Hedgehog^.King then
-                                AddCaption(FormatA(GetEventString(eidKingDied), s), cWhiteColor, capgrpMessage)
+                                AddCaption(FormatA(GetEventString(eidKingDied), s), capcolDefault, capgrpMessage)
                             else
-                                AddCaption(FormatA(GetEventString(eidDrowned), s), cWhiteColor, capgrpMessage);
+                                AddCaption(FormatA(GetEventString(eidDrowned), s), capcolDefault, capgrpMessage);
                             end
                         end
                     else
@@ -1580,7 +1580,7 @@
     FollowGear^.Pos:= posCaseHealth;
     // health crate is smaller than the other crates
     FollowGear^.Radius := cCaseHealthRadius;
-    AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo);
+    AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
     end
 else if (t<a+h) then
     begin
@@ -1592,7 +1592,7 @@
         i:= Low(TAmmoType);
         FollowGear^.Pos:= posCaseAmmo;
         FollowGear^.AmmoType:= i;
-        AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo);
+        AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
         end
     end
 else
@@ -1605,7 +1605,7 @@
         i:= Low(TAmmoType);
         FollowGear^.Pos:= posCaseUtility;
         FollowGear^.AmmoType:= i;
-        AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo);
+        AddCaption(GetEventString(eidNewUtilityPack), capcolDefault, capgrpAmmoInfo);
         end
     end;
 
--- a/hedgewars/uScript.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uScript.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -650,7 +650,7 @@
     if CheckAndFetchParamCount(L, 1, 3, call, params, cg) then
         begin
         if cg = 1 then
-            AddCaption(lua_tostringA(L, 1), cWhiteColor, capgrpMessage)
+            AddCaption(lua_tostringA(L, 1), capcolDefault, capgrpMessage)
         else
             begin
             cg:= LuaToCapGroupOrd(L, 3, call, params);
@@ -3961,6 +3961,9 @@
 for we:= Low(TWorldEdge) to High(TWorldEdge) do
     ScriptSetInteger(EnumToStr(we), ord(we));
 
+ScriptSetInteger('capcolDefault'    , capcolDefault);
+ScriptSetInteger('capcolSetting'    , capcolSetting);
+
 ScriptSetInteger('gstDrowning'      , gstDrowning);
 ScriptSetInteger('gstHHDriven'      , gstHHDriven);
 ScriptSetInteger('gstMoving'        , gstMoving);
--- a/hedgewars/uStats.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uStats.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -162,7 +162,7 @@
         AddVoice(sndStupid, PreviousTeam^.voicepack);
         // Message for hurting itself only (not drowning)
         if (CurrentHedgehog^.stats.DamageGiven = CurrentHedgehog^.stats.StepDamageRecv) and (CurrentHedgehog^.stats.StepDamageRecv >= 1) then
-            AddCaption(FormatA(GetEventString(eidHurtSelf), s), cWhiteColor, capgrpMessage);
+            AddCaption(FormatA(GetEventString(eidHurtSelf), s), capcolDefault, capgrpMessage);
         end
 
     // Hog hurts, poisons or kills own team/clan member. Sacrifice is taken into account
@@ -205,7 +205,7 @@
     else if isTurnSkipped and (not PlacingHogs) then
         begin
         AddVoice(sndCoward, PreviousTeam^.voicepack);
-        AddCaption(FormatA(GetEventString(eidTurnSkipped), s), cWhiteColor, capgrpMessage);
+        AddCaption(FormatA(GetEventString(eidTurnSkipped), s), capcolDefault, capgrpMessage);
         end
     end;
 
--- a/hedgewars/uStore.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uStore.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -507,12 +507,12 @@
 
     InitHealth;
 
-    PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
-    AFKTexture:= RenderStringTex(trmsg[sidAFK], cYellowColor, fntBig);
+    PauseTexture:= RenderStringTex(trmsg[sidPaused], cCentralMessageColor, fntBig);
+    AFKTexture:= RenderStringTex(trmsg[sidAFK], cCentralMessageColor, fntBig);
     keyConfirm:= KeyBindToName('confirm');
     keyQuit:= KeyBindToName('quit');
-    ConfirmTexture:= RenderStringTex(Format(trmsg[sidConfirm], [keyConfirm, keyQuit]), cYellowColor, fntBig);
-    SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
+    ConfirmTexture:= RenderStringTex(Format(trmsg[sidConfirm], [keyConfirm, keyQuit]), cCentralMessageColor, fntBig);
+    SyncTexture:= RenderStringTex(trmsg[sidSync], cCentralMessageColor, fntBig);
 
     if not reload then
         AddProgress;
--- a/hedgewars/uTeams.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uTeams.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -82,7 +82,7 @@
     begin
     if AliveCount = 0 then
         begin // draw
-        AddCaption(GetEventString(eidRoundDraw), cWhiteColor, capgrpGameState);
+        AddCaption(GetEventString(eidRoundDraw), capcolDefault, capgrpGameState);
         if SendGameResultOn then
             SendStat(siGameResult, shortstring(trmsg[sidDraw]));
         AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000);
@@ -96,7 +96,7 @@
                 s:= ansistring(Teams[0]^.TeamName);
                 // Victory caption is randomly selected
                 cap:= FormatA(GetEventString(eidRoundWin), s);
-                AddCaption(cap, cWhiteColor, capgrpGameState);
+                AddCaption(cap, capcolDefault, capgrpGameState);
                 s:= FormatA(trmsg[sidWinner], s);
                 end
             else // clan with at least 2 teams wins
@@ -117,7 +117,7 @@
 
                 // The winner caption is the same as the stats message and not randomized
                 cap:= s;
-                AddCaption(cap, cWhiteColor, capgrpGameState);
+                AddCaption(cap, capcolDefault, capgrpGameState);
                 // TODO (maybe): Show victory animation/captions per-team instead of all winners at once?
                 end;
 
@@ -385,7 +385,7 @@
     if cHedgehogTurnTime < 1000000 then
         ReadyTimeLeft:= cReadyDelay;
     s:= ansistring(CurrentTeam^.TeamName);
-    AddCaption(FormatA(trmsg[sidReady], s), cWhiteColor, capgrpGameState)
+    AddCaption(FormatA(trmsg[sidReady], s), capcolDefault, capgrpGameState)
     end
 else
     begin
--- a/hedgewars/uTouch.pas	Wed Aug 08 14:10:32 2018 +0200
+++ b/hedgewars/uTouch.pas	Wed Aug 08 14:38:54 2018 +0200
@@ -296,7 +296,7 @@
     end;
 
 if targetting then
-    AddCaption(trmsg[sidPressTarget], cWhiteColor, capgrpAmmoInfo);
+    AddCaption(trmsg[sidPressTarget], capcolDefault, capgrpAmmoInfo);
 
 deleteFinger(pointerId);
 end;