// Squad Information Plate Handler.
// Worthless Bums 2012.


// Updated squad information panels.
function updateSquadInformationPanels ()
{//echo("updateSquadInformationPanels()");
	if ($leaderPersist)
	{
		// Define parameters.
		%className = "Leader";
		%blockName = "ActionBlock";
		%index = 0;
		// Make panel visible.
		(%className @ "SquadPanel").setVisible(1);
		
		// Set health bar.
		%healthBarHeight = 13;
		%healthBarWidth = $playerSquad[%index].currentHealth / $playerSquad[%index].maxHealth;
		%healthBarWidth = mFloor(%healthBarWidth * 108);
		(%className @ "HealthBar").extent = %healthBarWidth SPC %healthBarHeight;
		
		// Set health text.
		(%className @ "HealthText").setText($playerSquad[%index].currentHealth @ "/" @ $playerSquad[%index].maxHealth);
		
		// Set action blocks.
		// Loop through action point blocks.
		for (%i = 1; %i <= 7; %i++)
		{
			// Compose block object.
			%blockObject = %className @ %blockName @ %i;
			// Available action point.
			if ($playerSquad[%index].currentActionPoints >= %i)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlock");
			}
			// Used action point.
			else if (%i <= $playerSquad[%index].maxActionPoints)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlockEmpty");
			}
			// Beyond max action points!
			else
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/blank (1x1)");
			}
		}
		if ($activeCharacter == 0)
		{
			LeaderHighlightSelectButton.setVisible(0);
		}
		else
		{
			LeaderHighlightSelectButton.setVisible(1);
		}
	}
	else
	{
		// Make panel invisible.
		LeaderSquadPanel.setVisible(0);
	}
	
	if ($scoutPersist)
	{
		// Define parameters.
		%className = "Scout";
		%blockName = "ActionBlock";
		%index = 1;
		// Make panel visible.
		(%className @ "SquadPanel").setVisible(1);
		
		// Set health bar.
		%healthBarHeight = 13;
		%healthBarWidth = $playerSquad[%index].currentHealth / $playerSquad[%index].maxHealth;
		%healthBarWidth = mFloor(%healthBarWidth * 108);
		(%className @ "HealthBar").extent = %healthBarWidth SPC %healthBarHeight;
		
		// Set health text.
		(%className @ "HealthText").setText($playerSquad[%index].currentHealth @ "/" @ $playerSquad[%index].maxHealth);
		
		// Set action blocks.
		// Loop through action point blocks.
		for (%i = 1; %i <= 7; %i++)
		{
			// Compose block object.
			%blockObject = %className @ %blockName @ %i;
			// Available action point.
			if ($playerSquad[%index].currentActionPoints >= %i)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlock");
			}
			// Used action point.
			else if (%i <= $playerSquad[%index].maxActionPoints)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlockEmpty");
			}
			// Beyond max action points!
			else
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/blank (1x1)");
			}
		}
		if ($activeCharacter == 1)
		{
			ScoutHighlightSelectButton.setVisible(0);
		}
		else
		{
			ScoutHighlightSelectButton.setVisible(1);
		}
	}
	else
	{
		// Make panel invisible.
		ScoutSquadPanel.setVisible(0);
	}
	
	if ($grenadierPersist)
	{
		// Define parameters.
		%className = "Grenadier";
		%blockName = "ActionBlock";
		%index = 2;
		// Make panel visible.
		(%className @ "SquadPanel").setVisible(1);
		
		// Set health bar.
		%healthBarHeight = 13;
		%healthBarWidth = $playerSquad[%index].currentHealth / $playerSquad[%index].maxHealth;
		%healthBarWidth = mFloor(%healthBarWidth * 108);
		(%className @ "HealthBar").extent = %healthBarWidth SPC %healthBarHeight;
		
		// Set health text.
		(%className @ "HealthText").setText($playerSquad[%index].currentHealth @ "/" @ $playerSquad[%index].maxHealth);
		
		// Set action blocks.
		// Loop through action point blocks.
		for (%i = 1; %i <= 7; %i++)
		{
			// Compose block object.
			%blockObject = %className @ %blockName @ %i;
			// Available action point.
			if ($playerSquad[%index].currentActionPoints >= %i)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlock");
			}
			// Used action point.
			else if (%i <= $playerSquad[%index].maxActionPoints)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlockEmpty");
			}
			// Beyond max action points!
			else
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/blank (1x1)");
			}
		}
		if ($activeCharacter == 2)
		{
			GrenadierHighlightSelectButton.setVisible(0);
		}
		else
		{
			GrenadierHighlightSelectButton.setVisible(1);
		}
	}
	else
	{
		// Make panel invisible.
		GrenadierSquadPanel.setVisible(0);
	}
	
	if ($supportPersist)
	{
		// Define parameters.
		%className = "Support";
		%blockName = "ActionBlock";
		%index = 3;
		// Make panel visible.
		(%className @ "SquadPanel").setVisible(1);
		
		// Set health bar.
		%healthBarHeight = 13;
		%healthBarWidth = $playerSquad[%index].currentHealth / $playerSquad[%index].maxHealth;
		%healthBarWidth = mFloor(%healthBarWidth * 108);
		(%className @ "HealthBar").extent = %healthBarWidth SPC %healthBarHeight;
		
		// Set health text.
		(%className @ "HealthText").setText($playerSquad[%index].currentHealth @ "/" @ $playerSquad[%index].maxHealth);
		
		// Set action blocks.
		// Loop through action point blocks.
		for (%i = 1; %i <= 7; %i++)
		{
			// Compose block object.
			%blockObject = %className @ %blockName @ %i;
			// Available action point.
			if ($playerSquad[%index].currentActionPoints >= %i)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlock");
			}
			// Used action point.
			else if (%i <= $playerSquad[%index].maxActionPoints)
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/UI/Explore/ActionBlockEmpty");
			}
			// Beyond max action points!
			else
			{
				%blockObject.setBitmap("../../../Sprites/1/assets/images/blank (1x1)");
			}
		}
		if ($activeCharacter == 3)
		{
			SupportHighlightSelectButton.setVisible(0);
		}
		else
		{
			SupportHighlightSelectButton.setVisible(1);
		}
	}
	else
	{
		// Make panel invisible.
		SupportSquadPanel.setVisible(0);
	}
}