public MessageDialog(Manager manager, string title, string text) : base(manager) { var size = Manager.Skin.Controls["Label"].Layers[0].Text.Font.Resource.MeasureString(text); ClientWidth = (int)size.X + 16 + 16; ClientHeight = (int)size.Y + 120 - 48; TopPanel.Visible = false; IconVisible = true; Resizable = false; Text = title; Center(); var label = new Label(this.Manager); label.Init(); label.Left = 16; label.Top = 16; label.Width = this.ClientWidth - label.Left; label.Height = (int)size.Y; label.Alignment = Alignment.TopLeft; label.Text = text; var btnOk = new Button(this.Manager); btnOk.Init(); btnOk.Left = base.BottomPanel.ClientWidth / 2 - btnOk.Width - 4; btnOk.Top = 8; btnOk.Text = "OK"; btnOk.ModalResult = ModalResult.Ok; Add(label); BottomPanel.Add(btnOk); DefaultControl = btnOk; }
/// <summary> /// Exit Dialog. /// </summary> public ExitDialog() { string msg = "Do you really want to exit?"; ClientWidth = (int)Skin.Controls["Label"].Layers[0].Text.Font.Font.MeasureString(msg).X + 48 + 16 + 16 + 16; ClientHeight = 120; TopPanel.Visible = false; IconVisible = true; Resizable = false; StayOnTop = true; Text = EngineManager.GameWindow.Title; CenterWindow(); imageIcon = new ImageBox { Texture = Skin.Images["Icon.Question"].Texture, Left = 16, Top = 16, Width = 48, Height = 48, SizeMode = SizeMode.Stretched }; labelMessage = new Label { Left = 80, Top = 16, Height = 48, Alignment = Alignment.TopLeft, Text = msg }; labelMessage.Width = ClientWidth - labelMessage.Left; buttonYes = new Button { Top = 8, Text = "Yes", ModalResult = ModalResult.Yes }; buttonYes.Left = (BottomPanel.ClientWidth / 2) - buttonYes.Width - 4; buttonNo = new Button { Left = (BottomPanel.ClientWidth/2) + 4, Top = 8, Text = "No", ModalResult = ModalResult.No }; Add(imageIcon); Add(labelMessage); BottomPanel.Add(buttonYes); BottomPanel.Add(buttonNo); DefaultControl = buttonNo; } // ExitDialog
//////////////////////////////////////////////////////////////////////////// #endregion #region //// Properties //////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// #endregion #region //// Events //////////// //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// #endregion #region //// Construstors ////// //////////////////////////////////////////////////////////////////////////// public ExitDialog(Manager manager) : base(manager) { string msg = "Do you really want to exit " + Manager.Game.Window.Title + "?"; ClientWidth = (int)Manager.Skin.Controls["Label"].Layers[0].Text.Font.Resource.MeasureString(msg).X + 48 + 16 + 16 + 16; ClientHeight = 120; TopPanel.Visible = false; IconVisible = true; Resizable = false; Text = Manager.Game.Window.Title; Center(); imgIcon = new ImageBox(Manager); imgIcon.Init(); imgIcon.Image = Manager.Skin.Images["Icon.Question"].Resource; imgIcon.Left = 16; imgIcon.Top = 16; imgIcon.Width = 48; imgIcon.Height = 48; imgIcon.SizeMode = SizeMode.Stretched; lblMessage = new Label(Manager); lblMessage.Init(); lblMessage.Left = 80; lblMessage.Top = 16; lblMessage.Width = ClientWidth - lblMessage.Left; lblMessage.Height = 48; lblMessage.Alignment = Alignment.TopLeft; lblMessage.Text = msg; btnYes = new Button(Manager); btnYes.Init(); btnYes.Left = (BottomPanel.ClientWidth / 2) - btnYes.Width - 4; btnYes.Top = 8; btnYes.Text = "Yes"; btnYes.ModalResult = ModalResult.Yes; btnNo = new Button(Manager); btnNo.Init(); btnNo.Left = (BottomPanel.ClientWidth / 2) + 4; btnNo.Top = 8; btnNo.Text = "No"; btnNo.ModalResult = ModalResult.No; Add(imgIcon); Add(lblMessage); BottomPanel.Add(btnYes); BottomPanel.Add(btnNo); DefaultControl = btnNo; }
public DirectConnect(Manager manager): base(manager) { Height = 150; Width = 300; MinimumHeight = 100; MinimumWidth = 100; Text = "Direct Connect"; Center(); TopPanel.Visible = true; Caption.Text = "Information"; Description.Text = "Connect to a server without adding to list"; Caption.TextColor = Description.TextColor = new Color(96, 96, 96); IP = new Label(manager); IP.Init(); IP.Top = 8 + TopPanel.Height; IP.Left = 8; IP.Text = "IP Address:"; IP.Width = 100; Add(IP); IPBox= new TextBox(manager); IPBox.Init(); IPBox.Top = 8 + TopPanel.Height; IPBox.Left = 96; Add(IPBox); Connect = new Button(manager); Connect.Init(); Connect.Left = 8; Connect.Top = 8; Connect.Text = "Join"; Connect.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { //Game.config.EnableMessageType(Lidgren.Network.NetIncomingMessageType.DiscoveryResponse); //Game.client = new Lidgren.Network.NetClient(Game.config); //Game.client.Start(); //Lidgren.Network.NetOutgoingMessage outmsg = Game.client.CreateMessage(); //outmsg.Write((byte)PacketTypes.Login); //outmsg.Write(Game.UserName); //Game.client.Connect(IPBox.Text, 14242,outmsg); //Game.currentGameState = Game.GameState.GameOn; Close(); }); BottomPanel.Add(Connect); }
public TaskContentPacks(Manager manager) : base(manager) { Height = 400; Width = 500; MinimumHeight = 100; MinimumWidth = 100; Resizable = false; Text = "Content Packs"; Center(); TopPanel.Visible = true; BottomPanel.Visible = true; //TopPanel.Visible = true; Caption.Text = "Content Packs"; Description.Text = "Customize the graphics of Zarknorth with content packs!\nCurrent Pack: " + Game.ContentPackName; Caption.TextColor = Description.TextColor = new Color(96, 96, 96); AddList(manager); ResetItems(manager); btnOpen = new Button(manager); btnOpen.Width = 200; btnOpen.Top = 8; btnOpen.Left = (ClientWidth / 2) - btnOpen.Width - 8; btnOpen.Text = "Open Content Packs Folder"; btnOpen.Click += btnOpen_Click; BottomPanel.Add(btnOpen); btnSet = new Button(manager); btnSet.Width = 200; btnSet.Top = 8; btnSet.Left = (ClientWidth / 2) + 8; btnSet.Text = "Set as Current Content Pack"; btnSet.Click += btnSet_Click; btnSet.Enabled = false; BottomPanel.Add(btnSet); for (int i = 0; i < List.Items.Count; i++) { if ((List.Items[i] as ContentPackListControl).Pack.Name == Game.ContentPackName) { List.ItemIndex = i; curPack = i; } } List.ItemIndexChanged += List_ItemIndexChanged; }
/// <summary> /// Create a new window for editng Text tiles, eg signs /// </summary> /// <param name="manager">UI Manager Object</param> /// <param name="interact">Interaction Parameters, includes level and position of sign</param> public TaskSign(Manager manager, InteractBlockEventArgs interact) : base(manager) { //Set up the window Text = "Sign"; Resizable = false; Init(); ClientWidth = 320; ClientHeight = 172; TopPanel.Visible = false; BottomPanel.Visible = true; Center(); //Create the input box for text editing Input = new TextBox(manager); Input.Init(); Input.Left = 8; Input.Top = 8; Input.Width = ClientArea.Width - 16; Input.Height = ClientArea.Height - 54; Input.Anchor = Anchors.All; Input.Mode = TextBoxMode.Multiline; Input.Text = (interact.level.tiles[interact.x, interact.y] as TextTile).Text; Input.SelectAll(); Input.Focused = true; Input.ScrollBars = ScrollBars.Both; Add(Input); //Saves the text, Durrr Save = new Button(manager); Save.Init(); Save.Text = "Save"; Save.Width = 64; Save.Height = 24; Save.Top = 8; Save.Left = (ClientWidth / 2) - Save.Width - 8; Save.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object sender, TomShane.Neoforce.Controls.EventArgs e) { //If the tile is still a text tile (Incase it got destroyed) then set it's text if (interact.level.tiles[interact.x, interact.y] is TextTile) { (interact.level.tiles[interact.x, interact.y] as TextTile).Text = Input.Text; } //Close up here Close(); }); //What could this do? Cancel = new Button(manager); Cancel.Init(); Cancel.Text = "Cancel"; Cancel.Width = 64; Cancel.Height = 24; Cancel.Top = 8; Cancel.Left = (ClientWidth / 2) + 8; Cancel.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object sender, TomShane.Neoforce.Controls.EventArgs e) { Close(); //Self-Explanitory }); //Add the new controls BottomPanel.Add(Save); BottomPanel.Add(Cancel); }
/// <summary> /// Create a new window for editng Text tiles, eg signs /// </summary> /// <param name="manager">UI Manager Object</param> /// <param name="interact">Interaction Parameters, includes level and position of sign</param> public TaskRenamePlanet(Manager manager, PlanetaryObject planet) : base(manager) { //Set up the window Text = "Rename Planet"; Resizable = false; Init(); ClientWidth = 175; ClientHeight = 74; TopPanel.Visible = false; BottomPanel.Visible = true; DefaultControl = Input; Center(); //Create the input box for text editing Input = new TextBox(manager); Input.Init(); Input.Left = 8; Input.Top = 8; Input.Width = ClientArea.Width - 16; Input.Anchor = Anchors.All; Input.Text = planet.Name; Input.SelectAll(); Input.Focused = true; Input.TextChanged += Input_TextChanged; Add(Input); //Saves the text, Durrr Save = new Button(manager); Save.Init(); Save.Text = "Save"; Save.Width = 64; Save.Height = 24; Save.Top = 8; Save.Left = (ClientWidth / 2) - Save.Width - 8; Save.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object sender, TomShane.Neoforce.Controls.EventArgs e) { try { planet.Name = Input.Text.Trim(); Game.UniverseViewer.CenterCamera(); } catch { System.Diagnostics.Debug.Assert(false, "Error"); } Close(); }); //What could this do? Cancel = new Button(manager); Cancel.Init(); Cancel.Text = "Cancel"; Cancel.Width = 64; Cancel.Height = 24; Cancel.Top = 8; Cancel.Left = (ClientWidth / 2) + 8; Cancel.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object sender, TomShane.Neoforce.Controls.EventArgs e) { Close(); //Self-Explanitory }); //Add the new controls BottomPanel.Add(Save); BottomPanel.Add(Cancel); }
/// <summary> /// Color picker dialog. /// </summary> public ColorPickerDialog(Color _oldColor) { ClientWidth = 5 + 132 + 10; ClientHeight = 235; TopPanel.Visible = false; IconVisible = false; Resizable = false; BorderVisible = false; Movable = false; StayOnTop = true; AutoScroll = false; #region Background // The background object is invisible, it serves input actions. background = new Control { Left = 0, Top = 0, Width = Screen.Width, Height = Screen.Height, StayOnTop = true, // To bring it to the second place (first is the main control) Color = new Color(0, 0, 0, 0) }; UserInterfaceManager.Add(background); // If we click outside the window close it. background.MouseDown += delegate(object sender, MouseEventArgs e) { if (e.Button == MouseButton.Left) { if (isPicking) { // If you want to use the user interface outside my engine you will need to change // only the following two lines (I presume the compiler it is telling this right now) // Create an event in the dialog called like "PickRequested" // In the color slider you will need to have the same event (to propagate this) // And then you read the event and do whatever you need to do. // The editor should read this event and not the other way around. EditorManager.colorPickerNeedsToPick = true; EditorManager.colorPickerDialog = this; isPicking = false; // The background control takes the first place (z order), now it needs to be in second. background.StayOnTop = false; // We need to change this so that the main control can take first place. BringToFront(); } else Close(); } }; #endregion #region Buttons // Button pick buttonPick = new Button { Top = 8, Glyph = new Glyph(Skin.Images["Dropper"].Texture) { SizeMode = SizeMode.Centered }, }; buttonPick.Left = (BottomPanel.ClientWidth / 2) - buttonPick.Width - 4; BottomPanel.Add(buttonPick); buttonPick.Click += delegate { //picker = new Picker(); isPicking = true; background.StayOnTop = true; background.BringToFront(); }; // Button close buttonClose = new Button { Left = (BottomPanel.ClientWidth / 2) + 4, Top = 8, Text = "Close", ModalResult = ModalResult.No }; BottomPanel.Add(buttonClose); buttonClose.Click += delegate { Close(); }; DefaultControl = buttonClose; #endregion #region Square color palette // Square color squareColorPalette = new Control { Left = squareColorLeft, Top = squareColorTop, Width = squareColorlenght, Height = squareColorlenght, Color = new Color(0, 0, 0, 0), Movable = true, // To implement a roboust color picker when you can move the mouse outside the color palette limits. }; Add(squareColorPalette); #endregion #region Intensity level bar // Intensity level bar intensityLevelBar = new Control { Left = 5 + squareColorlenght, Top = 5, Width = 20, Height = squareColorlenght, Color = new Color(0, 0, 0, 0), Movable = true, // To implement a roboust level picker when you can move the mouse outside the intensity level bar limits. }; Add(intensityLevelBar); #endregion #region R G B Text Boxes // R var labelRed = new Label { Parent = this, Text = " R", Width = 40, Top = 5 + squareColorlenght + 50, Left = 5, }; textBoxRed = new TextBox { Parent = this, Left = 5, Top = labelRed.Top + labelRed.Height + 2, Width = 40, Text = "1" }; // G var labelGreen = new Label { Parent = this, Text = " G", Width = 40, Top = 5 + squareColorlenght + 50, Left = labelRed.Width + 10, }; textBoxGreen = new TextBox { Parent = this, Left = labelRed.Width + 10, Top = labelRed.Top + labelRed.Height + 2, Width = 40, Text = "1" }; // B var labelBlue = new Label { Parent = this, Text = " B", Width = 40, Top = 5 + squareColorlenght + 50, Left = labelRed.Width * 2 + 15, }; textBoxBlue = new TextBox { Parent = this, Left = labelRed.Width * 2 + 15, Top = labelRed.Top + labelRed.Height + 2, Width = 40, Text = "1" }; UpdateRGBFromColor(); #endregion background.BringToFront(); oldColor = _oldColor; Color = oldColor; positionSquareColor = PositionFromColor(Color); #region Events squareColorPalette.MouseDown += delegate { OnMouseDown(new MouseEventArgs()); }; squareColorPalette.MousePress += delegate { OnMousePress(new MouseEventArgs()); }; squareColorPalette.MouseUp += delegate { OnMouseUp(new MouseEventArgs()); }; intensityLevelBar.MouseDown += delegate { OnMouseDown(new MouseEventArgs()); }; intensityLevelBar.MousePress += delegate { OnMousePress(new MouseEventArgs()); }; intensityLevelBar.MouseUp += delegate { OnMouseUp(new MouseEventArgs()); }; #endregion } // ColorPickerDialog
public CreateWorldDialog(Manager manager, LobbyWindow parent) : base(manager) { roomList = parent; //Setup the window Text = "Create World"; TopPanel.Visible = false; Resizable = false; Width = 250; Height = 190; Center(); //Add controls lblName = new Label(manager) { Left = 8, Top = 8, Text = "Name:", Width = this.ClientWidth - 16 }; lblName.Init(); Add(lblName); txtName = new TextBox(manager) { Left = 8, Top = lblName.Bottom + 4, Width = this.ClientWidth - 16 }; txtName.Init(); txtName.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (txtName.Text.Length > Bricklayer.Common.Networking.Messages.CreateRoomMessage.MaxNameLength) { txtName.Text = txtName.Text.Truncate(Bricklayer.Common.Networking.Messages.CreateRoomMessage.MaxNameLength); } }); Add(txtName); lblDescription = new Label(manager) { Left = 8, Top = txtName.Bottom + 4, Text = "Description:", Width = this.ClientWidth - 16 }; lblDescription.Init(); Add(lblDescription); txtDescription = new TextBox(manager) { Left = 8, Top = lblDescription.Bottom + 4, Width = this.ClientWidth - 16, Height = 34, Mode = TextBoxMode.Multiline, ScrollBars = ScrollBars.None }; txtDescription.Init(); txtDescription.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { //Filter the text by checking for length and lines if (txtDescription.Text.Length > Bricklayer.Common.Networking.Messages.CreateRoomMessage.MaxDescriptionLength) { txtDescription.Text = txtDescription.Text.Truncate(Bricklayer.Common.Networking.Messages.CreateRoomMessage.MaxDescriptionLength); } int newLines = txtDescription.Text.Count(c => c == '\n'); if (newLines >= Bricklayer.Common.Networking.Messages.CreateRoomMessage.MaxDescriptionLines) { txtDescription.Text = txtDescription.Text.Substring(0, txtDescription.Text.Length - 1); txtDescription.CursorPosition = 0; } }); Add(txtDescription); createBtn = new Button(manager) { Top = 8, Text = "Create" }; createBtn.Init(); createBtn.Left = (Width / 2) - (createBtn.Width / 2); createBtn.Click += CreateBtn_Click; BottomPanel.Add(createBtn); }
public CreateLevelDialog(Manager manager, LobbyScreen screen) : base(manager) { this.screen = screen; // Setup the window Text = "Create Level"; TopPanel.Visible = false; Resizable = false; Width = 250; Height = 196; Center(); // Add controls lblName = new Label(manager) { Left = 8, Top = 8, Text = "Name:", Width = ClientWidth - 16 }; lblName.Init(); Add(lblName); txtName = new TextBox(manager) { Left = 8, Top = lblName.Bottom + 4, Width = ClientWidth - 16 }; txtName.Init(); txtName.TextChanged += (sender, args) => { // If you're trying to fix this function, please check out line 77 first. if (txtName.Text.Length > CreateLevelMessage.MaxNameLength) { txtName.Text = txtName.Text.Truncate(CreateLevelMessage.MaxNameLength); } createBtn.Enabled = !string.IsNullOrWhiteSpace(txtName.Text); // Makes sure aspects like text selection rendering gets covered by MonoForce args.Handled = false; }; Add(txtName); lblDescription = new Label(manager) { Left = 8, Top = txtName.Bottom + 4, Text = "Description:", Width = ClientWidth - 16 }; lblDescription.Init(); Add(lblDescription); txtDescription = new TextBox(manager) { Left = 8, Top = lblDescription.Bottom + 4, Width = ClientWidth - 16, Height = 40, Mode = TextBoxMode.Multiline, ScrollBars = ScrollBars.None }; txtDescription.Init(); txtDescription.TextChanged += (sender, args) => { // Dear maintainer: // // If you've come here to avoid the truncation and instead // stop the player from typing those characters on the first place // then you're reading the right comment, because I already tried it! // // Here is why it doesn't work: // * NeoForce just straight ignore args.Handled on this function; // * KeyDown works however if you hold down a key it just ignores your code; // * KeyUp is useless, as is KeyPress; // // Once you are done trying to 'fix' this routine, and have realized // what a terrible mistake that was, please increment the following // counter as a warning to the next guy: // // total_hours_wasted_here = 4 if (txtDescription.Text.Length > CreateLevelMessage.MaxDescriptionLength) { txtDescription.Text = txtDescription.Text.Truncate(CreateLevelMessage.MaxDescriptionLength); } var newLines = txtDescription.Text.Count(c => c == '\n') + 1; // There is always one line! if (newLines > CreateLevelMessage.MaxDescriptionLines) { txtDescription.Text = string.Join("\n", txtDescription.Text.Split('\n'), 0, CreateLevelMessage.MaxDescriptionLines); txtDescription.CursorPosition = txtDescription.Text.Length - 1; } // Makes sure aspects like text selection rendering gets covered by MonoForce // Works everytime, 50% of the time. args.Handled = false; }; Add(txtDescription); createBtn = new Button(manager) { Top = 8, Text = "Create", Enabled = false }; createBtn.Init(); createBtn.Left = (Width / 2) - (createBtn.Width / 2); createBtn.Click += CreateBtn_Click; BottomPanel.Add(createBtn); }
public MessageBox(Manager manager, MessageBoxType Type, string message, string title) : base(manager) { ClientWidth = (int)Manager.Skin.Controls["Label"].Layers[0].Text.Font.Resource.MeasureString(message).X + 48 + 16 + 16 + 16; ClientHeight = 120; TopPanel.Visible = false; IconVisible = true; Resizable = false; if (title == string.Empty) { Text = Manager.Game.Window.Title; } else { Title = title; } Center(); imgIcon = new ImageBox(Manager); imgIcon.Init(); imgIcon.Image = Manager.Skin.Images["Icon.Question"].Resource; imgIcon.Left = 16; imgIcon.Top = 16; imgIcon.Width = 48; imgIcon.Height = 48; imgIcon.SizeMode = SizeMode.Stretched; lblMessage = new Label(Manager); lblMessage.Init(); lblMessage.Left = 80; lblMessage.Top = 16; lblMessage.Width = ClientWidth - lblMessage.Left; lblMessage.Height = (int)Manager.Skin.Fonts["Default8"].Resource.MeasureRichString(message, Manager).Y; lblMessage.Alignment = Alignment.MiddleCenter; lblMessage.Text = message; BottomPanel.Show(); BottomPanel.Visible = true; buttons = new List <Button>(); if (Type == MessageBoxType.Okay || Type == MessageBoxType.Cancel) { buttons.Add(new Button(Manager)); buttons[0].Init(); buttons[0].Top = 8; buttons[0].Left = (BottomPanel.ClientWidth / 2) - (buttons[0].Width / 2); buttons[0].Text = (Type == MessageBoxType.Okay ? "Okay" : "Cancel"); buttons[0].ModalResult = (Type == MessageBoxType.Okay ? ModalResult.Ok : ModalResult.Cancel); imgIcon.Image = Manager.Skin.Images["Icon.Information"].Resource; BottomPanel.Add(buttons[0]); } else if (Type == MessageBoxType.Error) { buttons.Add(new Button(Manager)); buttons[0].Init(); buttons[0].Top = 8; buttons[0].Left = (BottomPanel.ClientWidth / 2) - (buttons[0].Width / 2); buttons[0].Text = "Okay"; buttons[0].ModalResult = ModalResult.Ok; imgIcon.Image = Manager.Skin.Images["Icon.Error"].Resource; BottomPanel.Add(buttons[0]); } else if (Type == MessageBoxType.Warning) { buttons.Add(new Button(Manager)); buttons[0].Init(); buttons[0].Top = 8; buttons[0].Left = (BottomPanel.ClientWidth / 2) - (buttons[0].Width / 2); buttons[0].Text = "Okay"; buttons[0].ModalResult = ModalResult.Ok; imgIcon.Image = Manager.Skin.Images["Icon.Warning"].Resource; BottomPanel.Add(buttons[0]); } else if (Type == MessageBoxType.YesNo) { buttons.Add(new Button(Manager)); buttons[0].Init(); buttons[0].Top = 8; buttons[0].Left = (BottomPanel.ClientWidth / 2) - buttons[0].Width - 4; buttons[0].Text = "Yes"; buttons[0].ModalResult = ModalResult.Yes; buttons.Add(new Button(Manager)); buttons[1].Init(); buttons[1].Top = buttons[0].Top; buttons[1].Left = (BottomPanel.ClientWidth / 2) + 4; buttons[1].Text = "No"; buttons[1].ModalResult = ModalResult.No; imgIcon.Image = Manager.Skin.Images["Icon.Question"].Resource; BottomPanel.Add(buttons[0]); BottomPanel.Add(buttons[1]); } else if (Type == MessageBoxType.YesNoCancel) { buttons.Add(new Button(Manager)); buttons[0].Init(); buttons[0].Text = "Yes"; buttons[0].Top = 8; buttons[0].Left = (BottomPanel.ClientWidth / 2) - (int)((buttons[0].Width) * 1.5f) - 4; buttons[0].ModalResult = ModalResult.Yes; buttons.Add(new Button(Manager)); buttons[1].Init(); buttons[1].Text = "No"; buttons[1].Top = buttons[0].Top; buttons[1].Left = (BottomPanel.ClientWidth / 2) - (buttons[0].Width / 2); buttons[1].ModalResult = ModalResult.No; buttons.Add(new Button(Manager)); buttons[2].Init(); buttons[2].Text = "Cancel"; buttons[2].Top = buttons[0].Top; buttons[2].Left = (BottomPanel.ClientWidth / 2) + (int)((buttons[0].Width) * .5f) + 4; buttons[2].ModalResult = ModalResult.Cancel; imgIcon.Image = Manager.Skin.Images["Icon.Question"].Resource; BottomPanel.Add(buttons[0]); BottomPanel.Add(buttons[1]); BottomPanel.Add(buttons[2]); } Add(imgIcon); Add(lblMessage); DefaultControl = buttons[0]; }
public ServerWindow(Manager manager, ServerScreen screen) : base(manager) { this.screen = screen; // Setup the window CaptionVisible = false; TopPanel.Visible = false; Movable = false; Resizable = false; Width = 550; Height = 500; Shadow = true; Center(); // Create main server list lstServers = new ControlList <ServerDataControl>(manager) { Left = 8, Top = 8, Width = ClientWidth - 16, Height = ClientHeight - BottomPanel.Height - 16, }; lstServers.Init(); Add(lstServers); RefreshServerList(); lstServers.DoubleClick += (sender, args) => { if (lstServers.ItemIndex < 0) { return; } var sdc = (ServerDataControl)lstServers.Items[lstServers.ItemIndex]; // Make sure the user clicks the item and not the empty space in the list if (sdc.CheckPositionMouse(((MouseEventArgs)args).Position - lstServers.AbsoluteRect.Location)) { this.screen.Client.Network.SendSessionRequest(servers[lstServers.ItemIndex].Host, servers[lstServers.ItemIndex].Port); } }; // Add controls to the bottom panel. (Add server, edit server, etc.) btnEdit = new Button(manager) { Text = "Edit", Top = 8, Width = 64 }; btnEdit.Init(); btnEdit.Left = (Width / 2) - (btnEdit.Width / 2); btnEdit.Click += (sender, args) => { if (lstServers.Items.Count <= 0) { return; } var window = new AddServerDialog(Manager, this, lstServers.ItemIndex, true, servers[lstServers.ItemIndex].Name, servers[lstServers.ItemIndex].Host, servers[lstServers.ItemIndex].Port); window.Init(); Manager.Add(window); window.ShowModal(); }; BottomPanel.Add(btnEdit); btnRemove = new Button(manager) { Text = "Remove", Left = btnEdit.Right + 8, Top = 8, Width = 64 }; btnRemove.Init(); btnRemove.Click += (clickSender, clickArgs) => { // Show a messagebox that asks for confirmation to delete the selected server. if (lstServers.Items.Count > 0) { var confirm = new MessageBox(manager, MessageBoxType.YesNo, "Are you sure you would like to remove\nthis server from your server list?", "Confirm Removal"); confirm.Init(); // When the message box is closed, check if the user clicked yes, if so, removed the server from the list. confirm.Closed += (closedSender, closedArgs) => { var dialog = closedSender as Dialog; if (dialog?.ModalResult != ModalResult.Yes) { return; } // If user clicked Yes servers.RemoveAt(lstServers.ItemIndex); lstServers.Items.RemoveAt(lstServers.ItemIndex); screen.Client.IO.WriteServers(servers); // Write the new server list to disk. }; Manager.Add(confirm); confirm.Show(); } }; BottomPanel.Add(btnRemove); btnAdd = new Button(manager) { Text = "Add", Top = 8, Width = 64 }; btnAdd.Init(); btnAdd.Right = btnEdit.Left - 8; btnAdd.Click += (sender, args) => { // Show add server dialog var window = new AddServerDialog(Manager, this, lstServers.ItemIndex, false, string.Empty, string.Empty, Globals.Values.DefaultServerPort); window.Init(); Manager.Add(window); window.ShowModal(); }; BottomPanel.Add(btnAdd); btnJoin = new Button(manager) { Text = "Connect", Top = 8, Width = 100 }; btnJoin.Init(); btnJoin.Right = btnAdd.Left - 8; btnJoin.Click += (sender, args) => { if (lstServers.ItemIndex < 0) { return; } btnJoin.Enabled = false; btnJoin.Text = "Connecting..."; this.screen.Client.Network.SendSessionRequest(servers[lstServers.ItemIndex].Host, servers[lstServers.ItemIndex].Port); }; BottomPanel.Add(btnJoin); btnRefresh = new Button(manager) { Text = "Refresh", Left = btnRemove.Right + 8, Top = 8, Width = 64 }; btnRefresh.Init(); btnRefresh.Click += (sender, args) => { RefreshServerList(); }; BottomPanel.Add(btnRefresh); // Listen for when init message is recieved screen.Client.Events.Network.Game.InitReceived.AddHandler(OnInit); // If user was disconnected from the server screen.Client.Events.Network.Game.Disconnected.AddHandler(OnDisconnect); }
public TaskDeath(Manager manager, string DeathMessage) : base(manager) { tb = new GradientPanel(manager); tb.Init(); tb.Width = Game.MainWindow.ClientWidth; tb.Height = Game.MainWindow.ClientHeight; tb.Left = Game.MainWindow.ClientLeft; tb.Top = Game.MainWindow.ClientTop; tb.Color = Color.Red; tb.Alpha = 0; manager.Add(tb); this.manager = manager; Height = 400; Width = 400; MinimumHeight = 100; MinimumWidth = 100; Text = "You died!"; CaptionVisible = false; Caption.Text = Description.Text = string.Empty; Center(); Movable = false; TopPanel.Visible = true; deathImage = new ImageBox(manager); deathImage.Init(); deathImage.Left = 8; deathImage.Top = 8; deathImage.Image = ContentPack.Textures["gui\\death"]; deathImage.Width = deathImage.Image.Width; deathImage.Height = deathImage.Image.Height; ClientWidth = (deathImage.Left * 2) + deathImage.Width; deathMessage = new Label(manager); deathMessage.Init(); deathMessage.Left = 8; deathMessage.Top = TopPanel.Height + 24; deathMessage.Text = DeathMessage; deathMessage.Width = (int)manager.Skin.Fonts["Default14"].Resource.MeasureRichString(deathMessage.Text, manager, true).X; deathMessage.Font = FontSize.Default14; deathMessage.Left = ((ClientWidth / 2) - (deathMessage.Width / 2)); deathMessageBG = new Label(manager); deathMessageBG.Init(); deathMessageBG.Left = 8; deathMessageBG.Top = TopPanel.Height + 23; deathMessageBG.Text = DeathMessage; deathMessage.Text = deathMessage.Text.Replace(":Red]", ":DarkRed]"); deathMessage.TextColor = Color.DimGray; deathMessageBG.Width = (int)manager.Skin.Fonts["Default14"].Resource.MeasureRichString(deathMessage.Text, manager, true).X; deathMessageBG.Font = FontSize.Default14; deathMessageBG.Left = ((ClientWidth / 2) - (deathMessage.Width / 2)) - 1; deathMessageBG.Height = deathMessage.Height = 24; Respawn = new Button(manager); Respawn.Init(); Respawn.Text = "Respawn"; Respawn.Left = ((ClientWidth / 2) - (Respawn.Width)) - 4; Respawn.Top = 8; Respawn.Click += Respawn_Click; BottomPanel.Add(Respawn); Quit = new Button(manager); Quit.Init(); Quit.Text = "Quit"; Quit.Left = (ClientWidth / 2) + 4; Quit.Top = 8; Quit.Click += Quit_Click; BottomPanel.Add(Quit); TopPanel.Add(deathImage); Add(deathMessage); Add(deathMessageBG); TopPanel.Height = (deathImage.Top * 2) + deathImage.Height; Height = TopPanel.Height + BottomPanel.Height + deathMessage.Height + 24; StayOnTop = true; FocusLost += TaskDeath_FocusLost; CanFocus = true; Focused = true; Closed += TaskDeath_Closed; }
/// <summary> /// Create a new window for editng Text tiles, eg signs /// </summary> /// <param name="manager">UI Manager Object</param> /// <param name="interact">Interaction Parameters, includes level and position of sign</param> public TaskTimer(Manager manager, InteractBlockEventArgs interact) : base(manager) { this.interact = interact; if (interact.level.tiles[interact.x, interact.y] is TimerTile) { orgTime = (interact.level.tiles[interact.x, interact.y] as TimerTile).Time; orgLength = (interact.level.tiles[interact.x, interact.y] as TimerTile).Length; } //Set up the window Text = "Edit Timer"; Resizable = false; Init(); Width = 300 + 16; ClientHeight = 142; TopPanel.Visible = false; TopPanel.Height = 0; BottomPanel.Visible = true; DefaultControl = timeBar; Center(); timeLabel = new Label(manager); timeLabel.Init(); timeLabel.Top = TopPanel.Height + 6; timeLabel.Left = 8; timeLabel.Width = ClientWidth - 32; Add(timeLabel); timeBar = new TrackBar(manager); timeBar.Init(); timeBar.Top = timeLabel.Top + timeLabel.Height + 4; timeBar.Range = (30 * 10) - 5; timeBar.Value = 0; timeBar.Width = ClientWidth - 12; timeBar.Height = 24; timeBar.Left = (ClientWidth / 2) - (timeBar.Width / 2); timeBar.ValueChanged += timeBar_ValueChanged; Add(timeBar); lengthLabel = new Label(manager); lengthLabel.Init(); lengthLabel.Top = timeBar.Top + timeBar.Height + 4; lengthLabel.Left = 8; lengthLabel.Width = ClientWidth - 32; Add(lengthLabel); lengthBar = new TrackBar(manager); lengthBar.Init(); lengthBar.Top = lengthLabel.Top + lengthLabel.Height + 4; lengthBar.Range = (30 * 10) - 5; lengthBar.Value = 0; lengthBar.Width = ClientWidth - 12; lengthBar.Height = 24; lengthBar.Left = (ClientWidth / 2) - (timeBar.Width / 2); lengthBar.ValueChanged += lengthBar_ValueChanged; Add(lengthBar); //Saves the text, Durrr Save = new Button(manager); Save.Init(); Save.Text = "Save"; Save.Width = 64; Save.Height = 24; Save.Top = 8; Save.Left = (ClientWidth / 2) - Save.Width - 8; Save.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object sender, TomShane.Neoforce.Controls.EventArgs e) { if (interact.level.tiles[interact.x, interact.y] is TimerTile) { (interact.level.tiles[interact.x, interact.y] as TimerTile).Time = time; (interact.level.tiles[interact.x, interact.y] as TimerTile).Length = length; } Close(); }); //What could this do? Cancel = new Button(manager); Cancel.Init(); Cancel.Text = "Cancel"; Cancel.Width = 64; Cancel.Height = 24; Cancel.Top = 8; Cancel.Left = (ClientWidth / 2) + 8; Cancel.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object sender, TomShane.Neoforce.Controls.EventArgs e) { if (interact.level.tiles[interact.x, interact.y] is TimerTile) { (interact.level.tiles[interact.x, interact.y] as TimerTile).Time = orgTime; (interact.level.tiles[interact.x, interact.y] as TimerTile).Length = orgLength; } Close(); //Self-Explanitory }); //Add the new controls BottomPanel.Add(Save); BottomPanel.Add(Cancel); if (interact.level.tiles[interact.x, interact.y] is TimerTile) { timeBar.Value = (int)(((interact.level.tiles[interact.x, interact.y] as TimerTile).Time * 10) - 5); lengthBar.Value = (int)(((interact.level.tiles[interact.x, interact.y] as TimerTile).Length * 10) - 5); timeBar_ValueChanged(null, null); lengthBar_ValueChanged(null, null); } }
public LobbyWindow(Manager manager, LobbyScreen screen) : base(manager) { lobbyScreen = screen; // Setup the window CaptionVisible = false; TopPanel.Visible = false; Movable = false; Resizable = false; Width = (int)(Manager.ScreenWidth * .9); Height = (int)(Manager.ScreenHeight * .9); Shadow = true; Center(); // Group panels grpServer = new GroupPanel(Manager) { Left = ClientWidth - Globals.Values.MaxBannerWidth - 1, Width = Globals.Values.MaxBannerWidth, Height = ClientHeight - BottomPanel.Height + 2, Text = "Server" }; grpServer.Init(); Add(grpServer); var grpLobby = new GroupPanel(Manager) { Width = ClientWidth - grpServer.Width, // Fill remaining space Height = ClientHeight - BottomPanel.Height + 2, Text = "Levels" }; grpLobby.Init(); Add(grpLobby); // Top controls txtSearch = new TextBox(Manager) { Left = 8, Top = 8, Width = (int)((grpLobby.Width / 2d) - 16) }; txtSearch.Init(); txtSearch.Text = searchStr; txtSearch.TextChanged += (sender, args) => { RefreshLevels(); }; // Show "Search..." text, but make it dissapear on focus txtSearch.FocusGained += (sender, args) => { if (txtSearch.Text.Trim() == searchStr) { txtSearch.Text = string.Empty; } }; txtSearch.FocusLost += (sender, args) => { if (txtSearch.Text.Trim() == string.Empty) { txtSearch.Text = searchStr; } }; grpLobby.Add(txtSearch); cmbSort = new ComboBox(Manager) { Left = txtSearch.Right + 8, Top = 8, Width = (grpLobby.Width / 2) - 16 - 20 }; cmbSort.Init(); cmbSort.Items.AddRange(sortFilters); cmbSort.ItemIndex = 0; cmbSort.ItemIndexChanged += (sender, args) => { RefreshLevels(); }; grpLobby.Add(cmbSort); var btnReload = new Button(Manager) { Left = cmbSort.Right + 8, Top = 8, Width = 20, Height = 20, Text = string.Empty }; btnReload.Init(); btnReload.Glyph = new Glyph(screen.Client.Content["gui.icons.refresh"]); btnReload.ToolTip.Text = "Refresh"; btnReload.Click += (sender, args) => { btnReload.Enabled = false; lobbyScreen.Client.Network.Send(new RequestMessage(MessageTypes.Init)); }; grpLobby.Add(btnReload); // Main level list lstLevels = new ControlList <LobbyDataControl>(Manager) { Left = 8, Top = txtSearch.Bottom + 8, Width = grpLobby.Width - 16, Height = grpLobby.Height - 16 - txtSearch.Bottom - 24 }; lstLevels.Init(); lstLevels.DoubleClick += (sender, args) => { if (lstLevels.ItemIndex < 0) { return; } var ldc = (LobbyDataControl)lstLevels.Items[lstLevels.ItemIndex]; // Make sure the user clicks the item and not the empty space in the list if (ldc.CheckPositionMouse(((MouseEventArgs)args).Position - lstLevels.AbsoluteRect.Location)) { JoinLevel(lstLevels.ItemIndex); } }; grpLobby.Add(lstLevels); // Server info labels lblName = new Label(Manager) { Text = "Loading...", Top = 8, Font = FontSize.Default20, Left = 8, Alignment = Alignment.MiddleCenter, Height = 30, Width = grpServer.ClientWidth - 16 }; lblName.Init(); grpServer.Add(lblName); lblDescription = new Label(Manager) { Text = string.Empty, Top = 8 + lblName.Bottom, Left = 8, Alignment = Alignment.MiddleCenter, Width = grpServer.ClientWidth - 16 }; lblDescription.Init(); grpServer.Add(lblDescription); lblInfo = new Label(Manager) { Text = string.Empty, Top = 8 + lblDescription.Bottom, Left = 8, Alignment = Alignment.TopLeft, Width = grpServer.ClientWidth - 16, Height = grpServer.Height }; lblInfo.Init(); grpServer.Add(lblInfo); // Bottom buttons var btnCreate = new Button(Manager) { Top = 8, Text = "Create" }; btnCreate.Left = (ClientWidth / 2) - (btnCreate.Width / 2); btnCreate.Init(); btnCreate.Click += (sender, args) => { var window = new CreateLevelDialog(manager, screen); window.Init(); Manager.Add(window); window.ShowModal(); }; BottomPanel.Add(btnCreate); var btnJoin = new Button(Manager) { Right = btnCreate.Left - 8, Top = 8, Text = "Join" }; btnJoin.Init(); btnJoin.Click += (sender, args) => { JoinLevel(lstLevels.ItemIndex); }; BottomPanel.Add(btnJoin); var btnDisconnect = new Button(Manager) { Left = btnCreate.Right + 8, Top = 8, Text = "Quit" }; btnDisconnect.Init(); btnDisconnect.Click += (sender, args) => { lobbyScreen.Client.Network.NetClient.Disconnect("Left Lobby"); MainWindow.ScreenManager.SwitchScreen(new LoginScreen()); }; BottomPanel.Add(btnDisconnect); // When client gets banner data from server screen.Client.Events.Network.Game.LobbyBannerReceived.AddHandler(LobbyBannerReceived); // When client receives level data after joining/creating a level screen.Client.Events.Network.Game.LevelDataReceived.AddHandler(LevelDataReceived); // When the lobby data is received (after connecting or on reload) screen.Client.Events.Network.Game.InitReceived.AddHandler(InitReceived); LoadLevels(); screen.Client.Network.Send(new RequestMessage(MessageTypes.Banner)); }
public TaskProfile(Manager manager) : base(manager) { LoadContent(); CreateColorPickers(manager); IO.LoadPlayerSkin(this); Resizable = false; BottomPanel.Top -= 16; Height = 256; Width = 550; Text = "Profile"; Center(); TopPanel.Visible = true; Caption.Text = "Profile - " + Game.UserName; Caption.TextColor = Description.TextColor = new Color(96, 96, 96); //Cant close form unless character is made bool CanClose = IO.ProfileExists(); Savebtn = new Button(manager); Savebtn.Init(); Savebtn.Top = 8; Savebtn.Left = CanClose ? (Width / 2) - Savebtn.Width - 4 : (Width / 2) - (Savebtn.Width / 2); Savebtn.Text = CanClose ? "Save" : "Create"; Savebtn.Click += Savebtn_Click; BottomPanel.Add(Savebtn); if (CanClose) { Cancelbtn = new Button(manager); Cancelbtn.Init(); Cancelbtn.Top = 8; Cancelbtn.Left = (Width / 2) + 4; Cancelbtn.Text = "Cancel"; Cancelbtn.Click += Cancelbtn_Click; BottomPanel.Add(Cancelbtn); } else { CaptionVisible = false; Movable = false; StayOnTop = true; } CloseButton.Enabled = CanClose; if (CanClose) { Description.Text = "Customize your character's personality!"; } else { Description.Text = "[color:Gold]Create your character to continue![/color]"; } Emotionlbl = new Label(manager); Emotionlbl.Init(); Emotionlbl.Left = 16 + 8; Emotionlbl.Top = TopPanel.Height + ClientArea.Top - 24; Emotionlbl.Text = "Expression:"; Emotionlbl.Width = 120; Emotionlbl.Alignment = Alignment.MiddleRight; Add(Emotionlbl); EmotionSpn = new SpinBox(manager, SpinBoxMode.List); EmotionSpn.Init(); EmotionSpn.Top = TopPanel.Height + ClientArea.Top - 24; EmotionSpn.Left = 16 + 8 + 124; EmotionSpn.Items.Add("Neutral"); EmotionSpn.Items.Add("Happy"); EmotionSpn.Items.Add("Sad"); EmotionSpn.Items.Add("Smile"); EmotionSpn.Width = 100; EmotionSpn.ItemIndex = ExpressionVariation; EmotionSpn.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { ExpressionVariation = EmotionSpn.ItemIndex; }); Add(EmotionSpn); Shirtlbl = new Label(manager); Shirtlbl.Init(); Shirtlbl.Left = 16 + 8; Shirtlbl.Top = TopPanel.Height + ClientArea.Top - 2; Shirtlbl.Text = "Shirt Style:"; Shirtlbl.Width = 120; Shirtlbl.Alignment = Alignment.MiddleRight; Add(Shirtlbl); ShirtSpn = new SpinBox(manager, SpinBoxMode.List); ShirtSpn.Init(); ShirtSpn.Top = TopPanel.Height + ClientArea.Top - 2; ShirtSpn.Left = 16 + 8 + 124; ShirtSpn.Items.Add("Long"); ShirtSpn.Items.Add("Short"); ShirtSpn.Width = 100; ShirtSpn.ItemIndex = ShirtSleeveVariation; ShirtSpn.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { ShirtSleeveVariation = ShirtSpn.ItemIndex; }); Add(ShirtSpn); Pantslbl = new Label(manager); Pantslbl.Init(); Pantslbl.Left = 16 + 8; Pantslbl.Top = TopPanel.Height + ClientArea.Top + 20; Pantslbl.Text = "Pants Style:"; Pantslbl.Width = 120; Pantslbl.Alignment = Alignment.MiddleRight; Add(Pantslbl); PantsSpn = new SpinBox(manager, SpinBoxMode.List); PantsSpn.Init(); PantsSpn.Top = TopPanel.Height + ClientArea.Top + 20; PantsSpn.Left = 16 + 8 + 124; PantsSpn.Items.Add("Long"); PantsSpn.Items.Add("Short"); PantsSpn.Width = 100; PantsSpn.ItemIndex = PantsLegVariation; PantsSpn.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { PantsLegVariation = PantsSpn.ItemIndex; }); Add(PantsSpn); Hairlbl = new Label(manager); Hairlbl.Init(); Hairlbl.Left = 16 + 8; Hairlbl.Top = TopPanel.Height + ClientArea.Top + 42; Hairlbl.Text = "Hair Style:"; Hairlbl.Width = 120; Hairlbl.Alignment = Alignment.MiddleRight; Add(Hairlbl); HairSpn = new SpinBox(manager, SpinBoxMode.List); HairSpn.Init(); HairSpn.Top = TopPanel.Height + ClientArea.Top + 42; HairSpn.Left = 16 + 8 + 124; HairSpn.Items.Add("Undefined"); HairSpn.Width = 100; HairSpn.ItemIndex = HairVariation; HairSpn.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { HairVariation = HairSpn.ItemIndex; }); Add(HairSpn); Shoeslbl = new Label(manager); Shoeslbl.Init(); Shoeslbl.Left = 16 + 8; Shoeslbl.Top = TopPanel.Height + ClientArea.Top + 64; Shoeslbl.Text = "Shoe Style:"; Shoeslbl.Width = 120; Shoeslbl.Alignment = Alignment.MiddleRight; Add(Shoeslbl); ShoesSpn = new SpinBox(manager, SpinBoxMode.List); ShoesSpn.Init(); ShoesSpn.Top = TopPanel.Height + ClientArea.Top + 64; ShoesSpn.Left = 16 + 8 + 124; ShoesSpn.Items.Add("Normal"); ShoesSpn.Items.Add("Boots"); ShoesSpn.Items.Add("Flat"); ShoesSpn.Width = 100; ShoesSpn.ItemIndex = ShoeVariation; ShoesSpn.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { ShoeVariation = ShoesSpn.ItemIndex; }); Add(ShoesSpn); //Have to ajust if (!CaptionVisible) { Emotionlbl.Top += 20; EmotionSpn.Top += 20; Shirtlbl.Top += 20; ShirtSpn.Top += 20; Pantslbl.Top += 20; PantsSpn.Top += 20; Shoeslbl.Top += 20; ShoesSpn.Top += 20; Hairlbl.Top += 20; HairSpn.Top += 20; Height -= 20; } }
public LoginWindow(Manager manager, LoginScreen screen) : base(manager) { this.screen = screen; // Events // Listen for valid response from auth server screen.Client.Events.Network.Auth.InitReceived.AddHandler(OnInit); // Listen for failed login response from auth server screen.Client.Events.Network.Auth.FailedLogin.AddHandler(OnFailedLogin); // Setup the window CaptionVisible = false; Caption.Text = "Welcome to Bricklayer!"; Description.Text = "An open source, fully moddable and customizable 2D\nbuilding game."; Movable = false; Resizable = false; Width = 450; Height = 218; TopPanel.Height = 72; Shadow = true; Center(); // Text boxes txtUsername = new TextBox(Manager); txtUsername.Init(); txtUsername.Width = ClientWidth / 2 - 16; txtUsername.Left = 8; txtUsername.Top = TopPanel.Bottom + 8; txtUsername.Placeholder = "Username"; txtUsername.Text = screen.Client.IO.Config.Client.Username; Add(txtUsername); txtPassword = new TextBox(Manager); txtPassword.Init(); txtPassword.Width = txtUsername.Width; txtPassword.Left = txtUsername.Left; txtPassword.Top = txtUsername.Bottom + 8; txtPassword.Placeholder = "Password"; txtPassword.Text = screen.Client.IO.GetPassword(); txtPassword.Mode = TextBoxMode.Password; Add(txtPassword); chkRemember = new CheckBox(Manager); chkRemember.Init(); chkRemember.Width = txtUsername.Width; chkRemember.Left = txtUsername.Right + 16; chkRemember.Top = txtPassword.Top + 3; chkRemember.Text = "Remember Me"; chkRemember.Checked = screen.Client.IO.Config.Client.RememberMe; Add(chkRemember); // Sign in buttons btnLoginAccount = new Button(Manager); btnLoginAccount.Init(); btnLoginAccount.Width = txtUsername.Width; btnLoginAccount.Left = txtUsername.Left; btnLoginAccount.Top = 8; btnLoginAccount.Click += LoginAccountClick; btnLoginAccount.Text = "Sign in"; BottomPanel.Add(btnLoginAccount); btnLoginGuest = new Button(Manager); btnLoginGuest.Enabled = false; btnLoginGuest.Init(); btnLoginGuest.Width = btnLoginAccount.Width; btnLoginGuest.Left = btnLoginAccount.Right + 16; btnLoginGuest.Top = btnLoginAccount.Top; btnLoginGuest.Text = "Try as Guest"; BottomPanel.Add(btnLoginGuest); // Links lnkForgot = new LinkLabel(Manager); lnkForgot.Init(); lnkForgot.Width = txtUsername.Width; lnkForgot.Alignment = Alignment.MiddleCenter; lnkForgot.Left = txtUsername.Left; lnkForgot.Top = btnLoginAccount.Bottom + 8; lnkForgot.Text = "Forgot Password?"; lnkForgot.URL = Constants.Strings.ForgotPasswordURL; lnkForgot.ToolTip = new ToolTip(Manager) { Text = "A new browser window will be opened." }; BottomPanel.Add(lnkForgot); lnkCreateAccount = new LinkLabel(Manager); lnkCreateAccount.Init(); lnkCreateAccount.Width = txtUsername.Width; lnkCreateAccount.Alignment = Alignment.MiddleCenter; lnkCreateAccount.Left = btnLoginGuest.Left; lnkCreateAccount.Top = lnkForgot.Top; lnkCreateAccount.Text = "Create an account"; lnkCreateAccount.URL = Constants.Strings.CreateAccountURL; BottomPanel.Add(lnkCreateAccount); // Color selector bodyClr = new ColorPicker(Manager) { Left = txtUsername.Right + 16, Top = txtUsername.Top, Width = txtUsername.Width - 18 - 8, Saturation = 210, Value = 250 }; bodyClr.Init(); bodyClr.ValueChanged += (sender, args) => { BodyImg.Color = bodyClr.SelectedColor; // TODO: Update value in the game class }; Add(bodyClr); BodyImg = new ImageBox(Manager) { Left = bodyClr.Right + 8, Top = bodyClr.Top, Width = 18, Height = 18, Image = screen.Client.Content["entity.body"] }; BodyImg.Init(); Add(BodyImg); SmileyImg = new ImageBox(Manager) { Left = BodyImg.Left, Top = BodyImg.Top, Width = 18, Height = 18, Image = screen.Client.Content["entity.smileys"], SourceRect = new Rectangle(0, 0, 18, 18) }; SmileyImg.Init(); SmileyImg.ToolTip.Text = "I love this color!"; Add(SmileyImg); bodyClr.Hue = screen.Client.IO.Config.Client.Color; BottomPanel.Height = lnkForgot.Bottom + 28; BottomPanel.Top = Height - BottomPanel.Height; }
public AddServerDialog(Manager manager, ServerWindow parent, int index, bool edit, string name, string host, int port) : base(manager) { // Are we editing a server or adding one (They use same dialog) this.edit = edit; this.index = index; wndServer = parent; // Setup the window Text = this.edit ? "Edit Server" : "Add Server"; TopPanel.Visible = false; Resizable = false; Width = 250; Height = 180; Center(); // Add controls lblName = new Label(manager) { Left = 8, Top = 8, Text = "Name:", Width = ClientWidth - 16 }; lblName.Init(); Add(lblName); txtName = new TextBox(manager) { Left = 8, Top = lblName.Bottom + 4, Width = ClientWidth - 16 }; txtName.Init(); txtName.Text = name; txtName.TextChanged += TxtNameTextChanged; Add(txtName); lblHost = new Label(manager) { Left = 8, Top = txtName.Bottom + 8, Text = $"Address: (Default port is {Globals.Values.DefaultServerPort})", Width = ClientWidth - 16 }; lblHost.Init(); Add(lblHost); txtHost = new TextBox(manager) { Left = 8, Top = lblHost.Bottom + 4, Width = ClientWidth - 16 }; txtHost.Init(); txtHost.Text = port != 0 && port != Globals.Values.DefaultServerPort ? $"{host}:{port}" : host; txtHost.TextChanged += TxtHostTextChanged; Add(txtHost); btnSave = new Button(manager) { Top = 8, Text = this.edit ? "Save" : "Add" }; btnSave.Init(); btnSave.Left = (Width / 2) - (btnSave.Width / 2); btnSave.Click += BtnSaveClick; BottomPanel.Add(btnSave); if (this.edit) { Validate(); // Validate existing text } }
public AddServerDialog(Manager manager, ServerWindow parent, int index, bool edit, string name, string address) : base(manager) { //Are we editing a server or adding one (They use same dialog) Edit = edit; Index = index; ServerList = parent; //Setup the window Text = Edit ? "Edit Server" : "Add Server"; TopPanel.Visible = false; Resizable = false; Width = 250; Height = 180; Center(); //Add controls NameLbl = new Label(manager) { Left = 8, Top = 8, Text = "Name:", Width = this.ClientWidth - 16 }; NameLbl.Init(); Add(NameLbl); NameTxt = new TextBox(manager) { Left = 8, Top = NameLbl.Bottom + 4, Width = this.ClientWidth - 16 }; NameTxt.Init(); NameTxt.Text = name; NameTxt.TextChanged += NameTxt_TextChanged; Add(NameTxt); AddressLbl = new Label(manager) { Left = 8, Top = NameTxt.Bottom + 8, Text = string.Format("Address: (Default port is {0})", Bricklayer.Common.GlobalSettings.DefaultPort), Width = this.ClientWidth - 16 }; AddressLbl.Init(); Add(AddressLbl); AddressTxt = new TextBox(manager) { Left = 8, Top = AddressLbl.Bottom + 4, Width = this.ClientWidth - 16 }; AddressTxt.Init(); AddressTxt.Text = address; AddressTxt.TextChanged += AddressTxt_TextChanged; Add(AddressTxt); SaveBtn = new Button(manager) { Top = 8, Text = Edit ? "Save" : "Add", }; SaveBtn.Init(); SaveBtn.Left = (Width / 2) - (SaveBtn.Width / 2); SaveBtn.Click += SaveBtn_Click; SaveBtn.Enabled = false; BottomPanel.Add(SaveBtn); if (Edit) { Validate(); //Validate existing text } }
public LobbyWindow(Manager manager) : base(manager) { //Setup the window CaptionVisible = false; TopPanel.Visible = false; Movable = false; Resizable = false; Width = 700; Height = 500; Shadow = true; Center(); //Group panels grpLobby = new GroupPanel(Manager) { Width = ClientWidth / 2, Height = ClientHeight - BottomPanel.Height + 2, Text = "Rooms" }; grpLobby.Init(); Add(grpLobby); grpServer = new GroupPanel(Manager) { Left = (ClientWidth / 2) - 1, Width = (ClientWidth / 2) + 1, Height = ClientHeight - BottomPanel.Height + 2, Text = "Server" }; grpServer.Init(); Add(grpServer); //Top controls txtSearch = new TextBox(Manager) { Left = 8, Top = 8, Width = (ClientWidth / 4) - 16, }; txtSearch.Init(); txtSearch.Text = searchStr; txtSearch.TextChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { RefreshRooms(); }); //Show "Search..." text, but make it dissapear on focus txtSearch.FocusGained += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (txtSearch.Text.Trim() == searchStr) { txtSearch.Text = string.Empty; } }); txtSearch.FocusLost += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (txtSearch.Text.Trim() == string.Empty) { txtSearch.Text = searchStr; } }); grpLobby.Add(txtSearch); cmbSort = new ComboBox(Manager) { Left = txtSearch.Right + 8, Top = 8, Width = (ClientWidth / 4) - 16 - 20, }; cmbSort.Init(); cmbSort.Items.AddRange(sortFilters); cmbSort.ItemIndex = 0; cmbSort.ItemIndexChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { RefreshRooms(); }); grpLobby.Add(cmbSort); btnReload = new Button(Manager) { Left = cmbSort.Right + 8, Top = 8, Width = 20, Height = 20, Text = string.Empty, }; btnReload.Init(); btnReload.Glyph = new Glyph(ContentPack.Textures["gui\\icons\\refresh"]); btnReload.ToolTip.Text = "Refresh"; btnReload.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { Game.NetManager.Send(new RequestMessage(MessageTypes.Lobby)); }); grpLobby.Add(btnReload); //Main room list RoomListCtrl = new ControlList <LobbyDataControl>(Manager) { Left = 8, Top = txtSearch.Bottom + 8, Width = grpLobby.Width - 16, Height = grpLobby.Height - 16 - txtSearch.Bottom - 24 }; RoomListCtrl.Init(); grpLobby.Add(RoomListCtrl); //Server info labels lblName = new Label(Manager) { Text = "Loading...", Top = 8, Font = FontSize.Default20, Left = 8, Alignment = Alignment.MiddleCenter, Height = 30, Width = grpServer.ClientWidth - 16 }; lblName.Init(); grpServer.Add(lblName); lblDescription = new Label(Manager) { Text = string.Empty, Top = 8 + lblName.Bottom, Left = 8, Alignment = Alignment.MiddleCenter, Width = grpServer.ClientWidth - 16 }; lblDescription.Init(); grpServer.Add(lblDescription); lblInfo = new Label(Manager) { Text = string.Empty, Top = 8 + lblDescription.Bottom, Left = 8, Alignment = Alignment.TopLeft, Width = grpServer.ClientWidth - 16, Height = grpServer.Height }; lblInfo.Init(); grpServer.Add(lblInfo); //Bottom buttons btnCreate = new Button(Manager) { Top = 8, Text = "Create" }; btnCreate.Left = (ClientWidth / 2) - (btnCreate.Width / 2); btnCreate.Init(); btnCreate.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { CreateWorldDialog window = new CreateWorldDialog(manager, this); window.Init(); Manager.Add(window); window.Show(); }); BottomPanel.Add(btnCreate); btnJoin = new Button(Manager) { Right = btnCreate.Left - 8, Top = 8, Text = "Join" }; btnJoin.Init(); btnJoin.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { JoinRoom(RoomListCtrl.ItemIndex); }); BottomPanel.Add(btnJoin); btnDisconnect = new Button(Manager) { Left = btnCreate.Right + 8, Top = 8, Text = "Quit" }; btnDisconnect.Init(); btnDisconnect.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { Game.NetManager.Disconnect("Left Lobby"); Game.CurrentGameState = GameState.Login; Interface.MainWindow.ScreenManager.SwitchScreen(new LoginScreen()); }); BottomPanel.Add(btnDisconnect); //When finished, request server send lobby data Game.NetManager.Send(new RequestMessage(MessageTypes.Lobby)); }
public ServerWindow(Manager manager) : base(manager) { //Setup server pinger/query Pinger = new ServerPinger(); //Setup the window CaptionVisible = false; Caption.Text = "Welcome to Bricklayer!"; Description.Text = "An open source, fully moddable and customizable 2D\nbuilding game built with the community in mind."; Movable = false; Resizable = false; Width = 450; Height = 350; Shadow = true; Center(); //Player config NameLbl = new Label(Manager) { Left = 8, Top = TopPanel.Bottom + 10, Width = 64, Text = "Username:"******"Color:" }; ColorLbl.Init(); Add(ColorLbl); BodyClr = new ColorPicker(Manager) { Left = ColorLbl.Right + 4, Top = TopPanel.Bottom + 8, Width = 128, Saturation = GlobalSettings.ColorSaturation, Value = GlobalSettings.ColorValue }; BodyClr.Init(); BodyClr.ValueChanged += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { BodyImg.Color = BodyClr.SelectedColor; Game.MyColor = BodyClr.SelectedColor; Game.MyHue = BodyClr.Hue; }); Add(BodyClr); BodyImg = new ImageBox(Manager) { Left = BodyClr.Right + 6, Top = TopPanel.Bottom + 8, Width = 18, Height = 18, Color = Game.MyColor, Image = ContentPack.Textures["entity\\body"] }; BodyImg.Init(); Add(BodyImg); SmileyImg = new ImageBox(Manager) { Left = BodyClr.Right + 6, Top = TopPanel.Bottom + 8, Width = 18, Height = 18, Image = ContentPack.Textures["entity\\smileys"], SourceRect = new Rectangle(0, 0, 18, 18) }; SmileyImg.Init(); SmileyImg.ToolTip.Text = "I love this color!"; Add(SmileyImg); BodyClr.Hue = Game.MyHue; //Create main server list ServerListCtrl = new ControlList <ServerDataControl>(manager) { Left = 8, Top = TopPanel.Bottom + 34, Width = ClientWidth - 16, Height = ClientHeight - TopPanel.Height - BottomPanel.Height - 42 }; ServerListCtrl.Init(); Add(ServerListCtrl); RefreshServerList(); //Add BottomPanel controls JoinBtn = new Button(manager) { Text = "Connect", Left = 24, Top = 8, Width = 100, }; JoinBtn.Init(); JoinBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { //Logical place to save name/color settings IO.SaveSettings(new Settings() { Username = Game.Username, Color = Game.MyHue, ContentPack = Game.ContentPackName, Resolution = new Point(Game.Resolution.Width, Game.Resolution.Height), UseVSync = Game.MainWindow.Manager.Graphics.SynchronizeWithVerticalRetrace }); //Connect if (ServerListCtrl.Items.Count > 0) { if ((ServerListCtrl.Items[ServerListCtrl.ItemIndex] as ServerDataControl).Ping != null && (ServerListCtrl.Items[ServerListCtrl.ItemIndex] as ServerDataControl).Ping.Error) { return; } //Create a world and connect JoinBtn.Enabled = false; JoinBtn.Text = "Connecting..."; Game.NetManager.Connect(Servers[ServerListCtrl.ItemIndex].IP, Servers[ServerListCtrl.ItemIndex].Port); } }); BottomPanel.Add(JoinBtn); AddBtn = new Button(manager) { Text = "Add", Left = JoinBtn.Right + 8, Top = 8, Width = 64, }; AddBtn.Init(); AddBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { AddServerDialog window = new AddServerDialog(manager, this, ServerListCtrl.ItemIndex, false, string.Empty, string.Empty); window.Init(); Manager.Add(window); window.Show(); }); BottomPanel.Add(AddBtn); EditBtn = new Button(manager) { Text = "Edit", Left = AddBtn.Right + 8, Top = 8, Width = 64, }; EditBtn.Init(); EditBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (ServerListCtrl.Items.Count > 0) { AddServerDialog window = new AddServerDialog(manager, this, ServerListCtrl.ItemIndex, true, Servers[ServerListCtrl.ItemIndex].Name, Servers[ServerListCtrl.ItemIndex].GetHostString()); window.Init(); Manager.Add(window); window.Show(); } }); BottomPanel.Add(EditBtn); RemoveBtn = new Button(manager) { Text = "Remove", Left = EditBtn.Right + 8, Top = 8, Width = 64 }; RemoveBtn.Init(); RemoveBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { if (ServerListCtrl.Items.Count > 0) { MessageBox confirm = new MessageBox(manager, MessageBoxType.YesNo, "Are you sure you would like to remove\nthis server from your server list?", "[color:Red]Confirm Removal[/color]"); confirm.Init(); confirm.Closed += new WindowClosedEventHandler(delegate(object sender, WindowClosedEventArgs args) { if ((sender as Dialog).ModalResult == ModalResult.Yes) //If user clicked yes { Servers.RemoveAt(ServerListCtrl.ItemIndex); ServerListCtrl.Items.RemoveAt(ServerListCtrl.ItemIndex); IO.WriteServers(Servers); RefreshServerList(); } }); Manager.Add(confirm); confirm.Show(); } }); BottomPanel.Add(RemoveBtn); RefreshBtn = new Button(manager) { Text = "Refresh", Left = RemoveBtn.Right + 8, Top = 8, Width = 64 }; RefreshBtn.Init(); RefreshBtn.Click += new TomShane.Neoforce.Controls.EventHandler(delegate(object o, TomShane.Neoforce.Controls.EventArgs e) { RefreshServerList(); }); BottomPanel.Add(RefreshBtn); MainWindow.ScreenManager.FadeIn(); validateUsername(); }