Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.07 KB | None | 0 0
  1. namespace Game.UI.Login
  2. {
  3.     public class LoginWindow : Control
  4.     {
  5.         Control window;
  6.         EditBox editBoxMail;
  7.         EditBox editBoxPassword;
  8.  
  9.         static string UserLogin;
  10.         static string UserPassword;
  11.         static LoginWindow instance;
  12.  
  13.         public static LoginWindow Instance
  14.         {
  15.             get { return instance; }
  16.         }
  17.  
  18.         protected override void OnAttach()
  19.         {
  20.             instance = this;
  21.             base.OnAttach();
  22.  
  23.             EngineApp.Instance.Config.RegisterClassParameters(GetType());
  24.  
  25.             window = ControlDeclarationManager.Instance.CreateControl("Gui\\Login\\LoginWindow.gui");
  26.  
  27.             window.ColorMultiplier = new ColorValue(1, 1, 1, 0);
  28.             Controls.Add(window);
  29.  
  30.             if (window.Controls["LoginButton"] != null)
  31.                 ((Button)window.Controls["LoginButton"]).Click += LoginButton_Click;
  32.  
  33.             editBoxMail = (EditBox)window.Controls["UserMail"];
  34.             editBoxMail.Text = "";
  35.             editBoxMail.TextChange += editBoxMail_TextChange;
  36.  
  37.             editBoxPassword = (EditBox)window.Controls["UserPassword"];
  38.             editBoxPassword.Text = "";
  39.             editBoxPassword.TextChange += editBoxPassword_TextChange;
  40.  
  41.             GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true);
  42.         }
  43.  
  44.         void editBoxMail_TextChange(Control sender)
  45.         {
  46.             UserLogin = editBoxMail.Text.Trim();
  47.         }
  48.  
  49.         void editBoxPassword_TextChange(Control sender)
  50.         {
  51.             UserPassword = editBoxPassword.Text.Trim();
  52.         }
  53.  
  54.         void LoginButton_Click(Button sender)
  55.         {
  56.             if (string.IsNullOrEmpty(UserLogin))
  57.             {
  58.                 Controls.Add(new ErrorWindow(1));//ошибка - не введен логин
  59.             }
  60.             else if (string.IsNullOrEmpty(UserPassword))
  61.             {
  62.                 Controls.Add(new ErrorWindow(2));//ошибка - не введен пароль
  63.             }
  64.             else
  65.             {
  66.                 // если данные введены
  67.             }
  68.         }
  69.  
  70.         protected override void OnDetach()
  71.         {
  72.             base.OnDetach();
  73.             instance = null;
  74.         }
  75.  
  76.         protected override bool OnKeyDown( KeyEvent e )
  77.         {
  78.             if( base.OnKeyDown( e ) )
  79.                 return true;
  80.             return false;
  81.         }
  82.  
  83.         protected override void OnTick( float delta )
  84.         {
  85.             base.OnTick( delta );
  86.  
  87.             //Change window transparency
  88.             {
  89.                 float alpha = 0;
  90.  
  91.                 if( Time > 3 && Time <= 5 )
  92.                     alpha = ( Time - 3 ) / 2;
  93.                 else if( Time > 4 )
  94.                     alpha = 1;
  95.  
  96.                 window.ColorMultiplier = new ColorValue( 1, 1, 1, alpha );
  97.                 //versionTextBox.ColorMultiplier = new ColorValue( 1, 1, 1, alpha );
  98.             }
  99.  
  100.             //update sound listener
  101.             SoundWorld.Instance.SetListener( new Vec3( 1000, 1000, 1000 ),
  102.                 Vec3.Zero, new Vec3( 1, 0, 0 ), new Vec3( 0, 0, 1 ) );
  103.         }
  104.  
  105.         protected override void OnRender()
  106.         {
  107.             base.OnRender();
  108.         }
  109.  
  110.         protected override void OnRenderUI( GuiRenderer renderer )
  111.         {
  112.             base.OnRenderUI( renderer );
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement