// everytime the player discoveres or clicks on something for the first time a pop up will tell them what it's about

function DisplayTutorial(%item)
{
   introtutorial1.Visible = false;
   introtutorial2.Visible = false;
   tutorialbutton.text = "Close";
   tutorialbutton.command = "CloseTutorial();";      
   
   if($tutorialsoff $= true)
      return;

   switch$ (%item)
   {
      case "city":
         if($Tutorial_City $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Cities are controlled by rival gangs, for each city your gang captures and controls " @ 
         "you will receive 1 upgrade point per day to upgrade your vehicles with. Nuclear scientists and specialists are also located in cities, they will " @
         "make their presence known as soon as you drive in. You also have a slightly better chance of finding vehicles and " @
         "supplies in cities.");

         $Tutorial_City = true;

      case "citycapture":
         if($Tutorial_City $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Once your gang captures a city it will be in your control for the duration of the game.");

         $Tutorial_City = true;

      case "failedcitycapture":
         if($Tutorial_FailedCityCapture $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Your gang has successfully fought the hostile gang however you haven't taken over the city yet. It may take several rounds of combat " @
         "to fully destroy the rival gang and gain control of the city."); 
         
         $Tutorial_FailedCityCapture = true;
               
      case "silo":
         if($Tutorial_silo $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Unless you have at least 1 nuclear scientist in your gang you may not attempt to capture a silo. Once you have a nuclear scientist " @
         "and you click on a enemy silo you will be asked if you want to capture it.  A captured silo will give you 1 upgrade point per day just like a city.");

         $Tutorial_silo = true;
            
      case "block":
         if($Tutorial_block $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You may not move your gang into forests, mountains, water or off the terrain, your only option is to find another way around.");
         $Tutorial_block = true;

      case "doctor":
         if($Tutorial_doctor $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("A doctor will reduce the chances your gang will contract a disease and your gang will need less medicine to heal it."); 
         $Tutorial_doctor = true;

      case "mechanic":
         if($Tutorial_mechanic $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("A mechanic will help your gang repair your vehicles at a faster rate.");
         $Tutorial_mechanic = true;

      case "sargeant":
         if($Tutorial_sargeant $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("A sargeant will increase the rate and quality of promotions after your solders do battle.");
         $Tutorial_sargeant = true;

      case "recruiter":
         if($Tutorial_recruiter $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("A recruiter will increase the number and the rank of new soldiers you bring into your gang.");
         $Tutorial_recruiter = true;

      case "scout":
         if($Tutorial_scout $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("A scout will increase your chances of finding supplies and new vehicles.");
         $Tutorial_scout = true;

      case "scientist":
         if($Tutorial_scientist $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Now that you have your first nuclear scientist you can capture a silo. You will need one nuclear scientist " @
         "for each silo.");
         $Tutorial_scientist = true;

      case "supplysearch":
         if($Tutorial_supplysearch $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("When you search for supplies you have a chance of finding food, fuel, guns, ammo, medicine, tires and spare parts. Searching for supplies takes 1 hour of game time " @
         "and there is a chance you will be attacked by a rival gang. If you click on Supply Search and nothing happens that means your gang didn't find anything.");
         $Tutorial_supplysearch = true;

      case "vehiclesearch":
         if($Tutorial_vehiclesearch $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("When you search for a vehicle you have a chance of finding anything from a motorcycle to a trailer truck. Sometimes " @
         "a vehicle will be new and sometimes it will be damaged. Searching for vehicles takes 1 hour of game time " @
         "and there is a chance you will be attacked by a rival gang. A vehicle search may not always be successful.");
         $Tutorial_vehiclesearch = true;

      case "peoplesearch":
         if($Tutorial_peoplesearch $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("When you search for people you are looking for new soldiers to replenish your ranks. Soldiers of " @
         "all experience can be recruited except for mercenaries. Searching for people takes 1 hour of game time " @
         "and there is a chance you will be attacked by a rival gang. A people search may not always be successful.");
         $Tutorial_peoplesearch = true;
      
      case "specialevent":      
         if($Tutorial_specialevent $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Once in a while your gang will stumble accross a special location and it should be approached with caution. Sometimes you will be rewarded for investigating and " @
         "other times your gang will suffer for it.");
         $Tutorial_specialevent = true;            

      case "aftercombat":      
         if($Tutorial_aftercombat $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("After vehicle combat is over you will have your pick of the left over enemy supplies. Some of your soldiers " @
         "will also get promoted. Flat tires be fixed automatically assuming you have enough spare tires and your gang will be able to repair a certain amount of vehicle damage per game hour using your spare parts supply. " @
         "Morale will also increase after a successful battle.");
         $Tutorial_aftercombat = true;            

      case "starving":      
         if($Tutorial_starving $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Your gang is now starving. Gang morale will continue to decline and your gang will suffer a penalty during combat.");
         $Tutorial_starving = true;            

      case "startcombat":      
         if($Tutorial_startcombat $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("This is the battle screen for vehicle combat. It allows you to see the vehicles of the enemy gang and you " @
         "have the option to attempt to retreat but if you do retreat it will lower your gang's morale. Retreating will not always be successful. You can also optionally choose the initial vehicle formation " @
         "of your vehicles.");
         $Tutorial_startcombat = true;            
      
      case "acceleration":
         if($Tutorial_acceleration $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("The faster a vehicle travels the harder it will be for an enemy vehicle to hit it and will do more damage if it " @
         "rams into another vehicle, friendly or enemy. It will also turn slower and have a higher chance of hitting an obstacle. The higher rate of speed makes it harder " @
         "for it to board other vehicles and to be boarded by enemy vehicles.");
         $Tutorial_acceleration = true;            

         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;      

      case "specialorders":
         if($Tutorial_SpecialOrders $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You can issue special attack orders for your vehicles either in real time or while combat is paused. You can " @
         "select a target by either selecting the actual enemy vehicle or the enemy icon in the quickbar. When you issue Boarding orders " @
         "none of your other vehicles will fire at the target vehicle until the order is completed.");
         $Tutorial_SpecialOrders = true;            

         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;      

      case "donotfire":
         if($Tutorial_DoNotFire $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("The Do Not Fire order will tell your entire gang to not fire at a single enemy vehicle. Selecting a custom attack order " @ 
         "will override this selection for the currently selected player vehicle only. The purpose of this order is to allow your gang to capture an enemy vehicle but use it with caution.");
         $Tutorial_DoNotFire = true;            

         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;      
         
      case "selecttarget":
         if($Tutorial_SelectTarget $= true)
            return;
         if($peoplebattle $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Selecting an enemy vehicle will order your vehicle to make it the primary target but your vehicle may still fire at other targets. If you select the ground, your vehicle will stay in that area and will still fire at nearby targets.");
         $Tutorial_SelectTarget = true;            
         
         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;      

      case "casino":
         if($Tutorial_casino $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a casino. It will increase the morale of your gang. Your gang may " @
         "only use a casino once per day. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_casino = true;            

      case "learningcenter":
         if($Tutorial_Learningcenter $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a learning center. It will increase the rank of some of your gang members and increase the experience of all your specialists. " @
         "A single learning center may only be used once. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_LearningCenter = true;            

      case "militarybase":
         if($Tutorial_MilitaryBase $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a military base. You may recruit soldiers here as well as loot guns and ammo. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_MilitaryBase = true;            

      case "airport":
         if($Tutorial_Airport $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found an airport. You may loot fuel, tires, spare parts and food here. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_AirPort = true;            

      case "Cache":
         if($Tutorial_Cache $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a supply cache. It will contain a variety of supplies and may only be used once. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_Cache = true;            

      case "Hospital":
         if($Tutorial_Hospital $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a hospital. You will find a cache of medicine here and your gang will be cured of disease. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_Hospital = true;            

      case "farm":
         if($Tutorial_farm $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a farm. A good supply of food will be found here. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_farm = true;            

      case "gasstation":
         if($Tutorial_GasStation $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a Gas Station. A good supply of fuel and tires will be found here. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_GasStation = true;            

      case "autocenter":
         if($Tutorial_AutoCenter $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found an Auto Center. It will upgrade a specific area on all your vehicles. It may only be used once. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_AutoCenter = true;            

      case "truckdepot":
         if($Tutorial_TruckDepot $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You gang has found a truck depot. Your gang can get a partial repair of vehicles without using spare parts and it can only be used once per day. The more people you send out in a scouting party the better chance you have of avoiding an ambush.");
         $Tutorial_TruckDepot = true;            
         
      case "SpareParts":
         if($Tutorial_SpareParts $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("If you look at the Spare Parts text you will now notice a number to the right. That is the number of spare parts your gang will need to repair all of the damage your vehicles currently have.");
         $Tutorial_SpareParts = true;            

      case "Upgrade":
         if($Tutorial_Upgrade $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("The upgrade screen will allow you to use your upgrade points to improve your vehicles. The more cities your gang captures the more upgrades will be available.");
         $Tutorial_Upgrade = true;            

      case "DropSupplies":
         if($Tutorial_DropSupplies $= true)
            return;
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("You can drop unwanted or excess supplies, just click on any of the boxes in the left column to display the drop arrows. " @
         "Clicking on the dropped amount will return the discarded supplies.");
         $Tutorial_DropSupplies = true;            

      case "MayNotBoard":
         if($Tutorial_MayNotBoard $= true)
            return;

         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;      
         
         canvas.pushdialog(tutorial);                           
         tutorialdesc.setText("Your vehicle may only board an enemy vehicle if it has more than 2 occupants or else you will hear a buzzer.");
         $Tutorial_MayNotBoard = true;       
         
      case "infantrybattle":
         if($Tutorial_InfantryBattle $= true)
            return;

         $InfantryTutorialPage = 1;

         InfantryTutorial(1);
         
         $Tutorial_InfantryBattle = true;            
         
         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;                        

      case "vehiclebattle":
         LoadVehicleBattleTutorial();
         
         if($Tutorial_VehicleBattle $= true)
            return;

         $VehicleTutorialPage = 1;

         VehicleTutorial(1);
         
         $Tutorial_VehicleBattle = true;            
         
         if($pause $= "")
         {
            sg.setScenePause(true);
            $pause = 1;
         }
         else
            $PauseFlag = true;                        
         
         SaveVehicleBattleTutorial();
   }
}

function CloseTutorial()
{
   if($pause $= 1 && $PauseFlag $= "")
   {
      sg.setScenePause(false);
      $pause = 0;
   }
   
   $PauseFlag = "";
   
   // so the continue button will work on a dialog after the tutorial
      
   canvas.PopDialog(tutorial);    
   SaveTutorial();  
}