Skip to content

Commit

Permalink
icons and categories
Browse files Browse the repository at this point in the history
  • Loading branch information
nacrt committed Mar 2, 2021
1 parent a551ee6 commit 6c82af1
Show file tree
Hide file tree
Showing 61 changed files with 262 additions and 26 deletions.
1 change: 0 additions & 1 deletion SkyblockClient/MainWindow.triggers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

Expand Down
6 changes: 3 additions & 3 deletions SkyblockClient/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="ListBox">
<Style TargetType="local:TabControlOptions">
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Margin" Value="10,45,10,90"/>
Expand All @@ -35,8 +35,8 @@
<Button x:Name="BtnClose" Content="" IsTabStop="False" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Background="#00000000" BorderBrush="#00000000" Click="BtnClose_Click" FontFamily="MS PGothic" Margin="0,0,11,0" FontWeight="Bold" Grid.Column="1"/>
<Button x:Name="BtnFullscreen" Content="" IsTabStop="False" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Background="#00000000" BorderBrush="#00000000" Margin="0,0,41,0" Click="BtnFullscreen_Click" FontFamily="Consolas" FontWeight="Bold" Grid.Column="1"/>
<Button x:Name="BtnMinimize" Content="----" IsTabStop="False" VerticalAlignment="Top" HorizontalAlignment="Right" Width="25" Height="25" Background="#00000000" BorderBrush="#00000000" Margin="0,0,71,0" Click="BtnMinimize_Click" FontFamily="Bauhaus 93" Grid.Column="1" />
<ListBox x:Name="lbMods" IsSynchronizedWithCurrentItem="False"/>
<ListBox x:Name="lbPacks" Grid.Column="1"/>
<local:TabControlOptions x:Name="tabMods"/>
<local:TabControlOptions x:Name="tabPacks" Grid.Column="1"/>
<Button x:Name="btnInstall" BorderBrush="#2c3e50" BorderThickness="2,0,2,5" Background="#FF587593" Foreground="White" Content="Install SkyClient" Margin="15,0,15,15" Grid.ColumnSpan="2" Height="35" VerticalAlignment="Bottom" Click="BtnInstallModsAndForgeClick"/>
<Button x:Name="btnOpenAdvancedSettings" BorderBrush="#2c3e50" BorderThickness="2,0,2,5" Background="#FF587593" Foreground="White" Content="Open Advanced settings" Margin="15,0,10,55" Height="30" VerticalAlignment="Bottom" Click="BtnAdvancedSettinsClick"/>
<Button x:Name="btnUpdate" Content="Update" Grid.Column="1" Margin="10,0,15,55" BorderBrush="#2c3e50" BorderThickness="2,0,2,5" Background="#FF587593" Foreground="White" Click="BtnUpdate_Click" Height="30" VerticalAlignment="Bottom"/>
Expand Down
11 changes: 7 additions & 4 deletions SkyblockClient/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,28 @@ private async Task DownloadResourceFile()

public void RefreshPacks()
{
lbPacks.Items.Clear();
var list = new List<CheckBoxMod>();
foreach (PackOption pack in Globals.packOptions)
{
if (!pack.Hidden)
{
lbPacks.Items.Add(pack.CheckBox);
list.Add(pack.CheckBox);
}
}

tabPacks.ItemSource = list;
}
public void RefreshMods()
{
lbMods.Items.Clear();
var list = new List<CheckBoxMod>();
foreach (ModOption mod in Globals.modOptions)
{
if (!mod.Hidden)
{
lbMods.Items.Add(mod.CheckBox);
list.Add(mod.CheckBox);
}
}
tabMods.ItemSource = list;
}

