Skip to content

Commit

Permalink
Merge pull request #32 from Glumboi/Experimental
Browse files Browse the repository at this point in the history
2.5.1.0 Commit
  • Loading branch information
Glumboi authored Jun 18, 2023
2 parents 731d619 + 26f5131 commit 6395ac3
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 55 deletions.
77 changes: 58 additions & 19 deletions EmuSak-Revive.GUI-WPF/CustomControls/GameButton.xaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,70 @@
<ui:Button
<ui:CardExpander
x:Class="EmuSak_Revive.GUI_WPF.CustomControls.GameButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:EmuSak_Revive.GUI_WPF.CustomControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Width="{Binding DesiredButtonSize}"
Height="{Binding DesiredButtonSize}"
Width="220"
Margin="{Binding GlobalMargin}"
d:DesignHeight="450"
d:DesignWidth="800"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Expanded="CardExpander_Expanded"
mc:Ignorable="d">
<Grid>
<Rectangle
Width="{Binding DesiredImageSize}"
Height="{Binding DesiredImageSize}"
HorizontalAlignment="Center"
RadiusX="10"
RadiusY="10">
<Rectangle.Effect>
<DropShadowEffect Opacity="0.5" ShadowDepth="5" />
</Rectangle.Effect>
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding GameImageSource}" />
</Rectangle.Fill>
</Rectangle>
</Grid>
</ui:Button>
<ui:CardExpander.Header>
<Grid>
<Rectangle
Width="{Binding DesiredImageSize}"
Height="{Binding DesiredImageSize}"
HorizontalAlignment="Center"
RadiusX="10"
RadiusY="10">
<Rectangle.Effect>
<DropShadowEffect Opacity="0.5" ShadowDepth="5" />
</Rectangle.Effect>
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding GameImageSource}" />
</Rectangle.Fill>
</Rectangle>
</Grid>
</ui:CardExpander.Header>
<ui:CardExpander.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid>
<TextBlock
Padding="2"
HorizontalAlignment="Left"
FontWeight="Bold"
Text="{Binding LocalShaderCount, StringFormat=Local: {0}}" />
<TextBlock
Padding="2"
HorizontalAlignment="Right"
FontWeight="Bold"
Text="{Binding WebShaderCount, StringFormat=Web:{0}}" />
</Grid>
<ui:Button
Grid.Row="1"
Margin="0,0,0,2"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Command="{Binding DownloadShaderCommand}"
Content="Install Shaders"
Icon="ArrowDownload24" />
<ui:Button
Grid.Row="2"
Margin="0,2,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Content="Coming later..."
Icon="Save24"
IsEnabled="False" />
</Grid>
</ui:CardExpander.Content>
</ui:CardExpander>
84 changes: 78 additions & 6 deletions EmuSak-Revive.GUI-WPF/CustomControls/GameButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
using EmuSak_Revive.Emulators;
using EmuSak_Revive.EmuFiles;
using EmuSak_Revive.Emulators;
using EmuSak_Revive.GUI_WPF.ExtraWindows;
using EmuSak_Revive.Network;
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Wpf.Ui.Common;
using Wpf.Ui.Controls;

