## XIII
Class HudCartoonWindow

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

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

Direct Known Subclasses:None

class HudCartoonWindow
extends Engine.Info

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

Variables
`color` | `BorderColor`
`int` | `CWndAppearFX` optim to compute coords & mem them for multiple uses
`YS,` | `EndOfLife`
`HudCartoonWindow` | `NextHudWnd`
`OMsgWidth,` | `OMsgH` witdh of the message, Height of one line
`OMsgX,` | `OMsgY` position of message
`array` | `OverlayMsg` message to display in overlay
`HudCartoonWindow` | `PrevHudWnd`
`float` | `StartOfLife` optim to compute coords & mem them for multiple uses
`BitmapMaterial` | `WndTex`
`XP,` | `YP` optim to compute coords & mem them for multiple uses
`bool` | `bLowPriority` position of message

Function Summary
`simulated` | `AddCartoonWindow(float XPos, float YPos, float DXSize, float DYSize, BitmapMaterial Tex, float X, float Y, float XSize, float YSize, float Lifetime, color cBorder, int CWAFX, bool bLowPrio)`
`simulated` | `DrawWnd(Canvas C)`
    //____________________________________________________________________
`void` | `RemoveMe()`
    //____________________________________________________________________
`simulated` | `SetUpCartoonWindow(float XPos, float YPos, float DXSize, float DYSize, BitmapMaterial Tex, float X, float Y, float XSize, float YSize, float Lifetime, color cBorder, int CWAFX, bool bLowPrio)`
    //____________________________________________________________________

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class HudCartoonWindow extends Info
    00005	  NotPlaceable;
    00006
    00007	var HudCartoonWindow NextHudWnd;
    00008	var HudCartoonWindow PrevHudWnd;
    00009
    00010	var float XL, YL, DXS, DYS, XSt, YSt, XS, YS, EndOfLife;
    00011	var BitMapMaterial WndTex;
    00012	var color BorderColor;
    00013	var float XP, YP;                 // optim to compute coords & mem them for multiple uses
    00014
    00015	// vars for appearance sfx
    00016	var float StartOfLife;
    00017	var int CWndAppearFX;
    00018
    00019	// vars for overlay text
    00020	var array<string> OverlayMsg;     // message to display in overlay
    00021	var float OMsgWidth, OMsgH;       // witdh of the message, Height of one line
    00022	var float OMsgX, OMsgY;           // position of message
    00023	var bool bLowPriority;
    00024
    00025	CONST TRANSITDELAY=0.15;          // transition delay for SFXs
    00026
    00027	//____________________________________________________________________
    00028	simulated function SetUpCartoonWindow(float XPos, float YPos, float DXSize, float DYSize, BitMapMaterial Tex, float X, float Y, float XSize, float YSize, float Lifetime, color cBorder, int CWAFX, bool bLowPrio)
    00029	{
    00030	    XL = XPos;
    00031	    YL = YPos;
    00032	    DXS = DXSize;
    00033	    DYS = DYSize;
    00034	    WndTex = Tex;
    00035	    XSt = X;
    00036	    YSt = Y;
    00037	    XS = XSize;
    00038	    YS = YSize;
    00039	    StartOfLife = Level.TimeSeconds;
    00040	    EndOfLife = Level.TimeSeconds + LifeTime;
    00041	    BorderColor = cBorder;
    00042	    CWndAppearFX = CWAFX;
    00043	    bLowPriority = bLowPrio;
    00044	}
    00045
    00046	simulated function AddCartoonWindow(float XPos, float YPos, float DXSize, float DYSize, BitMapMaterial Tex, float X, float Y, float XSize, float YSize, float Lifetime, color cBorder, int CWAFX, bool bLowPrio)
    00047	{
    00048	    if ( bLowPrio && !bLowPriority )
    00049	      return; // don't add this as we have a high priority window on screen
    00050
    00051	    if ( NextHudWnd == none )
    00052	    {
    00053	      NextHudWnd = Spawn(class'HudCartoonWindow',Owner);
    00054	      NextHudWnd.PrevHudWnd = self;
    00055	      if( bLowPrio )
    00056	        NextHudWnd.SetUpCartoonWindow(XPos, YPos, DXSize, DYSize, Tex, X, Y, XSize, YSize, Lifetime, cBorder, CWAFX, true);
    00057	      else
    00058	        NextHudWnd.SetUpCartoonWindow(XPos, YPos, DXSize, DYSize, Tex, X, Y, XSize, YSize, Lifetime, cBorder, CWAFX, false);
    00059	    }
    00060	    else
    00061	    {
    00062	      if( bLowPrio )
    00063	        NextHudWnd.AddCartoonWindow(XPos, YPos, DXSize, DYSize, Tex, X, Y, XSize, YSize, Lifetime, cBorder, CWAFX, true);
    00064	      else
    00065	        NextHudWnd.AddCartoonWindow(XPos, YPos, DXSize, DYSize, Tex, X, Y, XSize, YSize, Lifetime, cBorder, CWAFX, false);
    00066	    }
    00067	}
    00068
    00069	//____________________________________________________________________
    00070	simulated function DrawWnd(Canvas C)
    00071	{
    00072	    local float fDrawScale;
    00073	    local int i;
    00074	    local float MsgXL, MsgYL;
    00075	    local float XAF, YAF, XSize, YSize;
    00076	    local float tX, tY;
    00077
    00078	    switch ( CWndAppearFX )
    00079	    {
    00080	      Case 0: //CAFX_None:
    00081	        XAF = 1.0;
    00082	        YAF = 1.0;
    00083	        XSize = 1.0;
    00084	        YSize = 1.0;
    00085	        break;
    00086	      Case 1: //CAFX_ComeFromLeft:
    00087	        XAF = 1.0 - fMax(0, StartOfLife + TRANSITDELAY - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00088	        YAF = 1.0;
    00089	        XSize = 1.0;
    00090	        YSize = 1.0;
    00091	        break;
    00092	      Case 2: //CAFX_ComeFromAbove:
    00093	        XAF = 1.0;
    00094	        YAF = 1.0 - fMax(0, StartOfLife + TRANSITDELAY  - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00095	        XSize = 1.0;
    00096	        YSize = 1.0;
    00097	        break;
    00098	      Case 3: //CAFX_StretchHorizontal:
    00099	        XAF = 1.0;
    00100	        YAF = 1.0;
    00101	        XSize = 1.0 - fMax(0, StartOfLife + TRANSITDELAY*0.5 - Level.TimeSeconds)*(1.0/TRANSITDELAY*0.5);
    00102	        YSize = 1.0;
    00103	        break;
    00104	      Case 4: //CAFX_StretchVertical:
    00105	        XAF = 1.0;
    00106	        YAF = 1.0;
    00107	        XSize = 1.0;
    00108	        YSize = 1.0 - fMax(0, StartOfLife + TRANSITDELAY*0.5 - Level.TimeSeconds)*(1.0/TRANSITDELAY*0.5);
    00109	        break;
    00110	      Case 5: //CAFX_Zoom
    00111	        XAF = 1.0;
    00112	        YAF = 1.0;
    00113	        XSize = 1.0 - fMax(0, StartOfLife + TRANSITDELAY*0.5 - Level.TimeSeconds)*(1.0/TRANSITDELAY*0.5);
    00114	        YSize = XSize;
    00115	        break;
    00116	      Case 6: //CAFX_ComeFromRight:
    00117	        XAF = 1.0 + fMax(0, StartOfLife + TRANSITDELAY - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00118	        YAF = 1.0;
    00119	        XSize = 1.0;
    00120	        YSize = 1.0;
    00121	        break;
    00122	      Case 7: //CAFX_ComeFromUnder:
    00123	        XAF = 1.0;
    00124	        YAF = 1.0 + fMax(0, StartOfLife + TRANSITDELAY  - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00125	        XSize = 1.0;
    00126	        YSize = 1.0;
    00127	        break;
    00128	      Case 8: //CAFX_ComeFromTopLeft:
    00129	        XAF = 1.0 - fMax(0, StartOfLife + TRANSITDELAY - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00130	        YAF = XAF;
    00131	        XSize = 1.0;
    00132	        YSize = 1.0;
    00133	        break;
    00134	      Case 9: //CAFX_ComeFromTopRight:
    00135	        XAF = 1.0 + fMax(0, StartOfLife + TRANSITDELAY - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00136	        YAF = 2.0 - XAF;
    00137	        XSize = 1.0;
    00138	        YSize = 1.0;
    00139	        break;
    00140	      Case 10: //CAFX_ComeFromDownLeft:
    00141	        XAF = 1.0 - fMax(0, StartOfLife + TRANSITDELAY - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00142	        YAF = 2.0 - XAF;
    00143	        XSize = 1.0;
    00144	        YSize = 1.0;
    00145	        break;
    00146	      Case 11: //CAFX_ComeFromDownRight:
    00147	        XAF = 1.0 + fMax(0, StartOfLife + TRANSITDELAY - Level.TimeSeconds)*(1.0/TRANSITDELAY);
    00148	        YAF = XAF;
    00149	        XSize = 1.0;
    00150	        YSize = 1.0;
    00151	        break;
    00152	    }
    00153	/*
    00154		CAFX_None,
    00155		CAFX_ComeFromLeft,
    00156		CAFX_ComeFromAbove,
    00157		CAFX_StretchHorizontal,
    00158		CAFX_StretchVertical,
    00159		CAFX_Zoom,
    00160		CAFX_ComeFromRight,
    00161		CAFX_ComeFromUnder,
    00162		CAFX_ComeFromTopLeft,
    00163		CAFX_ComeFromTopRight,
    00164		CAFX_ComeFromDownLeft,
    00165		CAFX_ComeFromDownright,
    00166	*/
    00167	    fDrawScale = C.ClipX/640.0;
    00168
    00169	    if (EndOfLife - Level.TimeSeconds > 0.01)
    00170	    {
    00171	      tX = DXS*fDrawScale*XSize;
    00172	      tY = DYS*fDrawScale*YSize;
    00173	      C.Style = ERenderStyle.STY_Alpha;
    00174
    00175	      if ( XAF <= 1.0 ) // come from left
    00176	        XP = int((XL*fDrawScale+XIIIBaseHUD(Owner).LeftMargin*C.ClipX) * XAF + DXS*fDrawScale*0.5*(1.0-XSize));
    00177	      else // come from right
    00178	        XP = int(
    00179	          (XL*fDrawScale+XIIIBaseHUD(Owner).LeftMargin*C.ClipX) * (2.0 - XAF)
    00180	          + (XAF - 1.0) * C.ClipX
    00181	          + DXS*fDrawScale*0.5*(1.0-XSize));
    00182	      if ( YAF <= 1.0 ) // come from above
    00183	        YP = int((YL*fDrawScale+XIIIBaseHUD(Owner).UpMargin*C.ClipY) * YAF + DYS*fDrawScale*0.5*(1.0-YSize));
    00184	      else // come from below
    00185	        YP = int(
    00186	          (YL*fDrawScale+XIIIBaseHUD(Owner).UpMargin*C.ClipY) * (2.0 - YAF)
    00187	          + (YAF - 1.0) * C.ClipY
    00188	          + DYS*fDrawScale*0.5*(1.0-YSize));
    00189
    00190	      if ( BorderColor.A != 0 )
    00191	      { // optim, drawing this is faster than using border (1 tile faster than 8 lines).
    00192	        C.SetPos(XP-8, YP-8);
    00193	        C.DrawColor = C.Static.MakeColor(0,0,0,255);
    00194	        C.DrawRect(XIIIBaseHUD(Owner).FondDlg, tX + 16, tY + 16);
    00195	        C.SetPos(XP-6, YP-6);
    00196	        C.DrawColor = BorderColor;
    00197	        C.DrawRect(XIIIBaseHUD(Owner).FondDlg, tX + 12, tY + 12);
    00198	        C.SetPos(XP-2,YP-2);
    00199	        C.DrawColor = C.Static.MakeColor(0,0,0,255);
    00200	        C.DrawRect(XIIIBaseHUD(Owner).FondDlg, tX + 4, tY + 4);
    00201	      }
    00202
    00203	      C.DrawColor = C.Static.MakeColor(255,255,255,255);
    00204	      C.SetPos(XP,YP);
    00205	      C.DrawTile(WndTex, tX, tY, XSt, YSt, XS, YS);
    00206
    00207	      // Draw Overlay message
    00208	      if ( OverlayMsg.Length > 0 )
    00209	      {
    00210	        XIIIBaseHUD(Owner).UseDialogFont(C);
    00211	        C.SpaceX = 0;
    00212	//        C.bTextShadow = true; // ELR Drawing Cwnd is time consuming enough, don't enable text shadows here
    00213	        if ( OMsgWidth == 0 )
    00214	        {
    00215	          for ( i=0; i<OverlayMsg.Length; i++)
    00216	          {
    00217	            C.StrLen( OverlayMsg[i], MsgXL, MsgYL);
    00218	            OMsgWidth = fMax( MsgXL, OMsgWidth );
    00219	            OMsgH = fMax( MsgYL, OMsgH );
    00220	          }
    00221	        }
    00222	        OMsgX = XL + DXS;
    00223	        OMsgY = YL + 10;
    00224	        XP = OMsgX*fDrawScale + XIIIBaseHUD(Owner).LeftMargin*C.ClipX - 3;
    00225	        YP = OMsgY*fDrawScale + XIIIBaseHUD(Owner).UpMargin*C.ClipY - 3;
    00226	        C.Style = ERenderStyle.STY_Alpha;
    00227	        C.SetPos(XP-2, YP-2);
    00228	        C.SetDrawColor(0,0,0,255);
    00229	        C.DrawRect(XIIIBaseHUD(Owner).FondDlg, OMsgWidth + 6 + 4, OMsgH*OverlayMsg.Length + 6 + 4);
    00230	        C.SetPos(XP, YP);
    00231	        C.SetDrawColor(220,220,220,255);
    00232	        C.DrawRect(XIIIBaseHUD(Owner).FondDlg, OMsgWidth + 6 , OMsgH*OverlayMsg.Length + 6);
    00233	        XP = OMsgX*fDrawScale + XIIIBaseHUD(Owner).LeftMargin*C.ClipX;
    00234	        YP = OMsgY*fDrawScale + XIIIBaseHUD(Owner).UpMargin*C.ClipY;
    00235	        C.SetDrawColor(15,15,15,255);
    00236	        for ( i=0; i<OverlayMsg.Length; i++)
    00237	        {
    00238	          C.SetPos(XP, YP + i*OMsgH);
    00239	          C.DrawText(OverlayMsg[i]);
    00240	        }
    00241	      }
    00242	    }
    00243
    00244	    if (NextHudWnd != none)
    00245
NextHudWnd.DrawWnd(C); 00246 00247 if ( Level.TimeSeconds > EndOfLife ) 00248 ReMoveMe(); 00249 } 00250 00251 //____________________________________________________________________ 00252 function RemoveMe() 00253 { 00254 XIIIBaseHUD(Owner).CWndMat.FreeRect(XSt, YSt, XS, YS); 00255 00256 if (PrevHudWnd == none) 00257 { 00258 if (NextHudWnd != none) 00259 { 00260 XIIIBaseHUD(Owner).HudWnd = NextHudWnd; 00261 NextHudWnd.PrevHudWnd = none; 00262 } 00263 else 00264 XIIIBaseHUD(Owner).HudWnd = none; 00265 } 00266 else 00267 { 00268 PrevHudWnd.NextHudWnd = NextHudWnd; 00269 if ( NextHudWnd != none ) 00270 NextHudWnd.PrevHudWnd = PrevHudWnd; 00271 } 00272 Destroy(); 00273 } 00274 00275 00276 00277 defaultproperties 00278 { 00279 BorderColor=(B=255,G=255,R=255,A=255) 00280 }

End Source Code