home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / season / calendar / page_season_calendar.cnc < prev    next >
Text File  |  2001-06-05  |  29KB  |  867 lines

  1. //
  2. //----------------------------------------------------------------------------------------------------------------//
  3. func void ShowRaceInfo(i32x _iRaceID,i32x _iStageID)
  4. {
  5.     var component pOldComponent;
  6.  
  7.     if(oPage_Season_Calendar.pThis)
  8.     {
  9.         pOldComponent = GetParserComponent();
  10.  
  11.         var i32x iSubsetID,iPosX,iPosY,iW,iH;
  12.         var i32x iNameID;
  13.         var szx szName;
  14.         var i32x stagetime;
  15.  
  16.  
  17.         SetParserComponent(oCalendar_RaceInfo.pThis);
  18.  
  19.         iNameID = Join_GetIntFromKey(oPage_Season_Calendar.m_jRaceFullNameId,_iRaceID);
  20.         szName = GetLocalizedFromKey(iNameID);
  21.         oPage_Season_Calendar.iInfoCount = oPage_Season_Calendar.iInfoCount + 1;
  22.  
  23.         SetContainerText(oCalendar_RaceInfo.m_cRaceName,szName);
  24.  
  25.         if(_iStageID>=0)
  26.         {
  27.             iNameID = Join_GetIntFromKey(oPage_Season_Calendar.m_jStageName,_iStageID);
  28.             szName = GetLocalizedFromKey(iNameID);
  29.             SetContainerText(oCalendar_RaceInfo.m_cStageName,szName);
  30.         }
  31.  
  32.         ResizeComponent(oCalendar_RaceInfo.m_cRaceName);
  33.         ResizeComponent(oCalendar_RaceInfo.m_cStageName);
  34.  
  35.         iW = GetComponentWidth(oCalendar_RaceInfo.m_cRaceName);
  36.         if(GetComponentWidth(oCalendar_RaceInfo.m_cStageName)>iW)
  37.             iW = GetComponentWidth(oCalendar_RaceInfo.m_cStageName);
  38.  
  39.         
  40.         SetCadreSize(oCalendar_RaceInfo.m_cBackground, iW + 16 ,40);
  41.  
  42.         // Set page calendar context
  43.         SetParserComponent(oPage_Season_Calendar.pThis);
  44.  
  45.         // Move Race info
  46.         iPosX = GetMousePosX()-(iW/2)-GetObjectPositionX();
  47.         iPosY = GetMousePosY() - 50 - GetObjectPositionY();
  48.         if(iPosX<0)
  49.             iPosX = 0;
  50.         if((iPosX+iW)>630)
  51.             iPosX=630-iW;
  52.         SetComponentPosition(oPage_Season_Calendar.iRaceInfoID,iPosX,iPosY);
  53.  
  54.         // Show race info
  55.         SetComponentVisibleStatus(oPage_Season_Calendar.iRaceInfoID,1);
  56.  
  57.         SetParserComponent(pOldComponent);
  58.     }
  59. }
  60.  
  61.  
  62. //
  63. //----------------------------------------------------------------------------------------------------------------//
  64. func void HideRaceInfo()
  65. {
  66.     var component pOldComponent;
  67.  
  68.     if(oPage_Season_Calendar.pThis)
  69.     {
  70.         if(oPage_Season_Calendar.iInfoCount>0)
  71.         {
  72.             oPage_Season_Calendar.iInfoCount =oPage_Season_Calendar.iInfoCount - 1;
  73.  
  74.             if(oPage_Season_Calendar.iInfoCount == 0)
  75.             {
  76.  
  77.                 pOldComponent = GetParserComponent();
  78.                 SetParserComponent(oPage_Season_Calendar.pThis);
  79.  
  80.                 SetComponentVisibleStatus(oPage_Season_Calendar.iRaceInfoID,0);
  81.  
  82.                 SetParserComponent(pOldComponent);
  83.             }
  84.             
  85.         }
  86.     }
  87. }
  88.  
  89. //----------------------------------------------------------------------------------------------------------------//
  90. //----------------------------------------------------------------------------------------------------------------//
  91. //Object_Season_Calendar Create func
  92. //----------------------------------------------------------------------------------------------------------------//
  93. //----------------------------------------------------------------------------------------------------------------//
  94.  
  95. func void Object_RaceInfo_Create ()
  96. {
  97.     // Save context
  98.     oCalendar_RaceInfo.pThis = GetParserComponent();
  99.  
  100.     //Components Init
  101.     SetComponentNumber(3);
  102.  
  103.     // Background
  104.     oCalendar_RaceInfo.m_cBackground=Init_LibObject_FilledCadre(tFCadre7,128,40);
  105.  
  106.     oCalendar_RaceInfo.m_cRaceName = InitContainer(tFontArialItalique);
  107.     SetComponentPosition(oCalendar_RaceInfo.m_cRaceName,5,5);
  108.  
  109.     oCalendar_RaceInfo.m_cStageName = InitContainer(tFontArialItalique);
  110.     SetComponentPosition(oCalendar_RaceInfo.m_cStageName,5,18);
  111.     
  112.     AutoResize();
  113. }
  114.  
  115.  
  116.  
  117.  
  118. //----------------------------------------------------------------------------------------------------------------//
  119. //----------------------------------------------------------------------------------------------------------------//
  120. //Object_Season_Calendar Event func
  121. //----------------------------------------------------------------------------------------------------------------//
  122. //----------------------------------------------------------------------------------------------------------------//
  123.  
  124. func i32x Object_RaceInfo_Event (i32x _iComponentID, i32x _iEvent)
  125. {
  126.     if(_iComponentID == -1)
  127.     {
  128.         if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
  129.         {
  130.             oPage_Season_Calendar.pThis = g_poNullComponent;
  131.         }
  132.     }
  133.  
  134.     return 1;
  135. }
  136.  
  137.  
  138.  
  139.  
  140. //----------------------------------------------------------------------------------------------------------------//
  141. //----------------------------------------------------------------------------------------------------------------//
  142. //Object_Season_Calendar Init member
  143. //----------------------------------------------------------------------------------------------------------------//
  144. //----------------------------------------------------------------------------------------------------------------//
  145.  
  146. func void Object_RaceInfo_InitMembers ()
  147. {
  148.     oCalendar_RaceInfo.oFunc.pcreate        = Object_RaceInfo_Create;
  149.     oCalendar_RaceInfo.oFunc.pevent        = Object_RaceInfo_Event;
  150. }
  151.  
  152.  
  153.  
  154.  
  155.  
  156. //----------------------------------------------------------------------------------------------------------------//
  157. //----------------------------------------------------------------------------------------------------------------//
  158. //
  159. //----------------------------------------------------------------------------------------------------------------//
  160. //----------------------------------------------------------------------------------------------------------------//
  161.  
  162. func i32x LeapYear (i32x _iYear)
  163. {
  164.     if ((_iYear % 400) == 0)
  165.         return true;
  166.  
  167.     if ((_iYear > 1582) && ((_iYear % 100) == 0))
  168.         return false;
  169.  
  170.     if ((_iYear % 4) == 0)
  171.         return true;
  172.  
  173.     return false;
  174. }
  175.  
  176. func void SelectMonth(i32x _month)
  177. {
  178.     var i32x i;
  179.     // Must be in PageCalendar context
  180.  
  181.     i=0;
  182.     while(i<12)
  183.     {
  184.         if(i!=_month)
  185.             SetTextRadioButtonCheckBox(oPage_Season_Calendar.cMonthsName[i],0);
  186.         else
  187.             SetTextRadioButtonCheckBox(oPage_Season_Calendar.cMonthsName[i],1);
  188.         i=i+1;
  189.     }
  190. }
  191.  
  192.  
  193.  
  194. func void DrawMonth (i32x _iYDay,i32x _iStartDay, i32x _iNbDays, boolx _bSpecial)
  195. {
  196.     var i32x subsetid;
  197.     var i32x iRaceRow,iRaceID,iFinish,iStart,iUCIclass,iStringID;
  198.     var i32x iStageNum,iRaceNumberOfStages,iStageID;
  199.     var i32x bRestDay;
  200.     var i32x iCol;
  201.     var szx szRaceName;
  202.  
  203.     // Subset for stage and race link
  204.     subsetid = TEMP_DATABASE;
  205.  
  206.     iCol = _iStartDay + 1;
  207.  
  208.  
  209.     var i32x iRow;
  210.     iRow = 2;
  211.  
  212.     var i32x iX;
  213.     var i32x iY;
  214.  
  215.     var i32x iLoop;
  216.     iLoop = 1;
  217.     while (iLoop <= _iNbDays)
  218.     {
  219.         if ((_bSpecial) && (iLoop == 5))
  220.             iLoop = iLoop + 10;                // skip 10 days (Oct 5-14) in October, 1582
  221.  
  222.         iX = (iCol - 1) * 90 + 20;                    // ColWidth = 90
  223.         iY = (iRow - 1) * 58 + 40;                    // RowHeight = 57
  224.  
  225.         bRestDay = false;
  226.         iRaceID = -1;
  227.         iStart = 0;
  228.         iFinish = 0;
  229.  
  230.         // Stage this day .
  231.         iStageID = Join_FindKeyFromIntData(oPage_Season_Calendar.m_jStageDate,_iYDay+iLoop);
  232.  
  233.  
  234.         if(iStageID<0)
  235.         {
  236.             // No stage : maybe a rest day ?
  237.             iStageID = Join_FindKeyFromIntData(oPage_Season_Calendar.m_jStageDate,_iYDay+iLoop-1);
  238.             if(iStageID>0)
  239.             {
  240.                 bRestDay = Join_GetIntFromKey(oPage_Season_Calendar.m_jStageFollowedRestDay,iStageID);
  241.                 if(!bRestDay)
  242.                     iStageID = -1;
  243.             }
  244.         }
  245.  
  246.         if(iStageID>0)
  247.         {
  248.             // Race of stage
  249.             iRaceID = Join_GetIntFromKey(oPage_Season_Calendar.m_jStageRaceID,iStageID);
  250.  
  251.             // Stage number
  252.             iStageNum = Join_GetIntFromKey(oPage_Season_Calendar.m_jStageNum,iStageID);
  253.             // Total stage number
  254.             iRaceNumberOfStages = Join_GetIntFromKey(oPage_Season_Calendar.m_jRaceNumberOfStages,iRaceID);
  255.             // Race UCI class
  256.             iUCIclass = Join_GetIntFromKey(oPage_Season_Calendar.m_jRaceUCIClass,iRaceID);
  257.         }
  258.  
  259.         if(iRaceNumberOfStages>1)
  260.         {
  261.             if(iStageNum == 1)
  262.             {
  263.                 iStart = 1;
  264.                 iFinish = 0;
  265.             }
  266.             else if(iStageNum == iRaceNumberOfStages)
  267.             {
  268.                 iStart = 0;
  269.                 iFinish = 1;
  270.             }
  271.         }
  272.         else
  273.         {
  274.             iStart = 1;
  275.             iFinish = 1;
  276.         }
  277.  
  278.         // Create day object
  279.         oPage_Season_Calendar.iDayObject[iLoop - 1] = InitCalendarDay(iLoop,iRaceID,iStageID,iUCIclass,iStart,iFinish,bRestDay);
  280.         SetComponentPosition(oPage_Season_Calendar.iDayObject[iLoop - 1], iX, iY);
  281.  
  282.         iCol = iCol + 1;
  283.         if (iCol > 7)
  284.         {
  285.             iCol = 1;
  286.             iRow = iRow + 1;
  287.         }
  288.  
  289.         iLoop = iLoop + 1;
  290.     }
  291. }
  292.  
  293.  
  294. //Init calendar day
  295. //----------------------------------------------------------------------------------------------------------------//
  296. func i32x InitCalendarDay(i32x _iLoop,i32x _iRaceID,i32x _iStageID,i32x _iUCIclass,i32x _iStart,i32x _iFinish,i32x _bRestDay)
  297. {
  298.     var i32x id;
  299.  
  300.     oObject_Season_Calendar.iDay            = _iLoop;
  301.     oObject_Season_Calendar.iRaceID            = _iRaceID;
  302.     oObject_Season_Calendar.iStageID        = _iStageID;
  303.  
  304.     oObject_Season_Calendar.iClass        = _iUCIclass;
  305.     oObject_Season_Calendar.iIsStart    = _iStart;
  306.     oObject_Season_Calendar.iIsFinish    = _iFinish;
  307.     oObject_Season_Calendar.bRestDay    = _bRestDay;
  308.  
  309.     id = InitObject(
  310.         oObject_Season_Calendar.szName,
  311.         oObject_Season_Calendar.oFunc.pcreate,
  312.         oObject_Season_Calendar.oFunc.pevent
  313.     );
  314.     SetStackEvents(id, GUI_Mouse);
  315.     return id;
  316. }
  317.  
  318. //----------------------------------------------------------------------------------------------------------------//
  319. //----------------------------------------------------------------------------------------------------------------//
  320. //
  321. //----------------------------------------------------------------------------------------------------------------//
  322. //----------------------------------------------------------------------------------------------------------------//
  323.  
  324. func void DoMonth (i32x _iMonth, i32x _iYear)
  325. {
  326.     var boolx bLeap;
  327.     var i32x iDaysInMonth;
  328.     var i32x iDaysInYear;
  329.     var i32x iStartOfMonth;
  330.     var i32x iLoop;
  331.  
  332.     bLeap = LeapYear(_iYear);
  333.  
  334.     iLoop = 0;
  335.     while (iLoop < 31)
  336.     {
  337.         if (oPage_Season_Calendar.iDayObject[iLoop] != ID_NOT_CREATED)
  338.         {
  339.             DeleteComponent(oPage_Season_Calendar.iDayObject[iLoop]);
  340.             oPage_Season_Calendar.iDayObject[iLoop] = ID_NOT_CREATED;
  341.         }
  342.         iLoop = iLoop + 1;
  343.     }
  344.  
  345.     SelectMonth(_iMonth);
  346.  
  347.     var i32x iY;
  348.     iY = _iYear - 1;
  349.  
  350.     var boolx bSpecial;    //september 1582
  351.     bSpecial = ((_iYear == 1582) && (_iMonth == 9));
  352.  
  353.  
  354.     iDaysInYear = 0;
  355.  
  356.     var boolx bPre;        //before september 1582
  357.     bPre = ((_iYear < 1582) || ((_iYear == 1582) && (_iMonth <= 9)));
  358.  
  359.     if (bPre)
  360.         iStartOfMonth = 6 + iY + (iY / 4);
  361.     else
  362.         iStartOfMonth = 1 + iY + (iY / 4) - (iY / 100) + (iY / 400);
  363.  
  364.  
  365.     if (bLeap)
  366.     {
  367.         iDaysInMonth = oPage_Season_Calendar.iLeapDays[_iMonth];
  368.  
  369.         iLoop = 0;
  370.  
  371.         while (iLoop < _iMonth)
  372.         {
  373.             iDaysInYear = iDaysInYear + oPage_Season_Calendar.iLeapDays[iLoop];
  374.             iStartOfMonth = iStartOfMonth + oPage_Season_Calendar.iLeapDays[iLoop];
  375.             iLoop = iLoop + 1;
  376.         }
  377.     }
  378.     else
  379.     {
  380.         iDaysInMonth = oPage_Season_Calendar.iMonthDays[_iMonth];
  381.  
  382.         iLoop = 0;
  383.  
  384.         while (iLoop < _iMonth)
  385.         {
  386.             iDaysInYear = iDaysInYear + oPage_Season_Calendar.iMonthDays[iLoop];
  387.             iStartOfMonth = iStartOfMonth + oPage_Season_Calendar.iMonthDays[iLoop];
  388.             iLoop = iLoop + 1;
  389.         }
  390.     }
  391.     iStartOfMonth = iStartOfMonth % 7;
  392.  
  393.     oPage_Season_Calendar.iStartOfMonth = iStartOfMonth;
  394.     DrawMonth (iDaysInYear,iStartOfMonth, iDaysInMonth, bSpecial);
  395. }
  396. //*********************************
  397. //Destruct global join if any
  398. //*********************************
  399. func void vDestroyCalendarJoin()
  400. {
  401.     if(oPage_Season_Calendar.m_jRaceFullNameId != 0)
  402.     {
  403.         Join_Destructor(oPage_Season_Calendar.m_jRaceFullNameId);
  404.         oPage_Season_Calendar.m_jRaceFullNameId = 0;
  405.     }
  406.     if(oPage_Season_Calendar.m_jRaceDate != 0)
  407.     {
  408.         Join_Destructor(oPage_Season_Calendar.m_jRaceDate);
  409.         oPage_Season_Calendar.m_jRaceDate = 0;
  410.     }
  411.     if(oPage_Season_Calendar.m_jRaceID != 0)
  412.     {
  413.         Join_Destructor(oPage_Season_Calendar.m_jRaceID);
  414.         oPage_Season_Calendar.m_jRaceID = 0;
  415.     }
  416.     if(oPage_Season_Calendar.m_jRaceNumberOfStages != 0)
  417.     {
  418.         Join_Destructor(oPage_Season_Calendar.m_jRaceNumberOfStages);
  419.         oPage_Season_Calendar.m_jRaceNumberOfStages = 0;
  420.     }
  421.     if(oPage_Season_Calendar.m_jRaceUCIClass != 0)
  422.     {
  423.         Join_Destructor(oPage_Season_Calendar.m_jRaceUCIClass);
  424.         oPage_Season_Calendar.m_jRaceUCIClass = 0;
  425.     }
  426.     if(oPage_Season_Calendar.m_jRaceNameID != 0)
  427.     {
  428.         Join_Destructor(oPage_Season_Calendar.m_jRaceNameID);
  429.         oPage_Season_Calendar.m_jRaceNameID = 0;
  430.     }
  431.     if(oPage_Season_Calendar.m_jStageID != 0)
  432.     {
  433.         Join_Destructor(oPage_Season_Calendar.m_jStageID);
  434.         oPage_Season_Calendar.m_jStageID = 0;
  435.     }
  436.     if(oPage_Season_Calendar.m_jStageDate != 0)
  437.     {
  438.         Join_Destructor(oPage_Season_Calendar.m_jStageDate);
  439.         oPage_Season_Calendar.m_jStageDate = 0;
  440.     }
  441.     if(oPage_Season_Calendar.m_jStageRaceID != 0)
  442.     {
  443.         Join_Destructor(oPage_Season_Calendar.m_jStageRaceID);
  444.         oPage_Season_Calendar.m_jStageRaceID = 0;
  445.     }
  446.     if(oPage_Season_Calendar.m_jStageNum != 0)
  447.     {
  448.         Join_Destructor(oPage_Season_Calendar.m_jStageNum);
  449.         oPage_Season_Calendar.m_jStageNum = 0;
  450.     }
  451.     if(oPage_Season_Calendar.m_jStageFollowedRestDay != 0)
  452.     {
  453.         Join_Destructor(oPage_Season_Calendar.m_jStageFollowedRestDay);
  454.         oPage_Season_Calendar.m_jStageFollowedRestDay = 0;
  455.     }
  456.     if(oPage_Season_Calendar.m_jStageName != 0)
  457.     {
  458.         Join_Destructor(oPage_Season_Calendar.m_jStageName);
  459.         oPage_Season_Calendar.m_jStageName = 0;
  460.     }
  461. }
  462. //*********************************
  463. //Create calendar page join
  464. //*********************************
  465. func void vCreateCalendarJoins()
  466. {
  467.     
  468.     oPage_Season_Calendar.m_jRaceFullNameId = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_race.gene_strID_race_name");
  469.     oPage_Season_Calendar.m_jRaceDate = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_race.gene_i_date");
  470.     oPage_Season_Calendar.m_jRaceNumberOfStages = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_race.gene_i_number_stages");
  471.     oPage_Season_Calendar.m_jRaceID = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_race.IDrace");
  472.     oPage_Season_Calendar.m_jRaceUCIClass = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_race.fkIDUCI_class");
  473.     oPage_Season_Calendar.m_jRaceNameID = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_race.gene_strID_race_abbreviation");
  474.  
  475.     oPage_Season_Calendar.m_jStageID = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_stage.IDstage");
  476.     oPage_Season_Calendar.m_jStageRaceID = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_stage.fkIDrace");
  477.     oPage_Season_Calendar.m_jStageDate = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_stage.gene_i_day");
  478.     oPage_Season_Calendar.m_jStageNum = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_stage.gene_i_stage_number");
  479.     oPage_Season_Calendar.m_jStageFollowedRestDay = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_stage.gene_b_followed_rest_day");
  480.     oPage_Season_Calendar.m_jStageName = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_stage.gene_strID_stage_name");
  481. }
  482.  
  483.  
  484. //----------------------------------------------------------------------------------------------------------------//
  485. //----------------------------------------------------------------------------------------------------------------//
  486. //Page_Season_Calendar Create func
  487. //----------------------------------------------------------------------------------------------------------------//
  488. //----------------------------------------------------------------------------------------------------------------//
  489.  
  490. func void Page_Season_Calendar_Create ()
  491. {
  492.     var i32x i,id,iNumUCIClass,jUCIClassStrId,jUCIClassId,iIndex,iColor;
  493.     var szx szTmp;
  494.  
  495.     // Save context
  496.     oPage_Season_Calendar.pThis = GetParserComponent();
  497.  
  498.     // *** Update Title Bar ***
  499.     Set_Title_Bar_Text(GetLocalizedFromGMKey(149)); // page title
  500.  
  501.     SetComponentNumber(92);
  502.  
  503.     // Page Background
  504.     id = Init_LibObject_FilledCadre(tCadreDialbox,700,550);
  505.     SetEvents(id,0);
  506.     SetComponentHeight(id,500);
  507.  
  508.     // Days text
  509.     i = 0;
  510.     while (i < 7)
  511.     {
  512.         var i32x iOffset;
  513.         id = InitContainer(tFontArialItalique);
  514.         SetContainerText(id, oPage_Season_Calendar.szDayNames[i]);
  515.         iOffset = (85 - GetTextSizeX(id,oPage_Season_Calendar.szDayNames[i]))/2;
  516.         SetComponentPosition(id, i * 90 + 17 + iOffset, 76);
  517.         i = i + 1;
  518.     }
  519.     // Title Line
  520.     id = InitContainer(t_Common_Color_White);
  521.     SetContainerSize(id,645,1);
  522.     SetComponentPosition(id,5,92);
  523.     // Months
  524.     i = 0;
  525.     while (i < 12)
  526.     {
  527.         // RadioButton
  528.         oPage_Season_Calendar.cMonthsName[i] =Init_LibObject_MultiRadioButtonWithText(tButton32Multi,0,oPage_Season_Calendar.szMonthNames[i],tFontArial,381+i);
  529.         SetTextButtonStateFunc(oPage_Season_Calendar.cMonthsName[i],CheckBoxMultiState,MultiRadioButtonWithText_TextState);
  530.         SetComponentPosition(oPage_Season_Calendar.cMonthsName[i], i * 54 + 3, 35);
  531.         ResizeComponent(oPage_Season_Calendar.cMonthsName[i]);
  532.         i = i + 1;
  533.     }
  534.  
  535.     // UCI class
  536.     jUCIClassId        = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_UCI_class.IDUCI_class");
  537.     jUCIClassStrId    = Join_Constructor(QUERY_GLOBAL_STAGES,"STA_UCI_class.gene_strID_UCI_class");
  538.     iNumUCIClass    = Join_GetNumRows(jUCIClassStrId);
  539.     i = 0;
  540.     while (i < iNumUCIClass)
  541.     {
  542.         //iIndex = Join_GetIntFromIndex(jUCIClassId,i)-1;
  543.         iIndex = oPage_Season_Calendar.m_aUCIClassOrder[i];
  544.         
  545.         if((i>=0)&&(i<oPage_Season_Calendar.m_iNumValidColor))
  546.             iColor = oPage_Season_Calendar.m_a16UCIColor[oPage_Season_Calendar.m_aUCIClassColor[iIndex]];
  547.         else
  548.             iColor = oPage_Season_Calendar.m_a16UCIColor[0];
  549.  
  550.         szTmp = GetLocalizedFromKey(Join_GetIntFromKey(jUCIClassStrId,iIndex));
  551.  
  552.         id = Init_LibObject_FilledCadre(tFCadre2,96,32);
  553.         SetComponentPosition(id,(i%5)*96+40,446+32*(i/5));
  554.         SetCadreColor(id, iColor);
  555.  
  556.         id = InitContainer(tFontArialItalique);
  557.         SetComponentPosition(id,(i%5)*96+40,446+32*(i/5));
  558.         SetComponentSize(id,96,32);
  559.         SetContainerOffset(id,-1);
  560.         SetContainerTextJustify(id,szTmp);
  561.  
  562.         i = i + 1;
  563.     }
  564.  
  565.     Join_Destructor(jUCIClassId);
  566.     Join_Destructor(jUCIClassStrId);
  567.  
  568.  
  569.     // Init day object structure
  570.     Object_Season_Calendar_InitMembers();
  571.  
  572.     // Create calendar joins
  573.     vCreateCalendarJoins();
  574.  
  575.     // Draw month
  576.     DoMonth(oPage_Season_Calendar.iCurrentMonth, oPage_Season_Calendar.iCurrentYear);
  577.  
  578.     // Race info cadre
  579.     // Title Line
  580.     id = InitContainer(t_Common_Color_White);
  581.     SetContainerSize(id,645,1);
  582.     SetComponentPosition(id,5,441);
  583.  
  584.     // Dummy component
  585.     // To let 1 free index between day and race info
  586.     id = InitContainer(t_Common_Color_White);
  587.  
  588.     Object_RaceInfo_InitMembers();
  589.     oPage_Season_Calendar.iRaceInfoID = InitObject("Race Info", oCalendar_RaceInfo.oFunc.pcreate, oCalendar_RaceInfo.oFunc.pevent);
  590.     SetComponentPosition(oPage_Season_Calendar.iRaceInfoID, 30, 480);
  591.     SetComponentVisibleStatus(oPage_Season_Calendar.iRaceInfoID,0);
  592.     SetEvents(oPage_Season_Calendar.iRaceInfoID,GUI_NoEvent);
  593.  
  594.     DeleteComponent(id);
  595.  
  596.     AutoResize();
  597. }
  598.  
  599.  
  600.  
  601.  
  602. //----------------------------------------------------------------------------------------------------------------//
  603. //----------------------------------------------------------------------------------------------------------------//
  604. //Page_Season_Calendar Event func
  605. //----------------------------------------------------------------------------------------------------------------//
  606. //----------------------------------------------------------------------------------------------------------------//
  607.  
  608. func i32x Page_Season_Calendar_Event (i32x _iComponentID, i32x _iEvent)
  609. {
  610.     if(_iEvent == GUI_RADIOBUTTON_CHANGED)
  611.     {
  612.         var i32x i;
  613.  
  614.         PlaySound(0,sbClickSound[0]);
  615.  
  616.         i=0;
  617.         while(i<12)
  618.         {
  619.             if(_iComponentID==oPage_Season_Calendar.cMonthsName[i])
  620.             {
  621.                 oPage_Season_Calendar.iCurrentMonth = i;
  622.             }
  623.             else
  624.             {
  625.                 SetTextRadioButtonCheckBox(oPage_Season_Calendar.cMonthsName[i],0);
  626.             }
  627.  
  628.             i=i+1;
  629.         }
  630.         DoMonth(oPage_Season_Calendar.iCurrentMonth, oPage_Season_Calendar.iCurrentYear);
  631.     }
  632.     else if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
  633.     {
  634.         if(_iComponentID == -1)
  635.         {
  636.             // Destroy global join
  637.             vDestroyCalendarJoin();
  638.             Reset_Tool_Bar_Text();
  639.         }
  640.     }
  641.     return 1;
  642. }
  643.  
  644.  
  645.  
  646.  
  647. //----------------------------------------------------------------------------------------------------------------//
  648. //----------------------------------------------------------------------------------------------------------------//
  649. //Page_Season_Calendar Constructor
  650. //----------------------------------------------------------------------------------------------------------------//
  651. //----------------------------------------------------------------------------------------------------------------//
  652.  
  653. func i32x Page_Season_Calendar_Constructor ()
  654. {
  655.     // Retrieve current date
  656.     oPage_Season_Calendar.iCurrentMonth = g_oGameConfig.m_iMonth-1; //1..12 to 0..11
  657.     oPage_Season_Calendar.iCurrentYear = g_oGameConfig.m_iYear;
  658.  
  659.     oPage_Season_Calendar.szDayNames[0] = GetLocalizedFromGMKey(17);
  660.     oPage_Season_Calendar.szDayNames[1] = GetLocalizedFromGMKey(10);
  661.     oPage_Season_Calendar.szDayNames[2] = GetLocalizedFromGMKey(11);
  662.     oPage_Season_Calendar.szDayNames[3] = GetLocalizedFromGMKey(12);
  663.     oPage_Season_Calendar.szDayNames[4] = GetLocalizedFromGMKey(14);
  664.     oPage_Season_Calendar.szDayNames[5] = GetLocalizedFromGMKey(15);
  665.     oPage_Season_Calendar.szDayNames[6] = GetLocalizedFromGMKey(16);
  666.  
  667.     oPage_Season_Calendar.szMonthNames[0] = strncpy(GetLocalizedFromGMKey(18),3);
  668.     oPage_Season_Calendar.szMonthNames[1] = strncpy(GetLocalizedFromGMKey(19),3);
  669.     oPage_Season_Calendar.szMonthNames[2] = strncpy(GetLocalizedFromGMKey(20),3);
  670.     oPage_Season_Calendar.szMonthNames[3] = strncpy(GetLocalizedFromGMKey(21),3);
  671.     oPage_Season_Calendar.szMonthNames[4] = strncpy(GetLocalizedFromGMKey(22),3);
  672.     oPage_Season_Calendar.szMonthNames[5] = strncpy(GetLocalizedFromGMKey(23),3);
  673.     oPage_Season_Calendar.szMonthNames[6] = strncpy(GetLocalizedFromGMKey(24),3);
  674.     oPage_Season_Calendar.szMonthNames[7] = strncpy(GetLocalizedFromGMKey(25),3);
  675.     oPage_Season_Calendar.szMonthNames[8] = strncpy(GetLocalizedFromGMKey(26),3);
  676.     oPage_Season_Calendar.szMonthNames[9] = strncpy(GetLocalizedFromGMKey(27),3);
  677.     oPage_Season_Calendar.szMonthNames[10] = strncpy(GetLocalizedFromGMKey(28),3);
  678.     oPage_Season_Calendar.szMonthNames[11] = strncpy(GetLocalizedFromGMKey(29),3);
  679.  
  680.     // create page
  681.     oPage_Season_Calendar.iWindowID = InitObject(oPage_Season_Calendar.szName, oPage_Season_Calendar.oFunc.pcreate, oPage_Season_Calendar.oFunc.pevent);
  682.     SetStackEvents(oPage_Season_Calendar.iWindowID,GUI_Destroy| GUI_Char | GUI_KeyDown);
  683.  
  684.     return oPage_Season_Calendar.iWindowID;
  685. }
  686.  
  687.  
  688.  
  689.  
  690. //----------------------------------------------------------------------------------------------------------------//
  691. //----------------------------------------------------------------------------------------------------------------//
  692. //Page_Season_Calendar Destructor
  693. //----------------------------------------------------------------------------------------------------------------//
  694. //----------------------------------------------------------------------------------------------------------------//
  695.  
  696. func void Page_Season_Calendar_Destructor ()
  697. {
  698.     var i32x iLoop;
  699.  
  700.     Reset_Tool_Bar_Text();
  701.     // Destroy all page global join
  702.     vDestroyCalendarJoin();
  703.  
  704.     // Reinit component index
  705.     iLoop = 0;
  706.     while (iLoop < 31)
  707.     {
  708.         oPage_Season_Calendar.iDayObject[iLoop] = ID_NOT_CREATED;
  709.         iLoop = iLoop + 1;
  710.     }
  711.  
  712.     // Delete page
  713.     DeleteComponent(oPage_Season_Calendar.iWindowID);
  714.     oPage_Season_Calendar.iWindowID = ID_NOT_CREATED;
  715. }
  716.  
  717.  
  718.  
  719.  
  720. //----------------------------------------------------------------------------------------------------------------//
  721. //----------------------------------------------------------------------------------------------------------------//
  722. //Page_Season_Calendar Init member
  723. //----------------------------------------------------------------------------------------------------------------//
  724. //----------------------------------------------------------------------------------------------------------------//
  725.  
  726. func void Page_Season_Calendar_InitMembers ()
  727. {
  728.     oPage_Season_Calendar.szName            = "Page_Season_Calendar";
  729.     oPage_Season_Calendar.oFunc.pcreate        = Page_Season_Calendar_Create;
  730.     oPage_Season_Calendar.oFunc.pevent        = Page_Season_Calendar_Event;
  731.  
  732.     // Join_Index init
  733.     oPage_Season_Calendar.m_jStageID = 0;
  734.     oPage_Season_Calendar.m_jStageDate = 0;
  735.     oPage_Season_Calendar.m_jStageNum = 0;
  736.     oPage_Season_Calendar.m_jStageFollowedRestDay = 0;
  737.     oPage_Season_Calendar.m_jRaceDate = 0;
  738.     oPage_Season_Calendar.m_jRaceID = 0;
  739.     oPage_Season_Calendar.m_jRaceUCIClass = 0;
  740.     oPage_Season_Calendar.m_jRaceNameID = 0;
  741.     oPage_Season_Calendar.m_jStageName = 0;
  742.     
  743.     oPage_Season_Calendar.iMonthDays[0] = 31;    // janvier
  744.     oPage_Season_Calendar.iMonthDays[1] = 28;    // fevrier
  745.     oPage_Season_Calendar.iMonthDays[2] = 31;    // mars
  746.     oPage_Season_Calendar.iMonthDays[3] = 30;    // avril
  747.     oPage_Season_Calendar.iMonthDays[4] = 31;    // mai
  748.     oPage_Season_Calendar.iMonthDays[5] = 30;    // juin
  749.     oPage_Season_Calendar.iMonthDays[6] = 31;    // juillet
  750.     oPage_Season_Calendar.iMonthDays[7] = 31;    // aout
  751.     oPage_Season_Calendar.iMonthDays[8] = 30;    // septembre
  752.     oPage_Season_Calendar.iMonthDays[9] = 31;    // octobre
  753.     oPage_Season_Calendar.iMonthDays[10] = 30;    // novembre
  754.     oPage_Season_Calendar.iMonthDays[11] = 31;    // decembre
  755.  
  756.     oPage_Season_Calendar.iLeapDays[0] = 31;    // janvier
  757.     oPage_Season_Calendar.iLeapDays[1] = 29;    // fevrier
  758.     oPage_Season_Calendar.iLeapDays[2] = 31;    // mars
  759.     oPage_Season_Calendar.iLeapDays[3] = 30;    // avril
  760.     oPage_Season_Calendar.iLeapDays[4] = 31;    // mai
  761.     oPage_Season_Calendar.iLeapDays[5] = 30;    // juin
  762.     oPage_Season_Calendar.iLeapDays[6] = 31;    // juillet
  763.     oPage_Season_Calendar.iLeapDays[7] = 31;    // aout
  764.     oPage_Season_Calendar.iLeapDays[8] = 30;    // septembre
  765.     oPage_Season_Calendar.iLeapDays[9] = 31;    // octobre
  766.     oPage_Season_Calendar.iLeapDays[10] = 30;    // novembre
  767.     oPage_Season_Calendar.iLeapDays[11] = 31;    // decembre
  768.  
  769.     // UCI color
  770.     oPage_Season_Calendar.m_iNumValidColor = 12;
  771.  
  772.     
  773.     oPage_Season_Calendar.m_aUCIClassOrder[0] = 1;
  774.     oPage_Season_Calendar.m_aUCIClassOrder[1] = 8;
  775.     oPage_Season_Calendar.m_aUCIClassOrder[2] = 9;
  776.     oPage_Season_Calendar.m_aUCIClassOrder[3] = 10;
  777.     oPage_Season_Calendar.m_aUCIClassOrder[4] = 11;
  778.     oPage_Season_Calendar.m_aUCIClassOrder[5] = 2;
  779.     oPage_Season_Calendar.m_aUCIClassOrder[6] = 3;
  780.     oPage_Season_Calendar.m_aUCIClassOrder[7] = 4;
  781.     oPage_Season_Calendar.m_aUCIClassOrder[8] = 5;
  782.     oPage_Season_Calendar.m_aUCIClassOrder[9] = 6;
  783.  
  784.  
  785.     oPage_Season_Calendar.m_aUCIClassColor[0] = 0;
  786.     oPage_Season_Calendar.m_aUCIClassColor[1] = 0;
  787.     oPage_Season_Calendar.m_aUCIClassColor[2] = 5;
  788.     oPage_Season_Calendar.m_aUCIClassColor[3] = 6;
  789.     oPage_Season_Calendar.m_aUCIClassColor[4] = 7;
  790.     oPage_Season_Calendar.m_aUCIClassColor[5] = 8;
  791.     oPage_Season_Calendar.m_aUCIClassColor[6] = 9;
  792.     oPage_Season_Calendar.m_aUCIClassColor[7] = 0;
  793.     oPage_Season_Calendar.m_aUCIClassColor[8] = 1;
  794.     oPage_Season_Calendar.m_aUCIClassColor[9] = 2;
  795.     oPage_Season_Calendar.m_aUCIClassColor[10] = 3;
  796.     oPage_Season_Calendar.m_aUCIClassColor[11] = 4;
  797.     oPage_Season_Calendar.m_aUCIClassColor[12] = 0;
  798.  
  799.  
  800.  
  801.     oPage_Season_Calendar.m_a16UCIColor[0]    = MakeARGB(255,68,105,0);
  802.     oPage_Season_Calendar.m_a16UCIColor2[0] = MakeARGB(255,96,255,0);
  803.  
  804.     oPage_Season_Calendar.m_a16UCIColor[1]    = MakeARGB(255,68,136,0);
  805.     oPage_Season_Calendar.m_a16UCIColor2[1] = MakeARGB(255,96,255,0);
  806.  
  807.     oPage_Season_Calendar.m_a16UCIColor[2]    = MakeARGB(255,85,172,0);
  808.     oPage_Season_Calendar.m_a16UCIColor2[2] = MakeARGB(255,96,255,0);
  809.  
  810.     oPage_Season_Calendar.m_a16UCIColor[3]    = MakeARGB(255,107,216,0);
  811.     oPage_Season_Calendar.m_a16UCIColor2[3] = MakeARGB(255,96,255,0);
  812.  
  813.     oPage_Season_Calendar.m_a16UCIColor[4]    = MakeARGB(255,162,249,80);
  814.     oPage_Season_Calendar.m_a16UCIColor2[4] = MakeARGB(255,96,255,0);
  815.  
  816.  
  817.  
  818.  
  819.  
  820.     oPage_Season_Calendar.m_a16UCIColor[5]    = MakeARGB(255,231,101,26);
  821.     oPage_Season_Calendar.m_a16UCIColor2[5] = MakeARGB(255,255,255,0);
  822.  
  823.     oPage_Season_Calendar.m_a16UCIColor[6]    = MakeARGB(255,255,160,28);
  824.     oPage_Season_Calendar.m_a16UCIColor2[6] = MakeARGB(255,255,255,0);
  825.  
  826.     oPage_Season_Calendar.m_a16UCIColor[7]    = MakeARGB(255,255,190,55);
  827.     oPage_Season_Calendar.m_a16UCIColor2[7] = MakeARGB(255,255,255,0);
  828.  
  829.     oPage_Season_Calendar.m_a16UCIColor[8]    = MakeARGB(255,255,222,99);
  830.     oPage_Season_Calendar.m_a16UCIColor2[8] = MakeARGB(255,255,255,0);
  831.  
  832.     oPage_Season_Calendar.m_a16UCIColor[9]    = MakeARGB(255,251,232,161);
  833.     oPage_Season_Calendar.m_a16UCIColor2[9] = MakeARGB(255,255,255,0);
  834.  
  835.  
  836.  
  837.  
  838.     oPage_Season_Calendar.m_a16UCIColor[10] = MakeARGB(255,64,64,98);
  839.     oPage_Season_Calendar.m_a16UCIColor2[10] = MakeARGB(255,128,128,196);
  840.  
  841.  
  842.     oPage_Season_Calendar.m_a16UCIColor[11] = MakeARGB(255,64,64,98);
  843.     oPage_Season_Calendar.m_a16UCIColor2[11] = MakeARGB(255,128,128,196);
  844.  
  845.     oPage_Season_Calendar.m_a16UCIColor[12] = MakeARGB(255,128,98,128);
  846.     oPage_Season_Calendar.m_a16UCIColor2[12] = MakeARGB(255,255,196,255);
  847.  
  848.  
  849.     var i32x iLoop;
  850.     iLoop = 0;
  851.     while (iLoop < 31)
  852.     {
  853.         oPage_Season_Calendar.iDayObject[iLoop] = ID_NOT_CREATED;
  854.         iLoop = iLoop + 1;
  855.     }
  856.  
  857.     iLoop = 0;
  858.     while (iLoop < 12)
  859.     {
  860.         oPage_Season_Calendar.cMonthsName[iLoop] = ID_NOT_CREATED;
  861.         iLoop = iLoop + 1;
  862.     }
  863.  
  864.     oPage_Season_Calendar.iWindowID = ID_NOT_CREATED;
  865.     oPage_Season_Calendar.iInfoCount = 0;
  866. }
  867.