Skip to content

Commit

Permalink
UI Scaling Settings (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
DEATHB4DEFEAT authored Dec 18, 2024
1 parent 6ad58e4 commit 9ab5567
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 133 deletions.
2 changes: 2 additions & 0 deletions SS14.Launcher/Assets/Locale/en-US/text.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ tab-options-log-launcher = Log Launcher
tab-options-log-launcher-desc = Enables logging of the launcher. Useful for developers. (requires launcher restart)
tab-options-verbose-launcher-logging = Verbose Launcher Logging
tab-options-verbose-launcher-logging-desc = For when the developers are *very* stumped with your problem. (requires launcher restart)
tab-options-ui-scaling = UI Scale
tab-options-ui-scaling-lock = Lock X and Y together
tab-options-seasonal-branding = Seasonal Branding
tab-options-seasonal-branding-desc = Whatever temporally relevant icons and logos we can come up with.
tab-options-disable-signing = Disable Engine Signature Checks
Expand Down
7 changes: 7 additions & 0 deletions SS14.Launcher/Models/Data/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public static readonly CVarDef<bool> HasDismissedEarlyAccessWarning
/// </summary>
public static readonly CVarDef<int> MaxForkVersionsToKeep = CVarDef.Create("MaxForkVersionsToKeep", 3);

public static readonly CVarDef<double> UiScalingX = CVarDef.Create("UiScalingX", 1.0);
public static readonly CVarDef<double> UiScalingY = CVarDef.Create("UiScalingY", 1.0);
/// <summary>
/// Whether the UI scaling options should always be the same as each other.
/// </summary>
public static readonly CVarDef<bool> UiScalingLock = CVarDef.Create("UiScalingLock", true);

/// <summary>
/// Whether to display override assets (trans rights).
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions SS14.Launcher/Models/Data/DataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ private void LoadSqliteConfig(SqliteConnection sqliteConnection)
Set((long) v != 0);
else if (entry.Type == typeof(int))
Set((int)(long) v);
else if (entry.Type == typeof(double))
Set((double) v);
else
throw new NotImplementedException("Unknown CVar type.");

void Set<T>(T value) => ((CVarEntry<T>)entry).ValueInternal = value;
}
Expand Down
33 changes: 32 additions & 1 deletion SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public OptionsTabViewModel()
public bool DisableIncompatibleMacOS { get; }

#if RELEASE
public bool HideDisableSigning => true;
public bool HideDisableSigning => true;
#else
public bool HideDisableSigning => false;
#endif
Expand Down Expand Up @@ -85,6 +85,37 @@ public bool DisableSigning
}
}

public double UiScalingX
{
get => Cfg.GetCVar(CVars.UiScalingX);
set
{
Cfg.SetCVar(CVars.UiScalingX, value);
Cfg.CommitConfig();
}
}

public double UiScalingY
{
get => Cfg.GetCVar(CVars.UiScalingY);
set
{
Cfg.SetCVar(CVars.UiScalingY, value);
Cfg.CommitConfig();
}
}

public bool NotUiScalingLock => !UiScalingLock;
public bool UiScalingLock
{
get => Cfg.GetCVar(CVars.UiScalingLock);
set
{
Cfg.SetCVar(CVars.UiScalingLock, value);
Cfg.CommitConfig();
}
}

