Skip to content

Commit f0bb55c

Browse files
committed
Merge branch 'VEX-103_v1.87' into main
2 parents c1ae5e8 + 833fd86 commit f0bb55c

16 files changed

+311
-31
lines changed

VexTrack/App.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
<DataTemplate DataType="{x:Type popupViewModel:DeleteGoalGroupConfirmationPopupViewModel}">
125125
<popupView:DeleteGoalGroupConfirmationPopup/>
126126
</DataTemplate>
127+
128+
<DataTemplate DataType="{x:Type popupViewModel:SeasonEndConfirmationPopupViewModel}">
129+
<popupView:SeasonEndConfirmationPopup/>
130+
</DataTemplate>
127131
</ResourceDictionary>
128132
</Application.Resources>
129133
</Application>

VexTrack/Core/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace VexTrack.Core
66
static class Constants
77
{
88
public static readonly string AppName = "VexTrack";
9-
public static readonly string Version = "v1.86";
9+
public static readonly string Version = "v1.87";
1010

1111
public static readonly string DataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"/VexTrack - Preview";
1212
public static readonly string LegacyDataFolder = @"dat";

VexTrack/Core/TrackingData.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,19 @@ public static Season CurrentSeasonData
141141
DateTimeOffset today = DateTimeOffset.Now.ToLocalTime().Date;
142142

143143
int remainingDays = (endDate - today).Days;
144+
if ((endDate - today).Hours > 12) { remainingDays += 1; }
144145
if (remainingDays < 0) remainingDays = 0;
145146

146147
return remainingDays;
147148
}
148149

149150
public static int GetDuration(string sUUID)
150151
{
151-
DateTimeOffset endDate = DateTimeOffset.Parse(Data.Seasons.Find(s => s.UUID == sUUID).EndDate).ToLocalTime();
152+
DateTimeOffset endDate = DateTimeOffset.Parse(Data.Seasons.Find(s => s.UUID == sUUID).EndDate).ToLocalTime().Date;
152153
DateTimeOffset startDate = DateTimeOffset.FromUnixTimeSeconds(Data.Seasons.Find(s => s.UUID == sUUID).History.First().Time).ToLocalTime().Date;
153154

154155
int duration = (endDate - startDate).Days;
156+
if ((endDate - startDate).Hours > 12) { duration += 1; }
155157
if (duration < 0) duration = 0;
156158

157159
return duration;
@@ -749,6 +751,13 @@ public static void EditSeason(string uuid, Season data)
749751
CallUpdate();
750752
}
751753

754+
public static void EndSeason(string uuid)
755+
{
756+
// Set end date to today
757+
Data.Seasons[Data.Seasons.FindIndex(s => s.UUID == uuid)].EndDate = DateTime.Today.ToLocalTime().Date.ToString("d");
758+
CallUpdate();
759+
}
760+
752761

753762
public static void CreateSeasonInitPopup()
754763
{

VexTrack/MVVM/View/Popups/AboutPopup.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
</Hyperlink>
8080
</TextBlock>
8181

82-
<TextBlock Text="Created by BitTim, Copyright ©2021"
82+
<TextBlock Text="Created by BitTim, Copyright ©2021 - 2022"
8383
Grid.Row="3"
8484
FontSize="14"
8585
TextWrapping="Wrap"
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<UserControl x:Class="VexTrack.MVVM.View.Popups.SeasonEndConfirmationPopup"
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:local="clr-namespace:VexTrack.MVVM.View.Popups"
7+
mc:Ignorable="d"
8+
d:DesignHeight="812" d:DesignWidth="872">
9+
10+
<Grid Height="Auto"
11+
Width="640"
12+
VerticalAlignment="Center">
13+
<Grid.RowDefinitions>
14+
<RowDefinition Height="Auto"/>
15+
</Grid.RowDefinitions>
16+
17+
<Border Background="{DynamicResource Background}"
18+
CornerRadius="8">
19+
<Grid Margin="16">
20+
<Grid.RowDefinitions>
21+
<RowDefinition Height="*"/>
22+
<RowDefinition Height="Auto"/>
23+
</Grid.RowDefinitions>
24+
25+
<Grid.ColumnDefinitions>
26+
<ColumnDefinition Width="*"/>
27+
<ColumnDefinition Width="Auto"/>
28+
</Grid.ColumnDefinitions>
29+
30+
<Grid Grid.Row="0"
31+
Grid.Column="0"
32+
Margin="0, 4, 0, 0">
33+
34+
<Grid.RowDefinitions>
35+
<RowDefinition Height="Auto"/>
36+
<RowDefinition Height="Auto"/>
37+
<RowDefinition Height="Auto"/>
38+
<RowDefinition Height="Auto"/>
39+
</Grid.RowDefinitions>
40+
41+
<TextBlock Text="End Season"
42+
Grid.Column="0"
43+
Grid.Row="0"
44+
Grid.ColumnSpan="2"
45+
FontSize="20"
46+
FontWeight="Bold"
47+
Foreground="{DynamicResource Foreground}"
48+
Margin="0, 0, 0, 16"/>
49+
50+
<TextBlock Grid.Row="1"
51+
Grid.Column="0"
52+
FontSize="14"
53+
TextWrapping="Wrap"
54+
Foreground="{DynamicResource Foreground}"
55+
Margin="0, 0, 0, 4">
56+
This operation will end the current season and start a new one. History entries cannot be added to an ended season.
57+
</TextBlock>
58+
59+
<TextBlock Grid.Row="2"
60+
Grid.Column="0"
61+
FontSize="14"
62+
TextWrapping="Wrap"
63+
Foreground="{DynamicResource Foreground}"
64+
Margin="0, 0, 0, 4">
65+
This operation cannot be reverted. Are you sure you want to continue?
66+
</TextBlock>
67+
68+
<Grid Grid.Row="3"
69+
Grid.Column="0"
70+
Margin="0, 16, 0, 0">
71+
<Grid.RowDefinitions>
72+
<RowDefinition Height="Auto"/>
73+
<RowDefinition Height="Auto"/>
74+
<RowDefinition Height="Auto"/>
75+
</Grid.RowDefinitions>
76+
77+
<Grid.ColumnDefinitions>
78+
<ColumnDefinition Width="*"/>
79+
<ColumnDefinition Width="*"/>
80+
</Grid.ColumnDefinitions>
81+
82+
<TextBlock Grid.Row="0"
83+
Grid.Column="0"
84+
Grid.ColumnSpan="2"
85+
FontSize="14"
86+
TextWrapping="Wrap"
87+
Foreground="{DynamicResource Foreground}"
88+
Margin="0, 0, 0, 4">
89+
<Bold>Current Season:</Bold>
90+
</TextBlock>
91+
92+
<TextBlock Grid.Row="1"
93+
Grid.Column="0"
94+
FontSize="14"
95+
TextWrapping="Wrap"
96+
FontWeight="Bold"
97+
Text="Name"
98+
Foreground="{DynamicResource Foreground}"
99+
Margin="0, 0, 0, 4"/>
100+
101+
<TextBlock Grid.Row="2"
102+
Grid.Column="0"
103+
FontSize="14"
104+
TextWrapping="Wrap"
105+
FontWeight="Bold"
106+
Text="End Date"
107+
Foreground="{DynamicResource Foreground}"
108+
Margin="0, 0, 0, 4"/>
109+
110+
111+
112+
113+
<TextBlock Text="{Binding Name}"
114+
Grid.Row="1"
115+
Grid.Column="1"
116+
FontSize="14"
117+
TextWrapping="Wrap"
118+
Foreground="{DynamicResource Foreground}"
119+
Margin="0, 0, 0, 4"/>
120+
121+
<TextBlock Text="{Binding EndDate}"
122+
Grid.Row="2"
123+
Grid.Column="1"
124+
Foreground="{DynamicResource Foreground}"
125+
FontSize="14"
126+
Margin="0, 0, 0, 4"/>
127+
</Grid>
128+
</Grid>
129+
130+
<Grid Grid.Row="1"
131+
Grid.ColumnSpan="2"
132+
Margin="0, 16, 0, 0">
133+
<Grid.ColumnDefinitions>
134+
<ColumnDefinition Width="*"/>
135+
<ColumnDefinition Width="*"/>
136+
</Grid.ColumnDefinitions>
137+
138+
<Button Content="No"
139+
Background="{DynamicResource Background}"
140+
Foreground="{DynamicResource Foreground}"
141+
Width="80"
142+
Height="30"
143+
HorizontalAlignment="Left"
144+
VerticalAlignment="Bottom"
145+
Style="{DynamicResource ButtonTheme}"
146+
Command="{Binding OnNoClicked}"/>
147+
148+
<Button Content="Yes"
149+
Background="{DynamicResource AccRed}"
150+
Foreground="{DynamicResource White}"
151+
Grid.Column="1"
152+
HorizontalAlignment="Right"
153+
Width="80"
154+
Height="30"
155+
VerticalAlignment="Bottom"
156+
Style="{DynamicResource ButtonTheme}"
157+
Command="{Binding OnYesClicked}"
158+
Margin="0, 0, 4, 0"/>
159+
</Grid>
160+
</Grid>
161+
</Border>
162+
</Grid>
163+
</UserControl>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Windows.Controls;
2+
3+
namespace VexTrack.MVVM.View.Popups
4+
{
5+
/// <summary>
6+
/// Interaction logic for SeasonEndConfirmationPopup.xaml
7+
/// </summary>
8+
public partial class SeasonEndConfirmationPopup : UserControl
9+
{
10+
public SeasonEndConfirmationPopup()
11+
{
12+
InitializeComponent();
13+
}
14+
}
15+
}

VexTrack/MVVM/View/SeasonView.xaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@
5050
</ItemsControl.ItemTemplate>
5151
</ItemsControl>
5252
</Grid>
53-
</ScrollViewer>
54-
</Grid>
53+
</ScrollViewer>
54+
55+
<Button Grid.Row="0"
56+
Width="48" Height="48"
57+
HorizontalAlignment="Right"
58+
VerticalAlignment="Center"
59+
Margin="0, 0, 16, 0"
60+
Style="{DynamicResource AddButtonTheme}"
61+
Command="{Binding OnAddClicked}"/>
62+
</Grid>
5563
</UserControl>

VexTrack/MVVM/ViewModel/MainViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class MainViewModel : ObservableObject
4141
private EditableGoalGroupPopupViewModel EditableGoalGroupPopup { get; set; }
4242
private DeleteGoalConfirmationPopupViewModel DeleteGoalConfirmationPopup { get; set; }
4343
private DeleteGoalGroupConfirmationPopupViewModel DeleteGoalGroupConfirmationPopup { get; set; }
44+
private SeasonEndConfirmationPopupViewModel SeasonEndConfirmationPopup { get; set; }
4445

4546
private object _currentView;
4647
private bool _epilogue;
@@ -217,6 +218,9 @@ private void InitPopupViewModels()
217218

218219
EditableGoalGroupPopup = new EditableGoalGroupPopupViewModel();
219220
ViewModelManager.ViewModels.Add("EditableGoalGroupPopup", EditableGoalGroupPopup);
221+
222+
SeasonEndConfirmationPopup = new SeasonEndConfirmationPopupViewModel();
223+
ViewModelManager.ViewModels.Add("SeasonEndConfirmationPopup", SeasonEndConfirmationPopup);
220224
}
221225

