Skip to content

Commit

Permalink
Starting work on Downloading versions
Browse files Browse the repository at this point in the history
  • Loading branch information
TrinityDevelopers committed Apr 13, 2020
1 parent a3c22ff commit 539fab8
Show file tree
Hide file tree
Showing 36 changed files with 574 additions and 258 deletions.
16 changes: 4 additions & 12 deletions ZenovaLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace ZenovaLauncher
Expand All @@ -20,14 +14,15 @@ public partial class App : Application
private readonly string _directoryProfiles = "Profiles";
private readonly string _directoryVersions = "Versions";
private string _dataDirectory;
private EnvironmentVariableTarget _environmentType;


public void AppStart(object sender, StartupEventArgs e)
{
SetupEnvironment();
VersionManager.instance = new VersionManager(Path.Combine(VersionsDirectory, "versions.json"));
VersionDownloader.standard = new VersionDownloader();
VersionDownloader.user = new VersionDownloader();
VersionManager.instance = new VersionManager(VersionsDirectory);
ProfileManager.instance = new ProfileManager(ProfilesDirectory);
ProfileLauncher.instance = new ProfileLauncher();
Preferences.LoadPreferences(DataDirectory);
Dispatcher.Invoke(async () =>
{
Expand All @@ -49,21 +44,18 @@ private void SetupEnvironment()
if (value != null)
{
_dataDirectory = value;
_environmentType = EnvironmentVariableTarget.User;
}
else
{
value = Environment.GetEnvironmentVariable(_environmentKey, EnvironmentVariableTarget.Machine);
if (value != null)
{
_dataDirectory = value;
_environmentType = EnvironmentVariableTarget.Machine;
}
else
{
// if not, create user environment variable at default location
Environment.SetEnvironmentVariable(_environmentKey, DataDirectory, EnvironmentVariableTarget.User);
_environmentType = EnvironmentVariableTarget.User;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions ZenovaLauncher/Controls/LauncherSideMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ZenovaLauncher.Controls"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:ui="http://schemas.modernwpf.com/2019">

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:local="clr-namespace:ZenovaLauncher.Controls">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ModernWpf;component/Styles/ListBox.xaml" />
</ResourceDictionary.MergedDictionaries>
Expand Down
4 changes: 0 additions & 4 deletions ZenovaLauncher/Controls/LauncherTabControl.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
Expand Down
15 changes: 2 additions & 13 deletions ZenovaLauncher/Dialogs/AddProfileDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
using System;
using ModernWpf.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ModernWpf.Controls;

namespace ZenovaLauncher
{
Expand Down
15 changes: 2 additions & 13 deletions ZenovaLauncher/Dialogs/EditProfileDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
using System;
using ModernWpf.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ModernWpf.Controls;

namespace ZenovaLauncher
{
Expand Down
2 changes: 1 addition & 1 deletion ZenovaLauncher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<ui:SymbolIcon Symbol="Home" />
</mah:HamburgerMenuIconItem.Icon>
</mah:HamburgerMenuIconItem>

<mah:HamburgerMenuIconItem
Label="News"
Tag="Pages/NewsPage.xaml">
Expand Down
10 changes: 0 additions & 10 deletions ZenovaLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ZenovaLauncher
{
Expand Down
15 changes: 1 addition & 14 deletions ZenovaLauncher/Pages/HelpPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace ZenovaLauncher
{
Expand Down
15 changes: 1 addition & 14 deletions ZenovaLauncher/Pages/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace ZenovaLauncher
{
Expand Down
18 changes: 3 additions & 15 deletions ZenovaLauncher/Pages/ModsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace ZenovaLauncher
{
Expand All @@ -20,7 +7,8 @@ namespace ZenovaLauncher
/// </summary>
public partial class ModsPage : Page
{
public ModsPage() {
public ModsPage()
{
InitializeComponent();
}
}
Expand Down
15 changes: 1 addition & 14 deletions ZenovaLauncher/Pages/NewsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace ZenovaLauncher
{
Expand Down
13 changes: 9 additions & 4 deletions ZenovaLauncher/Pages/PlayPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Y" From="-20" To="0" Duration="0:0:0.2" />
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.1" To="1.0" Duration="0:0:0.2" />
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
Expand All @@ -51,11 +51,16 @@
Content="Launch Minecraft"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Width="200"
Width="240"
Height="50"
Margin="0,0,0,20"
Style="{DynamicResource AccentButtonStyle}" />
<Grid Grid.Row="1" Grid.ColumnSpan="3" Background="#FF262626" />
ui:ControlHelper.CornerRadius="4"
FontWeight="Normal"
FontSize="14"
Style="{DynamicResource LauncherAccentButtonStyle}"
Click="PlayButtonClick"
IsEnabled="{Binding Path=IsNotDownloading}"/>
<Grid Grid.Row="1" Grid.ColumnSpan="3" Background="{DynamicResource LauncherControlPageBackgroundChromeMediumBrush}" />
<Grid Grid.Row="1" Grid.Column="0">
<ComboBox
Style="{StaticResource ProfileBoxStyle}"
Expand Down
23 changes: 9 additions & 14 deletions ZenovaLauncher/Pages/PlayPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ZenovaLauncher
{
Expand All @@ -20,9 +8,16 @@ namespace ZenovaLauncher
/// </summary>
public partial class PlayPage : Page
{
public PlayPage() {
public PlayPage()
{
InitializeComponent();
ProfileBox.ItemsSource = ProfileManager.instance;
DataContext = ProfileLauncher.instance;
}

private void PlayButtonClick(object sender, RoutedEventArgs e)
{
ProfileLauncher.instance.LaunchProfile(ProfileBox.SelectedItem as Profile);
}
}
}
18 changes: 17 additions & 1 deletion ZenovaLauncher/Pages/ProfilesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ZenovaLauncher"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:tz="http://schemas.abtsoftware.co.uk/transitionz"
xmlns:comment="Comments"
mc:Ignorable="d comment">

Expand All @@ -17,6 +18,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" MaxWidth="900" Margin="15,10,15,12" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -94,7 +96,7 @@
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel x:Name="InteractButtons" Grid.Column="2" HorizontalAlignment="Right" Orientation="Horizontal" Spacing="8" Visibility="Hidden">
<Button Content="Play" Style="{DynamicResource LauncherAccentButtonStyle}" />
<Button Content="Play" Style="{DynamicResource LauncherAccentButtonStyle}" Click="PlayButtonClick" />
<Button Padding="5,5,6,6" Style="{DynamicResource LauncherDefaultButtonStyle}">
<Button.Content>
<ui:SymbolIcon Symbol="More" />
Expand Down Expand Up @@ -125,6 +127,20 @@
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid Grid.Row="2" HorizontalAlignment="Stretch" Background="{DynamicResource LauncherControlPageBackgroundChromeMediumBrush}">
<ProgressBar
x:Name="LoadingProgressBar"
Margin="10,9,10,9"
MinHeight="32"
HorizontalAlignment="Stretch"
ui:ControlHelper.CornerRadius="0"
Background="{DynamicResource LauncherControlTransientLowBackgroundBrush}"
Minimum="0"
Maximum="{Binding Path=DownloadInfo.TotalSize}"
local:ProgressBarSmoother.SmoothValue="{Binding Path=DownloadInfo.DownloadedBytes}"
IsIndeterminate="{Binding Path=DownloadInfo.IsProgressIndeterminate}"
Visibility="{Binding Path=IsDownloading, Converter={StaticResource BooleanToVisibilityConverter}}" />
</Grid>
</Grid>
</ui:ScrollViewerEx>
</Grid>
Expand Down
19 changes: 9 additions & 10 deletions ZenovaLauncher/Pages/ProfilesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ZenovaLauncher
{
Expand All @@ -21,8 +13,10 @@ namespace ZenovaLauncher
/// </summary>
public partial class ProfilesPage : Page
{
public ProfilesPage() {
public ProfilesPage()
{
InitializeComponent();
DataContext = ProfileLauncher.instance;
ProfileListBox.ItemsSource = ProfileManager.instance;
SortProfileBox.DataContext = Preferences.instance;
ReleasesBox.DataContext = Preferences.instance;
Expand Down Expand Up @@ -74,6 +68,11 @@ private void ProfileSelected(object sender, MouseButtonEventArgs e)
EditProfile((sender as FrameworkElement).DataContext as Profile);
}

private void PlayButtonClick(object sender, RoutedEventArgs e)
{
ProfileLauncher.instance.LaunchProfile((sender as FrameworkElement).DataContext as Profile);
}

private void SortChanged(object sender, SelectionChangedEventArgs e)
{
SortProfileList(Preferences.instance.ProfileSorting);
Expand All @@ -93,7 +92,7 @@ protected void FilterProfileList()
predicates.Add(Profile.betaFilter);
if (Preferences.instance.EnableHistorical)
predicates.Add(Profile.historicalFilter);
if(ProfileListBox != null)
if (ProfileListBox != null)
ProfileListBox.Items.Filter = o => predicates.Any(predicate => predicate(o));
}

Expand Down
Loading

0 comments on commit 539fab8

Please sign in to comment.