Skip to content

Commit

Permalink
changed Drawing.ResumeDrawing() to once again use Refresh(); implemen…
Browse files Browse the repository at this point in the history
…ted ability to alter 'level obtained' for an item, which then reflects on combined stat table
  • Loading branch information
djrecipe committed Apr 25, 2016
1 parent 12be552 commit 71bb4c3
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 17 deletions.
12 changes: 11 additions & 1 deletion Riot.API/Builder/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,22 @@ public void SetChampion(ChampionInfo champion_in)

public void SetItem(int index, ItemInfo item)
{
if(index < 0 || index >=6)
if (index < 0 || index >= 6)
throw new ArgumentOutOfRangeException("Item index must be 0 or greater and less than six", "index");
this.Items[index] = item;
this.FireUpdate(this.Name);
return;
}
public void SetItemLevel(int index, int level)
{
if (index < 0 || index >= 6)
throw new ArgumentOutOfRangeException("Item index must be 0 or greater and less than six", "index");
if (this.Items[index] == null)
return;
this.Items[index].LevelObtained = level;
this.FireUpdate(this.Name);
return;
}
#endregion
}
}
9 changes: 9 additions & 0 deletions Riot.API/Serialization/Champions/ChampionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ public class ChampionInfo : IRiotDroppable
/// </summary>
[JsonProperty("image", ItemIsReference = true, ReferenceLoopHandling = ReferenceLoopHandling.Serialize)]
private ImageInfo ImageData { get; set; } = null;

