## XIDInterf
Class XIIIValueControl

source: C:\XIII\XIDInterf\Classes\XIIIValueControl.uc

    Core.Object
       |
       +--GUI.GUI
          |
          +--GUI.GUIComponent
             |
             +--GUI.GUILabel
                |
                +--XIDInterf.XIIIGUIBaseButton
                   |
                   +--XIDInterf.XIIIValueControl

Direct Known Subclasses:None

class XIIIValueControl
extends XIDInterf.XIIIGUIBaseButton

Variables
`FirstBoxWidth,` | `CanvasClipX`
`ValX,` | `TextY`
`bShowLeftArrow,` | `bShowRightArrow`
`minValue,` | `maxValue`
`string` | `sValue`
`Texture` | `tArrow`

Function Summary
`void` | `BeforePaint(Canvas C, float X, float Y)`
`void` | `Created()`
    /*
`int` | `GetValue()`
`void` | `InitComponent(GUIController MyController, GUIComponent MyOwner)`
`bool` | `InternalOnClick(out byte)`
`bool` | `InternalOnKeyEvent(out byte, out byte, float delta)`
`void` | `Paint(Canvas C, float X, float Y)`
`void` | `SetArrows()`
    //    tArrow = texture(DynamicLoadObject("XIIIMenuStart.Load_game.fleches", class'Texture'));
    }
    */
`void` | `SetRange(int Vmin, int Vmax)`
`void` | `SetValue(int v)`

