Move ReShade folder to Integrations

Also adjusted design of ReShade settings in menu, and moved Screenshots folder to Pictures folder.
This commit is contained in:
pizzaboxer 2023-02-03 20:44:28 +00:00
parent 6fa7a73ac7
commit 02727cc751
5 changed files with 57 additions and 51 deletions

View File

@ -7,9 +7,10 @@ namespace Bloxstrap.Helpers
{ {
// note that these are directories that aren't tethered to the basedirectory // note that these are directories that aren't tethered to the basedirectory
// so these can safely be called before initialization // so these can safely be called before initialization
public static string LocalAppData { get => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); } public static string LocalAppData => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
public static string Desktop { get => Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); } public static string Desktop => Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
public static string StartMenu { get => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", App.ProjectName); } public static string StartMenu => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", App.ProjectName);
public static string MyPictures => Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
public static string Base { get; private set; } = ""; public static string Base { get; private set; } = "";
public static string Downloads { get; private set; } = ""; public static string Downloads { get; private set; } = "";
@ -17,11 +18,10 @@ namespace Bloxstrap.Helpers
public static string Versions { get; private set; } = ""; public static string Versions { get; private set; } = "";
public static string Modifications { get; private set; } = ""; public static string Modifications { get; private set; } = "";
public static string Updates { get; private set; } = ""; public static string Updates { get; private set; } = "";
public static string ReShade { get; private set; } = "";
public static string Application { get; private set; } = ""; public static string Application { get; private set; } = "";
public static bool Initialized { get => String.IsNullOrEmpty(Base); } public static bool Initialized => String.IsNullOrEmpty(Base);
public static void Initialize(string baseDirectory) public static void Initialize(string baseDirectory)
{ {
@ -31,7 +31,6 @@ namespace Bloxstrap.Helpers
Versions = Path.Combine(Base, "Versions"); Versions = Path.Combine(Base, "Versions");
Modifications = Path.Combine(Base, "Modifications"); Modifications = Path.Combine(Base, "Modifications");
Updates = Path.Combine(Base, "Updates"); Updates = Path.Combine(Base, "Updates");
ReShade = Path.Combine(Base, "ReShade");
Application = Path.Combine(Base, $"{App.ProjectName}.exe"); Application = Path.Combine(Base, $"{App.ProjectName}.exe");
} }

View File

