home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / common / libraries / library_page_nanager.cnc < prev    next >
Text File  |  2001-06-07  |  9KB  |  293 lines

  1. func void LowLevelLoadPage(i32x iPageId)
  2. {
  3.     if(iPageId != oManager.iPageID)
  4.     {
  5. #checkpoint LOWLEVELLOADPAGE
  6.         // SetManagerContext
  7.         SetParserComponent(oManager.pThis);
  8.  
  9.         // Direct call to manager event func
  10.         // Delete the current page
  11.         //        print("*** [low level loadpage] *** destructor on page : ");
  12.         //        println(itoa(oManager.iPageID));
  13.         CallDestructor(oPageList[oManager.iPageID].pdelete);
  14.  
  15.         // Init Menu Background
  16.         vInitMenuBackground();
  17.  
  18.         // Create the new page
  19.         oManager.iPageID = iPageId;
  20.         //        print("*** [low level loadpage] *** constructor on page : ");
  21.         //        println(itoa(oManager.iPageID));
  22.         oManager.iWindowID = CallConstructor(oPageList[oManager.iPageID].pnew);
  23.         SetComponentPosition(oManager.iWindowID, oManager.iWindowPositionX, oManager.iWindowPositionY);
  24.         if(oManager.iWindowDialogID != ID_NOT_CREATED)
  25.         {
  26.             oManager.iWindowEventsBF = GetEvents(oManager.iWindowID);
  27.             if(oManager.iWindowEventsBF == GUI_NoEvent)
  28.             {
  29.                 oManager.iWindowEventsBF = GUI_Destroy | GUI_MouseRoll | GUI_MouseMove | GUI_MouseUp | GUI_MouseDown | GUI_MouseEnter | GUI_MouseLeave | GUI_Key | GUI_Refresh | GUI_Enable | GUI_Disable;
  30.             }
  31.             SetEvents(oManager.iWindowID, GUI_NoEvent);
  32.         }
  33.     }
  34.     else
  35.     {
  36.         print("*** [low level loadpage] *** no need to load this page : ");
  37.         println(itoa(iPageId));
  38.     }
  39. }
  40. func void ReloadPage()
  41. {
  42.     // Re load actual displayed page
  43.     SetParserComponent(oManager.pThis);
  44.  
  45.     CallDestructor(oPageList[oManager.iPageID].pdelete);
  46.     oManager.iWindowID = CallConstructor(oPageList[oManager.iPageID].pnew);
  47.     SetComponentPosition(oManager.iWindowID, oManager.iWindowPositionX, oManager.iWindowPositionY);
  48. }
  49.  
  50. func void InRace_LoadPage()
  51. {
  52.     SetParserComponent(oManager.pThis);
  53.  
  54.     // delete menu
  55.     HideMenuPrincipal();
  56.  
  57.     // delete current page
  58.     if (oManager.iWindowID != ID_NOT_CREATED)
  59.     {
  60.         CallDestructor(oPageList[oManager.iPageID].pdelete);
  61.         oManager.iWindowID = ID_NOT_CREATED;
  62.     }
  63.     
  64.     // delete background
  65.     vDeleteMenuBackground();
  66.     
  67.     // Create the new page
  68.     oManager.iPageID = PAGE_INRACE;
  69.     oManager.iWindowID = CallConstructor(oPageList[oManager.iPageID].pnew);
  70. }
  71.  
  72.  
  73. func void Manager_LoadPage(i32x _iEventID)
  74. {
  75.     if (_iEventID != oManager.iPageID)
  76.     {
  77.         // Delete the current page
  78.         if (oManager.iWindowID != ID_NOT_CREATED)
  79.         {
  80.             print("deleting current page\n");
  81.             CallDestructor(oPageList[oManager.iPageID].pdelete);
  82.             oManager.iWindowID = ID_NOT_CREATED;
  83.         }
  84.  
  85.         // Init Menu Background
  86.         vInitMenuBackground();
  87.  
  88.         // Create the new page
  89.         oManager.iPageID = _iEventID;
  90.         oManager.iWindowID = CallConstructor(oPageList[oManager.iPageID].pnew);
  91.         SetComponentPosition(oManager.iWindowID, oManager.iWindowPositionX, oManager.iWindowPositionY);
  92.         if(oManager.iWindowDialogID != ID_NOT_CREATED)
  93.         {
  94.             oManager.iWindowEventsBF = GetEvents(oManager.iWindowID);
  95.             if(oManager.iWindowEventsBF == GUI_NoEvent)
  96.             {
  97.                 oManager.iWindowEventsBF = GUI_Destroy | GUI_MouseRoll | GUI_MouseMove | GUI_MouseUp | GUI_MouseDown | GUI_MouseEnter | GUI_MouseLeave | GUI_Key | GUI_Refresh | GUI_Enable | GUI_Disable;
  98.             }
  99.             SetEvents(oManager.iWindowID, GUI_NoEvent);
  100.         }
  101.     }
  102. }
  103.  
  104. func void Manager_CreateDialog(i32x _iDialog)
  105. {
  106.     if (oManager.iWindowDialogID==ID_NOT_CREATED)
  107.     {
  108.         // set context
  109.         var component pOldComponent;
  110.         pOldComponent=GetParserComponent();
  111.         SetParserComponent(oManager.pThis);
  112.  
  113.         // Dialog is reserved
  114.         // even if Dialbox constructor create a dialbox the manager don't create it !
  115.         oManager.iWindowDialogID = -1;
  116.         // create dialog
  117.         oManager.iWindowDialogID=CallConstructor(oDialogList[_iDialog].pnew);
  118.         oManager.iDialogID=_iDialog;
  119.         // make modal dialog
  120.         if (oManager.iMenu_PrincipalID != ID_NOT_CREATED)
  121.         {
  122.             oManager.iMenuEventsBF = GetEvents(oManager.iMenu_PrincipalID);
  123.             SetEvents(oManager.iMenu_PrincipalID, GUI_NoEvent);
  124.         }
  125.         if (oManager.iWindowID != ID_NOT_CREATED)
  126.         {
  127.             oManager.iWindowEventsBF = GetEvents(oManager.iWindowID);
  128.             SetEvents(oManager.iWindowID, GUI_NoEvent);
  129.         }
  130.         else
  131.         {
  132.             //Default windows event
  133.             oManager.iWindowEventsBF = GUI_Destroy | GUI_MouseMove | GUI_MouseUp | GUI_MouseDown | GUI_MouseEnter | GUI_MouseLeave | GUI_Key | GUI_Refresh | GUI_Enable | GUI_Disable;
  134.         }
  135.  
  136.         // center dialog
  137.         var i32x iWidth,iHeight,iPosX,iPosY;
  138.         iWidth=GetComponentWidth(oManager.iWindowDialogID);
  139.         iHeight=GetComponentHeight(oManager.iWindowDialogID);
  140.         iPosX=(800-iWidth)/2;
  141.         iPosY=(600-iHeight)/2;
  142.         SetComponentPosition(oManager.iWindowDialogID,iPosX,iPosY);
  143.         // restore context
  144.         SetParserComponent(pOldComponent);
  145.     }
  146. }
  147.  
  148. func void Manager_DestroyDialog ()
  149. {
  150.     if (oManager.iWindowDialogID != ID_NOT_CREATED)
  151.     {
  152.         CallDestructor(oDialogList[oManager.iDialogID].pdelete);
  153.         oManager.iWindowDialogID=ID_NOT_CREATED;
  154.         // restore Events BF
  155.         if (oManager.iMenu_PrincipalID != ID_NOT_CREATED)
  156.             SetEvents(oManager.iMenu_PrincipalID, oManager.iMenuEventsBF);
  157.         if (oManager.iWindowID != ID_NOT_CREATED)
  158.         {
  159.             SetEvents(oManager.iWindowID, oManager.iWindowEventsBF);
  160.             if(oManager.iDialogID != DIALOG_LOADING_DATA)
  161.             {
  162.                 // Inform active page that dialbox is closed
  163.                 PushEventOnChild(oManager.iWindowID,GUI_DIALOG_RETURN);
  164.             }
  165.         }
  166.     }
  167. }
  168.  
  169. func void CreateDialog(i32x _iDialog)
  170. {
  171.     if (oManager.iWindowDialogID==ID_NOT_CREATED)
  172.     {
  173.         Manager_CreateDialog(_iDialog);
  174.     }
  175.     else
  176.     {
  177.         // A dialog is already available
  178.         // So push an event into parents stack so that
  179.         // it can manage the CreateDialog
  180.         PushEvent(GUI_CREATE_DIALOG + _iDialog);
  181.     }
  182. }
  183.  
  184. func void DestroyDialog()
  185. {
  186.     var component pComponent;
  187.  
  188.     // Save current context
  189.     pComponent = GetParserComponent();
  190.  
  191.     // Set page manager context
  192.     SetParserComponent(oManager.pThis);
  193.  
  194.     Manager_DestroyDialog();
  195.  
  196.     // Restore context
  197.     SetParserComponent(pComponent);
  198. }
  199.  
  200. func void LoadPage(i32x _iPageID)
  201. {
  202.     if (_iPageID != oManager.iPageID)
  203.     {
  204.         // fonction save de la page courante
  205.         if (oPageList[oManager.iPageID].psavedata)
  206.         {
  207.             // set context (manager)
  208.             var component pComponent;
  209.             pComponent=GetParserComponent();
  210.             SetParserComponent(oManager.pThis);
  211.             
  212.             // create waiting dialog    
  213.             CreateDialog(DIALOG_LOADING_DATA);
  214.  
  215.             CallSaveData(oPageList[oManager.iPageID].psavedata);
  216.  
  217.             SetParserComponent(pComponent);
  218.         }
  219.         
  220.         // if there is a load func call it
  221.         if (oPageList[_iPageID].ploaddata)
  222.         {
  223.             #checkpoint >> loading page data
  224.     
  225.             CallLoadData(oPageList[_iPageID].ploaddata);
  226.         }
  227.         else
  228.         {
  229.             PushEvent(_iPageID);
  230.         }
  231.     }
  232. }
  233.  
  234. //func void Manager_CreatePopup(szx szMessage)
  235. //{
  236. //    print("********************** POPUP ***********************\n");
  237. //    print(szMessage);
  238. //    print("\n********************** POPUP ***********************\n");
  239. //    Dialog_Popup_InitMembers(szMessage);
  240. //    CreateDialog(DIALOG_POPUP);
  241. //}
  242.  
  243. //----------------------------------------------------------------------------------------------------------------//
  244. //----------------------------------------------------------------------------------------------------------------//
  245. //----------------------------------------------------------------------------------------------------------------//
  246. //----------------------------------------------------------------------------------------------------------------//
  247. func void DisplayMenuPrincipal ()
  248. {
  249.     if (oManager.iMenu_PrincipalID == ID_NOT_CREATED)
  250.     {
  251.         var component pComponent;
  252.         // Get current context
  253.         pComponent = GetParserComponent();
  254.  
  255.         // Set main object (manager) context
  256.         SetParserComponent(oManager.pThis);
  257.  
  258.         // Init the main menu
  259.         oManager.iMenu_PrincipalID = InitObject(oMenu_Principal.szName, oMenu_Principal.oFunc.pcreate, oMenu_Principal.oFunc.pevent);
  260.         SetStackEvents(oManager.iMenu_PrincipalID,GUI_Destroy | GUI_Key | GUI_Enable | GUI_Disable | GUI_Refresh);
  261.         SetRefreshState(oManager.iMenu_PrincipalID,64,0);
  262.         SetComponentPositionY(oManager.iMenu_PrincipalID, 100);
  263.  
  264.         // restore context
  265.         SetParserComponent(pComponent);
  266.     }
  267. }
  268.  
  269. //----------------------------------------------------------------------------------------------------------------//
  270. //----------------------------------------------------------------------------------------------------------------//
  271. //----------------------------------------------------------------------------------------------------------------//
  272. //----------------------------------------------------------------------------------------------------------------//
  273. func void HideMenuPrincipal ()
  274. {
  275.     if (oManager.iMenu_PrincipalID != ID_NOT_CREATED)
  276.     {
  277.         // set context
  278.         var component pComponent;
  279.         // Save current context
  280.         pComponent = GetParserComponent();
  281.  
  282.         // Set object manager context
  283.         SetParserComponent(oManager.pThis);
  284.  
  285.         // delete menu principal
  286.         DeleteComponent(oManager.iMenu_PrincipalID);
  287.         oManager.iMenu_PrincipalID = ID_NOT_CREATED;
  288.  
  289.         // restore context
  290.         SetParserComponent(pComponent);
  291.     }
  292. }
  293.