/// <summary> /// Focuses the specified control. /// </summary> /// <param name="control">The control to focus on.</param> protected void Focus(Control control) { if (this.focus == control) { return; } else { if (this.focus != null) { this.focus.SetFocus(false); } control.SetFocus(true); this.focus = control; } }
/// <summary> /// Initialization /// </summary> protected override void OnInitialize() { var device = AlmiranteEngine.Device; this.overlay = new Texture2D(device, 1, 1); this.overlay.SetData(new Color[] { Color.FromNonPremultiplied(0, 0, 0, 255) }); /// /// Name panel /// this.panel_login = new Control() { Size = new Vector2(250, 250), Position = new Vector2((1280 - 250) / 2, (720 - 250) / 2) }; var labellogin = new Label() { Text = "Name:", Visible = true, Size = new Vector2(250, 15), Position = new Vector2(0, 0) }; this.panel_login.Controls.Add(labellogin); this.textname = new Textbox() { Visible = true, Size = new Vector2(250, 30), Position = labellogin.Position + new Vector2(0, 30) }; this.panel_login.Controls.Add(this.textname); this.enter = new Button() { Text = "Enter", Visible = true, Size = new Vector2(120, 30), Position = textname.Position + new Vector2(0, 40) }; this.enter.MouseClick += OnEnter; this.panel_login.Controls.Add(this.enter); this.back = new Button() { Text = "Back", Visible = true, Size = new Vector2(120, 30), Position = textname.Position + new Vector2(130, 40) }; this.back.MouseClick += OnBack; this.panel_login.Controls.Add(this.back); this.Interface.Controls.Add(this.panel_login); /// /// Message /// this.message_label = new Label() { Size = new Vector2(600, 15), Position = new Vector2(300, 0), Alignment = FontAlignment.Center, Text = "?" }; this.message_button = new Button() { Size = new Vector2(100, 30), Position = new Vector2(250, 30), Text = "OK" }; this.message_panel = new Control() { Size = new Vector2(600, 50), Position = new Vector2((1280 - 600) / 2, (720 - 50) / 2), Visible = false }; this.message_panel.Controls.Add(this.message_label); this.message_panel.Controls.Add(this.message_button); this.Interface.Controls.Add(this.message_panel); /// /// Messages /// Player.Instance.Protocol.Subscribe<JoinResponse>(this.OnJoinResponse); }
/// <summary> /// Initializes the scene. /// </summary> internal virtual void Initialize() { this.state = SceneState.Default; this.input = AlmiranteEngine.Input; var settings = AlmiranteEngine.Settings; this.Interface = new RootControl() { Active = true, Position = Vector2.Zero, Size = new Vector2(settings.Resolution.BaseWidth, settings.Resolution.BaseHeight), Parent = null, }; this.focus = Interface; this.OnInitialize(); }