home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / manager / object_manager_palmares.cnc < prev    next >
Text File  |  2001-06-07  |  7KB  |  193 lines

  1. //----------------------------------------------------------------------------------------------------------------//
  2. // Create Manager Palmares list : must be called in Manager Page context
  3. func i32x iCreateManagerPalmaresList()
  4. {
  5.     var i32x i,iNumItems;
  6.  
  7.     i = InitList(
  8.         "Manager Palmares List", // List name
  9.         256, // Max item number
  10.         600,230, // Width, height
  11.         Manager_Palmares_Item_Create,Manager_Palmares_Item_Update,Manager_Palmares_Item_Event, // Item oFunc
  12.         t_btn_slider, // Slider texture
  13.         NullButtonState);    // State func for the slider
  14.  
  15.     SetComponentPosition(i,20,230);
  16.  
  17.     return i;
  18. }
  19.  
  20.  
  21. //Manager Palmares Item Create func
  22. //----------------------------------------------------------------------------------------------------------------//
  23. func void Manager_Palmares_Item_Create ()
  24. {
  25.     var i32x id;
  26.     SetComponentNumber(1);
  27.     SetObjectMembersNumber(2);
  28.  
  29.     // Palmares result
  30.     oManager_Palmares_Item.m_cResult=InitContainer(tFontArialItalique);
  31.     SetComponentPositionX(oManager_Palmares_Item.m_cResult,20);
  32.     SetComponentSize(oManager_Palmares_Item.m_cResult,580,16);
  33.  
  34.     SetObjectSize(580,16);
  35. }
  36.  
  37. //Manager Palmares Item Update func
  38. //----------------------------------------------------------------------------------------------------------------//
  39. func void Manager_Palmares_Item_Update (i32x _iItemID)
  40. {
  41.     var i32x iRank,iRace,iClassification,iCyclistID;
  42.     var szx szText;
  43.     var szx szRaceName,szClassificationName,szRank;
  44.  
  45.     iRank = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_irank,_iItemID);
  46.     iRace = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_ifkIDrace,_iItemID);    
  47.     iClassification = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_ifkIDclassification,_iItemID);    
  48.     
  49.     // Get the name of the race
  50.     szRaceName = GetLocalizedFromKey(Database_GetIntData(QUERY_GLOBAL_STAGES,"STA_race.gene_strID_race_name",ROW_KEY,iRace));
  51.     
  52.     // Get the name of the classification
  53.     szClassificationName = GetLocalizedFromKey(Database_GetIntData(QUERY_GLOBAL_CLASSIFICATION,"STA_classification.gene_strID_classification_name",ROW_KEY,iClassification));
  54.  
  55.     // Get the name of the rank
  56.     if(iRank == 1)
  57.         szRank = GetLocalizedFromGMKey(421);    // First
  58.     else
  59.     {
  60.         if(iRank == 2)
  61.             szRank = GetLocalizedFromGMKey(422);    // Second
  62.         else
  63.             szRank = GetLocalizedFromGMKey(423);    // Third
  64.     }
  65.  
  66.     szText = strcat(szRaceName, " - ");
  67.     szText = strcat(szText, szClassificationName);
  68.     szText = strcat(szText, " : ");
  69.     szText = strcat(szText, szRank);
  70.  
  71.     // Get Cyclist name
  72.     iCyclistID = Join_GetIntFromSortedIndex(oManager_Palmares.m_jManager_Palmares_ifkIDcyclist,_iItemID);
  73.     if(iCyclistID>0)
  74.     {
  75.         var szx szFirstName,szLastName,szName;
  76.  
  77.         szFirstName = Database_GetStringData(QUERY_GLOBAL_CYCLISTS,"DYN_cyclist.gene_sz_firstname",ROW_KEY,iCyclistID);
  78.         szLastName = Database_GetStringData(QUERY_GLOBAL_CYCLISTS,"DYN_cyclist.gene_sz_lastname",ROW_KEY,iCyclistID);
  79.  
  80.         szName = strncpy(szFirstName,1);    // First name initial
  81.         szName = strcat(szName,". ");
  82.         szName = strcat(szName,szLastName);
  83.         szText = strcat(szText, " (");
  84.         szText = strcat(szText, szName);
  85.         szText = strcat(szText, ")");
  86.     }
  87.     
  88.     SetContainerText(oManager_Palmares_Item.m_cResult, szText);
  89.     if(iRank == 1)
  90.         SetContainerColor(oManager_Palmares_Item.m_cResult,c_Yellow);
  91.     else
  92.         SetContainerColor(oManager_Palmares_Item.m_cResult,c_White);
  93.     SetContainerOffset(oManager_Palmares_Item.m_cResult,-1);
  94.  
  95. }
  96. //Manager Palmares Item Event func
  97. //----------------------------------------------------------------------------------------------------------------//
  98. func i32x Manager_Palmares_Item_Event (i32x _iComponentID, i32x _iEvent)
  99. {
  100.     return 1;
  101. }
  102.  
  103. //----------------------------------------------------------------------------------------------------------------//
  104. // Update Manager Palmares list
  105. func void Manager_Palmares_Update_List_Display ()
  106. {
  107.     var i32x iNumItems;
  108.     var component poComponent;
  109.  
  110.     //Save context
  111.     poComponent = GetParserComponent();
  112.     SetParserComponent(oPage_Manager.pThis);
  113.  
  114.     // Clear the subset to fill it with new data
  115.     DatabaseSubset_Clear(TEMP_DATABASE);
  116.  
  117.     // create query to fill the subset
  118.     Query_Create(0, TEMP_DATABASE);
  119.     Query_SetNumJoinTables(    0, 1);
  120.     Query_SelectJoinTable(    0, 0, "DYN_palmares");
  121.  
  122.     // Only results for the current manager
  123.     Query_SelectWhereIntEqual(0, "DYN_palmares.fkIDmanager", oObject_Profil.m_iManagerID); // result for the current manager
  124.     Query_Execute(0);
  125.  
  126.     // Order by race
  127.     Table_Sort(TEMP_DATABASE,"DYN_palmares","fkIDrace",-1);
  128.     Table_Sort(TEMP_DATABASE,"DYN_palmares","fkIDclassification",1);
  129.     Table_Sort(TEMP_DATABASE,"DYN_palmares","gene_i_rank",1);
  130.  
  131.  
  132.     iNumItems = Table_GetNumRows(TEMP_DATABASE,0);
  133.     SetListNbItems(oManager_Palmares.iPalmaresID,iNumItems);
  134.  
  135.     if(iNumItems>0)
  136.     {
  137.         SetListPosition(oManager_Palmares.iPalmaresID,0);
  138.         SetListSelectedItem(oManager_Palmares.iPalmaresID,0);
  139.     }
  140.  
  141.     // Restore context
  142.     SetParserComponent(poComponent);
  143.  
  144. }
  145.  
  146. //----------------------------------------------------------------------------------------------------------------//
  147. // Create manager palmares joins
  148. //----------------------------------------------------------------------------------------------------------------//
  149. func void CreateManagerPalmaresJoins()
  150. {
  151.     // Create subset to store data
  152.     DatabaseSubset_Create( TEMP_DATABASE, QUERY_MANAGER_PALMARES);
  153.     Database_AddTables(    TEMP_DATABASE, 1);
  154.     Table_SetName( TEMP_DATABASE, 0, "DYN_palmares");
  155.     TableSubset_SelectColumns( TEMP_DATABASE, 0, "*");
  156.  
  157.     oManager_Palmares.m_jManager_Palmares_irank = Join_Constructor(TEMP_DATABASE,"DYN_palmares.gene_i_rank");
  158.     oManager_Palmares.m_jManager_Palmares_ifkIDrace = Join_Constructor(TEMP_DATABASE,"DYN_palmares.fkIDrace");
  159.     oManager_Palmares.m_jManager_Palmares_ifkIDclassification = Join_Constructor(TEMP_DATABASE,"DYN_palmares.fkIDclassification");
  160.     oManager_Palmares.m_jManager_Palmares_ifkIDcyclist = Join_Constructor(TEMP_DATABASE,"DYN_palmares.fkIDcyclist");
  161.  
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------------------------------//
  165. // Destroy manager palmares joins
  166. //----------------------------------------------------------------------------------------------------------------//
  167. func void DestroyManagerPalmaresJoins()
  168. {
  169.     if(oManager_Palmares.m_jManager_Palmares_irank > 0)
  170.     {
  171.         Join_Destructor(oManager_Palmares.m_jManager_Palmares_irank);
  172.         oManager_Palmares.m_jManager_Palmares_irank = 0;
  173.     }
  174.     
  175.     if(oManager_Palmares.m_jManager_Palmares_ifkIDrace > 0)
  176.     {
  177.         Join_Destructor(oManager_Palmares.m_jManager_Palmares_ifkIDrace);
  178.         oManager_Palmares.m_jManager_Palmares_ifkIDrace = 0;
  179.     }
  180.     
  181.     if(oManager_Palmares.m_jManager_Palmares_ifkIDclassification > 0)
  182.     {
  183.         Join_Destructor(oManager_Palmares.m_jManager_Palmares_ifkIDclassification);
  184.         oManager_Palmares.m_jManager_Palmares_ifkIDclassification = 0;
  185.     }
  186.  
  187.     if(oManager_Palmares.m_jManager_Palmares_ifkIDcyclist > 0)
  188.     {
  189.         Join_Destructor(oManager_Palmares.m_jManager_Palmares_ifkIDcyclist);
  190.         oManager_Palmares.m_jManager_Palmares_ifkIDcyclist = 0;
  191.     }
  192. }
  193.