class UMenuMenuBar expands UWindowMenuBar;

#exec TEXTURE IMPORT NAME=BarL FILE=Textures\BarL.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarTile FILE=Textures\BarTile.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarMax FILE=Textures\BarMax.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarWin FILE=Textures\BarWin.bmp GROUP="Icons" FLAGS=2 MIPS=OFF

#exec TEXTURE IMPORT NAME=BarInL FILE=Textures\BarInL.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarInR FILE=Textures\BarInR.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarInM FILE=Textures\BarInM.bmp GROUP="Icons" FLAGS=2 MIPS=OFF

#exec TEXTURE IMPORT NAME=BarOutL FILE=Textures\BarOutL.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarOutR FILE=Textures\BarOutR.bmp GROUP="Icons" FLAGS=2 MIPS=OFF
#exec TEXTURE IMPORT NAME=BarOutM FILE=Textures\BarOutM.bmp GROUP="Icons" FLAGS=2 MIPS=OFF



var UWindowPulldownMenu Game, Multiplayer, Options, Tool, Help;
var UMenuHelpWindow HelpWindow;
var config bool ShowHelp;

var localized string[32] GameName;
var localized string[32] MultiplayerName;
var localized string[32] OptionsName;
var localized string[32] ToolName;
var localized string[32] HelpName;
var localized string[32] VersionName;

function Created()
{
	Super.Created();

	bAlwaysOnTop = True;

	Game = AddItem(GameName).CreateMenu(class'UMenuGameMenu');
	Multiplayer = AddItem(MultiplayerName).CreateMenu(class'UMenuMultiplayerMenu');
	Options = AddItem(OptionsName).CreateMenu(class'UMenuOptionsMenu');
	Tool = AddItem(ToolName).CreateMenu(class'UMenuToolsMenu');
	Help = AddItem(HelpName).CreateMenu(class'UMenuHelpMenu');
	if (ShowHelp)
	{
		UMenuHelpMenu(Help).ExecuteItem(UMenuHelpMenu(Help).Context);
	}

	Spacing = 12;
}

function SetHelp(string[240] NewHelpText, string[100] NewTitle)
{
	if (HelpWindow != None)
	{
		UMenuHelpClientWindow(HelpWindow.ClientArea).TextArea.HelpText = NewHelpText;
		if (NewTitle == "")
			HelpWindow.WindowTitle = "Help";
		else
			HelpWindow.WindowTitle = "Help::"$NewTitle;
	}
}

function CloseUp()
{
	Super.CloseUp();
	SetHelp("", "");
}

function Select(UWindowMenuBarItem I)
{
	if (I == None)
		SetHelp("", "");

	Super.Select(I);
}

defaultproperties
{
	GameName="Game"
	MultiplayerName="Multiplayer"
	OptionsName="Options"
	ToolName="Tools"
	HelpName="Help"
	VersionName="Version"
}




function DrawItem(Canvas C, UWindowList Item, float X, float Y, float W, float H)
{
	local string[240] Text;
	local string[240] Underline;


	C.DrawColor.R = 255;
	C.DrawColor.G = 255;
	C.DrawColor.B = 255;
	
	if(UWindowMenuBarItem(Item).bHelp) W = W - 16;

	UWindowMenuBarItem(Item).ItemLeft = X;
	UWindowMenuBarItem(Item).ItemWidth = W;

	if(Selected == Item)
	{
		C.Style = ERenderStyle.STY_Masked;
		DrawClippedTexture(C, X, 0, Texture'BarInL');
		DrawClippedTexture(C, X+W-1, 0, Texture'BarInR');
		DrawStretchedTexture(C, X+1, 0, W-2, 16, Texture'BarInM');
		C.Style = ERenderStyle.STY_Normal;
	}
	else
	if (Over == Item)
	{
		DrawClippedTexture(C, X, 0, Texture'BarOutL');
		DrawClippedTexture(C, X+W-1, 0, Texture'BarOutR');
		DrawStretchedTexture(C, X+1, 0, W-2, 16, Texture'BarOutM');
	}

	C.Font = Root.TahomaFont;
	C.DrawColor.R = 0;
	C.DrawColor.G = 0;
	C.DrawColor.B = 0;

	ParseAmpersand(UWindowMenuBarItem(Item).Caption, Text, Underline, True);
	ClipText(C, X + SPACING / 2, 3, Text);
	ClipText(C, X + SPACING / 2, 5, Underline);

}


function DrawMenuBar(Canvas C)
{
	local float W, H;

	DrawClippedTexture(C, 0, 0, Texture'UMenu.BarL');
	DrawStretchedTexture( C, 16, 0, WinWidth - 32, 16, Texture'UMenu.BarTile');
	DrawClippedTexture(C, WinWidth - 16, 0, Texture'UMenu.BarWin');

	C.Font = Root.TahomaFont;
	C.DrawColor.R = 0;
	C.DrawColor.G = 0;
	C.DrawColor.B = 0;
	C.StrLen(VersionName$" "$Level.EngineVersion, W, H);
	ClipText(C, WinWidth - W - 20, 3, VersionName$" "$Level.EngineVersion);
}
