It builds

This commit is contained in:
Isaac Marovitz 2023-05-18 14:30:25 -04:00 committed by Isaac Marovitz
parent 281a078773
commit d224996c15
7 changed files with 47 additions and 46 deletions

View file

@ -39,17 +39,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
} }
} }
private bool _showSettings;
public bool ShowSettings
{
get => _showSettings;
set
{
_showSettings = value;
OnPropertyChanged();
}
}
private SvgImage _image; private SvgImage _image;
public SvgImage Image public SvgImage Image
{ {
@ -70,5 +59,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
await RumbleInputView.Show(this); await RumbleInputView.Show(this);
} }
public ControllerInputViewModel(InputViewModel model, ControllerInputConfig config)
{
IsLeft = model.IsLeft;
IsRight = model.IsRight;
Image = model.Image;
Config = config;
}
} }
} }

View file

@ -47,7 +47,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private int _controllerNumber = 0; private int _controllerNumber = 0;
private string _controllerImage; private string _controllerImage;
private int _device; private int _device;
private object _configuration; private object _configViewModel;
private string _profileName; private string _profileName;
private bool _isLoaded; private bool _isLoaded;
private readonly UserControl _owner; private readonly UserControl _owner;
@ -72,12 +72,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public bool IsModified { get; set; } public bool IsModified { get; set; }
public object Configuration public object ConfigViewModel
{ {
get => _configuration; get => _configViewModel;
set set
{ {
_configuration = value; _configViewModel = value;
OnPropertyChanged(); OnPropertyChanged();
} }
@ -286,12 +286,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
if (Config is StandardKeyboardInputConfig keyboardInputConfig) if (Config is StandardKeyboardInputConfig keyboardInputConfig)
{ {
Configuration = new KeyboardInputConfig(keyboardInputConfig); ConfigViewModel = new KeyboardInputViewModel(this, new KeyboardInputConfig(keyboardInputConfig));
} }
if (Config is StandardControllerInputConfig controllerInputConfig) if (Config is StandardControllerInputConfig controllerInputConfig)
{ {
Configuration = new ControllerInputConfig(controllerInputConfig); ConfigViewModel = new ControllerInputViewModel(this, new ControllerInputConfig(controllerInputConfig));
} }
} }
@ -733,7 +733,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
return; return;
} }
if (Configuration == null) if (ConfigViewModel == null)
{ {
return; return;
} }
@ -756,11 +756,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
if (IsKeyboard) if (IsKeyboard)
{ {
config = (Configuration as KeyboardInputConfig).GetConfig(); config = (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig();
} }
else if (IsController) else if (IsController)
{ {
config = (Configuration as ControllerInputConfig).GetConfig(); config = (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
} }
config.ControllerType = Controllers[_controller].Type; config.ControllerType = Controllers[_controller].Type;
@ -825,18 +825,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
if (device.Type == DeviceType.Keyboard) if (device.Type == DeviceType.Keyboard)
{ {
var inputConfig = Configuration as KeyboardInputConfig; var inputConfig = (ConfigViewModel as KeyboardInputViewModel).Config;
inputConfig.Id = device.Id; inputConfig.Id = device.Id;
} }
else else
{ {
var inputConfig = Configuration as ControllerInputConfig; var inputConfig = (ConfigViewModel as ControllerInputViewModel).Config;
inputConfig.Id = device.Id.Split(" ")[0]; inputConfig.Id = device.Id.Split(" ")[0];
} }
var config = !IsController var config = !IsController
? (Configuration as KeyboardInputConfig).GetConfig() ? (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig()
: (Configuration as ControllerInputConfig).GetConfig(); : (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
config.ControllerType = Controllers[_controller].Type; config.ControllerType = Controllers[_controller].Type;
config.PlayerIndex = _playerId; config.PlayerIndex = _playerId;
@ -867,7 +867,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public void NotifyChanges() public void NotifyChanges()
{ {
OnPropertyChanged(nameof(Configuration)); OnPropertyChanged(nameof(ConfigViewModel));
OnPropertyChanged(nameof(IsController)); OnPropertyChanged(nameof(IsController));
OnPropertyChanged(nameof(ShowSettings)); OnPropertyChanged(nameof(ShowSettings));
OnPropertyChanged(nameof(IsKeyboard)); OnPropertyChanged(nameof(IsKeyboard));

View file

@ -38,17 +38,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
} }
} }
private bool _showSettings;
public bool ShowSettings
{
get => _showSettings;
set
{
_showSettings = value;
OnPropertyChanged();
}
}
private SvgImage _image; private SvgImage _image;
public SvgImage Image public SvgImage Image
{ {
@ -59,5 +48,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
OnPropertyChanged(); OnPropertyChanged();
} }
} }
public KeyboardInputViewModel(InputViewModel model, KeyboardInputConfig config)
{
IsLeft = model.IsLeft;
IsRight = model.IsRight;
Image = model.Image;
Config = config;
}
} }
} }

