mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Rework converters and improve string formatting
This commit is contained in:
parent
db8edbc94f
commit
f542de5421
@ -3,7 +3,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:Bloxstrap"
|
xmlns:local="clr-namespace:Bloxstrap"
|
||||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||||
xmlns:converters="clr-namespace:Bloxstrap.Converters"
|
xmlns:converters="clr-namespace:Bloxstrap.UI.Converters"
|
||||||
ShutdownMode="OnExplicitShutdown"
|
ShutdownMode="OnExplicitShutdown"
|
||||||
DispatcherUnhandledException="GlobalExceptionHandler">
|
DispatcherUnhandledException="GlobalExceptionHandler">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
@ -16,6 +16,7 @@
|
|||||||
<FontFamily x:Key="Rubik">pack://application:,,,/Resources/Fonts/#Rubik Light</FontFamily>
|
<FontFamily x:Key="Rubik">pack://application:,,,/Resources/Fonts/#Rubik Light</FontFamily>
|
||||||
|
|
||||||
<converters:ResourceConverter x:Key="ResourceConverter" />
|
<converters:ResourceConverter x:Key="ResourceConverter" />
|
||||||
|
<converters:StringFormatConverter x:Key="StringFormatConverter" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Bloxstrap.Converters
|
namespace Bloxstrap.UI.Converters
|
||||||
{
|
{
|
||||||
internal class ResourceConverter : IValueConverter
|
internal class ResourceConverter : IValueConverter
|
||||||
{
|
{
|
||||||
@ -17,9 +17,7 @@ namespace Bloxstrap.Converters
|
|||||||
string parameterStr = parameter.ToString()!;
|
string parameterStr = parameter.ToString()!;
|
||||||
string resourceName = parameterStr + valueStr;
|
string resourceName = parameterStr + valueStr;
|
||||||
|
|
||||||
string resourceValue = Resources.Strings.ResourceManager.GetStringSafe(resourceName);
|
return Resources.Strings.ResourceManager.GetStringSafe(resourceName);
|
||||||
|
|
||||||
return resourceValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
33
Bloxstrap/UI/Converters/StringFormatConverter.cs
Normal file
33
Bloxstrap/UI/Converters/StringFormatConverter.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace Bloxstrap.UI.Converters
|
||||||
|
{
|
||||||
|
public class StringFormatConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
string? valueStr = value as string;
|
||||||
|
string? parameterStr = parameter as string;
|
||||||
|
|
||||||
|
if (valueStr is null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (parameterStr is null)
|
||||||
|
return valueStr;
|
||||||
|
|
||||||
|
string[] args = parameterStr.Split(new char[] { '|' });
|
||||||
|
|
||||||
|
return string.Format(valueStr, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException(nameof(ConvertBack));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,7 @@
|
|||||||
<controls:OptionControl
|
<controls:OptionControl
|
||||||
Header="{x:Static resources:Strings.Menu_FastFlags_Presets_Debug_HttpProxyAddress_Title}"
|
Header="{x:Static resources:Strings.Menu_FastFlags_Presets_Debug_HttpProxyAddress_Title}"
|
||||||
Description="{x:Static resources:Strings.Menu_FastFlags_Presets_Debug_HttpProxyAddress_Description}">
|
Description="{x:Static resources:Strings.Menu_FastFlags_Presets_Debug_HttpProxyAddress_Description}">
|
||||||
<ui:ToggleSwitch IsChecked="{Binding HttpRequestProxy, Mode=TwoWay}" />
|
<ui:TextBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" Text="{Binding HttpRequestProxy, Mode=TwoWay}" />
|
||||||
</controls:OptionControl>
|
</controls:OptionControl>
|
||||||
|
|
||||||
<controls:OptionControl
|
<controls:OptionControl
|
||||||
@ -59,7 +59,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock Text="{x:Static resources:Strings.Common_Presets}" FontSize="16" FontWeight="Medium" Margin="0,16,0,0" />
|
<TextBlock Text="{x:Static resources:Strings.Common_Presets}" FontSize="16" FontWeight="Medium" Margin="0,16,0,0" />
|
||||||
<controls:MarkdownTextBlock MarkdownText="{Binding Direct3DExclusiveFullscreenInfoText}"/>
|
<controls:MarkdownTextBlock MarkdownText="{Binding Source={x:Static resources:Strings.Menu_FastFlags_Presets_D3DExclusiveFullscreenInfo}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://github.com/pizzaboxer/bloxstrap/wiki/A-guide-to-FastFlags#exclusive-fullscreen'}" />
|
||||||
|
|
||||||
<controls:OptionControl
|
<controls:OptionControl
|
||||||
Header="{x:Static resources:Strings.Menu_FastFlags_Presets_FPSLimit_Title}"
|
Header="{x:Static resources:Strings.Menu_FastFlags_Presets_FPSLimit_Title}"
|
||||||
@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
<controls:OptionControl
|
<controls:OptionControl
|
||||||
Header="{x:Static resources:Strings.Menu_FastFlags_Presets_HideGuis_Title}"
|
Header="{x:Static resources:Strings.Menu_FastFlags_Presets_HideGuis_Title}"
|
||||||
Description="{Binding HideGuisDescriptionText}"
|
Description="{Binding Source={x:Static resources:Strings.Menu_FastFlags_Presets_HideGuis_Description}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://github.com/pizzaboxer/bloxstrap/wiki/A-guide-to-FastFlags#gui-hiding|https://www.roblox.com/groups/32380007/Bloxstrap'}"
|
||||||
HelpLink="https://github.com/pizzaboxer/bloxstrap/wiki/A-guide-to-FastFlags#gui-hiding">
|
HelpLink="https://github.com/pizzaboxer/bloxstrap/wiki/A-guide-to-FastFlags#gui-hiding">
|
||||||
<ui:ToggleSwitch IsChecked="{Binding GuiHidingEnabled, Mode=TwoWay}" />
|
<ui:ToggleSwitch IsChecked="{Binding GuiHidingEnabled, Mode=TwoWay}" />
|
||||||
</controls:OptionControl>
|
</controls:OptionControl>
|
||||||
|
@ -147,20 +147,5 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
get => App.FastFlags.GetPreset("UI.Hide") == "32380007";
|
get => App.FastFlags.GetPreset("UI.Hide") == "32380007";
|
||||||
set => App.FastFlags.SetPreset("UI.Hide", value ? "32380007" : null);
|
set => App.FastFlags.SetPreset("UI.Hide", value ? "32380007" : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Direct3DExclusiveFullscreenInfoText
|
|
||||||
{
|
|
||||||
get => string.Format(
|
|
||||||
Resources.Strings.Menu_FastFlags_Presets_D3DExclusiveFullscreenInfo,
|
|
||||||
"https://github.com/pizzaboxer/bloxstrap/wiki/A-guide-to-FastFlags#exclusive-fullscreen");
|
|
||||||
}
|
|
||||||
|
|
||||||
public string HideGuisDescriptionText
|
|
||||||
{
|
|
||||||
get => string.Format(
|
|
||||||
Resources.Strings.Menu_FastFlags_Presets_HideGuis_Description,
|
|
||||||
"https://github.com/pizzaboxer/bloxstrap/wiki/A-guide-to-FastFlags#gui-hiding",
|
|
||||||
"https://www.roblox.com/groups/32380007/Bloxstrap");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user