function IntroTutorial(%num)
{   
   %file = "~/introtutorial.sav";
  
   %fo = new fileobject();
      
   %ret = %fo.OpenForRead(%file);
   
   if(%ret !$= false)
   {
      if(isObject(QuickBattleMap) $= true)
         QuickBattleMap.Safedelete();

      new ActionMap(moveMap);   
      moveMap.push();
      exec("./keymap.cs");   
      %fo.close();
      return;      
   }

   tutorialbutton.text = "Next";
   introtutorial1.Visible = false;
   introtutorial2.Visible = false;
   canvas.pushdialog(tutorial);                           
   
   switch$ (%num)
   {
      case 1:
         tutorialdesc.setText("This is a dangerous place, the highways and cities are littered with other gangs that survive by killing anything that moves for fuel and supplies. Since your gang " @
         "is just starting out the first thing you should do is add a new vehicle so you have more capacity for supplies and recruitment. Normally you would click the Search Vehicle button or use keyboard shorcut " @ $keys_VehicleSearch @ " but for now just click Next." @
         "When you search for vehicles, supplies or try to recruit new members, you may not always find something but the search will still consume an hour of game time.");
         tutorialbutton.command = "IntroTutorial(2);";
         $foundvehicle = "pickuptruck";
         
      case 2:
         AddVehicle();
         tutorialdesc.setText("Your gang now has a new Pickup Truck. You will notice that your supply capacity has increased and your gang can now carry up to 14 people. With each new vehicle your fuel usage will go up so carrying a good supply of fuel is critical. Your gang can have a maximum of 10 vehicles and you can also use the Vehicle Stats page to abandoned a vehicle. " );
         tutorialbutton.command = "IntroTutorial(3);";
   
      case 3:
         tutorialdesc.setText("Now that you have a higher capacity let's get some new supplies. New supplies can be aquired by either clicking on the Supply Search button, after vehicle combat or finding special locations scattered around the country. As with other searches, a supply search will take an hour of game time and sometimes your gang won't be able to find anything. Click next to round up some badly needed supplies for your gang.");
         tutorialbutton.command = "IntroTutorial(4);";
   
      case 4:
         $Food = 50;
         $fuel = 72;
         $guns = 5;
         $ammo = 37;
         
         UpdateStatsBar();
         tutorialdesc.setText("Your gang just found some food, fuel, guns and ammo. The type of supplies found and the quantity will vary. Food is deducted once a day, 1 unit per gang member. Spare parts are very important to carry since they are needed to repair your vehicles after combat. You can also use the Gang Stats page to drop excess supplies.");
         tutorialbutton.command = "IntroTutorial(5);";

      case 5:
         tutorialdesc.setText("Since death in the wasteland is quite common your gang will always need to recruit new meat! Gang members can be 1 of 6 ranks with Refuge being the lowest and Mercenary being the highest, after combat some of your troops will get promoted to a higher rank. Just like the Supply and Vehicle search, a People Search will take 1 hour of game time and sometimes your gang won't be able to find anyone to recruit. If your gang doesn't have enough guns during combat they will use crossbows. \n\nClick Next to recruit some fresh meat into your gang.");
         tutorialbutton.command = "IntroTutorial(6);";

      case 6:
         $refuges = 8;
         $militia = 3;
         tutorialdesc.setText("You just recruited some Refuges and Militia into your gang. When a group of potential recruits wants to join your gang they will have a general description to give you a better idea of what they are ranked. For example, a Mob will only contain Refuges and a few Brigands. Mercenaries can never be recruited, they can only be promoted from within your own ranks. If you let your gang Morale get too low by retreating from combat some of your troops will desert you.");
         tutorialbutton.command = "IntroTutorial(7);";
         UpdateStatsBar();

      case 7:
         tutorialdesc.setText("There are over 50 major cities in the game, by simply driving into a city you will be notified if there is a scientist or a specialist present. 1 scientist is needed to capture and disable each nuclear silo. A specialist is someone with specialized skills that will help your gang, such as a doctor to help prevent disease or a sargeant to promote your troops. Capturing a city will give you upgrade points to upgrade your vehicles, each captured city will give your gang 1 upgrade point per day.");
         tutorialbutton.command = "IntroTutorial(8);";

      case 8:
         tutorialdesc.setText("If you have Upgrade Points you can click on the Upgrade Points text and use the points to repair your vehicles. This may only be used once per game day. ");
         tutorialbutton.command = "IntroTutorial(9);";

      case 9:
         tutorialdesc.setText("When your vehicles are damaged, a second number in the Spare Parts text will appear to the right. That is the total number of spare parts needed to repair all of the damage your vehicles currently have.");
         tutorialbutton.command = "IntroTutorial(10);";

      case 10:
         tutorialdesc.setText("Now that your gang is slightly better equiped, you must start exploring to capture and disable all the nuclear silos in 150 days time or else what's left of the country and the population will be destroyed. You should also do a few additional searches to get more vehicles, supplies and recruits, when you take to the roads only the well prepared will survive.");
         tutorialbutton.command = "canvas.PopDialog(tutorial);";      
         introtutorial1.Visible = true;
         introtutorial2.Visible = true;

         tutorialbutton.text = "Close";
   }   
}

function tutorial::OnSleep()
{
   %state = introtutorial1.getValue();
   
   if(%state $= true)
   {
      %fo = new fileobject();
     
      %file = "~/introtutorial.sav";
    
      %fo.OpenForWrite(%file);   
      %fo.WriteLine("off");              
      
      %fo.close();
   }
   
   if(isObject(QuickBattleMap) $= 1)
      QuickBattleMap.delete();
   new ActionMap(moveMap);   
   moveMap.push();
   exec("./keymap.cs");   
}

