/// <summary> /// Handles the Drag event of a <see cref="Control"/>. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void DragControl(Control sender, EventArgs e) { var s = (TextControl)sender; s.Text = s.Position.ToString(); _dragLbl.Text = "Screen Position: " + s.ScreenPosition; }
/// <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(); }
/// <summary> /// Initializes a new instance of the <see cref="StatsForm"/> 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 StatsForm(UserInfo userInfo, Control parent) : base(parent, Vector2.Zero, new Vector2(225, 275)) { if (userInfo == null) throw new ArgumentNullException("userInfo"); _addStatGrh = new Grh(GrhInfo.GetData("GUI", "AddStat")); _userInfo = userInfo; _yOffset = 2; NewUserInfoLabel("Level", x => x.Level.ToString()); NewUserInfoLabel("Exp", x => x.Exp.ToString()); NewUserInfoLabel("StatPoints", x => x.StatPoints.ToString()); AddLine(); NewUserInfoLabel("HP", x => x.HP + " / " + x.ModStats[StatType.MaxHP]); NewUserInfoLabel("MP", x => x.MP + " / " + x.ModStats[StatType.MaxMP]); AddLine(); NewStatLabel(StatType.MinHit); NewStatLabel(StatType.MaxHit); NewStatLabel(StatType.Defence); AddLine(); NewStatLabel(StatType.Str); NewStatLabel(StatType.Agi); NewStatLabel(StatType.Int); }
/// <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; } }
/// <summary> /// Initializes a new instance of the <see cref="SkillsForm"/> class. /// </summary> /// <param name="cooldownManager">The skill cooldown manager.</param> /// <param name="position">The position.</param> /// <param name="parent">The parent.</param> /// <param name="knownSkills">The known skills.</param> /// <exception cref="ArgumentNullException"><paramref name="knownSkills" /> is <c>null</c>.</exception> public SkillsForm(ISkillCooldownManager cooldownManager, Vector2 position, Control parent, KnownSkillsCollection knownSkills) : base(parent, position, new Vector2(32, 32)) { if (knownSkills == null) throw new ArgumentNullException("knownSkills"); _knownSkills = knownSkills; IsVisible = false; _cooldownManager = cooldownManager; var fontLineSpacing = Font.GetLineSpacing(); // Find the spacing to use between lines _lineSpacing = (int)Math.Max(fontLineSpacing, _iconSize.Y); // Create all the skills var offset = Vector2.Zero; foreach (var skillType in EnumHelper<SkillType>.Values) { CreateSkillEntry(offset, skillType); offset += new Vector2(0, _lineSpacing); } }
/// <summary> /// Initializes a new instance of the <see cref="Form"/> class. /// </summary> /// <param name="gps">The <see cref="GameplayScreen"/>.</param> /// <param name="parent">Parent <see cref="Control"/> of this <see cref="Control"/>.</param> /// <param name="position">Position of the Control reletive to its parent.</param> /// <exception cref="NullReferenceException"><paramref name="parent"/> is null.</exception> public QuickBarForm(GameplayScreen gps, Control parent, Vector2 position) : base(parent, position, Vector2.One) { ResizeToChildren = false; _gps = gps; RepositionSlots(); }
/// <summary> /// Initializes a new instance of the <see cref="MiniMapForm"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="screen">The game play screen.</param> public MiniMapForm(Control parent, GameplayScreen screen) : base(parent, new Vector2(50, 50), new Vector2(250, 250)) { _topLeftPos = new Vector2(this.Position.X + this.Border.LeftWidth, this.Position.Y + this.Border.TopHeight); _scaledMapGrh = new Grh(null); _entityCharGrh = new Grh(GrhInfo.GetData("GUI", "MiniMapCharacter")); _entityNPCGrh = new Grh(GrhInfo.GetData("GUI", "MiniMapNPC")); _gamePlayScreen = screen; }
/// <summary> /// Initializes a new instance of the <see cref="Toolbar"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="pos">The pos.</param> public Toolbar(Control parent, Vector2 pos) : base(parent, pos, Vector2.One) { ResizeToChildren = true; ResizeToChildrenPadding = _padding; _items = CreateToolbarItems(); Position = pos; }
/// <summary> /// Initializes a new instance of the <see cref="TextControl"/> class. /// </summary> /// <param name="parent">Parent <see cref="Control"/> of this <see cref="Control"/>.</param> /// <param name="position">Position of the Control reletive to its parent.</param> /// <param name="clientSize">The size of the <see cref="Control"/>'s client area.</param> /// <exception cref="NullReferenceException"><paramref name="parent"/> is null.</exception> public TextBox(Control parent, Vector2 position, Vector2 clientSize) : base(parent, position, clientSize) { _numCharsToDraw.TextBox = this; _editableTextHandler = new EditableTextHandler(this); // Set the initial line length and number of visible lines UpdateMaxLineLength(); UpdateMaxVisibleLines(); }
/// <summary> /// Initializes a new instance of the <see cref="AvailableQuestsForm"/> class. /// </summary> /// <param name="parent">Parent <see cref="Control"/> of this <see cref="Control"/>.</param> /// <param name="position">Position of the Control reletive to its parent.</param> /// <param name="clientSize">The size of the <see cref="Control"/>'s client area.</param> /// <param name="hasStartQuestReqs">A func used to check if the user has the requirements to start a quest.</param> /// <param name="hasFinishQuestReqs">A func used to check if the user has the requirements to finish a quest.</param> /// <exception cref="NullReferenceException"><paramref name="parent"/> is null.</exception> public AvailableQuestsForm(Control parent, Vector2 position, Vector2 clientSize, Func<QuestID, bool> hasStartQuestReqs, Func<QuestID, bool> hasFinishQuestReqs) : base(parent, position, clientSize) { _hasStartQuestReqs = hasStartQuestReqs; _hasFinishQuestReqs = hasFinishQuestReqs; CreateChildren(); IsVisible = false; }
void ClickButton_DeleteCharacter(Control sender, MouseButtonEventArgs args) { var s = (CharacterSlotControl)sender; var ci = s.CharInfo; if (ci == null) return; var mb = new DeleteCharacterMessageBox(GUIManager, ci.Name, ci.Index) { Font = GameScreenHelper.DefaultChatFont }; mb.DeleteRequested += DeleteCharacterMsgBox_DeleteRequested; }
/// <summary> /// Initializes a new instance of the <see cref="StatusEffectsForm"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="position">The position.</param> /// <param name="getTime">The get time.</param> public StatusEffectsForm(Control parent, Vector2 position, IGetTime getTime) : base(parent, position, _iconSize) { IsCloseButtonVisible = false; _getTime = getTime; Border = null; CanFocus = false; CanDrag = false; }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="ChatBubble"/> class. /// </summary> /// <param name="parent">The parent <see cref="Control"/>.</param> /// <param name="owner">The <see cref="Entity"/> that this <see cref="ChatBubble"/> is for.</param> /// <param name="text">The text to display.</param> /// <exception cref="ArgumentNullException"><paramref name="owner" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="text" /> is <c>null</c>.</exception> public ChatBubble(Control parent, Entity owner, string text) : base(parent, Vector2.Zero, Vector2.Zero) { if (owner == null) throw new ArgumentNullException("owner"); if (string.IsNullOrEmpty(text)) throw new ArgumentNullException("text"); _owner = owner; _deathTime = (TickCount)(TickCount.Now + Lifespan); _textControl = new ChatBubbleText(this, text) { Font = Font }; _owner.Disposed += ChatBubble_Owner_Disposed; }
/// <summary> /// Initializes a new instance of the <see cref="EquippedForm"/> class. /// </summary> /// <param name="dragDropHandler">The drag-drop handler.</param> /// <param name="infoRequester">The info requester.</param> /// <param name="position">The position.</param> /// <param name="parent">The parent.</param> /// <exception cref="ArgumentNullException"><paramref name="infoRequester" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="dragDropHandler" /> is <c>null</c>.</exception> public EquippedForm(DragDropHandler dragDropHandler, ItemInfoRequesterBase<EquipmentSlot> infoRequester, Vector2 position, Control parent) : base(parent, position, new Vector2(200, 200)) { if (infoRequester == null) throw new ArgumentNullException("infoRequester"); if (dragDropHandler == null) throw new ArgumentNullException("dragDropHandler"); _dragDropHandler = dragDropHandler; _infoRequester = infoRequester; CreateItemSlots(); }
/// <summary> /// Initializes a new instance of the <see cref="ShopForm"/> class. /// </summary> /// <param name="dragDropHandler">The drag-drop handler callback.</param> /// <param name="position">The position.</param> /// <param name="parent">The parent.</param> public ShopForm(DragDropHandler dragDropHandler, Vector2 position, Control parent) : base(parent, position, new Vector2(200, 200)) { _dragDropHandler = dragDropHandler; IsVisible = false; var itemsSize = _columns * _itemSize; var paddingSize = (_columns + 1) * _padding; Size = itemsSize + paddingSize + Border.Size; CreateItemSlots(); }
private void OnlineUsersForm_VisibleChanged(Control sender, EventArgs e) { if (Sockets == null || !Sockets.IsConnected) return; using (var pw = ClientPacket.GetOnlineUsers()) { _sockets.Send(pw, ClientMessageType.GUI); } if (this.IsVisible) { Text = (_lbOnlineUsers == null ? "Users Online" : "Users Online: " + _lbOnlineUsers.Items.Count); UpdateUsersList(); } }
/// <summary> /// Initializes a new instance of the <see cref="OnlineUsersForm"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <exception cref="ArgumentNullException"><paramref name="userInfo" /> is <c>null</c>.</exception> public OnlineUsersForm(Control parent) : base(parent, Vector2.Zero, new Vector2(225, 400)) { _sockets = ClientSockets.Instance; this.VisibleChanged -= OnlineUsersForm_VisibleChanged; this.VisibleChanged += OnlineUsersForm_VisibleChanged; Online = new List<String>(); var items = new List<String>(); for (var i = 0; i < (Online.Count); i++) { items.Add(i.ToString()); } _lbOnlineUsers = new ListBox<String>(this, new Vector2(20, 20), this.ClientSize - new Vector2(50, 50)) { Items = items, ShowPaging = true, CanSelect = true }; }
/// <summary> /// Initializes a new instance of the <see cref="InventoryForm"/> class. /// </summary> /// <param name="dragDropHandler">The drag-drop handler.</param> /// <param name="isUserInv">A func used to determine if an <see cref="Inventory"/> is the /// user's inventory.</param> /// <param name="infoRequester">The item info tooltip.</param> /// <param name="position">The position.</param> /// <param name="parent">The parent.</param> /// <exception cref="ArgumentNullException"><paramref name="infoRequester"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="isUserInv"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="dragDropHandler"/> is null.</exception> public InventoryForm(DragDropHandler dragDropHandler, Func<Inventory, bool> isUserInv, ItemInfoRequesterBase<InventorySlot> infoRequester, Vector2 position, Control parent) : base(parent, position, new Vector2(200, 200)) { if (infoRequester == null) throw new ArgumentNullException("infoRequester"); if (isUserInv == null) throw new ArgumentNullException("isUserInv"); if (dragDropHandler == null) throw new ArgumentNullException("dragDropHandler"); _dragDropHandler = dragDropHandler; _isUserInv = isUserInv; _infoRequester = infoRequester; var itemsSize = _columns * _itemSize; var paddingSize = (_columns + 1) * _padding; Size = itemsSize + paddingSize + Border.Size; CreateItemSlots(); }
/// <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; } }
/// <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 }; 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 }; }
static StyledText[] TooltipCallback(Control sender, TooltipArgs args) { var src = (InventoryItemPB)sender; var slot = src.Slot; IItemTable itemInfo; if (!src.InventoryForm._infoRequester.TryGetInfo(slot, out itemInfo)) { // The data has not been received yet - returning null will make the tooltip retry later return null; } // Data was received, so format it and return it return ItemInfoHelper.GetStyledText(itemInfo); }
/// <summary> /// Initializes a new instance of the <see cref="Label"/> class. /// </summary> /// <param name="parent">Parent <see cref="Control"/> of this <see cref="Control"/>.</param> /// <param name="position">Position of the Control reletive to its parent.</param> /// <exception cref="NullReferenceException"><paramref name="parent"/> is null.</exception> public CheckBox(Control parent, Vector2 position) : base(parent, position) { HandleAutoResize(); }
/// <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; // 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.ReceivedLoginSuccessful += PacketHandler_ReceivedLoginSuccessful; _sockets.PacketHandler.ReceivedLoginUnsuccessful -= PacketHandler_ReceivedLoginUnsuccessful; _sockets.PacketHandler.ReceivedLoginUnsuccessful += PacketHandler_ReceivedLoginUnsuccessful; }
/// <summary> /// Handles the <see cref="TextBox.TextChanged"/> event of the <see cref="_cPasswordText"/> control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void cPasswordText_TextChanged(Control sender, EventArgs e) { var c = sender as TextBox; if (c == null) return; var clp = _cPasswordText.CursorLinePosition; _cPasswordText.Text = GameData.AccountPassword.AllowedChars.GetValidCharsOnly(_cPasswordText.Text); _cPasswordText.CursorLinePosition = clp; }
/// <summary> /// Handles the corresponding event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void _cRememberPassword_ValueChanged(Control sender, EventArgs e) { ClientSettings.Default.UI_RememberPassword = _cRememberPassword.Value; SaveScreenSettings(); }
/// <summary> /// Initializes a new instance of the <see cref="ToolbarEventArgs"/> class. /// </summary> /// <param name="itemType"><see cref="ToolbarItemType"/> for the Toolbar item that raised the event.</param> /// <param name="control">The <see cref="Control"/> that raised the event.</param> public ToolbarEventArgs(ToolbarItemType itemType, Control control) { _itemType = itemType; _control = control; }
/// <summary> /// Handles when the value changes for a <see cref="CheckBox"/> for a <see cref="Level"/>. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> void LevelCheckBox_ValueChanged(Control sender, EventArgs e) { // Rebuild the list of disabled log levels _disabledLogLevels.Clear(); _disabledLogLevels.AddRange(_logLevelCheckBoxes.Where(x => !x.Value).Select(x => (Level)x.Tag)); // Also add filters to the logger to reject the disabled log levels _logger.ClearFilters(); foreach (var disabledLevel in _disabledLogLevels) { _logger.AddFilter(new LevelMatchFilter { AcceptOnMatch = false, LevelToMatch = disabledLevel }); } }
public ResponseText(Control parent, Vector2 position) : base(parent, position) { }
public SkillLabel(Control parent, SkillInfo<SkillType> skillInfo, Vector2 position) : base(parent, position) { SkillInfo = skillInfo; Text = SkillInfo.DisplayName; }
/// <summary> /// Handles the <see cref="ChatBubble.CreateChatBubbleInstance"/> to create custom <see cref="ChatBubble"/>s. /// </summary> /// <param name="parent">The parent <see cref="NetGore.Graphics.GUI.Control"/>.</param> /// <param name="owner">The <see cref="Entity"/> the chat bubble is for.</param> /// <param name="text">The text to display.</param> /// <returns>The <see cref="ChatBubble"/> instance.</returns> static ChatBubble CreateChatBubbleInstanceHandler(Control parent, Entity owner, string text) { return(new GameChatBubble(parent, owner, text)); }