Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FriendsForm"/> class.
        /// </summary>
        /// <param name="userInfo">The user info.</param>
        /// <param name="parent">The parent.</param>
        /// <exception cref="ArgumentNullException"><paramref name="userInfo" /> is <c>null</c>.</exception>
        public FriendsForm(UserInfo userInfo, Control parent)
            : base(parent, Vector2.Zero, new Vector2(225, 400))
        {
            if (userInfo == null)
                throw new ArgumentNullException("userInfo");

            AddBtn = new Button(this, new Vector2(30, 300), new Vector2(30, 25)) { Text = "Add" };
            AddBtn.Clicked += AddBtn_Clicked;

            RemoveBtn = new Button(this, new Vector2(90, 300), new Vector2(30, 25)) { Text = "Remove" };
            RemoveBtn.Clicked += RemoveBtn_Clicked;

            SendBtn = new Button(this, new Vector2(150, 300), new Vector2(30, 25)) { Text = "Send" };
            SendBtn.Clicked += SendBtn_Clicked;

            // Create the input and output TextBoxes
            InputTextBox = new TextBox(this, new Vector2(10, 270), new Vector2(120, 25))
            {
                IsMultiLine = false,
                IsEnabled = true,
                Font = GameScreenHelper.DefaultChatFont,
                BorderColor = new Color(255, 255, 255, 100)
            };

            _userInfo = userInfo;

            for (int i = 0; i < 50; i++)
            {
                var position = new Vector2(10, (30 + 15 * i));

                FriendsCollection[i] = new Label(this, position) { Text = "", CanFocus = false, Tag = i, Font = GameScreenHelper.DefaultChatFont };
                FriendsCollection[i].MouseDown += Friend_Clicked;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChatForm"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <param name="pos">The pos.</param>
        public ChatForm(Control parent, Vector2 pos) : base(parent, pos, new Vector2(300, 150))
        {
            // Create the input and output TextBoxes
            _input = new TextBox(this, Vector2.Zero, new Vector2(32, 32))
            {
                IsMultiLine = false,
                IsEnabled = true,
                Font = GameScreenHelper.DefaultChatFont,
                MaxInputTextLength = GameData.MaxClientSayLength,
                BorderColor = new Color(255, 255, 255, 100)
            };

            _output = new TextBox(this, Vector2.Zero, new Vector2(32, 32))
            {
                IsMultiLine = true,
                IsEnabled = false,
                Font = GameScreenHelper.DefaultChatFont,
                BorderColor = new Color(255, 255, 255, 100)
            };

            _input.KeyPressed -= Input_KeyPressed;
            _input.KeyPressed += Input_KeyPressed;
           
            // Force the initial repositioning
            RepositionTextBoxes();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var decodedPass = MachineCrypto.ValidatedDecode(ClientSettings.Default.UI_EnteredPassword) ?? string.Empty;

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the login fields
            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Name:");
            _cNameText = new TextBox(cScreen, new Vector2(220, 260), new Vector2(200, 40))
            { IsMultiLine = false, Text = ClientSettings.Default.UI_EnteredUserName };
            _cNameText.KeyPressed += cNameText_KeyPressed;
            _cNameText.TextChanged += cNameText_TextChanged;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 320), "Password:"******"Remember Password",
                Value = ClientSettings.Default.UI_RememberPassword,
                ForeColor = Color.White,
                Font = GameScreenHelper.DefaultChatFont
            };
            _cRememberPassword.ValueChanged += _cRememberPassword_ValueChanged;

            // NOTE: Display the admin account info
            const string adminAccountInfo =
                "Use the following account for the default admin account:" + "\n    Username: Spodi" + "\n    Password: qwerty123";
            new Label(cScreen, _cRememberPassword.Position + new Vector2(-32, _cRememberPassword.Size.Y + 32))
            { Text = adminAccountInfo, ForeColor = Color.Green, Font = GameScreenHelper.DefaultChatFont };

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Login", "Back");
            _btnLogin = menuButtons["Login"];
            _btnLogin.Clicked += _btnLogin_Clicked;
            menuButtons["Back"].Clicked += LoginScreen_Clicked;

            cScreen.SetFocus();

            // Set up the networking stuff for this screen
            _sockets = ClientSockets.Instance;
            _sockets.StatusChanged -= _sockets_StatusChanged;
            _sockets.StatusChanged += _sockets_StatusChanged;
            _sockets.PacketHandler.ReceivedLoginSuccessful += PacketHandler_ReceivedLoginSuccessful;
            _sockets.PacketHandler.ReceivedLoginUnsuccessful += PacketHandler_ReceivedLoginUnsuccessful;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// When overridden in the derived class, allows for something to be created and placed on the <see cref="MessageBox"/>
        /// before the buttons.
        /// </summary>
        /// <param name="yOffset">The current y-axis offset. If controls are added, this offset should be used, then updated afterwards
        /// to offset the <see cref="Control"/>s that will come after it.</param>
        protected override void BeforeCreateButtons(ref int yOffset)
        {
            base.BeforeCreateButtons(ref yOffset);

            var pos = new Vector2(Padding, yOffset);

            if (_input == null)
            {
                _input = CreateTextBoxControl(pos, new Vector2(32, 4));
                _input.SetFocus();
            }

            var height = Math.Max(_input.Size.Y, _input.Font.GetLineSpacing(_input.Font.DefaultSize) + _input.Border.Height);
            InputControl.Size = new Vector2(ClientSize.X - (Padding * 2), height);

            yOffset += (int)_input.Size.Y;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NPCChatDialogForm"/> class.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="parent">The parent.</param>
        public NPCChatDialogForm(Vector2 position, Control parent) : base(parent, position, new Vector2(400, 300))
        {
            IsVisible = false;

            // NOTE: We want to use a scrollable textbox here... when we finally make one

            float spacing = Font.GetLineSpacing();

            var responseStartY = ClientSize.Y - (_numDisplayedResponses * spacing);
            var textboxSize = ClientSize - new Vector2(0, ClientSize.Y - responseStartY);
            _dialogTextControl = new TextBox(this, Vector2.Zero, textboxSize)
            { IsEnabled = false, CanFocus = false, IsMultiLine = true, Font = GameScreenHelper.DefaultChatFont };
            _dialogTextControl.ClientSize -= _dialogTextControl.Border.Size;

            for (byte i = 0; i < _numDisplayedResponses; i++)
            {
                var r = new ResponseText(this, new Vector2(5, responseStartY + (spacing * i))) { IsVisible = true, Font = GameScreenHelper.DefaultChatFont };
                r.Clicked += ResponseText_Clicked;
                _responseTextControls[i] = r;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            _menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Accept", "Cancel");
            _menuButtons["Accept"].Clicked += accept_Clicked;
            _menuButtons["Cancel"].Clicked += cancel_Clicked;

            // Create the options
            var pos = new Vector2(60, 180);
            var lblSound = GameScreenHelper.CreateMenuLabel(cScreen, pos, "Sound (0 to 100):");
            _txtSound = new TextBox(cScreen, pos + new Vector2(lblSound.Size.X + 10, -6), 
                new Vector2(128, lblSound.ClientSize.Y + 4)) { AllowKeysHandler = TextEventArgsFilters.IsDigitFunc };

            pos.Y += _txtSound.Size.Y + 16;
            var lblMusic = GameScreenHelper.CreateMenuLabel(cScreen, pos, "Music (0 to 100):");
            _txtMusic = new TextBox(cScreen, pos + new Vector2(lblMusic.Size.X + 10, -6), 
                new Vector2(128, lblMusic.ClientSize.Y + 4)) { AllowKeysHandler = TextEventArgsFilters.IsDigitFunc };
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            BasicConfigurator.Configure(_logger);

            ScreenManager.Updated -= ScreenManager_Updated;
            ScreenManager.Updated += ScreenManager_Updated;

            _consoleFont = ScreenManager.Content.LoadFont("Font/Courier New", 14, ContentLevel.GameScreen);

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize) { Border = ControlBorder.Empty };

            // The main console output textbox
            _txtOutput = new TextBox(_cScreen, Vector2.Zero, _cScreen.Size)
            {
                Font = _consoleFont,
                Size = _cScreen.Size,
                Border = ControlBorder.Empty,
                MaxBufferSize = 200,
                BufferTruncateSize = 80,
                CanFocus = false,
                CanDrag = false,
                IsMultiLine = true,
                IsEnabled = false
            };
            _txtOutput.Resized += delegate { UpdateConsoleBufferSize(); };
            _txtOutput.FontChanged += delegate { UpdateConsoleBufferSize(); };

            // Create the panel that holds the settings options
            var settingsButtonSize = _consoleFont.MeasureString("Show Settings") + new Vector2(10, 4);
            _btnShowSettings = new Button(_cScreen, new Vector2(_cScreen.Size.X, 0), settingsButtonSize) { Font = _consoleFont, Text = "Hide Settings" };
            _btnShowSettings.Position += new Vector2(-4, 4);
            _btnShowSettings.Clicked += btnShowSettings_Clicked;

            var settingsPanelSize = new Vector2(400, 400);
            _cSettingsPanel = new Panel(_cScreen, new Vector2(_cScreen.Size.X - settingsPanelSize.X - 4, _btnShowSettings.Position.Y + _btnShowSettings.Size.Y + 8), settingsPanelSize) 
                { IsVisible = true, CanDrag = false };

            // Create the logging level checkboxes
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Fatal, 0));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Error, 1));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Warn, 2));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Info, 3));
            _logLevelCheckBoxes.Add(CreateLogLevelCheckBox(Level.Debug, 4));

            // Disable debug by default
            _logLevelCheckBoxes.First(x => (Level)x.Tag == Level.Debug).Value = false;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Create character", "Back");
            _btnCreateCharacter = menuButtons["Create character"];
            _btnCreateCharacter.Clicked += ClickButton_CreateCharacter;
            menuButtons["Back"].Clicked += ClickButton_Back;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Name:");

            _txtName = new TextBox(cScreen, new Vector2(220, 260), new Vector2(200, 40)) { IsMultiLine = false, Text = "", IsEnabled = true };
            _txtName.TextChanged += _txtName_TextChanged;

            _lblValidNameMarker = new Label(cScreen, _txtName.Position + new Vector2(_txtName.Size.X + 10, 0)) { Text = "*", IsVisible = false, ForeColor = Color.Red };

            var textBoxPos = new Vector2(60, _txtName.Position.Y + _txtName.Size.Y + 20);
            var textBoxSize = new Vector2(cScreen.ClientSize.X - (textBoxPos.X * 2), cScreen.ClientSize.Y - textBoxPos.Y - 60);

            _cStatus = new TextBox(cScreen, textBoxPos, textBoxSize) { ForeColor = Color.Red, Border = null, CanFocus = false, IsMultiLine = true, IsEnabled = false };
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            _sockets = ClientSockets.Instance;

            _sockets.PacketHandler.ReceivedCreateAccount -= PacketHandler_ReceivedCreateAccount;
            _sockets.PacketHandler.ReceivedCreateAccount += PacketHandler_ReceivedCreateAccount;

            var cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize);

            // Create the new account fields. Use a different font since our default TextBox font doesn't support some characters
            // needed for email, and it'd look funny to only change it for the email textbox.
            var textBoxFont = GameScreenHelper.DefaultChatFont;

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 180), "Name:");
            _cNameText = new TextBox(cScreen, new Vector2(220, 180), new Vector2(200, 40)) { IsMultiLine = false, Text = string.Empty, Font = textBoxFont };

            GameScreenHelper.CreateMenuLabel(cScreen, new Vector2(60, 260), "Password:"******"Email:");
            _cEmailText = new TextBox(cScreen, new Vector2(220, 320), new Vector2(200, 40)) { IsMultiLine = false, Text = string.Empty, Font = textBoxFont };

            var textBoxPos = new Vector2(60, _cEmailText.Position.Y + _cEmailText.Size.Y + 20);
            var textBoxSize = new Vector2(cScreen.ClientSize.X - (textBoxPos.X * 2), cScreen.ClientSize.Y - textBoxPos.Y - 60);
            _cStatus = new TextBox(cScreen, textBoxPos, textBoxSize) { ForeColor = Color.Red, Border = null, CanFocus = false, IsMultiLine = true, IsEnabled = false };

            // Create the menu buttons
            var menuButtons = GameScreenHelper.CreateMenuButtons(ScreenManager, cScreen, "Create Account", "Back");
            menuButtons["Create Account"].Clicked += ClickButton_CreateAccount;
            menuButtons["Back"].Clicked += delegate { ScreenManager.SetScreen<MainMenuScreen>(); };

            _createAccountButton = menuButtons["Create Account"];

            _sockets.StatusChanged -= _sockets_StatusChanged;
            _sockets.StatusChanged += _sockets_StatusChanged;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            topForm = new Form(GUIManager, new Vector2(5, 5), new Vector2(700, 550)) { Text = "Primary form" };

            var tb = new TextBox(topForm, new Vector2(10, 10), new Vector2(150, 300));

            _textBox = new TextBox(topForm, new Vector2(350, 10), new Vector2(200, 200))
            { Font = GUIManager.Font, Text = "abcdef\nghi\r\njklj\n" };

            for (var i = 0; i < 150; i++)
            {
                var c = new Color((byte)rnd.Next(0, 256), (byte)rnd.Next(256), (byte)rnd.Next(256), 255);
                _textBox.Append(new StyledText(i + " ", c));
            }

            var styledTexts = new List<StyledText>
            {
                new StyledText("Black ", Color.Black),
                new StyledText("Red ", Color.Red),
                new StyledText("Green ", Color.Green),
                new StyledText("Yellow ", Color.Yellow),
                new StyledText("Voilet ", Color.Violet),
                new StyledText("Orange ", Color.Orange),
                new StyledText("Tomato ", Color.Tomato),
                new StyledText("DarkRed ", Color.DarkRed),
            };

            tb.Append(styledTexts);

            var form = new Form(topForm, new Vector2(50, 50), new Vector2(200, 200)) { Text = "My form" };

            var b = new Button(form, new Vector2(20, 20), new Vector2(80, 30)) { Text = "Press me" };
            b.Clicked += b_Clicked;

            new CheckBox(form, new Vector2(20, 200)) { Text = "Checkbox" };

            var f2 = new Form(topForm, new Vector2(200, 250), new Vector2(275, 270)) { Text = "My form 2" };
            var f3 = new Form(f2, Vector2.Zero, new Vector2(200, 200)) { Text = "form 3" };
            var f4 = new Form(f3, Vector2.Zero, new Vector2(100, 100)) { Text = "form 4" };

            var testLabelF4 = new Label(f4, Vector2.Zero) { Text = "Click me" };
            testLabelF4.Clicked += testLabelF4_Clicked;

            _dragLbl = new Label(topForm, topForm.Size - new Vector2(75, 30));

            topForm.BeginDrag += DragControl;
            topForm.EndDrag += DragControl;
            form.BeginDrag += DragControl;
            form.EndDrag += DragControl;
            f2.BeginDrag += DragControl;
            f2.EndDrag += DragControl;
            f3.BeginDrag += DragControl;
            f3.EndDrag += DragControl;
            f4.BeginDrag += DragControl;
            f4.EndDrag += DragControl;

            // Set up the tooltips
            foreach (var c in GUIManager.GetAllControls())
            {
                if (c.GetType() == typeof(Button))
                    c.Tooltip = Tooltip_Button;
                else if (c.GetType() == typeof(Label))
                    c.Tooltip += Tooltip_Label;
            }

            // Paged list
            var items = new List<string>();
            for (var i = 0; i < 100; i++)
            {
                items.Add(i.ToString());
            }

            new ListBox<string>(topForm, new Vector2(500, 250), new Vector2(100, 100)) { Items = items, ShowPaging = true };
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates the children controls for this form.
        /// </summary>
        void CreateChildren()
        {
            _lblAvailableQuests = new Label(this, Vector2.Zero) { Text = "Available Quests:" };

            _lstQuests = new QuestDescriptionListBox(this, Vector2.Zero, new Vector2(32), _hasStartQuestReqs, _hasFinishQuestReqs) 
            { Items = _emptyQuests, ShowPaging = false };
            _lstQuests.SelectedIndexChanged += lstQuests_SelectedIndexChanged;

            _lblQuestInfo = new Label(this, Vector2.Zero) { Text = "Quest Information:" };

            _txtQuestInfo = new TextBox(this, Vector2.Zero, new Vector2(32)) { IsMultiLine = true, IsEnabled = false };

            _btnAccept = new Button(this, Vector2.Zero, new Vector2(90, 18)) { Text = "Accept Quest" };
            _btnAccept.Clicked += btnAccept_Clicked;

            _btnClose = new Button(this, Vector2.Zero, new Vector2(60, 18)) { Text = "Close" };
            _btnClose.Clicked += btnClose_Clicked;

            RepositionChildren();
        }