Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Game.UI.Login
- {
- public class LoginWindow : Control
- {
- Control window;
- EditBox editBoxMail;
- EditBox editBoxPassword;
- static string UserLogin;
- static string UserPassword;
- static LoginWindow instance;
- public static LoginWindow Instance
- {
- get { return instance; }
- }
- protected override void OnAttach()
- {
- instance = this;
- base.OnAttach();
- EngineApp.Instance.Config.RegisterClassParameters(GetType());
- window = ControlDeclarationManager.Instance.CreateControl("Gui\\Login\\LoginWindow.gui");
- window.ColorMultiplier = new ColorValue(1, 1, 1, 0);
- Controls.Add(window);
- if (window.Controls["LoginButton"] != null)
- ((Button)window.Controls["LoginButton"]).Click += LoginButton_Click;
- editBoxMail = (EditBox)window.Controls["UserMail"];
- editBoxMail.Text = "";
- editBoxMail.TextChange += editBoxMail_TextChange;
- editBoxPassword = (EditBox)window.Controls["UserPassword"];
- editBoxPassword.Text = "";
- editBoxPassword.TextChange += editBoxPassword_TextChange;
- GameMusic.MusicPlay("Sounds\\Music\\MainMenu.ogg", true);
- }
- void editBoxMail_TextChange(Control sender)
- {
- UserLogin = editBoxMail.Text.Trim();
- }
- void editBoxPassword_TextChange(Control sender)
- {
- UserPassword = editBoxPassword.Text.Trim();
- }
- void LoginButton_Click(Button sender)
- {
- if (string.IsNullOrEmpty(UserLogin))
- {
- Controls.Add(new ErrorWindow(1));//ошибка - не введен логин
- }
- else if (string.IsNullOrEmpty(UserPassword))
- {
- Controls.Add(new ErrorWindow(2));//ошибка - не введен пароль
- }
- else
- {
- // если данные введены
- }
- }
- protected override void OnDetach()
- {
- base.OnDetach();
- instance = null;
- }
- protected override bool OnKeyDown( KeyEvent e )
- {
- if( base.OnKeyDown( e ) )
- return true;
- return false;
- }
- protected override void OnTick( float delta )
- {
- base.OnTick( delta );
- //Change window transparency
- {
- float alpha = 0;
- if( Time > 3 && Time <= 5 )
- alpha = ( Time - 3 ) / 2;
- else if( Time > 4 )
- alpha = 1;
- window.ColorMultiplier = new ColorValue( 1, 1, 1, alpha );
- //versionTextBox.ColorMultiplier = new ColorValue( 1, 1, 1, alpha );
- }
- //update sound listener
- SoundWorld.Instance.SetListener( new Vec3( 1000, 1000, 1000 ),
- Vec3.Zero, new Vec3( 1, 0, 0 ), new Vec3( 0, 0, 1 ) );
- }
- protected override void OnRender()
- {
- base.OnRender();
- }
- protected override void OnRenderUI( GuiRenderer renderer )
- {
- base.OnRenderUI( renderer );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement