Pārlūkot izejas kodu

Make style a little more internally consistent

Dragon 4 gadi atpakaļ
vecāks
revīzija
5bc707388d
2 mainītis faili ar 69 papildinājumiem un 69 dzēšanām
  1. 36 36
      Interface.cs
  2. 33 33
      Plugin.cs

+ 36 - 36
Interface.cs

@@ -20,7 +20,7 @@ namespace HuntBuddy
 
 		public Interface(Plugin plugin)
 		{
-			_plugin = plugin;
+			this._plugin = plugin;
 		}
 
 		public unsafe bool Draw()
@@ -31,23 +31,23 @@ namespace HuntBuddy
 
 			ImGui.SetNextWindowSize(new Vector2(400 * ImGui.GetIO().FontGlobalScale, 500), ImGuiCond.Once);
 
-			if (!ImGui.Begin($"{_plugin.Name}", ref draw, ImGuiWindowFlags.NoDocking))
+			if (!ImGui.Begin($"{this._plugin.Name}", ref draw, ImGuiWindowFlags.NoDocking))
 			{
 				return draw;
 			}
 
-			if (!_plugin.MobHuntEntriesReady)
+			if (!this._plugin.MobHuntEntriesReady)
 			{
 				ImGui.Text("Reloading data ...");
 				ImGui.End();
 				return draw;
 			}
 
-			if (IconButton(FontAwesomeIcon.Redo, "Reload"))
+			if (Interface.IconButton(FontAwesomeIcon.Redo, "Reload"))
 			{
 				ImGui.End();
-				_plugin.MobHuntEntriesReady = false;
-				Task.Run(() => _plugin.ReloadData());
+				this._plugin.MobHuntEntriesReady = false;
+				Task.Run(() => this._plugin.ReloadData());
 				return draw;
 			}
 
@@ -60,24 +60,24 @@ namespace HuntBuddy
 			
 			ImGui.SameLine();
 
-			if (IconButton(FontAwesomeIcon.Cog, "Config"))
+			if (Interface.IconButton(FontAwesomeIcon.Cog, "Config"))
 			{
 				this._drawConfigurationInterface = !this._drawConfigurationInterface;
 			}
 
