Skip to content

Commit

Permalink
Update 0.9
Browse files Browse the repository at this point in the history
Almost release ready
  • Loading branch information
Auricrystal committed Aug 20, 2023
1 parent fc1a384 commit 43d2436
Show file tree
Hide file tree
Showing 401 changed files with 31,182 additions and 301 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 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.
15 changes: 15 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="RemnantWorldChanger.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<RemnantWorldChanger.Properties.Settings>
<setting name="BulkData" serializeAs="String">
<value />
</setting>
</RemnantWorldChanger.Properties.Settings>
</userSettings>
</configuration>
62 changes: 45 additions & 17 deletions BulkSave.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.DirectoryServices.ActiveDirectory;
using System.IO;
using System.IO.Packaging;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
Expand All @@ -17,53 +20,78 @@ namespace RemnantWorldChanger
public class BulkSave
{
static Random _R = new Random();
static T RandomEnumValue<T>()
public static Random R { get { return _R; } }
public static T RandomEnumValue<T>()
{
var v = Enum.GetValues(typeof(T));
return (T)v.GetValue(_R.Next(v.Length-1)+1);
return (T)v.GetValue(_R.Next(v.Length - 1) + 1);
}
public ObservableCollection<DataPackage> SaveInfo { get; set; }

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

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

public void AddSave(byte[] savedata, string world = "", string name = "")
public void AddSave(byte[] savedata, SaveType type = SaveType.All, string world = "Earth", string name = "Unknown", SaveDifficulty diff = SaveDifficulty.Unset, string mods = "")
{
Guid guid = Guid.NewGuid();
GuidToBytes.Add(guid, savedata);

var list = new string[] {"Hearty", "Vicious", "Spiteful", "Drain", "Skullcracker", "Vortex", "Waller", "RatSwarm", "Displacer", "Teleporter" };

Random random = new Random();
SaveDifficulty diff = RandomEnumValue<SaveDifficulty>();

string mods = string.Join(", ",list.OrderBy(x=>random.Next()).Take((int)diff));


SaveInfo.Add(new DataPackage(guid) {Difficulty=diff, World = world, Name = name, Mods = mods });
GuidToBytes.Add(guid, savedata);
var dp = new DataPackage(guid) { Difficulty = diff, World = world, Name = name, Mods = mods, Type = type };
SaveInfo.Add(dp);
//Debug.WriteLine("Created: "+dp);
}
public void AddSave(byte[] savedata, DataPackage dp)
{
GuidToBytes.Add(dp.ID, savedata);
SaveInfo.Add(dp);
}


public static DirectoryInfo TryGetSolutionDirectoryInfo(string currentPath = null)
{
var directory = new DirectoryInfo(
currentPath ?? Directory.GetCurrentDirectory());
while (directory != null && !directory.GetFiles("*.sln").Any())
{
directory = directory.Parent;
}
return directory;
}

public void Serialize()
[Conditional("DEBUG")]
public void SerializeData(string name)
{
File.WriteAllText(@"C:\Users\AuriCrystal\Documents\VisualProjects\RemnantWorldChanger\Output\DataA.json",
if (!Directory.Exists(name))
Directory.CreateDirectory(name);
File.WriteAllText($@"{name}\Data.RIndex",
JsonSerializer.Serialize(SaveInfo, new JsonSerializerOptions
{
WriteIndented = true
}));

File.WriteAllText(@"C:\Users\AuriCrystal\Documents\VisualProjects\RemnantWorldChanger\Output\DataB.json",
File.WriteAllText($@"{name}\Data.RData",
JsonSerializer.Serialize(GuidToBytes, new JsonSerializerOptions
{
WriteIndented = true
}));
}
public static BulkSave DeserializeData(string path)
{
var header = new ObservableCollection<DataPackage>(Directory.EnumerateFiles(path, "*.RIndex").Select(s => JsonSerializer.Deserialize<ObservableCollection<DataPackage>>(File.ReadAllText(s))).SelectMany(x => x));

var data = Directory.EnumerateFiles(path, "*.RData").Select(s => JsonSerializer.Deserialize<Dictionary<Guid, byte[]>>(File.ReadAllText(s))).SelectMany(x => x).ToDictionary(x => x.Key, y => y.Value);

return new BulkSave(header, data);
}

}

Expand Down
16 changes: 10 additions & 6 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,30 @@
<MenuItem Header="Options">
<MenuItem Header="Auto-Update" IsCheckable="True"/>
<MenuItem Header="Check for update"/>
<MenuItem Name="btnGenExample" Header="Generate Test Saves" Click="GenerateExamples_Click" Visibility="Collapsed" IsEnabled="false"/>
</MenuItem>
<CheckBox Content="Keep Checkpoint"/>
<CheckBox Name="cbKeepSave" Content="Keep Checkpoint" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked"/>

</Menu>
<DockPanel DockPanel.Dock="Top" Height="20" VerticalAlignment="Top">
<ComboBox Name="cmbSaveType" DockPanel.Dock="Left" HorizontalAlignment="Left" Width="100"/>
<TextBox Margin="20,0,0,0" Width="200"/>
<ComboBox Name="cmbSaveType" DockPanel.Dock="Left" HorizontalAlignment="Left" Width="100" SelectionChanged="Save_SelectionChanged"/>
<Button Content="Add Checkpoint" DockPanel.Dock="Top" HorizontalAlignment="Right" Width="100" Height="20" Click="SaveCheckpoint_Click"/>
</DockPanel>
<DockPanel >
<DataGrid Name="SaveList" SelectionMode="Single" SelectionChanged="SaveList_SelectionChanged" DockPanel.Dock="Left" Width="200" HorizontalAlignment="Left" AutoGenerateColumns="False" Background="{x:Null}" CanUserReorderColumns="False" CanUserResizeColumns="False" IsReadOnly="True">
<DataGrid Name="SaveList" SelectionMode="Single" SelectionChanged="Save_SelectionChanged" DockPanel.Dock="Left" Width="200" HorizontalAlignment="Left" AutoGenerateColumns="False" Background="{x:Null}" CanUserReorderColumns="False" CanUserResizeColumns="False" IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="World" Width="*" Binding="{Binding Value}"/>
<DataGridTextColumn Header="Name" Width="2*" Binding="{Binding Key}"/>
</DataGrid.Columns>
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Edit Save" Click="SaveEdit_Click"/>
<MenuItem Header="Load Save" Click="LoadSave_Click"/>
</ContextMenu>
</DataGrid.ContextMenu>
</DataGrid>
<DockPanel DockPanel.Dock="Right">
<ListView Name="DifficultyList" SelectionMode="Single" SelectionChanged="DifficultyList_SelectionChanged" DockPanel.Dock="Top" Height="110" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListView Name="DifficultyList" SelectionMode="Single" SelectionChanged="Save_SelectionChanged" DockPanel.Dock="Top" Height="110" ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Width="230">
Expand All @@ -47,10 +49,11 @@
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Edit Save" Click="SaveEdit_Click"/>
<MenuItem Header="Load Save" Click="LoadSave_Click"/>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
<ListView Name="ModifierList" SelectionMode="Single" SelectionChanged="ModifierList_SelectionChanged" DockPanel.Dock="Bottom" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListView Name="ModifierList" SelectionMode="Single" SelectionChanged="Save_SelectionChanged" DockPanel.Dock="Bottom" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListView.View>
<GridView AllowsColumnReorder="False" >
<GridViewColumn Width="230">
Expand All @@ -61,6 +64,7 @@
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Edit Save" Click="SaveEdit_Click"/>
<MenuItem Header="Load Save" Click="LoadSave_Click"/>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
Expand Down
Loading

0 comments on commit 43d2436

Please sign in to comment.