home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / team / roster / page_team_roster.cnc < prev    next >
Text File  |  2001-07-09  |  47KB  |  1,253 lines

  1. //----------------------------------------------------------------------------------------------------------------//
  2. //----------------------------------------------------------------------------------------------------------------//
  3. // return true if roster can be edited
  4. //----------------------------------------------------------------------------------------------------------------//
  5. //----------------------------------------------------------------------------------------------------------------//
  6. func i32x bRoster_CanBeEdited()
  7. {
  8.     var i32x bTest;
  9.  
  10.     bTest = true;
  11.     if(oObject_TeamListbox.m_iSelectedTeamID != g_oUser.m_iMyTeamID)
  12.         bTest = false;
  13.     if(g_oGameConfig.m_iPhaseID != G_iPhase_Management)
  14.         bTest = false;
  15.     if(g_oGameConfig.m_iGameMode != GAME_MODE_STAGE)
  16.     {
  17.         if(Page_Team_Roster_GetCurrentStageNumber() != 1)
  18.             bTest = false;
  19.     }
  20.  
  21.     return bTest;
  22. }
  23.  
  24. //----------------------------------------------------------------------------------------------------------------//
  25. //----------------------------------------------------------------------------------------------------------------//
  26. // Refresh racing team panel
  27. //----------------------------------------------------------------------------------------------------------------//
  28. //----------------------------------------------------------------------------------------------------------------//
  29. func void DisplayPull ()
  30. {
  31.     var component pOldParserComponent;
  32.  
  33.     // Get Current Context
  34.     pOldParserComponent=GetParserComponent();
  35.  
  36.     // Set page Roaster context
  37.     SetParserComponent(oPage_Team_Roaster.pComponent);
  38.  
  39.     // MistER-j test
  40.     PushEventOnChild(oPage_Team_Roaster.iPanelRacingTeamID,GUI_COMPONENT_REFRESH);
  41.  
  42.     // show add & remove buttons if we are displaying our team
  43.     if (bRoster_CanBeEdited())
  44.     {
  45.         SetComponentEnableStatus(oPage_Team_Roaster.iSelectID,true);
  46.         SetComponentEnableStatus(oPage_Team_Roaster.iRemoveID,true);
  47.     }
  48.     else
  49.     {
  50.         SetComponentEnableStatus(oPage_Team_Roaster.iSelectID,false);
  51.         SetComponentEnableStatus(oPage_Team_Roaster.iRemoveID,false);
  52.     }
  53.  
  54.     // restore old parser component
  55.     SetParserComponent(pOldParserComponent);
  56. }
  57.  
  58. //----------------------------------------------------------------------------------------------------------------//
  59. //----------------------------------------------------------------------------------------------------------------//
  60. // Add a cyclist in the racing team (check if cyclist is already present...)
  61. //----------------------------------------------------------------------------------------------------------------//
  62. //----------------------------------------------------------------------------------------------------------------//
  63. func void Page_Team_Roster_AddPullCyclist (i32x _iCyclistID)
  64. {
  65.     var i32x iLoop,iFreeSlot;
  66.     var boolx bTest;
  67.  
  68.     if (bRoster_CanBeEdited())
  69.     {
  70.         iFreeSlot = -1;
  71.         bTest = true;
  72.  
  73.         iLoop = 8;
  74.         while (iLoop>=0)
  75.         {
  76.             if (oPage_Team_Roaster.iCyclistsPull[iLoop]==_iCyclistID)
  77.                 bTest = false;
  78.             if(oPage_Team_Roaster.iCyclistsPull[iLoop] == -1)
  79.             {
  80.                 // Found free slot
  81.                 iFreeSlot = iLoop;
  82.             }
  83.             iLoop=iLoop-1;
  84.         }
  85.         if((bTest)&&(iFreeSlot>=0))
  86.         {
  87.             oPage_Team_Roaster.iCyclistsPull[iFreeSlot] = _iCyclistID;
  88.             oPage_Team_Roaster.iNbCyclistsInPull = oPage_Team_Roaster.iNbCyclistsInPull + 1;
  89.  
  90.             // Update pull display
  91.             DisplayPull();
  92.         }
  93.     }
  94. }
  95.  
  96. //----------------------------------------------------------------------------------------------------------------//
  97. //----------------------------------------------------------------------------------------------------------------//
  98. // Remove a cyclist from the racing team and defrag the pull
  99. //----------------------------------------------------------------------------------------------------------------//
  100. //----------------------------------------------------------------------------------------------------------------//
  101. func void Page_Team_Roster_RemovePullCyclist (i32x _iCyclistID)
  102. {
  103.     // defrag the pull
  104.     var i32x iLoop,iNextCyclistID,iSlot;
  105.  
  106.  
  107.     if (bRoster_CanBeEdited())
  108.     {
  109.         // Find the slot to free
  110.         iSlot = -1;
  111.         iLoop = 0;
  112.         while (iLoop < 9)
  113.         {
  114.             if(oPage_Team_Roaster.iCyclistsPull[iLoop] == _iCyclistID)
  115.             {
  116.                 // Remove this cyclist
  117.                 iSlot = iLoop;
  118.                 oPage_Team_Roaster.iCyclistsPull[iLoop] = -1;
  119.  
  120.                 // set new nb cyclists in pull
  121.                 oPage_Team_Roaster.iNbCyclistsInPull = oPage_Team_Roaster.iNbCyclistsInPull - 1;
  122.  
  123.                 // break loop
  124.                 iLoop = 8;
  125.             }
  126.             iLoop=iLoop+1;
  127.         }
  128.  
  129.         if(iSlot>=0)
  130.         {
  131.             // Defrag the pull
  132.             iLoop = iSlot;
  133.             while (iLoop < 9)
  134.             {
  135.                 if(iLoop < 8)
  136.                     iNextCyclistID = oPage_Team_Roaster.iCyclistsPull[iLoop+1];
  137.                 else
  138.                     iNextCyclistID = -1;
  139.  
  140.                 oPage_Team_Roaster.iCyclistsPull[iLoop] = iNextCyclistID;
  141.                 iLoop=iLoop+1;
  142.             }
  143.  
  144.             // Update display
  145.             DisplayPull();
  146.         }
  147.     }
  148. }
  149.  
  150. //----------------------------------------------------------------------------------------------------------------//
  151. //----------------------------------------------------------------------------------------------------------------//
  152. //
  153. //----------------------------------------------------------------------------------------------------------------//
  154. //----------------------------------------------------------------------------------------------------------------//
  155. func void Page_Team_Roaster_SaveRacingTeam ()
  156. {
  157.     if ((g_oUser.m_iUserMode!=G_iGuestUser)&&
  158.         (g_oGameConfig.m_iPhaseID==G_iPhase_Management)&&
  159.         (    (Page_Team_Roster_GetCurrentStageNumber()==1)||
  160.             (g_oGameConfig.m_iGameMode == GAME_MODE_STAGE) ) )
  161.     {    
  162.         // get our team id
  163.         var i32x iCyclistIndex,i,iNumRegisters,iNumCyclists,iStartIndex;
  164.         var i32x iTeamID,iCyclistID,bRegistered,iFreeSlot;
  165.  
  166.         iTeamID=g_oUser.m_iMyTeamID;
  167.  
  168.         // Clear the Subset
  169.         DatabaseSubset_Clear(TEMP_DATABASE);
  170.  
  171.         // create query to fill the cyclist of team subset
  172.         Query_Create(0, TEMP_DATABASE);
  173.         Query_SetNumJoinTables(    0, 1);
  174.         Query_SelectJoinTable(    0, 0, "DYN_cyclist");
  175.  
  176.         Query_SelectWhereIntEqual(0, "DYN_cyclist.fkIDteam", iTeamID);
  177.         Query_Execute(0);
  178.  
  179.         // Check each slot to have nine cyclists in roster
  180.         iNumCyclists = Join_GetNumRows(oPage_Team_Roaster.m_jCyclistID);
  181.         iNumRegisters = 0;
  182.         iCyclistIndex=0;
  183.         while(iCyclistIndex<9)
  184.         {
  185.             if(oPage_Team_Roaster.iCyclistsPull[iCyclistIndex] <= 0)
  186.             {
  187.                 // Free slot : register cyclist
  188.                 iNumRegisters = iNumRegisters + 1;
  189.  
  190.  
  191.             }
  192.             iCyclistIndex=iCyclistIndex+1;
  193.         }
  194.         //print("NumRegiter :");println(itoa(iNumRegisters));
  195.         // Register cyclist
  196.         i=0;
  197.         while((iNumRegisters>0)&&(i<iNumCyclists))
  198.         {
  199.             iCyclistID = Join_GetIntFromIndex(oPage_Team_Roaster.m_jCyclistID,i);
  200.  
  201.             // Check if cyclist already registered
  202.             bRegistered = false;
  203.             iCyclistIndex = 0;
  204.             iFreeSlot = -1;
  205.             while(iCyclistIndex<9)
  206.             {
  207.                 if(oPage_Team_Roaster.iCyclistsPull[iCyclistIndex] == iCyclistID)
  208.                     bRegistered = true;
  209.                 else if(oPage_Team_Roaster.iCyclistsPull[iCyclistIndex] <= 0)
  210.                     iFreeSlot = iCyclistIndex;
  211.                 iCyclistIndex=iCyclistIndex+1;
  212.             }
  213.  
  214.             if(bRegistered == false)
  215.             {
  216.                 if(iFreeSlot>=0)
  217.                 {
  218.                     //print("RegisterCyclist :");println(itoa(iCyclistID));
  219.                     // Register it
  220.                     oPage_Team_Roaster.iCyclistsPull[iFreeSlot] = iCyclistID;
  221.                 }
  222.                 iNumRegisters = iNumRegisters - 1;
  223.             }
  224.             i=i+1;
  225.         }
  226.  
  227.         
  228.         // update local database
  229.         iCyclistIndex=0;
  230.         while(iCyclistIndex<9)
  231.         {
  232.             Join_SetIntFromKey(oPage_Team_Roaster.m_jRacingCyclist[iCyclistIndex],iTeamID,oPage_Team_Roaster.iCyclistsPull[iCyclistIndex]);
  233.             iCyclistIndex=iCyclistIndex+1;
  234.         }
  235.         
  236.         // send update to server
  237.         g_oMenuServer.m_oServer << mSetRacingTeam(
  238.             oPage_Team_Roaster.iCyclistsPull[0],
  239.             oPage_Team_Roaster.iCyclistsPull[1],
  240.             oPage_Team_Roaster.iCyclistsPull[2],
  241.             oPage_Team_Roaster.iCyclistsPull[3],
  242.             oPage_Team_Roaster.iCyclistsPull[4],
  243.             oPage_Team_Roaster.iCyclistsPull[5],
  244.             oPage_Team_Roaster.iCyclistsPull[6],
  245.             oPage_Team_Roaster.iCyclistsPull[7],
  246.             oPage_Team_Roaster.iCyclistsPull[8]
  247.         );
  248.     }
  249. }
  250.  
  251. //----------------------------------------------------------------------------------------------------------------//
  252. //----------------------------------------------------------------------------------------------------------------//
  253. // Page Team Roster Destructor
  254. //----------------------------------------------------------------------------------------------------------------//
  255. //----------------------------------------------------------------------------------------------------------------//
  256. func void Page_Team_Roaster_Destructor ()
  257. {
  258.     Reset_Tool_Bar_Text();
  259.  
  260.     if(oPage_Team_Roaster.bDataReceived)
  261.     {
  262.         // save current team if needed
  263.         if(oObject_TeamListbox.m_iSelectedTeamID==g_oUser.m_iMyTeamID)
  264.         {
  265.             // keep current parser component
  266.             var component pComponent;
  267.             pComponent=GetParserComponent();
  268.             // call save func in Page_Team_Roaster context
  269.             SetParserComponent(oPage_Team_Roaster.pComponent);
  270.             // save current racing team
  271.             Page_Team_Roaster_SaveRacingTeam();
  272.             // restore old parser component
  273.             SetParserComponent(pComponent);
  274.         }
  275.     }
  276.     // Destroy page global join
  277.     vPage_Team_Roaster_DestroyJoins();
  278.     // delete the page
  279.     DeleteComponent(oPage_Team_Roaster.iWindowID);
  280. }
  281.  
  282. // Destroy page global join
  283. //----------------------------------------------------------------------------------------------------------------//
  284. func void vPage_Team_Roaster_DestroyJoins()
  285. {
  286.     var i32x i;
  287.     if(oPage_Team_Roaster.m_jCyclistID != 0)
  288.     {
  289.         Join_Destructor(oPage_Team_Roaster.m_jCyclistID);
  290.         oPage_Team_Roaster.m_jCyclistID = 0;
  291.     }
  292.     if(oPage_Team_Roaster.m_jCyclistFirstName != 0)
  293.     {
  294.         Join_Destructor(oPage_Team_Roaster.m_jCyclistFirstName);
  295.         oPage_Team_Roaster.m_jCyclistFirstName = 0;
  296.     }
  297.     if(oPage_Team_Roaster.m_jCyclistLastName != 0)
  298.     {
  299.         Join_Destructor(oPage_Team_Roaster.m_jCyclistLastName);
  300.         oPage_Team_Roaster.m_jCyclistLastName = 0;
  301.     }
  302.     if(oPage_Team_Roaster.m_jCyclistAge != 0)
  303.     {
  304.         Join_Destructor(oPage_Team_Roaster.m_jCyclistAge);
  305.         oPage_Team_Roaster.m_jCyclistAge = 0;
  306.     }
  307.     if(oPage_Team_Roaster.m_jCyclistRiding != 0)
  308.     {
  309.         Join_Destructor(oPage_Team_Roaster.m_jCyclistRiding);
  310.         oPage_Team_Roaster.m_jCyclistRiding = 0;
  311.     }
  312.     if(oPage_Team_Roaster.m_jCyclistClimbing != 0)
  313.     {
  314.         Join_Destructor(oPage_Team_Roaster.m_jCyclistClimbing);
  315.         oPage_Team_Roaster.m_jCyclistClimbing = 0;
  316.     }
  317.     if(oPage_Team_Roaster.m_jCyclistDownhill != 0)
  318.     {
  319.         Join_Destructor(oPage_Team_Roaster.m_jCyclistDownhill);
  320.         oPage_Team_Roaster.m_jCyclistDownhill = 0;
  321.     }
  322.     if(oPage_Team_Roaster.m_jCyclistSprint != 0)
  323.     {
  324.         Join_Destructor(oPage_Team_Roaster.m_jCyclistSprint);
  325.         oPage_Team_Roaster.m_jCyclistSprint = 0;
  326.     }
  327.     if(oPage_Team_Roaster.m_jCyclistEndurance != 0)
  328.     {
  329.         Join_Destructor(oPage_Team_Roaster.m_jCyclistEndurance);
  330.         oPage_Team_Roaster.m_jCyclistEndurance = 0;
  331.     }
  332.     if(oPage_Team_Roaster.m_jCyclistRecuperation != 0)
  333.     {
  334.         Join_Destructor(oPage_Team_Roaster.m_jCyclistRecuperation);
  335.         oPage_Team_Roaster.m_jCyclistRecuperation = 0;
  336.     }
  337.     if(oPage_Team_Roaster.m_jCyclistAcceleration != 0)
  338.     {
  339.         Join_Destructor(oPage_Team_Roaster.m_jCyclistAcceleration);
  340.         oPage_Team_Roaster.m_jCyclistAcceleration = 0;
  341.     }
  342.     if(oPage_Team_Roaster.m_jCyclistAgility != 0)
  343.     {
  344.         Join_Destructor(oPage_Team_Roaster.m_jCyclistAgility);
  345.         oPage_Team_Roaster.m_jCyclistAgility = 0;
  346.     }
  347.     if(oPage_Team_Roaster.m_jCyclistIntelligence != 0)
  348.     {
  349.         Join_Destructor(oPage_Team_Roaster.m_jCyclistIntelligence);
  350.         oPage_Team_Roaster.m_jCyclistIntelligence = 0;
  351.     }
  352.     if(oPage_Team_Roaster.m_jCyclistDiscipline != 0)
  353.     {
  354.         Join_Destructor(oPage_Team_Roaster.m_jCyclistDiscipline);
  355.         oPage_Team_Roaster.m_jCyclistDiscipline = 0;
  356.     }
  357.     if(oPage_Team_Roaster.m_jCyclistFitness != 0)
  358.     {
  359.         Join_Destructor(oPage_Team_Roaster.m_jCyclistFitness);
  360.         oPage_Team_Roaster.m_jCyclistFitness = 0;
  361.     }
  362.     if(oPage_Team_Roaster.m_jCyclistRating != 0)
  363.     {
  364.         Join_Destructor(oPage_Team_Roaster.m_jCyclistRating);
  365.         oPage_Team_Roaster.m_jCyclistRating = 0;
  366.     }
  367.     // Delete old racing team join if exist (should not :) )
  368.     i=0;
  369.     while(i<9)
  370.     {
  371.         if(oPage_Team_Roaster.m_jRacingCyclist[i] != 0)
  372.         {
  373.             Join_Destructor(oPage_Team_Roaster.m_jRacingCyclist[i]);
  374.             oPage_Team_Roaster.m_jRacingCyclist[i] = 0;
  375.         }
  376.         i=i+1;
  377.     }
  378. }
  379. func szx szGetColumnNameFromIndex(i32x _iColumnIndex)
  380. {
  381.     var szx szColumnName;
  382.  
  383.     // Select sorted column
  384.     szColumnName="gene_sz_lastname"; // Name by default
  385.     //    if (oPage_Team_Roaster.iSortedComponent==oPage_Team_Roaster.iColumnTitleID[0])
  386.     //        szColumnName="gene_sz_name";
  387.     if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[1])
  388.         szColumnName="gene_i_age";
  389.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[2])
  390.         szColumnName="gene_i_rating";
  391.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[3])
  392.         szColumnName="carac_f_riding";
  393.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[4])
  394.         szColumnName="carac_f_climbing";
  395.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[5])
  396.         szColumnName="carac_f_downhill";
  397.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[6])
  398.         szColumnName="carac_f_sprint";
  399.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[7])
  400.         szColumnName="carac_f_endurance";
  401.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[8])
  402.         szColumnName="carac_f_recuperation";
  403.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[9])
  404.         szColumnName="carac_f_acceleration";
  405.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[10])
  406.         szColumnName="carac_f_agility";
  407.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[11])
  408.         szColumnName="carac_f_intelligence";
  409.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[12])
  410.         szColumnName="carac_f_discipline";
  411.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[13])
  412.         szColumnName="fkIDgame_menu_fitness";
  413.  
  414.     return szColumnName;
  415. }
  416.  
  417. func szx szGetLocalizedCaracNameFromIndex(i32x _iColumnIndex)
  418. {
  419.     var szx szColumnName;
  420.  
  421.     if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[0])
  422.         szColumnName = GetLocalizedFromGMKey(65); // name
  423.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[1])
  424.         szColumnName = GetLocalizedFromGMKey(31); // age
  425.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[2])
  426.         szColumnName = GetLocalizedFromGMKey(33); //rating
  427.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[3])
  428.         szColumnName = GetLocalizedFromGMKey(98); // riding
  429.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[4])
  430.         szColumnName = GetLocalizedFromGMKey(99); // climbing
  431.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[5])
  432.         szColumnName=GetLocalizedFromGMKey(100); // downhill
  433.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[6])
  434.         szColumnName = GetLocalizedFromGMKey(101); // sprint
  435.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[7])
  436.         szColumnName = GetLocalizedFromGMKey(102); // endurance
  437.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[8])
  438.         szColumnName = GetLocalizedFromGMKey(104); // recup
  439.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[9])
  440.         szColumnName = GetLocalizedFromGMKey(106); // acceleration
  441.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[10])
  442.         szColumnName = GetLocalizedFromGMKey(105); // agility
  443.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[11])
  444.         szColumnName = GetLocalizedFromGMKey(103); // intelligence
  445.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[12])
  446.         szColumnName = GetLocalizedFromGMKey(107); // discipline 
  447.     else if (_iColumnIndex==oPage_Team_Roaster.iColumnTitleID[13])
  448.         szColumnName = GetLocalizedFromGMKey(127); // fitness
  449.  
  450.     return szColumnName;
  451. }
  452. func void vUpdateRoasterSubset()
  453. {
  454.     // Clear the Subset
  455.     DatabaseSubset_Clear(TEMP_DATABASE);
  456.  
  457.     // create query to fill the cyclist of team subset
  458.     Query_Create(0, TEMP_DATABASE);
  459.     Query_SetNumJoinTables(    0, 1);
  460.     Query_SelectJoinTable(    0, 0, "DYN_cyclist");
  461.  
  462.     Query_SelectWhereIntEqual(0, "DYN_cyclist.fkIDteam", oObject_TeamListbox.m_iSelectedTeamID);
  463.     Query_Execute(0);
  464.  
  465.     // Sort subset
  466.     vSortRoasterSubset();
  467. }
  468.  
  469. func void vSortRoasterSubset()
  470. {
  471.     Table_Sort(TEMP_DATABASE,"DYN_cyclist",szGetColumnNameFromIndex(oPage_Team_Roaster.iSortedComponent),oPage_Team_Roaster.iSortDirection);
  472. }
  473.  
  474. //----------------------------------------------------------------------------------------------------------------//
  475. //----------------------------------------------------------------------------------------------------------------//
  476. // Page Team Roster Create
  477. //----------------------------------------------------------------------------------------------------------------//
  478. //----------------------------------------------------------------------------------------------------------------//
  479. func void Page_Team_Roaster_Create ()
  480. {
  481.     oPage_Team_Roaster.pThis = GetParserComponent();
  482.     
  483.     oPage_Team_Roaster.bDataReceived = false;
  484.     oPage_Team_Roaster.iCurrentStageNumber = Page_Team_Roster_GetCurrentStageNumber();
  485.  
  486.  
  487.     // MistER-j antibug
  488.     oPage_Team_Roaster.iSelectedDivisionID = 1;
  489.  
  490.     var i32x iLoop;
  491.     var i32x iID;
  492.  
  493.     // *** Update Title Bar ***
  494.     Set_Title_Bar_Text(GetLocalizedFromGMKey(151)); // page title
  495.  
  496.     // init pull
  497.     iLoop = 0;
  498.     while (iLoop<9)
  499.     {
  500.         oPage_Team_Roaster.iCyclistsPull[iLoop] = -1;
  501.         iLoop=iLoop+1;
  502.     }
  503.     oPage_Team_Roaster.iNbCyclistsInPull=0;
  504.     
  505.     // Get Page context
  506.     oPage_Team_Roaster.pComponent=GetParserComponent();
  507.  
  508.     // list component not initialized
  509.     oPage_Team_Roaster.iCyclistListID = ID_NOT_CREATED;
  510.  
  511.  
  512.     // Page component number
  513.     SetComponentNumber(65);
  514.  
  515.  
  516.     // Init page global join
  517.     vPage_Team_Roaster_DestroyJoins();
  518.  
  519.     // Page Background
  520.     iID = Init_LibObject_FilledCadre(tCadreDialbox,700,550);
  521.     SetEvents(iID,0);
  522.  
  523.     // Guest or registered user ?
  524.     Table_Sort(QUERY_GLOBAL_TEAMS,"DYN_team","gene_sz_name",1);
  525.     if(g_oUser.m_iUserMode == G_iRegisteredUser)
  526.     {
  527.         // first display current team
  528.         oObject_TeamListbox.m_iSelectedTeamID = g_oUser.m_iMyTeamID;
  529.         oPage_Team_Roaster.m_cSubscribe = ID_NOT_CREATED;
  530.  
  531.         // Don't Create unsubscribe button
  532.         oPage_Team_Roaster.m_cUnsubscribe = ID_NOT_CREATED;
  533.         //oPage_Team_Roaster.m_cUnsubscribe = InitLibMultiSpriteButtonWithText(tButton32Multi,5,GetLocalizedFromGMKey(158),tFontArial,1274);
  534.         //SetComponentPosition(oPage_Team_Roaster.m_cUnsubscribe,350,35);
  535.     }
  536.     else if(g_oUser.m_iUserMode == G_iGuestUser)
  537.     {
  538.         // Guest user
  539.         // Display the first team g_oMenuJoins
  540.         oObject_TeamListbox.m_iSelectedTeamID = Join_GetIntFromSortedIndex(g_oMenuJoins.m_iTeamID,0);
  541.         oPage_Team_Roaster.m_cSubscribe = InitLibMultiSpriteButtonWithText(tButton32Multi,5,GetLocalizedFromGMKey(156),tFontArial,1273);
  542.         oPage_Team_Roaster.m_cUnsubscribe = ID_NOT_CREATED;
  543.         // Hide this button by default
  544.         SetComponentVisibleStatus(oPage_Team_Roaster.m_cSubscribe,0);
  545.         SetComponentPosition(oPage_Team_Roaster.m_cSubscribe,350,35);
  546.     }
  547.  
  548.     // panel racing team
  549.     Panel_Team_Roster_RacingTeam_InitMembers();
  550.     iID = InitObject(
  551.         oPanel_Team_Roster_RacingTeam.szName,
  552.         oPanel_Team_Roster_RacingTeam.oFunc.pcreate,
  553.         oPanel_Team_Roster_RacingTeam.oFunc.pevent
  554.     );
  555.     SetComponentPosition(iID,10,75);
  556.     oPage_Team_Roaster.iPanelRacingTeamID = iID;
  557.  
  558. //    Page_Team_Roster_Create_List();
  559.  
  560.     // buttons to edit pull
  561.     oPage_Team_Roaster.iSelectID = InitButton(tButtonUpRoaster);
  562.     SetContainerStateFunc(oPage_Team_Roaster.iSelectID, ButtonState);
  563.     SetComponentPosition(oPage_Team_Roaster.iSelectID,625-(2*GetComponentWidth(oPage_Team_Roaster.iSelectID)),35);
  564.  
  565.     oPage_Team_Roaster.iRemoveID = InitButton(tButtonDownRoaster);
  566.     SetContainerStateFunc(oPage_Team_Roaster.iRemoveID, ButtonState);
  567.     SetComponentPosition(oPage_Team_Roaster.iRemoveID,635-GetComponentWidth(oPage_Team_Roaster.iRemoveID),35);
  568.  
  569.     // display team list box
  570.     Object_Roster_Team_Listbox_InitMembers(QUERY_GLOBAL_TEAMS);
  571.     oPage_Team_Roaster.m_cTeamListBox = InitObject(
  572.         oObject_TeamListbox.m_szName,        // Object name
  573.         oObject_TeamListbox.oFunc.pcreate,    // Object create func
  574.         oObject_TeamListbox.oFunc.pevent);    // Object event func
  575.     SetComponentPosition(oPage_Team_Roaster.m_cTeamListBox,15,35);
  576.  
  577.     UpdateSubscribe();
  578.  
  579.     AutoResize();
  580. }
  581.  
  582.  
  583. func void Page_Team_Roster_Create_List()
  584. {
  585.     var component pComponent;
  586.     pComponent = GetParserComponent();
  587.     SetParserComponent(oPage_Team_Roaster.pThis);
  588.     
  589.     var i32x iID, iLoop;
  590.  
  591.     // Create a subset to be filled by cyclists of team...
  592.     DatabaseSubset_Create( TEMP_DATABASE, QUERY_GLOBAL_CYCLISTS);
  593.     Database_AddTables(    TEMP_DATABASE, 1);
  594.     Table_SetName( TEMP_DATABASE, 0, "DYN_cyclist");
  595.     TableSubset_SelectColumns( TEMP_DATABASE, 0, "*");
  596.  
  597.     // Create page global join on this
  598.     oPage_Team_Roaster.m_jCyclistID                = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.IDcyclist");
  599.     oPage_Team_Roaster.m_jCyclistFirstName        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.gene_sz_firstname");
  600.     oPage_Team_Roaster.m_jCyclistLastName        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.gene_sz_lastname");
  601.     oPage_Team_Roaster.m_jCyclistAge            = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.gene_i_age");
  602.     oPage_Team_Roaster.m_jCyclistRiding            = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_riding");
  603.     oPage_Team_Roaster.m_jCyclistClimbing        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_climbing");
  604.     oPage_Team_Roaster.m_jCyclistDownhill        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_downhill");
  605.     oPage_Team_Roaster.m_jCyclistSprint            = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_sprint");
  606.     oPage_Team_Roaster.m_jCyclistEndurance        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_endurance");
  607.     oPage_Team_Roaster.m_jCyclistRecuperation    = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_recuperation");
  608.     oPage_Team_Roaster.m_jCyclistAcceleration    = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_acceleration");
  609.     oPage_Team_Roaster.m_jCyclistAgility        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_agility");
  610.     oPage_Team_Roaster.m_jCyclistIntelligence    = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_intelligence");
  611.     oPage_Team_Roaster.m_jCyclistDiscipline        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.carac_f_discipline");
  612.     oPage_Team_Roaster.m_jCyclistRating            = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.gene_i_rating");
  613.     oPage_Team_Roaster.m_jCyclistFitness        = Join_Constructor(TEMP_DATABASE,"DYN_cyclist.fkIDgame_menu_fitness");
  614.  
  615.     var i32x iLineHeight, iLinePosY;
  616.     iLineHeight = 293;
  617.     iLinePosY = 230;
  618.     {    // table init
  619.         
  620.         
  621.         // slider ruler
  622.         oPage_Team_Roaster.iTableBorderID[0] = InitContainer(tCommonTableBorder);
  623.         SetComponentPosition(oPage_Team_Roaster.iTableBorderID[0],654-16,iLinePosY+22);
  624.         SetContainerSize(oPage_Team_Roaster.iTableBorderID[0], 16, iLineHeight-22-16);
  625.  
  626.         oPage_Team_Roaster.iTableBorderID[1] = InitContainer(tCommonTableBorder);
  627.         SetComponentPosition(oPage_Team_Roaster.iTableBorderID[1],654-15,iLinePosY+21+3);
  628.         SetContainerSize(oPage_Team_Roaster.iTableBorderID[1],14, iLineHeight -21-16 - 3);
  629.         SetContainerColor(oPage_Team_Roaster.iTableBorderID[1],MakeARGB(255,30,40,100));
  630.     }
  631.  
  632.     // *** Cyclist List ***
  633.     oPage_Team_Roaster.iCyclistListID = InitList(
  634.             "Cyclist List",
  635.             40,
  636.             654,252,
  637.             Team_Roaster_List_Item_Create,
  638.             Team_Roaster_List_Item_Update,
  639.             Team_Roaster_List_Item_Event,
  640.             t_btn_slider_large,
  641.             ButtonState
  642.     );
  643.     SetComponentPosition(oPage_Team_Roaster.iCyclistListID,0,iLinePosY+22+3);
  644.  
  645.     // title background
  646.     iID=InitContainer(tCommonTableBorder);
  647.     SetContainerColor(iID,c_TitleList);
  648.  
  649.     SetContainerSize(iID,649,22);
  650.     SetComponentPosition(iID,5,iLinePosY);
  651.     SetEvents(iID,GUI_NoEvent);
  652.  
  653.     // horizontal lines
  654.     oPage_Team_Roaster.iTableBorderID[2] = InitContainer(tCommonTableBorder);
  655.     SetComponentPosition(oPage_Team_Roaster.iTableBorderID[2],5,iLinePosY);
  656.     SetContainerSize(oPage_Team_Roaster.iTableBorderID[2], 649, 2);
  657.  
  658.     oPage_Team_Roaster.iTableBorderID[3] = InitContainer(tCommonTableBorder);
  659.     SetComponentPosition(oPage_Team_Roaster.iTableBorderID[3],5,iLinePosY + 22);
  660.     SetContainerSize(oPage_Team_Roaster.iTableBorderID[3], 649, 2);
  661.  
  662.     oPage_Team_Roaster.iTableBorderID[4] = InitContainer(tCommonTableBorder);
  663.     SetComponentPosition(oPage_Team_Roaster.iTableBorderID[4],5,507);
  664.     SetContainerSize(oPage_Team_Roaster.iTableBorderID[4], 649, 2);
  665.  
  666.     iLoop = 0;
  667.     while (iLoop < 13)
  668.     {
  669.         iID = iLoop + 5;
  670.  
  671.         oPage_Team_Roaster.iTableBorderID[iID] = InitContainer(tCommonTableBorder);
  672.         SetComponentPosition(oPage_Team_Roaster.iTableBorderID[iID],iLoop * 30 + 190,iLinePosY);
  673.         SetContainerSize(oPage_Team_Roaster.iTableBorderID[iID], 1, iLineHeight - 16);
  674.  
  675.         iLoop = iLoop + 1;
  676.     }
  677.  
  678.     //** column titles
  679.     iLinePosY=iLinePosY+7;
  680.  
  681.     iLoop = 0;
  682.     while (iLoop < 14)
  683.     {
  684.         iID=InitButton(tFontArialItalique);
  685.  
  686.         oPage_Team_Roaster.iColumnTitleID[iLoop] = iID;
  687.  
  688.         iLoop = iLoop + 1;
  689.     }
  690.     // Set column name
  691.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[0],GetLocalizedFromGMKey(65)); // name
  692.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[1],GetLocalizedFromGMKey(66)); // age
  693.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[2],GetLocalizedFromGMKey(126)); // rating
  694.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[3],GetLocalizedFromGMKey(108));    // riding
  695.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[4],GetLocalizedFromGMKey(109)); // climbing
  696.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[5],GetLocalizedFromGMKey(110)); // downhill
  697.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[6],GetLocalizedFromGMKey(111)); // sprint
  698.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[7],GetLocalizedFromGMKey(112)); // endurance
  699.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[8],GetLocalizedFromGMKey(114)); // recuperation
  700.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[9],GetLocalizedFromGMKey(116)); // acceleration
  701.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[10],GetLocalizedFromGMKey(115)); // agility
  702.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[11],GetLocalizedFromGMKey(113)); // intelligence
  703.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[12],GetLocalizedFromGMKey(117)); // discipline
  704.     SetContainerText(oPage_Team_Roaster.iColumnTitleID[13],GetLocalizedFromGMKey(127)); // fitness
  705.     // Refresh component
  706.     var i32x iPosX=5;
  707.     iLoop = 0;
  708.     while (iLoop < 14)
  709.     {
  710.         SetContainerStateFunc(oPage_Team_Roaster.iColumnTitleID[iLoop],ColumnTextButtonState);
  711.         SetComponentPosition(oPage_Team_Roaster.iColumnTitleID[iLoop],iPosX,iLinePosY);
  712.         if(iLoop>=1)
  713.             iPosX = iPosX + 30;
  714.         else
  715.             iPosX = iPosX + 190;
  716.         ResizeComponent(oPage_Team_Roaster.iColumnTitleID[iLoop]);
  717.         iLoop = iLoop + 1;
  718.     }
  719.  
  720.     // sort init
  721.     oPage_Team_Roaster.iSortDirection = 1;
  722.     oPage_Team_Roaster.iSortedComponent = oPage_Team_Roaster.iColumnTitleID[0];
  723.  
  724.     SetParserComponent(pComponent);
  725. }
  726.  
  727.  
  728.  
  729.  
  730. //----------------------------------------------------------------------------------------------------------------//
  731. //----------------------------------------------------------------------------------------------------------------//
  732. // Page Team Roster Constructor
  733. //----------------------------------------------------------------------------------------------------------------//
  734. //----------------------------------------------------------------------------------------------------------------//
  735. func i32x Page_Team_Roaster_Constructor ()
  736. {
  737.     // create page
  738.     oPage_Team_Roaster.iWindowID = InitObject(oPage_Team_Roaster.szName, oPage_Team_Roaster.oFunc.pcreate, oPage_Team_Roaster.oFunc.pevent);
  739.  
  740.     // create waiting dialog    
  741.     CreateDialog(DIALOG_LOADING_DATA);
  742.     
  743.     // query databases
  744. // MistER-j WARNING LOCALIZED
  745.     Dialog_Loading_Data_SetText("Loading teams");
  746.     ResetQuery(QUERY_TEAMS_DIVISIONS);
  747.     GetQuery(g_oMenuServer.m_oServer,QUERY_TEAMS_DIVISIONS,"Query Teams Divisions",vPage_Team_Roaster_TeamsDivisionsOk,0);
  748.         
  749.     // reset for this query is done on phase change
  750.     ResetQuery(QUERY_CYCLISTS_FITNESS);
  751.     GetQuery(g_oMenuServer.m_oServer,QUERY_CYCLISTS_FITNESS,"Query Cyclists Fitness",vPage_Team_Roaster_CyclistsFitnessOK,0);
  752.     
  753.     ResetQuery(QUERY_RACING_CYCLISTS);
  754.     GetQuery(g_oMenuServer.m_oServer,QUERY_RACING_CYCLISTS,"Query Racing Cyclists",vPage_Team_Roaster_RacingTeamsOK,0);
  755.  
  756.     return oPage_Team_Roaster.iWindowID;
  757. }
  758.  
  759.  
  760. //----------------------------------------------------------------------------------------------------------------//
  761. //----------------------------------------------------------------------------------------------------------------//
  762. // Update Display of racing team
  763. //----------------------------------------------------------------------------------------------------------------//
  764. //----------------------------------------------------------------------------------------------------------------//
  765. func void UpdatePullDisplay ()
  766. {
  767.     var i32x i,iTeamID,iCyclistID,iPullIndex;
  768.  
  769.     // Get team id
  770.     iTeamID = oObject_TeamListbox.m_iSelectedTeamID;
  771.  
  772.     // Database are okay ?
  773.     if(oPage_Team_Roaster.m_jRacingCyclist[i] > 0)
  774.     {
  775.         iPullIndex=0;
  776.         i=0;
  777.         while(i<9)
  778.         {
  779.             iCyclistID = Join_GetIntFromKey(oPage_Team_Roaster.m_jRacingCyclist[i],iTeamID);
  780.  
  781.             if (iCyclistID > 0)
  782.             {
  783.                 oPage_Team_Roaster.iCyclistsPull[iPullIndex] = iCyclistID;
  784.                 iPullIndex=iPullIndex+1;
  785.             }
  786.             else
  787.                 oPage_Team_Roaster.iCyclistsPull[iPullIndex] = -1;
  788.  
  789.             i = i+1;
  790.         }
  791.         oPage_Team_Roaster.iNbCyclistsInPull=iPullIndex;
  792.  
  793.         // Hades : ???
  794.         if(iTeamID==g_oUser.m_iMyTeamID)
  795.             oPage_Team_Roaster.bDataReceived = true;
  796.  
  797.         // Display pull
  798.         DisplayPull();
  799.     }
  800. }
  801.  
  802. //----------------------------------------------------------------------------------------------------------------//
  803. //----------------------------------------------------------------------------------------------------------------//
  804. //
  805. //----------------------------------------------------------------------------------------------------------------//
  806. //----------------------------------------------------------------------------------------------------------------//
  807. func void UpdateListDisplay ()
  808. {
  809.     var component pOldParserComponent;
  810.     pOldParserComponent=GetParserComponent();
  811.     SetParserComponent(oPage_Team_Roaster.pComponent);
  812.  
  813.     // Fill The subset with new data
  814.     vUpdateRoasterSubset();
  815.  
  816.     // Sort roaster subset
  817.     vSortRoasterSubset();
  818.  
  819.     // Get Cyclist number in subset
  820.     var i32x iNumCyclists;
  821.  
  822.     if(oPage_Team_Roaster.m_jCyclistID != 0)
  823.     {
  824.         iNumCyclists = Join_GetNumRows(oPage_Team_Roaster.m_jCyclistID);
  825.     }
  826.     else
  827.     {
  828.         iNumCyclists = 0;
  829.     }
  830.  
  831.     // Update item number
  832.     SetListNbItems(oPage_Team_Roaster.iCyclistListID,iNumCyclists);
  833.  
  834.     // restore old parser component
  835.     SetParserComponent(pOldParserComponent);
  836. }
  837. //----------------------------------------------------------------------------------------------------------------//
  838. //----------------------------------------------------------------------------------------------------------------//
  839. //
  840. //----------------------------------------------------------------------------------------------------------------//
  841. //----------------------------------------------------------------------------------------------------------------//
  842. func void UpdateSubscribe()
  843. {
  844.     var i32x iTeamID;
  845.     // Selected team
  846.     iTeamID = oObject_TeamListbox.m_iSelectedTeamID;
  847.     if(g_oUser.m_iUserMode == G_iGuestUser)
  848.     {
  849.         // if Guest mode : display or hide subscribe button depend on team
  850.         if(Join_GetIntFromKey(g_oMenuJoins.m_iTeam_iUserID, iTeamID) != 0)
  851.         {
  852.             // Hide this button if team has already a human manager
  853.             SetComponentVisibleStatus(oPage_Team_Roaster.m_cSubscribe,0);
  854.         }
  855.         else
  856.         {
  857.             // Display subscribe button
  858.             SetComponentVisibleStatus(oPage_Team_Roaster.m_cSubscribe,1);
  859.         }
  860.     }
  861.     else
  862.     {
  863.         // registered user
  864.         // if Guest mode : display or hide subscribe button depend on team
  865.         if(iTeamID == g_oUser.m_iMyTeamID)
  866.         {
  867.             if(oPage_Team_Roaster.m_cUnsubscribe != ID_NOT_CREATED)
  868.             {
  869.                 // Display unsubscribe button
  870.                 SetComponentVisibleStatus(oPage_Team_Roaster.m_cUnsubscribe,1);
  871.             }
  872.         }
  873.         else
  874.         {
  875.             if(oPage_Team_Roaster.m_cUnsubscribe != ID_NOT_CREATED)
  876.             {
  877.                 // Hide unsubscribe button if not on player team
  878.                 SetComponentVisibleStatus(oPage_Team_Roaster.m_cUnsubscribe,0);
  879.             }
  880.         }
  881.     }
  882. }
  883. //----------------------------------------------------------------------------------------------------------------//
  884. //----------------------------------------------------------------------------------------------------------------//
  885. //
  886. //----------------------------------------------------------------------------------------------------------------//
  887. //----------------------------------------------------------------------------------------------------------------//
  888. func void UpdateDisplay()
  889. {
  890.     UpdateSubscribe();
  891.     // Update cyclist list
  892.     UpdateListDisplay();
  893.     // Update Roster
  894.     UpdatePullDisplay();
  895. }
  896.  
  897.  
  898. //----------------------------------------------------------------------------------------------------------------//
  899. //----------------------------------------------------------------------------------------------------------------//
  900. // Page Team Roster Event
  901. //----------------------------------------------------------------------------------------------------------------//
  902. //----------------------------------------------------------------------------------------------------------------//
  903. func i32x Page_Team_RoasterEvent (i32x _iComponentID,i32x _iEvent)
  904. {
  905.     if(_iComponentID == oPage_Team_Roaster.m_cTeamListBox)
  906.     {
  907.         if(_iEvent == GUI_COMPONENT_REFRESH)
  908.         {
  909.             UpdateDisplay();
  910.         }
  911.     }
  912.  
  913.     // list titles
  914.     if ((_iComponentID>=oPage_Team_Roaster.iColumnTitleID[0])&&(_iComponentID<=oPage_Team_Roaster.iColumnTitleID[13]))
  915.     {
  916.  
  917.         if(_iEvent == GUI_COMPONENT_MOUSE_ENTER )
  918.         {
  919.             Set_Tool_Bar_Text(szGetLocalizedCaracNameFromIndex(_iComponentID));
  920.         }
  921.         else if(_iEvent == GUI_COMPONENT_MOUSE_LEAVE )
  922.         {
  923.             Reset_Tool_Bar_Text();
  924.         }
  925.         
  926.         
  927.         if(_iEvent == GUI_BUTTON_PRESSED )
  928.         {
  929.             PlaySound(0,sbClickSound[0]);
  930.  
  931.             // sort direction
  932.             if (oPage_Team_Roaster.iSortedComponent==_iComponentID)
  933.             {
  934.                 // invert sorting direction
  935.                 oPage_Team_Roaster.iSortDirection = -oPage_Team_Roaster.iSortDirection;
  936.             }
  937.             else
  938.             {
  939.                 // new sorted column
  940.                 oPage_Team_Roaster.iSortedComponent= _iComponentID;
  941.  
  942.                 // default sort direction
  943.                 if (strcmp(szGetColumnNameFromIndex(oPage_Team_Roaster.iSortedComponent),"gene_sz_name")==0)
  944.                 {
  945.                     // name in ascending order
  946.                     oPage_Team_Roaster.iSortDirection = 1;
  947.                 }
  948.                 else
  949.                 {
  950.                     // carac in descending order
  951.                     oPage_Team_Roaster.iSortDirection = -1;
  952.                 }
  953.             }
  954.  
  955.             // sort table
  956.             vSortRoasterSubset();
  957.  
  958.             // Update display
  959.             UpdateListDisplay ();
  960.         }    
  961.     }
  962.     // select button
  963.     if(_iComponentID == oPage_Team_Roaster.iSelectID)
  964.     {
  965.         if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
  966.             PlaySound(0,sbClickSound[0]);
  967.         if(_iEvent == GUI_BUTTON_PRESSED )
  968.         {
  969.             Page_Team_Roster_AddPullCyclist(oPage_Team_Roaster.iSelectedCyclistID);
  970.         }
  971.     }
  972.     
  973.     // remove button
  974.     if(_iComponentID == oPage_Team_Roaster.iRemoveID)
  975.     {
  976.         if(_iEvent == GUI_BUTTON_PRESSED )
  977.         {
  978.             PlaySound(0,sbClickSound[0]);
  979.             Page_Team_Roster_RemovePullCyclist(oPage_Team_Roaster.iSelectedCyclistID);
  980.         }
  981.     }
  982.  
  983.     // Subscribe button
  984.     if(_iComponentID == oPage_Team_Roaster.m_cSubscribe)
  985.     {
  986.         // Guest mode verification (could maybe prevent multi click)
  987.         if(g_oUser.m_iUserMode == G_iGuestUser)
  988.         {
  989.             if(_iEvent == GUI_BUTTON_PRESSED )
  990.             {
  991.                 var i32x iTeamID;
  992.                 var szx szInfo;
  993.  
  994.                 PlaySound(0,sbClickSound[0]);
  995.  
  996.                 // Selected team
  997.                 iTeamID = oObject_TeamListbox.m_iSelectedTeamID;
  998.                 szInfo = strcat(GetLocalizedFromGMKey(341)," ");
  999.                 szInfo = strcat(szInfo,Join_GetStringFromKey(oObject_TeamListbox.m_jTeamName, iTeamID));
  1000.                 CreateMessageBox(szInfo, 1, Subscribe_MessageBoxCallback);
  1001.             }
  1002.         }
  1003.     }
  1004.     
  1005.     // Unsubscribe button
  1006.     if(_iComponentID == oPage_Team_Roaster.m_cUnsubscribe)
  1007.     {
  1008.         // Registered mode verification (could maybe prevent multi click)
  1009.         if(g_oUser.m_iUserMode == G_iRegisteredUser)
  1010.         {
  1011.             if(_iEvent == GUI_BUTTON_PRESSED )
  1012.             {
  1013.                 var szx szInfo;
  1014.  
  1015.                 PlaySound(0,sbClickSound[0]);
  1016.                 szInfo = strcat(GetLocalizedFromGMKey(342)," ");
  1017.                 szInfo = strcat(szInfo,Join_GetStringFromKey(oObject_TeamListbox.m_jTeamName, g_oUser.m_iMyTeamID));
  1018.                 CreateMessageBox(szInfo, 1, Unsubscribe_MessageBoxCallback);
  1019.             }
  1020.         }
  1021.     }
  1022.  
  1023.     return 1;
  1024. }
  1025.  
  1026. //----------------------------------------------------------------------------------------------------------------//
  1027. //----------------------------------------------------------------------------------------------------------------//
  1028. // Page Team Roster Members Init
  1029. //----------------------------------------------------------------------------------------------------------------//
  1030. //----------------------------------------------------------------------------------------------------------------//
  1031. func void Page_Team_Roaster_InitMembers ()
  1032. {
  1033.     oPage_Team_Roaster.szName        = "Page_Team_Roaster";
  1034.     oPage_Team_Roaster.oFunc.pcreate    = Page_Team_Roaster_Create;
  1035.     oPage_Team_Roaster.oFunc.pevent        = Page_Team_RoasterEvent;
  1036. }
  1037.  
  1038.  
  1039. //----------------------------------------------------------------------------------------------------------------//
  1040. //----------------------------------------------------------------------------------------------------------------//
  1041. // Query reception funcs
  1042. //----------------------------------------------------------------------------------------------------------------//
  1043. //----------------------------------------------------------------------------------------------------------------//
  1044. func void vPage_Team_Roaster_TeamsDivisionsOk()
  1045. {
  1046.     Dialog_Loading_Data_SetText(GetLocalizedFromGMKey(317));
  1047. }
  1048.  
  1049. func void vPage_Team_Roaster_CyclistsTeamsOk()
  1050. {
  1051.     Dialog_Loading_Data_SetText(GetLocalizedFromGMKey(326));
  1052. }
  1053.  
  1054. func void vPage_Team_Roaster_CyclistsFitnessOK()
  1055. {
  1056.     
  1057.     // update global cyclist database with new fitness
  1058.     var i32x iReadJoin, iReadIDJoin, iWriteJoin;
  1059.     var i32x iNbRows, iCyclistIndex;
  1060.     
  1061.     iReadJoin = Join_Constructor(QUERY_CYCLISTS_FITNESS,"DYN_cyclist.fkIDgame_menu_fitness");
  1062.     iReadIDJoin = Join_Constructor(QUERY_CYCLISTS_FITNESS,"DYN_cyclist.IDcyclist");
  1063.     iWriteJoin = Join_Constructor(QUERY_GLOBAL_CYCLISTS,"DYN_cyclist.fkIDgame_menu_fitness");
  1064.  
  1065.     iNbRows = Join_GetNumRows(iReadJoin);
  1066.  
  1067.     iCyclistIndex = 0;
  1068.     while (iCyclistIndex < iNbRows)
  1069.     {
  1070.         Join_SetIntFromKey(iWriteJoin,Join_GetIntFromIndex(iReadIDJoin,iCyclistIndex),Join_GetIntFromIndex(iReadJoin,iCyclistIndex));
  1071.         iCyclistIndex = iCyclistIndex + 1;
  1072.     }
  1073.     
  1074.     Join_Destructor(iReadJoin);
  1075.     Join_Destructor(iReadIDJoin);
  1076.     Join_Destructor(iWriteJoin);
  1077.  
  1078.     // display cyclist list
  1079.     Page_Team_Roster_Create_List();
  1080.     UpdateListDisplay();
  1081.  
  1082.     Dialog_Loading_Data_SetText(GetLocalizedFromGMKey(327));
  1083. }
  1084.  
  1085. func void vPage_Team_Roaster_RacingTeamsOK()
  1086. {
  1087.     var i32x i;
  1088.  
  1089.     // Delete old racing team join if exist (should not :) )
  1090.     i=0;
  1091.     while(i<9)
  1092.     {
  1093.         if(oPage_Team_Roaster.m_jRacingCyclist[i] != 0)
  1094.         {
  1095.             Join_Destructor(oPage_Team_Roaster.m_jRacingCyclist[i]);
  1096.             oPage_Team_Roaster.m_jRacingCyclist[i] = 0;
  1097.         }
  1098.         i=i+1;
  1099.     }
  1100.  
  1101.     // Create Racing team join
  1102.     oPage_Team_Roaster.m_jRacingCyclist[0] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_1");
  1103.     oPage_Team_Roaster.m_jRacingCyclist[1] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_2");
  1104.     oPage_Team_Roaster.m_jRacingCyclist[2] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_3");
  1105.     oPage_Team_Roaster.m_jRacingCyclist[3] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_4");
  1106.     oPage_Team_Roaster.m_jRacingCyclist[4] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_5");
  1107.     oPage_Team_Roaster.m_jRacingCyclist[5] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_6");
  1108.     oPage_Team_Roaster.m_jRacingCyclist[6] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_7");
  1109.     oPage_Team_Roaster.m_jRacingCyclist[7] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_8");
  1110.     oPage_Team_Roaster.m_jRacingCyclist[8] = Join_Constructor(QUERY_RACING_CYCLISTS,"DYN_team.fkIDcyclist_9");
  1111.  
  1112.     // Update pull
  1113.     UpdatePullDisplay();
  1114.  
  1115.     // Destroy loading data dialog
  1116.     DestroyDialog();
  1117. }
  1118. //----------------------------------------------------------------------------------------------------------------//
  1119. //----------------------------------------------------------------------------------------------------------------//
  1120. // Page Team Roster LoadData
  1121. //----------------------------------------------------------------------------------------------------------------//
  1122. //----------------------------------------------------------------------------------------------------------------//
  1123. func void Page_Team_Roster_LoadData ()
  1124. {
  1125. }
  1126. //----------------------------------------------------------------------------------------------------------------//
  1127. //----------------------------------------------------------------------------------------------------------------//
  1128. // Page Team Roster LoadData
  1129. //----------------------------------------------------------------------------------------------------------------//
  1130. //----------------------------------------------------------------------------------------------------------------//
  1131. func void Page_Team_Roster_Refresh ()
  1132. {
  1133.     // Refresh roster after MS notify
  1134.     // Update cyclist list display
  1135.     UpdateListDisplay();
  1136.  
  1137.     // Update pull
  1138.     // Display pull
  1139.     DisplayPull();
  1140. }
  1141.  
  1142.  
  1143. //----------------------------------------------------------------------------------------------------------------//
  1144. //----------------------------------------------------------------------------------------------------------------//
  1145. // Page Team Roster SaveData
  1146. //----------------------------------------------------------------------------------------------------------------//
  1147. //----------------------------------------------------------------------------------------------------------------//
  1148. func void Page_Team_Roster_SaveData ()
  1149. {
  1150.     Page_Team_Roaster_SaveRacingTeam();
  1151. }
  1152.  
  1153. //----------------------------------------------------------------------------------------------------------------//
  1154. //----------------------------------------------------------------------------------------------------------------//
  1155. // Return the current stage number
  1156. //----------------------------------------------------------------------------------------------------------------//
  1157. //----------------------------------------------------------------------------------------------------------------//
  1158. func i32x Page_Team_Roster_GetCurrentStageNumber ()
  1159. {
  1160.     var i32x iTemp;
  1161.     iTemp = 0;
  1162.     // get current stage number from database
  1163.     iTemp = Database_GetIntData(QUERY_GLOBAL_STAGES,
  1164.                                 "STA_stage.gene_i_stage_number",
  1165.                                 ROW_KEY,
  1166.                                 g_oGameConfig.m_iCurrentStageID );
  1167.     // debug print
  1168.     //print("current stage number : ");
  1169.     //println(itoa(iTemp));
  1170.  
  1171.     return iTemp;
  1172. }
  1173.  
  1174. //----------------------------------------------------------------------------------------------------------------//
  1175. //----------------------------------------------------------------------------------------------------------------//
  1176. //
  1177. //----------------------------------------------------------------------------------------------------------------//
  1178. //----------------------------------------------------------------------------------------------------------------//
  1179. func void Page_Team_Roster_SetSelectedListItem (i32x _iSelectedItem)
  1180. {
  1181.     // set context
  1182.     var component pComponent;
  1183.     pComponent=GetParserComponent();
  1184.     SetParserComponent(oPage_Team_Roaster.pThis);
  1185.  
  1186.     // set selected item in list
  1187.     SetListSelectedItem(oPage_Team_Roaster.iCyclistListID, _iSelectedItem);
  1188.  
  1189.     // restore context
  1190.     SetParserComponent(pComponent);
  1191. }
  1192.  
  1193. //----------------------------------------------------------------------------------------------------------------//
  1194. //----------------------------------------------------------------------------------------------------------------//
  1195. //
  1196. //----------------------------------------------------------------------------------------------------------------//
  1197. //----------------------------------------------------------------------------------------------------------------//
  1198. func void Page_Team_Roster_SetListPosition (i32x _iSelectedItem)
  1199. {
  1200.     // set context
  1201.     var component pComponent;
  1202.     pComponent=GetParserComponent();
  1203.     SetParserComponent(oPage_Team_Roaster.pThis);
  1204.  
  1205.     // set selected item in list
  1206.     SetListPosition(oPage_Team_Roaster.iCyclistListID, _iSelectedItem);
  1207.  
  1208.     // restore context
  1209.     SetParserComponent(pComponent);
  1210. }
  1211.  
  1212.  
  1213. //----------------------------------------------------------------------------------------------------------------//
  1214. //----------------------------------------------------------------------------------------------------------------//
  1215. // Message box callback func
  1216. //----------------------------------------------------------------------------------------------------------------//
  1217. //----------------------------------------------------------------------------------------------------------------//
  1218. func void Subscribe_MessageBoxCallback(i32x _iResult)
  1219. {
  1220.     if(_iResult == g_iTypeOkDialog)
  1221.     {
  1222.         var i32x iTeamID;
  1223.         var szx szInfo;
  1224.  
  1225.         // Selected team
  1226.         iTeamID = oObject_TeamListbox.m_iSelectedTeamID;
  1227.  
  1228.         // create waiting dialog    
  1229.         CreateDialog(DIALOG_LOADING_DATA);
  1230.  
  1231.         szInfo = GetLocalizedFromGMKey(156);
  1232.         Dialog_Loading_Data_SetText(szInfo);
  1233.  
  1234.         // Send subscribe message to menu server and wait for validation SubscribeOk message
  1235.         g_oMenuServer.m_oServer<<mGame_UserSubscribe(iTeamID);
  1236.     }
  1237. }
  1238. func void Unsubscribe_MessageBoxCallback(i32x _iResult)
  1239. {
  1240.     if(_iResult == g_iTypeOkDialog)
  1241.     {
  1242.         var szx szInfo;
  1243.         // create waiting dialog    
  1244.         CreateDialog(DIALOG_LOADING_DATA);
  1245.  
  1246.         szInfo = GetLocalizedFromGMKey(158);
  1247.         Dialog_Loading_Data_SetText(szInfo);
  1248.  
  1249.         // Send unsubscribe message to menu server and wait for validation UnsubscribeOk message
  1250.         g_oMenuServer.m_oServer<<mGame_UserUnsubscribe();
  1251.     }
  1252. }
  1253.