//--- OBJECT WRITE BEGIN ---
new GuiChunkedBitmapCtrl(CreditGui) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "800 600";
   minExtent = "8 2";
   visible = "1";
   bitmap = "./images/credits.jpg";
   useVariable = "0";
   tile = "0";

   new GuiScrollCtrl(Credit_ScrollCtrl) {
      profile = "GuiScrollProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "458 112";
      extent = "299 328";
      minExtent = "8 8";
      visible = "1";
      willFirstRespond = "1";
      hScrollBar = "alwaysOff";
      vScrollBar = "alwaysOff";
      constantThumbHeight = "0";
      childMargin = "2 2";
         helpTag = "0";

      new GuiMLTextCtrl(Credit_Text) {
         profile = "GuiMLTextProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "2 -278";
         extent = "298 4104";
         minExtent = "8 8";
         visible = "1";
         lineSpacing = "2";
         allowColorChars = "0";
         maxChars = "-1";
            helpTag = "0";
      };
   };
   new GuiBitmapCtrl(Credit_Cover) {
      profile = "GuiDefaultProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "405 46";
      extent = "385 460";
      minExtent = "8 2";
      visible = "1";
      bitmap = "./images/empty.png";
      wrap = "0";
   };
   new GuiBitmapButtonCtrl(CreditGui_Left) {
      profile = "GuiDefaultProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "5 4";
      extent = "460 583";
      minExtent = "8 2";
      visible = "1";
      lockMouse = "0";
      bitmap = "./images/empty.png";
      HighlightBitmap = "./images/empty.png";
      PressedBitmap = "./images/empty.png";
      wrap = "0";
   };
};
//--- OBJECT WRITE END ---

function CreditGui::onWake()
{
	Credit_ScrollCtrl.setActive(false);
	
	%fontSize=getHelpFontSize();
	%fontTitleSize=getHelpTitleFontSize();
	%fontText = "<font:Forgotten Futurist:" @ %fontSize @ "><color:000000>";
	%fontTitleText = "<font:Forgotten Futurist Bold:" @ %fontTitleSize @ "><color:000000>";
	
	%fo = new FileObject();
	%fo.openForRead(loadHelp("c_credits.txt"));
	while (!%fo.isEOF())
		%text = %text @ %fo.readLine() @ "\n";
	
	%fo.delete();

	%fo = new FileObject();
	%fo.openForRead("gamefiles/client/help/rabbit.hfl");
	while(!%fo.isEOF())
	     %text = %text @ %fo.readLine() @ "\n";
	%fo.delete();
	     
	%text = strreplace(%text,"<storytitlefont>",%fontTitleText);
	%text = strreplace(%text,"<storyfont>",%fontText);
	
	Credit_Text.setText(%text);	

        //startRunMusic();
	//$jukebox.shutOffAudioType(song);
	//$jukeBox.playSound(TTRun_Music,1);
	cancel($CreditGui::CreditSchedule);
	$CreditGui::CreditSchedule=schedule(1000,0,"CreditGui_scroll");
}

function CreditGui_scroll()
{
   Credit_ScrollCtrl.scrollPixels(1);
   $CreditGui::CreditSchedule=schedule(50,0,"CreditGui_scroll");
}

function Credit_Cover::onAction()
{
   Canvas.setContentWithFade(MainJournalScreen);
}

function CreditGui_Left::onAction()
{
   Canvas.setContentWithFade(MainJournalScreen);
}
