home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / common / admin / page_admin.cnc < prev    next >
Text File  |  2001-06-11  |  16KB  |  453 lines

  1. func void SkipFailed_MessageBoxCallback(i32x iResult)
  2. {
  3.     // Nothing todo
  4. }
  5.  
  6. // Object Admin
  7. func void ObjectAdmin_Create ()
  8. {
  9.     var szx szTemp;
  10.     var i32x i,id,iRaceId;
  11.     // Get current context
  12.     oObjectAdmin.pthis = GetParserComponent();
  13.  
  14.     SetComponentNumber(49);
  15.  
  16.     //game mode
  17.     szTemp = strcat(GetLocalizedFromGMKey(171),":");
  18.  
  19.     if(g_oGameConfig.m_iGameMode == GAME_MODE_SEASON)
  20.         szTemp = strcat(szTemp,GetLocalizedFromGMKey(130));
  21.     if(g_oGameConfig.m_iGameMode == GAME_MODE_TOUR)
  22.         szTemp = strcat(szTemp,GetLocalizedFromGMKey(264));
  23.     if(g_oGameConfig.m_iGameMode == GAME_MODE_STAGE)
  24.         szTemp = strcat(szTemp,GetLocalizedFromGMKey(95));
  25.  
  26.     oObjectAdmin.m_cInfoMode=InitContainer(tFnt_20);
  27.     SetContainerText(oObjectAdmin.m_cInfoMode,szTemp);
  28.     SetComponentPosition(oObjectAdmin.m_cInfoMode,10,0);
  29.  
  30.     
  31.     //info phase
  32.     oObjectAdmin.m_cInfoPhase=InitContainer(tFnt_20);
  33.     SetComponentPosition(oObjectAdmin.m_cInfoPhase,300,0);
  34.  
  35.  
  36.     id = InitContainer(tCommonTableBorder);
  37.     SetContainerSize(id,600,1);
  38.     SetComponentPosition(id,10,40);
  39.     SetEvents(id,GUI_NoEvent);
  40.  
  41.     // Race Name
  42.     oObjectAdmin.m_cRaceName = InitContainer(tFnt_20);
  43.     SetContainerScaleY(oObjectAdmin.m_cRaceName,0.5);
  44.     SetContainerText(oObjectAdmin.m_cRaceName,GetLocalizedFromKey(Join_GetIntFromKey(g_oLocalJoins.m_iRace_iNameId,g_oGameConfig.m_iCurrentRaceID)));
  45.     SetComponentPosition(oObjectAdmin.m_cRaceName,10,130);
  46.  
  47.     //Profil of the current stage
  48.     Panel_Team_Tactic_Profil_InitMembers(g_oGameConfig.m_iCurrentStageID,1,1,600,100,10,150);
  49.     oObjectAdmin.m_cProfil=InitObject(oPanel_Team_Tactic_Profil.szName, oPanel_Team_Tactic_Profil.oFunc.pcreate, oPanel_Team_Tactic_Profil.oFunc.pevent);
  50.     SetStackEvents(oObjectAdmin.m_cProfil,GUI_Destroy | GUI_Char|GUI_KeyDown);
  51.  
  52.     // Profil border
  53.     id = InitContainer(tCommonTableBorder);
  54.     SetContainerSize(id,600,1);
  55.     SetComponentPosition(id,10,150);
  56.     SetEvents(id,GUI_NoEvent);
  57.     id = InitContainer(tCommonTableBorder);
  58.     SetContainerSize(id,600,1);
  59.     SetComponentPosition(id,10,250);
  60.     SetEvents(id,GUI_NoEvent);
  61.     id = InitContainer(tCommonTableBorder);
  62.     SetContainerSize(id,1,100);
  63.     SetComponentPosition(id,10,150);
  64.     SetEvents(id,GUI_NoEvent);
  65.     id = InitContainer(tCommonTableBorder);
  66.     SetContainerSize(id,1,100);
  67.     SetComponentPosition(id,610,150);
  68.     SetEvents(id,GUI_NoEvent);
  69.  
  70.     //button ready
  71.     oObjectAdmin.m_cReady=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,9,GetLocalizedFromGMKey(379),tFontArial,1470);
  72.     SetTextButtonStateFunc(oObjectAdmin.m_cReady,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
  73.     SetComponentPosition(oObjectAdmin.m_cReady,15,260);
  74.  
  75.     //button not ready
  76.     oObjectAdmin.m_cNotReady=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,9,GetLocalizedFromGMKey(381),tFontArial,1472);
  77.     SetTextButtonStateFunc(oObjectAdmin.m_cNotReady,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
  78.     SetComponentPosition(oObjectAdmin.m_cNotReady,600-GetComponentWidth(oObjectAdmin.m_cNotReady),260);
  79.  
  80.     //skip
  81.     oObjectAdmin.m_cSkip=InitLibMultiSpriteButtonWithText(tButton32Multi,7,GetLocalizedFromGMKey(424),tFontArial,0);
  82.     SetComponentPosition(oObjectAdmin.m_cSkip,600-GetComponentWidth(oObjectAdmin.m_cSkip),115);
  83.  
  84.     if(g_oGameConfig.m_iGameMode == GAME_MODE_STAGE)
  85.         SetComponentVisibleStatus(oObjectAdmin.m_cSkip,false);
  86.  
  87.     // Ready mode : by default
  88.     if(g_oGameConfig.m_iGameOver == 1)
  89.     {
  90.         SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
  91.         SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
  92.         SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
  93.     }
  94.     else
  95.     {
  96.         if(g_oUser.m_iUserMode == G_iGuestUser)
  97.         {
  98.             SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
  99.             SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
  100.             SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
  101.         }
  102.         else
  103.         {
  104.             if(g_oGameConfig.m_iReady)
  105.             {
  106.                 SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,true);
  107.             }
  108.             else
  109.             {
  110.                 SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
  111.             }
  112.         }
  113.     }
  114.  
  115.     AutoResize();
  116. }    
  117.  
  118. func i32x ObjectAdmin_Event (i32x _iComponentID,i32x _iEvent)
  119. {
  120.     if(_iComponentID == oObjectAdmin.m_cProfil)
  121.     {
  122.         if(_iEvent >= GUI_CREATE_DIALOG )
  123.         {
  124.             PushEvent(_iEvent); // Chain event
  125.         }
  126.     }
  127.     if(_iEvent == GUI_RADIOBUTTON_CHANGED )
  128.     {
  129.         PlaySound(0,sbClickSound[0]);
  130.  
  131.         if(_iComponentID == oObjectAdmin.m_cReady)
  132.         {
  133.             g_oGameConfig.m_iReady = true;
  134.             SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,false);
  135.             // Send Next command to menu server
  136.             g_oMenuServer.m_oServer<<mGame_NextPhase();
  137.         }
  138.         if(_iComponentID == oObjectAdmin.m_cNotReady)
  139.         {
  140.             g_oGameConfig.m_iReady = false;
  141.             SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,false);
  142.             // Send CancelNext command to menu server
  143.             g_oMenuServer.m_oServer<<mGame_CancelNextPhase();
  144.         }
  145.     }
  146.     if(_iComponentID == oObjectAdmin.m_cSkip)
  147.     {
  148.         if(_iEvent == GUI_BUTTON_PRESSED )
  149.         {
  150.             PlaySound(0,sbClickSound[0]);
  151.  
  152.             // Can't skip the last stage of a tour
  153.             /*
  154.             if(Database_GetIntData(QUERY_GLOBAL_STAGES,"STA_stage.gene_i_stage_number",ROW_KEY,g_oGameConfig.m_iCurrentStageID)
  155.                 < Database_GetIntData(QUERY_GLOBAL_STAGES,"STA_race.gene_i_number_stages",ROW_KEY,g_oGameConfig.m_iCurrentRaceID))
  156.             {
  157.                 // Send Next stage command to menu server
  158.                 g_oMenuServer.m_oServer<<mGame_NextStage();
  159.             }
  160.             else
  161.             {
  162.                 CreateMessageBox(GetLocalizedFromGMKey(434),g_iTypeOkDialog,SkipFailed_MessageBoxCallback);
  163.             }
  164.             */
  165.             // Send Next stage command to menu server
  166.             g_oMenuServer.m_oServer<<mGame_NextStage();
  167.         }
  168.     }
  169.     if(_iComponentID == -1)
  170.     {
  171.         if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
  172.         {
  173.             // Raz index and pointer
  174.             oObjectAdmin.pthis = g_poNullComponent;
  175.  
  176.             oObjectAdmin.m_cProfil = ID_NOT_CREATED;
  177.             oObjectAdmin.m_cReady = ID_NOT_CREATED;
  178.             oObjectAdmin.m_cNotReady = ID_NOT_CREATED;
  179.             oObjectAdmin.m_cInfoMode = ID_NOT_CREATED;
  180.             oObjectAdmin.m_cInfoPhase = ID_NOT_CREATED;
  181.         }
  182.     }
  183.     return 1;
  184. }
  185.  
  186.  
  187. //----------------------------------------------------------------------------------------------------------------//
  188. //----------------------------------------------------------------------------------------------------------------//
  189. //PageAdmin Window Create func
  190. //----------------------------------------------------------------------------------------------------------------//
  191. //----------------------------------------------------------------------------------------------------------------//
  192. func void PageAdmin_Create ()
  193. {
  194.     var i32x iPosX;
  195.     SetComponentNumber(9);
  196.  
  197.     // Get current context
  198.     oPageAdmin.pthis = GetParserComponent();
  199.  
  200.     // *** Update Title Bar ***
  201.     Set_Title_Bar_Text(GetLocalizedFromGMKey(383)); // page title
  202.  
  203.     //Dialog background
  204.     oPageAdmin.m_cBackground = Init_LibObject_FilledCadre(tCadreDialbox,700,550);
  205.  
  206.     // *** Create onglet selection radio button ***
  207.     iPosX = 5;
  208.     oPageAdmin.m_cAdmin=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,7,GetLocalizedFromGMKey(164),tFontArial,0);
  209.     SetComponentPosition(oPageAdmin.m_cAdmin, iPosX, 40);
  210.     SetTextButtonStateFunc(oPageAdmin.m_cAdmin,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
  211.     ResizeComponent(oPageAdmin.m_cAdmin);
  212.     iPosX = iPosX + GetComponentWidth(oPageAdmin.m_cAdmin) + 5;
  213.  
  214.     //Admin
  215.     oPageAdmin.iAdminID=InitObject("admin",ObjectAdmin_Create ,ObjectAdmin_Event);
  216.     SetComponentPosition(oPageAdmin.iAdminID,20 ,90);
  217.     SetStackEvents(oPageAdmin.iAdminID,GUI_Destroy | GUI_Key | GUI_Enable | GUI_Disable | GUI_Refresh);
  218.     SetRefreshState(oPageAdmin.iAdminID,40,1);
  219.  
  220.     if(g_oGameConfig.m_iSinglePlayer==0)
  221.     {
  222.         // Users onglet
  223.         oPageAdmin.m_cUsers=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,7,GetLocalizedFromGMKey(177),tFontArial,0);
  224.         SetComponentPosition(oPageAdmin.m_cUsers, iPosX, 40);
  225.         SetTextButtonStateFunc(oPageAdmin.m_cUsers,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
  226.         ResizeComponent(oPageAdmin.m_cUsers);
  227.         iPosX = iPosX + GetComponentWidth(oPageAdmin.m_cUsers) + 5;
  228.  
  229.         oPageAdmin.iUsersID = InitObject("users",Object_Users_Create ,Object_Users_Event);
  230.         SetComponentPosition(oPageAdmin.iUsersID,60 ,90);
  231.         SetStackEvents(oPageAdmin.iUsersID,GUI_Destroy | GUI_Key | GUI_Enable | GUI_Disable);
  232.     }
  233.     else
  234.     {
  235.         oPageAdmin.m_cUsers = ID_NOT_CREATED;
  236.         oPageAdmin.iUsersID = ID_NOT_CREATED;
  237.     }
  238.  
  239.  
  240.     // Select admin onglet by default
  241.     SetTextRadioButtonCheckBox(oPageAdmin.m_cAdmin,1);
  242.  
  243.     if(oPageAdmin.iUsersID != ID_NOT_CREATED)
  244.     {
  245.         SetComponentVisibleStatus(oPageAdmin.iUsersID,false);
  246.     }
  247.     else
  248.     {
  249.         // Hide administration button
  250.         SetComponentVisibleStatus(oPageAdmin.m_cAdmin,false);
  251.     }
  252.  
  253.     DisplayMenuPrincipal();
  254.     SetObjectSize(700,525);
  255. }
  256.  
  257. //----------------------------------------------------------------------------------------------------------------//
  258. //----------------------------------------------------------------------------------------------------------------//
  259. //PageAdmin Window Event func
  260. //----------------------------------------------------------------------------------------------------------------//
  261. //----------------------------------------------------------------------------------------------------------------//
  262. func i32x PageAdmin_Event (i32x _iComponentID,i32x _iEvent)
  263. {
  264.     if(_iEvent == GUI_RADIOBUTTON_CHANGED)
  265.     {
  266.         PlaySound(0,sbClickSound[0]);
  267.  
  268.         if(oPageAdmin.m_cUsers != ID_NOT_CREATED)
  269.         {
  270.             if(_iComponentID == oPageAdmin.m_cUsers)
  271.             {
  272.                 // UnSelect calendar onglet
  273.                 SetTextRadioButtonCheckBox(oPageAdmin.m_cAdmin,0);
  274.                 // Show users
  275.                 SetComponentVisibleStatus(oPageAdmin.iUsersID,1);
  276.                 // Hide admin
  277.                 SetComponentVisibleStatus(oPageAdmin.iAdminID,0);
  278.             }
  279.         }
  280.         if(_iComponentID == oPageAdmin.m_cAdmin)
  281.         {
  282.             // UnSelect calendar onglet
  283.             if(oPageAdmin.m_cUsers != ID_NOT_CREATED)
  284.                 SetTextRadioButtonCheckBox(oPageAdmin.m_cUsers,0);
  285.             // Hide users
  286.             if(oPageAdmin.iUsersID != ID_NOT_CREATED)
  287.                 SetComponentVisibleStatus(oPageAdmin.iUsersID,0);
  288.             // Show admin
  289.             SetComponentVisibleStatus(oPageAdmin.iAdminID,1);
  290.         }
  291.     }
  292.     if(_iComponentID == -1)
  293.     {
  294.         if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
  295.         {
  296.             oPageAdmin.iWindowID = ID_NOT_CREATED;
  297.             oPageAdmin.pthis = g_poNullComponent;
  298.             oPageAdmin.m_cClose = ID_NOT_CREATED;
  299.             oPageAdmin.m_cBackground = ID_NOT_CREATED;
  300.             oPageAdmin.iAdminID = ID_NOT_CREATED;
  301.         }
  302.     }
  303.     
  304.     return 1;
  305. }
  306.  
  307. func void vAdminConfigUpdate()
  308. {
  309.     Update_Next_Phase();
  310. }
  311.  
  312.  
  313. func void FillAdminDialbox()
  314. {
  315.     if(oPageAdmin.iWindowID != ID_NOT_CREATED)
  316.     {
  317.         if(oPageAdmin.iUsersID != ID_NOT_CREATED)
  318.             vFillUsersList();
  319.         vAdminConfigUpdate();
  320.     }
  321. }
  322.  
  323. //----------------------------------------------------------------------------------------------------------------//
  324. //----------------------------------------------------------------------------------------------------------------//
  325. //Constructor
  326. //----------------------------------------------------------------------------------------------------------------//
  327. //----------------------------------------------------------------------------------------------------------------//
  328. func i32x PageAdmin_Constructor ()
  329. {
  330.     // create page
  331.     oPageAdmin.iWindowID = InitObject("PageAdmin",oPageAdmin.oFunc.pcreate,oPageAdmin.oFunc.pevent);
  332.     SetStackEvents(oPageAdmin.iWindowID,GUI_Mouse|GUI_Key|GUI_Destroy);
  333.  
  334.     // Direct fill dialbox
  335.     FillAdminDialbox();
  336.  
  337.     //special looprun
  338.     if(G_iLoopRunVersion)
  339.     {
  340.         G_iLoopRunNumLoopMenu = 0;
  341.     }
  342.  
  343.     return oPageAdmin.iWindowID;
  344. }
  345.  
  346. //----------------------------------------------------------------------------------------------------------------//
  347. //----------------------------------------------------------------------------------------------------------------//
  348. //Destructor
  349. //----------------------------------------------------------------------------------------------------------------//
  350. //----------------------------------------------------------------------------------------------------------------//
  351. func void PageAdmin_Destructor ()
  352. {
  353.     // delete page
  354.     print("\noPageAdmin.iWindowID = ");println(itoa(oPageAdmin.iWindowID));
  355.     DeleteComponent(oPageAdmin.iWindowID);
  356.     oPageAdmin.iWindowID=ID_NOT_CREATED;
  357. }
  358.  
  359. //----------------------------------------------------------------------------------------------------------------//
  360. //----------------------------------------------------------------------------------------------------------------//
  361. //PageAdmin Window Init member
  362. //----------------------------------------------------------------------------------------------------------------//
  363. //----------------------------------------------------------------------------------------------------------------//
  364.  
  365. func void PageAdmin_InitMembers ()
  366. {
  367.     oPageAdmin.oFunc.pcreate    = PageAdmin_Create;
  368.     oPageAdmin.oFunc.pevent    = PageAdmin_Event;
  369. }
  370.  
  371.  
  372. //page admin update next phase info
  373. func void Update_Next_Phase()
  374. {
  375.     var component pold;
  376.     
  377.     if (oPageAdmin.iWindowID !=ID_NOT_CREATED && oPageAdmin.iWindowID!=0)
  378.     {
  379.         if(oObjectAdmin.pthis)
  380.         {
  381.             // Get current context
  382.             pold=GetParserComponent();
  383.  
  384.             // Set Admin onglet context
  385.             SetParserComponent(oObjectAdmin.pthis);
  386.  
  387.             if (g_oGameConfig.m_iPhaseID == G_iPhase_InRace)
  388.             {
  389.                 SetContainerText(oObjectAdmin.m_cInfoPhase,GetLocalizedFromGMKey(168));
  390.                 SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
  391.                 SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
  392.             }
  393.             else if (g_oGameConfig.m_iPhaseID == G_iPhase_PreRace)
  394.             {
  395.                 SetContainerText(oObjectAdmin.m_cInfoPhase,GetLocalizedFromGMKey(167));
  396.             }
  397.             else
  398.             {
  399.                 SetContainerText(oObjectAdmin.m_cInfoPhase,GetLocalizedFromGMKey(166));
  400.                 if(g_oGameConfig.m_iGameOver == 1)
  401.                 {
  402.                     SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
  403.                     SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
  404.                     SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
  405.                 }
  406.                 else
  407.                 {
  408.                     if(g_oUser.m_iUserMode == G_iGuestUser)
  409.                     {
  410.                         SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
  411.                         SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
  412.                         SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
  413.                     }
  414.                     else
  415.                     {
  416.                         if(g_oGameConfig.m_iReady)
  417.                         {
  418.                             SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,true);
  419.                             SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,false);
  420.                         }
  421.                         else
  422.                         {
  423.                             SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
  424.                             SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,false);
  425.                         }
  426.                     }
  427.                 }
  428.             }
  429.             ResizeComponent(oObjectAdmin.m_cInfoPhase);
  430.             SetComponentPositionX(oObjectAdmin.m_cInfoPhase,600 - GetComponentWidth(oObjectAdmin.m_cInfoPhase));
  431.  
  432.             // Delete profil
  433.             if(oObjectAdmin.m_cProfil != ID_NOT_CREATED)
  434.             {
  435.                 DeleteComponent(oObjectAdmin.m_cProfil);
  436.                 oObjectAdmin.m_cProfil = ID_NOT_CREATED;
  437.             }
  438.             
  439.             SetContainerText(oObjectAdmin.m_cRaceName,GetLocalizedFromKey(Join_GetIntFromKey(g_oLocalJoins.m_iRace_iNameId,g_oGameConfig.m_iCurrentRaceID)));
  440.             // Reinit profil
  441.             Panel_Team_Tactic_Profil_InitMembers(g_oGameConfig.m_iCurrentStageID,1,1,600,100,10,150);
  442.             oObjectAdmin.m_cProfil=InitObject(oPanel_Team_Tactic_Profil.szName, oPanel_Team_Tactic_Profil.oFunc.pcreate, oPanel_Team_Tactic_Profil.oFunc.pevent);
  443.             SetStackEvents(oObjectAdmin.m_cProfil,GUI_Destroy | GUI_Char|GUI_KeyDown);
  444.  
  445.             // Update game password
  446.             // SetContainerText(oObjectAdmin.m_cPassword,g_oGameConfig.m_szGamePassword);
  447.  
  448.             // Restore old context
  449.             SetParserComponent(pold);
  450.         }
  451.     }
  452. }
  453.