public bool OverrideAssets
{
get => Cfg.GetCVar(CVars.OverrideAssets);
Expand Down
264 changes: 133 additions & 131 deletions SS14.Launcher/Views/MainWindowContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,135 +8,137 @@
xmlns:mainWindowTabs="clr-namespace:SS14.Launcher.ViewModels.MainWindowTabs"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SS14.Launcher.Views.MainWindowContent">
<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>

<Panel>
<DockPanel LastChildFill="true">
<!-- Header -->
<Panel DockPanel.Dock="Top">
<Panel.Background>
<SolidColorBrush Color="#212126" />
</Panel.Background>

<DockPanel Name="HeaderPanel" Classes="MainWindowHeader">
<!-- Logo -->
<Image DockPanel.Dock="Left" HorizontalAlignment="Left" Height="60" Margin="0, 0, 0, 8"
Source="{DynamicResource LogoLong}" />
<!--<v:Logo DockPanel.Dock="Left" Height="60" HorizontalAlignment="Left" Margin="0, 8"></v:Logo>-->
<Grid DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center"
ColumnDefinitions="Auto, Auto" RowDefinitions="Auto, Auto" Margin="0, 0, 3, 0">
<!-- Discord link -->
<Button Grid.Row="0" Grid.Column="0" MinWidth="90"
Command="{Binding OnDiscordButtonPressed}" Classes="OpenBoth"
Margin="0, 6, 2, 2">
<v:IconLabel Icon="{DynamicResource InfoIcon-discord}"
Content="{loc:Loc main-window-header-link-discord}" />
</Button>

<!-- Website link -->
<Button Grid.Row="0" Grid.Column="1" MinWidth="90"
Command="{Binding OnWebsiteButtonPressed}" Classes="OpenLeft"
Margin="0, 6, 0, 2">
<v:IconLabel Icon="{DynamicResource InfoIcon-web}" Content="{loc:Loc main-window-header-link-website}" />
</Button>

<!-- Account drop down -->
<v:AccountDropDown Grid.ColumnSpan="2" Grid.Row="1"
IsEnabled="{Binding $parent.DataContext.AccountDropDownVisible}"
DataContext="{Binding AccountDropDown}" />
</Grid>
</DockPanel>
</Panel>
<Panel DockPanel.Dock="Top" Classes="GoldLineHorizontal" />
<Grid>
<!-- Main tabbed layout when logged in -->
<TabControl IsVisible="{Binding LoggedIn}" ItemsSource="{Binding Tabs}" TabStripPlacement="Bottom"
SelectedIndex="{Binding SelectedIndex,Mode=TwoWay}" Margin="0 4 0 0">
<TabControl.ItemTemplate>
<DataTemplate DataType="mainWindowTabs:MainWindowTabViewModel">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
<!-- Login interface when not logged in -->
<v:MainWindowLogin
IsVisible="{Binding !$parent.DataContext.LoggedIn}"
DataContext="{Binding LoginViewModel}" />
</Grid>
</DockPanel>

<ContentControl Classes="OverlayBox"
IsVisible="{Binding LoginViewModel.Screen.OverlayControl, Converter={x:Static ObjectConverters.IsNotNull}}">
<ContentControl Content="{Binding LoginViewModel.Screen.OverlayControl}" />
</ContentControl>

<ContentControl Classes="OverlayBox" IsVisible="{Binding LoginViewModel.Screen.Busy}">
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<Viewbox Classes="DungSpinnerBox">
<v:DungSpinner />
</Viewbox>
<TextBlock Text="{Binding LoginViewModel.Screen.BusyText}" HorizontalAlignment="Center" />
</StackPanel>
</ContentControl>

<ContentControl Classes="OverlayBox"
IsVisible="{Binding OverlayViewModel, Converter={x:Static ObjectConverters.IsNotNull}}">
<ContentControl Content="{Binding OverlayViewModel}" />
</ContentControl>

<ContentControl Classes="OverlayBox" IsVisible="{Binding BusyTask,Converter={x:Static ObjectConverters.IsNotNull}}">
<StackPanel Orientation="Vertical">
<Viewbox Classes="DungSpinnerBox">
<v:DungSpinner DockPanel.Dock="Top" />
</Viewbox>
<TextBlock Text="{Binding BusyTask}" HorizontalAlignment="Center" />
</StackPanel>
</ContentControl>

<ContentControl Classes="OverlayBox" IsVisible="{Binding OutOfDate}">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" Classes="NanoHeadingMedium" Text="{loc:Loc main-window-out-of-date}" />
<TextBlock Margin="0, 10" TextAlignment="Center"
Text="{loc:Loc main-window-out-of-date-desc}" />
<DockPanel LastChildFill="False">
<Button DockPanel.Dock="Right" Content="{loc:Loc main-window-out-of-date-exit}"
Command="{Binding ExitPressed}" />
<Button DockPanel.Dock="Left" Content="{loc:Loc main-window-out-of-date-download-manual}"
Command="{Binding DownloadPressed}" />
</DockPanel>
</StackPanel>
</ContentControl>

<!-- Yes I realize the absurdity of having literally 5 of these error overlay controls defined get off my back. -->

<ContentControl Classes="OverlayBox" IsVisible="{Binding !HasDismissedEarlyAccessWarning.Value}">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" Classes="NanoHeadingMedium"
Text="{loc:Loc main-window-early-access-title}" />
<TextBlock Margin="0, 10" TextAlignment="Center" MaxWidth="450" TextWrapping="Wrap"
Text="{loc:Loc main-window-early-access-desc}" />
<Button Content="{loc:Loc main-window-early-access-accept}" Command="{Binding DismissEarlyAccessPressed}"
HorizontalAlignment="Center" />
</StackPanel>
</ContentControl>

<!--
Literally just keep piling them on it doesn't matter.
This is way easier than coming up with some horribly over-engineered solution.
-->

<v:ConnectingOverlay DataContext="{Binding ConnectingVM}"
IsVisible="{Binding $parent.DataContext.ConnectingVM, Converter={x:Static ObjectConverters.IsNotNull}}" />

<v:AngleBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

<ContentControl Classes="OverlayBox" Name="DragDropOverlay" IsVisible="False">
<TextBlock Text="{loc:Loc main-window-drag-drop-prompt}" />
</ContentControl>

<TextBlock Text="{Binding Version}" HorizontalAlignment="Right"
VerticalAlignment="Bottom" Classes="SubText" Margin="6"/>
</Panel>
<LayoutTransformControl Name="TransformControl">
<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>

<Panel>
<DockPanel LastChildFill="true">
<!-- Header -->
<Panel DockPanel.Dock="Top">
<Panel.Background>
<SolidColorBrush Color="#212126" />
</Panel.Background>

<DockPanel Name="HeaderPanel" Classes="MainWindowHeader">
<!-- Logo -->
<Image DockPanel.Dock="Left" HorizontalAlignment="Left" Height="60" Margin="0, 0, 0, 8"
Source="{DynamicResource LogoLong}" />
<!--<v:Logo DockPanel.Dock="Left" Height="60" HorizontalAlignment="Left" Margin="0, 8"></v:Logo>-->
<Grid DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Center"
ColumnDefinitions="Auto, Auto" RowDefinitions="Auto, Auto" Margin="0, 0, 3, 0">
<!-- Discord link -->
<Button Grid.Row="0" Grid.Column="0" MinWidth="90"
Command="{Binding OnDiscordButtonPressed}" Classes="OpenBoth"
Margin="0, 6, 2, 2">
<v:IconLabel Icon="{DynamicResource InfoIcon-discord}"
Content="{loc:Loc main-window-header-link-discord}" />
</Button>

<!-- Website link -->
<Button Grid.Row="0" Grid.Column="1" MinWidth="90"
Command="{Binding OnWebsiteButtonPressed}" Classes="OpenLeft"
Margin="0, 6, 0, 2">
<v:IconLabel Icon="{DynamicResource InfoIcon-web}" Content="{loc:Loc main-window-header-link-website}" />
</Button>

<!-- Account drop down -->
<v:AccountDropDown Grid.ColumnSpan="2" Grid.Row="1"
IsEnabled="{Binding $parent.DataContext.AccountDropDownVisible}"
DataContext="{Binding AccountDropDown}" />
</Grid>
</DockPanel>
</Panel>
<Panel DockPanel.Dock="Top" Classes="GoldLineHorizontal" />
<Grid>
<!-- Main tabbed layout when logged in -->
<TabControl IsVisible="{Binding LoggedIn}" ItemsSource="{Binding Tabs}" TabStripPlacement="Bottom"
SelectedIndex="{Binding SelectedIndex,Mode=TwoWay}" Margin="0 4 0 0">
<TabControl.ItemTemplate>
<DataTemplate DataType="mainWindowTabs:MainWindowTabViewModel">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
<!-- Login interface when not logged in -->
<v:MainWindowLogin
IsVisible="{Binding !$parent.DataContext.LoggedIn}"
DataContext="{Binding LoginViewModel}" />
</Grid>
</DockPanel>

<ContentControl Classes="OverlayBox"
IsVisible="{Binding LoginViewModel.Screen.OverlayControl, Converter={x:Static ObjectConverters.IsNotNull}}">
<ContentControl Content="{Binding LoginViewModel.Screen.OverlayControl}" />
</ContentControl>

<ContentControl Classes="OverlayBox" IsVisible="{Binding LoginViewModel.Screen.Busy}">
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
<Viewbox Classes="DungSpinnerBox">
<v:DungSpinner />
</Viewbox>
<TextBlock Text="{Binding LoginViewModel.Screen.BusyText}" HorizontalAlignment="Center" />
</StackPanel>
</ContentControl>

<ContentControl Classes="OverlayBox"
IsVisible="{Binding OverlayViewModel, Converter={x:Static ObjectConverters.IsNotNull}}">
<ContentControl Content="{Binding OverlayViewModel}" />
</ContentControl>

<ContentControl Classes="OverlayBox" IsVisible="{Binding BusyTask,Converter={x:Static ObjectConverters.IsNotNull}}">
<StackPanel Orientation="Vertical">
<Viewbox Classes="DungSpinnerBox">
<v:DungSpinner DockPanel.Dock="Top" />
</Viewbox>
<TextBlock Text="{Binding BusyTask}" HorizontalAlignment="Center" />
</StackPanel>
</ContentControl>

<ContentControl Classes="OverlayBox" IsVisible="{Binding OutOfDate}">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" Classes="NanoHeadingMedium" Text="{loc:Loc main-window-out-of-date}" />
<TextBlock Margin="0, 10" TextAlignment="Center"
Text="{loc:Loc main-window-out-of-date-desc}" />
<DockPanel LastChildFill="False">
<Button DockPanel.Dock="Right" Content="{loc:Loc main-window-out-of-date-exit}"
Command="{Binding ExitPressed}" />
<Button DockPanel.Dock="Left" Content="{loc:Loc main-window-out-of-date-download-manual}"
Command="{Binding DownloadPressed}" />
</DockPanel>
</StackPanel>
</ContentControl>

<!-- Yes I realize the absurdity of having literally 5 of these error overlay controls defined get off my back. -->

<ContentControl Classes="OverlayBox" IsVisible="{Binding !HasDismissedEarlyAccessWarning.Value}">
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" Classes="NanoHeadingMedium"
Text="{loc:Loc main-window-early-access-title}" />
<TextBlock Margin="0, 10" TextAlignment="Center" MaxWidth="450" TextWrapping="Wrap"
Text="{loc:Loc main-window-early-access-desc}" />
<Button Content="{loc:Loc main-window-early-access-accept}" Command="{Binding DismissEarlyAccessPressed}"
HorizontalAlignment="Center" />
</StackPanel>
</ContentControl>

<!--
Literally just keep piling them on it doesn't matter.
This is way easier than coming up with some horribly over-engineered solution.
-->

<v:ConnectingOverlay DataContext="{Binding ConnectingVM}"
IsVisible="{Binding $parent.DataContext.ConnectingVM, Converter={x:Static ObjectConverters.IsNotNull}}" />

<v:AngleBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

<ContentControl Classes="OverlayBox" Name="DragDropOverlay" IsVisible="False">
<TextBlock Text="{loc:Loc main-window-drag-drop-prompt}" />
</ContentControl>

<TextBlock Text="{Binding Version}" HorizontalAlignment="Right"
VerticalAlignment="Bottom" Classes="SubText" Margin="6"/>
</Panel>
</LayoutTransformControl>
</UserControl>
Loading

0 comments on commit 9ab5567

Please sign in to comment.