## XIII
Class HudState

source: C:\XIII\XIII\Classes\HudState.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--XIII.HudState

Direct Known Subclasses:None

class HudState
extends Engine.Info

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`color` | `DrawColor`
`float` | `EndOfLife`
`float` | `LifeTime`
`Class` | `Message`
`HUDLocalizedMessage` | `MyMessage`
`Object` | `OptionalObject`
`string` | `StringMessage`
`int` | `Switch`
`float` | `YP`
`float` | `fXSize`
`int` | `numLines`

Function Summary
`simulated` | `DrawStt(Canvas C)`
    //____________________________________________________________________
`void` | `ProcessMessage(Canvas C)`
    //____________________________________________________________________
`void` | `RemoveMe()`

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class HudState extends Info
    00005	  NotPlaceable;
    00006
    00007	struct HUDLocalizedMessage
    00008	{
    00009	    var Class<LocalMessage> Message;
    00010	    var int Switch;
    00011	//    var PlayerReplicationInfo RelatedPRI;
    00012	    var Object OptionalObject;
    00013	    var float EndOfLife;
    00014	    var float LifeTime;
    00015	//    var bool bDrawing;
    00016	    var int numLines;
    00017	    var string StringMessage;
    00018	    var color DrawColor;
    00019	//    var bool bCenter;
    00020	    var float fXSize;
    00021	};
    00022
    00023	var HUDLocalizedMessage MyMessage;
    00024	var float YP;
    00025
    00026	// New method using auto-line cut
    00027	//____________________________________________________________________
    00028	simulated function SetUpLocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString )
    00029	{
    00030	    if ( CriticalString == "" )
    00031	      CriticalString = Message.Static.GetString(Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject);
    00032	    CriticalString=Caps(CriticalString);
    00033
    00034	    if ( CriticalString == "" )
    00035	      RemoveMe();
    00036
    00037	    MyMessage.Message = Message;
    00038	    MyMessage.Switch = Switch;
    00039	    MyMessage.OptionalObject = OptionalObject;
    00040	    MyMessage.EndOfLife = Message.Default.Lifetime + Level.TimeSeconds;
    00041	    MyMessage.LifeTime = Message.Default.Lifetime;
    00042	    MyMessage.NumLines = 0; // should be initialized first time we draw the string
    00043	    MyMessage.StringMessage = CriticalString;
    00044	    MyMessage.DrawColor = Message.Static.GetColor(Switch, RelatedPRI_1, RelatedPRI_2);
    00045	    MyMessage.fXSize = 0; // should be initialized first time we draw the string
    00046	}
    00047
    00048	//____________________________________________________________________
    00049	/*
    00050	simulated function AddLocalizedMessage( class<LocalMessage> Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString )
    00051	{
    00052	    if ( NextHudDlg == none )
    00053	    {
    00054	      NextHudDlg = Spawn(class'HudDialog',Owner);
    00055	      NextHudDlg.PrevHudDlg = self;
    00056	      NextHudDlg.SetUpLocalizedMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString );
    00057	    }
    00058	    else
    00059	    {
    00060	      NextHudDlg.AddLocalizedMessage( Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject, CriticalString );
    00061	    }
    00062	}*/
    00063
    00064	//____________________________________________________________________
    00065	FUNCTION ProcessMessage(Canvas C)
    00066	{
    00067	    local int i; // Index of the processed space
    00068	    local int linesCounter; // number of lines
    00069	    local string SubString, NewCriticalString, NewCriticalCurrentString;
    00070	    local float XT,XT2,YT;
    00071	    local string LeftString;
    00072
    00073	    MyMessage.fXSize = C.ClipX * (1.0 - XIIIBaseHUD(Owner).RightMargin - XIIIBaseHUD(Owner).LeftMargin) * 0.7;
    00074	    linesCounter = 1;
    00075	    XIIIBaseHUD(Owner).UseMsgFont(C);
    00076	    C.SpaceX=0;
    00077	    SubString = MyMessage.StringMessage;
    00078	    NewCriticalString = "";
    00079	    NewCriticalcurrentString = "";
    00080	    i = InStr(SubString, " ");
    00081	    while ( i >= 0 )
    00082	    {
    00083	      LeftString = Left(SubString, i);
    00084	      NewCriticalCurrentString = NewCriticalCurrentString$LeftString;
    00085	      C.StrLen(NewCriticalCurrentString, XT2, YT);
    00086	      if ( (XT2 >= MyMessage.fXSize-20) || (XT2 == XT) )
    00087	      {
    00088	        NewCriticalString = NewCriticalString$"#N"$LeftString;
    00089	        NewCriticalcurrentString = LeftString$" ";
    00090	        linesCounter++;
    00091	      }
    00092	      else
    00093	      {
    00094	        NewCriticalString = NewCriticalString@LeftString;
    00095	        NewCriticalcurrentString = NewCriticalcurrentString$" ";
    00096	      }
    00097	      XT = XT2;
    00098	      SubString = Mid (SubString,i+1);
    00099	      i = InStr(SubString, " ");
    00100	    }
    00101	// Last Word
    00102	    NewCriticalCurrentString = NewCriticalCurrentString$SubString;
    00103	    C.StrLen(NewCriticalCurrentString, XT2, YT);
    00104	    if ( (XT2 >= MyMessage.fXSize-20) || (XT == XT2) )
    00105	    {
    00106	      NewCriticalString = NewCriticalString$"#N"$SubString;
    00107	      linesCounter++;
    00108	    }
    00109	    else
    00110	      NewCriticalString = NewCriticalString@SubString;
    00111
    00112	    MyMessage.NumLines = linesCounter;
    00113	    MyMessage.StringMessage = NewCriticalString;
    00114	}
    00115
    00116	//____________________________________________________________________
    00117	simulated function DrawStt(Canvas C)
    00118	{
    00119	    Local float XL,YL,XT,YT,XP;
    00120	    local float fAlpha;
    00121	    local int i,j;
    00122	    local string OutString, SubString;
    00123
    00124	    if( XIIIBaseHUD(Owner).HudCartoonSFX )
    00125	        return;
    00126
    00127	    C.SpaceX=0;
    00128	    if ( MyMessage.NumLines == 0 )
    00129	      ProcessMessage(C);
    00130
    00131	    XIIIBaseHUD(Owner).UseMsgFont(C);
    00132	    C.StrLen("A",XL,YL);
    00133
    00134	    YP = C.ClipY/2.0 - YL*MyMessage.NumLines -8;
    00135	    XP = (C.ClipX - MyMessage.fXSize -8)/2.0;
    00136
    00137	    fAlpha = fMin(0.10, MyMessage.EndOfLife - Level.TimeSeconds) * 4.0;
    00138
    00139	    if (fAlpha > 0.01)
    00140	    {
    00141	      C.SetPos(XP,YP);
    00142	      C.Style = ERenderStyle.STY_Alpha;
    00143	      C.DrawColor = MyMessage.DrawColor * 0.3;
    00144	      C.DrawColor.A = 150 * fAlpha;
    00145	      C.BorderColor = MyMessage.DrawColor;
    00146	      C.BorderColor.A = 255 * fAlpha;
    00147	      C.bUseBorder = true;
    00148	      C.DrawTile(XIIIBaseHUD(Owner).FondMsg, MyMessage.fXSize+8 ,YL*MyMessage.NumLines+8, 0, 0, XIIIBaseHUD(Owner).FondMsg.USize, XIIIBaseHUD(Owner).FondMsg.VSize);
    00149	      C.bUseBorder = false;
    00150
    00151	      C.Style = ERenderStyle.STY_Alpha;
    00152
    00153	      j = 0;
    00154	      SubString = MyMessage.StringMessage;
    00155	      do
    00156	      {
    00157	        i = InStr(SubString, "#N");
    00158
    00159	        if (i>0)
    00160	          OutString = Left(SubString, i);
    00161	        else
    00162	          OutString = SubString;
    00163
    00164	        C.StrLen(OutString, XT, YT);
    00165	        C.SetPos((C.ClipX-XT)/2+2,YP+4+j*(YT+0)+2);
    00166	        C.DrawColor = MyMessage.DrawColor;
    00167	        C.DrawColor.A = 255 * fAlpha;
    00168	        C.DrawText(OutString);
    00169
    00170	        j ++;
    00171	        SubString = right(SubString, Len(SubString)-i-2);
    00172	      } until ( i < 0 );
    00173	    }
    00174	    else
    00175	      fAlpha = 0.0;
    00176
    00177	    if ( (MyMessage.EndOfLife <= Level.TimeSeconds)  )
    00178	      ReMoveMe();
    00179	    C.SpaceX=0;
    00180	    C.bCenter = false;
    00181	}
    00182
    00183	function RemoveMe()
    00184	{
    00185	    XIIIBaseHUD(Owner).HudStt = none;
    00186	    Destroy();
    00187	}
    00188
    00189	//    HudDlgFont=font'XIIIfonts.PoliceF16'
    00190
    00191
    00192	defaultproperties
    00193	{
    00194	}

End Source Code