예제 #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;
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameMenuForm"/> class.
        /// </summary>
        /// <param name="parent">The parent.</param>
        public GameMenuForm(Control parent) : base(parent, Vector2.Zero, new Vector2(32))
        {
            var logOutLbl = new Label(this, new Vector2(3, 3)) { Text = "Log Out" };
            logOutLbl.Clicked += logOutLbl_Clicked;

            // Center on the parent
            Position = (Parent.ClientSize / 2f) - (Size / 2f);

            IsVisible = false;

            parent.KeyPressed += parent_KeyPressed;
        }
예제 #3
0
        void CreateControls()
        {
            var buttonSize = new Vector2(100, 20);

            _lblName = new Label(this, Vector2.Zero);

            _btnJoinLeave = new Button(this, Vector2.Zero, buttonSize);
            _btnMembers = new Button(this, Vector2.Zero, buttonSize) { Text = "Members" };
            _btnOnline = new Button(this, Vector2.Zero, buttonSize) { Text = "Online" };

            _btnJoinLeave.Clicked += _btnJoinLeave_Clicked;
            _btnMembers.Clicked += btnMembers_Clicked;
            _btnOnline.Clicked += btnOnline_Clicked;

            var formSize = new Vector2(200, 200);
            _frmOnline = new GuildOnlineMembersForm(Parent, new Vector2(200, 200), formSize) { GuildInfo = GuildInfo, IsVisible = false };
            _frmMembers = new GuildMembersForm(Parent, new Vector2(250, 250), formSize) { GuildInfo = GuildInfo, IsVisible = false };

            RelocateControls();
        }
예제 #4
0
        /// <summary>
        /// Initializes the GUI components.
        /// </summary>
        void InitializeGUI()
        {
            // Set up the fonts
            _guiFont = GameScreenHelper.DefaultGameGUIFont;
            GUIManager.Font = _guiFont;
            GUIManager.Tooltip.Font = _guiFont;
            Character.NameFont = _guiFont;

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize) { CanFocus = true };

            // Set up all the forms used by this screen
            _statsForm = new StatsForm(UserInfo, _cScreen);
            _statsForm.RequestRaiseStat += StatsForm_RequestRaiseStat;

            _inventoryForm = new InventoryForm(_dragDropHandler, x => x == UserInfo.Inventory, InventoryInfoRequester,
                new Vector2(250, 0), _cScreen);
            _inventoryForm.RequestDropItem += InventoryForm_RequestDropItem;
            _inventoryForm.RequestUseItem += InventoryForm_RequestUseItem;

            _shopForm = new ShopForm(_dragDropHandler, new Vector2(250, 0), _cScreen);
            _shopForm.RequestPurchase += ShopForm_RequestPurchase;

            _skillsForm = new SkillsForm(SkillCooldownManager, new Vector2(100, 0), _cScreen, UserInfo.KnownSkills);
            _skillsForm.RequestUseSkill += SkillsForm_RequestUseSkill;

            _infoBox = new InfoBox(GameData.ScreenSize - new Vector2(5, 5), _guiFont);

            _equippedForm = new EquippedForm(_dragDropHandler, EquipmentInfoRequester, new Vector2(500, 0), _cScreen);
            _equippedForm.RequestUnequip += EquippedForm_RequestUnequip;

            _chatForm = new ChatForm(_cScreen, new Vector2(0, _cScreen.Size.Y));
            _chatForm.Say += ChatForm_Say;

            _chatDialogForm = new NPCChatDialogForm(new Vector2(50, 50), _cScreen);
            _chatDialogForm.SelectResponse += ChatDialogForm_SelectResponse;
            _chatDialogForm.RequestEndDialog += ChatDialogForm_RequestEndDialog;

            _statusEffectsForm = new StatusEffectsForm(_cScreen, new Vector2(_cScreen.Size.X, 0), this);

            _quickBarForm = new QuickBarForm(this, _cScreen, _cScreen.Position);

            _guildForm = new GuildForm(_cScreen, new Vector2(100, 100)) { GuildInfo = UserInfo.GuildInfo, IsVisible = false };
            _guildForm.JoinRequested += _guildForm_JoinRequested;
            _guildForm.LeaveRequested += _guildForm_LeaveRequested;

            _groupForm = new GroupForm(_cScreen, new Vector2(50, 350), new Vector2(150, 150)) { GroupInfo = UserInfo.GroupInfo };

            Func<QuestID, bool> questStartReqs = x => UserInfo.HasStartQuestRequirements.HasRequirements(x) ?? false;
            Func<QuestID, bool> questFinishReqs =
                x =>
                UserInfo.QuestInfo.ActiveQuests.Contains(x) && (UserInfo.HasFinishQuestRequirements.HasRequirements(x) ?? false);
            _availableQuestsForm = new AvailableQuestsForm(_cScreen, new Vector2(200), new Vector2(250, 350), questStartReqs,
                questFinishReqs);
            _availableQuestsForm.QuestAccepted += availableQuestsForm_QuestAccepted;

            _latencyLabel = new Label(_cScreen, new Vector2(_cScreen.ClientSize.X - 75, 5))
            { Text = string.Format(_latencyString, 0), ForeColor = Color.White };

            _skillCastProgressBar = new SkillCastProgressBar(_cScreen);

            var toolbar = new Toolbar(_cScreen, new Vector2(200, 200));
            toolbar.ItemClicked += Toolbar_ItemClicked;

            var gameMenu = new GameMenuForm(_cScreen);
            gameMenu.ClickedLogOut += GameMenuClickedLogOut;

            _peerTradeForm = new PeerTradeForm(_cScreen, new Vector2(200))
            { PeerTradeInfoHandler = Socket.PacketHandler.PeerTradeInfoHandler };

            // Add the forms to the GUI settings manager (which also restores any existing settings)
            _guiStatePersister = new GUIStatePersister("Default"); // FUTURE: Allow changing of the profile
            _guiStatePersister.Add("InventoryForm", _inventoryForm);
            _guiStatePersister.Add("EquippedForm", _equippedForm);
            _guiStatePersister.Add("StatsForm", _statsForm);
            _guiStatePersister.Add("ChatForm", _chatForm);
            _guiStatePersister.Add("ToolbarForm", toolbar);
            _guiStatePersister.Add("GuildForm", _guildForm);
            _guiStatePersister.Add("StatusEffectsForm", _statusEffectsForm);
            _guiStatePersister.Add("SkillsForm", _skillsForm);
            _guiStatePersister.Add("QuickBarForm", _quickBarForm);
            _guiStatePersister.Add("PeerTradeForm", _peerTradeForm);

            // Set the focus to the screen container
            _cScreen.SetFocus();
        }
