Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search bar in games list #41

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions MelonLoader.Installer/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;

namespace MelonLoader.Installer.ViewModels;

public class MainViewModel : ViewModelBase
public partial class MainViewModel : ViewModelBase
{
private static bool _ready;
[ObservableProperty]
private bool ready;

public bool Ready
{
get => _ready;
set
{
_ready = value;
OnPropertyChanged();
}
}
[ObservableProperty]
private string? search;

public ObservableCollection<GameModel> Games => GameManager.Games;
[ObservableProperty]
private ObservableCollection<GameModel> games = GameManager.Games;

public string Version => Program.VersionName;
partial void OnSearchChanged(string? value)
{
Games = new(GameManager.Games.Where(x => string.IsNullOrEmpty(value) || x.Name.Contains(value, StringComparison.CurrentCultureIgnoreCase)));
}
}
128 changes: 65 additions & 63 deletions MelonLoader.Installer/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,81 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:MelonLoader.Installer.ViewModels"
xmlns:views="clr-namespace:MelonLoader.Installer.Views"
xmlns:root="clr-namespace:MelonLoader.Installer"
mc:Ignorable="d" d:DesignWidth="450" d:DesignHeight="650"
x:Class="MelonLoader.Installer.Views.MainView"
x:DataType="vm:MainViewModel">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at
App.axaml.cs) -->
<vm:MainViewModel />
</Design.DataContext>
<vm:MainViewModel />
</Design.DataContext>

<Grid RowDefinitions="auto, auto, *, auto, auto">
<TextBlock Grid.Row="4" VerticalAlignment="Bottom" Foreground="#AFFF"
Text="{Binding Version}" />
<Grid RowDefinitions="auto, auto, auto, *, auto, auto">
<TextBlock Grid.Row="5" VerticalAlignment="Bottom" Foreground="#AFFF"
Text="{x:Static root:Program.VersionName}" />

<StackPanel Grid.Row="0" Height="40" Orientation="Horizontal" HorizontalAlignment="Center">
<Image Source="/Assets/icon.ico" Margin="0 0 10 0" />
<Image Source="/Assets/ML_Text.png" Height="30" />
</StackPanel>
<TextBlock Margin="0 20 0 0" HorizontalAlignment="Stretch" Grid.Row="1" Foreground="#AFFF"
xml:space="preserve" TextAlignment="Center">To install MelonLoader, click on one of the games below.
<StackPanel Grid.Row="0" Height="40" Orientation="Horizontal" HorizontalAlignment="Center">
<Image Source="/Assets/icon.ico" Margin="0 0 10 0" />
<Image Source="/Assets/ML_Text.png" Height="30" />
</StackPanel>
<TextBlock Margin="0 20 0 0" HorizontalAlignment="Stretch" Grid.Row="1" Foreground="#AFFF"
xml:space="preserve" TextAlignment="Center">To install MelonLoader, click on one of the games below.
If you can't find your game on the list, add it manually.</TextBlock>
<Border Grid.Row="2" Background="#0000" CornerRadius="8" Margin="0 10" ClipToBounds="True">
<Grid>
<ScrollViewer>
<ItemsControl IsVisible="{Binding Ready}" ItemsSource="{Binding Games}" Margin="10">
<ItemsControl.ItemTemplate>
<DataTemplate>
<views:GameControl DataContext="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<TextBlock Name="NoGamesText" IsVisible="False" Foreground="#3FFF" HorizontalAlignment="Center"
VerticalAlignment="Center" TextAlignment="Center" xml:space="preserve">
<TextBox Margin="0 20 0 0" Grid.Row="2" Watermark="Search a game..." Text="{Binding Search}"/>
<Border Grid.Row="3" Background="#0000" CornerRadius="8" Margin="0 10" ClipToBounds="True">
<Grid>
<ScrollViewer>
<ItemsControl IsVisible="{Binding Ready}" ItemsSource="{Binding Games}" Margin="10">
<ItemsControl.ItemTemplate>
<DataTemplate>
<views:GameControl DataContext="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<TextBlock Name="NoGamesText" IsVisible="False" Foreground="#3FFF" HorizontalAlignment="Center"
VerticalAlignment="Center" TextAlignment="Center" xml:space="preserve">
No Unity games have been found on your device.
Please add one manually using the button below.
</TextBlock>
<TextBlock Name="LoadingText" IsVisible="{Binding !Ready}" Foreground="#9FFF" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" TextAlignment="Center">
Loading...
</TextBlock>
</Grid>
<TextBlock Name="LoadingText" IsVisible="{Binding !Ready}" Foreground="#9FFF" FontSize="20" HorizontalAlignment="Center"
VerticalAlignment="Center" TextAlignment="Center">
Loading...
</TextBlock>
</Grid>
</Border>
<Button Grid.Row="4" IsEnabled="{Binding Ready}" HorizontalAlignment="Right" Click="AddGameManuallyHandler">Add Game Manually</Button>
<StackPanel Height="38" Grid.Row="4" Spacing="1" Orientation="Horizontal">
<Button Click="MelonWikiLink" ToolTip.Tip="MelonWiki"
ToolTip.Placement="RightEdgeAlignedBottom" Padding="3" CornerRadius="1000"
Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/icon.ico" />
</Border>
</Button>
<Button Click="DiscordLink" ToolTip.Tip="Official MelonLoader Discord"
ToolTip.Placement="RightEdgeAlignedBottom" Padding="3"
CornerRadius="1000" Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/discord.png" />
</Border>
</Button>
<Button Click="GithubLink" ToolTip.Tip="LavaGang Github"
ToolTip.Placement="RightEdgeAlignedBottom" Padding="0" CornerRadius="1000"
Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/github.png" />
</Border>
</Button>
<Button Click="TwitterLink" ToolTip.Tip="LavaGang Twitter (nobody is calling it X)"
ToolTip.Placement="RightEdgeAlignedBottom"
Padding="3" CornerRadius="1000" Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/twitter.png" />
</Border>
<Button Grid.Row="3" IsEnabled="{Binding Ready}" HorizontalAlignment="Right" Click="AddGameManuallyHandler">Add Game Manually</Button>
<StackPanel Height="38" Grid.Row="3" Spacing="1" Orientation="Horizontal">
<Button Click="MelonWikiLink" ToolTip.Tip="MelonWiki"
ToolTip.Placement="RightEdgeAlignedBottom" Padding="3" CornerRadius="1000"
Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/icon.ico" />
</Border>
</Button>
<Button Click="DiscordLink" ToolTip.Tip="Official MelonLoader Discord"
ToolTip.Placement="RightEdgeAlignedBottom" Padding="3"
CornerRadius="1000" Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/discord.png" />
</Border>
</Button>
<Button Click="GithubLink" ToolTip.Tip="LavaGang Github"
ToolTip.Placement="RightEdgeAlignedBottom" Padding="0" CornerRadius="1000"
Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/github.png" />
</Border>
</Button>
<Button Click="TwitterLink" ToolTip.Tip="LavaGang Twitter (nobody is calling it X)"
ToolTip.Placement="RightEdgeAlignedBottom"
Padding="3" CornerRadius="1000" Background="Transparent">
<Border CornerRadius="1000" ClipToBounds="True">
<Image Source="/Assets/twitter.png" />
</Border>
</Button>
</StackPanel>
</Grid>
</Button>
</StackPanel>
</Grid>
</UserControl>
Loading