Browse Source

Fixed ModList buttons to persist better

Logger now writes to basic log files and compresses them next start
Library loader now updates cache after installing pending updates
pull/12/head
Anairkoen Schno 5 years ago
parent
commit
5e07dd7164
8 changed files with 37 additions and 42 deletions
  1. +5
    -3
      BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs
  2. +3
    -0
      IPA.Injector/Injector.cs
  3. +2
    -2
      IPA.Loader/Loader/LibLoader.cs
  4. +27
    -15
      IPA.Loader/Logging/Printers/GZFilePrinter.cs
  5. BIN
      Refs/Assembly-CSharp.dll
  6. BIN
      Refs/BeatSaberCustomUI.dll
  7. +0
    -22
      Refs/BeatSaberCustomUI.xml
  8. BIN
      Refs/Unity.TextMeshPro.dll

+ 5
- 3
BSIPA-ModList/UI/ViewControllers/DownloadProgressViewController.cs View File

@ -108,10 +108,12 @@ namespace BSIPA_ModList.UI.ViewControllers
_restartGame = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(ButtonXOffset, -8f), ButtonSize, Restart, "Restart Game");
_restartGame.interactable = DownloadController.Instance.HadUpdates;
_restartGame.ToggleWordWrapping(false);
DownloadController.Instance.OnDownloaderListChanged += Refresh;
DownloadController.Instance.OnDownloadStateChanged += DownloaderStateChanged;
}
DownloadController.Instance.OnDownloaderListChanged += Refresh;
DownloadController.Instance.OnDownloadStateChanged += DownloaderStateChanged;
DownloaderStateChanged();
}
private void Restart()


+ 3
- 0
IPA.Injector/Injector.cs View File

@ -59,6 +59,8 @@ namespace IPA.Injector
Updates.InstallPendingUpdates();
LibLoader.SetupAssemblyFilenames(true);
pluginAsyncLoadTask = PluginLoader.LoadTask();
}
catch (Exception e)
@ -81,6 +83,7 @@ namespace IPA.Injector
if (loadingDone) return;
loadingDone = true;
AppDomain.CurrentDomain.AssemblyResolve += LibLoader.AssemblyLibLoader;
LibLoader.SetupAssemblyFilenames(true);
}
private static void InstallBootstrapPatch()


+ 2
- 2
IPA.Loader/Loader/LibLoader.cs View File

