Skip to content

Commit

Permalink
Fixed updating and tweaked browser
Browse files Browse the repository at this point in the history
  • Loading branch information
TekkaGB committed Sep 22, 2021
1 parent 93fef1b commit 0766426
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 36 deletions.
39 changes: 6 additions & 33 deletions Unverum/ModUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public async static void CheckForUpdates(string path, MainWindow main)
var cancellationToken = new CancellationTokenSource();
var requestUrls = new Dictionary<string, List<string>>();
var mods = Directory.GetDirectories(path).Where(x => File.Exists($"{x}/mod.json")).ToList();
var modCount = 0;
var soundCount = 0;
var wipCount = 0;
var modList = new Dictionary<string, List<string>>();
var urlCounts = new Dictionary<string, int>();
foreach (var mod in mods)
{
if (!File.Exists($"{mod}{Global.s}mod.json"))
Expand All @@ -63,19 +61,9 @@ public async static void CheckForUpdates(string path, MainWindow main)
{
var MOD_TYPE = char.ToUpper(url.Segments[1][0]) + url.Segments[1].Substring(1, url.Segments[1].Length - 3);
var MOD_ID = url.Segments[2];
int index = 0;
switch (MOD_TYPE)
{
case "Mod":
index = modCount;
break;
case "Sound":
index = soundCount;
break;
case "Wip":
index = wipCount;
break;
}
if (!urlCounts.ContainsKey(MOD_TYPE))
urlCounts.Add(MOD_TYPE, 0);
int index = urlCounts[MOD_TYPE];
if (!modList.ContainsKey(MOD_TYPE))
modList.Add(MOD_TYPE, new());
modList[MOD_TYPE].Add(mod);
Expand All @@ -84,23 +72,8 @@ public async static void CheckForUpdates(string path, MainWindow main)
else if (requestUrls[MOD_TYPE].Count == index)
requestUrls[MOD_TYPE].Add($"https://gamebanana.com/apiv6/{MOD_TYPE}/Multi?_csvProperties=_sName,_bHasUpdates,_aLatestUpdates,_aFiles,_aPreviewMedia,_aAlternateFileSources&_csvRowIds=");
requestUrls[MOD_TYPE][index] += $"{MOD_ID},";
if (requestUrls[MOD_TYPE][modCount].Length > 1990)
{
switch (MOD_TYPE)
{
case "Mod":
modCount++;
break;
case "Sound":
soundCount++;
break;
case "Wip":
wipCount++;
break;
}
// Remove extra comma
requestUrls[MOD_TYPE][modCount] = requestUrls[MOD_TYPE][modCount].Substring(0, requestUrls[MOD_TYPE][modCount].Length - 1);
}
if (requestUrls[MOD_TYPE][index].Length > 1990)
urlCounts[MOD_TYPE]++;
}
}
// Remove extra comma
Expand Down
13 changes: 12 additions & 1 deletion Unverum/UI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,18 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Margin="5,0,35,0" Grid.Column="5" IsEnabled="False" KeyDown="SearchBar_KeyDown" Name="SearchBar" Height="35" MinWidth="200" HorizontalAlignment="Stretch" VerticalContentAlignment="Center"/>
<TextBox Margin="5,0,35,0" Padding="4,0,0,0" Grid.Column="5" IsEnabled="False" KeyDown="SearchBar_KeyDown" Name="SearchBar" Height="35" MinWidth="200" HorizontalAlignment="Stretch" VerticalContentAlignment="Center"/>
<TextBlock Margin="5,0,35,0" Padding="7,5.5,3,3" Grid.Column="5" IsHitTestVisible="False" Height="35" MinWidth="200" HorizontalAlignment="Left" Text="Search..." VerticalAlignment="Center" Foreground="#303030">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SearchBar, Path=Text.IsEmpty}" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<Button Grid.Column="5" IsEnabled="False" HorizontalAlignment="Right" Click="SearchButton_Click" Name="SearchButton" Height="35" Width="35">
<fa5:ImageAwesome Icon="Solid_Search" Foreground="#f2f2f2" Margin="3"/>
</Button>
Expand Down
2 changes: 1 addition & 1 deletion Unverum/UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ private void FilterSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (IsLoaded && !filterSelect)
{
if (!searched)
if (!searched || FilterBox.SelectedIndex != 3)
{
filterSelect = true;
var temp = FilterBox.SelectedIndex;
Expand Down
2 changes: 1 addition & 1 deletion Unverum/Unverum.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\unverum.ico</ApplicationIcon>
<AssemblyName>Unverum</AssemblyName>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<AssemblyVersion>1.3.2.0</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 0766426

Please sign in to comment.