function gangstats::OnWake()
{
   echo("GANG STATS CLICK");
   alxPlay(click);
   UpdateGangSupplies();
   UpdateGangVehicles();
   UpdateGangStats();
   UpdateGangPeople();   
   UpdateSilos();
   UpdateHealth();
   $screenActive = true;
}

function UpdateHealth()
{
   if($disease $= true)
      stats_disease.setText("Diseased");
   else
      stats_disease.setText("Ok");
      
   if($starving $= true)
      stats_starving.setText("Starving");
   else
      stats_starving.setText("Ok");
}

function UpdateSilos()
{
   remainingsilos.setText($remainingsilos);
   
   if($scientists $= "")
      stats_scientists.setText("0");
   else
      stats_scientists.setText($scientists);
      
   if($CapturedCities $= "")
      stats_cities.setText(0);
   else
      stats_cities.setText($CapturedCities);
   
}

function UpdateGangVehicles()
{
   stats_numvehicles.text = GetNumVehicles();
   
   stats_tonnage.text = GetVehicleTonnage() SPC "/" SPC GetMaxVehicleTonnage();      
}

function UpdateGangStats()
{
   stats_morale.text = $morale;
}

function UpdateGangSupplies()
{
   stats_Food.text = $food;
   stats_Guns.text = $guns;
   stats_Ammo.text = $ammo;
   stats_medicine.text = $medicine;
   stats_tires.text = $tires;
   stats_spareparts.text = $spareparts;   
   stats_Fuel.text = $fuel;
   stats_people.text = GetTotalNumPeople() SPC "/" SPC GetTotalPeopleCapacity();
   stats_capacity.text = GetCurrentSupplyCount() SPC "/" SPC GetTotalSupplyCapacity();
   
 }

function UpdateGangPeople()
{
   if($refuges $= "")
      %refuges = 0;
   else
      %refuges = $refuges;
      
   stats_refuges.text = %refuges;   
   
   if($Brigands $= "")
      %brigands = 0;
   else
      %brigands = $Brigands;
      
   stats_brigands.text = %brigands;   

   if($Militia $= "")
      %militia = 0;
   else
      %militia = $Militia;
      
   stats_militia.text = %militia;   

   if($Police $= "")
      %police = 0;
   else
      %police = $police;
      
   stats_police.text = %police;   

   if($soldiers $= "")
      %soldiers = 0;
   else
      %soldiers = $soldiers;
      
   stats_soldiers.text = %soldiers;   


   if($Mercenaries $= "")
      %mercenaries = 0;
   else
      %mercenaries = $Mercenaries;
      
   stats_mercenaries.text = %mercenaries;   

   if($Mechanic $= "")
      %mechanic = "No";
   else
      %mechanic = "Yes";
      
   stats_mechanic.text = %mechanic;   

   if($Sergeant $= "")
      %sergeant = "No";
   else
      %sergeant = "Yes";
      
   stats_sergeant.text = %sergeant;   

   if($Doctor $= "")
      %doctor = "No";
   else
      %doctor = "Yes";
      
   stats_doctor.text = %doctor;   

   if($Recruiter $= "")
      %recruiter = "No";
   else
      %recruiter = "Yes";
      
   stats_recruiter.text = %recruiter;   

   if($scout $= "")
      %scout = "No";
   else
      %scout = "Yes";
      
   stats_scout.text = %scout;   

   stats_peoplecapacity.text = GetTotalNumPeople() SPC "/" SPC GetTotalPeopleCapacity();   
}

function gangstats::OnSleep()
{
   echo("GANG STATS CLOSE CLICK");
      $screenActive = false;   
   alxPlay(click);   
}