Skip to content

Commit

Permalink
Version 2.0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Drommedhar committed Oct 6, 2024
1 parent 4658308 commit 0b346b1
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 43 deletions.
18 changes: 9 additions & 9 deletions DlssUpdater/Controls/GamePanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@
</Rectangle.Fill>
</Rectangle>
</StackPanel>
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="25,0,0,0">
<Label Content="Anti Cheat" FontSize="16" HorizontalAlignment="Left" Margin="0,0,0,10" VerticalAlignment="Top" Foreground="#3EFFFFFF" FontWeight="Normal"/>
<Rectangle Width="30" Height="30" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding GameInfo.AntiCheatImage, ElementName=gamePanel}" Stretch="Uniform" Opacity="0.5"/>
</Rectangle.Fill>
</Rectangle>
</StackPanel>
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Left" Margin="25,0,0,0" Width="120">
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Left" Margin="70,0,0,0" Width="120">
<Label Content="Upscaling" FontSize="16" HorizontalAlignment="Left" Margin="0,0,0,10" VerticalAlignment="Top" Foreground="#3EFFFFFF" FontWeight="Normal"/>
<Label Content="{Binding GameInfo.InstalledVersionDlss, ElementName=gamePanel}" FontSize="16" HorizontalAlignment="Left" Margin="0,0,0,4" VerticalAlignment="Bottom" Foreground="#FFFFFFFF" FontWeight="Thin"/>
</Grid>
Expand All @@ -48,6 +40,14 @@
<Label Content="Frame Generation" FontSize="16" HorizontalAlignment="Left" Margin="0,0,0,10" VerticalAlignment="Top" Foreground="#3EFFFFFF" FontWeight="Normal"/>
<Label Content="{Binding GameInfo.InstalledVersionDlssG, ElementName=gamePanel}" FontSize="16" HorizontalAlignment="Left" Margin="0,0,0,4" VerticalAlignment="Bottom" Foreground="#FFFFFFFF" FontWeight="Thin"/>
</Grid>
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="25,0,0,0">
<Label Content="Anti Cheat" FontSize="16" HorizontalAlignment="Left" Margin="0,0,0,10" VerticalAlignment="Top" Foreground="#3EFFFFFF" FontWeight="Normal" Visibility="{Binding GameInfo.HasAntiCheat, ElementName=gamePanel}"/>
<Rectangle Width="30" Height="30" HorizontalAlignment="Center" VerticalAlignment="Bottom">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding GameInfo.AntiCheatImage, ElementName=gamePanel}" Stretch="Uniform" Opacity="0.5"/>
</Rectangle.Fill>
</Rectangle>
</StackPanel>
</StackPanel>
</Grid>
</StackPanel>
Expand Down
2 changes: 2 additions & 0 deletions DlssUpdater/Controls/GamePanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Windows.Navigation;
using System.Windows.Shapes;
using DLSSUpdater.Singletons;
using DlssUpdater.Helpers;

namespace DLSSUpdater.Controls
{
Expand Down Expand Up @@ -70,6 +71,7 @@ private void Button_Click_1(object sender, RoutedEventArgs e)
Height = 0,
Owner = wndMain
};
WindowPositionHelper.CenterWindowToParent(wndConfig, wndMain!);
wndConfig.ShowDialog();
wndMain?.SetEffect(false);
}
Expand Down
2 changes: 1 addition & 1 deletion DlssUpdater/DLSSUpdater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<SelfContained>true</SelfContained>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<SignAssembly>False</SignAssembly>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.1.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand Down
5 changes: 4 additions & 1 deletion DlssUpdater/Defines/GameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public partial class GameInfo : ObservableObject, IEquatable<GameInfo>
[ObservableProperty] [JsonIgnore] public ImageSource? _libraryImage;
[ObservableProperty][JsonIgnore] public ImageSource? _antiCheatImage;
[ObservableProperty][JsonIgnore] public ImageSource? _hideImage;
[ObservableProperty][JsonIgnore] public Visibility _hasAntiCheat = Visibility.Collapsed;