View file

@ -35,8 +35,7 @@
<!-- Button / JoyStick Settings --> <!-- Button / JoyStick Settings -->
<Grid <Grid
Name="SettingButtons" Name="SettingButtons"
MinHeight="450" MinHeight="450">
IsVisible="{Binding ShowSettings}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
@ -451,7 +450,7 @@
<Button <Button
Margin="10" Margin="10"
Grid.Column="1" Grid.Column="1"
Command="{Binding ShowMotionConfig}"> Command="{ReflectionBinding ShowMotionConfig}">
<TextBlock Text="{locale:Locale ControllerSettingsConfigureGeneral}" /> <TextBlock Text="{locale:Locale ControllerSettingsConfigureGeneral}" />
</Button> </Button>
</Grid> </Grid>
@ -477,7 +476,7 @@
<Button <Button
Margin="10" Margin="10"
Grid.Column="1" Grid.Column="1"
Command="{Binding ShowRumbleConfig}"> Command="{ReflectionBinding ShowRumbleConfig}">
<TextBlock Text="{locale:Locale ControllerSettingsConfigureGeneral}" /> <TextBlock Text="{locale:Locale ControllerSettingsConfigureGeneral}" />
</Button> </Button>
</Grid> </Grid>

View file

@ -211,7 +211,15 @@
</Grid> </Grid>
</Grid> </Grid>
</StackPanel> </StackPanel>
<views:ControllerInputView IsVisible="{Binding IsController}"/> <ContentControl Content="{Binding ConfigViewModel}" IsVisible="{Binding ShowSettings}">
<views:KeyboardInputView IsVisible="{Binding !IsController}"/> <ContentControl.DataTemplates>
<DataTemplate DataType="viewModels:ControllerInputViewModel">
<views:ControllerInputView/>
</DataTemplate>
<DataTemplate DataType="viewModels:KeyboardInputViewModel">
<views:KeyboardInputView/>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View file

@ -27,14 +27,15 @@ namespace Ryujinx.Ava.UI.Views.Input
InitializeComponent(); InitializeComponent();
foreach (ILogical visual in SettingButtons.GetLogicalDescendants()) // TODO: Move this stuff to Controller/KeyboardInputView
/*foreach (ILogical visual in SettingButtons.GetLogicalDescendants())
{ {
if (visual is ToggleButton button && !(visual is CheckBox)) if (visual is ToggleButton button && !(visual is CheckBox))
{ {
button.Checked += Button_Checked; button.Checked += Button_Checked;
button.Unchecked += Button_Unchecked; button.Unchecked += Button_Unchecked;
} }
} }*/
} }
protected override void OnPointerReleased(PointerReleasedEventArgs e) protected override void OnPointerReleased(PointerReleasedEventArgs e)

View file

@ -35,8 +35,7 @@
<!-- Button / JoyStick Settings --> <!-- Button / JoyStick Settings -->
<Grid <Grid
Name="SettingButtons" Name="SettingButtons"
MinHeight="450" MinHeight="450">
IsVisible="{Binding ShowSettings}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />