Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Menu/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Ensage.Common.Menu
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
Expand Down Expand Up @@ -109,7 +110,7 @@ static Menu()
MenuPanel = new DrawRect(Color.Black);
PanelText = new DrawText { Text = "EnsageSharp Menu", FontFlags = FontFlags.AntiAlias };
TextureDictionary = new Dictionary<string, DotaTexture>();
ItemDictionary = new Dictionary<string, MenuItem>();
ItemDictionary = new ConcurrentDictionary<string, MenuItem>();
Drawing.OnDraw += OnDraw;
ActivateCommonMenu();
}
Expand Down Expand Up @@ -149,10 +150,8 @@ public Menu(
this.ShowTextWithTexture = showTextWithTexture;
this.transition = new ExpoEaseInOut(0.25);

if (Root?.Item("allowCustomTextures").GetValue<bool>() != true)
{
if (!Root?.Item("allowCustomTextures").GetValue<bool>() ?? false)
this.TextureName = null;
}

AppDomain.CurrentDomain.DomainUnload += delegate { this.SaveAll(); };
AppDomain.CurrentDomain.ProcessExit += delegate { this.SaveAll(); };
Expand Down Expand Up @@ -301,7 +300,7 @@ public string TextureName {
/// <summary>
/// The item dictionary.
/// </summary>
internal static Dictionary<string, MenuItem> ItemDictionary { get; set; }
internal static ConcurrentDictionary<string, MenuItem> ItemDictionary { get; set; }

/// <summary>Gets or sets the menu panel.</summary>
internal static DrawRect MenuPanel { get; set; }
Expand Down Expand Up @@ -817,10 +816,7 @@ public MenuItem Item(string name, bool makeChampionUniq = false)
?? (from subMenu in this.Children where subMenu.Item(name) != null select subMenu.Item(name))
.FirstOrDefault();
if (tempItem != null)
{
ItemDictionary.Add(id, tempItem);
}

ItemDictionary.TryAdd(id, tempItem);
return tempItem;
}

Expand Down