Skip to content

Commit 0fc7234

Browse files
committed
Added options window with some tracker settings
1 parent 4db6322 commit 0fc7234

File tree

12 files changed

+174
-31
lines changed

12 files changed

+174
-31
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Controls;
4+
using System.Windows.Data;
5+
6+
namespace D2RSO.Classes
7+
{
8+
public class BoolToOrientationConverter: IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
return (bool)value ? Orientation.Vertical : Orientation.Horizontal;
13+
}
14+
15+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
16+
{
17+
return Binding.DoNothing;
18+
}
19+
}
20+
}

D2RSO/Classes/SettingsClass.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ public class SettingsClass: INotifyPropertyChanged
1212
private string _filePath;
1313
private double _formScaleX;
1414
private double _formScaleY;
15+
private bool _isTrackerInsertToLeft;
16+
private bool _isTrackerVertical;
17+
private bool _showDigitsInTracker;
18+
private int _redTrackerOverlaySec;
19+
20+
public bool ShowDigitsInTracker
21+
{
22+
get => _showDigitsInTracker;
23+
set { _showDigitsInTracker = value; OnPropertyChanged(); }
24+
}
25+
26+
public bool IsTrackerVertical
27+
{
28+
get => _isTrackerVertical;
29+
set { _isTrackerVertical = value; OnPropertyChanged(); }
30+
}
1531

1632
/// <summary>
1733
/// Skills data collection
@@ -45,6 +61,21 @@ public double FormScaleY
4561
set { _formScaleY = value; OnPropertyChanged(); }
4662
}
4763

64+
public bool IsTrackerInsertToLeft
65+
{
66+
get => _isTrackerInsertToLeft;
67+
set { _isTrackerInsertToLeft = value; OnPropertyChanged(); }
68+
}
69+
70+
[JsonIgnore]
71+
public bool IsRedTrackerOverlayEnabled => _redTrackerOverlaySec > 0;
72+
73+
public int RedTrackerOverlaySec
74+
{
75+
get => _redTrackerOverlaySec;
76+
set { _redTrackerOverlaySec = value; OnPropertyChanged(); OnPropertyChanged(nameof(IsRedTrackerOverlayEnabled)); }
77+
}
78+
4879
/// <summary>
4980
/// Save settings to a file
5081
/// </summary>

D2RSO/Classes/StaticCommands.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace D2RSO.Classes
44
{
5-
/* internal static class StaticCommands
5+
internal static class StaticCommands
66
{
7-
public static ICommand AddTrackerItemCommand { get; } =
8-
new RoutedUICommand(nameof(AddTrackerItemCommand), nameof(AddTrackerItemCommand), typeof(StaticCommands));
9-
public static ICommand RemTrackerItemCommand { get; } =
10-
new RoutedUICommand(nameof(RemTrackerItemCommand), nameof(AddTrackerItemCommand), typeof(StaticCommands));
11-
}*/
7+
public static ICommand CloseOptionsCommand { get; } =
8+
new RoutedUICommand(nameof(CloseOptionsCommand), nameof(CloseOptionsCommand), typeof(StaticCommands));
9+
}
1210
}

