Skip to content

Commit

Permalink
1.0.2 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Auricrystal committed Aug 26, 2023
1 parent b2b19cc commit cd7074e
Show file tree
Hide file tree
Showing 316 changed files with 2,925 additions and 194 deletions.
Binary file modified .vs/ProjectEvaluation/remnantworldchanger.metadata.v7.bin
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/remnantworldchanger.projects.v7.bin
Binary file not shown.
Binary file modified .vs/RemnantWorldChanger/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified .vs/RemnantWorldChanger/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/RemnantWorldChanger/v17/.suo
Binary file not shown.
14 changes: 10 additions & 4 deletions BulkSave.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.DirectoryServices.ActiveDirectory;
using System.IO;
Expand Down Expand Up @@ -30,14 +31,17 @@ public static T RandomEnumValue<T>()
}
public ObservableCollection<DataPackage> SaveInfo { get; set; }


public Dictionary<Guid, byte[]> GuidToBytes { get; set; }

public BulkSave(ObservableCollection<DataPackage> header, Dictionary<Guid, byte[]> data)
{
SaveInfo = header;
GuidToBytes = data;
}
public BulkSave()


public BulkSave()
{
SaveInfo = new ObservableCollection<DataPackage>();
GuidToBytes = new Dictionary<Guid, byte[]>();
Expand Down Expand Up @@ -177,14 +181,16 @@ public override bool Equals(object obj)

public bool Contains(string s)
{
var _ = new string[] { Name, World, Mods, Difficulty.ToString() };
return _.ToList().Select(x =>x.ToLower()).Any(x=>x.Contains(s));

var _ = new string[] { Name, World, Mods, Difficulty.ToString() };

return _.ToList().Select(x => x.ToLower()).Any(x => x.Contains(s.ToLower()));

}

public bool Contains(params string[] st)
{
return st.ToList().Any(x => Contains(x));
return st.ToList().All(x => Contains(x));
}
public override int GetHashCode() => (Difficulty, Name, Mods).GetHashCode();
}
Expand Down
55 changes: 34 additions & 21 deletions Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public SaveType SaveType
return (SaveType)cbSaveType.SelectedItem;
}
}

public void UpdateData(ObservableCollection<DataPackage> packages)
{
DataPackages = packages;
Regenerate();
}
public Display(ObservableCollection<DataPackage> packages, DataGrid saveList, ListView difficultyList, ListView modifierList, TextBox tbSearchBar, ComboBox saveType)
{
DataPackages = packages;
Expand All @@ -56,23 +60,15 @@ public Display(ObservableCollection<DataPackage> packages, DataGrid saveList, Li

private void SaveType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Debug.WriteLine("Save Type Changed");
if (SaveType == SaveType.All)
CollectionViewSource.GetDefaultView(SaveList.ItemsSource).Filter = o =>
{
return true;
};
else
CollectionViewSource.GetDefaultView(SaveList.ItemsSource).Filter = o =>
{
return SearchBar().ToList().Find(x => x.Name == ((KeyValuePair<string, string>)o).Key)!.Type == SaveType;
};
// Debug.WriteLine("Save Type Changed");

Regenerate();
SaveList.SelectedIndex = 0;
}

public void SaveInfo_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Debug.WriteLine("Collection Changed!");
if (sender is null)
return;
DataPackages = ((ObservableCollection<DataPackage>)sender);
Expand All @@ -88,23 +84,24 @@ private void TbSearchBar_TextChanged(object sender, TextChangedEventArgs e)
public void Regenerate()
{
SaveList.ItemsSource = SearchBar().GroupBy(x => x.Name).ToDictionary(x => x.Key, x => x.First().World).OrderBy(x => x.Value).ThenBy(x => x.Key);

ModifierList.ItemsSource = SearchBar().Select(x => x.Mods).Distinct().OrderBy(x => x);

}
private ObservableCollection<DataPackage> SearchBar()
{
string[] filterText = tbSearchBar.Text.Split(' ');

return new ObservableCollection<DataPackage>(DataPackages.Where(x => x.Contains(filterText)));
return new ObservableCollection<DataPackage>(DataPackages.Where(x => x.Contains(filterText) && (x.Type == SaveType || SaveType == SaveType.All)));

}
private void SaveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

Debug.WriteLine("SaveList Changed");
// Debug.WriteLine($"SaveList Changed{SaveList.SelectedIndex}");

if (SaveList.SelectedIndex == -1)
{
//Debug.WriteLine("No Save Selected");
if (DifficultyList.ItemsSource is not null)
CollectionViewSource.GetDefaultView(DifficultyList.ItemsSource).Filter = o => false;
if (ModifierList.ItemsSource is not null)
Expand All @@ -120,31 +117,47 @@ private void SaveList_SelectionChanged(object sender, SelectionChangedEventArgs

if (DifficultyList.SelectedIndex == -1)
DifficultyList.SelectedIndex = 0;
else
DifficultyList_SelectionChanged(sender, e);


//Debug.WriteLine("Calling Difflist");
DifficultyList_SelectionChanged(sender, e);

}
private void DifficultyList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Debug.WriteLine("DifficultyList Changed");
if (SaveList.SelectedIndex == -1)
return;
if (DifficultyList.SelectedIndex == -1)
return;
//Debug.WriteLine($"DifficultyList Changed{DifficultyList.SelectedIndex}");

var name = ((KeyValuePair<string, string>)SaveList.SelectedItem).Key;
var diff = DifficultyList.SelectedItem.ToString();

// Debug.WriteLine($"Name: {name} Diff:{diff} {DifficultyList.Items.Count}");

// Debug.WriteLine("MATCHES"+string.Join("\n", SearchBar().Where(x => x.Name == name && x.Difficulty.ToString() == diff)));

CollectionViewSource.GetDefaultView(ModifierList.ItemsSource).Filter = o =>
{
return SearchBar().Where(x => x.Name == name && x.Difficulty.ToString() == diff).Select(y => y.Mods).Contains(o.ToString());
};

//Debug.WriteLine($"Mods: {ModifierList.Items.Count}");

if (ModifierList.SelectedIndex == -1)
ModifierList.SelectedIndex = 0;
else
ModifierList_SelectionChanged(sender, e);


// Debug.WriteLine("Calling Modlist");
ModifierList_SelectionChanged(sender, e);

}
private void ModifierList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

Debug.WriteLine("ModifierList Changed");
// Debug.WriteLine($"ModifierList Changed: {ModifierList.SelectedIndex}");


}

Expand Down
83 changes: 70 additions & 13 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ namespace RemnantWorldChanger
public partial class MainWindow : Window
{

private FileSystemWatcher? _watcher;
private string Packages
{
get
{
var _= Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\RemnantWorldChanger\\Packages\\";
var _ = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\RemnantWorldChanger\\Packages\\";
if (!Directory.Exists(_))
Directory.CreateDirectory(_);
return _;
Expand All @@ -55,6 +56,7 @@ private BulkSave Saves
return saves = new BulkSave();

return saves = BulkSave.DeserializeData(Packages);

}
set { saves = value; }
}
Expand Down Expand Up @@ -103,6 +105,50 @@ private FileSystemWatcher SaveWatcher
}
set { savewatcher = value; }
}
private FileSystemWatcher PackageWatcher
{
get
{
if (_watcher is null)
{
_watcher = new FileSystemWatcher()
{
Path = Packages,
NotifyFilter = NotifyFilters.Attributes
| NotifyFilters.CreationTime
| NotifyFilters.DirectoryName
| NotifyFilters.FileName
| NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.Security
| NotifyFilters.Size,
Filter = "*.RIndex"
};
_watcher.Changed += Watcher_Changed;
_watcher.Created += Watcher_Changed;
}
return _watcher;
}
}

private void Watcher_Changed(object sender, FileSystemEventArgs e)
{
var result = MessageBox.Show("Reload Saves?", "New Data Detected", MessageBoxButton.YesNo, MessageBoxImage.Information);
if (result != MessageBoxResult.Yes)
return;
Saves = BulkSave.DeserializeData(Packages);
try
{
this.Dispatcher.Invoke(() =>
{
display?.UpdateData(Saves.SaveInfo);
});

}
catch (Exception) { }

}

