home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revista CD Expert 51
/
PCGamer51_17Demos.iso
/
games
/
CM
/
CyclingManagerDemoCangas.exe
/
CyclingManagerDemo
/
scripts
/
common
/
admin
/
page_admin.cnc
< prev
next >
Wrap
Text File
|
2001-06-11
|
16KB
|
453 lines
func void SkipFailed_MessageBoxCallback(i32x iResult)
{
// Nothing todo
}
// Object Admin
func void ObjectAdmin_Create ()
{
var szx szTemp;
var i32x i,id,iRaceId;
// Get current context
oObjectAdmin.pthis = GetParserComponent();
SetComponentNumber(49);
//game mode
szTemp = strcat(GetLocalizedFromGMKey(171),":");
if(g_oGameConfig.m_iGameMode == GAME_MODE_SEASON)
szTemp = strcat(szTemp,GetLocalizedFromGMKey(130));
if(g_oGameConfig.m_iGameMode == GAME_MODE_TOUR)
szTemp = strcat(szTemp,GetLocalizedFromGMKey(264));
if(g_oGameConfig.m_iGameMode == GAME_MODE_STAGE)
szTemp = strcat(szTemp,GetLocalizedFromGMKey(95));
oObjectAdmin.m_cInfoMode=InitContainer(tFnt_20);
SetContainerText(oObjectAdmin.m_cInfoMode,szTemp);
SetComponentPosition(oObjectAdmin.m_cInfoMode,10,0);
//info phase
oObjectAdmin.m_cInfoPhase=InitContainer(tFnt_20);
SetComponentPosition(oObjectAdmin.m_cInfoPhase,300,0);
id = InitContainer(tCommonTableBorder);
SetContainerSize(id,600,1);
SetComponentPosition(id,10,40);
SetEvents(id,GUI_NoEvent);
// Race Name
oObjectAdmin.m_cRaceName = InitContainer(tFnt_20);
SetContainerScaleY(oObjectAdmin.m_cRaceName,0.5);
SetContainerText(oObjectAdmin.m_cRaceName,GetLocalizedFromKey(Join_GetIntFromKey(g_oLocalJoins.m_iRace_iNameId,g_oGameConfig.m_iCurrentRaceID)));
SetComponentPosition(oObjectAdmin.m_cRaceName,10,130);
//Profil of the current stage
Panel_Team_Tactic_Profil_InitMembers(g_oGameConfig.m_iCurrentStageID,1,1,600,100,10,150);
oObjectAdmin.m_cProfil=InitObject(oPanel_Team_Tactic_Profil.szName, oPanel_Team_Tactic_Profil.oFunc.pcreate, oPanel_Team_Tactic_Profil.oFunc.pevent);
SetStackEvents(oObjectAdmin.m_cProfil,GUI_Destroy | GUI_Char|GUI_KeyDown);
// Profil border
id = InitContainer(tCommonTableBorder);
SetContainerSize(id,600,1);
SetComponentPosition(id,10,150);
SetEvents(id,GUI_NoEvent);
id = InitContainer(tCommonTableBorder);
SetContainerSize(id,600,1);
SetComponentPosition(id,10,250);
SetEvents(id,GUI_NoEvent);
id = InitContainer(tCommonTableBorder);
SetContainerSize(id,1,100);
SetComponentPosition(id,10,150);
SetEvents(id,GUI_NoEvent);
id = InitContainer(tCommonTableBorder);
SetContainerSize(id,1,100);
SetComponentPosition(id,610,150);
SetEvents(id,GUI_NoEvent);
//button ready
oObjectAdmin.m_cReady=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,9,GetLocalizedFromGMKey(379),tFontArial,1470);
SetTextButtonStateFunc(oObjectAdmin.m_cReady,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
SetComponentPosition(oObjectAdmin.m_cReady,15,260);
//button not ready
oObjectAdmin.m_cNotReady=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,9,GetLocalizedFromGMKey(381),tFontArial,1472);
SetTextButtonStateFunc(oObjectAdmin.m_cNotReady,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
SetComponentPosition(oObjectAdmin.m_cNotReady,600-GetComponentWidth(oObjectAdmin.m_cNotReady),260);
//skip
oObjectAdmin.m_cSkip=InitLibMultiSpriteButtonWithText(tButton32Multi,7,GetLocalizedFromGMKey(424),tFontArial,0);
SetComponentPosition(oObjectAdmin.m_cSkip,600-GetComponentWidth(oObjectAdmin.m_cSkip),115);
if(g_oGameConfig.m_iGameMode == GAME_MODE_STAGE)
SetComponentVisibleStatus(oObjectAdmin.m_cSkip,false);
// Ready mode : by default
if(g_oGameConfig.m_iGameOver == 1)
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
}
else
{
if(g_oUser.m_iUserMode == G_iGuestUser)
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
}
else
{
if(g_oGameConfig.m_iReady)
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,true);
}
else
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
}
}
}
AutoResize();
}
func i32x ObjectAdmin_Event (i32x _iComponentID,i32x _iEvent)
{
if(_iComponentID == oObjectAdmin.m_cProfil)
{
if(_iEvent >= GUI_CREATE_DIALOG )
{
PushEvent(_iEvent); // Chain event
}
}
if(_iEvent == GUI_RADIOBUTTON_CHANGED )
{
PlaySound(0,sbClickSound[0]);
if(_iComponentID == oObjectAdmin.m_cReady)
{
g_oGameConfig.m_iReady = true;
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,false);
// Send Next command to menu server
g_oMenuServer.m_oServer<<mGame_NextPhase();
}
if(_iComponentID == oObjectAdmin.m_cNotReady)
{
g_oGameConfig.m_iReady = false;
SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,false);
// Send CancelNext command to menu server
g_oMenuServer.m_oServer<<mGame_CancelNextPhase();
}
}
if(_iComponentID == oObjectAdmin.m_cSkip)
{
if(_iEvent == GUI_BUTTON_PRESSED )
{
PlaySound(0,sbClickSound[0]);
// Can't skip the last stage of a tour
/*
if(Database_GetIntData(QUERY_GLOBAL_STAGES,"STA_stage.gene_i_stage_number",ROW_KEY,g_oGameConfig.m_iCurrentStageID)
< Database_GetIntData(QUERY_GLOBAL_STAGES,"STA_race.gene_i_number_stages",ROW_KEY,g_oGameConfig.m_iCurrentRaceID))
{
// Send Next stage command to menu server
g_oMenuServer.m_oServer<<mGame_NextStage();
}
else
{
CreateMessageBox(GetLocalizedFromGMKey(434),g_iTypeOkDialog,SkipFailed_MessageBoxCallback);
}
*/
// Send Next stage command to menu server
g_oMenuServer.m_oServer<<mGame_NextStage();
}
}
if(_iComponentID == -1)
{
if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
{
// Raz index and pointer
oObjectAdmin.pthis = g_poNullComponent;
oObjectAdmin.m_cProfil = ID_NOT_CREATED;
oObjectAdmin.m_cReady = ID_NOT_CREATED;
oObjectAdmin.m_cNotReady = ID_NOT_CREATED;
oObjectAdmin.m_cInfoMode = ID_NOT_CREATED;
oObjectAdmin.m_cInfoPhase = ID_NOT_CREATED;
}
}
return 1;
}
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
//PageAdmin Window Create func
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
func void PageAdmin_Create ()
{
var i32x iPosX;
SetComponentNumber(9);
// Get current context
oPageAdmin.pthis = GetParserComponent();
// *** Update Title Bar ***
Set_Title_Bar_Text(GetLocalizedFromGMKey(383)); // page title
//Dialog background
oPageAdmin.m_cBackground = Init_LibObject_FilledCadre(tCadreDialbox,700,550);
// *** Create onglet selection radio button ***
iPosX = 5;
oPageAdmin.m_cAdmin=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,7,GetLocalizedFromGMKey(164),tFontArial,0);
SetComponentPosition(oPageAdmin.m_cAdmin, iPosX, 40);
SetTextButtonStateFunc(oPageAdmin.m_cAdmin,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
ResizeComponent(oPageAdmin.m_cAdmin);
iPosX = iPosX + GetComponentWidth(oPageAdmin.m_cAdmin) + 5;
//Admin
oPageAdmin.iAdminID=InitObject("admin",ObjectAdmin_Create ,ObjectAdmin_Event);
SetComponentPosition(oPageAdmin.iAdminID,20 ,90);
SetStackEvents(oPageAdmin.iAdminID,GUI_Destroy | GUI_Key | GUI_Enable | GUI_Disable | GUI_Refresh);
SetRefreshState(oPageAdmin.iAdminID,40,1);
if(g_oGameConfig.m_iSinglePlayer==0)
{
// Users onglet
oPageAdmin.m_cUsers=Init_LibObject_MultiRadioButtonWithText(tButton32Multi,7,GetLocalizedFromGMKey(177),tFontArial,0);
SetComponentPosition(oPageAdmin.m_cUsers, iPosX, 40);
SetTextButtonStateFunc(oPageAdmin.m_cUsers,CheckBoxMultiState,MultiRadioButtonWithText_TextState);
ResizeComponent(oPageAdmin.m_cUsers);
iPosX = iPosX + GetComponentWidth(oPageAdmin.m_cUsers) + 5;
oPageAdmin.iUsersID = InitObject("users",Object_Users_Create ,Object_Users_Event);
SetComponentPosition(oPageAdmin.iUsersID,60 ,90);
SetStackEvents(oPageAdmin.iUsersID,GUI_Destroy | GUI_Key | GUI_Enable | GUI_Disable);
}
else
{
oPageAdmin.m_cUsers = ID_NOT_CREATED;
oPageAdmin.iUsersID = ID_NOT_CREATED;
}
// Select admin onglet by default
SetTextRadioButtonCheckBox(oPageAdmin.m_cAdmin,1);
if(oPageAdmin.iUsersID != ID_NOT_CREATED)
{
SetComponentVisibleStatus(oPageAdmin.iUsersID,false);
}
else
{
// Hide administration button
SetComponentVisibleStatus(oPageAdmin.m_cAdmin,false);
}
DisplayMenuPrincipal();
SetObjectSize(700,525);
}
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
//PageAdmin Window Event func
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
func i32x PageAdmin_Event (i32x _iComponentID,i32x _iEvent)
{
if(_iEvent == GUI_RADIOBUTTON_CHANGED)
{
PlaySound(0,sbClickSound[0]);
if(oPageAdmin.m_cUsers != ID_NOT_CREATED)
{
if(_iComponentID == oPageAdmin.m_cUsers)
{
// UnSelect calendar onglet
SetTextRadioButtonCheckBox(oPageAdmin.m_cAdmin,0);
// Show users
SetComponentVisibleStatus(oPageAdmin.iUsersID,1);
// Hide admin
SetComponentVisibleStatus(oPageAdmin.iAdminID,0);
}
}
if(_iComponentID == oPageAdmin.m_cAdmin)
{
// UnSelect calendar onglet
if(oPageAdmin.m_cUsers != ID_NOT_CREATED)
SetTextRadioButtonCheckBox(oPageAdmin.m_cUsers,0);
// Hide users
if(oPageAdmin.iUsersID != ID_NOT_CREATED)
SetComponentVisibleStatus(oPageAdmin.iUsersID,0);
// Show admin
SetComponentVisibleStatus(oPageAdmin.iAdminID,1);
}
}
if(_iComponentID == -1)
{
if(_iEvent == GUI_COMPONENT_DESTRUCTOR)
{
oPageAdmin.iWindowID = ID_NOT_CREATED;
oPageAdmin.pthis = g_poNullComponent;
oPageAdmin.m_cClose = ID_NOT_CREATED;
oPageAdmin.m_cBackground = ID_NOT_CREATED;
oPageAdmin.iAdminID = ID_NOT_CREATED;
}
}
return 1;
}
func void vAdminConfigUpdate()
{
Update_Next_Phase();
}
func void FillAdminDialbox()
{
if(oPageAdmin.iWindowID != ID_NOT_CREATED)
{
if(oPageAdmin.iUsersID != ID_NOT_CREATED)
vFillUsersList();
vAdminConfigUpdate();
}
}
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
//Constructor
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
func i32x PageAdmin_Constructor ()
{
// create page
oPageAdmin.iWindowID = InitObject("PageAdmin",oPageAdmin.oFunc.pcreate,oPageAdmin.oFunc.pevent);
SetStackEvents(oPageAdmin.iWindowID,GUI_Mouse|GUI_Key|GUI_Destroy);
// Direct fill dialbox
FillAdminDialbox();
//special looprun
if(G_iLoopRunVersion)
{
G_iLoopRunNumLoopMenu = 0;
}
return oPageAdmin.iWindowID;
}
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
//Destructor
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
func void PageAdmin_Destructor ()
{
// delete page
print("\noPageAdmin.iWindowID = ");println(itoa(oPageAdmin.iWindowID));
DeleteComponent(oPageAdmin.iWindowID);
oPageAdmin.iWindowID=ID_NOT_CREATED;
}
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
//PageAdmin Window Init member
//----------------------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------------------------------------//
func void PageAdmin_InitMembers ()
{
oPageAdmin.oFunc.pcreate = PageAdmin_Create;
oPageAdmin.oFunc.pevent = PageAdmin_Event;
}
//page admin update next phase info
func void Update_Next_Phase()
{
var component pold;
if (oPageAdmin.iWindowID !=ID_NOT_CREATED && oPageAdmin.iWindowID!=0)
{
if(oObjectAdmin.pthis)
{
// Get current context
pold=GetParserComponent();
// Set Admin onglet context
SetParserComponent(oObjectAdmin.pthis);
if (g_oGameConfig.m_iPhaseID == G_iPhase_InRace)
{
SetContainerText(oObjectAdmin.m_cInfoPhase,GetLocalizedFromGMKey(168));
SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
}
else if (g_oGameConfig.m_iPhaseID == G_iPhase_PreRace)
{
SetContainerText(oObjectAdmin.m_cInfoPhase,GetLocalizedFromGMKey(167));
}
else
{
SetContainerText(oObjectAdmin.m_cInfoPhase,GetLocalizedFromGMKey(166));
if(g_oGameConfig.m_iGameOver == 1)
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
}
else
{
if(g_oUser.m_iUserMode == G_iGuestUser)
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
SetComponentEnableStatus(oObjectAdmin.m_cReady,false);
SetComponentEnableStatus(oObjectAdmin.m_cNotReady,false);
}
else
{
if(g_oGameConfig.m_iReady)
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,true);
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,false);
}
else
{
SetTextRadioButtonCheckBox(oObjectAdmin.m_cNotReady,true);
SetTextRadioButtonCheckBox(oObjectAdmin.m_cReady,false);
}
}
}
}
ResizeComponent(oObjectAdmin.m_cInfoPhase);
SetComponentPositionX(oObjectAdmin.m_cInfoPhase,600 - GetComponentWidth(oObjectAdmin.m_cInfoPhase));
// Delete profil
if(oObjectAdmin.m_cProfil != ID_NOT_CREATED)
{
DeleteComponent(oObjectAdmin.m_cProfil);
oObjectAdmin.m_cProfil = ID_NOT_CREATED;
}
SetContainerText(oObjectAdmin.m_cRaceName,GetLocalizedFromKey(Join_GetIntFromKey(g_oLocalJoins.m_iRace_iNameId,g_oGameConfig.m_iCurrentRaceID)));
// Reinit profil
Panel_Team_Tactic_Profil_InitMembers(g_oGameConfig.m_iCurrentStageID,1,1,600,100,10,150);
oObjectAdmin.m_cProfil=InitObject(oPanel_Team_Tactic_Profil.szName, oPanel_Team_Tactic_Profil.oFunc.pcreate, oPanel_Team_Tactic_Profil.oFunc.pevent);
SetStackEvents(oObjectAdmin.m_cProfil,GUI_Destroy | GUI_Char|GUI_KeyDown);
// Update game password
// SetContainerText(oObjectAdmin.m_cPassword,g_oGameConfig.m_szGamePassword);
// Restore old context
SetParserComponent(pold);
}
}
}