exec("./playMissionGui.netjet.gui");

package PMOverride {

function getMissionObject(%mission) {
   %infoObject = "";
	%file = new FileObject();

	if ( %file.openForRead( %mission ) ) {
		%inInfoBlock = false;
		
		while ( !%file.isEOF() ) {
			%line = %file.readLine();
			%line = trim( %line );
			
			if( %line $= "new ScriptObject(MissionInfo) {" )
			{
            %line = "new ScriptObject() {";
				%inInfoBlock = true;
         } else if( %inInfoBlock && %line $= "};" ) {
				%inInfoBlock = false;
				%infoObject = %infoObject @ %line; 
				break;
			}
			
			if( %inInfoBlock )
			   %infoObject = %infoObject @ %line @ " ";
		}
		
		%file.close();
		%file.delete();
	}
	
	%infoObject = "%infoObject = " @ %infoObject;
	eval(%infoObject);
	
	if (!isObject(MTYPE_beginner))
	   PlayMissionGroup.add(new SimGroup(MTYPE_beginner));
   if (!isObject(MTYPE_intermediate))
	   PlayMissionGroup.add(new SimGroup(MTYPE_intermediate));
   if (!isObject(MTYPE_advanced))
	   PlayMissionGroup.add(new SimGroup(MTYPE_advanced));
   if (!isObject(MTYPE_custom))
	   PlayMissionGroup.add(new SimGroup(MTYPE_custom));
	   
   if (%infoObject.type !$= "beginner" && %infoObject.type !$= "intermediate" && %infoObject.type !$= "advanced")
   {
      %infoObject.type = "custom";
	  $hasCustomLevels = true;
   }
      
   if (%infoObject.gameType $= "")
      %infoObject.gameType = "SinglePlayer";
      
   eval("MTYPE_" @ %infoObject.type @ ".add(%infoObject);");
	
	%infoObject.file = %mission;
	
	return %infoObject;
}

function PM_TypeSlider::incValue(%this)
{
	if ($MissionType $= "Beginner")
		$MissionType = "Intermediate";
	else if ($MissionType $= "Intermediate")
		$MissionType = "Advanced";
	else if ($MissionType $= "Advanced")
	{
		if ($hasCustomLevels)
			$MissionType = "Custom";
		else
			$MissionType = "Beginner";
	}
	else if ($MissionType $= "Custom")
		$MissionType = "Beginner";
		
	PM_MissionType.setText("<font:SF Slapstick Comic:24><just:center><shadow:1:1><color:ffffff><shadowcolor:000000>" @ $MissionType);
	BuildMissionList();
}

function PM_TypeSlider::decValue(%this)
{
	if ($MissionType $= "Beginner")
	{
		if ($hasCustomLevels)
			$MissionType = "Custom";
		else
			$MissionType = "Advanced";
	}
	else if ($MissionType $= "Intermediate")
		$MissionType = "Beginner";
	else if ($MissionType $= "Custom")
		$MissionType = "Advanced";
	else if ($MissionType $= "Advanced")
		$MissionType = "Intermediate";
		
	PM_MissionType.setText("<font:SF Slapstick Comic:24><just:center><shadow:1:1><color:ffffff><shadowcolor:000000>" @ $MissionType);
	BuildMissionList();
}

};

activatePackage(PMOverride);