home *** CD-ROM | disk | FTP | other *** search
Text File | 2001-05-31 | 48.1 KB | 1,486 lines |
- var i32x g_i_RefreshLoop = 10; //Panel is refreshed every 10 GUI update (60 hz) so one panel refresh loop is 1/6 s
- var i32x g_i_TimeLoopConvCoef = 6;//invert of 1/6 s
- var i32x g_i_AttackWaitNumLoop = 100;//16s
- var i32x g_i_EatWaitNumLoop = 120;//20s
- var f32x g_f_MinGlycoToStartAttack = 15.0;
- var f32x g_f_MinGlycoToStopAttack = 1.0;
-
- //inrace client interface management
- func void SetCyclistAttackButtonState(i32x _iCyclistLocalId,i32x _iButtonState)
- {
- g_oMenuServer.m_oServer << mAttack (_iCyclistLocalId,_iButtonState);
- }
- func void SetCyclistSprintCheckBoxState(i32x _iCyclistLocalId,i32x _iButtonState)
- {
- g_oMenuServer.m_oServer << mSprint (_iCyclistLocalId,_iButtonState);
- }
- func void SetCyclistTakeRelayCheckBoxState(i32x _iCyclistLocalId,i32x _iButtonState)
- {
- g_oMenuServer.m_oServer << mRelay (_iCyclistLocalId,_iButtonState);
- }
- func void SetCyclistSpeedSliderValue(i32x _iCyclistLocalId,f32x _fSpeeValue)
- {
- g_oMenuServer.m_oServer << mSpeed (_iCyclistLocalId,_fSpeeValue);
- }
- func void AIBreak(i32x _iPreRaceCyclist)
- {
- g_oMenuServer.m_oServer << mAIBreak (_iPreRaceCyclist);
- }
- func void AIWithdrawal(i32x _iPreRaceCyclist)
- {
- g_oMenuServer.m_oServer << mAIWithdrawal(_iPreRaceCyclist);
- }
- func void AIAllWithdrawal()
- {
- g_oMenuServer.m_oServer << mAIAllwithdrawal();
- }
- func void AIFall(i32x _iPreRaceCyclist)
- {
- g_oMenuServer.m_oServer << mAIFall(_iPreRaceCyclist);
- }
- func void SetCyclistAutoCheckBoxState(i32x _iCyclistLocalId,i32x _iButtonState)
- {
- g_oMenuServer.m_oServer << mAuto (_iCyclistLocalId,_iButtonState);
- }
- func void SetCyclistEatRation(i32x _iCyclistLocalId)
- {
- g_oMenuServer.m_oServer << mRation (_iCyclistLocalId);
- }
-
-
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //SendInterface func function called from the menuserver
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func void CSendInterface_Null(i32x _iValue,i32x _iValue2)
- {
- }
- func void CSendInterface(i32x _iValue,i32x _iValue2)
- {
- var i32x iPreRaceTeamIndex,iCyclistInTeamIndex,iTempValue,bAuto;
- var component pOldComponent;
-
- /*
- #define DEF_INTERFACE_PRERACETEAM_INDEX_MASK 0xFE000000
- #define DEF_INTERFACE_PRERACETEAM_INDEX_OFFSET 25
- #define DEF_INTERFACE_CYCLIST_INTEAMINDEX_MASK 0x01FE0000
- #define DEF_INTERFACE_CYCLIST_INTEAMINDEX_OFFSET 17
- */
-
- //print("Receive interface:");
- //print("\n PreRaceTeamID:");
- iPreRaceTeamIndex=_iValue/33554432;
- //print(itoa(iPreRaceTeamIndex));
-
- //print("\n CyclistIndexInTeam:");
- iCyclistInTeamIndex=(_iValue&33423360)/131072;
- //print(itoa(iCyclistInTeamIndex));
-
- if (iPreRaceTeamIndex!=g_oUser.m_iMyInRaceTeamID)
- {
- print("\n Error : Bad iPreRaceTeamIndex in SendInterface \n");
- }
- if ((iCyclistInTeamIndex<0)||(iCyclistInTeamIndex>8))
- {
- print("\n Error : Bad iCyclistInTeamIndex in SendInterface \n");
- }
-
- /*
-
- #define DEF_INTERFACE_ATTACK_MASK 0x0001C000
- #define DEF_INTERFACE_ATTACK_OFFSET 14
- #define DEF_INTERFACE_SPRINT_MASK 0x00003000
- #define DEF_INTERFACE_SPRINT_OFFSET 12
- #define DEF_INTERFACE_TAKERELAY_MASK 0x00000C00
- #define DEF_INTERFACE_TAKERELAY_OFFSET 10
- #define DEF_INTERFACE_SPEED_MASK 0x000003FF
- #define DEF_INTERFACE_SPEED_OFFSET 0
- */
-
- if(oControlPanel.oFunc.pevent)
- {
- pOldComponent = GetParserComponent();
-
- SetParserComponent(oTeamPanel.PanelComponent);
- SetParserComponent(GetObject(oTeamPanel.iPanelID[iCyclistInTeamIndex]));
- bAuto=Geti32x(oControlPanel.i_m_bAuto);
-
- if(bAuto)
- {
- if (_iValue&8192)
- {
- SetComponentEnableStatus(oControlPanel.iSprintID,true);
- SetCheckboxState(oControlPanel.iSprintID,true);
- Seti32x(oControlPanel.i_m_iSprintState,1);
- }
- else if (_iValue&4096)
- {
- SetComponentEnableStatus(oControlPanel.iSprintID,true);
- SetCheckboxState(oControlPanel.iSprintID,false);
- Seti32x(oControlPanel.i_m_iSprintState,0);
- }
- else
- {
- SetComponentEnableStatus(oControlPanel.iSprintID,false);
- SetCheckboxState(oControlPanel.iSprintID,false);
- Seti32x(oControlPanel.i_m_iSprintState,0);
- }
-
- //Relay
- if (_iValue&2048)
- {
- //SetContainerMap(oControlPanel.iRelayID,a3_t_relaytake[2]);
- }
- else if (_iValue&1024)
- {
- //SetContainerMap(oControlPanel.iRelayID,a3_t_relaytake[1]);
- }
- else
- {
- //SetContainerMap(oControlPanel.iRelayID,a3_t_relaytake[0]);
- }
-
- //Speed
- iTempValue=(_iValue&1023);
- if(iTempValue>=128)
- {
- print("\n Error: Unknown speed value.");
- print(itoa(iTempValue));
- print("\n");
- }
- else
- {
- Seti32x(oControlPanel.i_m_iEffort,iTempValue);
- }
-
- //Attack
- if ((_iValue&114688)/16384)
- {
- SetComponentEnableStatus(oControlPanel.iAttackID,true);
- SetCheckboxState(oControlPanel.iAttackID,true);
- }
- else
- {
- if(GetCyclistGlycogen(Geti32x(oControlPanel.i_m_iPreRaceCyclistID))>=g_f_MinGlycoToStartAttack)
- {
- SetComponentEnableStatus(oControlPanel.iAttackID,true);
- SetCheckboxState(oControlPanel.iAttackID,false);
- }
- else
- {
- SetComponentEnableStatus(oControlPanel.iAttackID,false);
- }
- }
- /*
- #define DEF_INTERFACE_NB_RATIONS_MASK 0x00000003
- #define DEF_INTERFACE_NB_RATION_OFFSET 0
- #define DEF_INTERFACE_EATING_RATION_TIME_MASK 0x000001FC
- #define DEF_INTERFACE_EATING_RATION_TIME_OFFSET 2
- #define DEF_INTERFACE_EATING_RATION_TIME_MASK 0x000001FC
- #define DEF_INTERFACE_ATTACKING_TIME_OFFSET 9
- #define DEF_INTERFACE_ATTACKING_TIME_MASK 0x0000FE00
- #define DEF_INTERFACE_NOTUSED_MASK 0xFFFF0000
- */
- //num rations
- iTempValue=(_iValue2&3);
- if(iTempValue>3)
- iTempValue=3;
- if(iTempValue<0)
- iTempValue=0;
- Seti32x(oControlPanel.i_m_iNbBouf,iTempValue);
- SetContainerMap(oControlPanel.iBoufID,a4_t_bouffe[iTempValue]);
-
- //eating time
- iTempValue=((_iValue2&508)/4);
- iTempValue=iTempValue*g_i_TimeLoopConvCoef;
- if(iTempValue==0)
- {
- Seti32x(oControlPanel.i_m_iEatWaitLoop,0);
- SetCheckboxState(oControlPanel.iBoufID, false);
- }
- else if(iTempValue>=(g_i_EatWaitNumLoop-1))
- {
- Seti32x(oControlPanel.i_m_iEatWaitLoop,2);
- SetCheckboxState(oControlPanel.iBoufID, true);
- }
- else
- {
- Seti32x(oControlPanel.i_m_iEatWaitLoop,(g_i_EatWaitNumLoop-iTempValue));
- SetCheckboxState(oControlPanel.iBoufID, true);
- }
-
- //attacking time
- iTempValue=((_iValue2&65024)/512);
- iTempValue=iTempValue*g_i_TimeLoopConvCoef;
- if(iTempValue==0)
- {
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,0);
- Seti32x(oControlPanel.i_m_bAttack,0);
- }
- else if(iTempValue>=(g_i_AttackWaitNumLoop-1))
- {
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,2);
- Seti32x(oControlPanel.i_m_bAttack,1);
- }
- else
- {
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,(g_i_AttackWaitNumLoop-iTempValue));
- Seti32x(oControlPanel.i_m_bAttack,1);
- }
- }
- SetParserComponent(pOldComponent);
- }
- }
-
- func void SetManualMode()
- {
- Seti32x(oControlPanel.i_m_bAuto,0);
- if(GetCheckboxState(oControlPanel.iAutoID)==true)
- SetCheckboxState(oControlPanel.iAutoID,false);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
- }
-
- func void SetAutomaticMode()
- {
- Seti32x(oControlPanel.i_m_bAuto,1);
- if(GetCheckboxState(oControlPanel.iAutoID)==false)
- SetCheckboxState(oControlPanel.iAutoID,true);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
- }
-
- // State func for ingame button
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func void ControlPanel_State (i32x _iComponentID,i32x _iState)
- {
- if(_iState & GUI_State_Enabled)
- {
- if(_iState & GUI_State_Checked)
- {
- SetContainerSprite(_iComponentID, 2, 0);
- }
- else
- {
- SetContainerSprite(_iComponentID, 0, 0);
- }
- }
- else
- {
- SetContainerSprite(_iComponentID, 1, 0);
- }
- }
- func void ButtonAttack_State (i32x _iComponentID,i32x _iState)
- {
- if(_iState & GUI_State_Enabled)
- {
- if(_iState & GUI_State_Checked)
- {
- SetContainerSprite(_iComponentID, 2, 0);
- }
- else
- {
- if(_iState & GUI_State_Activated)
- SetContainerSprite(_iComponentID, 1, 0);
- else
- SetContainerSprite(_iComponentID, 0, 0);
- }
- }
- else
- {
- SetContainerSprite(_iComponentID, 3, 0);
- }
- if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
- {
- if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
- {
- Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
- oTeamPanel.m_poUnderMousePanel = GetParserComponent();
- }
- }
- else
- {
- if(oTeamPanel.m_poUnderMousePanel == GetParserComponent())
- {
- if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
- Reset_Tool_Bar_Text();
- }
- }
- }
- func void ButtonIA_State (i32x _iComponentID,i32x _iState)
- {
- if(_iState & GUI_State_Enabled)
- {
- if(_iState & GUI_State_Checked)
- {
- if(_iState & GUI_State_Activated)
- SetContainerSprite(_iComponentID, 1, 0);
- else
- SetContainerSprite(_iComponentID, 0, 0);
- }
- else
- {
- if(_iState & GUI_State_Activated)
- SetContainerSprite(_iComponentID, 3, 0);
- else
- SetContainerSprite(_iComponentID, 2, 0);
- }
- }
- else
- {
- SetContainerSprite(_iComponentID, 2, 0);
- }
- if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
- {
- if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
- {
- Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
- oTeamPanel.m_poUnderMousePanel = GetParserComponent();
- }
- }
- else
- {
- if(oTeamPanel.m_poUnderMousePanel == GetParserComponent())
- {
- if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
- Reset_Tool_Bar_Text();
- }
- }
- }
- func void ButtonSprint_State (i32x _iComponentID,i32x _iState)
- {
- if(_iState & GUI_State_Enabled)
- {
- if(_iState & GUI_State_Checked)
- {
- SetContainerSprite(_iComponentID, 1, 0);
- }
- else
- {
- SetContainerSprite(_iComponentID, 2, 0);
- }
- }
- else
- {
- SetContainerSprite(_iComponentID, 0, 0);
- }
- if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
- {
- if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
- {
- Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
- oTeamPanel.m_poUnderMousePanel = GetParserComponent();
- }
- }
- else
- {
- if(oTeamPanel.m_poUnderMousePanel == GetParserComponent())
- {
- if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
- Reset_Tool_Bar_Text();
- }
- }
- }
-
- func void ButtonBouf_State (i32x _iComponentID,i32x _iState)
- {
- if(_iState & GUI_State_Enabled)
- {
- if(_iState & GUI_State_Checked)
- {
- SetContainerSprite(_iComponentID, 1, 0);
- }
- else
- {
- SetContainerSprite(_iComponentID, 0, 0);
- }
- }
- else
- {
- SetContainerSprite(_iComponentID, 0, 0);
- }
- if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
- {
- if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
- {
- Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
- oTeamPanel.m_poUnderMousePanel = GetParserComponent();
- }
- }
- else
- {
- if(oTeamPanel.m_poUnderMousePanel == GetParserComponent())
- {
- if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
- Reset_Tool_Bar_Text();
- }
- }
- }
-
- func void CyclistName_State (i32x _iComponentID,i32x _iState)
- {
- if(_iState & GUI_State_Enabled)
- {
- if(_iState & GUI_State_Checked)
- {
- SetContainerColor(_iComponentID, c_ActivatedText);
- }
- else
- {
- if(_iState & GUI_State_UnderMouse)
- SetContainerColor(_iComponentID, c_UnderMouseText);
- else
- SetContainerColor(_iComponentID, c_EnabledText);
- }
- }
- else
- {
- SetContainerColor(_iComponentID, c_DisabledText);
- }
- if((_iState & GUI_State_UnderMouse)&&(GetContainerHelpIndex(_iComponentID)!=0))
- {
- if(ToolBar_GetHelpStringID() != GetContainerHelpIndex(_iComponentID))
- {
- Set_Tool_Bar_TextID(GetContainerHelpIndex(_iComponentID));
- oTeamPanel.m_poUnderMousePanel = GetParserComponent();
- }
- }
- else
- {
- if(oTeamPanel.m_poUnderMousePanel == GetParserComponent())
- {
- if(ToolBar_GetHelpStringID() == GetContainerHelpIndex(_iComponentID))
- Reset_Tool_Bar_Text();
- }
- }
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //ControlPanel Create func
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func void CreateControlPanel ()
- {
- var i32x i;
-
- SetObjectMembersNumber(19);
-
- // Members Index init
- oControlPanel.i_m_iCyclistInTeamID=0;
- Seti32x(oControlPanel.i_m_iCyclistInTeamID,oControlPanel.iCyclistInTeamID);
-
- oControlPanel.i_m_iEffort=1;
- Seti32x(oControlPanel.i_m_iEffort,50);
-
- oControlPanel.i_m_iEffortSent=2;
- Seti32x(oControlPanel.i_m_iEffortSent,50);
-
- oControlPanel.i_m_iAbandonState=3;
- Seti32x(oControlPanel.i_m_iAbandonState,0);
-
- oControlPanel.i_m_iAbandonStateSent=4;
- Seti32x(oControlPanel.i_m_iAbandonStateSent,0);
-
- oControlPanel.i_m_iAttackWaitLoop=5;
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,0);
-
- oControlPanel.i_m_iSprintState=6;
- Seti32x(oControlPanel.i_m_iSprintState,0);
-
- oControlPanel.i_m_iSprintStateSent=7;
- Seti32x(oControlPanel.i_m_iSprintStateSent,0);
-
- oControlPanel.i_m_iRelayState=8;
- Seti32x(oControlPanel.i_m_iRelayState,0);
-
- oControlPanel.i_m_iRelayStateSent=9;
- Seti32x(oControlPanel.i_m_iRelayStateSent,0);
-
- oControlPanel.i_m_bHasToSendData=10;
- Seti32x(oControlPanel.i_m_bHasToSendData,0);
-
- oControlPanel.i_m_iSendDataWaitLoop=11;
- Seti32x(oControlPanel.i_m_iSendDataWaitLoop,0);
-
- oControlPanel.i_m_bAuto=12;
- Seti32x(oControlPanel.i_m_bAuto,1);
-
- oControlPanel.i_m_bAutoSent=13;
- Seti32x(oControlPanel.i_m_bAutoSent,1);
-
- oControlPanel.i_m_iPreRaceCyclistID=14;
- Seti32x(oControlPanel.i_m_iPreRaceCyclistID,oControlPanel.iPreRaceCyclistID);
-
- oControlPanel.i_m_iEatWaitLoop=15;
- Seti32x(oControlPanel.i_m_iEatWaitLoop,0);
-
- oControlPanel.i_m_iNbBouf=16;
- Seti32x(oControlPanel.i_m_iNbBouf,3);
-
- oControlPanel.i_m_bAttack=17;
- Seti32x(oControlPanel.i_m_bAttack,0);
-
- oControlPanel.i_m_bAttackSent=18;
- Seti32x(oControlPanel.i_m_bAttackSent,0);
-
- SetComponentNumber(24);
-
- // ****************************************
- // Gauge behind background
-
- // *** Tire gauge ***
- i = InitContainer(tCommonTableBorder); // Tire gauge background
- SetComponentPosition(i, 29, 24);
- SetContainerSize(i, 47, 6);
- SetContainerColor(i,c_BackGlyco);
- SetEvents(i,GUI_NoEvent);
-
- oControlPanel.iTireBarID = InitContainer(tCommonTableBorder); // Tire gauge forground (green)
- SetComponentPosition(oControlPanel.iTireBarID, 29, 24);
- SetContainerSize(oControlPanel.iTireBarID, 47, 6);
- SetContainerColor(oControlPanel.iTireBarID,c_Energy);
- SetEvents(oControlPanel.iTireBarID,GUI_NoEvent);
-
- // *** Glyco gauge ***
- i = InitContainer(tCommonTableBorder); // Boost gauge background
- SetComponentPosition(i, 29, 33);
- SetContainerSize(i, 47, 6);
- SetContainerColor(i,c_BackGlyco);
-
- oControlPanel.iBoostBarID = InitContainer(tCommonTableBorder);
- SetComponentPosition(oControlPanel.iBoostBarID, 29, 33);
- SetContainerSize(oControlPanel.iBoostBarID, 47, 6);
- SetContainerColor(oControlPanel.iBoostBarID,c_Glyco); // Blue
-
- // ************************
- // Control panel background
- oControlPanel.iBackGroundID = InitRadioButton(tControlPanel);
- SetContainerStateFunc(oControlPanel.iBackGroundID,ControlPanel_State);
- // ************************
-
- // *** Cyclist name ***
- oControlPanel.iNameID = InitRadioButton(tFontArial);
- SetContainerStateFunc(oControlPanel.iNameID,CyclistName_State);
- SetComponentSize(oControlPanel.iNameID,95,16);
- SetComponentClipper(oControlPanel.iNameID,0,0,78,16);
- SetContainerScaleX(oControlPanel.iNameID,0.9);
- SetComponentPosition(oControlPanel.iNameID, 15, 3);
- SetContainerText(oControlPanel.iNameID, oControlPanel.szName);
- SetContainerOffset(oControlPanel.iNameID,-1.5);
-
- oControlPanel.iSprintID = InitRadioButton(tBtnSprint);
- SetContainerStateFunc(oControlPanel.iSprintID, ButtonSprint_State);
- SetContainerHelpIndex(oControlPanel.iSprintID,1478);
- SetComponentPosition(oControlPanel.iSprintID, 3, 16);
-
- oControlPanel.iRelayID = InitButton(a3_t_relaytake[0]);
- SetContainerStateFunc(oControlPanel.iRelayID, ButtonState);
- SetContainerHelpIndex(oControlPanel.iRelayID,1479);
- SetComponentPosition(oControlPanel.iRelayID, 54, 43);
-
- // *** Speed caption ***
- oControlPanel.iSpeedValueID = InitContainer(tFontArial);
- SetContainerOffset(oControlPanel.iSpeedValueID,-1);
- SetContainerScale(oControlPanel.iSpeedValueID, 1.1, 1.3);
- SetEvents(oControlPanel.iSpeedValueID,GUI_NoEvent);
- SetComponentPosition(oControlPanel.iSpeedValueID, 96, 7);
- SetContainerText(oControlPanel.iSpeedValueID,"0");
-
- // *** Heart rate caption ***
- // Heart rate is hidden by default
- oControlPanel.iHRValueID = InitContainer(tFontArial);
- SetContainerOffset(oControlPanel.iHRValueID,-1.1);
- SetContainerScale(oControlPanel.iHRValueID, 1.0, 1.3);
- SetEvents(oControlPanel.iHRValueID,GUI_NoEvent);
- SetComponentPosition(oControlPanel.iHRValueID, 96, 7);
- SetContainerText(oControlPanel.iHRValueID,"0");
- SetComponentVisibleStatus(oControlPanel.iHRValueID,false);
-
- oControlPanel.iBoufID=InitRadioButton(a4_t_bouffe[3]);
- SetContainerStateFunc(oControlPanel.iBoufID,ButtonBouf_State);
- SetContainerHelpIndex(oControlPanel.iBoufID,1482);
- SetComponentPosition(oControlPanel.iBoufID,77, 43);
-
-
-
- oControlPanel.iGroupNameID = InitContainer(tFontArialItalique);
- SetContainerOffset(oControlPanel.iGroupNameID,-2);
- SetComponentPosition(oControlPanel.iGroupNameID, 2,3);
- if (GetInRaceMode()==G_iRaceModeNormal )
- {
- SetContainerText(oControlPanel.iGroupNameID,GetGroupNameFromPreRaceCyclistIndex(Geti32x(oControlPanel.i_m_iPreRaceCyclistID)));
- }
- else if (GetInRaceMode()==G_iRaceModeTimeTrial)
- {
- SetContainerText(oControlPanel.iGroupNameID,itoa(Geti32x(oControlPanel.i_m_iCyclistInTeamID)+1));
- }
- else
- {
- SetContainerText(oControlPanel.iGroupNameID,g_szNull);
- }
- SetContainerScale(oControlPanel.iGroupNameID,0.90,0.90);
- SetEvents(oControlPanel.iGroupNameID,GUI_NoEvent);
-
-
- oControlPanel.iAutoID = InitCheckBox(tBtnIA);
- SetContainerStateFunc(oControlPanel.iAutoID, ButtonIA_State);
- SetContainerHelpIndex(oControlPanel.iAutoID,1483);
- SetComponentPosition(oControlPanel.iAutoID, 29, 43);
- SetCheckboxState(oControlPanel.iAutoID,1);
-
- // *** Attack radio button ***
- oControlPanel.iAttackID = InitRadioButton(tBtnAttack);
- SetContainerStateFunc(oControlPanel.iAttackID,ButtonAttack_State);
- SetContainerHelpIndex(oControlPanel.iAttackID,1475);
- SetComponentPosition(oControlPanel.iAttackID,0,37);
-
-
- // Heart rate checkbox
- oControlPanel.iHeartRateCB = InitCheckBox(tBtnHeart);
- SetContainerStateFunc(oControlPanel.iHeartRateCB,CheckboxState);
- SetContainerHelpIndex(oControlPanel.iHeartRateCB,1476);
- SetComponentPosition(oControlPanel.iHeartRateCB, 79, 25);
-
- // *********************
- // *** Effort slider ***
- // *********************
- oControlPanel.iEffortID = InitCheckBox(tFontArial);
- SetContainerHelpIndex(oControlPanel.iEffortID,1485);
- SetContainerStateFunc(oControlPanel.iEffortID,CyclistName_State);
- SetComponentPosition(oControlPanel.iEffortID, 96, 28);
- SetContainerScale(oControlPanel.iEffortID, 0.8, 0.8);
- SetContainerText(oControlPanel.iEffortID,"0");
- SetComponentSize(oControlPanel.iEffortID,24,11);
- // slider color
- oControlPanel.iSliderColorID = InitContainer(tCommonTableBorder);
- SetContainerSize(oControlPanel.iSliderColorID,86,4);
- SetComponentPosition(oControlPanel.iSliderColorID,33,50);
- SetEvents(oControlPanel.iSliderColorID,GUI_NoEvent);
- // slider back
- oControlPanel.iSliderBackID = InitContainer(tEffortSlider);
- SetContainerSprite(oControlPanel.iSliderBackID,1,0);
- SetComponentPosition(oControlPanel.iSliderBackID,29,44);
- SetEvents(oControlPanel.iSliderBackID,GUI_NoEvent);
- // slider
- oControlPanel.iSliderID = InitSlide(tEffortSlider,0,100,92,1,0);
- SetComponentPosition(oControlPanel.iSliderID,31,45);
- SetContainerStateFunc(oControlPanel.iSliderID,NullButtonState);
-
- // SLider are hidden by default
- SetComponentVisibleStatus(oControlPanel.iSliderID,false);
- SetComponentVisibleStatus(oControlPanel.iSliderBackID,false);
- SetComponentVisibleStatus(oControlPanel.iSliderColorID,false);
-
- AutoResize();
- }
-
- func void SendMode()
- {
- if(Geti32x(oControlPanel.i_m_bAuto)!=Geti32x(oControlPanel.i_m_bAutoSent))
- {
- SetCyclistAutoCheckBoxState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_bAuto));
- Seti32x(oControlPanel.i_m_bAutoSent,Geti32x(oControlPanel.i_m_bAuto));
-
- if(Geti32x(oControlPanel.i_m_bAuto)==0)
- {
- SetCyclistSpeedSliderValue(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iEffort));
- Seti32x(oControlPanel.i_m_iEffortSent,Geti32x(oControlPanel.i_m_iEffort));
-
- SetCyclistTakeRelayCheckBoxState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iRelayState));
- Seti32x(oControlPanel.i_m_iRelayStateSent,Geti32x(oControlPanel.i_m_iRelayState));
-
- SetCyclistSprintCheckBoxState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iSprintState));
- Seti32x(oControlPanel.i_m_iSprintStateSent,Geti32x(oControlPanel.i_m_iSprintState));
-
- SetCyclistAttackButtonState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_bAttack));
- Seti32x(oControlPanel.i_m_bAttackSent,Geti32x(oControlPanel.i_m_bAttack));
- }
- }
- }
- func void vPanel_UpdateEffort(i32x _iValue)
- {
- var f32x f;
- var i32x iColor;
- //Effort
- SetContainerText(oControlPanel.iEffortID,itoa(_iValue));
- ResizeComponent(oControlPanel.iEffortID);
- SetComponentPositionX(oControlPanel.iEffortID,116-GetComponentWidth(oControlPanel.iEffortID));
- SetSliderValue(oControlPanel.iSliderID,_iValue);
- if(_iValue==0)
- {
- iColor = c_Black;
- }
- else if(_iValue<50)
- {
- f = _iValue;
- f = f / 50.0;
- iColor = ColorLERP(c_Green,c_Yellow,f);
- }
- else
- {
- f = _iValue-50;
- f = f / 50.0;
- iColor = ColorLERP(c_Yellow,c_Red,f);
- }
- SetContainerColor(oControlPanel.iSliderColorID,iColor);
- }
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //ControlPanel Event func
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func i32x ControlPanel (i32x _iComponentID,i32x _iEvent)
- {
- if(_iComponentID == -1)
- {
- if(_iEvent == GUI_COMPONENT_DISABLED)
- {
- SetContainerText(oControlPanel.iSpeedValueID,"0");
- SetContainerText(oControlPanel.iEffortID,"0");
- SetContainerText(oControlPanel.iHRValueID,"0");
- }
- if(_iEvent == GUI_COMPONENT_ENABLED)
- {
- // Disable sprint on activate panel
- SetComponentEnableStatus(oControlPanel.iSprintID,false);
- SetComponentEnableStatus(oControlPanel.iBoufID,true);
- SetComponentEnableStatus(oControlPanel.iAttackID,false);
- }
- if(_iEvent == GUI_PANELCLICK)
- {
- // Unselect panel
- SetCheckboxState(oControlPanel.iBackGroundID,false);
- SetCheckboxState(oControlPanel.iNameID,false);
- }
- else if(_iEvent == GUI_COMPONENT_REFRESH )
- {
- var i32x iPreRaceCyclistIndex,iSpeed,iEffort,bCanSprint,iRaceSpeed;
- var f32x fTire,fBoost,fStrain,fGlycogen;
-
- //Refresh gauges of the control panel
- iPreRaceCyclistIndex = Geti32x(oControlPanel.i_m_iPreRaceCyclistID);
-
- //Race speed set by the client
- iRaceSpeed=GetCyclistRaceSpeed(iPreRaceCyclistIndex);
-
- iEffort = Geti32x(oControlPanel.i_m_iEffort);
- //Effort
- vPanel_UpdateEffort(iEffort);
-
- //Jauge fatigue
- fTire = 100.0 - GetCyclistEnergy(iPreRaceCyclistIndex);
- SetComponentClipper(oControlPanel.iTireBarID, 0, 0, 47.0 - (fTire * 47.0) / 100.0, 6.0);
-
- //Boost bar
- fGlycogen = GetCyclistGlycogen(iPreRaceCyclistIndex);
- fBoost = 160.0 - fGlycogen;
- SetComponentClipper(oControlPanel.iBoostBarID, 0, 0, 47.0 - (fBoost * 47.0) / 160.0, 6.0);
-
- //Speed figures
- SetContainerText(oControlPanel.iSpeedValueID,itoa(GetCyclistSpeedValue(iPreRaceCyclistIndex)));
- ResizeComponent(oControlPanel.iSpeedValueID);
- SetComponentPositionX(oControlPanel.iSpeedValueID,116-GetComponentWidth(oControlPanel.iSpeedValueID));
-
- //Heart rate figures
- SetContainerText(oControlPanel.iHRValueID,itoa(GetCyclistHRValue(iPreRaceCyclistIndex)));
- ResizeComponent(oControlPanel.iHRValueID);
- SetComponentPositionX(oControlPanel.iHRValueID,116-GetComponentWidth(oControlPanel.iHRValueID));
-
- //test if the panel has not been desactivated
- if(oRace.a9_bControlPanelActivated[Geti32x(oControlPanel.i_m_iCyclistInTeamID)]!=0)
- {
- SetComponentEnableStatus(oControlPanel.iBackGroundID,true);
- SetComponentEnableStatus(oControlPanel.iNameID,true);
- if(iPreRaceCyclistIndex == GetActiveCyclistPreRaceID())
- {
- if(oTeamPanel.m_iSelectedCyclistInTeam != Geti32x(oControlPanel.i_m_iCyclistInTeamID))
- {
- oTeamPanel.m_iSelectedCyclistInTeam = Geti32x(oControlPanel.i_m_iCyclistInTeamID);
- PushEvent(GUI_PANELCLICK);
- }
- SetCheckboxState(oControlPanel.iNameID, true);
- SetCheckboxState(oControlPanel.iBackGroundID, true);
- }
- else
- {
- if(oTeamPanel.m_iSelectedCyclistInTeam == Geti32x(oControlPanel.i_m_iCyclistInTeamID))
- {
- oTeamPanel.m_iSelectedCyclistInTeam = -1;
- PushEvent(GUI_PANELRESET);
- }
- SetCheckboxState(oControlPanel.iNameID, false);
- SetCheckboxState(oControlPanel.iBackGroundID, false);
- }
- }
-
- // Refresh group name
- if (GetInRaceMode()==G_iRaceModeNormal)
- {
- SetContainerText(oControlPanel.iGroupNameID,GetGroupNameFromPreRaceCyclistIndex(Geti32x(oControlPanel.i_m_iPreRaceCyclistID)));
- }
- else if(GetInRaceMode()==G_iRaceModeTimeTrial)
- {
- SetContainerText(oControlPanel.iGroupNameID,itoa(Geti32x(oControlPanel.i_m_iCyclistInTeamID)+1));
- }
- else
- {
- SetContainerText(oControlPanel.iGroupNameID,g_szNull);
- }
-
- if (Geti32x(oControlPanel.i_m_bAuto)==0)
- {
- //test if the cyclist can sprint
- bCanSprint=GetCyclistCanSprint(iPreRaceCyclistIndex);
- if((bCanSprint)&&(GetInRaceMode()==G_iRaceModeNormal))
- {
- if((GetComponentEnableStatus(oControlPanel.iSprintID)==false)&&(fGlycogen>=g_f_MinGlycoToStartAttack)&&(Geti32x(oControlPanel.i_m_iEatWaitLoop)==0))
- {
- SetComponentEnableStatus(oControlPanel.iSprintID,true);
- }
- else if ((GetComponentEnableStatus(oControlPanel.iSprintID)==true)&&(fGlycogen<=g_f_MinGlycoToStopAttack))
- {
- SetComponentEnableStatus(oControlPanel.iSprintID,false);
- }
- }
- else
- {
- if(GetComponentEnableStatus(oControlPanel.iSprintID)==true)
- {
- SetComponentEnableStatus(oControlPanel.iSprintID,false);
- if((Geti32x(oControlPanel.i_m_iSprintState)!=0)||(Geti32x(oControlPanel.i_m_iSprintStateSent)!=0))
- {
- Seti32x(oControlPanel.i_m_iSprintState,0);
- Seti32x(oControlPanel.i_m_iSprintStateSent,0);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
- }
- }
- }
-
- //test if the cyclist can attack
- if((GetComponentEnableStatus(oControlPanel.iAttackID)==false)
- &&(fGlycogen>=g_f_MinGlycoToStartAttack)
- &&(Geti32x(oControlPanel.i_m_iEatWaitLoop)==0)
- &&(GetCheckboxState(oControlPanel.iSprintID)==false))
- {
- SetComponentEnableStatus(oControlPanel.iAttackID,true);
- }
- else if ((GetComponentEnableStatus(oControlPanel.iAttackID)==true)&&(fGlycogen<=g_f_MinGlycoToStopAttack))
- {
- SetCheckboxState(oControlPanel.iAttackID, false);
- SetComponentEnableStatus(oControlPanel.iAttackID,false);
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,0);
- Seti32x(oControlPanel.i_m_bAttack,0);
- }
-
- //test if the cyclist can eat
- if((GetComponentEnableStatus(oControlPanel.iBoufID)==false)
- &&(Geti32x(oControlPanel.i_m_iAttackWaitLoop)==0)
- &&(GetCheckboxState(oControlPanel.iSprintID)==false))
- {
- SetComponentEnableStatus(oControlPanel.iBoufID,true);
- }
-
- //send attack data if manual mode is active
- if (Geti32x(oControlPanel.i_m_iAttackWaitLoop))
- {
- if (Geti32x(oControlPanel.i_m_iAttackWaitLoop)==1)
- {
- //Go to manual mode
- SendMode();
-
- //Send do not sprint if not done yet
- if (Geti32x(oControlPanel.i_m_iSprintState)!=Geti32x(oControlPanel.i_m_iSprintStateSent))
- {
- SetCyclistSprintCheckBoxState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iSprintState));
- Seti32x(oControlPanel.i_m_iSprintStateSent,Geti32x(oControlPanel.i_m_iSprintState));
- }
-
- //Then send the attack to the server
- if(Geti32x(oControlPanel.i_m_bAttack)!=Geti32x(oControlPanel.i_m_bAttackSent))
- {
- SetCyclistAttackButtonState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_bAttack));
- Seti32x(oControlPanel.i_m_bAttackSent,Geti32x(oControlPanel.i_m_bAttack));
- }
- }
-
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,Geti32x(oControlPanel.i_m_iAttackWaitLoop)+iRaceSpeed);
-
- if (Geti32x(oControlPanel.i_m_iAttackWaitLoop)>=g_i_AttackWaitNumLoop)
- {
- SetCheckboxState(oControlPanel.iAttackID,false);
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,0);
- Seti32x(oControlPanel.i_m_bAttack,0);
- }
- }//end of if (Geti32x(oControlPanel.i_m_iAttackWaitLoop))
-
- if (Geti32x(oControlPanel.i_m_iEatWaitLoop))
- {
- if (Geti32x(oControlPanel.i_m_iEatWaitLoop)==1)
- {
- //Go to manual mode
- SendMode();
-
- //Then send the eatration message to the server
- SetCyclistEatRation(Geti32x(oControlPanel.i_m_iCyclistInTeamID));
- }
-
- Seti32x(oControlPanel.i_m_iEatWaitLoop,(Geti32x(oControlPanel.i_m_iEatWaitLoop)+iRaceSpeed));
-
- if (Geti32x(oControlPanel.i_m_iEatWaitLoop)>=g_i_EatWaitNumLoop)
- {
- SetCheckboxState(oControlPanel.iBoufID,false);
- Seti32x(oControlPanel.i_m_iEatWaitLoop,0);
- }
- }
- }//end of manual mode
-
- Seti32x(oControlPanel.i_m_iSendDataWaitLoop,Geti32x(oControlPanel.i_m_iSendDataWaitLoop)+iRaceSpeed);
-
- if (Geti32x(oControlPanel.i_m_iSendDataWaitLoop)>=10)
- {
- if (Geti32x(oControlPanel.i_m_bHasToSendData))
- {
- SendMode();
-
- if (Geti32x(oControlPanel.i_m_bAuto)==0)
- {
- //send data if manual mode is active
- if (Geti32x(oControlPanel.i_m_iEffort)!=Geti32x(oControlPanel.i_m_iEffortSent))
- {
- SetCyclistSpeedSliderValue(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iEffort));
- Seti32x(oControlPanel.i_m_iEffortSent,Geti32x(oControlPanel.i_m_iEffort));
- }
-
- if (Geti32x(oControlPanel.i_m_iRelayState)!=Geti32x(oControlPanel.i_m_iRelayStateSent))
- {
- SetCyclistTakeRelayCheckBoxState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iRelayState));
- Seti32x(oControlPanel.i_m_iRelayStateSent,Geti32x(oControlPanel.i_m_iRelayState));
- }
-
- if(Geti32x(oControlPanel.i_m_bAttack)!=Geti32x(oControlPanel.i_m_bAttackSent))
- {
- SetCyclistAttackButtonState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_bAttack));
- Seti32x(oControlPanel.i_m_bAttackSent,Geti32x(oControlPanel.i_m_bAttack));
- }
-
- if (Geti32x(oControlPanel.i_m_iSprintState)!=Geti32x(oControlPanel.i_m_iSprintStateSent))
- {
- SetCyclistSprintCheckBoxState(Geti32x(oControlPanel.i_m_iCyclistInTeamID),Geti32x(oControlPanel.i_m_iSprintState));
- Seti32x(oControlPanel.i_m_iSprintStateSent,Geti32x(oControlPanel.i_m_iSprintState));
- }
- }//end of if manual mode
-
- Seti32x(oControlPanel.i_m_bHasToSendData,0);
- }
-
- Seti32x(oControlPanel.i_m_iSendDataWaitLoop,0);
- }//end of if (Geti32x(oControlPanel.i_m_iSendDataWaitLoop)==10)
- }//end of refresh event
- }//end of component -1
- else if( (_iComponentID == oControlPanel.iBackGroundID) || (_iComponentID == oControlPanel.iNameID) )
- {
- if(_iEvent == GUI_COMPONENT_MOUSE_LDOWN )
- PlaySound(0,sbClickSound[1]);
- if(_iEvent == GUI_RADIOBUTTON_CHANGED)
- {
- oTeamPanel.m_iSelectedCyclistInTeam = Geti32x(oControlPanel.i_m_iCyclistInTeamID);
- PushEvent(GUI_PANELCLICK);
- }
- }//end of if( (_iComponentID == oControlPanel.iBackGroundID) || (_iComponentID == oControlPanel.iNameID) )
- else if(_iComponentID == oControlPanel.iHeartRateCB)
- {
- if(_iEvent == GUI_CHECKBOX_CHANGED )
- {
- var i32x iHR;
- PlaySound(0,sbClickSound[1]);
- iHR = GetCheckboxState(oControlPanel.iHeartRateCB);
- if(iHR == 1)
- {
- SetContainerHelpIndex(oControlPanel.iHeartRateCB,1477);
- // Display Heart rate and hide speed
- SetComponentVisibleStatus(oControlPanel.iSpeedValueID,false);
- SetComponentVisibleStatus(oControlPanel.iHRValueID,true);
- }
- else
- {
- SetContainerHelpIndex(oControlPanel.iHeartRateCB,1476);
- // Hide Heart rate and display speed
- SetComponentVisibleStatus(oControlPanel.iSpeedValueID,true);
- SetComponentVisibleStatus(oControlPanel.iHRValueID,false);
- }
- }
- }
- else if(_iComponentID == oControlPanel.iEffortID)
- {
- if(_iEvent == GUI_CHECKBOX_CHANGED )
- {
- var i32x iEffort;
-
- iEffort = GetCheckboxState(oControlPanel.iEffortID);
- if(iEffort == 1)
- {
- // Display effort slider
- SetComponentVisibleStatus(oControlPanel.iSliderID,true);
- SetComponentVisibleStatus(oControlPanel.iSliderBackID,true);
- SetComponentVisibleStatus(oControlPanel.iSliderColorID,true);
-
- // Hide other button
- SetComponentVisibleStatus(oControlPanel.iAutoID,false);
- SetComponentVisibleStatus(oControlPanel.iRelayID,false);
- SetComponentVisibleStatus(oControlPanel.iBoufID,false);
- }
- else
- {
- // Hide effort slider
- SetComponentVisibleStatus(oControlPanel.iSliderID,false);
- SetComponentVisibleStatus(oControlPanel.iSliderBackID,false);
- SetComponentVisibleStatus(oControlPanel.iSliderColorID,false);
-
- // Show other button
- SetComponentVisibleStatus(oControlPanel.iAutoID,true);
- SetComponentVisibleStatus(oControlPanel.iRelayID,true);
- SetComponentVisibleStatus(oControlPanel.iBoufID,true);
- }
- }
- }
- else if(_iComponentID == oControlPanel.iSliderID)
- {
- if(_iEvent == GUI_SLIDER_CHANGED )
- {
- var i32x iEffort;
-
- iEffort = GetSliderValue(oControlPanel.iSliderID);
- vPanel_UpdateEffort(iEffort);
- Seti32x(oControlPanel.i_m_iEffort,iEffort);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
- SetManualMode();
- }
- if(_iEvent == GUI_COMPONENT_MOUSE_UP )
- {
- // Hide effort slider
- SetComponentVisibleStatus(oControlPanel.iSliderID,false);
- SetComponentVisibleStatus(oControlPanel.iSliderBackID,false);
- SetComponentVisibleStatus(oControlPanel.iSliderColorID,false);
-
- // Show other button
- SetComponentVisibleStatus(oControlPanel.iAutoID,true);
- SetComponentVisibleStatus(oControlPanel.iRelayID,true);
- SetComponentVisibleStatus(oControlPanel.iBoufID,true);
-
- // Update check box
- SetCheckboxState(oControlPanel.iEffortID,false);
- }
- }
- else if(_iComponentID == oControlPanel.iRelayID)
- {
- if(_iEvent == GUI_BUTTON_PRESSED )
- {
- PlaySound(0,sbClickSound[2]);
- SetManualMode();
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
-
- if(GetContainerMap(oControlPanel.iRelayID)==a3_t_relaytake[0])
- {
- SetContainerHelpIndex(oControlPanel.iRelayID,1480);
- SetContainerMap(oControlPanel.iRelayID,a3_t_relaytake[1]);
- Seti32x(oControlPanel.i_m_iRelayState,1);
- }
- else if (GetContainerMap(oControlPanel.iRelayID)==a3_t_relaytake[1])
- {
- SetContainerHelpIndex(oControlPanel.iRelayID,1481);
- SetContainerMap(oControlPanel.iRelayID,a3_t_relaytake[2]);
- Seti32x(oControlPanel.i_m_iRelayState,2);
- }
- else
- {
- SetContainerHelpIndex(oControlPanel.iRelayID,1479);
- SetContainerMap(oControlPanel.iRelayID,a3_t_relaytake[0]);
- Seti32x(oControlPanel.i_m_iRelayState,0);
- }
- }
- }//end of if(_iComponentID == oControlPanel.iRelayID)
-
- else if(_iComponentID == oControlPanel.iSprintID)
- {
- if(_iEvent == GUI_RADIOBUTTON_CHANGED )
- {
- PlaySound(0,sbClickSound[9]);
- SetManualMode();
-
- Seti32x(oControlPanel.i_m_iSprintState,1);
- Seti32x(oControlPanel.i_m_iSprintStateSent,0);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
-
- //stop attack and eat
- Seti32x(oControlPanel.i_m_bAttack,0);
- Seti32x(oControlPanel.i_m_bAttackSent,1);
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,0);
- SetComponentEnableStatus(oControlPanel.iAttackID,false);
- SetComponentEnableStatus(oControlPanel.iBoufID,false);
- }
- }//end of if(_iComponentID == oControlPanel.iSprintID)
-
- else if(_iComponentID == oControlPanel.iAutoID)
- {
- if(_iEvent == GUI_CHECKBOX_CHANGED )
- {
-
- //The cyclist change sprint
- if(GetCheckboxState(_iComponentID))
- {
- PlaySound(0,sbClickSound[6]);
- SetContainerHelpIndex(oControlPanel.iAutoID,1483);
- SetAutomaticMode();
-
- }
- else
- {
- PlaySound(0,sbClickSound[7]);
- SetContainerHelpIndex(oControlPanel.iAutoID,1484);
- SetManualMode();
- }
- }
- }//end of if(_iComponentID == oControlPanel.iAutoID)
- else if(_iComponentID == oControlPanel.iAttackID)
- {
- if(_iEvent == GUI_RADIOBUTTON_CHANGED )
- {
- SetManualMode();
-
- PlaySound(0,sbClickSound[8]);
-
- SetContainerSprite(oControlPanel.iAttackID, 2, 0);
- Seti32x(oControlPanel.i_m_iAttackWaitLoop,1);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
- Seti32x(oControlPanel.i_m_bAttack,1);
- Seti32x(oControlPanel.i_m_bAttackSent,0);
- //stop sprint and eat
- Seti32x(oControlPanel.i_m_iSprintState,0);
- Seti32x(oControlPanel.i_m_iSprintStateSent,1);
- SetComponentEnableStatus(oControlPanel.iSprintID,false);
- SetComponentEnableStatus(oControlPanel.iBoufID,false);
- }
- }//end of if(_iComponentID == oControlPanel.iAttackID)
- else if(_iComponentID == oControlPanel.iBoufID)
- {
- if(_iEvent == GUI_RADIOBUTTON_CHANGED )
- {
- var i32x iNumBouf;
-
- iNumBouf = Geti32x(oControlPanel.i_m_iNbBouf);
- SetManualMode();
- //Test if an attack has already been launched
- if((Geti32x(oControlPanel.i_m_iEatWaitLoop)==0) && (iNumBouf>0))
- {
- iNumBouf = iNumBouf - 1;
- SetContainerMap(oControlPanel.iBoufID,a4_t_bouffe[iNumBouf]);
- Seti32x(oControlPanel.i_m_iEatWaitLoop,1);
- Seti32x(oControlPanel.i_m_iNbBouf,iNumBouf);
- Seti32x(oControlPanel.i_m_bHasToSendData,1);
-
- SetComponentEnableStatus(oControlPanel.iAttackID,false);
- SetComponentEnableStatus(oControlPanel.iSprintID,false);
- }
- }
- }//end of if((_iComponentID == oControlPanel.iBoufID))
- return 1;
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //ControlPanel Init func
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func void InitControlPanel (i32x iTeamID, i32x iCyclistInTeamID)
- {
- var i32x iID;
- var szx szCyclist;
-
- iID = GetPreRaceCyclistIndexFromTeamAndIndexInTeam(iTeamID, iCyclistInTeamID);
-
- if(iID != -1)
- {
- szCyclist = Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_FirstName,iID);
- szCyclist = strncpy(szCyclist,1);
- szCyclist = strcat(strcat(szCyclist,"."),Join_GetStringFromSortedIndex(g_stInraceJoins.m_iCyclist_LastName,iID));
- oControlPanel.szName = szCyclist;
- oControlPanel.iCyclistInTeamID = iCyclistInTeamID;
- oControlPanel.iPreRaceCyclistID = iID;
- }
- else
- {
- // MistER-j WARNING LOCALIZED
- oControlPanel.szName = "Not found";
- oControlPanel.iCyclistInTeamID = iCyclistInTeamID;
- oControlPanel.iPreRaceCyclistID = iID;
- }
-
- oControlPanel.oFunc.pcreate = CreateControlPanel;
- oControlPanel.oFunc.pevent = ControlPanel;
- }
-
- func void DesactivateControlPanel(i32x _iPanelIndex)
- {
- //print("Desactivate control panel:");
- //print(itoa(_iPanelIndex));
- //print("\n");
-
- // Disable Panel
- oRace.a9_bControlPanelActivated[_iPanelIndex]=0;
-
- // Save current context
- var component pold;
- pold=GetParserComponent();
-
- // Set Team panel context
- SetParserComponent(oTeamPanel.PanelComponent);
-
- SetComponentEnableStatus(oTeamPanel.iPanelID[_iPanelIndex],false);
- SetEvents(oTeamPanel.iPanelID[_iPanelIndex],GUI_Enable|GUI_Disable);
-
- // Restore old context
- SetParserComponent(pold);
- }
-
- func void ActivateControlPanel(i32x _iPanelIndex)
- {
- //print("Activate control panel:");
- //println(itoa(_iPanelIndex));
-
- // Enable Panel
- oRace.a9_bControlPanelActivated[_iPanelIndex]=1;
-
- // Save current context
- var component pold;
- pold=GetParserComponent();
-
- // Set Team panel context
- SetParserComponent(oTeamPanel.PanelComponent);
-
- SetComponentEnableStatus(oTeamPanel.iPanelID[_iPanelIndex],true);
- SetEvents(oTeamPanel.iPanelID[_iPanelIndex],GUI_Enable|GUI_Disable|GUI_Key|GUI_Mouse|GUI_Refresh);
-
- // Restore old context
- SetParserComponent(pold);
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //TeamPanel Create func
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func void CreateTeamPanel ()
- {
- var i32x i,iMax,iPosY,id;
-
- // 9 cyclist per team + background
- SetComponentNumber(10);
-
- // Get team panel context
- oTeamPanel.PanelComponent = GetParserComponent();
-
- // Create 9 control panel
- i=0;
- iMax=9;
- iPosY = 0;
- while(i<iMax)
- {
- var szx szObjName;
- var i32x iCyclistID;
-
- szObjName = "ControlPanel_";
- szObjName = strcat(szObjName,itoa(i));
-
- InitControlPanel(g_oUser.m_iMyInRaceTeamID,i);
- oTeamPanel.iPanelID[i] = InitObject(szObjName, oControlPanel.oFunc.pcreate, oControlPanel.oFunc.pevent);
- SetStackEvents(oTeamPanel.iPanelID[i],GUI_Refresh|GUI_MouseUp|GUI_Enable|GUI_Disable);
-
- if(Join_GetIntFromSortedIndex(g_stInraceJoins.m_bCyclist_Withdrawal,oControlPanel.iPreRaceCyclistID))
- {
- //print("Creation of control panel without desactivated and without refresh:");
- //println(itoa(i));
-
- SetEvents(oTeamPanel.iPanelID[i],GUI_Enable|GUI_Disable);
- SetComponentEnableStatus(oTeamPanel.iPanelID[i],false);
- }
- else
- {
- //print("Creation of control panel desactivated:");
- //println(itoa(i));
-
- SetEvents(oTeamPanel.iPanelID[i],GUI_Enable|GUI_Disable|GUI_Refresh);
- SetComponentEnableStatus(oTeamPanel.iPanelID[i],false);
- }
-
- SetRefreshState(oTeamPanel.iPanelID[i],iMax+1,i);
-
- iPosY = oTeamPanel.iPanelPos[i]*64;
- SetComponentPosition(oTeamPanel.iPanelID[i], 4, iPosY);
-
- //iPosY = iPosY + 64;
- i=i+1;
- }
-
- // Team panel size
- SetObjectSize(128,600);
- }
-
-
-
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //TeamPanel Event func
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func i32x TeamPanel (i32x _iComponentID,i32x _iEvent)
- {
- var i32x i;
- if(_iEvent == GUI_PANELCLICK )
- {
- PushEvent(GUI_RESET_SPRINTS);
- i=0;
- while(i<9)
- {
- if(_iComponentID == oTeamPanel.iPanelID[i])
- {
- SetActiveCyclist(GetPreRaceCyclistIndexFromTeamAndIndexInTeam(g_oUser.m_iMyInRaceTeamID,i));
- oPanelRank.m_bSeeClass=true;
- oPanelRank.m_bFindCyclist = true;
- SetComponentPositionX(oTeamPanel.iPanelID[i],0);
- }
- else
- {
- SetComponentPositionX(oTeamPanel.iPanelID[i],4);
- PushEventOnChild(oTeamPanel.iPanelID[i],GUI_PANELCLICK);
- }
- i=i+1;
- }
- vSetProfileCameraMode(0);
- RefreshInfos();
- }
- else if(_iEvent == GUI_PANELRESET)
- {
- i=0;
- while(i<9)
- {
- if(_iComponentID == oTeamPanel.iPanelID[i])
- {
- SetComponentPositionX(oTeamPanel.iPanelID[i],4);
- }
- i=i+1;
- }
- }
- else if(_iEvent == GUI_PANEL_UP)
- {
- if((oTeamPanel.m_iSelectedCyclistInTeam>=0)&&(oTeamPanel.m_iSelectedCyclistInTeam<9))
- {
- var i32x iSwapCyclist,iIndex,iNewPosY,iOldPosY;
-
- // Move up Control panel selected
- iIndex = oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam];
-
- if(iIndex>0)
- {
- iSwapCyclist = -1;
- i=0;
- while(i<9)
- {
- if(oTeamPanel.iPanelPos[i]==iIndex-1)
- {
- iSwapCyclist = i;
- i=8;
- }
- i=i+1;
- }
-
- if(iSwapCyclist>=0)
- {
- var i32x iTmp;
-
- iTmp = oTeamPanel.iPanelPos[iSwapCyclist];
- oTeamPanel.iPanelPos[iSwapCyclist] = oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam];
- oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam] = iTmp;
-
- // Calc new position
- iOldPosY = oTeamPanel.iPanelPos[iSwapCyclist]*64;
- iNewPosY = oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam]*64;
-
- // Move panel
- SetComponentPositionY(oTeamPanel.iPanelID[oTeamPanel.m_iSelectedCyclistInTeam],iNewPosY);
- SetComponentPositionY(oTeamPanel.iPanelID[iSwapCyclist],iOldPosY);
- }
- }
- }
- }
- else if(_iEvent == GUI_PANEL_DOWN)
- {
- if((oTeamPanel.m_iSelectedCyclistInTeam>=0)&&(oTeamPanel.m_iSelectedCyclistInTeam<9))
- {
- var i32x iSwapCyclist,iIndex,iNewPosY,iOldPosY;
-
- // Move up Control panel selected
- iIndex = oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam];
-
- if(iIndex<8)
- {
- iSwapCyclist = -1;
- i=0;
- while(i<9)
- {
- if(oTeamPanel.iPanelPos[i]==iIndex+1)
- {
- iSwapCyclist = i;
- i=8;
- }
- i=i+1;
- }
-
- if(iSwapCyclist>=0)
- {
- var i32x iTmp;
-
- iTmp = oTeamPanel.iPanelPos[iSwapCyclist];
- oTeamPanel.iPanelPos[iSwapCyclist] = iIndex;
- oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam] = iTmp;
-
- // Calc new position
- iOldPosY = oTeamPanel.iPanelPos[iSwapCyclist]*64;
- iNewPosY = oTeamPanel.iPanelPos[oTeamPanel.m_iSelectedCyclistInTeam]*64;
-
- // Move panel
- SetComponentPositionY(oTeamPanel.iPanelID[oTeamPanel.m_iSelectedCyclistInTeam],iNewPosY);
- SetComponentPositionY(oTeamPanel.iPanelID[iSwapCyclist],iOldPosY);
- }
- }
- }
- }
- return 1;
- }
-
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- //TeamPanel Init func
- //----------------------------------------------------------------------------------------------------------------//
- //----------------------------------------------------------------------------------------------------------------//
- func void InitTeamPanel ()
- {
- var i32x i;
- g_fSpeedStep = 1.0;
-
- oTeamPanel.szName = "TeamPanel";
-
- oTeamPanel.m_iSelectedCyclistInTeam = -1;
-
- while(i<9)
- {
- oTeamPanel.iPanelPos[i] = i;
- i=i+1;
- }
-
- oTeamPanel.oFunc.pcreate = CreateTeamPanel;
- oTeamPanel.oFunc.pevent = TeamPanel;
- }
-
-
-