private async Task DownloadModsFile()
Expand Down
3 changes: 2 additions & 1 deletion SkyblockClient/Options/CheckBoxMod.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace SkyblockClient
/// </summary>
public partial class CheckBoxMod : UserControl
{
public string[] Categories { get; set; }

public event ClickEventHandler Click;
public delegate void ClickEventHandler(object sender, RoutedEventArgs e);
Expand Down Expand Up @@ -94,7 +95,7 @@ public string Icon
_icon = value;
if (Utils.IsPropSet(Icon))
{
Utils.SetImage(btnIcon, Icon);
Utils.SetImage(btnIcon, Icon);
}
else
{
Expand Down
11 changes: 9 additions & 2 deletions SkyblockClient/Options/Option.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

namespace SkyblockClient.Options
{
public abstract class Option
public abstract class Option
{
public string Id { get; set; }

[DefaultValue(false)]
public bool Enabled { get; set; }
public bool Enabled { get; set; }

public string File { get; set; }

Expand Down Expand Up @@ -42,6 +42,11 @@ public abstract class Option

public List<OptionAction> Actions { get; set; }

[JsonIgnore]
public bool HasCategories => Utils.IsPropSet(Categories);

public string[] Categories { get; set; }

[JsonIgnore]
public bool HasWarning => Utils.IsPropSet(Warning);

Expand All @@ -58,6 +63,8 @@ public CheckBoxMod CheckBox
{
CheckBoxMod checkBox = new CheckBoxMod();

checkBox.Categories = HasCategories ? Categories : new string[] { "99;Other" };

checkBox.Click += ComboBoxChecked;
checkBox.HoverEnter += CheckBox_HoverEnter;
checkBox.HoverLeave += CheckBox_HoverLeave;
Expand Down
64 changes: 62 additions & 2 deletions SkyblockClient/SkyblockClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectGuid>{2DEA9CD8-419E-4F59-82D9-D089DC282BB7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SkyblockClient</RootNamespace>
<AssemblyName>SkyblockClient</AssemblyName>
<AssemblyName>SkyblockClient-1.3.9</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down Expand Up @@ -293,6 +293,9 @@
<DependentUpon>UnmanagedFilesManagerWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Config\ConfigUtil.cs" />
<Compile Include="TabControlOptions.xaml.cs">
<DependentUpon>TabControlOptions.xaml</DependentUpon>
</Compile>
<Compile Include="Utils.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
Expand All @@ -306,6 +309,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TabControlOptions.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Options\ModOption.cs" />
Expand Down Expand Up @@ -352,7 +359,60 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="textures\error.png" />
<Resource Include="icons\error.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="icons\sbov.png" />
<Resource Include="icons\actuallyassets.png" />
<Resource Include="icons\actuallymobs.png" />
<Resource Include="icons\apec.png" />
<Resource Include="icons\aycy.jpg" />
<Resource Include="icons\aycy.png" />
<Resource Include="icons\bisquit.png" />
<Resource Include="icons\chattriggers 48x.ico" />
<Resource Include="icons\cmm.png" />
<Resource Include="icons\controlling.png" />
<Resource Include="icons\cowlection-logo.png" />
<Resource Include="icons\curseforge.png" />
<Resource Include="icons\default.png" />
<Resource Include="icons\discord icon.png" />
<Resource Include="icons\dsm logo cropped.png" />
<Resource Include="icons\dungeon texturepack 1024x.png" />
<Resource Include="icons\en.jpg" />
<Resource Include="icons\faithful team logo.png" />
<Resource Include="icons\faithful.png" />
<Resource Include="icons\forum.png" />
<Resource Include="icons\fsr.png" />
<Resource Include="icons\furfskywebsite.ico" />
<Resource Include="icons\github.png" />
<Content Include="icons\github.svg" />
<Resource Include="icons\guide.png" />
<Resource Include="icons\hq16f.png" />
<Resource Include="icons\hq32f.png" />
<Resource Include="icons\hsb.png" />
<Resource Include="icons\invalid.png" />
<Resource Include="icons\itlt.png" />
<Resource Include="icons\mob packet.png" />
<Resource Include="icons\moulberrys bush.png" />
<Resource Include="icons\neulogo.png" />
<Resource Include="icons\optifine.png" />
<Resource Include="icons\packshq 512x.png" />
<Resource Include="icons\packshq.png" />
<Resource Include="icons\patcher.png" />
<Resource Include="icons\phq dark overlay big.png" />
<Resource Include="icons\phq dark overlay.png" />
<Resource Include="icons\planetminecraft.png" />
<Resource Include="icons\rnbw.png" />
<Resource Include="icons\sba.png" />
<Resource Include="icons\sk1er monkey.png" />
<Resource Include="icons\skyclient.png" />
<Resource Include="icons\skymobs.png" />
<Resource Include="icons\skytils.png" />
<Resource Include="icons\smol_icons.png" />
<Resource Include="icons\smooth scrolling everywhere.png" />
<Resource Include="icons\vtays.png" />
<Resource Include="icons\worldsandbeyond.png" />
<Resource Include="icons\youtube.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterResolveReferences">
Expand Down
5 changes: 5 additions & 0 deletions SkyblockClient/TabControlOptions.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<UserControl x:Class="SkyblockClient.TabControlOptions"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TabControl x:Name="tabControl" SelectionChanged="TabControl_SelectionChanged" />
</UserControl>
154 changes: 154 additions & 0 deletions SkyblockClient/TabControlOptions.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Windows.Controls;

namespace SkyblockClient
{
/// <summary>
/// Interaktionslogik für TabControlItems.xaml
/// </summary>
public partial class TabControlOptions : UserControl
{
private int LastSelectedIndex = 0;
public List<CheckBoxMod> ItemSource
{
get => Items.ToList();
set => Items = new ObservableCollection<CheckBoxMod>(value);
}

public ObservableCollection<CheckBoxMod> Items
{
get => _items;
set
{
if (_items != null)
_items.CollectionChanged -= CollectionChanged;
_items = value;
_items.CollectionChanged += CollectionChanged;

if (_items.Count > 0)
{
RedrawContent();
tabControl.SelectedIndex = LastSelectedIndex;
}
}
}

private ObservableCollection<CheckBoxMod> _items;

public bool HeadersAreDrawn = false;

public TabControlOptions()
{
InitializeComponent();
Items = new ObservableCollection<CheckBoxMod>();
}

private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
RedrawContent();
}

private string[] GetAllHeaders()
{
List<string> headers = new List<string>();
if (Items != null)
{
foreach (var item in Items)
{
foreach (var category in item.Categories)
{
if (!headers.Contains(category))
{
headers.Add(category);
}
}
}
}
headers.Sort();
return headers.ToArray();
}

private void RedrawContent()
{
EnsureHeadersAreDrawn();

var index = tabControl.SelectedIndex;
if (index == -1)
return;

if (index == 0)
{
var contentList = Items;
var content = new ListBox();
content.ItemsSource = contentList;
(tabControl.Items[index] as TabItem).Content = content;
}
else
{
var contentList = GetAllContent(index - 1);
var content = new ListBox();
content.ItemsSource = contentList;
(tabControl.Items[index] as TabItem).Content = content;
}
}

private void EnsureHeadersAreDrawn()
{
if (!HeadersAreDrawn)
{
var tabItems = new List<TabItem>();
var headers = GetAllHeaders();

var allTabItem = new TabItem();
allTabItem.Header = "All";
allTabItem.Content = new ListBox();
tabItems.Add(allTabItem);

foreach (var header in headers)
{
var tabItem = new TabItem();
tabItem.Header = GetDisplayPartCategory(header);
tabItem.Content = new ListBox();
tabItems.Add(tabItem);
}

tabControl.ItemsSource = tabItems;

HeadersAreDrawn = true;
}
}

private List<CheckBoxMod> GetAllContent(int index)
{
var result = new List<CheckBoxMod>();
var header = GetAllHeaders()[index];

foreach (var item in Items)
{
foreach (var cat in item.Categories)
{
if (cat != header)
continue;
result.Add(item);
}
}

return result;
}

private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
LastSelectedIndex = tabControl.SelectedIndex;
RedrawContent();
}

private string GetDisplayPartCategory(string category)
{
return category.Split(';')[1];
}
}
}
Loading

0 comments on commit 6c82af1

Please sign in to comment.