//=============================================================================
// HUDMultiSkills - In game skill selection for multiplayer
//=============================================================================

class HUDMultiSkillsMM extends HUDMultiSkills;


function SkillMessage( GC gc )
{
	local bool bShowMsg, bSkillAvail;
	local Skill askill;
	local float curx, cury, w, h, w2, t, offset;
	local String str;

			if ( _MMRPGPlayer(Player).bUpgraded )
			{
				RefreshKey();
				timeToNotify = Player.Level.Timeseconds + TimeDelay;
				Player.BuySkillSound( 3 );
				_MMRPGPlayer(Player).bUpgraded = False;
			}
			if ( timeToNotify > Player.Level.Timeseconds )
			{
				// Flash them to draw a little more attention 1.5 on .5 off
				if ( (Player.Level.Timeseconds % 1.5) < 1 )
				{
					offset = 0;
					gc.SetFont(Font'FontMenuSmall_DS');
					cury = height * skillMsgY;
					curx = width * skillListX;
					str = PressString $ curKeyName $ PressEndString;
					gc.GetTextExtent( 0, w, h, SkillsAvailableString );
					gc.GetTextExtent( 0, w2, h, str );
					if ( (curx + ((w-w2)*0.5)) < 0 )
						offset = -(curx + ((w-w2)*0.5));
					gc.SetTextColor( colLtGreen );
					gc.GetTextExtent( 0, w, h, SkillsAvailableString );
					gc.DrawText( curx+offset, cury, w, h, SkillsAvailableString );
					cury +=  h;
					gc.GetTextExtent( 0, w2, h, str );
					curx += ((w-w2)*0.5);
					gc.DrawText( curx+offset, cury, w2, h, str );
				}
			}

}



event DrawWindow(GC gc)
{
	local Skill askill;
	local float curx, cury, w, h;
	local String str, costStr;
	local int index;
	local bool bHitSwimming;
	local float barLen, costx, levelx;
	local int k;

	bHitSwimming = False;

	if (( Player == None ) || (!Player.PlayerIsClient()) )
		return;

	if ( Player.bBuySkills )
	{
		if (( Player != None ) && ( Player.SkillSystem != None ))
		{
			gc.SetFont(Font'FontMenuSmall_DS');
			index = 1;
			askill = Player.SkillSystem.FirstSkill;
			cury = height * skillListY;
			curx = width * skillListX;
			costx = width * skillCostX;
			levelx = width * skillLevelX;
			gc.GetTextExtent( 0, w, h, CostString );
//===added +5 -->
			barLen = (costx+(w*1.33))-curx+5;
			gc.DrawBox( curx, cury, barLen, 1, 0, 0, 1, Texture'Solid');
			cury += (h*0.25);
			str = SkillPointsString;
			gc.GetTextExtent( 0, w, h, str );
			gc.DrawText( curx, cury, w, h, str );
			cury += h;
			gc.DrawBox( curx, cury, barLen, 1, 0, 0, 1, Texture'Solid');
			cury += (h*0.25);
			str = SkillString;
			gc.GetTextExtent( 0, w, h, str );
			gc.DrawText( curx, cury, w, h, str );
			str = LevelString;
			gc.GetTextExtent( 0, w, h, str );
			gc.DrawText( levelx, cury, w, h, str );
			str = CostString;
			gc.GetTextExtent( 0, w, h, str );
			gc.DrawText( costx, cury, w, h, str );
			cury += h;
			gc.DrawBox( curx, cury, barLen, 1, 0, 0, 1, Texture'Solid');
			cury += (h*0.25);

			_MMRPGPlayer(Player).UpdSkill();

			while ( askill != None )
			{
				if ( SkillSwimming(askill) == None )
				{
					if ( index == 10 )
						str = "0. " $ askill.SkillName;
					else
						str = index $ ". " $ askill.SkillName;

					gc.GetTextExtent( 0, w, h, str );
					if ( askill.CurrentLevel == 3)
					{
						gc.SetTileColor( colBlue );
						gc.SetTextColor( colBlue );
						costStr = NAString;
					}
					else
					{
						if ( askill.CurrentLevel == 2)
						{
							gc.SetTextColor( colRed );
							gc.SetTileColor( colRed );
						}
						if ( askill.CurrentLevel == 1)
						{
							gc.SetTextColor( colLtGreen );
							gc.SetTileColor( colLtGreen );
						}
						if ( askill.CurrentLevel == 0)
						{
							gc.SetTextColor( colGreen );
							gc.SetTileColor( colGreen );
						}
						for ( k = 0; k < 11; k++ )
						{
							if(aSkill.Class == Player.SkillSystem.SkillClasses[k])
							{
								costStr = _MMRPGPlayer(Player).GetSkillXP(k);
							}
						}
					}
					gc.DrawText( curx, cury, w, h, str );
					DrawLevel( gc, levelx, cury, askill.CurrentLevel );
					gc.GetTextExtent(	0, w, h, costStr );
					gc.DrawText( costx, cury, w, h, costStr );
					cury += h;
					index += 1;
				}
				askill = askill.next;
			}
			gc.SetTileColor( colWhite );
			if ( curKeyName ~= KeyNotBoundString )
				RefreshKey();
			str = PressString $ curKeyName $ ToExitString;
			gc.GetTextExtent( 0, w, h, str );
			gc.DrawBox( curx, cury, barLen, 1, 0, 0, 1, Texture'Solid');
			cury += (h*0.25);
			gc.SetTextColor( colWhite );
			gc.DrawText( curx + ((barLen*0.5)-(w*0.5)), cury, w, h, str );
			cury += h;
			gc.DrawBox( curx, cury, barLen, 1, 0, 0, 1, Texture'Solid');
		}
	}
	else 
		SkillMessage( gc );

	Super(HUDBaseWindow).DrawWindow(gc);
}

defaultproperties
{
     SkillPointsString="Skill Manager"
     CostString="Experience"
     colBlue=(R=0,G=255,B=0)
     colWhite=(R=255,G=255,B=255)
     colGreen=(R=0,G=128,B=0)
     colLtGreen=(R=0,G=170,B=0)
     colRed=(R=0,G=190,B=0)
     SkillsAvailableString="Skill level up!"
}