D2RSO/Controls/OptionsDialog.xaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<UserControl x:Class="D2RSO.Controls.OptionsDialog"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:d2Rso="clr-namespace:D2RSO"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800">
9+
<Grid>
10+
<Grid.RowDefinitions>
11+
<RowDefinition Height="Auto"/>
12+
<RowDefinition Height="*"/>
13+
<RowDefinition Height="Auto"/>
14+
</Grid.RowDefinitions>
15+
16+
<Label Margin="10" HorizontalAlignment="Center" Content="Options" FontSize="20"/>
17+
18+
<Grid Grid.Row="1">
19+
<Grid.RowDefinitions>
20+
<RowDefinition Height="Auto"/>
21+
<RowDefinition Height="Auto"/>
22+
<RowDefinition Height="Auto"/>
23+
<RowDefinition Height="Auto"/>
24+
</Grid.RowDefinitions>
25+
<CheckBox Content="Insert tracker icons on the left" IsChecked="{Binding Source={x:Static d2Rso:App.Settings}, Path=IsTrackerInsertToLeft}" Grid.Row="0" Margin="5" ToolTip="Insert new icons from the left edge instead of adding to the right"/>
26+
<CheckBox Content="Vertical tracker" IsChecked="{Binding Source={x:Static d2Rso:App.Settings}, Path=IsTrackerVertical}" Grid.Row="1" Margin="5" ToolTip="Position icons vertically instead of horizontally"/>
27+
<CheckBox Content="Show digits in tracker" IsChecked="{Binding Source={x:Static d2Rso:App.Settings}, Path=ShowDigitsInTracker}" Grid.Row="2" Margin="5" ToolTip="Show or hide timer digits beside the icon"/>
28+
29+
<StackPanel Orientation="Horizontal" Grid.Row="3">
30+
<Label Content="Enable reddish icon (sec)" VerticalAlignment="Center" ToolTip="Icon becomes red when specified number of seconds left on the timer"/>
31+
<TextBox Text="{Binding Source={x:Static d2Rso:App.Settings}, Path=RedTrackerOverlaySec, Mode=TwoWay}" Width="50" Margin="5"/>
32+
</StackPanel>
33+
</Grid>
34+
35+
<Button Grid.Row="2" HorizontalAlignment="Center" Margin="5" Content="Close" Width="80" x:Name="CloseButton"/>
36+
</Grid>
37+
</UserControl>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
using MahApps.Metro.Controls;
4+
using MahApps.Metro.Controls.Dialogs;
5+
6+
namespace D2RSO.Controls
7+
{
8+
/// <summary>
9+
/// Interaction logic for OptionsDialog.xaml
10+
/// </summary>
11+
public partial class OptionsDialog : UserControl
12+
{
13+
public OptionsDialog()
14+
{
15+
InitializeComponent();
16+
}
17+
}
18+
}

D2RSO/CountersWindow.xaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
<Border Name="Border" Style="{StaticResource BorderConditionalStyle}"
3737
LayoutTransform="{StaticResource windowScaleTransform}">
38-
3938
<Grid>
4039
<Grid.RowDefinitions>
4140
<RowDefinition Height="Auto"/>
@@ -63,35 +62,34 @@
6362
</StackPanel>
6463
<!-- -->
6564

