This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
405 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Ryujinx.Ava.Ui.ViewModels; | ||
using System; | ||
|
||
namespace Ryujinx.Ava.Ui.Models | ||
{ | ||
public class CheatModel : BaseModel | ||
{ | ||
private bool _isEnabled; | ||
|
||
public event EventHandler<bool> EnableToggled; | ||
|
||
public CheatModel(string name, string buildId, bool isEnabled) | ||
{ | ||
Name = name; | ||
BuildId = buildId; | ||
IsEnabled = isEnabled; | ||
} | ||
|
||
public bool IsEnabled | ||
{ | ||
get => _isEnabled; set | ||
{ | ||
_isEnabled = value; | ||
EnableToggled?.Invoke(this, _isEnabled); | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public string BuildId { get; } | ||
|
||
public string BuildIdKey => $"{BuildId}-{Name}"; | ||
public string Name { get; } | ||
|
||
public string CleanName => Name.Substring(1, Name.Length - 8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Avalonia.Collections; | ||
using DynamicData.Binding; | ||
using System.Collections.ObjectModel; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
|
||
namespace Ryujinx.Ava.Ui.Models | ||
{ | ||
public class CheatsList : ObservableCollection<CheatModel> | ||
{ | ||
public CheatsList(string buildId, string path) | ||
{ | ||
BuildId = buildId; | ||
Path = path; | ||
this.CollectionChanged += CheatsList_CollectionChanged; | ||
} | ||
|
||
private void CheatsList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | ||
{ | ||
if(e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) | ||
{ | ||
(e.NewItems[0] as CheatModel).EnableToggled += Item_EnableToggled; | ||
} | ||
} | ||
|
||
private void Item_EnableToggled(object sender, bool e) | ||
{ | ||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); | ||
} | ||
|
||
public string BuildId { get; } | ||
public string Path { get; } | ||
|
||
public bool IsEnabled | ||
{ | ||
get | ||
{ | ||
return this.ToList().TrueForAll(x => x.IsEnabled); | ||
} | ||
set | ||
{ | ||
foreach (var cheat in this) | ||
{ | ||
cheat.IsEnabled = value; | ||
} | ||
|
||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled))); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<Window xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale" | ||
xmlns:model="clr-namespace:Ryujinx.Ava.Ui.Models" | ||
mc:Ignorable="d" | ||
x:Class="Ryujinx.Ava.Ui.Windows.CheatWindow" | ||
Width="550" | ||
Height="640" | ||
MinWidth="550" | ||
MinHeight="250" | ||
d:DesignHeight="640" | ||
d:DesignWidth="550" | ||
CanResize="False" | ||
WindowStartupLocation="CenterOwner" | ||
Title="CheatWindow"> | ||
<Window.Styles> | ||
<Style Selector="TreeViewItem"> | ||
<Setter Property="IsExpanded" Value="True" /> | ||
</Style> | ||
</Window.Styles> | ||
<Grid Name="DlcGrid" Margin="15"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<TextBlock | ||
Grid.Row="0" | ||
Margin="20,15,20,20" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Text="{Binding Heading}" | ||
TextAlignment="Center" /> | ||
<Border | ||
Grid.Row="1" | ||
Margin="5" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
BorderBrush="Gray" | ||
BorderThickness="1"> | ||
<TreeView Items="{Binding LoadedCheats}" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
Name="CheatsView" | ||
MinHeight="300"> | ||
<TreeView.DataTemplates> | ||
<TreeDataTemplate DataType="model:CheatsList" ItemsSource="{Binding}"> | ||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal"> | ||
<CheckBox IsChecked="{Binding IsEnabled}" MinWidth="20" /> | ||
<TextBlock Width="150" | ||
Text="{Binding BuildId}" /> | ||
<TextBlock | ||
Text="{Binding Path}" /> | ||
</StackPanel> | ||
</TreeDataTemplate> | ||
<DataTemplate x:DataType="model:CheatModel"> | ||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> | ||
<CheckBox IsChecked="{Binding IsEnabled}" MinWidth="20" /> | ||
<TextBlock Text="{Binding CleanName}" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</TreeView.DataTemplates> | ||
</TreeView> | ||
</Border> | ||
<DockPanel | ||
Grid.Row="2" | ||
Margin="0" | ||
HorizontalAlignment="Stretch"> | ||
<DockPanel Margin="0" HorizontalAlignment="Right"> | ||
<Button | ||
Name="SaveButton" | ||
MinWidth="90" | ||
Margin="5" | ||
IsVisible="{Binding !NoCheatsFound}" | ||
Command="{Binding Save}"> | ||
<TextBlock Text="{locale:Locale SettingsButtonSave}" /> | ||
</Button> | ||
<Button | ||
Name="CancelButton" | ||
MinWidth="90" | ||
Margin="5" | ||
Command="{Binding Close}"> | ||
<TextBlock Text="{locale:Locale InputDialogCancel}" /> | ||
</Button> | ||
</DockPanel> | ||
</DockPanel> | ||
</Grid> | ||
</Window> |
Oops, something went wrong.