private Dictionary<string, byte[]>? lockedsaves;
private Dictionary<string, byte[]> LockedSaves
{
Expand All @@ -114,7 +160,7 @@ private Dictionary<string, byte[]> LockedSaves
}
set { lockedsaves = value; }
}
private Display display;
private Display? display;
public MainWindow()
{
InitializeComponent();
Expand All @@ -128,16 +174,20 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
DifficultyList.ItemsSource = Enum.GetValues(typeof(SaveDifficulty));

cmbSaveType.SelectedIndex = 0;
display = new Display(Saves.SaveInfo,SaveList,DifficultyList,ModifierList,tbSearchbar,cmbSaveType);
display = new Display(Saves.SaveInfo, SaveList, DifficultyList, ModifierList, tbSearchbar, cmbSaveType);

Saves.SaveInfo.CollectionChanged += display.SaveInfo_CollectionChanged;

SaveList.SelectedIndex = 0;
display.Regenerate();


PackageWatcher.EnableRaisingEvents = true;
//display.Regenerate();

//Debug.WriteLine($"Mods: {ModifierList.Items.Count}");

}



[Conditional("DEBUG")]
private void EnableDebugOptions()
Expand All @@ -162,13 +212,19 @@ private void SaveCheckpoint_Click(object sender, RoutedEventArgs e)
if (Saves.NewPackage(out dp))
Saves.GuidToBytes.Add(dp.ID, File.ReadAllBytes(ofd.FileName));
else
{
Debug.WriteLine("New Package Failed!");
return;
}
else
Debug.WriteLine("Dialog False");
{
Debug.WriteLine("Dialog False");
return;
}

SaveList.SelectedIndex = 0;

display.Regenerate();
display?.Regenerate();
Debug.WriteLine($"Count: {Saves.SaveInfo.Count}");
Debug.WriteLine($"Count: {SaveList.Items.Count}");
}
Expand All @@ -183,6 +239,7 @@ private void SaveListContext_Click(object sender, RoutedEventArgs e)

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
PackageWatcher.EnableRaisingEvents = false;
Saves.SerializeData(Packages);
}

Expand Down Expand Up @@ -247,10 +304,10 @@ private void GenerateExamples_Click(object sender, RoutedEventArgs e)
skipupdate = false;
}





private void LoadSave_Click(object sender, RoutedEventArgs e)
{
DataPackage? _ = FindSelected();
Expand Down Expand Up @@ -337,6 +394,6 @@ private void DeleteSave_Click(object sender, RoutedEventArgs e)
display.Regenerate();
}


}
}
2 changes: 1 addition & 1 deletion Properties/PublishProfiles/FolderProfile.pubxml.user
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2023-08-22T22:23:17.5366089Z;True|2023-08-22T13:50:02.9891723-04:00;True|2023-08-21T18:35:16.1855047-04:00;True|2023-08-21T14:59:25.2633679-04:00;True|2023-08-21T12:01:47.2938761-04:00;False|2023-08-21T12:01:22.4718346-04:00;True|2023-08-21T12:00:32.1813074-04:00;</History>
<History>True|2023-08-26T19:36:51.5814954Z;True|2023-08-22T18:23:17.5366089-04:00;True|2023-08-22T13:50:02.9891723-04:00;True|2023-08-21T18:35:16.1855047-04:00;True|2023-08-21T14:59:25.2633679-04:00;True|2023-08-21T12:01:47.2938761-04:00;False|2023-08-21T12:01:22.4718346-04:00;True|2023-08-21T12:00:32.1813074-04:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion RemnantWorldChanger.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>C:\Users\Josh\Documents\GitHub\RemnantWorldChanger\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>C:\Users\AuriCrystal\Documents\VisualProjects\RemnantWorldChanger\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
Expand Down
Binary file modified bin/Debug/net6.0-windows/win-x64/RemnantWorldChanger.dll
Binary file not shown.
Binary file modified bin/Release/RemnantWorldChanger.exe
Binary file not shown.
Binary file modified bin/Release/net6.0-windows/win-x64/RemnantWorldChanger.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ build_property.EnableSingleFileAnalyzer = true
build_property.EnableTrimAnalyzer =
build_property.IncludeAllContentForSelfExtract =
build_property.RootNamespace = RemnantWorldChanger
build_property.ProjectDir = C:\Users\Josh\Documents\GitHub\RemnantWorldChanger\
build_property.ProjectDir = C:\Users\AuriCrystal\Documents\VisualProjects\RemnantWorldChanger\
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f6790012be9e6cd7d4a05348a5f5eb4a45055dd6
3776614b60cdb912446243de651126cb3a20a0a4
Loading

0 comments on commit cd7074e

Please sign in to comment.