namespace EmuSak_Revive.GUI_WPF.CustomControls
{
/// <summary>
/// Interaction logic for GameButton.xaml
/// </summary>
public partial class GameButton : Wpf.Ui.Controls.Button
public partial class GameButton : CardExpander
{
private string _shaderUrl;

public SwitchGame Game { get; private set; }

public string GameID
Expand All @@ -26,6 +33,26 @@ public string GameID
public static readonly DependencyProperty GameIDProperty =
DependencyProperty.Register("GameID", typeof(string), typeof(GameButton), new PropertyMetadata(null));

public string LocalShaderCount
{
get => (string)GetValue(LocalShaderCountProperty);
set => SetValue(LocalShaderCountProperty, value);
}

// Using a DependencyProperty as the backing store for GameID. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LocalShaderCountProperty =
DependencyProperty.Register("LocalShaderCount", typeof(string), typeof(GameButton), new PropertyMetadata(null));

public string WebShaderCount
{
get => (string)GetValue(WebShaderCountProperty);
set => SetValue(WebShaderCountProperty, value);
}

// Using a DependencyProperty as the backing store for GameID. This enables animation, styling, binding, etc...
public static readonly DependencyProperty WebShaderCountProperty =
DependencyProperty.Register("WebShaderCount", typeof(string), typeof(GameButton), new PropertyMetadata(null));

public string GameName
{
get => (string)GetValue(GameNameProperty);
Expand Down Expand Up @@ -76,10 +103,29 @@ public int DesiredButtonSize
public static readonly DependencyProperty DesiredButtonSizeProperty =
DependencyProperty.Register("ImageSize", typeof(int), typeof(GameButton), new PropertyMetadata(155));

public GameButton(SwitchGame switchGame = null)
public static readonly DependencyProperty DownloadShaderCommandProperty =
DependencyProperty.Register("DownloadShaderCommand", typeof(ICommand), typeof(GameButton));

public ICommand DownloadShaderCommand
{
get { return (ICommand)GetValue(DownloadShaderCommandProperty); }
set { SetValue(DownloadShaderCommandProperty, value); }
}

public void CreateDownloadShaderCommand()
{
DownloadShaderCommand = new RelayCommand(DownloadShader, IsShaderAvailable);
}

public GameButton(
SwitchGame switchGame = null,
int desiredImageSize = 155,
int desiredButtonSize = 220)
{
InitializeComponent();
Style = (Style)Application.Current.Resources[typeof(Wpf.Ui.Controls.Button)];
CreateDownloadShaderCommand();

Style = (Style)Application.Current.Resources[typeof(CardExpander)];

if (switchGame != null)
{
Expand All @@ -88,12 +134,14 @@ public GameButton(SwitchGame switchGame = null)
GameName = switchGame.GameName;
GameImageSource = ConvertToImageSource(switchGame.GameImage);
}

DesiredImageSize = desiredImageSize;
}

protected override void OnClick()
/*protected override void OnClick()
{
new GameActionsWindow(Game).Show();
}
}*/

private static ImageSource ConvertToImageSource(System.Drawing.Image image)
{
Expand Down Expand Up @@ -121,5 +169,29 @@ private static class NativeMethods
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
}

private void CardExpander_Expanded(object sender, RoutedEventArgs e)
{
LoadShaderInfo();
}

private bool IsShaderAvailable()
{
return !string.IsNullOrEmpty(_shaderUrl);
}

private void LoadShaderInfo()
{
LocalShaderCount = EmuShader.GetShaderCount(GameID);
WebShaderCount = Network.Networking.GetPasteGameShaderCount(GameName);
_shaderUrl = Network.Networking.GetShaderDownload(GameName);
}

private void DownloadShader()
{
var downloadUrl = Networking.GetShaderDownload(GameName);
EmuShader.InstallShader(MainWindow.EmuConfig, downloadUrl,
GameID);
}
}
}
40 changes: 27 additions & 13 deletions EmuSak-Revive.GUI-WPF/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,40 @@

<ui:UiWindow.Resources>
<Storyboard x:Key="SpinHomeImage">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Home_Image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Home_Image"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="360" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>

<Storyboard x:Key="SpinInfoImage">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Info_Image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Info_Image"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="360" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>

<Storyboard x:Key="SpinSettingsImage">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Settings_Image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Settings_Image"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="360" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>

<Storyboard x:Key="SpinNewsImage">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="News_Image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="News_Image"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="360" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>

<Storyboard x:Key="SpinPluginsImage">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Plugins_Image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Plugins_Image"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<EasingDoubleKeyFrame KeyTime="00:00:00.3000000" Value="360" />
</DoubleAnimationUsingKeyFrames>
Expand Down Expand Up @@ -279,12 +284,16 @@

<Border Padding="5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="59*" />
<ColumnDefinition Width="62*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="6*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel>
<StackPanel Grid.ColumnSpan="2">
<TextBlock
HorizontalAlignment="Center"
FontSize="20"
Expand All @@ -297,13 +306,17 @@
Fill="DarkGray" />
</StackPanel>

<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="2" Margin="0,61,0,0" Grid.RowSpan="2">
<TextBlock TextWrapping="Wrap">
GlumSak 2.x.x.x is a re defined experience of the Tool "GlumSak" made by Glumboi.<LineBreak />
GlumSak is a Tool made by Glumboi that helps you to set up your Emulators. This Project took big inspiration of the Tool "emusak-ui" and is a sort of revive for it.<LineBreak />
I spent much time developing and improving this tool over the past 4 Months to bring ya'll the best experience of this Project and it's Visions.<LineBreak />
GlumSak 2.x.x.x is a re defined experience of the Tool "GlumSak" made by Glumboi.
<LineBreak />
GlumSak is a Tool made by Glumboi that helps you to set up your Emulators. This Project took big inspiration of the Tool "emusak-ui" and is a sort of revive for it.
<LineBreak />
I spent much time developing and improving this tool over the past 4 Months to bring ya'll the best experience of this Project and it's Visions.
<LineBreak />
<LineBreak />
If you have something to report such as a Bug or a new Feature, then you can do that with Discord or write me an E-Mail, I surely take a read sometimes.
<LineBreak />
If you have something to report such as a Bug or a new Feature, then you can do that with Discord or write me an E-Mail, I surely take a read sometimes.<LineBreak />
<LineBreak />
What is new in GlumSak 2.x.x.x and higher?<LineBreak />
<LineBreak />
Expand All @@ -312,10 +325,11 @@
- Better Window resizing<LineBreak />
- A new, clean and fresh looking UI design flow as I call it<LineBreak />
<LineBreak />
Old Versions (Versions using Windows Forms) are officially out of Support but can still work for some time.</TextBlock>
Old Versions (Versions using Windows Forms) are officially out of Support but can still work for some time.
</TextBlock>
</ScrollViewer>

<Grid Grid.Row="2">
<Grid Grid.Row="1" Grid.ColumnSpan="2" Margin="0,366,0,0" Grid.RowSpan="2">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
Expand Down
19 changes: 5 additions & 14 deletions EmuSak-Revive.GUI-WPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using EmuSak_Revive.GUI_WPF.PluginExtra;
using Wpf.Ui.Appearance;
using EmuSak_Revive.GUI_WPF.CustomControls;
using Wpf.Ui.Common;

namespace EmuSak_Revive.GUI_WPF
{
Expand Down Expand Up @@ -54,7 +55,7 @@ public partial class MainWindow : UiWindow
private List<string> names = new List<string>();
private List<string> firmwareVersions = new List<string>();
private List<SwitchGame> switchGames = new List<SwitchGame>();
private List<System.Windows.Controls.Button> imageButtons = new List<System.Windows.Controls.Button>();
private List<CardExpander> imageButtons = new List<CardExpander>();

#endregion List variables

Expand Down Expand Up @@ -290,7 +291,7 @@ private void LoadFirmwares()
Firmware_ComboBox.SelectedIndex = 0;
}

private System.Windows.Controls.Button CreateGameButtonFromMetaLine(string line)
private CardExpander CreateGameButtonFromMetaLine(string line)
{
string fileGameID = line.Split('\"')[3];
string icon = line.Split('\"')[1];
Expand All @@ -306,7 +307,7 @@ private System.Windows.Controls.Button CreateGameButtonFromMetaLine(string line)

private void LoadGamesToUI(int config)
{
IEnumerable<string> fileLines = File.ReadLines("./Json/gameIcons_Ids.txt");
IEnumerable<string> fileLines = File.ReadLines("./Json/gameIcons_Ids.txt");
List<string> games = config == 0 ? Yuzu.Games : Ryujinx.Games;

foreach (var line in fileLines)
Expand All @@ -321,17 +322,7 @@ private void LoadGamesToUI(int config)
GlumSakCache.CreateGlumSakCache(switchGames, config);
}

private void ShowGameActionsWindow(SwitchGame game)
{
/* PlayAudio.PlayFromByteArr(mainWindowPlayer,
Properties.Settings.Default.PlaySounds,
Properties.Resources.enter_back);*/

GameActionsWindow gameActionsWindow = new GameActionsWindow(game);
gameActionsWindow.Show();
}

private System.Windows.Controls.Button CreateButton(SwitchGame game, System.Drawing.Image btnImage = null)
private CardExpander CreateButton(SwitchGame game, System.Drawing.Image btnImage = null)
{
var gameBtn = new GameButton(game);
Games_Panel.Children.Add(gameBtn);
Expand Down
4 changes: 2 additions & 2 deletions EmuSak-Revive.GUI-WPF/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.5.0.1")]
[assembly: AssemblyFileVersion("2.5.0.1")]
[assembly: AssemblyVersion("2.5.1.0")]
[assembly: AssemblyFileVersion("2.5.1.0")]
Loading

0 comments on commit 6395ac3

Please sign in to comment.