@ -33,9 +33,9 @@ namespace IPA.Loader
internal static string NativeLibraryPath => Path.Combine(LibraryPath, "Native");
internal static Dictionary<string, string> FilenameLocations;
internal static void SetupAssemblyFilenames()
internal static void SetupAssemblyFilenames(bool force = false)
{
if (FilenameLocations == null)
if (FilenameLocations == null || force)
{
FilenameLocations = new Dictionary<string, string>();


+ 27
- 15
IPA.Loader/Logging/Printers/GZFilePrinter.cs View File

@ -28,7 +28,6 @@ namespace IPA.Logging.Printers
/// </summary>
protected StreamWriter FileWriter;
private GZipStream zstream;
private FileStream fstream;
/// <summary>
@ -37,6 +36,8 @@ namespace IPA.Logging.Printers
/// <returns></returns>
protected abstract FileInfo GetFileInfo();
private const string latestFormat = "_latest{0}";
private void InitLog()
{
try
@ -45,12 +46,19 @@ namespace IPA.Logging.Printers
{ // first init
fileInfo = GetFileInfo();
var ext = fileInfo.Extension;
fileInfo = new FileInfo(fileInfo.FullName + ".gz");
fileInfo.Create().Close();
var symlink = new FileInfo(Path.Combine(fileInfo.DirectoryName ?? throw new InvalidOperationException(), $"_latest{ext}.gz"));
var symlink = new FileInfo(Path.Combine(fileInfo.DirectoryName ?? throw new InvalidOperationException(), string.Format(latestFormat, ext)));
if (symlink.Exists) symlink.Delete();
foreach (var file in fileInfo.Directory.EnumerateFiles("*.log", SearchOption.TopDirectoryOnly))
{
if (file.Extension == ".gz") continue;
CompressOldLog(file);
}
fileInfo.Create().Close();
try
{
if (!CreateHardLink(symlink.FullName, fileInfo.FullName, IntPtr.Zero))
@ -73,6 +81,20 @@ namespace IPA.Logging.Printers
}
}
private static async void CompressOldLog(FileInfo file)
{
Logger.log.Debug($"Compressing log file {file}");
var newFile = new FileInfo(file.FullName + ".gz");
using (var istream = file.OpenRead())
using (var ostream = newFile.Create())
using (var gz = new GZipStream(ostream, CompressionMode.Compress, CompressionLevel.BestCompression, false))
await istream.CopyToAsync(gz);
file.Delete();
}
/// <summary>
/// Called at the start of any print session.
/// </summary>
@ -81,11 +103,7 @@ namespace IPA.Logging.Printers
InitLog();
fstream = fileInfo.Open(FileMode.Append, FileAccess.Write);
zstream = new GZipStream(fstream, CompressionMode.Compress)
{
FlushMode = FlushType.Full
};
FileWriter = new StreamWriter(zstream, new UTF8Encoding(false));
FileWriter = new StreamWriter(fstream, new UTF8Encoding(false));
}
/// <summary>
@ -94,13 +112,10 @@ namespace IPA.Logging.Printers
public sealed override void EndPrint()
{
FileWriter.Flush();
zstream.Flush();
fstream.Flush();
FileWriter.Dispose();
zstream.Dispose();
fstream.Dispose();
FileWriter = null;
zstream = null;
fstream = null;
}
@ -120,13 +135,10 @@ namespace IPA.Logging.Printers
if (disposing)
{
FileWriter.Flush();
zstream.Flush();
fstream.Flush();
FileWriter.Close();
zstream.Close();
fstream.Close();
FileWriter.Dispose();
zstream.Dispose();
fstream.Dispose();
}
}


BIN
Refs/Assembly-CSharp.dll View File


BIN
Refs/BeatSaberCustomUI.dll View File


+ 0
- 22
Refs/BeatSaberCustomUI.xml View File

@ -129,28 +129,6 @@
<param name="sizeDelta">The size of the color picker's RectTransform.</param>
<returns></returns>
</member>
<member name="M:CustomUI.BeatSaber.BeatSaberUI.CreateTextSegmentedControl(UnityEngine.RectTransform,UnityEngine.Vector2,UnityEngine.Vector2,UnityEngine.Events.UnityAction{System.Int32},System.Single,System.Single)">
<summary>
Creates a custom TextSegmentedControl component.
</summary>
<param name="parent">Thet transform to parent the new TextSegmentedControl component to.</param>
<param name="anchoredPosition">The position the TextSegmentedControl component should be anchored to.</param>
<param name="sizeDelta">The size of the TextSegmentedControl component RectTransform.</param>
<param name="onValueChanged">Callback when the user clicks on one of the segments.</param>
<param name="fontSize">Size of text in segments.</param>
<param name="padding">Size of padding in segments.</param>
<returns>The newly created TextSegmentedControl component.</returns>
</member>
<member name="M:CustomUI.BeatSaber.BeatSaberUI.CreateIconSegmentedControl(UnityEngine.RectTransform,UnityEngine.Vector2,UnityEngine.Vector2,UnityEngine.Events.UnityAction{System.Int32})">
<summary>
Creates a custom IconSegmentedControl component.
</summary>
<param name="parent">Thet transform to parent the new IconSegmentedControl component to.</param>
<param name="anchoredPosition">The position the IconSegmentedControl component should be anchored to.</param>
<param name="sizeDelta">The size of the IconSegmentedControl component RectTransform.</param>
<param name="onValueChanged">Callback when the user clicks on one of the segments.</param>
<returns>The newly created IconSegmentedControl component.</returns>
</member>
<member name="F:CustomUI.BeatSaber.CustomFlowCoordinator.parentFlowCoordinator">
<summary>
The FlowCoordinator that presented this FlowCoordinator


BIN
Refs/Unity.TextMeshPro.dll View File


Loading…
Cancel
Save