home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 51 / PCGamer51_17Demos.iso / games / CM / CyclingManagerDemoCangas.exe / CyclingManagerDemo / scripts / common / multiplayer / dialog_game_param.cnc next >
Text File  |  2001-06-05  |  7KB  |  159 lines

  1. func void Dialog_Game_Param_Default (i32x _iIsNew,i32x _iJoin,szx _szLogin, szx _szPassword)
  2. {
  3.     oDialog_Game_Param.m_iIsNew        = _iIsNew;
  4.     oDialog_Game_Param.m_iGameId    = _iJoin;
  5.     oDialog_Game_Param.m_szLogin    = _szLogin;
  6.     oDialog_Game_Param.m_szPassword = _szPassword;
  7. }
  8.  
  9. //----------------------------------------------------------------------------------------------------------------//
  10. //----------------------------------------------------------------------------------------------------------------//
  11. //Login Window Create func
  12. //----------------------------------------------------------------------------------------------------------------//
  13. //----------------------------------------------------------------------------------------------------------------//
  14. func void Dialog_Game_Param_Create ()
  15. {
  16.     var i32x id, iTemp;
  17.  
  18.     // Get page Login context
  19.     oDialog_Game_Param.pthis = GetParserComponent();
  20.     
  21.     SetComponentNumber(32);
  22.  
  23.     id = Init_LibObject_FilledCadre(tCadreDialbox,450,330);
  24.  
  25.     // Close button
  26.     id = InitButton(tBtnClose);
  27.     SetContainerStateFunc(id,ThreeStateButtonState);
  28.     SetContainerSize(id,25,25);
  29.     SetComponentPosition(id,385,4);
  30.     oDialog_Game_Param.m_cClose=id;
  31.     
  32.     // game static text box
  33.     id = InitContainer(tFontArialItalique);
  34.     SetStackEvents(id,GUI_NoEvent);
  35.     SetContainerText(id,strcat(GetLocalizedFromGMKey(378),":"));
  36.     ResizeComponent(id);
  37.     SetComponentPosition(id, 175-GetComponentWidth(id), 120);
  38.     
  39.     // password static text box
  40.     id = InitContainer(tFontArialItalique);
  41.     SetStackEvents(id,GUI_NoEvent);
  42.     SetContainerText(id,strcat(GetLocalizedFromGMKey(169),":"));
  43.     ResizeComponent(id);
  44.     SetComponentPosition(id, 175-GetComponentWidth(id), 145);
  45.     
  46.     // game Edit box
  47.     id = Init_LibObject_FilledCadre(tFCadre7,120,20);
  48.     SetComponentPosition(id,180 ,118);
  49.     
  50.     oDialog_Game_Param.c_login = InitEditBox(tFontArial,  32);
  51.     SetContainerStateFunc(oDialog_Game_Param.c_login, TextButtonState);
  52.     SetComponentSize(oDialog_Game_Param.c_login, 110, 16);
  53.     SetComponentPosition(oDialog_Game_Param.c_login, 185, 120);
  54.     SetContainerText(oDialog_Game_Param.c_login,oDialog_Game_Param.m_szLogin);
  55.  
  56.     // Password Edit box
  57.     id = Init_LibObject_FilledCadre(tFCadre7,120,20);
  58.     SetComponentPosition(id,180,143);
  59.     
  60.     oDialog_Game_Param.c_password = InitEditBox(tFontArial,  32);
  61.     SetContainerStateFunc(oDialog_Game_Param.c_password, TextButtonState);
  62.     SetComponentSize(oDialog_Game_Param.c_password, 110, 16);
  63.     SetComponentPosition(oDialog_Game_Param.c_password, 185, 145);
  64.     SetContainerText(oDialog_Game_Param.c_password,oDialog_Game_Param.m_szPassword );
  65.  
  66.     // Enter Button
  67.     oDialog_Game_Param.c_ok = InitLibMultiSpriteButtonWithText(tButton32Multi,8,GetLocalizedFromGMKey(290),tFontArial,0);
  68.     SetComponentPosition(oDialog_Game_Param.c_ok, 200-GetComponentWidth(oDialog_Game_Param.c_ok)/2, 250);
  69.  
  70.     // Default selected component
  71.     SetSelectedComponent(oDialog_Game_Param.c_login);
  72.  
  73.     AutoResize();
  74. }
  75.  
  76. //----------------------------------------------------------------------------------------------------------------//
  77. //----------------------------------------------------------------------------------------------------------------//
  78. //Dialog_Game_Param_Event
  79. //----------------------------------------------------------------------------------------------------------------//
  80. //----------------------------------------------------------------------------------------------------------------//
  81. func i32x Dialog_Game_Param_Event (i32x _iComponentID,i32x _iEvent)
  82. {
  83.     if(_iEvent == GUI_BUTTON_PRESSED)
  84.     {
  85.         PlaySound(0,sbClickSound[0]);
  86.  
  87.         if(_iComponentID == oDialog_Game_Param.c_ok)
  88.         {
  89.             if (oDialog_Game_Param.m_iGameId==0)
  90.             {
  91.                 if (oDialog_Game_Param.m_iIsNew)
  92.                 {
  93.                     var i32x iSlotId;
  94.                     
  95.                     // Create a new slot
  96.                     iSlotId = iCreateNewOnlineGame(oGameMode_Dialog.m_iSelectedGameMode,GetContainerText(oDialog_Game_Param.c_login),GetContainerText(oDialog_Game_Param.c_password));
  97.                     fnCreateMultiplayer(iSlotId,oGameMode_Dialog.m_iSelectedStartingDay);
  98.                 }
  99.                 else
  100.                 {
  101.                     Join_SetStringFromKey(g_oLocalJoins.m_iMSlot_szName,oPage_MultiPlayer.m_iSelectedSlotId,GetContainerText(oDialog_Game_Param.c_login));
  102.                     Join_SetStringFromKey(g_oLocalJoins.m_iMSlot_szPass,oPage_MultiPlayer.m_iSelectedSlotId,GetContainerText(oDialog_Game_Param.c_password));
  103.                     
  104.                     // starting day is no more valid
  105.                     fnCreateMultiplayer(oPage_MultiPlayer.m_iSelectedSlotId,0);
  106.                 }
  107.             }
  108.             else
  109.             {
  110.                 if (g_oGameConfig.m_iInternet)
  111.                 {
  112.                     fnInternetLogin(GetContainerText(oDialog_Game_Param.c_login),GetContainerText(oDialog_Game_Param.c_password));
  113.                 }
  114.             }
  115.             PushEvent(GUI_DESTROY_ME);
  116.         }
  117.         if(_iComponentID == oDialog_Game_Param.m_cClose)
  118.         {
  119.             PushEvent(GUI_DESTROY_ME);
  120.         }
  121.     }
  122.     return 1;
  123. }
  124.  
  125. //----------------------------------------------------------------------------------------------------------------//
  126. //----------------------------------------------------------------------------------------------------------------//
  127. //Constructor
  128. //----------------------------------------------------------------------------------------------------------------//
  129. //----------------------------------------------------------------------------------------------------------------//
  130. func i32x Dialog_Game_Param_Constructor ()
  131. {
  132.     // create dialbox
  133.     oDialog_Game_Param.iWindowID = InitObject("Dialog_game_param",oDialog_Game_Param.oFunc.pcreate,oDialog_Game_Param.oFunc.pevent);
  134.     SetStackEvents(oDialog_Game_Param.iWindowID,GUI_Destroy | GUI_Key);
  135.     return oDialog_Game_Param.iWindowID;
  136. }
  137.  
  138. //----------------------------------------------------------------------------------------------------------------//
  139. //----------------------------------------------------------------------------------------------------------------//
  140. //Destructor
  141. //----------------------------------------------------------------------------------------------------------------//
  142. //----------------------------------------------------------------------------------------------------------------//
  143. func void Dialog_Game_Param_Destructor ()
  144. {
  145.     DeleteComponent(oDialog_Game_Param.iWindowID);
  146. }
  147.  
  148. //----------------------------------------------------------------------------------------------------------------//
  149. //----------------------------------------------------------------------------------------------------------------//
  150. //Main Window Init member
  151. //----------------------------------------------------------------------------------------------------------------//
  152. //----------------------------------------------------------------------------------------------------------------//
  153.  
  154. func void Dialog_Game_Param_InitMembers ()
  155. {
  156.     oDialog_Game_Param.oFunc.pcreate    = Dialog_Game_Param_Create;
  157.     oDialog_Game_Param.oFunc.pevent        = Dialog_Game_Param_Event;
  158. }
  159.