Skip to content

Commit

Permalink
- Added support for duplicate/implicit affixes.
Browse files Browse the repository at this point in the history
- Added setting to adjust tooltip width for different resolutions.
- Added logging view.
- Only allow one tooltip at a time.
- Merged normal and lite mode in one image set.
- Fixed issues with affix filter by removing all underscores '_' from affix image names.
  • Loading branch information
josdemmers committed Jul 7, 2023
1 parent 4c6b073 commit 85e998f
Show file tree
Hide file tree
Showing 247 changed files with 1,007 additions and 871 deletions.
5 changes: 4 additions & 1 deletion D4Companion.Entities/SettingsD4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ namespace D4Companion.Entities
public class SettingsD4
{
public bool DebugMode { get; set; } = false;
public bool DevMode { get; set; } = false;
public bool LiteMode { get; set; } = true;
public string SelectedAffixName { get; set; } = string.Empty;
public string SelectedSystemPreset { get; set; } = "2560x1440";
public string SelectedSystemPreset { get; set; } = "2560x1440_SMF";
public int ThresholdMin { get; set; } = 60;
public int ThresholdMax { get; set; } = 255;
public int TooltipWidth { get; set; } = 500;
}
}
27 changes: 27 additions & 0 deletions D4Companion.Events/LoggingEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D4Companion.Events
{
public class ErrorOccurredEvent : PubSubEvent<ErrorOccurredEventParams>
{
}

public class ErrorOccurredEventParams
{
public string Message { get; set; } = string.Empty;
}

public class ExceptionOccurredEvent : PubSubEvent<ExceptionOccurredEventParams>
{
}

public class ExceptionOccurredEventParams
{
public string Message { get; set; } = string.Empty;
}
}
2 changes: 1 addition & 1 deletion D4Companion.Events/ScreenProcessEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ public class TooltipDataReadyEvent : PubSubEvent<TooltipDataReadyEventParams>

public class TooltipDataReadyEventParams
{
public List<ItemTooltipDescriptor> Tooltips { get; set; } = new List<ItemTooltipDescriptor>();
public ItemTooltipDescriptor Tooltip { get; set; } = new ItemTooltipDescriptor();
}
}
1 change: 1 addition & 0 deletions D4Companion.Interfaces/IAffixPresetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface IAffixPresetManager
List<ItemAffix> ItemAffixes { get; }
List<ItemAspect> ItemAspects { get; }
List<ItemType> ItemTypes { get; }
List<ItemType> ItemTypesLite { get; }

void AddAffixPreset(AffixPreset affixPreset);
void RemoveAffixPreset(AffixPreset affixPreset);
Expand Down
55 changes: 45 additions & 10 deletions D4Companion.Services/AffixPresetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
using D4Companion.Entities;
using D4Companion.Events;
using D4Companion.Interfaces;
using Emgu.CV.Structure;
using Emgu.CV;
using Microsoft.Extensions.Logging;
using Prism.Events;
using System.IO;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Windows.Media;

namespace D4Companion.Services
{
Expand All @@ -19,6 +23,7 @@ public class AffixPresetManager : IAffixPresetManager
private List<ItemAspect> _itemAspects = new List<ItemAspect>();
private List<AffixPreset> _affixPresets = new List<AffixPreset>();
private List<ItemType> _itemTypes = new List<ItemType>();
private List<ItemType> _itemTypesLite = new List<ItemType>();

// Start of Constructors region

Expand Down Expand Up @@ -47,6 +52,7 @@ public AffixPresetManager(IEventAggregator eventAggregator, ILogger<AffixPresetM

// Load item types
LoadItemTypes();
LoadItemTypesLite();
}

#endregion
Expand All @@ -65,6 +71,7 @@ public AffixPresetManager(IEventAggregator eventAggregator, ILogger<AffixPresetM
public List<ItemAffix> ItemAffixes { get => _itemAffixes; set => _itemAffixes = value; }
public List<ItemAspect> ItemAspects { get => _itemAspects; set => _itemAspects = value; }
public List<ItemType> ItemTypes { get => _itemTypes; }
public List<ItemType> ItemTypesLite { get => _itemTypesLite; }

#endregion

Expand All @@ -78,6 +85,7 @@ private void HandleSystemPresetChangedEvent()
LoadItemAffixes();
LoadItemAspects();
LoadItemTypes();
LoadItemTypesLite();
}

#endregion
Expand Down Expand Up @@ -193,23 +201,50 @@ private void LoadItemTypes()

string systemPreset = _settingsManager.Settings.SelectedSystemPreset;

// Process the list of files found in the directory.
string[] fileEntries = Directory.GetFiles($"{Environment.CurrentDirectory}/Images/{systemPreset}/Types/");
foreach (string filePath in fileEntries)
var directory = $"Images\\{systemPreset}\\Types\\";
if (Directory.Exists(directory))
{
string fileName = Path.GetFileName(filePath);
string typeName = fileName.Split('_')[0];
var fileEntries = Directory.GetFiles(directory).Where(itemtype => !itemtype.ToLower().Contains("weapon_all"));
foreach (string filePath in fileEntries)
{
string fileName = Path.GetFileName(filePath);
string typeName = fileName.Split('_')[0];

_itemTypes.Add(new ItemType
{
FileName = fileName,
Name = typeName
});
}
}
}

_itemTypes.Add(new ItemType
private void LoadItemTypesLite()
{
_itemTypesLite.Clear();

string systemPreset = _settingsManager.Settings.SelectedSystemPreset;

var directory = $"Images\\{systemPreset}\\Types\\";
if (Directory.Exists(directory))
{
var fileEntries = Directory.GetFiles(directory).Where(itemtype => itemtype.ToLower().Contains("weapon_all") ||
(!itemtype.ToLower().Contains("weapon_") && !itemtype.ToLower().Contains("ranged_") && !itemtype.ToLower().Contains("offhand_focus")));
foreach (string filePath in fileEntries)
{
FileName = fileName,
Name = typeName
});
string fileName = Path.GetFileName(filePath);
string typeName = fileName.Split('_')[0];

_itemTypesLite.Add(new ItemType
{
FileName = fileName,
Name = typeName
});
}
}
}

#endregion


}
}
Loading

0 comments on commit 85e998f

Please sign in to comment.