remove views and settings that are no longer supporte

This commit is contained in:
vddcore 2023-01-11 20:26:28 +01:00
parent e8895a11a0
commit d75e471a0f
5 changed files with 25 additions and 376 deletions

View file

@ -14,44 +14,23 @@ namespace Saradomin.Infrastructure.Services
{
private const string LegacyRemoteClientHashURL = "https://cdn.2009scape.org/2009scape.md5sum";
private const string LegacyRemoteClientExecutableURL = "https://cdn.2009scape.org/2009scape.jar";
private const string ExperimentalRemoteClientExecutableURL = "https://github.com/Pazaz/RT4-Client/releases/latest/download/rt4-client.jar";
private const string ExperimentalRemoteClientHashURL = "https://github.com/Pazaz/RT4-Client/releases/latest/download/rt4-client.jar.sha256";
private const string ExperimentalRemoteClientExecutableURL =
"https://github.com/Pazaz/RT4-Client/releases/latest/download/rt4-client.jar";
private const string ExperimentalRemoteClientHashURL =
"https://github.com/Pazaz/RT4-Client/releases/latest/download/rt4-client.jar.sha256";
private readonly ISettingsService _settingsService;
private float CurrentDownloadProgress { get; set; }
public string PreferredDownloadURL
{
get
{
return _settingsService.Launcher.ClientProfile switch
{
LauncherSettings.ClientReleaseProfile.Legacy => LegacyRemoteClientExecutableURL,
LauncherSettings.ClientReleaseProfile.Experimental => ExperimentalRemoteClientExecutableURL,
_ => throw new NotSupportedException("Unsupported client release profile.")
};
}
}
public string PreferredHashUrl
{
get
{
return _settingsService.Launcher.ClientProfile switch
{
LauncherSettings.ClientReleaseProfile.Legacy => LegacyRemoteClientHashURL,
LauncherSettings.ClientReleaseProfile.Experimental => ExperimentalRemoteClientHashURL,
_ => throw new NotSupportedException("Unsupported client release profile.")
};
}
}
public string PreferredDownloadURL => ExperimentalRemoteClientExecutableURL;
public string PreferredTargetFilePath
=> _settingsService.Launcher.ClientProfile == LauncherSettings.ClientReleaseProfile.Experimental
? CrossPlatform.Locate2009scapeExperimentalExecutable(_settingsService.Launcher.InstallationDirectory)
: CrossPlatform.Locate2009scapeLegacyExecutable(_settingsService.Launcher.InstallationDirectory);
public string PreferredHashUrl => ExperimentalRemoteClientHashURL;
public string PreferredTargetFilePath =>
CrossPlatform.Locate2009scapeExperimentalExecutable(_settingsService.Launcher.InstallationDirectory);
public event EventHandler<float> DownloadProgressChanged;
@ -69,7 +48,8 @@ namespace Saradomin.Infrastructure.Services
}
}
public async Task FetchRemoteClientExecutableAsync(CancellationToken cancellationToken, string targetPath = null)
public async Task FetchRemoteClientExecutableAsync(CancellationToken cancellationToken,
string targetPath = null)
{
CurrentDownloadProgress = 0;
@ -100,7 +80,7 @@ namespace Saradomin.Infrastructure.Services
await outFileStream.WriteAsync(data[0..dataRead], cancellationToken);
totalRead += dataRead;
CurrentDownloadProgress = totalRead / contentLength;
DownloadProgressChanged?.Invoke(this, CurrentDownloadProgress);
}
@ -109,34 +89,17 @@ namespace Saradomin.Infrastructure.Services
public async Task<string> ComputeLocalClientHashAsync(string filePath = null)
{
var isExperimental = _settingsService.Launcher.ClientProfile == LauncherSettings.ClientReleaseProfile.Experimental;
filePath ??= PreferredTargetFilePath;
if (!File.Exists(filePath))
throw new FileNotFoundException($"Unable to calculate local client hash. File '{filePath}' missing.");
await using var stream = File.OpenRead(filePath);
{
if (isExperimental)
{
var sha256 = SHA256.Create();
stream.Position = 0;
var hash = await sha256.ComputeHashAsync(stream);
return BitConverter.ToString(hash).Replace("-", string.Empty);
}
else
{
var md5 = MD5.Create();
var hash = await md5.ComputeHashAsync(stream);
var sb = new StringBuilder();
foreach (var b in hash)
sb.Append($"{b:x2}");
return sb.ToString();
}
var sha256 = SHA256.Create();
stream.Position = 0;
var hash = await sha256.ComputeHashAsync(stream);
return BitConverter.ToString(hash).Replace("-", string.Empty);
}
}
}