66-
<ListBox Margin="3" Grid.Row="1" ItemsSource="{Binding SkillTrackerItems, UpdateSourceTrigger=PropertyChanged}" Opacity=".8"
65+
<ItemsControl Margin="3" Grid.Row="1" ItemsSource="{Binding SkillTrackerItems, UpdateSourceTrigger=PropertyChanged}" Opacity=".8"
6766
Visibility="{Binding IsNotPreview, Converter={StaticResource BooleanToVisibilityConverter}}"
68-
Background="Transparent" BorderBrush="Transparent">
69-
<ListBox.ItemsPanel>
67+
Background="Transparent" BorderBrush="Transparent">
68+
<ItemsControl.ItemsPanel>
7069
<ItemsPanelTemplate>
71-
<StackPanel Orientation="Horizontal" Background="Transparent"/>
70+
<StackPanel Orientation="{Binding Source={x:Static local:App.Settings}, Path=IsTrackerVertical, Converter={StaticResource BoolToOrientationConverter}}" Background="Transparent"/>
7271
</ItemsPanelTemplate>
73-
</ListBox.ItemsPanel>
74-
<ListBox.ItemContainerStyle>
75-
<Style TargetType="{x:Type ListBoxItem}">
76-
<Setter Property="Background" Value="Transparent"></Setter>
77-
</Style>
78-
</ListBox.ItemContainerStyle>
79-
<ListBox.ItemTemplate>
72+
</ItemsControl.ItemsPanel>
73+
<ItemsControl.ItemTemplate>
8074
<DataTemplate DataType="{x:Type local:TrackerItem}">
8175
<Grid>
8276
<StackPanel Orientation="Vertical">
83-
<Image Margin="5,0" Width="50" Height="50" Stretch="Uniform" Source="{Binding Data.IconFileName, Converter={StaticResource IconToImageConverter}}"
84-
VerticalAlignment="Center" HorizontalAlignment="Center" IsHitTestVisible="False"/>
77+
<Grid>
78+
<Image Margin="5,0" Width="50" Height="50" Stretch="Uniform" Source="{Binding Data.IconFileName, Converter={StaticResource IconToImageConverter}}"
79+
VerticalAlignment="Center" HorizontalAlignment="Center" IsHitTestVisible="False"/>
80+
<Border Background="Red" Opacity=".5" Visibility="{Binding IsRedOverlayVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="5"/>
81+
</Grid>
8582
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
8683
<Border Background="{StaticResource MahApps.Brushes.Window.Background}" Opacity=".4"/>
8784
<Label Content="{Binding CurrentTimeValue, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" Padding="0"
88-
FontSize="18" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
85+
FontSize="18" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"
86+
Visibility="{Binding Source={x:Static local:App.Settings}, Path=ShowDigitsInTracker, Converter={StaticResource BooleanToVisibilityConverter}}"/>
8987
</Grid>
9088
</StackPanel>
9189
</Grid>
9290
</DataTemplate>
93-
</ListBox.ItemTemplate>
94-
</ListBox>
91+
</ItemsControl.ItemTemplate>
92+
</ItemsControl>
9593
</Grid>
9694
</Border>
9795
</Window>

D2RSO/CountersWindow.xaml.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public void AddTrackerItem(SkillDataItem item)
8585
//create new tracker
8686
var tr = new TrackerItem(item);
8787
tr.OnCompleted += RemTrackerItem;
88-
SkillTrackerItems.Add(tr);
88+
if(App.Settings.IsTrackerInsertToLeft)
89+
SkillTrackerItems.Insert(0, tr);
90+
else SkillTrackerItems.Add(tr);
8991
}
9092