/// <summary>
/// Level at which champion stats are taken into account
/// </summary>
public int LevelObtained
{
get { return this.Stats.RequiredLevel; }
set { this.Stats.RequiredLevel = value; }
}
/// <summary>
/// Collection of non-static data, primarily in regards to champion availability
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Riot.API/Serialization/General/CombinedStatsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void UpdateStats()
{
for (int i = 0; i <= 18; i++)
{
IEnumerable<IStatsInfo> collection = this.components.Where(c => c.RequiredLevel == 1 || c.RequiredLevel >= i);
IEnumerable<IStatsInfo> collection = this.components.Where(c => c.RequiredLevel == 1 || c.RequiredLevel <= i);
this.Stats[i]["AbilityPower"] = collection.Sum(info => (double)info.Stats[i]["AbilityPower"]);
this.Stats[i]["Armor"] = collection.Sum(info => (double)info.Stats[i]["Armor"]);
this.Stats[i]["AttackDamage"] = collection.Sum(info => (double)info.Stats[i]["AttackDamage"]);
Expand Down
1 change: 1 addition & 0 deletions Riot.API/Serialization/Interfaces/IRiotDroppable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace RiotPls.API.Serialization.Interfaces
public interface IRiotDroppable
{
Bitmap Image { get; }
int LevelObtained { get; set; }
string Name { get; }
}
}
8 changes: 8 additions & 0 deletions Riot.API/Serialization/Items/ItemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ public bool Consumable
public ImageInfo ImageData { get; private set; } = null;
[JsonProperty("inStore")]
public bool IsInStore { get; private set; } = false;
/// <summary>
/// Level at which item stats are taken into account
/// </summary>
public int LevelObtained
{
get { return this.Stats.RequiredLevel; }
set { this.Stats.RequiredLevel = value; }
}
[JsonProperty("maps", ItemIsReference = true)]
public Dictionary<string, bool> Maps { get; private set; } = new Dictionary<string, bool>();
[JsonProperty("name")]
Expand Down
2 changes: 1 addition & 1 deletion RiotPls.Tools/Drawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void ResumeDrawing(Control parent, bool refresh = true)
return;
Drawing.SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
if (refresh)
parent.Invalidate();
parent.Refresh();
return;
}
public static void SuspendDrawing(Control parent)
Expand Down
50 changes: 43 additions & 7 deletions RiotPls/Controls/DropSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ namespace RiotPls.Controls
{
public class DropSlot : UserControl
{
#region Types
public delegate void delDropOccurred(DropSlot slot, IRiotDroppable drop);
#region Types
public delegate void DropOccurredDelegate(DropSlot slot, IRiotDroppable drop);
public delegate void LevelObtainedChangedDelegate(DropSlot slot, IRiotDroppable drop, int level);
public enum DataType : uint
{
Champion = 0,
Expand All @@ -32,8 +33,9 @@ public enum DataType : uint
private Label lblMain;
private PictureBox picMain;
#endregion
#region Events
public event delDropOccurred DropOccurred;
#region Events
public event DropOccurredDelegate DropOccurred;
public event LevelObtainedChangedDelegate LevelObtainedChanged;
#endregion
private IRiotDroppable drop = null;
#endregion
Expand Down Expand Up @@ -113,7 +115,7 @@ private void InitializeComponent()
this.mnuitmRemoveItem,
this.mnuitmItemLevelObtained});
this.cmenItem.Name = "cmenItem";
this.cmenItem.Size = new System.Drawing.Size(154, 48);
this.cmenItem.Size = new System.Drawing.Size(154, 70);
//
// mnuitmRemoveItem
//
Expand All @@ -131,24 +133,27 @@ private void InitializeComponent()
this.mnuitmItemLevelObtained.Name = "mnuitmItemLevelObtained";
this.mnuitmItemLevelObtained.Size = new System.Drawing.Size(153, 22);
this.mnuitmItemLevelObtained.Text = "Level Obtained";
this.mnuitmItemLevelObtained.DropDownOpened += new System.EventHandler(this.mnuitmItemLevelObtained_DropDownOpened);
this.mnuitmItemLevelObtained.TextChanged += new System.EventHandler(this.mnuitmItemLevelObtained_TextChanged);
//
// mnuitmLevelObtainedValue
//
this.mnuitmLevelObtainedValue.Name = "mnuitmLevelObtainedValue";
this.mnuitmLevelObtainedValue.Size = new System.Drawing.Size(100, 23);
this.mnuitmLevelObtainedValue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.mnuitmLevelObtainedValue_KeyDown);
this.mnuitmLevelObtainedValue.TextChanged += new System.EventHandler(this.mnuitmLevelObtainedValue_TextChanged);
//
// cmenChampion
//
this.cmenChampion.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuitmRemoveChampion});
this.cmenChampion.Name = "cmenChampion";
this.cmenChampion.Size = new System.Drawing.Size(153, 48);
this.cmenChampion.Size = new System.Drawing.Size(118, 26);
//
// mnuitmRemoveChampion
//
this.mnuitmRemoveChampion.Name = "mnuitmRemoveChampion";
this.mnuitmRemoveChampion.Size = new System.Drawing.Size(152, 22);
this.mnuitmRemoveChampion.Size = new System.Drawing.Size(117, 22);
this.mnuitmRemoveChampion.Text = "Remove";
this.mnuitmRemoveChampion.Click += new System.EventHandler(this.mnuitmRemove_Click);
//
Expand Down Expand Up @@ -199,6 +204,7 @@ private void UpdateData()
{
this.picMain.BackgroundImage = this.drop?.Image;
this.lblMain.Text = this.drop?.Name ?? this.NullText;
this.mnuitmLevelObtainedValue.Text = (this.drop?.LevelObtained ?? 1).ToString();
this.FireDropOccurredEvent(this.drop);
return;
}
Expand Down Expand Up @@ -252,6 +258,36 @@ protected override void OnDragEnter(DragEventArgs e)
#endregion

#endregion
#region Event Methods
private void mnuitmItemLevelObtained_DropDownOpened(object sender, EventArgs e)
{
this.mnuitmLevelObtainedValue.Focus();
this.mnuitmLevelObtainedValue.SelectionStart = 0;
this.mnuitmLevelObtainedValue.SelectionLength = this.mnuitmLevelObtainedValue.TextLength;
}
private void mnuitmLevelObtainedValue_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.cmenItem.Close();
e.Handled = true;
}
return;
}
private void mnuitmLevelObtainedValue_TextChanged(object sender, EventArgs e)
{
if (this.drop == null)
return;
int level = 1;
if (int.TryParse(this.mnuitmLevelObtainedValue.Text, out level))
{
this.drop.LevelObtained = level;
if (this.LevelObtainedChanged != null)
this.LevelObtainedChanged(this, this.drop, this.drop.LevelObtained);
}
return;
}
#endregion

}
}
25 changes: 18 additions & 7 deletions RiotPls/Forms/formBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void InitializeComponent()
this.dropChampion.Size = new System.Drawing.Size(124, 151);
this.dropChampion.TabIndex = 22;
this.dropChampion.Type = RiotPls.Controls.DropSlot.DataType.Champion;
this.dropChampion.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropChampion_DropOccurred);
this.dropChampion.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropChampion_DropOccurred);
//
// dropItem1
//
Expand All @@ -93,7 +93,8 @@ private void InitializeComponent()
this.dropItem1.Size = new System.Drawing.Size(96, 121);
this.dropItem1.TabIndex = 23;
this.dropItem1.Type = RiotPls.Controls.DropSlot.DataType.Item;
this.dropItem1.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropItem_DropOccurred);
this.dropItem1.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropItem_DropOccurred);
this.dropItem1.LevelObtainedChanged += new RiotPls.Controls.DropSlot.LevelObtainedChangedDelegate(this.dropItem_LevelObtainedChanged);
//
// dropItem2
//
Expand All @@ -107,7 +108,8 @@ private void InitializeComponent()
this.dropItem2.Size = new System.Drawing.Size(96, 121);
this.dropItem2.TabIndex = 24;
this.dropItem2.Type = RiotPls.Controls.DropSlot.DataType.Item;
this.dropItem2.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropItem_DropOccurred);
this.dropItem2.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropItem_DropOccurred);
this.dropItem2.LevelObtainedChanged += new RiotPls.Controls.DropSlot.LevelObtainedChangedDelegate(this.dropItem_LevelObtainedChanged);
//
// dropItem3
//
Expand All @@ -121,7 +123,8 @@ private void InitializeComponent()
this.dropItem3.Size = new System.Drawing.Size(96, 121);
this.dropItem3.TabIndex = 25;
this.dropItem3.Type = RiotPls.Controls.DropSlot.DataType.Item;
this.dropItem3.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropItem_DropOccurred);
this.dropItem3.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropItem_DropOccurred);
this.dropItem3.LevelObtainedChanged += new RiotPls.Controls.DropSlot.LevelObtainedChangedDelegate(this.dropItem_LevelObtainedChanged);
//
// dropItem4
//
Expand All @@ -135,7 +138,8 @@ private void InitializeComponent()
this.dropItem4.Size = new System.Drawing.Size(96, 121);
this.dropItem4.TabIndex = 26;
this.dropItem4.Type = RiotPls.Controls.DropSlot.DataType.Item;
this.dropItem4.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropItem_DropOccurred);
this.dropItem4.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropItem_DropOccurred);
this.dropItem4.LevelObtainedChanged += new RiotPls.Controls.DropSlot.LevelObtainedChangedDelegate(this.dropItem_LevelObtainedChanged);
//
// dropItem5
//
Expand All @@ -149,7 +153,8 @@ private void InitializeComponent()
this.dropItem5.Size = new System.Drawing.Size(96, 121);
this.dropItem5.TabIndex = 27;
this.dropItem5.Type = RiotPls.Controls.DropSlot.DataType.Item;
this.dropItem5.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropItem_DropOccurred);
this.dropItem5.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropItem_DropOccurred);
this.dropItem5.LevelObtainedChanged += new RiotPls.Controls.DropSlot.LevelObtainedChangedDelegate(this.dropItem_LevelObtainedChanged);
//
// dropItem6
//
Expand All @@ -163,7 +168,8 @@ private void InitializeComponent()
this.dropItem6.Size = new System.Drawing.Size(96, 121);
this.dropItem6.TabIndex = 28;
this.dropItem6.Type = RiotPls.Controls.DropSlot.DataType.Item;
this.dropItem6.DropOccurred += new RiotPls.Controls.DropSlot.delDropOccurred(this.dropItem_DropOccurred);
this.dropItem6.DropOccurred += new RiotPls.Controls.DropSlot.DropOccurredDelegate(this.dropItem_DropOccurred);
this.dropItem6.LevelObtainedChanged += new RiotPls.Controls.DropSlot.LevelObtainedChangedDelegate(this.dropItem_LevelObtainedChanged);
//
// gridMain
//
Expand Down Expand Up @@ -304,6 +310,11 @@ private void dropItem_DropOccurred(DropSlot slot, API.Serialization.Interfaces.I
ItemInfo item = drop as ItemInfo;
this.Build.SetItem(index, item);
}
private void dropItem_LevelObtainedChanged(DropSlot slot, API.Serialization.Interfaces.IRiotDroppable drop, int level)
{
int index = this.itemDrops.ToList().IndexOf(slot);
this.Build.SetItemLevel(index, level);
}
#endregion
#region Grid Events
private void gridMain_SelectedRowChanged(int row)
Expand Down

0 comments on commit 71bb4c3

Please sign in to comment.