@ -25,9 +25,12 @@ namespace Bloxstrap.Helpers.Integrations
// and here we're effectively choosing for the user... hm... // and here we're effectively choosing for the user... hm...
// i mean, it should be fine? importing shaders is still gonna be a thing, though maybe not as simple, but most people would be looking to use extravi's presets anyway // i mean, it should be fine? importing shaders is still gonna be a thing, though maybe not as simple, but most people would be looking to use extravi's presets anyway
private static string ShadersFolder { get => Path.Combine(Directories.ReShade, "Shaders"); } private static string BaseDirectory => Path.Combine(Directories.Integrations, "ReShade");
private static string TexturesFolder { get => Path.Combine(Directories.ReShade, "Textures"); } private static string FontsFolder => Path.Combine(BaseDirectory, "Fonts");
private static string ConfigLocation { get => Path.Combine(Directories.Modifications, "ReShade.ini"); } private static string PresetsFolder => Path.Combine(BaseDirectory, "Presets");
private static string ShadersFolder => Path.Combine(BaseDirectory, "Shaders");
private static string TexturesFolder => Path.Combine(BaseDirectory, "Textures");
private static string ConfigLocation => Path.Combine(Directories.Modifications, "ReShade.ini");
// the base url that we're fetching all our remote configs and resources and stuff from // the base url that we're fetching all our remote configs and resources and stuff from
private const string BaseUrl = "https://raw.githubusercontent.com/Extravi/extravi.github.io/main/update"; private const string BaseUrl = "https://raw.githubusercontent.com/Extravi/extravi.github.io/main/update";
@ -61,7 +64,7 @@ namespace Bloxstrap.Helpers.Integrations
private static string GetSearchPath(string type, string name) private static string GetSearchPath(string type, string name)
{ {
return $",..\\..\\ReShade\\{type}\\{name}"; return $",..\\..\\Integrations\\ReShade\\{type}\\{name}";
} }
public static async Task DownloadConfig() public static async Task DownloadConfig()
@ -75,7 +78,7 @@ namespace Bloxstrap.Helpers.Integrations
using ZipArchive archive = new(zipStream); using ZipArchive archive = new(zipStream);
archive.Entries.Where(x => x.FullName == "ReShade.ini").First().ExtractToFile(ConfigLocation, true); archive.Entries.First(x => x.FullName == "ReShade.ini").ExtractToFile(ConfigLocation, true);
// when we extract the file we have to make sure the last modified date is overwritten // when we extract the file we have to make sure the last modified date is overwritten
// or else it will synchronize with the config in the version folder // or else it will synchronize with the config in the version folder
@ -84,7 +87,7 @@ namespace Bloxstrap.Helpers.Integrations
// we also gotta download the editor fonts // we also gotta download the editor fonts
foreach (ZipArchiveEntry entry in archive.Entries.Where(x => x.FullName.EndsWith(".ttf"))) foreach (ZipArchiveEntry entry in archive.Entries.Where(x => x.FullName.EndsWith(".ttf")))
entry.ExtractToFile(Path.Combine(Directories.ReShade, "Fonts", entry.FullName), true); entry.ExtractToFile(Path.Combine(FontsFolder, entry.FullName), true);
} }
// now we have to adjust the config file to use the paths that we need // now we have to adjust the config file to use the paths that we need
@ -93,12 +96,13 @@ namespace Bloxstrap.Helpers.Integrations
FileIniDataParser parser = new(); FileIniDataParser parser = new();
IniData data = parser.ReadFile(ConfigLocation); IniData data = parser.ReadFile(ConfigLocation);
data["GENERAL"]["EffectSearchPaths"] = "..\\..\\ReShade\\Shaders"; data["GENERAL"]["EffectSearchPaths"] = "..\\..\\Integrations\\ReShade\\Shaders";
data["GENERAL"]["TextureSearchPaths"] = "..\\..\\ReShade\\Textures"; data["GENERAL"]["TextureSearchPaths"] = "..\\..\\Integrations\\ReShade\\Textures";
data["GENERAL"]["PresetPath"] = data["GENERAL"]["PresetPath"].Replace(".\\reshade-presets\\", "..\\..\\ReShade\\Presets\\"); data["GENERAL"]["PresetPath"] = data["GENERAL"]["PresetPath"].Replace(".\\reshade-presets\\", "..\\..\\Integrations\\ReShade\\Presets\\");
data["SCREENSHOT"]["SavePath"] = "..\\..\\ReShade\\Screenshots"; //data["SCREENSHOT"]["SavePath"] = "..\\..\\ReShade\\Screenshots";
data["STYLE"]["EditorFont"] = data["STYLE"]["EditorFont"].Replace(".\\", "..\\..\\ReShade\\Fonts\\"); data["SCREENSHOT"]["SavePath"] = Path.Combine(Directories.MyPictures, "Roblox-ReShade");
data["STYLE"]["Font"] = data["STYLE"]["Font"].Replace(".\\", "..\\..\\ReShade\\Fonts\\"); data["STYLE"]["EditorFont"] = data["STYLE"]["EditorFont"].Replace(".\\", "..\\..\\Integrations\\ReShade\\Fonts\\");
data["STYLE"]["Font"] = data["STYLE"]["Font"].Replace(".\\", "..\\..\\Integrations\\ReShade\\Fonts\\");
// add search paths for shaders and textures // add search paths for shaders and textures
@ -170,7 +174,7 @@ namespace Bloxstrap.Helpers.Integrations
string downloadUrl = Shaders.First(x => x.Key == name).Value; string downloadUrl = Shaders.First(x => x.Key == name).Value;
// not all shader packs have a textures folder, so here we're determining if they exist purely based on if they have a Shaders folder // not all shader packs have a textures folder, so here we're determining if they exist purely based on if they have a Shaders folder
if (Directory.Exists(Path.Combine(Directories.ReShade, "Shaders", name))) if (Directory.Exists(Path.Combine(ShadersFolder, name)))
return; return;
Debug.WriteLine($"[ReShade] Downloading shaders for {name}"); Debug.WriteLine($"[ReShade] Downloading shaders for {name}");
@ -204,7 +208,7 @@ namespace Bloxstrap.Helpers.Integrations
// now we stitch it all together // now we stitch it all together
string extractionPath = Path.Combine( string extractionPath = Path.Combine(
Directories.ReShade, BaseDirectory,
fullPath.StartsWith("Shaders") ? "Shaders" : "Textures", fullPath.StartsWith("Shaders") ? "Shaders" : "Textures",
name, name,
relativePath relativePath
@ -226,7 +230,7 @@ namespace Bloxstrap.Helpers.Integrations
data["GENERAL"]["EffectSearchPaths"] += GetSearchPath("Shaders", name); data["GENERAL"]["EffectSearchPaths"] += GetSearchPath("Shaders", name);
// not every shader pack has a textures folder // not every shader pack has a textures folder
if (Directory.Exists(Path.Combine(Directories.ReShade, "Textures", name)) && !data["GENERAL"]["TextureSearchPaths"].Contains(name)) if (Directory.Exists(Path.Combine(TexturesFolder, name)) && !data["GENERAL"]["TextureSearchPaths"].Contains(name))
data["GENERAL"]["TextureSearchPaths"] += GetSearchPath("Textures", name); data["GENERAL"]["TextureSearchPaths"] += GetSearchPath("Textures", name);
parser.WriteFile(ConfigLocation, data); parser.WriteFile(ConfigLocation, data);
@ -236,8 +240,8 @@ namespace Bloxstrap.Helpers.Integrations
{ {
Debug.WriteLine($"[ReShade] Deleting shaders for {name}"); Debug.WriteLine($"[ReShade] Deleting shaders for {name}");
string shadersPath = Path.Combine(Directories.ReShade, "Shaders", name); string shadersPath = Path.Combine(ShadersFolder, name);
string texturesPath = Path.Combine(Directories.ReShade, "Textures", name); string texturesPath = Path.Combine(TexturesFolder, name);
if (Directory.Exists(shadersPath)) if (Directory.Exists(shadersPath))
Directory.Delete(shadersPath, true); Directory.Delete(shadersPath, true);
@ -290,7 +294,7 @@ namespace Bloxstrap.Helpers.Integrations
// remove containing folder // remove containing folder
string filename = entry.FullName.Substring(entry.FullName.IndexOf('/') + 1); string filename = entry.FullName.Substring(entry.FullName.IndexOf('/') + 1);
await Task.Run(() => entry.ExtractToFile(Path.Combine(Directories.ReShade, "Presets", filename), true)); await Task.Run(() => entry.ExtractToFile(Path.Combine(PresetsFolder, filename), true));
} }
} }
@ -298,7 +302,7 @@ namespace Bloxstrap.Helpers.Integrations
{ {
Debug.WriteLine("[ReShade] Uninstalling Extravi's presets..."); Debug.WriteLine("[ReShade] Uninstalling Extravi's presets...");
FileInfo[] presets = new DirectoryInfo(Path.Combine(Directories.ReShade, "Presets")).GetFiles(); FileInfo[] presets = new DirectoryInfo(PresetsFolder).GetFiles();
foreach (FileInfo preset in presets) foreach (FileInfo preset in presets)
{ {
@ -316,14 +320,6 @@ namespace Bloxstrap.Helpers.Integrations
string injectorLocation = Path.Combine(Directories.Modifications, "dxgi.dll"); string injectorLocation = Path.Combine(Directories.Modifications, "dxgi.dll");
// initialize directories
Directory.CreateDirectory(Directories.ReShade);
Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Fonts"));
Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Screenshots"));
Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Shaders"));
Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Textures"));
Directory.CreateDirectory(Path.Combine(Directories.ReShade, "Presets"));
if (!App.Settings.UseReShadeExtraviPresets) if (!App.Settings.UseReShadeExtraviPresets)
{ {
UninstallExtraviPresets(); UninstallExtraviPresets();
@ -340,11 +336,20 @@ namespace Bloxstrap.Helpers.Integrations
App.Settings.ReShadeConfigVersion = ""; App.Settings.ReShadeConfigVersion = "";
DeleteShaders("Stock"); //DeleteShaders("Stock");
if (Directory.Exists(BaseDirectory))
Directory.Delete(BaseDirectory, true);
return; return;
} }
// initialize directories
Directory.CreateDirectory(BaseDirectory);
Directory.CreateDirectory(FontsFolder);
Directory.CreateDirectory(ShadersFolder);
Directory.CreateDirectory(TexturesFolder);
Directory.CreateDirectory(PresetsFolder);
// the version manfiest contains the version of reshade available for download and the last date the presets were updated // the version manfiest contains the version of reshade available for download and the last date the presets were updated
var versionManifest = await Utilities.GetJson<ReShadeVersionManifest>("https://raw.githubusercontent.com/Extravi/extravi.github.io/main/update/version.json"); var versionManifest = await Utilities.GetJson<ReShadeVersionManifest>("https://raw.githubusercontent.com/Extravi/extravi.github.io/main/update/version.json");
bool shouldFetchReShade = false; bool shouldFetchReShade = false;

View File

@ -1,12 +1,14 @@
using System.Windows; using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Mvvm.Contracts; using Wpf.Ui.Mvvm.Contracts;
using Bloxstrap.Views.Pages;
using Bloxstrap.Helpers; using Bloxstrap.Helpers;
using System.Diagnostics; using Bloxstrap.Views.Pages;
namespace Bloxstrap.ViewModels namespace Bloxstrap.ViewModels
{ {
@ -20,7 +22,7 @@ namespace Bloxstrap.ViewModels
public ICommand OpenReShadeFolderCommand => new RelayCommand(OpenReShadeFolder); public ICommand OpenReShadeFolderCommand => new RelayCommand(OpenReShadeFolder);
public ICommand ShowReShadeHelpCommand => new RelayCommand(ShowReShadeHelp); public ICommand ShowReShadeHelpCommand => new RelayCommand(ShowReShadeHelp);
public bool CanOpenReShadeFolder => !App.IsFirstRun; public bool CanOpenReShadeFolder => App.Settings.UseReShade;
public IntegrationsViewModel(Page page) public IntegrationsViewModel(Page page)
{ {
@ -29,7 +31,7 @@ namespace Bloxstrap.ViewModels
private void OpenReShadeFolder() private void OpenReShadeFolder()
{ {
Process.Start("explorer.exe", Directories.ReShade); Process.Start("explorer.exe", Path.Combine(Directories.Integrations, "ReShade"));
} }
private void ShowReShadeHelp() private void ShowReShadeHelp()

View File

@ -55,7 +55,7 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ui:CardAction Grid.Column="0" Margin="0,8,4,0" Icon="Folder24" Command="{Binding OpenReShadeFolderCommand}" IsEnabled="{Binding CanOpenReShadeFolder}"> <ui:CardAction Grid.Column="0" Margin="0,8,4,0" Icon="Folder24" Command="{Binding OpenReShadeFolderCommand}" IsEnabled="{Binding CanOpenReShadeFolder}">
<StackPanel> <StackPanel>
@ -74,10 +74,10 @@
<TextBlock FontSize="12" Foreground="{DynamicResource TextFillColorTertiaryBrush}"> <TextBlock FontSize="12" Foreground="{DynamicResource TextFillColorTertiaryBrush}">
<TextBlock.Style> <TextBlock.Style>
<Style> <Style>
<Setter Property="TextBlock.Text" Value="Shaders and screenshots are stored here."/> <Setter Property="TextBlock.Text" Value="ReShade's resources are stored here." />
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding CanOpenReShadeFolder}" Value="False"> <DataTrigger Binding="{Binding CanOpenReShadeFolder}" Value="False">
<Setter Property="TextBlock.Text" Value="Bloxstrap must first be installed." /> <Setter Property="TextBlock.Text" Value="Available once Roblox is started with ReShade." />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
@ -88,7 +88,7 @@
<ui:CardAction Grid.Column="1" Margin="4,8,0,0" Icon="BookQuestionMark24" Command="{Binding ShowReShadeHelpCommand}"> <ui:CardAction Grid.Column="1" Margin="4,8,0,0" Icon="BookQuestionMark24" Command="{Binding ShowReShadeHelpCommand}">
<StackPanel> <StackPanel>
<TextBlock FontSize="13" FontWeight="Medium" Text="Help" /> <TextBlock FontSize="13" FontWeight="Medium" Text="Help" />
<TextBlock FontSize="12" Text="See help information on using ReShade." Foreground="{DynamicResource TextFillColorTertiaryBrush}" /> <TextBlock FontSize="12" Text="See info about using ReShade." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel> </StackPanel>
</ui:CardAction> </ui:CardAction>
</Grid> </Grid>

View File

@ -12,13 +12,14 @@
<StackPanel Margin="0,0,14,14"> <StackPanel Margin="0,0,14,14">
<TextBlock Text="Keyboard Controls" FontSize="16" FontWeight="Medium" /> <TextBlock Text="Keyboard Controls" FontSize="16" FontWeight="Medium" />
<Grid Column="0" Margin="0,8,0,0"> <Grid Margin="0,8,0,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
@ -31,14 +32,13 @@
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,16,8" FontSize="14" FontWeight="Medium" Text="Take Screenshot" /> <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,16,8" FontSize="14" FontWeight="Medium" Text="Take Screenshot" />
<TextBlock Grid.Row="2" Grid.Column="1" Margin="0,0,0,8" VerticalAlignment="Bottom" Text="Print Screen" Foreground="{DynamicResource TextFillColorTertiaryBrush}" /> <TextBlock Grid.Row="2" Grid.Column="1" Margin="0,0,0,8" VerticalAlignment="Bottom" Text="Print Screen" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
<TextBlock Grid.Row="0" Grid.Column="2" Grid.RowSpan="3" Margin="32,0,0,0" TextWrapping="Wrap" Text="If you're using a laptop keyboard, you may have to hold down the Fn key when pressing F6. Any screenshots you take are saved to your pictures folder." Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
</Grid> </Grid>
<TextBlock HorizontalAlignment="Left" Margin="0,8,0,0" TextWrapping="Wrap" Text="If you're using a laptop keyboard, you may have to hold down the Fn key when pressing F6." Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<TextBlock HorizontalAlignment="Left" Margin="0,8,0,0" TextWrapping="Wrap" Text="Any screenshots you take are saved to the Screenshots folder in the ReShade folder." Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<TextBlock Text="Adding your own shaders and presets" FontSize="16" FontWeight="Medium" Margin="0,16,0,0" /> <TextBlock Text="Adding your own shaders and presets" FontSize="16" FontWeight="Medium" Margin="0,16,0,0" />
<TextBlock HorizontalAlignment="Left" Margin="0,8,0,0" TextWrapping="Wrap" Text="While Bloxstrap provides Extravi's ReShade presets as a great way to enhance Roblox's graphics, it also provides the ability to install custom shaders and presets." Foreground="{DynamicResource TextFillColorSecondaryBrush}" /> <TextBlock Margin="0,8,0,0" TextWrapping="Wrap" Text="While Bloxstrap provides Extravi's ReShade presets as a great way to enhance Roblox's graphics, it also provides the ability to install custom shaders and presets." Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<TextBlock HorizontalAlignment="Left" Margin="0,8,0,0" TextWrapping="Wrap" Text="To install custom presets, just extract the necessary .ini files to the ReShade Presets folder. Though, you may also need to add additional shaders and textures." Foreground="{DynamicResource TextFillColorSecondaryBrush}" /> <TextBlock Margin="0,8,0,0" TextWrapping="Wrap" Text="To install custom presets, just extract the necessary .ini files to the ReShade Presets folder. Though, you may also need to add additional shaders and textures." Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<TextBlock HorizontalAlignment="Left" Margin="0,8,0,0" TextWrapping="Wrap" Text="To install shaders (known as effects), extract the necessary files to the ReShade Shaders folder. The same goes for textures, where you extract them to the ReShade Textures folder. You could alternatively extract them to organized subfolders like how Bloxstrap does them, though you'll have to configure ReShade to look in those folders." Foreground="{DynamicResource TextFillColorSecondaryBrush}" /> <TextBlock Margin="0,8,0,0" TextWrapping="Wrap" Text="To install shaders (known as effects), extract the necessary files to the ReShade Shaders folder. The same goes for textures, where you extract them to the ReShade Textures folder. You could alternatively extract them to organized subfolders like how Bloxstrap does them, though you'll have to configure ReShade to look in those folders." Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
</StackPanel> </StackPanel>
</ui:UiPage> </ui:UiPage>