[ObservableProperty] public string? _gameImageUri;

Expand Down Expand Up @@ -134,8 +135,10 @@ public void SetAntiCheatImage()
{
AntiCheatProvider.EasyAntiCheat => new BitmapImage(new Uri("pack://application:,,,/Icons/eac.png")),
AntiCheatProvider.BattlEye => new BitmapImage(new Uri("pack://application:,,,/Icons/battleye.png")),
_ => new BitmapImage(new Uri("pack://application:,,,/Icons/cross.png")),
_ => null,
};

HasAntiCheat = AntiCheatImage != null ? Visibility.Visible : Visibility.Collapsed;
}

public async Task<bool> GatherInstalledVersions()
Expand Down
1 change: 1 addition & 0 deletions DlssUpdater/Defines/UI/Pages/LibraryPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private void ShowGameConfig()
Height = 0,
Owner = wndMain
};
WindowPositionHelper.CenterWindowToParent(wndConfig, wndMain!);
wndConfig.ShowDialog();
wndMain?.SetEffect(false);
}
Expand Down
93 changes: 93 additions & 0 deletions DlssUpdater/Helpers/WindowPositionHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using System;
using System.Windows;
using System.Windows.Interop;

namespace DlssUpdater.Helpers;

public static class WindowPositionHelper
{
public static void CenterWindowToParent(Window childWindow, Window parentWindow)
{
// Ensure the child window is fully rendered before positioning
childWindow.SizeChanged += (sender, args) =>
{
// Get the DPI scaling factors for both the parent and the child window
var parentDpiScale = GetDpiScale(parentWindow);
var childDpiScale = GetDpiScale(childWindow);

// Check if the parent window is maximized
bool isParentMaximized = parentWindow.WindowState == WindowState.Maximized;

// Get the parent window's bounds
Rect parentBounds;
// Get the parent window's position and size in screen coordinates
var parentPosition = parentWindow.PointToScreen(new Point(0, 0));
double parentWidthInPx = parentWindow.ActualWidth * parentDpiScale.X;
double parentHeightInPx = parentWindow.ActualHeight * parentDpiScale.Y;
parentBounds = new Rect(parentPosition.X, parentPosition.Y, parentWidthInPx, parentHeightInPx);

// Get the child window's actual size in physical pixels
double childWidthInPx = childWindow.ActualWidth * childDpiScale.X;
double childHeightInPx = childWindow.ActualHeight * childDpiScale.Y;

// Ensure the child window size is available
if (childWidthInPx == 0 || childHeightInPx == 0)
{
return; // Wait until the size is properly calculated
}

// Calculate the centered position relative to the parent
double childLeft = parentBounds.X + (parentBounds.Width - childWidthInPx) / 2;
double childTop = parentBounds.Y + (parentBounds.Height - childHeightInPx) / 2;

// Convert the position back to logical units for the child window
childWindow.Left = childLeft / childDpiScale.X;
childWindow.Top = childTop / childDpiScale.Y;
};
}

private static Point GetDpiScale(Window window)
{
// Get the window's presentation source
var source = PresentationSource.FromVisual(window);
if (source?.CompositionTarget != null)
{
// Return the DPI scale factor (logical units to physical pixels)
return new Point(source.CompositionTarget.TransformToDevice.M11,
source.CompositionTarget.TransformToDevice.M22);
}
return new Point(1.0, 1.0); // Default scale if source is not available
}

// P/Invoke declarations to work with monitor information
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern IntPtr MonitorFromWindow(IntPtr hwnd, MonitorOptions dwFlags);

[System.Runtime.InteropServices.DllImport("User32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool GetMonitorInfo(IntPtr hMonitor, ref MONITORINFO lpmi);

[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}

[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public class MONITORINFO
{
public int cbSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(MONITORINFO));
public RECT rcMonitor = new RECT();
public RECT rcWork = new RECT();
public int dwFlags = 0;
}

private enum MonitorOptions : uint
{
MONITOR_DEFAULTTONULL = 0x00000000,
MONITOR_DEFAULTTOPRIMARY = 0x00000001,
MONITOR_DEFAULTTONEAREST = 0x00000002
}
}
35 changes: 19 additions & 16 deletions DlssUpdater/Views/Windows/GameConfigWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:controls="clr-namespace:DLSSUpdater.Controls"
mc:Ignorable="d"
Title="GameConfigWindow"
WindowStyle="None" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" SizeToContent="WidthAndHeight">
WindowStyle="None" WindowStartupLocation="Manual" ResizeMode="NoResize" SizeToContent="WidthAndHeight">
<adonisControls:AdonisWindow.Effect>
<DropShadowEffect BlurRadius="5" ShadowDepth="0"/>
</adonisControls:AdonisWindow.Effect>
Expand All @@ -21,7 +21,7 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<Grid Grid.Column="0" Margin="10" Width="100" Height="150" VerticalAlignment="Top">
<Grid Grid.Column="0" Margin="10,10,40,10" Width="100" Height="150" VerticalAlignment="Top">
<Rectangle Width="100" Height="150" HorizontalAlignment="Left" VerticalAlignment="Top" Stroke="#0FFFFFFF" StrokeThickness="2">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding ViewModel.GameInfo.GameImage}" Stretch="UniformToFill"/>
Expand Down Expand Up @@ -49,13 +49,13 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Label Content="Name:" Grid.Row="0" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center"/>
Expand All @@ -64,7 +64,7 @@
adonisExtensions:CursorSpotlightExtension.BorderBrush="#0FFFFFFF"
adonisExtensions:CursorSpotlightExtension.RelativeSpotlightSize="0.5"
Background="#FF1d263c" BorderBrush="#00000000"
Text="{Binding ViewModel.GameInfo.GameName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
Text="{Binding ViewModel.GameInfo.GameName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center"/>
<Label Content="Path:" Grid.Row="1" Grid.Column="0" Margin="0,4,10,0" VerticalAlignment="Center"/>
<Button x:Name="btnPath" Grid.Row="1" Grid.Column="1" Content="{Binding ViewModel.PathText}"
Foreground="White" IsEnabled="{Binding ViewModel.IsManualGame}"
Expand All @@ -85,7 +85,8 @@
adonisExtensions:CursorSpotlightExtension.BackgroundBrush="#0AFFFFFF"
adonisExtensions:CursorSpotlightExtension.BorderBrush="#0FFFFFFF"
adonisExtensions:CursorSpotlightExtension.RelativeSpotlightSize="0.5"
SelectedValue="{Binding ViewModel.DlssItem, Mode=TwoWay}" Margin="0,5,0,5" Background="#FF1d263c" BorderBrush="#00000000"/>
SelectedValue="{Binding ViewModel.DlssItem, Mode=TwoWay}" Margin="0,5,0,5"
VerticalAlignment="Center" Background="#FF1d263c" BorderBrush="#00000000"/>
<Label Content="Frame Generation:" Grid.Row="3" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center"/>
<ComboBox Grid.Column="1" Grid.Row="3" IsEnabled="{Binding ViewModel.DlssGEnabled}"
ItemsSource="{Binding ViewModel.InstalledVersionsDlssG}"
Expand All @@ -94,18 +95,20 @@
adonisExtensions:CursorSpotlightExtension.BackgroundBrush="#0AFFFFFF"
adonisExtensions:CursorSpotlightExtension.BorderBrush="#0FFFFFFF"
adonisExtensions:CursorSpotlightExtension.RelativeSpotlightSize="0.5"
SelectedValue="{Binding ViewModel.DlssGItem, Mode=TwoWay}" Margin="0,5,0,5" Background="#FF1d263c" BorderBrush="#00000000"/>
<Label Content="Ray Reconstruction:" Grid.Row="4" Grid.Column="0" Margin="0,0,10,0" VerticalAlignment="Center"/>
SelectedValue="{Binding ViewModel.DlssGItem, Mode=TwoWay}" Margin="0,5,0,5"
VerticalAlignment="Center" Background="#FF1d263c" BorderBrush="#00000000"/>
<Label Content="Ray Reconstruction:" Grid.Row="4" Grid.Column="0" Margin="0,0,20,0" VerticalAlignment="Center"/>
<ComboBox Grid.Column="1" Grid.Row="4" IsEnabled="{Binding ViewModel.DlssDEnabled}"
ItemsSource="{Binding ViewModel.InstalledVersionsDlssD}"
DisplayMemberPath="VersionDetailed"
SelectedValuePath="VersionDetailed"
adonisExtensions:CursorSpotlightExtension.BackgroundBrush="#0AFFFFFF"
adonisExtensions:CursorSpotlightExtension.BorderBrush="#0FFFFFFF"
adonisExtensions:CursorSpotlightExtension.RelativeSpotlightSize="0.5"
SelectedValue="{Binding ViewModel.DlssDItem, Mode=TwoWay}" Margin="0,5,0,5" Background="#FF1d263c" BorderBrush="#00000000"/>
<CheckBox Grid.Column="1" Grid.Row="5" Content="Save current versions as default" VerticalAlignment="Top" HorizontalAlignment="Right" IsChecked="{Binding ViewModel.SaveAsDefault, Mode=TwoWay}" Background="#00000000" FontSize="12" Focusable="False"/>
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.ColumnSpan="3" HorizontalAlignment="Right" Margin="0,20,0,0">
SelectedValue="{Binding ViewModel.DlssDItem, Mode=TwoWay}" Margin="0,5,0,5"
VerticalAlignment="Center" Background="#FF1d263c" BorderBrush="#00000000"/>
<CheckBox Grid.Column="1" Grid.Row="5" Margin="0,10,0,0" Content="Save current versions as default" VerticalAlignment="Top" HorizontalAlignment="Right" IsChecked="{Binding ViewModel.SaveAsDefault, Mode=TwoWay}" Background="#00000000" FontSize="12" Focusable="False"/>
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.ColumnSpan="3" HorizontalAlignment="Right" Margin="0,0,0,0">
<Button x:Name="btnApply" Grid.Row="1" Grid.Column="1" Content="Apply"
Foreground="White"
BorderBrush="{x:Null}"
Expand Down
14 changes: 0 additions & 14 deletions DlssUpdater/Views/Windows/GameConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public GameConfigWindow(GameConfigWindowViewModel viewModel, GameContainer gameC
_fileWatcher = watcher;
_updater = updater;

SizeChanged += (s, e) => CenterOwner(this);
InitializeComponent();

DataContext = this;
Expand All @@ -51,19 +50,6 @@ public GameConfigWindow(GameConfigWindowViewModel viewModel, GameContainer gameC
updateUi();
}

private void CenterOwner(Window w)
{
// TODO: Does not work if maximized
if (w.Owner != null)
{
double top = w.Owner.Top + ((w.Owner.Height - w.ActualHeight) / 2);
double left = w.Owner.Left + ((w.Owner.Width - w.ActualWidth) / 2);

w.Top = top < 0 ? 0 : top;
w.Left = left < 0 ? 0 : left;
}
}

private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
Expand Down
7 changes: 6 additions & 1 deletion DlssUpdater/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# 2.0.0.0
# 2.0.1.0
* Fix misaligned game configuration window
* Game config popup more space for controls
* Move Anti Cheat to the right

# 2.0.0.0
* Completely redesigned user interface
* Several bugfixes while creating new user interface
* New option "Show notifications" to hide notification bubbles
Expand Down
2 changes: 1 addition & 1 deletion DlssUpdater/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.0.0.0"
"version": "2.0.1.0"
}

0 comments on commit 0b346b1

Please sign in to comment.