/// <summary> /// Handles the MouseDown event of the lbSkills control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param> private void lbSkills_MouseDown(object sender, MouseEventArgs e) { // Retrieve the item at the given point and quit if none int index = lbSkills.IndexFromPoint(e.Location); if (index < 0 || index >= lbSkills.Items.Count) { return; } // Beware, this last index may actually means a click in the whitespace at the bottom // Let's deal with this special case if (index == lbSkills.Items.Count - 1) { Rectangle itemRect = lbSkills.GetItemRectangle(index); if (!itemRect.Contains(e.Location)) { return; } } // For a skill group, we have to handle the collapse/expand mechanism and the tooltip object item = lbSkills.Items[index]; SkillGroup skillGroup = item as SkillGroup; if (skillGroup != null) { // Left button : expand/collapse if (e.Button != MouseButtons.Right) { ToggleGroupExpandCollapse(skillGroup); return; } // If right click on the button, still expand/collapse Rectangle itemRect = lbSkills.GetItemRectangle(lbSkills.Items.IndexOf(item)); Rectangle buttonRect = GetButtonRectangle(skillGroup, itemRect); if (buttonRect.Contains(e.Location)) { ToggleGroupExpandCollapse(skillGroup); return; } return; } // Right click for skills below lv5 : we display a context menu to plan higher levels Skill skill = (Skill)item; if (e.Button == MouseButtons.Right) { lbSkills.Cursor = Cursors.Default; // Set the selected skill m_selectedSkill = skill; // Display the context menu contextMenuStrip.Show(lbSkills, e.Location); } }
private void archetypeDropEntryRefreshAction(DropDownEntry entry, object targetData) { if (entry.entryData != null) { SkillGroup skillGroup = entry.entryData as SkillGroup; entry.image.sprite = Assets.GetSprite(skillGroup.archetypeIcon); } }
public void SetAllowedSkills(SkillGroup allowedSkills) { profession.AllowedSkills = allowedSkills; foreach (var skill in laborSkills) { skill.IsAllowed = allowedSkills.IsSkillAllowed(skill.Type); } }
public ActionResult DeleteConfirmed(int id) { SkillGroup skillGroup = db.SkillGroups.Find(id); db.SkillGroups.Remove(skillGroup); db.SaveChanges(); return(RedirectToAction("Index")); }
public Skill(int id, bool action, string name) { this.ID = id; this.Action = action; this.Name = name; this.Value = 0.0f; this.Real = 0.0f; this.Group = (SkillGroup)null; this.Lock = SkillLock.Up; }
public ActionResult Edit([Bind(Include = "SkillGroupId,SkillGroupName")] SkillGroup skillGroup) { if (ModelState.IsValid) { db.Entry(skillGroup).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(skillGroup)); }
public ActionResult Create(SkillGroup skillGroup) { if (ModelState.IsValid) { db.SkillGroups.Add(skillGroup); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(skillGroup)); }
/// <summary> /// Toggles the expansion or collapsing of a single group /// </summary> /// <param name="group">The group to expand or collapse.</param> private void ToggleGroupExpandCollapse(SkillGroup group) { if (Character.UISettings.CollapsedGroups.Contains(group.Name)) { ExpandSkillGroup(group); } else { CollapseSkillGroup(group); } }
public ActionResult Create([Bind(Include = "SkillGroupId,SkillGroupName,Skill,Mode")] SkillGroup skillGroup) { if (ModelState.IsValid) { db.SkillGroups.Add(skillGroup); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(skillGroup)); }
public static string ToString(SkillGroup skillGroup) { if (skillGroup == null) { return null; } return "{GroupId = " + skillGroup.GroupId + ", GroupName = " + skillGroup.GroupName.ToString() + "}"; }
public CharacterInfo(PlayerDef def) { ID = def.CommonProperty.ID; Level = def.DefaultLevel; Exp = 0; Career = def.Career; Attribute = def.DefaultAttribute; CurrentHP = Attribute.HP; MaxHP = Attribute.HP; Items = new ItemGroup(def.DefaultWeapons); Skills = new SkillGroup(def.DefaultSkills); }
/// <summary> /// Returns true if Skill instances are equal /// </summary> /// <param name="other">Instance of Skill to be compared</param> /// <returns>Boolean</returns> public bool Equals(Skill other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( SkillGroup == other.SkillGroup || SkillGroup != null && SkillGroup.Equals(other.SkillGroup) ) && ( Cluster == other.Cluster || Cluster != null && Cluster.Equals(other.Cluster) ) && ( _Skill == other._Skill || _Skill != null && _Skill.Equals(other._Skill) ) && ( Validity == other.Validity || Validity != null && Validity.Equals(other.Validity) ) && ( DateGained == other.DateGained || DateGained != null && DateGained.Equals(other.DateGained) ) && ( ObtainedFromReason == other.ObtainedFromReason || ObtainedFromReason != null && ObtainedFromReason.Equals(other.ObtainedFromReason) ) && ( CertificateNumber == other.CertificateNumber || CertificateNumber != null && CertificateNumber.Equals(other.CertificateNumber) ) && ( Notes == other.Notes || Notes != null && Notes.Equals(other.Notes) )); }
//[RuntimeInitializeOnLoadMethod] //public static void LoadFromRecord() { // CharacterInfo info = new CharacterInfo(); // info= info.Load<CharacterInfo>(); // Debug.Log(info.Items.Weapons.Count); //} public CharacterInfo(CharacterLogic Logic) { ID = Logic.GetID(); Level = Logic.GetLevel(); Exp = Logic.GetExp(); Career = Logic.GetCareer(); Attribute = Logic.GetAttribute(); CurrentHP = Logic.GetCurrentHP(); MaxHP = Logic.GetMaxHP(); Items = new ItemGroup(); Skills = new SkillGroup(); }
/// <summary> /// Gets the rectangle for the collapse/expand button. /// </summary> /// <param name="group">The group.</param> /// <param name="itemRect">The item rect.</param> /// <returns></returns> private Rectangle GetButtonRectangle(SkillGroup group, Rectangle itemRect) { // Checks whether this group is collapsed bool isCollapsed = Character.UISettings.CollapsedGroups.Contains(group.Name); // Get the image for this state Image btnImage = isCollapsed ? Resources.Expand : Resources.Collapse; // Compute the top left point Point btnPoint = new Point(itemRect.Right - btnImage.Width - CollapserPadRight, SkillHeaderHeight / 2 - btnImage.Height / 2 + itemRect.Top); return(new Rectangle(btnPoint, btnImage.Size)); }
/// <summary> /// Draws the list item for the given skill group. /// </summary> /// <param name="skill"></param> /// <param name="e"></param> public void DrawItem(SkillGroup group, DrawItemEventArgs e) { Graphics g = e.Graphics; // Draws the background using (Brush b = new SolidBrush(Color.FromArgb(75, 75, 75))) { g.FillRectangle(b, e.Bounds); } using (Pen p = new Pen(Color.FromArgb(100, 100, 100))) { g.DrawLine(p, e.Bounds.Left, e.Bounds.Top, e.Bounds.Right + 1, e.Bounds.Top); } // Draw the header Size titleSizeInt = TextRenderer.MeasureText(g, group.Name, m_boldSkillsFont, Size.Empty, TextFormatFlags.NoPadding | TextFormatFlags.NoClipping); Point titleTopLeftInt = new Point(e.Bounds.Left + 3, e.Bounds.Top + ((e.Bounds.Height / 2) - (titleSizeInt.Height / 2))); Point detailTopLeftInt = new Point(titleTopLeftInt.X + titleSizeInt.Width, titleTopLeftInt.Y); string skillInTrainingSuffix = ""; bool hasTrainingSkill = group.Any(x => x.IsTraining); bool hasQueuedSkill = group.Any(x => x.IsQueued && !x.IsTraining); if (hasTrainingSkill) { skillInTrainingSuffix = ", ( 1 in training )"; } if (hasQueuedSkill) { skillInTrainingSuffix += String.Format(", ( {0} in queue )", group.Count(x => x.IsQueued && !x.IsTraining)); } // Draws the rest of the text header string detailText = String.Format(CultureInfo.CurrentCulture, ", {0} of {1} skills, {2:#,##0} Points{3}", group.Count(x => x.IsKnown), group.Count(x => x.IsPublic), group.TotalSP, skillInTrainingSuffix); TextRenderer.DrawText(g, group.Name, m_boldSkillsFont, titleTopLeftInt, Color.White); TextRenderer.DrawText(g, detailText, m_skillsFont, detailTopLeftInt, Color.White); // Draws the collapsing arrows bool isCollapsed = m_character.UISettings.CollapsedGroups.Contains(group.Name); Image i = (isCollapsed ? Properties.Resources.Expand : Properties.Resources.Collapse); g.DrawImageUnscaled(i, new Point(e.Bounds.Right - i.Width - CollapserPadRight, (SkillHeaderHeight / 2) - (i.Height / 2) + e.Bounds.Top)); }
// GET: SkillGroups/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SkillGroup skillGroup = db.SkillGroups.Find(id); if (skillGroup == null) { return(HttpNotFound()); } return(View(skillGroup)); }
/// <summary> /// Displays the tooltip for the given item (skill or skillgroup). /// </summary> /// <param name="item"></param> private void DisplayTooltip(Object item) { if (ttToolTip.Active && m_lastTooltipItem != null && m_lastTooltipItem == item) { return; } m_lastTooltipItem = item; ttToolTip.Active = false; SkillGroup skillGroup = item as SkillGroup; ttToolTip.SetToolTip(lbSkills, skillGroup != null ? GetTooltip(skillGroup) : GetTooltip((Skill)item)); ttToolTip.Active = true; }
private void OnArchetypeEntryClick(IListableOption skill, object data) { if (skill != null) { SkillGroup skillGroup = skill as SkillGroup; guaranteedAptitudeID = skillGroup.Id; selectedArchetypeIcon.sprite = Assets.GetSprite(skillGroup.archetypeIcon); Reshuffle(true); } else { guaranteedAptitudeID = null; selectedArchetypeIcon.sprite = dropdownArrowIcon; Reshuffle(true); } }
public void Add(SkillGroup skillGroup) { var shouldOpenConnection = Connection.State != ConnectionState.Open; if (shouldOpenConnection) { Connection.Open(); } Connection.Execute( @"INSERT INTO [SkillGroup]([SkillGroupId],[SkillGroupName]) VALUES (@SkillGroupId, @SkillGroupName)", skillGroup); if (shouldOpenConnection) { Connection.Close(); } }
/// <summary> /// Maps the specified skill group. /// </summary> /// <param name="skillGroup">The skill group.</param> /// <returns></returns> public static SkillGroupDto Map(this SkillGroup skillGroup) { return((skillGroup == null) ? null : new SkillGroupDto { Id = skillGroup.Id, Name = skillGroup.Name, Description = skillGroup.Description, Icon = skillGroup.Icon, Skills = skillGroup.Skills?.Select(s => new SkillDto { Id = s.Id, Name = s.Name, Description = s.Description, SkillGroupId = s.SkillGroupId }).ToList() }); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var groupname = (string)value; var exists = SkillDetailVM._SkillGroups.Any(sg => sg.Name.ToUpper() == groupname.ToUpper()); if (exists) { return(SkillDetailVM._SkillGroups.FirstOrDefault(sg => sg.Name.ToUpper() == groupname.ToUpper())); } else { var nsg = new SkillGroup((string)value); SkillDetailVM._SkillGroups.Add(nsg); return(nsg); } }
public SkillGroupControl(SkillGroup skillGroup) { _skillGroup = skillGroup; InitializeComponent(); //This is apparently a factor 30 faster than placed in load. NFI why Stopwatch sw = Stopwatch.StartNew(); SuspendLayout(); lblName.DataBindings.Add("Text", _skillGroup, "DisplayName"); _skillGroup.PropertyChanged += SkillGroup_PropertyChanged; tipToolTip.SetToolTip(lblName, _skillGroup.ToolTip); if (_skillGroup.CharacterObject.Created) { nudKarma.Visible = false; nudSkill.Visible = false; btnCareerIncrease.Visible = true; btnCareerIncrease.DataBindings.Add("Enabled", _skillGroup, nameof(SkillGroup.CareerCanIncrease), false, DataSourceUpdateMode.OnPropertyChanged); tipToolTip.SetToolTip(btnCareerIncrease, _skillGroup.UpgradeToolTip); lblGroupRating.Visible = true; lblGroupRating.DataBindings.Add("Text", _skillGroup, nameof(SkillGroup.DisplayRating), false, DataSourceUpdateMode.OnPropertyChanged); } else { nudKarma.DataBindings.Add("Value", _skillGroup, "Karma", false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.DataBindings.Add("Enabled", _skillGroup, "KarmaUnbroken", false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.DataBindings.Add("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Value", _skillGroup, "Base", false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Enabled", _skillGroup, "BaseUnbroken", false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); if (_skillGroup.CharacterObject.BuildMethod == CharacterBuildMethod.Karma || _skillGroup.CharacterObject.BuildMethod == CharacterBuildMethod.LifeModule) { nudSkill.Enabled = false; } } ResumeLayout(); sw.TaskEnd("Create skillgroup"); }
public SkillGroupControl(SkillGroup skillGroup) { if (skillGroup == null) { return; } _skillGroup = skillGroup; InitializeComponent(); this.TranslateWinForm(); //This is apparently a factor 30 faster than placed in load. NFI why Stopwatch sw = Stopwatch.StartNew(); SuspendLayout(); lblName.DoDatabinding("Text", _skillGroup, nameof(SkillGroup.CurrentDisplayName)); lblName.DoDatabinding("ToolTipText", _skillGroup, nameof(SkillGroup.ToolTip)); nudSkill.Visible = !skillGroup.CharacterObject.Created && skillGroup.CharacterObject.BuildMethodHasSkillPoints; nudKarma.Visible = !skillGroup.CharacterObject.Created; btnCareerIncrease.Visible = skillGroup.CharacterObject.Created; lblGroupRating.Visible = skillGroup.CharacterObject.Created; if (_skillGroup.CharacterObject.Created) { btnCareerIncrease.DoDatabinding("Enabled", _skillGroup, nameof(SkillGroup.CareerCanIncrease)); btnCareerIncrease.DoDatabinding("ToolTipText", _skillGroup, nameof(SkillGroup.UpgradeToolTip)); lblGroupRating.DoDatabinding("Text", _skillGroup, nameof(SkillGroup.DisplayRating)); } else { nudKarma.DoDatabinding("Value", _skillGroup, nameof(SkillGroup.Karma)); nudKarma.DoDatabinding("Enabled", _skillGroup, nameof(SkillGroup.KarmaUnbroken)); nudKarma.DoDatabinding("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode)); nudSkill.DoDatabinding("Visible", _skillGroup.CharacterObject, nameof(Character.BuildMethodHasSkillPoints)); nudSkill.DoDatabinding("Value", _skillGroup, nameof(SkillGroup.Base)); nudSkill.DoDatabinding("Enabled", _skillGroup, nameof(SkillGroup.BaseUnbroken)); nudSkill.DoDatabinding("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode)); } ResumeLayout(); sw.TaskEnd("Create skillgroup"); }
void Awake() { AttributeManager attributeManager = GetComponent <AttributeManager>(); attributeManager.AddAttribute(AttributeType.Mana, new ResourceModifier.Attribute(100, 0, 1000)); attributeManager.AddAttribute(AttributeType.ManaMax, new BasicAttribute(150, 0, 1000)); attributeManager.AddAttribute(AttributeType.ManaRegen, new BasicAttribute(0.5f, 0, 100)); attributeManager.AddAttribute(AttributeType.HealPower, new BasicAttribute(50, 0, 1000)); attributeManager.AddModifier(Factory.GetModifier(AttributModifierType.Resource, gameObject, new ResourceModifier.Params(AttributeType.ManaRegen, AttributeType.ManaMax, AttributeType.Mana))); SkillGroup progressTrackerProvider = GetComponent <SkillGroup>(); GameObject progressTracker = progressTrackerProvider.CreateSkill(DataManager.Instance.CreateDisplaySkillData(SkillType.HealSingleCharacter)); ASkillController skillController = progressTracker.GetComponent <ASkillController>(); ASkill skill = new HealSingleCharacterSkill(gameObject, 3f, 50f); skillController.Skill = new InteractionSkill(new SelectCharacterInteraction(this), skill); skillController.ProgressTracker = progressTracker.GetComponent <IProgressTracker>(); }
public void Update(SkillGroup skillGroup) { var shouldOpenConnection = Connection.State != ConnectionState.Open; if (shouldOpenConnection) { Connection.Open(); } Connection.Execute( @"UPDATE [SkillGroup] SET [SkillGroupName]=@SkillGroupName WHERE [SkillGroupId]=@SkillGroupId", skillGroup); if (shouldOpenConnection) { Connection.Close(); } }
/// <summary> /// Handles the DrawItem event of the lbSkills control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.DrawItemEventArgs"/> instance containing the event data.</param> private void lbSkills_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0 || e.Index >= lbSkills.Items.Count) { return; } object item = lbSkills.Items[e.Index]; SkillGroup skillGroup = item as SkillGroup; if (skillGroup != null) { DrawItem(skillGroup, e); } else { DrawItem((Skill)item, e); } }
/// <summary> /// Gets the tooltip content for the given skill group /// </summary> /// <param name="sg"></param> private string GetTooltip(SkillGroup group) { int totalValidSP = 0; int maxSP = 0; int totalSP = 0; int known = 0; int maxKnown = 0; double percentDonePoints = 0.0; double percentDoneSkills = 0.0; // Maximas are computed on public skills only foreach (Skill s in group.Where(x => x.IsPublic)) { totalValidSP += s.SkillPoints; maxSP += s.StaticData.GetPointsRequiredForLevel(5); maxKnown++; } // Current achievements are computed on every skill, including non-public foreach (Skill s in group) { totalSP += s.SkillPoints; if (s.IsKnown) { known++; } } // If the group is not completed yet if (totalValidSP < maxSP) { percentDonePoints = (1.0 * Math.Min(totalSP, maxSP)) / maxSP; percentDoneSkills = (1.0 * Math.Min(known, maxKnown)) / maxKnown; return(String.Format(CultureInfo.CurrentCulture, "Points Completed: {0:#,##0} of {1:#,##0} ({2:P1})\nSkills Known: {3} of {4} ({5:P0})", totalSP, maxSP, percentDonePoints, known, maxKnown, percentDoneSkills)); } // The group has been completed ! return(String.Format(CultureInfo.CurrentCulture, "Skill Group completed: {0:#,##0}/{1:#,##0} (100%)\nSkills: {2:#}/{3:#} (100%)", totalSP, maxSP, known, maxKnown)); }
public SkillGroupControl(SkillGroup skillGroup) { _skillGroup = skillGroup; InitializeComponent(); LanguageManager.TranslateWinForm(GlobalOptions.Language, this); //This is apparently a factor 30 faster than placed in load. NFI why Stopwatch sw = Stopwatch.StartNew(); SuspendLayout(); lblName.DataBindings.Add("Text", _skillGroup, nameof(SkillGroup.DisplayName), false, DataSourceUpdateMode.OnPropertyChanged); lblName.DataBindings.Add("ToolTipText", _skillGroup, nameof(SkillGroup.ToolTip), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.Visible = !skillGroup.CharacterObject.Created && skillGroup.CharacterObject.BuildMethodHasSkillPoints; nudKarma.Visible = !skillGroup.CharacterObject.Created; btnCareerIncrease.Visible = skillGroup.CharacterObject.Created; lblGroupRating.Visible = skillGroup.CharacterObject.Created; if (_skillGroup.CharacterObject.Created) { btnCareerIncrease.DataBindings.Add("Enabled", _skillGroup, nameof(SkillGroup.CareerCanIncrease), false, DataSourceUpdateMode.OnPropertyChanged); btnCareerIncrease.DataBindings.Add("ToolTipText", _skillGroup, nameof(SkillGroup.UpgradeToolTip), false, DataSourceUpdateMode.OnPropertyChanged); lblGroupRating.DataBindings.Add("Text", _skillGroup, nameof(SkillGroup.DisplayRating), false, DataSourceUpdateMode.OnPropertyChanged); } else { nudKarma.DataBindings.Add("Value", _skillGroup, nameof(SkillGroup.Karma), false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.DataBindings.Add("Enabled", _skillGroup, nameof(SkillGroup.KarmaUnbroken), false, DataSourceUpdateMode.OnPropertyChanged); nudKarma.DataBindings.Add("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Visible", _skillGroup.CharacterObject, nameof(Character.BuildMethodHasSkillPoints), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Value", _skillGroup, nameof(SkillGroup.Base), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("Enabled", _skillGroup, nameof(SkillGroup.BaseUnbroken), false, DataSourceUpdateMode.OnPropertyChanged); nudSkill.DataBindings.Add("InterceptMouseWheel", _skillGroup.CharacterObject.Options, nameof(CharacterOptions.InterceptMode), false, DataSourceUpdateMode.OnPropertyChanged); } ResumeLayout(); sw.TaskEnd("Create skillgroup"); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (SkillGroup != null) { hashCode = hashCode * 59 + SkillGroup.GetHashCode(); } if (Cluster != null) { hashCode = hashCode * 59 + Cluster.GetHashCode(); } if (_Skill != null) { hashCode = hashCode * 59 + _Skill.GetHashCode(); } if (Validity != null) { hashCode = hashCode * 59 + Validity.GetHashCode(); } if (DateGained != null) { hashCode = hashCode * 59 + DateGained.GetHashCode(); } if (ObtainedFromReason != null) { hashCode = hashCode * 59 + ObtainedFromReason.GetHashCode(); } if (CertificateNumber != null) { hashCode = hashCode * 59 + CertificateNumber.GetHashCode(); } if (Notes != null) { hashCode = hashCode * 59 + Notes.GetHashCode(); } return(hashCode); } }
/// <summary> /// Adds the skill group. /// </summary> /// <param name="plan">The plan.</param> /// <param name="skillGroup">The skill group.</param> /// <returns></returns> private static OutputSkillGroup AddSkillGroup(Plan plan, SkillGroup skillGroup) { int count = skillGroup .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))) .Select(x => GetMergedSkill(plan, x)) .Count(); Int64 skillGroupTotalSP = skillGroup .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))) .Select(x => GetMergedSkill(plan, x)) .Sum(x => x.Skillpoints); OutputSkillGroup outGroup = new OutputSkillGroup { Name = skillGroup.Name, SkillsCount = count, TotalSP = FormattableString.Invariant($"{skillGroupTotalSP:N0}") }; return(outGroup); }
/// <summary> /// Gets the tooltip content for the given skill group /// </summary> /// <param name="sg"></param> private string GetTooltip(SkillGroup group) { // Maximas are computed on public skills only int totalValidSP = group.Where(x => x.IsPublic).Sum(x => x.SkillPoints); int maxSP = group.Where(x => x.IsPublic).Sum(x => x.StaticData.GetPointsRequiredForLevel(5)); int maxKnown = group.Where(x => x.IsPublic).Count(); // Current achievements are computed on every skill, including non-public int totalSP = group.Sum(x => x.SkillPoints); int known = group.Where(x => x.IsKnown).Count(); // If the group is not completed yet if (totalValidSP < maxSP) { double percentDonePoints = (1.0 * Math.Min(totalSP, maxSP)) / maxSP; double percentDoneSkills = (1.0 * Math.Min(known, maxKnown)) / maxKnown; return String.Format(CultureConstants.DefaultCulture, "Points Completed: {0:#,##0} of {1:#,##0} ({2:P1})\nSkills Known: {3} of {4} ({5:P0})", totalSP, maxSP, percentDonePoints, known, maxKnown, percentDoneSkills); } // The group has been completed ! return String.Format(CultureConstants.DefaultCulture, "Skill Group completed: {0:#,##0}/{1:#,##0} (100%)\nSkills: {2:#}/{3:#} (100%)", totalSP, maxSP, known, maxKnown); }
/// <summary> /// Gets the rectangle for the collapse/expand button. /// </summary> /// <param name="group">The group.</param> /// <param name="itemRect">The item rect.</param> /// <returns></returns> private Rectangle GetButtonRectangle(SkillGroup group, Rectangle itemRect) { // Checks whether this group is collapsed bool isCollapsed = Character.UISettings.CollapsedGroups.Contains(group.Name); // Get the image for this state Image btnImage = isCollapsed ? Resources.Expand : Resources.Collapse; // Compute the top left point Point btnPoint = new Point(itemRect.Right - btnImage.Width - CollapserPadRight, SkillHeaderHeight / 2 - btnImage.Height / 2 + itemRect.Top); return new Rectangle(btnPoint, btnImage.Size); }
/// <summary> /// Collapse a skill group /// </summary> /// <param name="group">Skill group in lbSkills</param> private void CollapseSkillGroup(SkillGroup group) { Character.UISettings.CollapsedGroups.Add(group.Name); UpdateContent(); }
/// <summary> /// Gets the tooltip content for the given skill group /// </summary> /// <param name="group">The group.</param> /// <returns></returns> private static string GetTooltip(SkillGroup group) { // Maximas are computed on public skills only Int64 totalValidSP = group.Where(x => x.IsPublic).Sum(x => x.SkillPoints); Int64 maxSP = group.Where(x => x.IsPublic).Sum(x => x.StaticData.GetPointsRequiredForLevel(5)); int maxKnown = group.Count(x => x.IsPublic); // Current achievements are computed on every skill, including non-public Int64 totalSP = group.Sum(x => x.SkillPoints); int known = group.Count(x => x.IsKnown); // The group has been completed ! if (totalValidSP >= maxSP) { return $"Skill Group completed: {totalSP:N0}/{maxSP:N0} (100%){Environment.NewLine}" + $"Skills: {known}/{maxKnown} (100%)"; } // If the group is not completed yet double percentDonePoints = 1.0 * Math.Min(totalSP, maxSP) / maxSP; double percentDoneSkills = 1.0 * Math.Min(known, maxKnown) / maxKnown; return $"Points Completed: {totalSP:N0} of {maxSP:N0} ({percentDonePoints:P1}){Environment.NewLine}" + $"Skills Known: {known} of {maxKnown} ({percentDoneSkills:P0})"; }
/// <summary> /// Toggles the expansion or collapsing of a single group /// </summary> /// <param name="group">The group to expand or collapse.</param> private void ToggleGroupExpandCollapse(SkillGroup group) { if (Character.UISettings.CollapsedGroups.Contains(group.Name)) ExpandSkillGroup(group); else CollapseSkillGroup(group); }
/// <summary> /// Expand a skill group /// </summary> /// <param name="group">Skill group in lbSkills</param> private void ExpandSkillGroup(SkillGroup group) { Character.UISettings.CollapsedGroups.Remove(group.Name); UpdateContent(); }
public static SkillTreeResponse Deserialize(XDocument xmldoc) { var res = new SkillTreeResponse(); res.skillGroupsDict = new Dictionary<int, SkillGroup>(); res.skillsDict = new Dictionary<int, Skill>(); var api_response = xmldoc.Element("eveapi"); var groups = api_response.Element("result").RowSet("skillGroups"); foreach (var skillGroup in groups.Elements("row")) { var skills = skillGroup.RowSet("skills"); foreach (var skill in skills.Elements("row")) { int published = skill.AttributeInt("published"); if (published == 0) { continue; } Skill sk = new Skill { rank = skill.ElementInt("rank"), typeName = skill.AttributeString("typeName"), typeID = skill.AttributeInt("typeID"), description = skill.ElementString("description"), secondaryAttribute = Skill.Attribute.None, primaryAttribute = Skill.Attribute.None }; Dictionary<string, Skill.Attribute> skillAttributeMapping = new Dictionary<string, Skill.Attribute>(); skillAttributeMapping.Add("memory", Skill.Attribute.Memory); skillAttributeMapping.Add("intelligence", Skill.Attribute.Intelligence); skillAttributeMapping.Add("charisma", Skill.Attribute.Charisma); skillAttributeMapping.Add("willpower", Skill.Attribute.Willpower); skillAttributeMapping.Add("perception", Skill.Attribute.Perception); XElement requiredAttributes = skill.Element("requiredAttributes"); if (requiredAttributes != null) { string primary = requiredAttributes.ElementString("primaryAttribute"); string secondary = requiredAttributes.ElementString("secondaryAttribute"); if (primary != null && secondary != null) { if (skillAttributeMapping.ContainsKey(primary)) { sk.primaryAttribute = skillAttributeMapping[primary]; } if (skillAttributeMapping.ContainsKey(secondary)) { sk.secondaryAttribute = skillAttributeMapping[secondary]; } } } sk.requiredSkills = new List<RequiredSkill>(); var required_skills = skill.RowSet("requiredSkills"); foreach (var required_skill in required_skills.Elements("row")) { RequiredSkill rs = new RequiredSkill { skillLevel = required_skill.AttributeInt("skillLevel"), typeID = required_skill.AttributeInt("typeID") }; sk.requiredSkills.Add(rs); } var skillBonusCollection = skill.RowSet("skillBonusCollection"); var regEx = new Regex(@"requiredSkill(\d+)"); foreach (var skillBonus in skillBonusCollection.Elements("row")) { string str = skillBonus.AttributeString("bonusType"); Match match = regEx.Match(str); if (match.Success) { var matchingLevel = skillBonusCollection.Elements("row").FirstOrDefault( x=> x.AttributeString("bonusType") == (str +"Level")); if (matchingLevel != null) { RequiredSkill rs = new RequiredSkill { skillLevel = matchingLevel.AttributeInt("bonusValue"), typeID = skillBonus.AttributeInt("bonusValue") }; sk.requiredSkills.Add(rs); } } } int groupID = skill.AttributeInt("groupID"); SkillGroup a; if (res.skillGroupsDict.ContainsKey(groupID)) { a = res.skillGroupsDict[groupID]; } else { a = new SkillGroup { groupID = groupID, groupName = skillGroup.AttributeString("groupName") }; res.skillGroupsDict.Add(a.groupID, a); } sk.group = a; if (!res.skillsDict.ContainsKey(sk.typeID)) { res.skillsDict.Add(sk.typeID, sk); } } } foreach (var b in res.skillsDict.SelectMany(sk => sk.Value.requiredSkills.Where(b => res.skillsDict.ContainsKey(b.typeID)))) { b.skill = res.skillsDict[b.typeID]; } //var titanskill = res.skillsDict.FirstOrDefault(x => x.Value.typeName == "Amarr Titan"); //if (titanskill.Value != null) //{ // titanskill.Value.PrintRequiredSkills(0); //} return res; }
/// <summary> /// Draws the list item for the given skill group. /// </summary> /// <param name="group">The group.</param> /// <param name="e">The <see cref="System.Windows.Forms.DrawItemEventArgs"/> instance containing the event data.</param> private void DrawItem(SkillGroup group, DrawItemEventArgs e) { Graphics g = e.Graphics; // Draws the background using (Brush brush = Settings.UI.SafeForWork ? new SolidBrush(Color.FromArgb(75, 75, 75)) : (Brush)new LinearGradientBrush(new PointF(0F, 0F), new PointF(0F, SkillHeaderHeight), Color.FromArgb(75, 75, 75), Color.FromArgb(25, 25, 25))) { g.FillRectangle(brush, e.Bounds); } using (Pen pen = new Pen(Color.FromArgb(100, 100, 100))) { g.DrawLine(pen, e.Bounds.Left, e.Bounds.Top, e.Bounds.Right + 1, e.Bounds.Top); } // Measure Texts string skillInTrainingSuffix = String.Empty; string skillsInQueueSuffix = String.Empty; bool hasTrainingSkill = group.Any(x => x.IsTraining); bool hasQueuedSkill = group.Any(x => x.IsQueued && !x.IsTraining); if (hasTrainingSkill) skillInTrainingSuffix = "( 1 in training )"; if (hasQueuedSkill) { skillsInQueueSuffix = $"( {group.Count(x => x.IsQueued && !x.IsTraining)} in queue )"; } string skillsSummaryText = $"{group.Count(x => x.IsKnown)} of {group.Count(x => x.IsPublic)} skills"; string skillsTotalSPText = $"{group.TotalSP:N0} Points"; Rectangle skillGroupNameTextRect = new Rectangle(e.Bounds.Left + PadLeft, e.Bounds.Top + e.Bounds.Height / 2 - lbSkills.ItemHeight / 2, m_maxGroupNameWidth + PadLeft / 2, lbSkills.ItemHeight); int skillsSummaryTextWidth = (int)(SkillsSummaryTextWidth * (g.DpiX / EveMonConstants.DefaultDpi)); Rectangle skillsSummaryTextRect = new Rectangle( skillGroupNameTextRect.X + m_maxGroupNameWidth + PadLeft / 2, skillGroupNameTextRect.Y, skillsSummaryTextWidth + PadLeft / 2, lbSkills.ItemHeight); int skillGroupTotalSPTextWidth = (int)(SkillGroupTotalSPTextWidth * (g.DpiX / EveMonConstants.DefaultDpi)); Rectangle skillsTotalSPTextRect = new Rectangle( skillsSummaryTextRect.X + skillsSummaryTextWidth + PadLeft / 2, skillGroupNameTextRect.Y, skillGroupTotalSPTextWidth + PadLeft / 2, lbSkills.ItemHeight); Size skillInTrainingSuffixSize = TextRenderer.MeasureText(g, skillInTrainingSuffix, m_skillsFont, Size.Empty); Rectangle skillInTrainingSuffixRect = new Rectangle( skillsTotalSPTextRect.X + skillGroupTotalSPTextWidth + PadLeft / 2, skillGroupNameTextRect.Y, skillInTrainingSuffixSize.Width, lbSkills.ItemHeight); Size skillQueueTextSize = TextRenderer.MeasureText(g, skillsInQueueSuffix, m_skillsFont, Size.Empty); Rectangle skillQueueRect = new Rectangle( skillInTrainingSuffixRect.X + skillInTrainingSuffixSize.Width, skillInTrainingSuffixRect.Y, skillQueueTextSize.Width, lbSkills.ItemHeight); // Draw the header TextRenderer.DrawText(g, group.Name, m_boldSkillsFont, skillGroupNameTextRect, Color.White, Format); TextRenderer.DrawText(g, skillsSummaryText, m_skillsFont, skillsSummaryTextRect, Color.White, Format | TextFormatFlags.Right); TextRenderer.DrawText(g, skillsTotalSPText, m_skillsFont, skillsTotalSPTextRect, Color.White, Format | TextFormatFlags.Right); TextRenderer.DrawText(g, skillInTrainingSuffix, m_skillsFont, skillInTrainingSuffixRect, Color.White, Format | TextFormatFlags.Right); TextRenderer.DrawText(g, skillsInQueueSuffix, m_skillsFont, skillQueueRect, Settings.UI.SafeForWork ? Color.White : Color.Yellow, Format | TextFormatFlags.Right); // Draws the collapsing arrows bool isCollapsed = Character.UISettings.CollapsedGroups.Contains(group.Name); Image image = isCollapsed ? Resources.Expand : Resources.Collapse; g.DrawImageUnscaled(image, new Point(e.Bounds.Right - image.Width - CollapserPadRight, SkillHeaderHeight / 2 - image.Height / 2 + e.Bounds.Top)); }
/// <summary> /// Toggles the expansion or collapsing of a single group /// </summary> /// <param name="group">The group to expand or collapse.</param> public void ToggleGroupExpandCollapse(SkillGroup group) { if (Character.UISettings.CollapsedGroups.Contains(group.Name)) { ExpandSkillGroup(group); } else { CollapseSkillGroup(group); } }
/// <summary> /// Internal constructor, only used for character creation and updates /// </summary> /// <param name="owner"></param> /// <param name="group"></param> /// <param name="skill"></param> internal Skill(Character owner, SkillGroup group, StaticSkill skill) { m_character = owner; m_staticData = skill; m_skillGroup = group; }
/// <summary> /// Adds the skill groups. /// </summary> /// <param name="character">The character.</param> /// <param name="plan">The plan.</param> /// <param name="builder">The builder.</param> /// <param name="skillGroup">The skill group.</param> private static void AddSkillGroups(Character character, Plan plan, StringBuilder builder, SkillGroup skillGroup) { int count = skillGroup .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))) .Select(x => GetMergedSkill(plan, x)) .Count(); Int64 skillGroupTotalSP = skillGroup .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))) .Select(x => GetMergedSkill(plan, x)) .Sum(x => x.Skillpoints); // Skill Group builder.AppendLine($"{skillGroup.Name}, " + $"{count} Skill{(count > 1 ? "s" : String.Empty)}, " + FormattableString.Invariant($"{skillGroupTotalSP:N0} Points")); // Skills foreach (Skill skill in skillGroup.Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x)))) { AddSkills(character, plan, builder, skill); } }
/// <summary> /// Draws the list item for the given skill group. /// </summary> /// <param name="skill"></param> /// <param name="e"></param> public void DrawItem(SkillGroup group, DrawItemEventArgs e) { Graphics g = e.Graphics; // Draws the background using (Brush b = new SolidBrush(Color.FromArgb(75, 75, 75))) { g.FillRectangle(b, e.Bounds); } using (Pen p = new Pen(Color.FromArgb(100, 100, 100))) { g.DrawLine(p, e.Bounds.Left, e.Bounds.Top, e.Bounds.Right + 1, e.Bounds.Top); } // Draw the header Size titleSizeInt = TextRenderer.MeasureText( g, group.Name, m_boldSkillsFont, Size.Empty, TextFormatFlags.NoPadding | TextFormatFlags.NoClipping); Rectangle titleTopLeftInt = new Rectangle( e.Bounds.Left + 3, e.Bounds.Top + ((e.Bounds.Height / 2) - (titleSizeInt.Height / 2)), titleSizeInt.Width + PadRight, titleSizeInt.Height); string skillInTrainingSuffix = String.Empty; bool hasTrainingSkill = group.Any(x => x.IsTraining); bool hasQueuedSkill = group.Any(x=> x.IsQueued && !x.IsTraining); if (hasTrainingSkill) skillInTrainingSuffix = ", ( 1 in training )"; if (hasQueuedSkill) skillInTrainingSuffix += String.Format(CultureConstants.DefaultCulture, ", ( {0} in queue )", group.Count(x=> x.IsQueued && !x.IsTraining)); // Draws the rest of the text header string detailText = String.Format(CultureConstants.DefaultCulture, ", {0} of {1} skills, {2:#,##0} Points{3}", group.Count(x => x.IsKnown), group.Count(x => x.IsPublic), group.TotalSP, skillInTrainingSuffix); Size detailSizeInt = TextRenderer.MeasureText( g, detailText, m_skillsFont, Size.Empty, TextFormatFlags.NoPadding | TextFormatFlags.NoClipping); Rectangle detailTopLeftInt = new Rectangle( titleTopLeftInt.X + titleSizeInt.Width + 4, titleTopLeftInt.Y, detailSizeInt.Width, detailSizeInt.Height); TextRenderer.DrawText(g, group.Name, m_boldSkillsFont, titleTopLeftInt, Color.White); TextRenderer.DrawText(g, detailText, m_skillsFont, detailTopLeftInt, Color.White); // Draws the collapsing arrows bool isCollapsed = Character.UISettings.CollapsedGroups.Contains(group.Name); Image i = (isCollapsed ? CommonProperties.Resources.Expand : CommonProperties.Resources.Collapse); g.DrawImageUnscaled(i, new Point(e.Bounds.Right - i.Width - CollapserPadRight, (SkillHeaderHeight / 2) - (i.Height / 2) + e.Bounds.Top)); }
/// <summary> /// Internal constructor, only used for character creation and updates /// </summary> /// <param name="owner"></param> /// <param name="group"></param> /// <param name="skill"></param> internal Skill(Character owner, SkillGroup group, StaticSkill skill) { Character = owner; StaticData = skill; Group = group; }
/// <summary> /// Adds the skill group. /// </summary> /// <param name="plan">The plan.</param> /// <param name="skillGroup">The skill group.</param> /// <returns></returns> private static OutputSkillGroup AddSkillGroup(Plan plan, SkillGroup skillGroup) { int count = skillGroup .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))) .Select(x => GetMergedSkill(plan, x)) .Count(); Int64 skillGroupTotalSP = skillGroup .Where(x => x.IsKnown || (plan != null && plan.IsPlanned(x))) .Select(x => GetMergedSkill(plan, x)) .Sum(x => x.Skillpoints); OutputSkillGroup outGroup = new OutputSkillGroup { Name = skillGroup.Name, SkillsCount = count, TotalSP = FormattableString.Invariant($"{skillGroupTotalSP:N0}") }; return outGroup; }
public void SetAllowedSkills(SkillGroup allowedSkills) { profession.AllowedSkills = allowedSkills; foreach (var skill in laborSkills) skill.IsAllowed = allowedSkills.IsSkillAllowed(skill.Type); }