home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58b_TRIBES.iso / Tribes / base / scripts.vol / GUI.CS < prev    next >
Encoding:
Text File  |  1998-12-16  |  18.5 KB  |  729 lines

  1. //------------------------------------
  2. //
  3. // Game/network functions
  4. //
  5. //------------------------------------
  6.  
  7. function selectNewMaster()
  8. {
  9.     $Server::XLMaster1 = "";
  10.     $inet::Master1 = "";
  11.  
  12.     //translate the address
  13.     %translatedAddress = "";
  14.     if ($Server::Master1 != "") %translatedAddress = DNet::translateAddress($Server::Master1, 5000);
  15.     if (%translatedAddress == "")
  16.     {
  17.         GuiPopDialog(MainWindow, 0);
  18.         GuiPushDialog(MainWindow, "gui\\DNSWarning.gui");
  19.         %mesg = "Internet Connection Problem: Unable to resolve hostname from address: <f1>" @ $Server::Master1 @ ".<f0>  Be aware that you may experience timeout problems while refreshing your game server list.  Ensure your internet connection is operational, and that the master server chosen from the <f1>network options<f0> menu is valid.";
  20.         schedule("Control::setValue(DNSWarningTextFormat, \"" @ %mesg @ "\");", 1);
  21.     }
  22.     else
  23.     {
  24.         GuiPopDialog(MainWindow, 0);
  25.         $Server::XLMaster1 = %translatedAddress;
  26.         $inet::Master1 = %translatedAddress;
  27.     }
  28. }
  29.  
  30. function translateMasters()
  31. {
  32.     if ($DNSLookupFinished) return;
  33.     $DNSLookupFinished = TRUE;
  34.     echo("Verifying Internet connection - please wait...");
  35.     if (! $dedicated) renderCanvas(MainWindow);
  36.     %finished = false;
  37.     %num = 1;
  38.     if ($Server::Master1 == "") %finished = TRUE;
  39.     while (! %finished)
  40.     {
  41.         //translate the address
  42.         %translatedAddress = DNet::translateAddress($Server::Master[%num], 5000);
  43.  
  44.         //if the translation failed, push the warning dialog and exit
  45.         if (%translatedAddress == "" && %num == 1 && (! $dedicated))
  46.         {
  47.             %succeeded = FALSE;
  48.             GuiPushDialog(MainWindow, "gui\\DNSWarning.gui");
  49.             %mesg = "Unable to resolve hostname from address: <f1>" @ $Server::Master1 @ ".<f0>  Be aware that you may experience timeout problems while refreshing your game server list.  Ensure your internet connection is operational, and that the master server chosen from the <f1>network options<f0> menu is valid.";
  50.             schedule("Control::setValue(DNSWarningTextFormat, \"" @ %mesg @ "\");", 1);
  51.         }
  52.         else if (%translatedAddress != "")
  53.         {
  54.             $Server::XLMaster[%num] = %translatedAddress;
  55.         }
  56.         $inet::Master[%num] = $Server::XLMaster[%num];
  57.         %num++;
  58.         if ($Server::Master[%num] == "")
  59.         {
  60.             //we're finished - also pop the verification dialog
  61.             %finished = TRUE;
  62.         }
  63.     }
  64. }
  65.  
  66. function DNSWarning::retry()
  67. {
  68.     GuiPopDialog(MainWindow, 0);
  69.     $DNSLookupFinished = FALSE;
  70.     translateMasters();
  71. }
  72.  
  73. function DNSWarning::cancel()
  74. {
  75.     GuiPopDialog(MainWindow, 0);
  76. }
  77.  
  78. function QuickStart()
  79. {
  80.     $ConnectedToServer = FALSE;
  81.    setCursor(MainWindow, "Cur_Arrow.bmp");
  82.     cursorOn(MainWindow);
  83.     $QuickStart = TRUE;
  84.     if ($PlayingDemo)
  85.     {
  86.         $PlayingDemo = FALSE;
  87.         GuiLoadContentCtrl(MainWindow, "gui\\Recordings.gui");
  88.     }
  89.     else if ($PCFG::Name == "")
  90.        GuiLoadContentCtrl(MainWindow, "gui\\PlayerSetup.gui");
  91.     else if ($pref::PlayGameMode == "")
  92.        GuiLoadContentCtrl(MainWindow, "gui\\Connect.gui");
  93.     else if ($Pref::PlayGameMode == "JOIN")
  94.        GuiLoadContentCtrl(MainWindow, "gui\\JoinGame.gui");
  95.     else if ($pref::PlayGameMode == "TRAIN")
  96.        GuiLoadContentCtrl(MainWindow, "gui\\training.gui");
  97.     else
  98.        GuiLoadContentCtrl(MainWindow, "gui\\CreateServer.gui");
  99.  
  100.     //autologin to the irc client
  101.     IRCLogin::AutoConnect();
  102. }
  103.  
  104. function PlayerSetupNext()
  105. {
  106.     if ($QuickStart == "TRUE")
  107.         QuickStart();
  108.     else
  109.     {
  110.         if ($PCFG::Name == "")
  111.             OpenNewPlayerDialog();
  112.         else
  113.            GuiLoadContentCtrl(MainWindow, "gui\\Connect.gui");
  114.     }
  115. }
  116.  
  117. function JoinGame()
  118. {
  119.     if ($IRC::DisconnectInSim == "")
  120.         $IRC::DisconnectInSim = true;
  121.  
  122.     //disconnect from IRC if req'd
  123.     if ($IRC::DisconnectInSim == true)
  124.     {
  125.         ircDisconnect();
  126.         $IRCConnected = FALSE;
  127.         $IRCJoinedRoom = FALSE;
  128.     }
  129.     //load the "connecting" gui
  130.     GuiLoadContentCtrl(MainWindow, "gui\\Connecting.gui");
  131.  
  132.    $SinglePlayer = False;
  133.    purgeResources();
  134.    connect($Server::Address);
  135. }
  136.  
  137. function EndGame()
  138. {
  139.     $ConnectedToServer = FALSE;
  140.    setCursor(MainWindow, "Cur_Arrow.bmp");
  141.    disconnect();
  142.    if ($SinglePlayer)
  143.        TrainingEndGameCallback();
  144.  
  145.     if ($pref::userCDOverride == False)
  146.     {
  147.         rbSetPlayMode (CD, 0);
  148.         rbStop (CD);
  149.         $cdTrack = "";
  150.     }
  151.     $recordDemo = FALSE;
  152.    startMainMenuScreen();
  153.    deleteServer();
  154.     QuickStart();
  155.    deleteObject(ConsoleScheduler);
  156.    newObject(ConsoleScheduler, SimConsoleScheduler);
  157. }
  158.  
  159. function Canvas::handleEscapeKey()
  160. {
  161.     if ($ConnectedToServer && $InLobbyMode)
  162.     {
  163.         Client::exitLobbyMode();
  164.         return "true";
  165.     }
  166.     return "false";
  167. }
  168.  
  169. function startMainMenuScreen()
  170. {
  171.    GuiLoadContentCtrl(MainWindow, "gui\\MainMenu.gui");
  172.     translateMasters();
  173.  
  174.     if ($pref::userCDOverride == False)
  175.     {
  176.         rbSetPlayMode (CD, 0);
  177.         rbStop (CD);
  178.         $cdPlayMode = 1;
  179.         $cdTrack = 2;
  180.         if ($pref::cdMusic)
  181.             rbPlay (CD, $cdTrack);
  182.     }
  183.     else if ($Override == "")
  184.     {
  185.         $Override = True;
  186.         rbStop (CD);
  187.         rbSetPlayMode (CD, 2);
  188.         rbPlay (CD);
  189.     }
  190.    setCursor(MainWindow, "Cur_Arrow.bmp");
  191.    cursorOn(MainWindow);
  192. }
  193.  
  194. function loadPlayGui()
  195. {
  196.     if (File::FindFirst("play.gui") != "")
  197.         GuiLoadContentCtrl(MainWindow, "play.gui");
  198.     else
  199.         GuiLoadContentCtrl(MainWindow, "gui\\play.gui");
  200. }
  201.  
  202. function switchToChat()
  203. {
  204.     if ($IRCConnected == "TRUE")
  205.         GuiLoadContentCtrl(MainWindow, "gui\\IRCChat.gui");
  206.     else
  207.         GuiLoadContentCtrl(MainWindow, "gui\\IRCLogin.gui");
  208. }
  209.  
  210. //-----------------------------------------------
  211. //
  212. // onExit() is called when the program terminates
  213. //
  214. //-----------------------------------------------
  215.  
  216. function onExit()
  217. {
  218.    if(isObject(playGui))
  219.       storeObject(playGui, "config\\play.gui");
  220.  
  221.    saveActionMap("config\\config.cs", "actionMap.sae", "playMap.sae", "pdaMap.sae");
  222.  
  223.     //update the video mode - since it can be changed with alt-enter
  224.     $pref::VideoFullScreen = isFullScreenMode(MainWindow);
  225.  
  226.     echo("exporting pref::* to prefs.cs");
  227.    export("pref::*", "config\\ClientPrefs.cs", False);
  228.    export("Server::*", "config\\ServerPrefs.cs", False);
  229.    export("pref::lastMission", "config\\ServerPrefs.cs", True);
  230.    BanList::export("config\\banlist.cs");
  231. }
  232.  
  233. //-----------------------------------------------
  234. //
  235. // onQuit() is called when the user clicks the
  236. // in-shell close box
  237. //
  238. //-----------------------------------------------
  239.  
  240. function onQuit()
  241. {
  242.     GuiPushDialog(MainWindow, "gui\\Exit.gui");
  243. }
  244.  
  245. function buildMissionList()
  246. {
  247.    $MLIST::Count = 0;
  248.    $MLIST::TypeCount = 1;
  249.    $MLIST::Type[0] = "All Types";
  250.    $MLIST::MissionList[0] = "";
  251.  
  252.    %file = File::findFirst("missions\\*.dsc");
  253.    while(%file != "")
  254.    {
  255.       $MDESC::Type = "";
  256.       $MDESC::Name = "";
  257.       $MDESC::Text = "";
  258.  
  259.       exec(%file);
  260.  
  261.       if($MDESC::Type == "")
  262.       {
  263.          %file = File::findNext("missions\\*.dsc");
  264.          continue;
  265.       }
  266.       for(%i = 0; %i < $MLIST::TypeCount; %i++)
  267.       {
  268.          if($MLIST::Type[%i] == $MDESC::Type)
  269.             break;
  270.       }
  271.       if(%i == $MLIST::TypeCount)
  272.       {
  273.          $MLIST::Type[%i] = $MDESC::Type;
  274.          $MLIST::TypeCount++;
  275.          $MLIST::MissionList[%i] = "";
  276.       }
  277.       %ct = $MLIST::Count;
  278.       $MLIST::Count++;
  279.       
  280.       $MLIST::EType[%ct] = $MDESC::Type;
  281.       $MLIST::EName[%ct] = File::getBase(%file);
  282.       $MLIST::EText[%ct] = $MDESC::Text;
  283.       if($MDESC::Type != "Training")
  284.          $MLIST::MissionList[0] = %ct @ " " @ $MLIST::MissionList[0];
  285.       $MLIST::MissionList[%i] = %ct @ " " @ $MLIST::MissionList[%i];
  286.       %file = File::findNext("missions\\*.dsc");
  287.    }
  288.  
  289.  
  290.    for(%type = 1; %type < $MLIST::TypeCount; %type++)
  291.    {
  292.       %prev = getWord($MLIST::MissionList[%type], 0);
  293.       %ml = $MLIST::MissionList[%type] @ %prev;
  294.       %prevName = $MLIST::EName[%prev];
  295.       for(%i = 1; (%mis = getWord(%ml, %i)) != -1; %i++)
  296.       {
  297.          %misName = $MLIST::EName[%mis];
  298.          $nextMission[%prevName] = %misName;
  299.          %prevName = %misName;
  300.       }
  301.    }
  302. }
  303.  
  304. buildMissionList();
  305.  
  306. function JoinGameGui::onOpen()
  307. {
  308.     //update the record button
  309.     if (! $recordDemo) $recorderFileName = "";
  310.     Control::setValue(RecordDemo, $recordDemo);
  311. }
  312.  
  313. function CreateServerGui::onOpen()
  314. {
  315.    TextList::clear(MissionTextList);
  316.    FGCombo::clear(MissionTypePopup);
  317.    for(%i = 0; %i < $MLIST::TypeCount; %i++)
  318.       if($MLIST::Type[%i] != "Training")
  319.          FGCombo::addEntry(MissionTypePopup, $MLIST::Type[%i], %i);
  320.  
  321.    if($pref::LastMissionType == "" || $pref::LastMissionType >= $MLIST::TypeCount)
  322.       $pref::LastMissionType = 0;
  323.    FGCombo::setSelected(MissionTypePopup, $pref::LastMissionType);
  324.    MissionTypePopup::buildList();
  325.  
  326.     //verify the max number of players as well...
  327.     verifyMaxPlayers();
  328.     
  329.     //sort the mission text list
  330.     FGTextList::sort(MissionTextList);
  331.  
  332.     //now set the selected
  333.    MissionTextList::onAction();
  334.  
  335.     //update the record button
  336.     if (! $recordDemo) $recorderFileName = "";
  337.     Control::setValue(RecordDemo, $recordDemo);
  338. }
  339.  
  340. function enableHostGame()
  341. {
  342.     %valid = TRUE;
  343.  
  344.     //check the max number of players
  345.     if ($Server::MaxPlayers < 1 || $Server::MaxPlayers > 128)
  346.     {
  347.         %valid = FALSE;
  348.     }
  349.  
  350.     //check the server name
  351.     if (String::empty($Server::HostName))
  352.     {
  353.         %valid = FALSE;
  354.     }
  355.  
  356.     //set the button state
  357.     Control::setActive("CreateServerNow", %valid);
  358. }
  359.  
  360. function verifyServerName()
  361. {
  362.     if (String::Empty(Control::getValue("CreateServerHostName")))
  363.     {
  364.         Control::setValue("CreateServerHostName", "TRIBES Server");
  365.     }
  366. }
  367.  
  368. function verifyMaxPlayers()
  369. {
  370.     if (Control::getValue(IDCTG_MAX_PLAYERS) < 1) Control::setValue(IDCTG_MAX_PLAYERS, 8);
  371.     else if (Control::getValue(IDCTG_MAX_PLAYERS) > 32) Control::setValue(IDCTG_MAX_PLAYERS, 32);
  372.     enableHostGame();
  373. }
  374.  
  375. function TrainingGui::onOpen()
  376. {
  377.    TextList::clear(TrainingMissionTextList);
  378.    for(%i = 0; %i < $MLIST::TypeCount; %i++)
  379.       if($MLIST::Type[%i] == "Training")
  380.          break;
  381.  
  382.    for(%j = 0; (%mis = getWord($MLIST::MissionList[%i], %j)) != -1; %j++)
  383.       TextList::addLine(TrainingMissionTextList, $MLIST::EName[%mis]);
  384.    
  385.     //sort the training mission text list
  386.     FGTextList::sort(TrainingMissionTextList);
  387.  
  388.    Control::setValue(TrainingMissionTextList, $pref::LastTrainingMission);
  389.    TrainingMissionTextList::onAction();
  390.  
  391.    %prev = getWord($MLIST::MissionList[%i], 0);
  392.    %ml = $MLIST::MissionList[%i] @ %prev;
  393.    %prevName = $MLIST::EName[%prev];
  394.  
  395.     //update the record button
  396.     if (! $recordDemo) $recorderFileName = "";
  397.     Control::setValue(RecordDemo, $recordDemo);
  398. }
  399.  
  400. function MissionTypePopup::buildList()
  401. {
  402.    %sel = FGCombo::getSelected(MissionTypePopup);
  403.    TextList::clear(MissionTextList);
  404.  
  405.     //see if it gets added
  406.     %found = FALSE;
  407.    for(%i = 0; (%mis = getWord($MLIST::MissionList[%sel], %i)) != -1; %i++)
  408.     {
  409.       TextList::addLine(MissionTextList, $MLIST::EName[%mis]);
  410.         if ($MLIST::EName[%mis] == $pref::LastMission) %found = TRUE;
  411.     }
  412.  
  413.     //if the last mission selected was not added, choose the first in the list
  414.     if (%found == FALSE)
  415.     {
  416.        $pref::lastMission = $MLIST::EName[getWord($MLIST::MissionList[%sel], 0)];
  417.     }
  418.  
  419.     //sort the mission text list
  420.     FGTextList::sort(MissionTextList);
  421.  
  422.    Control::setValue(MissionTextList, $pref::LastMission);
  423.    $pref::lastMissionType = %sel;
  424.    MissionTextList::onAction();
  425. }
  426.  
  427. function MissionTextList::onAction()
  428. {
  429.    $pref::lastMission = Control::getValue(MissionTextList);
  430.  
  431.    // find the mission number...
  432.    for(%i = 0; %i < $MLIST::Count; %i++)
  433.       if($MLIST::EName[%i] == $pref::lastMission)
  434.          break;
  435.  
  436.    Control::setValue(MissionDescText, $MLIST::EText[%i]);
  437.  
  438. }
  439.  
  440. function TrainingMissionTextList::onAction()
  441. {
  442.    $pref::lastTrainingMission = Control::getValue(TrainingMissionTextList);
  443.  
  444.    // find the mission number...
  445.    for(%i = 0; %i < $MLIST::Count; %i++)
  446.       if($MLIST::EName[%i] == $pref::lastTrainingMission)
  447.          break;
  448.  
  449.    Control::setValue(MissionDescText, $MLIST::EText[%i]);
  450.  
  451. }
  452. //--------------------------------------------------------------------------------------------------
  453.  
  454. function RecordingsGui::onOpen()
  455. {
  456.     $RecordingsCount = 0;
  457.    EvalSearchPath();
  458.     TextList::clear(RecordingsTextList);
  459.    %rec = File::FindFirst("*.rec");
  460.    while(%rec != "")
  461.    {
  462.       %demo = File::getBase(%rec);
  463.       TextList::addLine(RecordingsTextList, %demo);
  464.       %rec = File::FindNext("*.rec");
  465.  
  466.         $Recording[$RecordingsCount] = %demo;
  467.         $RecordingsCount++;
  468.    }
  469.     RecordingsGui::verify();
  470.     FGTextList::sort(RecordingsTextList);
  471.     Control::setValue(RecordingsContinuous, $pref::RecordingsContinuous);
  472. }
  473.  
  474. function RecordingsGui::verify()
  475. {
  476.     if (Control::getValue(RecordingsTextList) == "")
  477.     {
  478.         %selected = FALSE;
  479.     }
  480.     else
  481.     {
  482.         %selected = TRUE;
  483.     }
  484.     Control::setActive(RecordingsRemove, %selected);
  485.     Control::setActive(RecordingsRename, %selected);
  486.     Control::setActive(RecordingsPlayDemo, %selected);
  487. }
  488.  
  489. function RecordingsGui::PlayDemo()
  490. {
  491.     %fileName = "recordings\\" @ Control::getValue(RecordingsTextList) @ ".rec";
  492.     if (isFile(%fileName))
  493.     {
  494.         $PlayingDemo = TRUE;
  495.        playDemo("recordings\\" @ Control::getValue(RecordingsTextList) @ ".rec");
  496.         cursorOn(MainWindow);
  497.        GuiLoadContentCtrl(MainWindow, "gui\\Loading.gui");
  498.         renderCanvas(MainWindow);
  499.     }
  500.     else
  501.     {
  502.         RecordingsGui::onOpen();
  503.     }
  504. }
  505.  
  506. function RecordingsGui::removeSelectedDemo()
  507. {
  508.     if (Control::getValue(RecordingsTextList) != "")
  509.     {
  510.         %srcFile = "recordings\\" @ Control::getValue(RecordingsTextList) @ ".rec";
  511.  
  512.         //delete the file
  513.         File::delete(%srcFile);
  514.  
  515.         //now repopulate the list
  516.         RecordingsGui::onOpen();
  517.     }
  518. }
  519.  
  520. function RecordingsGui::renameSelectedDemo()
  521. {
  522.     //first copy the old
  523.     %newName = Control::getValue(RenameDemoText);
  524.     if (Control::getValue(RecordingsTextList) != "" && %newName != "")
  525.     {
  526.         %srcFile = "recordings\\" @ Control::getValue(RecordingsTextList) @ ".rec";
  527.         if (String::findSubStr(%newName, ".rec") >= 1)
  528.         {
  529.             %destFile = "recordings\\" @ %newName;
  530.         }
  531.         else
  532.         {
  533.             %destFile = "recordings\\" @ %newName @ ".rec";
  534.         }
  535.  
  536.         //copy the file
  537.         if (File::copy(%srcFile, %destFile))
  538.         {
  539.             //delete the old
  540.             File::delete(%srcFile);
  541.  
  542.             //now repopulate the list
  543.             RecordingsGui::onOpen();
  544.  
  545.             //reselect the new name
  546.             TextList::setSelected(RecordingsTextList, %newName);
  547.             RecordingsGui::verify();
  548.             GuiPopDialog(MainWindow, 0);
  549.         }
  550.         else
  551.         {
  552.             GuiPopDialog(MainWindow, 0);
  553.             GuiPushDialog(MainWindow, "gui\\MessageDialog.gui");
  554.             Control::setValue(MessageDialogTextFormat, "Unable to save recording as <f1>" @ %newName @ ".<f0>  Please ensure the new name is a valid file name.");
  555.         }
  556.     }
  557. }
  558.  
  559. function RenameDemoText::onAction()
  560. {
  561.     if (! String::empty(Control::getValue(RenameDemoText)))
  562.     {
  563.         Control::setActive(IDCTG_RENAME_DEMO_DONE, TRUE);
  564.     }
  565.     else
  566.     {
  567.         Control::setActive(IDCTG_RENAME_DEMO_DONE, FALSE);
  568.     }
  569. }
  570.  
  571. function RecordingsGui::playRandom()
  572. {
  573.     if ($RecordingsCount > 0 && $pref::RecordingsContinuous)
  574.     {
  575.         %randomNum = floor(getRandom() * ($RecordingsCount - 0.01));
  576.         Control::setValue(RecordingsTextList, $Recording[%randomNum]);
  577.         RecordingsGui::PlayDemo();
  578.     }
  579. }
  580.  
  581. //--------------------------------------------------------------------------------------------------
  582.  
  583. // button names are favbutton1...favbutton5, markfavoritesButton, buyFavoritesButton
  584.  
  585. function BuyList::onSelect(%sel)
  586. {
  587.    ShapeView::setItem(ItemView, %sel);
  588.    //echo(%sel);
  589. }
  590.  
  591. function BuyList::onDoubleClick(%sel)
  592. {
  593.    remoteEval(2048, "buyItem", %sel);
  594.    //echo("BuyD " @ %sel);
  595. }
  596.  
  597. function InventoryList::onSelect(%sel)
  598. {
  599.    ShapeView::setItem(ItemView, %sel);
  600. }
  601.  
  602. function InventoryList::onDoubleClick(%sel)
  603. {
  604.    remoteEval(2048, "sellItem", %sel);
  605.    //echo("InvD " @ %sel);
  606. }
  607.  
  608. function CmdInventoryGui::sellSelected()
  609. {
  610.    %sel = Control::getValue(InventoryList);
  611.    if(%sel != -1)
  612.       remoteEval(2048, "sellItem", %sel);
  613. }
  614.  
  615. function CmdInventoryGui::dropSelected()
  616. {
  617.    %sel = Control::getValue(InventoryList);
  618.    if(%sel != -1)
  619.       remoteEval(2048, "dropItem", %sel);
  620. }
  621.  
  622. function CmdInventoryGui::useSelected()
  623. {
  624.    %sel = Control::getValue(InventoryList);
  625.    if(%sel != -1)
  626.       remoteEval(2048, "useItem", %sel);
  627. }
  628.  
  629. function CmdInventoryGui::buySelected()
  630. {
  631.    %sel = Control::getValue(BuyList);
  632.    if(%sel != -1)
  633.       remoteEval(2048, "buyItem", %sel);
  634. }
  635.  
  636. // ts control's name is ItemView
  637.  
  638. $curFavorites = -1;
  639.  
  640. function CmdInventoryGui::onOpen()
  641. {
  642.    if($curFavorites == -1)
  643.    {
  644.       CmdInventoryGui::favoritesSel(1);
  645.       Control::performClick("FavButton1");
  646.    }
  647. }
  648.  
  649. function CmdInventoryGui::favoritesSel(%favList)
  650. {
  651.    $curFavorites = %favList;
  652.    CmdInventory::setFavorites($pref::favoriteList[$curFavorites]);
  653. }
  654.  
  655. function CmdInventoryGui::markFavorites()
  656. {
  657.    if($curFavorites != -1)
  658.    {
  659.       $pref::favoriteList[$curFavorites] = CmdInventory::getVisibleSet(InventoryList);
  660.       CmdInventory::setFavorites($pref::favoriteList[$curFavorites]);
  661.    }
  662. }
  663.  
  664. function CmdInventoryGui::buyFavorites()
  665. {
  666.    if($curFavorites != -1)
  667.    {
  668.       %fav = $pref::favoriteList[$curFavorites];
  669.       %first = getWord(%fav, 0);
  670.       if(%first == -1)
  671.          return;
  672.  
  673.       %cmd = "remoteEval(2048, buyFavorites, " @ %first;
  674.       for(%i = 1; (%word = getWord(%fav, %i)) != -1; %i++)
  675.          %cmd = %cmd @ ", " @ %word;
  676.       %cmd = %cmd @ ");";
  677.       eval(%cmd);
  678.    }
  679. }
  680.  
  681. function ConnectGui::ChooseGame()
  682. {
  683.    if($pref::playGameMode == "JOIN")
  684.       GuiLoadContentCtrl(MainWindow, "gui\\joingame.gui");
  685.    else if($pref::playGameMode == "TRAIN")
  686.       GuiLoadContentCtrl(MainWindow, "gui\\training.gui");
  687.    else
  688.       GuiLoadContentCtrl(MainWindow, "gui\\createServer.gui");
  689. }
  690.  
  691. function LoadingGui::onOpen()
  692. {
  693.    Control::setValue(ProgressSlider, 0.0);
  694. }
  695.  
  696. //--------------------------------------------------------------------------------------------------
  697. function userCD ()
  698. {
  699.      $cdPlayMode = 2;
  700.     $pref::cdMusic = False;
  701.     $pref::userCDOverride = True;
  702.     rbStop (CD);
  703.     rbSetPlayMode (CD, $cdPlayMode);
  704.     rbPlay (CD, 1);
  705. }
  706.  
  707. function gameCD ()
  708. {
  709.     $pref::userCDOverride = False;
  710.     $pref::cdMusic = True;
  711.     rbStop (CD);
  712.     $cdPlayMode = 0;
  713.     rbSetPlayMode (CD, $cdPlayMode);
  714.     rbPlay (CD, 2);
  715. }
  716.  
  717. //--------------------------------------------------------------------------------------------------
  718. function LobbyGui::onOpen()
  719. {
  720.     Control::setValue(LobbyServerName, $ServerName);
  721.     Control::setValue(LobbyServerType, $ServerMod);
  722.     Control::setValue(LobbyMissionName, $ServerMission);
  723.     Control::setValue(LobbyMissionType, $ServerMissionType);
  724.     Control::setValue(LobbyVersion, $ServerVersion);
  725.     Control::setValue(LobbyAddress, $Server::Address);
  726.  
  727.    Control::setValue(LobbyServerText, $ServerInfo);
  728.    Control::setValue(LobbyMissionDesc, $ServerText);
  729. }