forked from AssetRipper/AssetRipper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
137 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
Source/AssetRipper.Export.UnityProjects/Configuration/ProcessingExportSettingsContext.cs
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
Source/AssetRipper.Export.UnityProjects/Configuration/SerializedSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using AssetRipper.Import.Configuration; | ||
using AssetRipper.Import.Utils; | ||
using System.Text.Json; | ||
|
||
namespace AssetRipper.Export.UnityProjects.Configuration; | ||
|
||
public readonly record struct SerializedSettings(ImportSettings Import, ProcessingSettings Processing, ExportSettings Export) | ||
{ | ||
public const string DefaultFileName = "AssetRipper.Settings.json"; | ||
|
||
public static string DefaultFilePath => ExecutingDirectory.Combine(DefaultFileName); | ||
|
||
public static SerializedSettings Load(string path) | ||
{ | ||
return JsonSerializer.Deserialize(File.ReadAllText(path), SerializedSettingsContext.Default.SerializedSettings); | ||
} | ||
|
||
public static bool TryLoadFromDefaultPath(out SerializedSettings settings) | ||
{ | ||
string path = DefaultFilePath; | ||
if (File.Exists(path)) | ||
{ | ||
settings = Load(path); | ||
return true; | ||
} | ||
settings = default; | ||
return false; | ||
} | ||
|
||
public void Save(string path) | ||
{ | ||
using FileStream fileStream = File.Create(path); | ||
JsonSerializer.Serialize(fileStream, this, SerializedSettingsContext.Default.SerializedSettings); | ||
} | ||
|
||
public void SaveToDefaultPath() | ||
{ | ||
Save(DefaultFilePath); | ||
} | ||
|
||
public static void DeleteDefaultPath() | ||
{ | ||
string path = DefaultFilePath; | ||
if (File.Exists(path)) | ||
{ | ||
File.Delete(path); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Source/AssetRipper.Export.UnityProjects/Configuration/SerializedSettingsContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace AssetRipper.Export.UnityProjects.Configuration; | ||
|
||
[JsonSourceGenerationOptions(WriteIndented = true)] | ||
[JsonSerializable(typeof(SerializedSettings))] | ||
internal sealed partial class SerializedSettingsContext : JsonSerializerContext | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters