/// <summary> /// Default construcotor /// </summary> /// <param name="stat">Stat to display</param> /// <param name="statName">Stat name to display</param> /// <param name="min">Min allowed value of the stat</param> /// <param name="max">Max allowed value of the stat</param> public StatSlot(Stat stat, string statName, float min, Stat max) { Dock = DockStyle.Fill; Size = new Size(196, 28); Margin = new Padding(0); this.stat = stat; this.statName = statName; this.min = min; this.max = max; float maxValue = stat.baseMax.Get(); if (max != null) { maxValue = max.value.Get(); max.value.AddListener(this); } valueBox = new NumericTextBox <float>(stat.value, min, maxValue, 60); LabeledControl labeledValueBox = new LabeledControl(statName, valueBox, 190); stat.value.AddListener(this); Controls.Add(labeledValueBox); }
/// <summary> /// Adds the control. /// </summary> /// <param name="labelText">The label text.</param> /// <param name="control">The control.</param> public void AddControl(string labelText, Control control) { LabeledControl label = new LabeledControl(labelText, control); //label.ID = "l"; Controls.Add(label); }
private void AddStringEntry(TweakOption option, Control panel) { var parent = new LabeledControl() { Text = option.Name, AutoSize = true }; var textBox = new TextBox(); try { textBox.Text = option.GetValue <string>(); textBox.Enabled = option.CanWrite; } catch { textBox.Enabled = false; } textBox.TextChanged += (s, e2) => { option.SetValue(textBox.Text); this.CheckRefresh(option); }; parent.Child = textBox; panel.Controls.Add(parent); }
/// <summary> /// Default constructor. /// </summary> /// <param name="playerDataFile">PlayerDataFile to use</param> public ScorePanel(PlayerDataFile playerDataFile) { this.playerDataFile = playerDataFile; scoreBox = new NumericTextBox <int>(playerDataFile.score, 0 /*GetMinScore()*/, int.MaxValue, 60); LabeledControl labeledScoreBox = new LabeledControl("Score", scoreBox, 190); Controls.Add(labeledScoreBox); LabeledControl LabeledPlayerKillsBox = new LabeledControl("Player kills", new NumericTextBox <int>(playerDataFile.playerKills, 0, int.MaxValue, 60), 190); Controls.Add(LabeledPlayerKillsBox); LabeledControl labeledZombieKillsBox = new LabeledControl("Zombie kills", new NumericTextBox <int>(playerDataFile.zombieKills, 0, int.MaxValue, 60), 190); Controls.Add(labeledZombieKillsBox); LabeledControl labeledDeathsBox = new LabeledControl("Deaths", new NumericTextBox <int>(playerDataFile.deaths, 0, int.MaxValue, 60), 190); Controls.Add(labeledDeathsBox); Size = new Size(196, 140); /*playerDataFile.playerKills.AddListener(this); * playerDataFile.zombieKills.AddListener(this); * playerDataFile.deaths.AddListener(this);*/ }
private void AddEnumEntry(TweakOption option, Control panel) { var parent = new LabeledControl() { Text = option.Name, AutoSize = true }; var comboBox = new ComboBox() { DropDownStyle = ComboBoxStyle.DropDownList, DrawMode = DrawMode.OwnerDrawVariable }; comboBox.DrawItem += (s, e2) => { //Can't render empty items. if (e2.Index < 0) { return; } e2.DrawBackground(); //Use display name as label, if not available use property name as fallback. var item = (Enum)comboBox.Items[e2.Index]; string valueDisplayName = item.GetAttribute <DisplayNameAttribute>()?.DisplayName ?? item.ToString(); e2.Graphics.DrawString(valueDisplayName, comboBox.Font, new SolidBrush(e2.ForeColor), e2.Bounds.X, e2.Bounds.Y); }; try { foreach (Enum value in Enum.GetValues(option.Type)) { comboBox.Items.Add(value); } comboBox.SelectedItem = option.GetValue <object>(); comboBox.Enabled = option.CanWrite; } catch { comboBox.Enabled = false; } comboBox.SelectedValueChanged += (s, e2) => { option.SetValue(comboBox.SelectedItem); this.CheckRefresh(option); }; parent.Child = comboBox; panel.Controls.Add(parent); }
/// <summary> /// Default constructor. /// </summary> /// <param name="liveStat">Live stat to display</param> /// <param name="liveStatName">Name to display</param> /// <param name="max">Maximum value of a live stat</param> public LiveStatSlot(LiveStats liveStat, string liveStatName, int max) { Dock = DockStyle.Fill; Size = new Size(196, 28); Margin = new Padding(0); this.liveStat = liveStat; this.liveStatName = liveStatName; this.max = max; LabeledControl labeledValueBox = new LabeledControl(liveStatName, new PercentageIntegerTextBox(liveStat.lifeLevel, max, 60), 190); Controls.Add(labeledValueBox); }
public PortalControl() { Layout += DoLayout; SuspendLayout(); _nodes = new LabeledControl <ComboBox>(new ComboBox(), "Nodes", TEXT_WIDTH); Controls.Add(_nodes); _nodes.Control.SelectedValueChanged += (o, e) => { Changed?.Invoke(); }; _series = new LabeledControl <ComboBox>(new ComboBox(), "Series", TEXT_WIDTH); Controls.Add(_series); _series.Control.SelectedValueChanged += (o, e) => { Changed?.Invoke(); }; _timeSeries = new TimeSeriesChart(); Controls.Add(_timeSeries); ResumeLayout(); }
private void AddIntegerEntry(TweakOption option, Control panel) { var parent = new LabeledControl() { Text = option.Name, AutoSize = true }; var rangeAttribute = option.GetAttribute <RangeAttribute>(); int?mininum = null; int?maximum = null; if (rangeAttribute != null) { mininum = (int)rangeAttribute.Mininum; maximum = (int)rangeAttribute.Maximum; } if (Properties.Settings.Default.PreferSliders && mininum != null && maximum != null) { var slider = new TrackBar() { Minimum = mininum ?? int.MinValue, Maximum = maximum ?? int.MaxValue, TickFrequency = int.MaxValue, AutoSize = false, Height = 24 }; try { slider.Value = option.GetValue <int>(); slider.Enabled = option.CanWrite; } catch { slider.Enabled = false; } slider.ValueChanged += (s, e2) => { option.SetValue(slider.Value); this.CheckRefresh(option); }; parent.Child = slider; } else { var upDown = new NumericUpDown() { Minimum = mininum ?? int.MinValue, Maximum = maximum ?? int.MaxValue }; try { upDown.Value = option.GetValue <int>(); upDown.Enabled = option.CanWrite; } catch { upDown.Enabled = false; } upDown.ValueChanged += (s, e2) => { option.SetValue((int)upDown.Value); this.CheckRefresh(option); }; parent.Child = upDown; } panel.Controls.Add(parent); }
/// <summary> /// Generates basic info for an item. This applies to every subclass. /// </summary> /// <returns></returns> protected TableLayoutPanel GenerateBasicInfo() { TableLayoutPanel basicInfo = new TableLayoutPanel() { Anchor = AnchorStyles.None, AutoSize = true }; if (!itemBinder.itemData.name.Equals("air")) { if (itemBinder.itemData.stackNumber > 1) { LabeledControl countBox = new LabeledControl("Count", new NumericTextBox <int>(itemBinder.itemStack.count, 1, itemBinder.itemData.stackNumber, textBoxWidth), labeledControlWidth); basicInfo.Controls.Add(countBox); } if (itemBinder.itemData.hasQuality) { int degradation = itemBinder.GetMaxDegradationForQuality(); degradationBox = new InvertedIntegerTextBox(itemBinder.itemValue.useTimes, 1, degradation, textBoxWidth); LabeledControl labeledDegradationBox = new LabeledControl("Durability", degradationBox, labeledControlWidth); qualityBox = new NumericTextBox <int>(itemBinder.itemValue.quality, 1, ItemData.MAX_QUALITY, textBoxWidth); itemBinder.itemValue.quality.AddListener(this); LabeledControl labeledQualityBox = new LabeledControl("Quality", qualityBox, labeledControlWidth); basicInfo.Controls.Add(labeledQualityBox); basicInfo.Controls.Add(labeledDegradationBox); if (itemBinder.itemData.magazineSize > 0) { magazineBox = new NumericTextBox <int>(itemBinder.itemValue.meta, 0, itemBinder.itemData.magazineSize, textBoxWidth); LabeledControl labeledMagazineBox = new LabeledControl("Ammo loaded", magazineBox, labeledControlWidth); basicInfo.Controls.Add(labeledMagazineBox); } if (itemBinder.itemData.partNames != null) { qualityBox.Enabled = false; degradationBox.Enabled = false; if (itemBinder.HasAllParts()) { qualityBox.Text = itemBinder.GetQualityFromParts().ToString(); } else { magazineBox.Enabled = false; qualityBox.Text = ""; magazineBox.Text = ""; } degradationBox.Text = ""; } if (itemBinder.itemData.magazineItems != null && itemBinder.itemData.magazineItems.Length > 1) { magazineItemsBox = new ComboBox(); magazineItemsBox.BindingContext = new BindingContext(); magazineItemsBox.DataSource = itemBinder.itemData.magazineItems; magazineItemsBox.SelectedIndex = itemBinder.itemValue.selectedAmmoTypeIndex.Get(); magazineItemsBox.Width = textBoxWidth; magazineItemsBox.DropDownStyle = ComboBoxStyle.DropDownList; magazineItemsBox.DropDownClosed += new EventHandler(MagazineItemBoxChanged); magazineItemsBox.SelectedValueChanged += new EventHandler(MagazineItemBoxChanged); LabeledControl magazineComboBox = new LabeledControl("Selected ammo", magazineItemsBox, labeledControlWidth); basicInfo.Controls.Add(magazineComboBox); } } } return(basicInfo); }
/// <summary> /// Default constructor. /// </summary> /// <param name="playerDataFile">PlayerDataFile to use</param> /// <param name="recipes">List of all the recipes</param> public SkillsTab(PlayerDataFile playerDataFile, List <RecipeBinder> recipes) { Text = "Skills"; this.playerDataFile = playerDataFile; this.recipes = recipes; SetUpSkills(); panel = new TableLayoutPanel(); panel.Dock = DockStyle.Fill; TableLayoutPanel general = new TableLayoutPanel() { Size = new Size(478, 36), Anchor = AnchorStyles.Top }; LabeledControl LabeledPlayerLevelBox = new LabeledControl("Player level", new NumericTextBox <int>(playerDataFile.level, 1, SkillData.maxPlayerLevel, 80), 150); playerDataFile.level.AddListener(this); general.Controls.Add(LabeledPlayerLevelBox, 0, 0); LabeledControl LabeledSkillPointsBox = new LabeledControl("Skill points", new NumericTextBox <int>(playerDataFile.skillPoints, 0, int.MaxValue, 80), 150); general.Controls.Add(LabeledSkillPointsBox, 1, 0); LabeledControl LabeledExperienceBox = new LabeledControl("Experience", new NumericTextBox <uint>(playerDataFile.experience, 0u, (uint)(SkillData.expToPlayerLevel * SkillData.maxPlayerLevel), 80), 150); playerDataFile.experience.AddListener(this); general.Controls.Add(LabeledExperienceBox, 2, 0); panel.Controls.Add(general); TableLayoutPanel skillsPanel = new TableLayoutPanel() { CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset, Dock = DockStyle.Fill, AutoScroll = true }; skillsPanel.MouseEnter += (sender, e) => { bool focusFree = true; foreach (SkillSlot skillSlot in skillSlots) { if (skillSlot.levelBox.Focused || (skillSlot.expToNextLevelBox != null && skillSlot.expToNextLevelBox.Focused)) { focusFree = false; break; } } if (focusFree) { skillsPanel.Focus(); } }; TableLayoutPanel centerer = new TableLayoutPanel() { Anchor = AnchorStyles.Top, CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset, AutoSize = true }; skillSlots = new List <SkillSlot>(); int i = 0; foreach (KeyValuePair <int, Skill> skillEntry in playerDataFile.skills.skillDictionary) { SkillSlot skillSlot = new SkillSlot(new SkillBinder(skillEntry.Value, playerDataFile.level, recipes)); skillSlots.Add(skillSlot); centerer.Controls.Add(skillSlot, i % 4, i / 4); i++; } skillsPanel.Controls.Add(centerer); panel.Controls.Add(skillsPanel); Controls.Add(panel); }
/// <summary> /// Generates the slot. /// </summary> public void GenerateSlot() { Size = new Size(210, 210); TableLayoutPanel title = new TableLayoutPanel() { Anchor = AnchorStyles.Top, MaximumSize = new Size(int.MaxValue, 94), AutoSize = true }; Label imageLabel = new Label() { Size = new Size(skillBinder.skillData.iconData.width, skillBinder.skillData.iconData.height), Anchor = AnchorStyles.Top, Text = "", BackgroundImage = null }; Bitmap image = skillBinder.GetImage(); if (image != null) { imageLabel.BackgroundImage = image; } title.Controls.Add(imageLabel, 0, 0); Label name = new Label() { TextAlign = ContentAlignment.MiddleLeft, Text = skillBinder.skillData.name, Anchor = AnchorStyles.None, AutoSize = true }; title.Controls.Add(name, 0, 1); Controls.Add(title, 0, 0); int min = 1; if (skillBinder.skillData.type == SkillType.Perk) { min = 0; } levelBox = new NumericTextBox <int>(skillBinder.skill.level, min, skillBinder.GetHighestUnlockedLevel(), 80); LabeledControl labeledLevelBox = new LabeledControl("Level", levelBox, 180); Controls.Add(labeledLevelBox, 0, 1); skillBinder.skill.level.AddListener(this); if (skillBinder.skillData.type != SkillType.Perk) { expToNextLevelBox = new NumericTextBox <int>(skillBinder.skill.expToNextLevel, 0, skillBinder.skillData.expToLevel, 80); LabeledControl labeledExpToNextLevelBox = new LabeledControl("Exp to next level", expToNextLevelBox, 180); Controls.Add(labeledExpToNextLevelBox, 0, 2); } else if (skillBinder.skillData.requirements.Count > 0) { RegisterListeners(); if (skillBinder.GetHighestUnlockedLevel() != skillBinder.skillData.maxLevel) { Controls.Add(GetRequirementTipsLabel(), 0, 3); } } }