-			foreach (var expansionEntry in _plugin.MobHuntEntries.Where(expansionEntry =>
+			foreach (var expansionEntry in this._plugin.MobHuntEntries.Where(expansionEntry =>
 				         ImGui.TreeNode(expansionEntry.Key)))
 			{
 				foreach (var entry in expansionEntry.Value.Where(entry =>
 					         ImGui.TreeNode(
-						         $"{entry.Key.Value} ({entry.Value.Count(x => _plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills)}/{entry.Value.Count})")))
+						         $"{entry.Key.Value} ({entry.Value.Count(x => this._plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills)}/{entry.Value.Count})")))
 				{
 					ImGui.Indent();
 					foreach (var mobHuntEntry in entry.Value)
 					{
 						if (Location.Database.ContainsKey(mobHuntEntry.MobHuntId))
 						{
-							if (IconButton(FontAwesomeIcon.Search, $"##{mobHuntEntry.MobHuntId}"))
+							if (Interface.IconButton(FontAwesomeIcon.Search, $"##{mobHuntEntry.MobHuntId}"))
 							{
 								Location.OpenMapLink(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
 									mobHuntEntry.MobHuntId);
@@ -86,7 +86,7 @@ namespace HuntBuddy
 							ImGui.SameLine();
 						}
 
-						var currentKills = _plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
+						var currentKills = this._plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
 						ImGui.Text(mobHuntEntry.Name);
 						if (ImGui.IsItemHovered())
 						{
@@ -101,11 +101,11 @@ namespace HuntBuddy
 							    mobHuntEntry.MobHuntType == 1) // Endwalker uses circle for non elite mobs
 							{
 								drawList.AddCircleFilled(cursorPos + new Vector2(imageSize / 2f), imageSize / 2f,
-									_plugin.Configuration.IconBackgroundColourU32);
+									this._plugin.Configuration.IconBackgroundColourU32);
 							}
 							else
 							{
-								drawList.AddRectFilled(cursorPos, cursorPos + new Vector2(imageSize), _plugin.Configuration.IconBackgroundColourU32);
+								drawList.AddRectFilled(cursorPos, cursorPos + new Vector2(imageSize), this._plugin.Configuration.IconBackgroundColourU32);
 							}
 
 							drawList.AddImage(mobHuntEntry.Icon.ImGuiHandle, cursorPos,
@@ -135,7 +135,7 @@ namespace HuntBuddy
 
 			ImGui.End();
 
-			if (_drawConfigurationInterface)
+			if (this._drawConfigurationInterface)
 			{
 				this.DrawConfiguration();
 			}
@@ -145,11 +145,11 @@ namespace HuntBuddy
 
 		public unsafe void DrawLocalHunts()
 		{
-			if (!_plugin.Configuration.ShowLocalHunts ||
-			    _plugin.CurrentAreaMobHuntEntries.IsEmpty ||
-			    _plugin.CurrentAreaMobHuntEntries.Count(x =>
-				    _plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills) ==
-			    _plugin.CurrentAreaMobHuntEntries.Count)
+			if (!this._plugin.Configuration.ShowLocalHunts ||
+			    this._plugin.CurrentAreaMobHuntEntries.IsEmpty ||
+			    this._plugin.CurrentAreaMobHuntEntries.Count(x =>
+				    this._plugin.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills) ==
+			    this._plugin.CurrentAreaMobHuntEntries.Count)
 			{
 				return;
 			}
@@ -160,7 +160,7 @@ namespace HuntBuddy
 
 			var windowFlags = ImGuiWindowFlags.NoNavInputs | ImGuiWindowFlags.NoDocking;
 
-			if (_plugin.Configuration.HideLocalHuntBackground)
+			if (this._plugin.Configuration.HideLocalHuntBackground)
 			{
 				windowFlags |= ImGuiWindowFlags.NoBackground;
 			}
@@ -170,18 +170,18 @@ namespace HuntBuddy
 				return;
 			}
 
-			foreach (var mobHuntEntry in _plugin.CurrentAreaMobHuntEntries)
+			foreach (var mobHuntEntry in this._plugin.CurrentAreaMobHuntEntries)
 			{
-				var currentKills = _plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
+				var currentKills = this._plugin.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
 
-				if (_plugin.Configuration.HideCompletedHunts && currentKills == mobHuntEntry.NeededKills)
+				if (this._plugin.Configuration.HideCompletedHunts && currentKills == mobHuntEntry.NeededKills)
 				{
 					continue;
 				}
 
 				if (Location.Database.ContainsKey(mobHuntEntry.MobHuntId))
 				{
-					if (IconButton(FontAwesomeIcon.Search, $"##{mobHuntEntry.MobHuntId}"))
+					if (Interface.IconButton(FontAwesomeIcon.Search, $"##{mobHuntEntry.MobHuntId}"))
 					{
 						Location.OpenMapLink(mobHuntEntry.TerritoryType, mobHuntEntry.MapId,
 							mobHuntEntry.MobHuntId);
@@ -192,7 +192,7 @@ namespace HuntBuddy
 
 				ImGui.Text($"{mobHuntEntry.Name} ({currentKills}/{mobHuntEntry.NeededKills})");
 
-				if (!_plugin.Configuration.ShowLocalHuntIcons)
+				if (!this._plugin.Configuration.ShowLocalHuntIcons)
 				{
 					continue;
 				}
@@ -206,11 +206,11 @@ namespace HuntBuddy
 				if (mobHuntEntry.ExpansionId == 4 &&
 				    mobHuntEntry.MobHuntType == 1) // Endwalker uses circle for non elite mobs
 				{
-					drawList.AddCircleFilled(cursorPos + new Vector2(imageSize / 2f), imageSize / 2f, _plugin.Configuration.IconBackgroundColourU32);
+					drawList.AddCircleFilled(cursorPos + new Vector2(imageSize / 2f), imageSize / 2f, this._plugin.Configuration.IconBackgroundColourU32);
 				}
 				else
 				{
-					drawList.AddRectFilled(cursorPos, cursorPos + new Vector2(imageSize), _plugin.Configuration.IconBackgroundColourU32);
+					drawList.AddRectFilled(cursorPos, cursorPos + new Vector2(imageSize), this._plugin.Configuration.IconBackgroundColourU32);
 				}
 
 				drawList.AddImage(mobHuntEntry.Icon.ImGuiHandle, cursorPos,
@@ -224,29 +224,29 @@ namespace HuntBuddy
 		{
 			ImGui.SetNextWindowSize(Vector2.Zero, ImGuiCond.Always);
 
-			if (!ImGui.Begin($"{_plugin.Name} settings", ImGuiWindowFlags.NoDocking))
+			if (!ImGui.Begin($"{this._plugin.Name} settings", ImGuiWindowFlags.NoDocking))
 			{
 				return;
 			}
 
 			var save = false;
 
-			save |= ImGui.Checkbox("Show hunts in local area", ref _plugin.Configuration.ShowLocalHunts);
-			save |= ImGui.Checkbox("Show icons of hunts in local area", ref _plugin.Configuration.ShowLocalHuntIcons);
+			save |= ImGui.Checkbox("Show hunts in local area", ref this._plugin.Configuration.ShowLocalHunts);
+			save |= ImGui.Checkbox("Show icons of hunts in local area", ref this._plugin.Configuration.ShowLocalHuntIcons);
 			save |= ImGui.Checkbox("Hide background of local hunts window",
-				ref _plugin.Configuration.HideLocalHuntBackground);
+				ref this._plugin.Configuration.HideLocalHuntBackground);
 			save |= ImGui.Checkbox("Hide completed targets in local hunts window",
-				ref _plugin.Configuration.HideCompletedHunts);
-			if (ImGui.ColorEdit4("Hunt icon background colour", ref _plugin.Configuration.IconBackgroundColour))
+				ref this._plugin.Configuration.HideCompletedHunts);
+			if (ImGui.ColorEdit4("Hunt icon background colour", ref this._plugin.Configuration.IconBackgroundColour))
 			{
-				_plugin.Configuration.IconBackgroundColourU32 =
-					ImGui.ColorConvertFloat4ToU32(_plugin.Configuration.IconBackgroundColour);
+				this._plugin.Configuration.IconBackgroundColourU32 =
+					ImGui.ColorConvertFloat4ToU32(this._plugin.Configuration.IconBackgroundColour);
 				save = true;
 			}
 
 			if (save)
 			{
-				_plugin.Configuration.Save();
+				this._plugin.Configuration.Save();
 			}
 
 

+ 33 - 33
Plugin.cs

@@ -79,32 +79,32 @@ namespace HuntBuddy
 						"D1 48 8D 0D ?? ?? ?? ?? 48 83 C4 20 5F E9 ?? ?? ?? ??");
 			}
 
-			ClientState.TerritoryChanged += ClientStateOnTerritoryChanged;
-			PluginInterface.UiBuilder.Draw += DrawInterface;
-			PluginInterface.UiBuilder.Draw += _interface.DrawLocalHunts;
-			PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
+			Plugin.ClientState.TerritoryChanged += ClientStateOnTerritoryChanged;
+			Plugin.PluginInterface.UiBuilder.Draw += DrawInterface;
+			Plugin.PluginInterface.UiBuilder.Draw += _interface.DrawLocalHunts;
+			Plugin.PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
 		}
 
 		private void ClientStateOnTerritoryChanged(object? sender, ushort e)
 		{
-			CurrentAreaMobHuntEntries.Clear();
+			this.CurrentAreaMobHuntEntries.Clear();
 
-			foreach (var mobHuntEntry in MobHuntEntries.SelectMany(expansionEntry => expansionEntry.Value
-				         .Where(entry => entry.Key.Key == ClientState.TerritoryType)
+			foreach (var mobHuntEntry in this.MobHuntEntries.SelectMany(expansionEntry => expansionEntry.Value
+				         .Where(entry => entry.Key.Key == Plugin.ClientState.TerritoryType)
 				         .SelectMany(entry => entry.Value)))
 			{
-				CurrentAreaMobHuntEntries.Add(mobHuntEntry);
+				this.CurrentAreaMobHuntEntries.Add(mobHuntEntry);
 			}
 		}
 
 		private void OpenConfigUi()
 		{
-			_interface.DrawInterface = !_interface.DrawInterface;
+			this._interface.DrawInterface = !this._interface.DrawInterface;
 		}
 
 		private void DrawInterface()
 		{
-			_interface.DrawInterface = _interface.DrawInterface && _interface.Draw();
+			this._interface.DrawInterface = this._interface.DrawInterface && this._interface.Draw();
 		}
 
 		private void Dispose(bool disposing)
@@ -114,19 +114,19 @@ namespace HuntBuddy
 				return;
 			}
 
-			MobHuntEntriesReady = false;
-			PluginInterface.UiBuilder.Draw -= DrawInterface;
-			PluginInterface.UiBuilder.Draw -= _interface.DrawLocalHunts;
-			PluginInterface.UiBuilder.OpenConfigUi -= OpenConfigUi;
+			this.MobHuntEntriesReady = false;
+			Plugin.PluginInterface.UiBuilder.Draw -= this.DrawInterface;
+			Plugin.PluginInterface.UiBuilder.Draw -= this._interface.DrawLocalHunts;
+			Plugin.PluginInterface.UiBuilder.OpenConfigUi -= this.OpenConfigUi;
 
-			_commandManager.Dispose();
+			this._commandManager.Dispose();
 		}
 
 		[Command("/phb")]
 		[HelpMessage("Toggles UI")]
 		public void PluginCommand(string command, string args)
 		{
-			OpenConfigUi();
+			this.OpenConfigUi();
 		}
 
 		public unsafe void ReloadData()
@@ -158,7 +158,7 @@ namespace HuntBuddy
 
 				var inventoryItem = *inventoryItemPtr;
 
-				foreach (var row in DataManager.Excel.GetSheet<MobHuntOrderType>()!)
+				foreach (var row in Plugin.DataManager.Excel.GetSheet<MobHuntOrderType>()!)
 				{
 					if (inventoryItem.ItemID == row.EventItem.Row)
 					{
@@ -168,13 +168,13 @@ namespace HuntBuddy
 				}
 			}
 			
-			MobHuntEntries.Clear();
+			this.MobHuntEntries.Clear();
 			var mobHuntList = new List<MobHuntEntry>();
-			var mobHuntOrderSheet = DataManager.Excel.GetSheet<MobHuntOrder>()!;
+			var mobHuntOrderSheet = Plugin.DataManager.Excel.GetSheet<MobHuntOrder>()!;
 			
 			foreach (var (mobHuntType, billNumber) in huntBills)
 			{
-				var mobHuntOrderTypeRow = DataManager.Excel.GetSheet<MobHuntOrderType>()!.GetRow(billNumber)!;
+				var mobHuntOrderTypeRow = Plugin.DataManager.Excel.GetSheet<MobHuntOrderType>()!.GetRow(billNumber)!;
 					
 				var rowId = mobHuntOrderTypeRow.OrderStart.Value!.RowId +
 				            (uint)(this.MobHuntStruct->BillOffset[mobHuntOrderTypeRow.RowId] - 1);
@@ -205,7 +205,7 @@ namespace HuntBuddy
 							MobHuntType = mobHuntType,
 							CurrentKillsOffset = 5 * billNumber + mobHuntOrderRow.SubRowId,
 							NeededKills = mobHuntOrderRow.NeededKills,
-							Icon = LoadIcon(mobHuntOrderRow.Target.Value.Icon)
+							Icon = Plugin.LoadIcon(mobHuntOrderRow.Target.Value.Icon)
 						});
 					}
 					else
@@ -223,42 +223,42 @@ namespace HuntBuddy
 				var key = entry.ExpansionName ?? "Unknown";
 				var subKey = new KeyValuePair<uint, string>(entry.TerritoryType, entry.TerritoryName ?? "Unknown");
 					
-				if (!MobHuntEntries.ContainsKey(key))
+				if (!this.MobHuntEntries.ContainsKey(key))
 				{
-					MobHuntEntries[key] = new Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>();
+					this.MobHuntEntries[key] = new Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>();
 				}
 
-				if (!MobHuntEntries[key].ContainsKey(subKey))
+				if (!this.MobHuntEntries[key].ContainsKey(subKey))
 				{
-					MobHuntEntries[key][subKey] = new List<MobHuntEntry>();
+					this.MobHuntEntries[key][subKey] = new List<MobHuntEntry>();
 				}
 					
-				MobHuntEntries[key][subKey].Add(entry);
+				this.MobHuntEntries[key][subKey].Add(entry);
 			}
 
-			ClientStateOnTerritoryChanged(null, 0);
+			this.ClientStateOnTerritoryChanged(null, 0);
 
-			MobHuntEntriesReady = true;
-			_interface.DrawInterface = true;
+			this.MobHuntEntriesReady = true;
+			this._interface.DrawInterface = true;
 		}
 		
 		private static TexFile? GetHdIcon(uint id)
 		{
 			var path = $"ui/icon/{id / 1000 * 1000:000000}/{id:000000}_hr1.tex";
-			return DataManager.GetFile<TexFile>(path);
+			return Plugin.DataManager.GetFile<TexFile>(path);
 		}
 
 		private static TextureWrap LoadIcon(uint id)
 		{
-			var icon     = GetHdIcon(id) ?? DataManager.GetIcon(id)!;
+			var icon     = Plugin.GetHdIcon(id) ?? Plugin.DataManager.GetIcon(id)!;
 			var iconData = icon.GetRgbaImageData();
 
-			return PluginInterface.UiBuilder.LoadImageRaw(iconData, icon.Header.Width, icon.Header.Height, 4);
+			return Plugin.PluginInterface.UiBuilder.LoadImageRaw(iconData, icon.Header.Width, icon.Header.Height, 4);
 		}
 
 		public void Dispose()
 		{
-			Dispose(true);
+			this.Dispose(true);
 			GC.SuppressFinalize(this);
 		}
 	}