222226
public void SetView(object view)
@@ -229,6 +233,8 @@ public void Update(bool epilogueOnly = false)
229233
if (InterruptUpdate) return;
230234
if (!ViewModelsInitialized) InitViewModels();
231235

236+
if (InterruptUpdate) return;
237+
232238
if (TrackingDataHelper.CurrentSeasonData.ActiveBPLevel > Constants.BattlepassLevels && SettingsHelper.Data.ForceEpilogue)
233239
{
234240
if (!Epilogue) Epilogue = true;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using VexTrack.Core;
2+
3+
namespace VexTrack.MVVM.ViewModel.Popups
4+
{
5+
class SeasonEndConfirmationPopupViewModel : BasePopupViewModel
6+
{
7+
public RelayCommand OnYesClicked { get; set; }
8+
public RelayCommand OnNoClicked { get; set; }
9+
10+
private string UUID = "";
11+
public string Name {get; set; }
12+
public string EndDate { get; set; }
13+
14+
15+
public SeasonEndConfirmationPopupViewModel()
16+
{
17+
CanCancel = true;
18+
19+
OnYesClicked = new RelayCommand(o =>
20+
{
21+
TrackingDataHelper.EndSeason(UUID);
22+
Close();
23+
});
24+
OnNoClicked = new RelayCommand(o => Close());
25+
}
26+
27+
public void SetData(string seasonUUID)
28+
{
29+
UUID = seasonUUID;
30+
Name = TrackingDataHelper.GetSeason(UUID).Name;
31+
EndDate = TrackingDataHelper.GetSeason(UUID).EndDate;
32+
}
33+
}
34+
}

VexTrack/MVVM/ViewModel/Popups/SeasonPopupViewModel.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ private void UpdateGraph(bool epilogue)
106106

107107
LineSeries ideal = GraphCalc.CalcIdealGraph(UUID, epilogue);
108108
LineSeries performance = GraphCalc.CalcPerformanceGraph(UUID);
109-
110-
LineSeries idealPoint = DashboardDataCalc.CalcGraphPoint(ideal, OxyColor.FromArgb(GraphIdealPoint.Color.A, GraphIdealPoint.Color.R, GraphIdealPoint.Color.G, GraphIdealPoint.Color.B));
111-
LineSeries performancePoint = DashboardDataCalc.CalcGraphPoint(performance, OxyColors.Maroon);
112-
109+
113110
RectangleAnnotation bufferZone = GraphCalc.CalcBufferZone(UUID, epilogue);
114111

115112
Graph.LegendPosition = LegendPosition.LeftTop;
@@ -126,8 +123,15 @@ private void UpdateGraph(bool epilogue)
126123
Graph.Series.Add(ideal);
127124
Graph.Series.Add(performance);
128125

129-
Graph.Series.Add(idealPoint);
130-
Graph.Series.Add(performancePoint);
126+
// Only add points to current season
127+
if (UUID == TrackingDataHelper.CurrentSeasonUUID)
128+
{
129+
LineSeries idealPoint = DashboardDataCalc.CalcGraphPoint(ideal, OxyColor.FromArgb(GraphIdealPoint.Color.A, GraphIdealPoint.Color.R, GraphIdealPoint.Color.G, GraphIdealPoint.Color.B));
130+
LineSeries performancePoint = DashboardDataCalc.CalcGraphPoint(performance, OxyColors.Maroon);
131+
132+
Graph.Series.Add(idealPoint);
133+
Graph.Series.Add(performancePoint);
134+
}
131135

132136
Graph.Annotations.Add(bufferZone);
133137

0 commit comments

Comments
 (0)