예제 #5
0
            /// <summary>
            /// Initializes a new instance of the <see cref="CharacterSlotControl"/> class.
            /// </summary>
            /// <param name="parent">Parent <see cref="Control"/> of this <see cref="Control"/>.</param>
            /// <param name="slot">The 0-base slot number.</param>
            /// <exception cref="NullReferenceException"><paramref name="parent"/> is null.</exception>
            public CharacterSlotControl(Control parent, byte slot) : base(parent, Vector2.Zero, _slotSize)
            {
                _slot = slot;

                Size = _slotSize;
                UpdatePositioning();

                // Create child controls

                // Slot number
                _slotNumberControl = CreateChildLabel(new Vector2(2, 2), (Slot + 1) + ". ");
                _slotNumberControl.ForeColor = _slotNumberTextColor;

                // Delete
                _deleteControl = CreateChildLabel(Vector2.Zero, "X", true);
                _deleteControl.Position = new Vector2(ClientSize.X - _deleteControl.ClientSize.X, 0) - new Vector2(2);
                _deleteControl.Clicked += _deleteControl_Clicked;
                _deleteControl.ForeColor = Color.White;
                _deleteControl.MouseEnter += delegate { _deleteControl.ForeColor = Color.Red; };
                _deleteControl.MouseLeave += delegate { _deleteControl.ForeColor = Color.White; };
                _deleteControl.IsVisible = (CharInfo != null);

                // Character name
                var charNameControlPos = _slotNumberControl.Position + new Vector2(_slotNumberControl.Size.X + 2, 0f);
                _charNameControl = CreateChildLabel(charNameControlPos, _unusedCharacterSlotText);
            }
예제 #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
            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 };
        }
예제 #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()
        {
            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 };
        }
예제 #8
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();
        }
예제 #9
0
        /// <summary>
        /// Creates the child controls for the <see cref="MessageBox"/>.
        /// </summary>
        void CreateChildControls()
        {
            if (_suspendCreateChildControls)
                return;

            // Clear out the old controls
            if (_msgBoxChildren.Count > 0)
            {
                foreach (var c in _msgBoxChildren)
                {
                    c.Dispose();
                }

                _msgBoxChildren.Clear();
            }

            var yOffset = Padding;

            BeforeCreateMessage(ref yOffset);

            // Create the text
            var lines = StyledText.ToMultiline(new StyledText[] { new StyledText(Message) }, true, Font,
                _maxWidth - (Padding * 2) - Border.Width);

            foreach (var line in lines)
            {
                var concatLine = StyledText.ToString(line);
                var lbl = new Label(this, new Vector2(Padding, yOffset)) { Text = concatLine, Font = Font };
                _msgBoxChildren.Add(lbl);
                yOffset += Font.GetLineSpacing();
            }

            yOffset += Padding;

            BeforeCreateButtons(ref yOffset);

            // Create the buttons
            var buttons = CreateButtons(ButtonTypes);
            _msgBoxChildren.AddRange(buttons);

            // Expand the form if needed to fit the buttons
            var neededButtonWidth = buttons.Sum(x => x.Size.X) + ((buttons.Count() + 1) * Padding);
            if (ClientSize.X < neededButtonWidth)
                ClientSize = new Vector2(neededButtonWidth, ClientSize.Y);

            // Arrange the buttons
            var xOffset = Math.Max(Padding, (ClientSize.X - neededButtonWidth) / 2f);
            foreach (var button in buttons)
            {
                button.Position = new Vector2(xOffset, yOffset);
                xOffset += button.Size.X + Padding;
            }

            AfterCreateButtons(ref yOffset);

            // Center to the screen
            Position = (GUIManager.ScreenSize / 2f) - (Size / 2f);
        }