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

  1. //----------------------------------------------------------------------------------------------------------------//
  2. //----------------------------------------------------------------------------------------------------------------//
  3. //
  4. //----------------------------------------------------------------------------------------------------------------//
  5. //----------------------------------------------------------------------------------------------------------------//
  6. func void Object_InRaceEvents_List_Item_Create ()
  7. {
  8.     SetObjectMembersNumber(2);
  9.     SetComponentNumber(2);
  10.     // selection
  11.     oInRaceEvents_List_Item.m_cSelection=InitContainer(t_Common_Color_White);
  12.     SetContainerSize(oInRaceEvents_List_Item.m_cSelection, 400, 16);
  13.     SetContainerColor(oInRaceEvents_List_Item.m_cSelection,c_ListSelection);
  14.     SetComponentClipper(oInRaceEvents_List_Item.m_cSelection, 0, 0, 400, 16);
  15.     SetComponentVisibleStatus(oInRaceEvents_List_Item.m_cSelection,false);
  16.     // race name
  17.     oInRaceEvents_List_Item.m_cEvents=InitContainer(tFontArial);
  18.     SetComponentSize(oInRaceEvents_List_Item.m_cEvents,400,16);
  19.     SetObjectSize(400,16);
  20.  
  21.     // No event affected
  22.     Seti32x(1,0);
  23. }
  24.  
  25. //----------------------------------------------------------------------------------------------------------------//
  26. //----------------------------------------------------------------------------------------------------------------//
  27. //
  28. //----------------------------------------------------------------------------------------------------------------//
  29. //----------------------------------------------------------------------------------------------------------------//
  30. func void Object_InRaceEvents_List_Item_Update (i32x _iItemID)
  31. {
  32.     var szx szTemp;
  33.  
  34.     // Store cyclist id into object
  35.     var i32x item,cyclistid,eventid;
  36.  
  37.     item = _iItemID;
  38.     cyclistid=Join_GetIntFromIndex(oRaceEvent.m_jCyclistID,item);
  39.     eventid = Join_GetIntFromIndex(oRaceEvent.m_jEventID,item);
  40.  
  41.     if(eventid != Geti32x(1))
  42.     {
  43.         // Store selected cyclist id into list member
  44.         Seti32x(0,cyclistid);
  45.  
  46.         // Store event id
  47.         Seti32x(1,eventid);
  48.  
  49.         // Retrieve race name
  50.         szTemp=Join_GetStringFromIndex(oRaceEvent.m_jEventsString,item);
  51.  
  52.         SetContainerText(oInRaceEvents_List_Item.m_cEvents,szTemp);
  53.     }
  54. }
  55.  
  56. func i32x Object_InRaceEvents_List_Item_Event (i32x _iComponentID, i32x _iEvent)
  57. {
  58.     if (_iComponentID == -1)
  59.     {
  60.         if (_iEvent == GUI_COMPONENT_MOUSE_LEAVE)
  61.         {
  62.             SetComponentVisibleStatus(oInRaceEvents_List_Item.m_cSelection, 0);
  63.         }
  64.         if (_iEvent == GUI_COMPONENT_MOUSE_ENTER)
  65.         {
  66.             SetComponentVisibleStatus(oInRaceEvents_List_Item.m_cSelection, 1);
  67.         }
  68.         if (_iEvent == GUI_LIST_SELECTITEM)
  69.         {
  70.             var i32x id;
  71.  
  72.             // Get cyclist id
  73.             id = Geti32x(0);
  74.  
  75.             // Change selected cyclist
  76.             SetActiveCyclist(id);
  77.  
  78.             // Refresh cyclist info
  79.             RefreshInfos();
  80.         }
  81.     }
  82.     
  83.     if (_iEvent == GUI_COMPONENT_MOUSE_LDOWN)
  84.     {
  85.         if (_iComponentID != oInRaceEvents_List_Item.m_cSelection)
  86.         {
  87.             PlaySound(0,sbClickSound[0]);
  88.             PushEvent(GUI_LIST_PRESSED);
  89.         }
  90.     }
  91.  
  92.     if (_iEvent == GUI_COMPONENT_MOUSE_LUP)
  93.     {
  94.         if (_iComponentID != oInRaceEvents_List_Item.m_cSelection)
  95.         {
  96.             PushEvent(GUI_LIST_SELECTION);
  97.         }
  98.     }
  99.     return 1;
  100. }
  101.  
  102. //panel inrace chat
  103. func void Panel_Inrace_EventLog_Create()
  104. {
  105.     SetComponentNumber(11);
  106.     
  107.     var i32x iID,iNumItems;
  108.  
  109.     // Save context
  110.     oPanelInraceEventLog.pThis=GetParserComponent();
  111.  
  112.     // Chat background
  113.     iID=Init_LibObject_FilledCadre(tCadreDialbox,500,300);
  114.     SetStackEvents(iID,GUI_NoEvent);
  115.     
  116.     oPanelInraceEventLog.m_iMaxItems = 128;
  117.     iNumItems = Join_GetNumRows(oRaceEvent.m_jCyclistID);
  118.     while(iNumItems >= oPanelInraceEventLog.m_iMaxItems)
  119.     {
  120.         oPanelInraceEventLog.m_iMaxItems = oPanelInraceEventLog.m_iMaxItems + 128;
  121.     }
  122.     // Slider background
  123.     iID=InitContainer(tCommonTableBorder);
  124.     SetContainerColor(iID,c_TitleList);
  125.     SetContainerSize(iID,20,200);
  126.     SetComponentPosition(iID,445-20,40);
  127.     //print("\n Creating event list \n");
  128.     oPanelInraceEventLog.m_cList = InitList(
  129.         "InRaceEvents List", // List name
  130.         oPanelInraceEventLog.m_iMaxItems, // Max item number
  131.         440,200, // Width, height
  132.         Object_InRaceEvents_List_Item_Create,Object_InRaceEvents_List_Item_Update,Object_InRaceEvents_List_Item_Event, // Item oFunc
  133.         t_btn_slider, // Slider texture
  134.         NullButtonState);    // State func for the slider
  135.  
  136.     SetComponentPosition(oPanelInraceEventLog.m_cList,5,40);
  137.     SetListNbItems(oPanelInraceEventLog.m_cList,iNumItems);
  138.     
  139.     // Border line
  140.     // Horizontal line
  141.     iID = InitContainer(tCommonTableBorder);
  142.     SetContainerSize(iID,440,1);
  143.     SetComponentPosition(iID,5,40);
  144.     iID = InitContainer(tCommonTableBorder);
  145.     SetContainerSize(iID,440,1);
  146.     SetComponentPosition(iID,5,40+200);
  147.  
  148.     // Vertical line
  149.     iID = InitContainer(tCommonTableBorder);
  150.     SetContainerSize(iID,1,200);
  151.     SetComponentPosition(iID,5,40);
  152.     iID = InitContainer(tCommonTableBorder);
  153.     SetContainerSize(iID,1,200);
  154.     SetComponentPosition(iID,445-20,40);
  155.     iID = InitContainer(tCommonTableBorder);
  156.     SetContainerSize(iID,1,200);
  157.     SetComponentPosition(iID,445,40);
  158.     if(iNumItems)
  159.     {
  160.         SetListPosition(oPanelInraceEventLog.m_cList,iNumItems-1);
  161.     }
  162.  
  163.     SetObjectSize(460,300);        
  164. }
  165.  
  166.  
  167. func void Panel_Inrace_EventLog_InitMembers ()
  168. {
  169.     oPanelInraceEventLog.oFunc.pcreate=Panel_Inrace_EventLog_Create;
  170.     oPanelInraceEventLog.oFunc.pevent=Panel_Inrace_EventLog_Event;
  171. }
  172.  
  173.  
  174. func void Panel_Inrace_EventLog_Update()
  175. {
  176.     var i32x iNumItems;
  177.     //update the list if the chat window is open
  178.     if(oRace.iLogWindow != ID_NOT_CREATED)
  179.     {
  180.         var component pold;
  181.  
  182.         if(oPanelInraceEventLog.pThis != g_poNullComponent)
  183.         {
  184.             // Save current contex
  185.             pold=GetParserComponent();
  186.  
  187.             // Set Chat window context
  188.             SetParserComponent(oPanelInraceEventLog.pThis);
  189.  
  190.             iNumItems = Join_GetNumRows(oRaceEvent.m_jCyclistID);
  191.             
  192.             if(iNumItems >= oPanelInraceEventLog.m_iMaxItems)
  193.             {
  194.                 while(iNumItems >= oPanelInraceEventLog.m_iMaxItems)
  195.                 {
  196.                     oPanelInraceEventLog.m_iMaxItems = oPanelInraceEventLog.m_iMaxItems + 128;
  197.                 }
  198.                 if (oPanelInraceEventLog.m_cList != ID_NOT_CREATED)
  199.                 {
  200.                     //print("\n Deleting event list \n");
  201.                     
  202.                     DeleteComponent(oPanelInraceEventLog.m_cList);
  203.                     oPanelInraceEventLog.m_cList = ID_NOT_CREATED;
  204.                 }
  205.             }
  206.             
  207.             if(oPanelInraceEventLog.m_cList == ID_NOT_CREATED)
  208.             {
  209.                 //print("\n Creating event list \n");
  210.                 oPanelInraceEventLog.m_cList = InitList(
  211.                     "InRaceEvents List", // List name
  212.                     oPanelInraceEventLog.m_iMaxItems, // Max item number
  213.                     400,190, // Width, height
  214.                     Object_InRaceEvents_List_Item_Create,Object_InRaceEvents_List_Item_Update,Object_InRaceEvents_List_Item_Event, // Item oFunc
  215.                     t_btn_slider, // Slider texture
  216.                     NullButtonState);    // State func for the slider
  217.  
  218.                 SetComponentPosition(oPanelInraceEventLog.m_cList,5,40);
  219.             }
  220.             SetListNbItems(oPanelInraceEventLog.m_cList,iNumItems);
  221.             
  222.             if(iNumItems)
  223.             {
  224.                 SetListPosition(oPanelInraceEventLog.m_cList,iNumItems-1);
  225.             }
  226.  
  227.             //restore context
  228.             SetParserComponent(pold);
  229.         }
  230.     }
  231. }
  232.  
  233.  
  234. func i32x Panel_Inrace_EventLog_Event(i32x _iComponentID, i32x _iEvent)
  235. {
  236.     if(_iComponentID==-1)
  237.     {
  238.         if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
  239.         {
  240.             oPanelInraceEventLog.pThis = g_poNullComponent;
  241.         }
  242.     }
  243.     return 1;
  244.     
  245. }
  246.  
  247.