Skip to content

Commit

Permalink
Merge pull request #41 from Shivansps/fix-fso-build-picker
Browse files Browse the repository at this point in the history
Fix fsobuildpicker not hidding fso builds and add fso stability color code
  • Loading branch information
Shivansps authored Nov 12, 2023
2 parents ad24c55 + 2803115 commit afda13a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
55 changes: 27 additions & 28 deletions Knossos.NET/ViewModels/Templates/FsoBuildPickerViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using Knossos.NET.Models;
using Knossos.NET.Views;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
Expand All @@ -14,7 +16,8 @@ namespace Knossos.NET.ViewModels
public partial class FsoBuildPickerViewModel : ViewModelBase
{
private bool directSeparatorAdded = false;
internal ObservableCollection<ComboBoxItem> BuildItems { get; set; } = new ObservableCollection<ComboBoxItem>();
[ObservableProperty]
internal ObservableCollection<ComboBoxItem> buildItems = new ObservableCollection<ComboBoxItem>();

internal bool hideRC = Knossos.globalSettings.hideBuildRC;
internal bool HideRC
Expand All @@ -27,16 +30,13 @@ internal bool HideRC
{
if (hideRC != value)
{
hideRC = value;
this.SetProperty(ref hideRC, value);
Knossos.globalSettings.hideBuildRC = value;
var rcItems = BuildItems.Where(items => items.Tag?.ToString() == "rc");
if(rcItems.Any())
{
foreach (var items in rcItems)
{
items.IsVisible = !value;
}
}
Knossos.globalSettings.Save(false);
BuildItems.ForEach(buildItem => {
if(buildItem.Tag != null && buildItem.Tag?.ToString() == "rc")
buildItem.IsVisible = !value;
});
}
}
}
Expand All @@ -53,15 +53,12 @@ internal bool HideCustom
if (hideCustom != value)
{
Knossos.globalSettings.hideBuildCustom = value;
hideCustom = value;
var customItems = BuildItems.Where(items => items.Tag?.ToString() == "custom");
if (customItems.Any())
{
foreach (var items in customItems)
{
items.IsVisible = !value;
}
}
Knossos.globalSettings.Save(false);
this.SetProperty(ref hideCustom, value);
BuildItems.ForEach(buildItem => {
if (buildItem.Tag != null && buildItem.Tag?.ToString() == "custom")
buildItem.IsVisible = !value;
});
}
}
}
Expand All @@ -77,16 +74,13 @@ internal bool HideNightly
{
if (hideNightly != value)
{
hideNightly = value;
this.SetProperty(ref hideNightly, value);
Knossos.globalSettings.hideBuildNightly = value;
var nightlyItems = BuildItems.Where(items => items.Tag?.ToString() == "nightly");
if (nightlyItems.Any())
{
foreach (var items in nightlyItems)
{
items.IsVisible = !value;
}
}
Knossos.globalSettings.Save(false);
BuildItems.ForEach(buildItem => {
if (buildItem.Tag != null && buildItem.Tag?.ToString() == "nightly")
buildItem.IsVisible = !value;
});
}
}
}
Expand Down Expand Up @@ -166,6 +160,7 @@ private void FillBuildsItems(FsoBuild? preSelected)
item.Content = build;
item.Tag = "custom";
item.IsVisible = !HideCustom;
item.Foreground = Brushes.Green;
BuildItems.Add(item);
if (preSelected != null)
{
Expand All @@ -192,6 +187,7 @@ private void FillBuildsItems(FsoBuild? preSelected)
item.Content = build;
item.Tag = "rc";
item.IsVisible = !HideRC;
item.Foreground = Brushes.Yellow;
BuildItems.Add(item);
if (preSelected != null)
{
Expand All @@ -218,6 +214,7 @@ private void FillBuildsItems(FsoBuild? preSelected)
item.Content = build;
item.Tag = "nightly";
item.IsVisible = !HideNightly;
item.Foreground = Brushes.LightBlue;
BuildItems.Add(item);
if (preSelected != null)
{
Expand All @@ -243,6 +240,7 @@ private void FillBuildsItems(FsoBuild? preSelected)
ComboBoxItem item = new ComboBoxItem();
item.Content = preSelected;
item.Tag = "directexec";
item.Foreground = Brushes.LemonChiffon;
BuildItems.Add(item);
selectedItem = item;
}
Expand Down Expand Up @@ -278,6 +276,7 @@ internal async void OpenFileCommand()
item.Content = new FsoBuild(path);
item.Tag = "directexec";
item.IsSelected = true;
item.Foreground = Brushes.LemonChiffon;
BuildItems.Add(item);
BuildSelectedIndex = BuildItems.IndexOf(item);
}
Expand Down
14 changes: 10 additions & 4 deletions Knossos.NET/Views/Templates/FsoBuildPickerView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@

<StackPanel>
<Grid Margin="5" ColumnDefinitions="Auto,Auto,Auto,Auto">
<CheckBox IsChecked="{Binding HideRC}" Grid.Column="0">Hide RC builds</CheckBox>
<CheckBox IsChecked="{Binding HideNightly}" Grid.Column="1" Margin="10,0,0,0">Hide Nightly builds</CheckBox>
<CheckBox IsChecked="{Binding HideCustom}" Grid.Column="2" Margin="10,0,0,0">Hide Custom builds</CheckBox>
<CheckBox IsChecked="{Binding HideRC}" Foreground="Yellow" Grid.Column="0">Hide RC builds</CheckBox>
<CheckBox IsChecked="{Binding HideNightly}" Foreground="LightBlue" Grid.Column="1" Margin="10,0,0,0">Hide Nightly builds</CheckBox>
<CheckBox IsChecked="{Binding HideCustom}" Foreground="Green" Grid.Column="2" Margin="10,0,0,0">Hide Custom builds</CheckBox>
<Button Command="{Binding OpenFileCommand}" Grid.Column="3" Margin="10,0,0,0">Browse</Button>
</Grid>
<ComboBox ItemsSource="{Binding BuildItems}" SelectedIndex="{Binding BuildSelectedIndex}" Margin="5" HorizontalAlignment="Stretch"></ComboBox>
<ComboBox ItemsSource="{Binding BuildItems}" SelectedIndex="{Binding BuildSelectedIndex}" Margin="5" HorizontalAlignment="Stretch">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</StackPanel>
</UserControl>

0 comments on commit afda13a

Please sign in to comment.