XIII
Class HudEndMessage

source: C:\XIII\XIII\Classes\HudEndMessage.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--XIII.HudEndMessage
Direct Known Subclasses:None

class HudEndMessage
extends Engine.Info

//----------------------------------------------------------- // used for if ( ( Message == class'XIIIEndGameMessage' ) || ( Message == class'XIIIMissionCompletedMessage' ) ) //-----------------------------------------------------------
Variables
 color DrawColor
 float EndOfLife
 float LifeTime
 Class Message
 HUDLocalizedMessage MyMessage
 HudEndMessage NextHudMsg
 Object OptionalObject
 HudEndMessage PrevHudMsg
 PlayerReplicationInfo RelatedPRI
 NooTex, SplatshTex
           If true, don't erase (increase lifetime indefinetly until player access info menu)
 string StringMessage
 int Switch
 Texture WhiteTex
           If true, don't erase (increase lifetime indefinetly until player access info menu)
 float YP
 bool bCenter
 bool bDrawing
 bool bIsSpecial
           If true, don't erase (increase lifetime indefinetly until player access info menu)
 float fXSize
 int index
 int numLines


Function Summary
 void ActualizeIndex()
     
//____________________________________________________________________
 void DestroyFirstMessage()
     
//____________________________________________________________________
 
simulated
DrawMsg(Canvas C)
     
//____________________________________________________________________
 void ProcessMessage(Canvas C)
     
//____________________________________________________________________
 void RemoveMe()
     
//____________________________________________________________________



Source Code


00001	//-----------------------------------------------------------
00002	// used for if ( ( Message == class'XIIIEndGameMessage' ) || ( Message == class'XIIIMissionCompletedMessage' ) )
00003	//-----------------------------------------------------------
00004	class HudEndMessage extends Info
00005	  NotPlaceable;
00006	
00007	var HudEndMessage NextHudMsg;
00008	var HudEndMessage PrevHudMsg;
00009	var int index;
00010	const MAXDISPLAYEDMESSAGES = 7;
00011	
00012	struct HUDLocalizedMessage
00013	{
00014	    var Class<LocalMessage> Message;
00015	    var int Switch;
00016	    var PlayerReplicationInfo RelatedPRI;
00017	    var Object OptionalObject;
00018	    var float EndOfLife;
00019	    var float LifeTime;
00020	    var bool bDrawing;
00021	    var int numLines;
00022	    var string StringMessage;
00023	    var color DrawColor;
00024	    var bool bCenter;
00025	    var float fXSize;
00026	};
00027	
00028	var HUDLocalizedMessage MyMessage;
00029	var float YP;
00030	var bool bIsSpecial; // If true, don't erase (increase lifetime indefinetly until player access info menu)
00031	
00032	var texture BloodTex, WinTex, NooTex, SplatshTex;
00033	var texture WhiteTex;
00034	
00035	CONST DBMSG=false;
00036	
00037	// new method using auto-line cut
00038	//____________________________________________________________________
00039	simulated function SetUpLocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString )
00040	{
00041	    if ( CriticalString == "" )
00042	      CriticalString = Message.Static.GetString(Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject);
00043	
00044	//    Log("EndMsg SetUpLocalizedMessage switch="$switch);
00045	    if ( CriticalString == "" )
00046	      RemoveMe();
00047	
00048	    bIsSpecial = Message.Default.bIsSpecial;
00049	    MyMessage.Message = Message;
00050	    MyMessage.Switch = switch;
00051	    MyMessage.RelatedPRI = RelatedPRI_1;
00052	    MyMessage.OptionalObject = OptionalObject;
00053	    if ( MessageTrigger(OptionalObject) != none )
00054	    {
00055	      MyMessage.EndOfLife = MessageTrigger(OptionalObject).fMessageDuration + Level.TimeSeconds;
00056	      MyMessage.LifeTime = MessageTrigger(OptionalObject).fMessageDuration;
00057	    }
00058	    else
00059	    {
00060	      MyMessage.EndOfLife = Message.Default.Lifetime + Level.TimeSeconds;
00061	      MyMessage.LifeTime = Message.Default.Lifetime;
00062	    }
00063	    MyMessage.bDrawing = true;
00064	    MyMessage.NumLines = 0; // should be initialized first time we draw the string
00065	    MyMessage.StringMessage = CriticalString;
00066	    MyMessage.DrawColor = Message.Static.GetColor(Switch, RelatedPRI_1, RelatedPRI_2);
00067	    MyMessage.bCenter = Message.default.bCenter;
00068	    MyMessage.fXSize = 0; // should be initialized first time we draw the string
00069	
00070	    if ( PrevHudMsg != none )
00071	      index = PrevHudMsg.index + 1;
00072	    else
00073	      index = 0;
00074	
00075	    if ( DBMSG ) log("MESSAGE index="$index@"'"$CriticalString$"'");
00076	    if ( index >= MAXDISPLAYEDMESSAGES )
00077	      PrevHudMsg.DestroyFirstMessage();
00078	}
00079	
00080	//____________________________________________________________________
00081	simulated function AddLocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString )
00082	{
00083	    if ( DBMSG ) Log("MESSAGE "$self$" AddLocalizedMessage index="$index$" NextHudMsg="$NextHudMsg);
00084	
00085	    if ( Message.default.bIsSpecial && bIsSpecial )
00086	      return; // don't draw 2 special messages.
00087	
00088	    if ( NextHudMsg == none )
00089	    {
00090	      NextHudMsg = Spawn(class'HudEndMessage',Owner);
00091	      NextHudMsg.PrevHudMsg = self;
00092	      NextHudMsg.SetUpLocalizedMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString );
00093	    }
00094	    else
00095	      NextHudMsg.AddLocalizedMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString );
00096	}
00097	
00098	//____________________________________________________________________
00099	function ProcessMessage(Canvas C)
00100	{
00101	    Local int i; // Index of the processed space
00102	    local int j; // number of lines
00103	    local int k; // index of the starting current strine
00104	    local string SubString, NewCriticalString, NewCriticalCurrentString;
00105	    local float XT,XT2,YT;
00106	    local bool bNotFirstTime;
00107	    local string LeftString;
00108	
00109	    MyMessage.fXSize = C.ClipX * (1.0 - XIIIBaseHUD(Owner).RightMargin - XIIIBaseHUD(Owner).LeftMargin);
00110	
00111	    if ( DBMSG ) Log("ProcessMessage, Len="$MyMessage.fXSize$" string="$MyMessage.StringMessage);
00112	    j = 1;
00113	
00114	//    XIIIBaseHUD(Owner).UseMsgFont(C);
00115	//    C.SpaceX=0;
00116	
00117	    SubString = MyMessage.StringMessage;
00118	    NewCriticalString = "";
00119	    NewCriticalcurrentString = "";
00120	    i = InStr(SubString, " ");
00121	    if ( DBMSG ) Log("NewCriticalCurrentString='"$NewCriticalCurrentString$"' SHOULD BE ''");
00122	    While ( i >= 0 )
00123	    {
00124	      LeftString = Left(SubString, i);
00125	      if ( DBMSG ) Log("pass I="$i$" adding '"$NewCriticalCurrentString$"' with '"$LeftString$"'");
00126	      NewCriticalCurrentString = NewCriticalCurrentString$LeftString;
00127	      C.StrLen(NewCriticalCurrentString, XT2, YT);
00128	      if ( DBMSG ) Log("NewCriticalCurrentString='"$NewCriticalCurrentString$"' Len="$XT2);
00129	      if ( (XT2 >= MyMessage.fXSize) || (XT2 == XT) )
00130	      {
00131	        NewCriticalString = NewCriticalString$"#N"$LeftString;
00132	        NewCriticalcurrentString = LeftString$" ";
00133	        j++;
00134	      }
00135	      else
00136	      {
00137	        if ( bNotFirstTime )
00138	          NewCriticalString = NewCriticalString$" "$LeftString;
00139	        else
00140	          NewCriticalString = LeftString;
00141	        NewCriticalcurrentString = NewCriticalcurrentString$" ";
00142	      }
00143	      bNotFirstTime=true;
00144	      XT = XT2;
00145	      SubString = right(SubString, len(SubString) - i - 1);
00146	      if ( DBMSG ) Log("  NewCriticalString='"$NewCriticalString$"' SubString='"$SubString$"'");
00147	      i = InStr(SubString, " ");
00148	    }
00149	    // Last Word
00150	    if ( DBMSG ) Log("Processing Last Word,  NewCriticalCurrentString='"$NewCriticalCurrentString$"' SubString='"$SubString$"'");
00151	    NewCriticalCurrentString = NewCriticalCurrentString$SubString;
00152	    C.StrLen(NewCriticalCurrentString, XT2, YT);
00153	    if ( DBMSG ) Log("NewCriticalCurrentString='"$NewCriticalCurrentString$"' Len="$XT2);
00154	    if ( (XT2 >= MyMessage.fXSize) || (XT == XT2) )
00155	    {
00156	      NewCriticalString = NewCriticalString$"#N"$SubString;
00157	      j++;
00158	    }
00159	    else
00160	    {
00161	      if ( bNotFirstTime )
00162	        NewCriticalString = NewCriticalString$" "$SubString;
00163	      else
00164	        NewCriticalString = SubString;
00165	    }
00166	    if ( DBMSG ) Log("  NewCriticalString='"$NewCriticalString$"'");
00167	
00168	    MyMessage.NumLines = j;
00169	    MyMessage.StringMessage = NewCriticalString;
00170	}
00171	
00172	//____________________________________________________________________
00173	simulated function DrawMsg(Canvas C)
00174	{
00175	    local float XP;
00176	    local float XL, YL, fAlpha, XT, YT;
00177	    Local int i,j;
00178	    local string OutString, SubString;
00179	
00180	    C.SpaceX = 0;
00181	    if ( MyMessage.Switch == 0 )
00182	      C.bTextShadow = false;
00183	    else
00184	      C.bTextShadow = true;
00185	
00186	    XIIIBaseHUD(Owner).UseLargeFont(C);
00187	    C.StrLen("A",XL,YL);
00188	
00189	    if ( MyMessage.NumLines == 0 )
00190	      ProcessMessage(C);
00191	
00192	    if ( PrevHudMsg != none )
00193	      YP = PrevHudMsg.YP;
00194	    else
00195	      YP = XIIIBaseHUD(Owner).YP;
00196	
00197	
00198	    YP -= ( (YL+0)*MyMessage.NumLines + 8 );
00199	
00200	    fAlpha = fMin(0.25, MyMessage.EndOfLife - Level.TimeSeconds) * 4.0;
00201	
00202	    if ( bIsSpecial )
00203	      fAlpha = 1.0;
00204	
00205	// Switch == 0 -> Level Complete
00206	// Switch == 1 -> Death killed
00207	// Switch == 3 -> Goal InComplete
00208	// Switch == 4 -> Player Falling
00209	
00210	    if (fAlpha > 0.01)
00211	    {
00212	      C.Style = ERenderStyle.STY_Alpha;
00213	
00214	      // Background
00215	      // White background for all
00216	      C.DrawColor = C.Static.MakeColor(255,255,255);
00217	      C.DrawColor.A = 255*fAlpha;
00218	      C.bUseBorder = false;
00219	//        C.SetPos(XP - 6,YP - 6);
00220	      C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin-6,YP+4-6);
00221	      C.DrawRect(WhiteTex, MyMessage.fXSize + 8 + 12 , MyMessage.NumLines*YL + 8 + 12);
00222	
00223	//      Log("MSG Display switch="$MyMessage.Switch);
00224	      // then background for message w/ black border
00225	      if ( MyMessage.switch == 0 ) // Complete
00226	        C.DrawColor = C.static.MakeColor(65*0.4,186*0.5,212*0.7,180*fAlpha);
00227	      else // Failure
00228	        C.DrawColor = C.Static.MakeColor(255,150,0,180*fAlpha);
00229	      C.BorderColor= C.Static.MakeColor(0,0,0);
00230	      C.BorderColor.A = 255;
00231	      C.bUseBorder = true;
00232	//        C.SetPos(XP,YP);
00233	      C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin,YP+4);
00234	      C.DrawRect(WhiteTex, MyMessage.fXSize + 8 , MyMessage.NumLines*YL + 8);
00235	      C.bUseBorder = false;
00236	
00237	      if ( MyMessage.NumLines == 1 )
00238	      {
00239	        C.StrLen(MyMessage.StringMessage, XT, YT);
00240	/*
00241	        // BackGround
00242	        C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin,YP+4);
00243	        C.DrawColor = MyMessage.DrawColor *0.3;
00244	        C.DrawColor.A = 90;
00245	        C.BorderColor= MyMessage.DrawColor;
00246	        C.BorderColor.A = 255;
00247	        C.bUseBorder = true;
00248	        C.DrawTile( XIIIBaseHUD(Owner).FondMsg, C.ClipX * (1.0 - XIIIBaseHUD(Owner).RightMargin - XIIIBaseHUD(Owner).LeftMargin),YT+4,0,0, XIIIBaseHUD(Owner).FondMsg.USize,XIIIBaseHUD(Owner).FondMsg.VSize );
00249	        C.bUseBorder = false;
00250	*/
00251	
00252	        // Text
00253	        C.SetPos((C.ClipX-XT)/2+1,YP+7);
00254	        C.DrawColor = MyMessage.DrawColor*0.3;
00255	        C.DrawColor.A = C.DrawColor.A * fAlpha;
00256	        C.DrawText(MyMessage.StringMessage);
00257	
00258	        C.SetPos((C.ClipX-XT)/2,YP+6);
00259	        C.DrawColor = MyMessage.DrawColor;
00260	        C.DrawColor.A = C.DrawColor.A * fAlpha;
00261	        C.DrawText(MyMessage.StringMessage);
00262	      }
00263	      else
00264	      {
00265	        C.StrLen("A", XT, YT);
00266	
00267	/*
00268	        C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin,YP+4);
00269	        C.DrawColor = MyMessage.DrawColor *0.3;
00270	        C.DrawColor.A = 90;
00271	        C.BorderColor= MyMessage.DrawColor;
00272	        C.BorderColor.A = 255;
00273	        C.bUseBorder = true;
00274	        C.DrawTile( XIIIBaseHUD(Owner).FondMsg, C.ClipX * (1.0 - XIIIBaseHUD(Owner).RightMargin - XIIIBaseHUD(Owner).LeftMargin), (MyMessage.NumLines)*(YT+0)+4,0,0, XIIIBaseHUD(Owner).FondMsg.USize,XIIIBaseHUD(Owner).FondMsg.VSize );
00275	        C.bUseBorder = false;
00276	*/
00277	        j = 0;
00278	        SubString = MyMessage.StringMessage;
00279	        i = InStr(SubString, "#N");
00280	
00281	        while ( i >= 0 )
00282	        {
00283	            OutString = Left(SubString, i);
00284	
00285	            C.StrLen(OutString, XT, YT);
00286	
00287	            C.SetPos((C.ClipX-XT)/2+1,YP+4+j*(YT+0)+3);
00288	            C.DrawColor = MyMessage.DrawColor*0.3;
00289	            C.DrawColor.A = C.DrawColor.A * fAlpha;
00290	            C.DrawText(OutString);
00291	
00292	            C.SetPos((C.ClipX-XT)/2,YP+4+j*(YT+0)+2);
00293	            C.DrawColor = MyMessage.DrawColor;
00294	            C.DrawColor.A = C.DrawColor.A * fAlpha;
00295	            C.DrawText(OutString);
00296	
00297	            j ++;
00298	            SubString = right(SubString, Len(SubString)-i-2);
00299	            i = InStr(SubString, "#N");
00300	        }
00301	
00302	        C.StrLen(SubString, XT, YT);
00303	
00304	        C.SetPos((C.ClipX-XT)/2+1,YP+4+j*(YT+0)+3);
00305	        C.DrawColor = MyMessage.DrawColor*0.3;
00306	        C.DrawColor.A = C.DrawColor.A * fAlpha;
00307	        C.DrawText(SubString);
00308	
00309	        C.SetPos((C.ClipX-XT)/2,YP+4+j*(YT+0)+2);
00310	        C.DrawColor = MyMessage.DrawColor;
00311	        C.DrawColor.A = C.DrawColor.A * fAlpha;
00312	        C.DrawText(SubString);
00313	      }
00314	      if ( MyMessage.Switch == 1 ) // Death
00315	      {
00316	        C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin + 16,YP-8-BloodTex.vSize/2.0);
00317	        C.DrawColor = C.static.MakeColor(255,100,0,255);
00318	        C.DrawIcon(BloodTex, 1.0);
00319	      }
00320	      if ( MyMessage.Switch == 4 ) // Fall
00321	      {
00322	        C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin + 16,YP-8-SplatshTex.vSize/4.0);
00323	        C.DrawColor = C.static.MakeColor(255,100,0,255);
00324	        C.DrawIcon(SplatshTex, 0.5);
00325	      }
00326	      else if ( MyMessage.Switch == 3 ) // failure
00327	      {
00328	        C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin + 16,YP-8-NooTex.vSize/2.0+4);
00329	        C.DrawColor = C.static.MakeColor(255,100,0,255);
00330	        C.DrawIcon(NooTex, 0.6);
00331	      }
00332	      else if ( MyMessage.Switch == 0 ) // Win
00333	      {
00334	        C.SetPos(C.ClipX * XIIIBaseHUD(Owner).LeftMargin + 16,YP-8-WinTex.vSize/2.0);
00335	        C.DrawColor = C.static.MakeColor(255,255,255,255);
00336	        C.DrawIcon(WinTex, 1.0);
00337	      }
00338	    }
00339	    else
00340	      fAlpha = 0.0;
00341	
00342	    if ( NextHudMsg != none )
00343	      NextHudMsg.DrawMsg(C);
00344	    else
00345	      XIIIBaseHUD(Owner).YP = YP;
00346	
00347	    if ( fAlpha == 0.0 )
00348	      ReMoveMe();
00349	
00350	    C.SpaceX = 0;
00351	}
00352	
00353	//____________________________________________________________________
00354	function RemoveMe()
00355	{
00356	    if (PrevHudMsg == none)
00357	    {
00358	      if (NextHudMsg != none)
00359	      {
00360	        XIIIBaseHUD(Owner).HudEndMsg = NextHudMsg;
00361	        NextHudMsg.PrevHudMsg = none;
00362	      }
00363	      else
00364	        XIIIBaseHUD(Owner).HudEndMsg = none;
00365	    }
00366	    else
00367	    {
00368	      PrevHudMsg.NextHudMsg = NextHudMsg;
00369	      if ( NextHudMsg != none )
00370	        NextHudMsg.PrevHudMsg = PrevHudMsg;
00371	    }
00372	    Destroy();
00373	}
00374	
00375	//____________________________________________________________________
00376	function DestroyFirstMessage()
00377	{
00378	    if ( (index == 0) || (PrevHudMsg == none) )
00379	    {
00380	      index = -1;
00381	      NextHudMsg.ActualizeIndex();
00382	      RemoveMe();
00383	    }
00384	    else
00385	      PrevHudMsg.DestroyFirstMessage();
00386	}
00387	
00388	//____________________________________________________________________
00389	function ActualizeIndex()
00390	{
00391	    if ( PrevHudMsg != none )
00392	      Index = PrevHudMsg.index + 1;
00393	    if ( NextHudMsg != none )
00394	      NextHudMsg.ActualizeIndex();
00395	}
00396	
00397	
00398	
00399	defaultproperties
00400	{
00401	     BloodTex=Texture'XIIICine.effets.vignetteblood'
00402	     WinTex=Texture'XIIICine.effets.impactpoing2A'
00403	     NooTex=Texture'XIIICine.effets.death4'
00404	     SplatshTex=Texture'XIIICine.effets.craash'
00405	     WhiteTex=Texture'XIIIMenu.HUD.blanc'
00406	}

End Source Code