9193
public void SetPreview(bool isPreview)
@@ -108,6 +110,14 @@ public class TrackerItem: INotifyPropertyChanged
108110
{
109111
private double _currentTimeValue;
110112
private readonly Timer _timer;
113+
private bool _isRedOverlayVisible;
114+
115+
public bool IsRedOverlayVisible
116+
{
117+
get => _isRedOverlayVisible;
118+
set { _isRedOverlayVisible = value; OnPropertyChanged(); }
119+
}
120+
111121
public SkillDataItem Data { get; set; }
112122

113123
public event Action<int> OnCompleted;
@@ -125,6 +135,9 @@ public TrackerItem(SkillDataItem data)
125135
_timer = new Timer(1000) { AutoReset = true };
126136
_timer.Elapsed += (_, _) =>
127137
{
138+
if(App.Settings.IsRedTrackerOverlayEnabled)
139+
IsRedOverlayVisible = (CurrentTimeValue-1) <= App.Settings.RedTrackerOverlaySec;
140+
128141
if (_currentTimeValue == 0)
129142
{
130143
Stop();

D2RSO/D2RSO.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@
118118
</None>
119119
</ItemGroup>
120120

121-
<ItemGroup>
122-
<Folder Include="Controls\" />
123-
</ItemGroup>
124-
125121
<ItemGroup>
126122
<Resource Include="Images\Logo.ico" />
127123
</ItemGroup>

D2RSO/MainWindow.xaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
<MenuItem Header="Exit" Click="ExitMenuItem_OnClick"/>
2626
</ContextMenu.Items>
2727
</ContextMenu>
28+
29+
<mah:CustomDialog x:Key="CustomDialogTest"
30+
Title="Options"
31+
x:Name="CustomTestDialog">
32+
33+
</mah:CustomDialog>
2834
</Window.Resources>
2935

3036
<Grid>
@@ -96,6 +102,13 @@
96102
</StackPanel>
97103

98104
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
105+
<Button Margin="5" Height="35" Width="35" Background="{StaticResource MahApps.Brushes.Window.Background}"
106+
Padding="3" Click="OptionsButtonBase_OnClick" IsEnabled="{Binding IsNotPlaying, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
107+
ToolTip="Exit the app">
108+
<Path Data="M17.25,12C17.25,12.23 17.23,12.46 17.2,12.68L18.68,13.84C18.81,13.95 18.85,14.13 18.76,14.29L17.36,16.71C17.27,16.86 17.09,16.92 16.93,16.86L15.19,16.16C14.83,16.44 14.43,16.67 14,16.85L13.75,18.7C13.72,18.87 13.57,19 13.4,19H10.6C10.43,19 10.28,18.87 10.25,18.7L10,16.85C9.56,16.67 9.17,16.44 8.81,16.16L7.07,16.86C6.91,16.92 6.73,16.86 6.64,16.71L5.24,14.29C5.15,14.13 5.19,13.95 5.32,13.84L6.8,12.68C6.77,12.46 6.75,12.23 6.75,12C6.75,11.77 6.77,11.54 6.8,11.32L5.32,10.16C5.19,10.05 5.15,9.86 5.24,9.71L6.64,7.29C6.73,7.13 6.91,7.07 7.07,7.13L8.81,7.84C9.17,7.56 9.56,7.32 10,7.15L10.25,5.29C10.28,5.13 10.43,5 10.6,5H13.4C13.57,5 13.72,5.13 13.75,5.29L14,7.15C14.43,7.32 14.83,7.56 15.19,7.84L16.93,7.13C17.09,7.07 17.27,7.13 17.36,7.29L18.76,9.71C18.85,9.86 18.81,10.05 18.68,10.16L17.2,11.32C17.23,11.54 17.25,11.77 17.25,12M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M12,10C10.89,10 10,10.89 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12C14,10.89 13.1,10 12,10Z" Fill="{StaticResource MahApps.Brushes.IdealForeground}"
109+
Stretch="Uniform"/>
110+
</Button>
111+
99112
<Button Margin="5" Height="35" Width="35" Background="{StaticResource MahApps.Brushes.Window.Background}"
100113
Padding="3" Click="ExitButtonBase_OnClick" IsEnabled="{Binding IsNotPlaying, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
101114
ToolTip="Exit the app">

D2RSO/MainWindow.xaml.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows.Input;
1010
using D2RSO.Classes;
1111
using D2RSO.Classes.Data;
12+
using D2RSO.Controls;
1213
using MahApps.Metro.Controls.Dialogs;
1314
using Microsoft.Xaml.Behaviors.Core;
1415
using Button = System.Windows.Controls.Button;
@@ -51,7 +52,7 @@ public MainWindow()
5152
InitializeComponent();
5253
DataContext = this;
5354

54-
Title = $"D2R Skill Overlay V1.0.0";
55+
Title = $"D2R Skill Overlay V1.0.1";
5556

5657
IsMaxRestoreButtonEnabled = false;
5758
IsMinButtonEnabled = true;
@@ -232,5 +233,17 @@ private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
232233
var pi = new ProcessStartInfo("https://github.com/panthernet") { UseShellExecute = true };
233234
Process.Start(pi);
234235
}
236+
237+
private async void OptionsButtonBase_OnClick(object sender, RoutedEventArgs e)
238+
{
239+
var dlg = new OptionsDialog();
240+
var dialog = new CustomDialog(this)
241+
{
242+
Content = dlg
243+
};
244+
dlg.CloseButton.Click += async (o, args) => await this.HideMetroDialogAsync(dialog);
245+
246+
await this.ShowMetroDialogAsync(dialog);
247+
}
235248
}
236249
}

0 commit comments

Comments
 (0)