private void ViewStatsForm_Load(object sender, EventArgs e) { TokenData tokData = mapToken.GetTokenData(); this.tokenNameLbl.Text = tokData.Name; this.curHPBox.Minimum = 0; this.curHPBox.Maximum = tokData.MaxHP; this.curHPBox.Value = tokData.CurrentHP; this.maxHPLbl.Text = "/ " + tokData.MaxHP; this.acLbl.Text = tokData.ArmorClass.ToString(); this.strLbl.Text = tokData.Strength.ToString(); this.dexLbl.Text = tokData.Dexterity.ToString(); this.constLbl.Text = tokData.Constitution.ToString(); this.intLbl.Text = tokData.Intelligence.ToString(); this.wisLbl.Text = tokData.Wisdom.ToString(); this.chrLbl.Text = tokData.Charisma.ToString(); this.notesBox.Text = tokData.Notes; formPos.X -= Size.Width; formPos.Y -= Size.Height; Rectangle screenRect = Screen.FromControl(this).Bounds; formPos.X = Math.Max(Math.Min(screenRect.Width - Size.Width, formPos.X), 0); formPos.Y = Math.Max(Math.Min(screenRect.Height - Size.Height, formPos.Y), 0); this.Location = formPos; }
private void actTokEditBtn_Click(object sender, EventArgs e) { int curSelectedIndex = activeTokensList.SelectedIndex; // No token selected if (curSelectedIndex < 0) { MessageBox.Show("No token selected.", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MapToken selectedToken = (MapToken)activeTokensList.Items[curSelectedIndex]; TokenData tokenData = selectedToken.GetTokenData(); EditTokenForm charForm = new EditTokenForm(gameState); charForm.SetTokenData(ref tokenData); DialogResult result = charForm.ShowDialog(this); if (result == DialogResult.OK) { tokenData = charForm.GetTokenData(); selectedToken.SetTokenData(ref tokenData); } }
// Copy constructor public MapToken(MapToken other) { TokenData otherTokenData = other.GetTokenData(); this.mapCtrl = other.mapCtrl; this.tokenData = new TokenData(ref otherTokenData); this.position = other.Position; }
// updates the mouse state of any active tokens on the map // depending on the current mouse position protected void updateActiveTokenMouseState(Point mousePos) { // No active tokens? Return if (gameState.ActiveTokens.Count == 0) { return; } // Get unit rectangle for current view RectangleF viewPortRect = GetViewportUnitRect(); MapToken tokenUnderMouse = null; // Loop through each active token foreach (MapToken token in gameState.ActiveTokens) { // Is a token currently being dragged? if (draggedToken != null) { if (token != draggedToken) { token.MouseState = TokenMouseState.Idle; } } else { RectangleF tokenUnitRect = token.GetUnitRect(); // Get unit rectangle for token Rectangle pixelRect = UnitRectToPixelRect(tokenUnitRect, viewPortRect); // Convert unit rect to pixel coordinates // If token is under mouse, set Hover state if (pixelRect.Contains(mousePos)) { token.MouseState = TokenMouseState.Hover; tokenUnderMouse = token; } else { token.MouseState = TokenMouseState.Idle; } } } if (tokenUnderMouse != null && !tokenHoverToolTip.Active) { TokenData data = tokenUnderMouse.GetTokenData(); tokenHoverToolTip.SetTokenData(ref data); tokenHoverToolTip.Active = true; } else if (tokenUnderMouse == null && tokenHoverToolTip.Active) { tokenHoverToolTip.Active = false; tokenHoverToolTip.Hide(this); } }
private void editTokenToolStripMenuItem_Click(object sender, EventArgs e) { if (rightClickedToken == null) { return; } TokenData data = rightClickedToken.GetTokenData(); EditTokenForm editTokenForm = new EditTokenForm(gameState); editTokenForm.SetTokenData(ref data); DialogResult result = editTokenForm.ShowDialog(); if (result == DialogResult.OK) { data = editTokenForm.GetTokenData(); rightClickedToken.SetTokenData(ref data); } }
public TokenListItemControl(MapToken token) { InitializeComponent(); this.token = token; this.data = token.GetTokenData(); TokenName.Text = data.Name; ACLabel.Text = "AC: " + data.ArmorClass; TokenStrength.Text = "STR: " + data.Strength; TokenDexterity.Text = "DEX: " + data.Dexterity; TokenConstitution.Text = "CON: " + data.Constitution; TokenIntelligence.Text = "INT: " + data.Intelligence; TokenWisdom.Text = "WIS: " + data.Wisdom; TokenCharisma.Text = "CHA: " + data.Charisma; HealthBox.Text = data.CurrentHP + " / " + data.MaxHP; if (data.CurrentHP >= data.MaxHP / 3) { HealthBox.BackColor = Color.Lime; } else if (data.CurrentHP >= data.MaxHP / 10) { HealthBox.BackColor = Color.Orange; } else { HealthBox.BackColor = Color.Red; } }