View file

@ -45,13 +45,9 @@ namespace Saradomin.Model.Settings.Client
[JsonPropertyName("js5_port")]
public ushort CacheServerPort { get; set; } = 43595;
[JsonPropertyName("debug")]
public DebuggingSettings Debugging { get; set; } = new();
[JsonPropertyName("customization")]
public CustomizationSettings Customization { get; set; } = new();
[Obsolete("Here for compatibility. Use LauncherSettings instead.")]
[JsonPropertyName("launcher")]
public OfficialLauncherSettings OfficialLauncher { get; set; } = new();
}

View file

@ -8,15 +8,6 @@ namespace Saradomin.Model.Settings.Launcher
{
public const string FileName = "saradomin_launcher.json";
public enum ClientReleaseProfile
{
[Description("Legacy")]
Legacy,
[Description("Experimental")]
Experimental
}
public bool PlaceCloseButtonOnLeft { get; set; } = false;
public bool ExitAfterLaunchingClient { get; set; } = true;
public bool AllowMultiboxing { get; set; } = false;
@ -29,8 +20,6 @@ namespace Saradomin.Model.Settings.Launcher
public string InstallationDirectory { get; set; } = CrossPlatform.LocateDefault2009scapeHome();
public ClientReleaseProfile ClientProfile { get; set; } = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? ClientReleaseProfile.Experimental : ClientReleaseProfile.Legacy;
protected override void OnSettingsModified(string propertyName)
{
if (propertyName == nameof(AllowMultiboxing) && AllowMultiboxing)

View file

@ -9,167 +9,7 @@
DataContext="{mvvm:DataContextSource vm:SettingsViewModel}">
<Grid Margin="0,0,2,2"
ColumnDefinitions="*,*">
<DockPanel Grid.Column="0"
IsEnabled="{Binding CanCustomize}">
<HeaderedContentControl Classes="GroupBox"
CornerRadius="6,0,0,0"
DockPanel.Dock="Top"
Header="graphics settings">
<Grid ColumnDefinitions="Auto,*">
<StackPanel Grid.Column="0"
VerticalAlignment="Center"
Orientation="Vertical">
<CheckBox Content="Mini-map smoothing"
IsChecked="{Binding Client.Customization.MiniMapSmoothingEnabled, Mode=TwoWay}" />
<CheckBox Content="Expanded render distance"
IsChecked="{Binding Client.Customization.Rendering.Technical.IncreaseRenderDistance}" />
</StackPanel>
<Grid Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
RowDefinitions="Auto,Auto,Auto">
<TextBlock Grid.Row="0"
Margin="0,0,0,2"
HorizontalAlignment="Center"
Foreground="{StaticResource DarkForegroundBrush}"
Text="Anti-aliasing quality" />
<controls:AntiAliasingSelector Grid.Row="1"
Margin="0,0,0,4"
HorizontalAlignment="Center"
AntiAliasingLevel="{Binding Client.Customization.AntiAliasingSampleCount, Mode=TwoWay}" />
</Grid>
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Classes="GroupBox"
DockPanel.Dock="Top"
Header="right-click menu settings">
<Grid Margin="2,4,0,4"
ColumnDefinitions="*,*"
RowDefinitions="Auto,Auto,Auto,Auto">
<StackPanel Grid.Column="0"
Margin="0,0,4,0"
Orientation="Vertical">
<CheckBox Margin="-2,0,0,0"
Content="Use RS3-style menu border"
IsChecked="{Binding Client.Customization.RightClickMenu.Styles.UseRuneScape3Border, Mode=TwoWay}" />
<controls:ColorSpinner Margin="0,0,0,4"
HorizontalAlignment="Right"
Header="Background color"
TargetColor="{Binding Client.Customization.RightClickMenu.Background.BackgroundColor, Mode=TwoWay}" />
<controls:ColorSpinner Margin="0,0,0,4"
HorizontalAlignment="Right"
Header="Title bar color"
TargetColor="{Binding Client.Customization.RightClickMenu.TitleBar.BackgroundColor, Mode=TwoWay}" />
<controls:ColorSpinner Margin="0,0,0,4"
HorizontalAlignment="Right"
EnableAlphaSpinner="False"
Header="Title text color"
TargetColor="{Binding Client.Customization.RightClickMenu.TitleBar.ForegroundColor, Mode=TwoWay}" />
<controls:ColorSpinner Margin="0,0,0,2"
HorizontalAlignment="Right"
Header="Border color"
TargetColor="{Binding Client.Customization.RightClickMenu.Border.BackgroundColor, Mode=TwoWay}" />
</StackPanel>
<StackPanel Grid.RowSpan="3"
Grid.Column="1"
Margin="0,66,0,0">
<Border VerticalAlignment="Center"
BorderBrush="{StaticResource DarkBorderBrush}"
BorderThickness="1">
<Grid>
<Image Width="150"
Height="160"
Margin="1"
Source="avares://Saradomin/Resources/Images/previewbg.png"
Stretch="Fill" />
<controls:MenuPreview Name="MenuPreview"
Width="130"
VerticalAlignment="Center"
BackgroundColor="{Binding Client.Customization.RightClickMenu.Background.BackgroundColor.Brush}"
BorderColor="{Binding Client.Customization.RightClickMenu.Border.BackgroundColor.Brush}"
TitleBarColor="{Binding Client.Customization.RightClickMenu.TitleBar.BackgroundColor.Brush}"
TitleFontColor="{Binding Client.Customization.RightClickMenu.TitleBar.ForegroundColor.Brush}"
UseRs3Border="{Binding Client.Customization.RightClickMenu.Styles.UseRuneScape3Border}" />
</Grid>
</Border>
<Button HorizontalAlignment="Center"
Classes="Hyperlink"
Command="{Binding ResetRightClickMenu}"
Content="reset colors" />
</StackPanel>
</Grid>
</HeaderedContentControl>
<HeaderedContentControl HorizontalAlignment="Stretch"
Classes="GroupBox"
DockPanel.Dock="Left"
Header="debugging settings">
<Grid ColumnDefinitions="Auto,Auto">
<StackPanel Grid.Column="0"
Orientation="Vertical">
<CheckBox Content="Show item IDs"
IsChecked="{Binding Client.Debugging.ItemDebuggingEnabled, Mode=TwoWay}" />
<CheckBox Content="Show object IDs"
IsChecked="{Binding Client.Debugging.ObjectDebuggingEnabled, Mode=TwoWay}" />
<CheckBox Content="Show NPC IDs"
IsChecked="{Binding Client.Debugging.NpcDebuggingEnabled, Mode=TwoWay}" />
</StackPanel>
<StackPanel Grid.Column="1"
Margin="8,0,0,0"
Orientation="Vertical">
<CheckBox Content="Enable login screen debugging"
IsChecked="{Binding Client.Debugging.HdLoginRegionDebuggingEnabled, Mode=TwoWay}" />
<CheckBox Margin="18,0,0,0"
Content="Verbose?"
IsChecked="{Binding Client.Debugging.HdLoginRegionVerboseDebuggingEnabled, Mode=TwoWay}"
IsVisible="{Binding Client.Debugging.HdLoginRegionDebuggingEnabled, Mode=TwoWay}" />
<CheckBox Content="Enable cache debugging"
IsChecked="{Binding Client.Debugging.CacheDebuggingEnabled, Mode=TwoWay}"
ToolTip.Tip="May cause instability and crashes. Use at your own peril." />
<CheckBox Content="Enable world map debugging"
IsChecked="{Binding Client.Debugging.WorldMapDebuggingEnabled, Mode=TwoWay}" />
</StackPanel>
</Grid>
</HeaderedContentControl>
</DockPanel>
<Border Grid.Column="0"
Margin="2,2,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{StaticResource DarkTranslucentBackgroundBrush}"
CornerRadius="6,0,0,0"
IsVisible="{Binding !CanCustomize, Mode=TwoWay}"
ZIndex="9">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="avares://Saradomin/Resources/Fonts/runescape_uf.ttf#RuneScape UF"
FontSize="16"
Text="Disabled: Experimental client chosen" />
</Border>
<DockPanel Grid.Column="1">
<DockPanel Grid.Column="0">
<HeaderedContentControl Classes="GroupBox"
DockPanel.Dock="Top"
Header="launcher settings">
@ -275,144 +115,11 @@
</ComboBox.Styles>
</ComboBox>
</Grid>
<Grid Margin="0,0,0,4"
RowDefinitions="Auto, Auto">
<TextBlock Grid.Row="0"
Margin="3,0,0,2"
HorizontalAlignment="Left"
Foreground="{StaticResource DarkForegroundBrush}"
Text="Client profile" />
<ComboBox Grid.Row="1"
Margin="2,0,0,2"
Items="{Binding ClientProfiles}"
SelectedItem="{Binding Launcher.ClientProfile, Converter={StaticResource EnumDescriptionConverter}, Mode=TwoWay}" />
<Button HorizontalAlignment="Center"
Classes="Hyperlink"
Command="{Binding OpenPluginTutorial}"
Content="How Do I Install Plugins?"
IsVisible="{Binding !CanCustomize}" />
</Grid>
</StackPanel>
</HeaderedContentControl>
</DockPanel>
<Grid DockPanel.Dock="Top">
<Border Margin="2,2,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{StaticResource DarkTranslucentBackgroundBrush}"
IsVisible="{Binding !CanCustomize, Mode=TwoWay}"
ZIndex="9">
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="avares://Saradomin/Resources/Fonts/runescape_uf.ttf#RuneScape UF"
FontSize="16"
Text="Disabled: Experimental client chosen" />
</Border>
<HeaderedContentControl Classes="GroupBox"
DockPanel.Dock="Top"
Header="interface settings"
IsEnabled="{Binding CanCustomize}">
<StackPanel Orientation="Vertical">
<Grid Margin="2,2,2,4"
RowDefinitions="Auto,Auto">
<TextBlock Grid.Row="0"
Margin="0,0,0,2"
Foreground="{StaticResource DarkForegroundBrush}"
Text="Main menu song" />
<!-- Workaround applies here. Check SettingsViewModel for details. -->
<ComboBox Grid.Row="1"
Items="{Binding MusicTitles}"
SelectedItem="{Binding LoginMusicTheme, Mode=TwoWay}"
VirtualizationMode="Simple" />
</Grid>
<CheckBox Content="Enable winter season features"
IsChecked="{Binding Client.Customization.SnowSeasonFeaturesEnabled, Mode=TwoWay}"
IsEnabled="{Binding !CanCustomize}" />
<CheckBox Content="Left-click attack on entities above your combat level"
IsChecked="{Binding Client.Customization.RightClickMenu.AttackStrongerEntitiesWithLeftClick, Mode=TwoWay}" />
<StackPanel>
<CheckBox Content="Enable Slayer tracker"
IsChecked="{Binding Client.Customization.SlayerTracker.IsEnabled}" />
<Grid Margin="0,0,2,0"
ColumnDefinitions="*,Auto"
IsVisible="{Binding Client.Customization.SlayerTracker.IsEnabled}">
<controls:ColorSpinner Grid.Column="0"
Margin="2,0,0,0"
Header="Background color"
TargetColor="{Binding Client.Customization.SlayerTracker.BackgroundColor, Mode=TwoWay}" />
<StackPanel Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center">
<Border BorderBrush="{StaticResource DarkBorderBrush}"
BorderThickness="1">
<Grid>
<Image Width="110"
Height="60"
Margin="1"
Source="avares://Saradomin/Resources/Images/previewbg.png"
Stretch="None">
<Image.Clip>
<RectangleGeometry Rect="0,0,110,60" />
</Image.Clip>
</Image>
<controls:SlayerPreview Width="90"
Height="40"
VerticalAlignment="Center"
BackgroundColor="{Binding Client.Customization.SlayerTracker.BackgroundColor}" />
</Grid>
</Border>
<Button HorizontalAlignment="Center"
Classes="Hyperlink"
Command="{Binding ResetSlayerTracker}"
Content="reset colors" />
</StackPanel>
</Grid>
</StackPanel>
<CheckBox Content="Enable XP tracker"
IsChecked="{Binding Client.Customization.XpTracker.IsEnabled, Mode=TwoWay}" />
<Grid Margin="2,0,1,4"
ColumnDefinitions="*,*"
IsVisible="{Binding Client.Customization.XpTracker.IsEnabled}">
<Grid Grid.Column="0"
Margin="0,0,4,0"
RowDefinitions="Auto,Auto">
<TextBlock Grid.Row="0"
Margin="0,0,0,2"
Foreground="{StaticResource DarkForegroundBrush}"
Text="XP counting mode" />
<ComboBox Grid.Row="1"
Items="{Binding DropModes}"
SelectedItem="{Binding Client.Customization.XpTracker.DropMode, Converter={StaticResource EnumDescriptionConverter}, Mode=TwoWay}" />
</Grid>
<Grid Grid.Column="1"
RowDefinitions="Auto, Auto">
<TextBlock Grid.Row="0"
Margin="0,0,0,2"
Foreground="{StaticResource DarkForegroundBrush}"
Text="XP tracking mode" />
<ComboBox Grid.Row="1"
Items="{Binding TrackingModes}"
SelectedItem="{Binding Client.Customization.XpTracker.TrackingMode, Converter={StaticResource EnumDescriptionConverter}, Mode=TwoWay}" />
</Grid>
</Grid>
</StackPanel>
</HeaderedContentControl>
</Grid>
<DockPanel Grid.Column="1">
<HeaderedContentControl Margin="2,2,0,0"
Classes="GroupBox"
DockPanel.Dock="Top"

View file

@ -26,7 +26,7 @@ namespace Saradomin.ViewModel.Controls
public LauncherSettings Launcher => _settingsService.Launcher;
public ClientSettings Client => _settingsService.Client;
public bool CanCustomize => Launcher.ClientProfile == LauncherSettings.ClientReleaseProfile.Legacy;
public bool CanCustomize => false;
public string VersionString
{
@ -101,12 +101,6 @@ namespace Saradomin.ViewModel.Controls
ClientSettings.ServerProfile.Local.ToDescription()
};
public ObservableCollection<EnumDescription> ClientProfiles { get; private set; } = new()
{
LauncherSettings.ClientReleaseProfile.Legacy.ToDescription(),
LauncherSettings.ClientReleaseProfile.Experimental.ToDescription()
};
public SettingsViewModel(ISettingsService settingsService)
{
_settingsService = settingsService;