Source Code

    00001	class XIIIValueControl extends XIIIGUIBaseButton;
    00002
    00003	//var XIIIArrowButton leftArrow, rightArrow;
    00004
    00005	var int Value, minValue, maxValue;
    00006	var float TextX, ValX, TextY;
    00007	var texture tArrow;
    00008	var string sValue;
    00009	var bool bCalculateSize, bShowLeftArrow, bShowRightArrow;
    00010	var float FirstBoxWidth, CanvasClipX;
    00011
    00012	function InitComponent(GUIController MyController, GUIComponent MyOwner)
    00013	{
    00014		Super.InitComponent(MyController, MyOwner);
    00015		OnKeyEvent = InternalOnKeyEvent;
    00016	}
    00017
    00018	/*
    00019	function Created()
    00020	{
    00021	    super.Created();
    00022	//    tArrow = texture(DynamicLoadObject("XIIIMenuStart.Load_game.fleches", class'Texture'));
    00023	}
    00024	*/
    00025	function SetArrows()
    00026	{
    00027	/*     leftArrow = XIIIArrowbutton(NotifyWindow.CreateControl(class'XIIIArrowbutton', Winleft + 200, WinTop + 4, 12, 12));
    00028	     leftArrow.OwnerWindow = self;
    00029	     leftArrow.bLeftOrient = true;
    00030	     rightArrow = XIIIArrowbutton(NotifyWindow.CreateControl(class'XIIIArrowbutton', WinLeft + 204, WinTop + 4, 12, 12));
    00031	     rightArrow.OwnerWindow = self;*/
    00032	}
    00033
    00034	FUNCTION SetRange( int Vmin, int Vmax )
    00035	{
    00036		minValue = Vmin;
    00037		maxValue = Vmax;
    00038	}
    00039
    00040	function BeforePaint(Canvas C, float X, float Y)
    00041	{
    00042	    local float W, H;
    00043
    00044		if ( bCalculateSize )
    00045		{
    00046			C.TextSize(/*/Caps*/(Text), W, H);
    00047			TextX = ((2*WinWidth*640*fRatioX)/3 - W)/2;
    00048			TextY = (WinHeight*480*fRatioY - H)/2;
    00049			C.TextSize(sValue, W, H);
    00050			ValX = (2*WinWidth*640*fRatioX)/3 + ((WinWidth*640*fRatioX)/3 - W + 16)/2;
    00051		}
    00052		else
    00053		{
    00054			C.TextSize(/*Caps*/(Text), W, H);
    00055			TextX = (FirstBoxWidth - W)/2;
    00056			TextY = (WinHeight*480*fRatioY - H)/2;
    00057			C.TextSize(sValue, W, H);
    00058			ValX = FirstBoxWidth + (WinWidth*640*fRatioX - FirstBoxWidth - W + 16)/2;
    00059		}
    00060	}
    00061
    00062	function Paint(Canvas C, float X, float Y)
    00063	{
    00064		local float W,H;
    00065
    00066	//     C.SetPos(X, Y);
    00067		CanvasClipX = C.ClipX;
    00068
    00069		C.Style = 5;
    00070		if ( bCalculateSize )
    00071		{
    00072			if (bHasFocus)
    00073	            BackColor.A = 255;
    00074	        else
    00075	            BackColor.A = 128;
    00076			C.DrawColor = BackColor;
    00077			C.bUseBorder = true;
    00078			DrawStretchedTexture(C, 0, 0, (2*WinWidth*640*fRatioX)/3, WinHeight*480*fRatioY, myRoot.FondMenu);
    00079			DrawStretchedTexture(C, (2*WinWidth*640*fRatioX)/3 + 40, 6, (WinWidth*640*fRatioX)/3 - 64, WinHeight*480*fRatioY - 12, myRoot.FondMenu);
    00080			C.bUseBorder = false;
    00081
    00082			if ( bShowLeftArrow )
    00083			{
    00084				C.SetPos((2*WinWidth*640*fRatioX)/3 + 16, 4);
    00085				C.DrawTile( tArrow, 16, WinHeight*480*fRatioY - 8, tArrow.USize, 0, -tArrow.USize, tArrow.VSize );
    00086			}
    00087			if ( bShowRightArrow )
    00088			{
    00089				C.SetPos(WinWidth*640*fRatioX - 16, 4);
    00090				C.DrawTile( tArrow, 16, WinHeight*480*fRatioY - 8, 0, 0, tArrow.USize, tArrow.VSize );
    00091			}
    00092
    00093			C.DrawColor = TextColor;
    00094			C.SetPos(TextX,TextY);
    00095			C.DrawText(/*Caps*/(Text), false);
    00096			C.SetPos(ValX,TextY);
    00097			C.DrawText(sValue, false);
    00098		}
    00099		else
    00100		{
    00101			if (bHasFocus)
    00102				BackColor.A = 255;
    00103			else
    00104				BackColor.A = 128;
    00105			C.DrawColor = BackColor;
    00106			C.bUseBorder = true;
    00107			DrawStretchedTexture(C, 0, 0, FirstBoxWidth, WinHeight*480*fRatioY, myRoot.FondMenu);
    00108			DrawStretchedTexture(C, FirstBoxWidth + 40, 6, WinWidth*640*fRatioX - FirstBoxWidth - 64, WinHeight*480*fRatioY - 12, myRoot.FondMenu);
    00109			C.bUseBorder = false;
    00110
    00111			if ( bShowLeftArrow )
    00112			{
    00113				C.SetPos(FirstBoxWidth + 16, 4);
    00114				C.DrawTile( tArrow, 16, WinHeight*480*fRatioY - 8, tArrow.USize, 0, -tArrow.USize, tArrow.VSize );
    00115			}
    00116			if ( bShowRightArrow )
    00117			{
    00118				C.SetPos(WinWidth*640*fRatioX - 16, 4);
    00119				C.DrawTile( tArrow, 16, WinHeight*480*fRatioY - 8, 0, 0, tArrow.USize, tArrow.VSize );
    00120			}
    00121
    00122			C.DrawColor = TextColor;
    00123			C.SetPos(TextX,TextY);
    00124			C.DrawText(/*Caps*/(Text), false);
    00125			C.SetPos(ValX,TextY);
    00126			C.DrawText(sValue, false);
    00127		}
    00128		C.Style = 1;
    00129	}
    00130
    00131	function SetValue(int v)
    00132	{
    00133	     Value = v; //Clamp( v, minValue, maxValue );
    00134		 bShowLeftArrow =  (v!=minValue);
    00135		 bShowRightArrow =  (v!=maxValue);
    00136	     sValue = string(Value);
    00137	}
    00138
    00139	function int GetValue()
    00140	{
    00141	     return Value;
    00142	}
    00143
    00144	function bool InternalOnClick( out byte Key )
    00145	{
    00146		LOCAL float RelativeX, LeftArrowLeft, RightArrowLeft;
    00147
    00148	    if ( (myRoot.bMapMenu || XIIIWindow(MenuOwner).bCenterInGame) && (CanvasClipX > 800) )
    00149			RelativeX = ((Controller.MouseX-(CanvasClipX-800)*0.5)/fRatioX-WinLeft*640);
    00150		else
    00151			RelativeX = (Controller.MouseX/fRatioX-WinLeft*640);
    00152
    00153
    00154	//	RelativeX = Controller.MouseX - WinLeft*640;
    00155
    00156	//	LOG ( "POS:"@RelativeX );
    00157	//	LOG ( "LEFT"@(2*WinWidth*640*fRatioX)/3 + 16-4 );
    00158	//	LOG ( "RIGHT"@WinWidth*640*fRatioX - 16 );
    00159
    00160		if ( bCalculateSize )
    00161		{
    00162			RightArrowLeft = WinWidth*640 - 16-4;
    00163			LeftArrowLeft = (2*WinWidth*640)/3 + 16-4;
    00164		}
    00165		else
    00166		{
    00167			RightArrowLeft = WinWidth*640 - 16-4;
    00168			LeftArrowLeft = FirstBoxWidth/fRatioX + 16-4;
    00169		}
    00170
    00171		if ( bShowRightArrow  )
    00172		{
    00173			if ( RelativeX>=RightArrowLeft && RelativeX<RightArrowLeft+24)
    00174			{
    00175				Key = 0x27;
    00176			}
    00177		}
    00178		if ( bShowLeftArrow )
    00179		{
    00180			if ( RelativeX>=LeftArrowLeft && RelativeX<LeftArrowLeft+24 )
    00181			{
    00182				Key = 0x25;
    00183			}
    00184		}
    00185
    00186		return false;
    00187	}
    00188
    00189	function bool InternalOnKeyEvent(out byte Key, out byte State, float delta)
    00190	{
    00191		if ( ( bShowRightArrow || bShowLeftArrow ) && Key==0x01 && State==1 )
    00192		{
    00193			return InternalOnClick( Key );
    00194		}
    00195		return false;
    00196	}
    00197
    00198
    00199
    00200	defaultproperties
    00201	{
    00202	     tArrow=Texture'XIIIMenuStart.Interface_LoadGame.fleches'
    00203	     bCalculateSize=True
    00204	     bShowLeftArrow=True
    00205	     bShowRightArrow=True
    00206	}

End Source Code