Skip to content

Commit

Permalink
Improved GUI for the overlay settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
josdemmers committed Jun 29, 2024
1 parent da6f540 commit 98ca02f
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 93 deletions.
2 changes: 1 addition & 1 deletion D4Companion.Constants/ScreenCaptureConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class ScreenCaptureConstants
{
public const int Delay = 50;
public const int DefaultDelay = 50;
public const int DelayError = 10000;
public const int DelayErrorShort = 1000;
public const int DelayMouse = 100;
Expand Down
3 changes: 3 additions & 0 deletions D4Companion.Entities/SettingsD4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public class SettingsD4
public Color DefaultColorAspects { get; set; } = Colors.Green;
public bool DevMode { get; set; } = false;
public bool DungeonTiers { get; set; } = true;
public bool IsAspectDetectionEnabled { get; set; } = true;
public bool IsItemPowerLimitEnabled { get; set; } = false;
public int ItemPowerLimit { get; set; } = 925;
public bool IsDebugInfoEnabled { get; set; } = false;
public bool IsTemperedAffixDetectionEnabled { get; set; } = true;
public bool IsTopMost { get; set; } = false;
public int MinimalOcrMatchType { get; set; } = 80;
public int OverlayFontSize { get; set; } = 18;
public int OverlayIconPosX { get; set; } = 0;
public int OverlayIconPosY { get; set; } = 0;
public int ScreenCaptureDelay { get; set; } = 50;
public string SelectedAffixLanguage { get; set; } = "enUS";
public string SelectedAppLanguage { get; set; } = "en-US";
public string SelectedAffixPreset { get; set; } = string.Empty;
Expand Down
72 changes: 72 additions & 0 deletions D4Companion.Localization/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions D4Companion.Localization/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -604,4 +604,28 @@
<data name="rsCapNormal" xml:space="preserve">
<value>Normal</value>
</data>
<data name="rsCapGeneral" xml:space="preserve">
<value>General</value>
</data>
<data name="rsCapFeatures" xml:space="preserve">
<value>Features</value>
</data>
<data name="rsCapScreenCaptureDelay" xml:space="preserve">
<value>Screencapture Delay</value>
</data>
<data name="rsTooltipScreenCaptureDelay" xml:space="preserve">
<value>Time in ms between screencaptures. Default 50ms.</value>
</data>
<data name="rsCapTemperedAffixDetection" xml:space="preserve">
<value>Tempered Affix Detection</value>
</data>
<data name="rsTooltipTemperedAffixDetection" xml:space="preserve">
<value>Toggle detection of tempered affixes.</value>
</data>
<data name="rsCapAspectDetection" xml:space="preserve">
<value>Aspect Detection</value>
</data>
<data name="rsTooltipAspectDetection" xml:space="preserve">
<value>Toggle detection of aspects.</value>
</data>
</root>
4 changes: 2 additions & 2 deletions D4Companion.Services/ScreenCaptureHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ScreenCaptureHandler : IScreenCaptureHandler

private Bitmap? _currentScreen = null;
private double _delayUpdateMouse = ScreenCaptureConstants.DelayMouse;
private double _delayUpdateScreen = ScreenCaptureConstants.Delay;
private double _delayUpdateScreen = ScreenCaptureConstants.DefaultDelay;
private bool _isEnabled = false;
private bool _isSaveScreenshotRequested = false;
private ScreenCapture _screenCapture = new ScreenCapture();
Expand Down Expand Up @@ -219,7 +219,7 @@ private void UpdateScreen()
});
}

_delayUpdateScreen = ScreenCaptureConstants.Delay;
_delayUpdateScreen = _settingsManager.Settings.ScreenCaptureDelay;
}
else
{
Expand Down
12 changes: 10 additions & 2 deletions D4Companion.Services/ScreenProcessHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,10 @@ private void ProcessScreen(Bitmap currentScreen)
},
() =>
{
// Only search for aspects when the item tooltip contains one.
if (!_currentTooltip.ItemAspectLocation.IsEmpty && !_currentTooltip.IsUniqueItem)
// Aspect detection should be enabled,
// and only search for aspects when the item tooltip contains one.
if (_settingsManager.Settings.IsAspectDetectionEnabled &&
!_currentTooltip.ItemAspectLocation.IsEmpty && !_currentTooltip.IsUniqueItem)
{
FindItemAspects();
}
Expand Down Expand Up @@ -815,6 +817,12 @@ private bool FindItemAffixes()

bool IsDebugInfoEnabled = _settingsManager.Settings.IsDebugInfoEnabled;

// Delete tempered affixes areas when disabled
if (!_settingsManager.Settings.IsTemperedAffixDetectionEnabled)
{
_currentTooltip.ItemAffixAreas.RemoveAll(a => a.AffixType.Equals(Constants.AffixTypeConstants.Tempered));
}

// Create image for each area
var currentScreenTooltip = _currentScreenTooltipFilter.Convert<Bgr, byte>();
var areaImages = new List<Image<Gray, byte>>();
Expand Down
36 changes: 36 additions & 0 deletions D4Companion/ViewModels/Dialogs/OverlayConfigViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ public OverlayConfigViewModel(Action<OverlayConfigViewModel> closeHandler)
public ObservableCollection<string> OverlayMarkerModes { get => _overlayMarkerModes; set => _overlayMarkerModes = value; }
public ObservableCollection<string> SigilDisplayModes { get => _sigilDisplayModes; set => _sigilDisplayModes = value; }

public bool IsAspectDetectionEnabled
{
get => _settingsManager.Settings.IsAspectDetectionEnabled;
set
{
_settingsManager.Settings.IsAspectDetectionEnabled = value;
RaisePropertyChanged(nameof(IsAspectDetectionEnabled));

_settingsManager.SaveSettings();
}
}

public bool IsDungeonTiersEnabled
{
get => _settingsManager.Settings.DungeonTiers;
Expand All @@ -86,6 +98,18 @@ public bool IsItemPowerLimitEnabled
}
}

public bool IsTemperedAffixDetectionEnabled
{
get => _settingsManager.Settings.IsTemperedAffixDetectionEnabled;
set
{
_settingsManager.Settings.IsTemperedAffixDetectionEnabled = value;
RaisePropertyChanged(nameof(IsTemperedAffixDetectionEnabled));

_settingsManager.SaveSettings();
}
}

public int ItemPowerLimit
{
get => _settingsManager.Settings.ItemPowerLimit;
Expand Down Expand Up @@ -134,6 +158,18 @@ public int OverlayIconPosY
}
}

public int ScreenCaptureDelay
{
get => _settingsManager.Settings.ScreenCaptureDelay;
set
{
_settingsManager.Settings.ScreenCaptureDelay = value;
RaisePropertyChanged(nameof(ScreenCaptureDelay));

_settingsManager.SaveSettings();
}
}

public string SelectedOverlayMarkerMode
{
get => _settingsManager.Settings.SelectedOverlayMarkerMode;
Expand Down
Loading

0 comments on commit 98ca02f

Please sign in to comment.