From b836c831a1872a1b286541d90d3fdb9fae97411f Mon Sep 17 00:00:00 2001 From: Ruemena Date: Fri, 29 Dec 2023 22:19:08 -0800 Subject: [PATCH] oh my god --- RueI.sln | 8 +++---- RueI/Main.cs | 3 +++ RueI/RueI.csproj | 1 + RueI/RueI/Constants.cs | 4 +++- RueI/RueI/Displays/AutoGiving/AutoGivers.cs | 1 - RueI/RueI/Displays/DisplayCore.cs | 2 -- RueI/RueI/Displays/ElemCombiner.cs | 13 +++++----- RueI/RueI/Displays/Scheduling/Scheduler.cs | 2 +- RueI/RueI/Parsing/Parser.cs | 2 -- RueI/RueI/Parsing/ParserContext.cs | 1 - .../RueI/Parsing/Tags/RichTextTagAttribute.cs | 4 ++++ RueI/RueI/Patches/HintPatch.cs | 4 ++++ RueI/UnityAlternative.cs | 24 ++++++------------- RueI/docs.xml | 3 +-- 14 files changed, 35 insertions(+), 37 deletions(-) diff --git a/RueI.sln b/RueI.sln index 5cb4b81..1f76b14 100644 --- a/RueI.sln +++ b/RueI.sln @@ -16,16 +16,16 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Debug Exiled|Any CPU.ActiveCfg = Debug|Any CPU - {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Debug|Any CPU.Build.0 = Release|Any CPU {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Release Exiled|Any CPU.ActiveCfg = Debug|Any CPU {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Release Exiled|Any CPU.Build.0 = Debug|Any CPU {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A7DFDD8-78E1-418F-928B-AA4BC1289AA9}.Release|Any CPU.Build.0 = Release|Any CPU {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Debug Exiled|Any CPU.ActiveCfg = Debug|Any CPU {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Debug Exiled|Any CPU.Build.0 = Debug|Any CPU - {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Debug|Any CPU.Build.0 = Release|Any CPU {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Release Exiled|Any CPU.ActiveCfg = Release|Any CPU {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Release Exiled|Any CPU.Build.0 = Release|Any CPU {91D7C5BF-1273-4E70-BE19-7EC8907E2DAC}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/RueI/Main.cs b/RueI/Main.cs index e673dfc..17db8a2 100644 --- a/RueI/Main.cs +++ b/RueI/Main.cs @@ -13,6 +13,9 @@ /// /// Represents the main class for RueI. /// +/// +/// The class is responsible for properly initializing all of RueI. It handles +/// public static class RueIMain { /// diff --git a/RueI/RueI.csproj b/RueI/RueI.csproj index 88c0138..b0a3f64 100644 --- a/RueI/RueI.csproj +++ b/RueI/RueI.csproj @@ -8,6 +8,7 @@ AnyCPU;x64 RueI CC0 1.0 + 2.0.2 Rue <3, Override (some help) True diff --git a/RueI/RueI/Constants.cs b/RueI/RueI/Constants.cs index 2c580cc..5ce3cae 100644 --- a/RueI/RueI/Constants.cs +++ b/RueI/RueI/Constants.cs @@ -7,7 +7,9 @@ /// /// Provides a variety of constant values. /// -/// This class is mosty designed for internal use within RueI. However, they can still be useful for external use. +/// +/// This class is mosty designed for internal use within RueI. However, they can still be useful for external use. +/// public static class Constants { /// diff --git a/RueI/RueI/Displays/AutoGiving/AutoGivers.cs b/RueI/RueI/Displays/AutoGiving/AutoGivers.cs index 82ba14f..a19a9c1 100644 --- a/RueI/RueI/Displays/AutoGiving/AutoGivers.cs +++ b/RueI/RueI/Displays/AutoGiving/AutoGivers.cs @@ -131,7 +131,6 @@ public AutoElement UpdateEvery(TimeSpan span, int priority = 35) /// The to give to. protected virtual void GiveTo(DisplayCore core) { - ServerConsole.AddLog("Hello"); if (element != null) { core.AddAsReference(reference, element); diff --git a/RueI/RueI/Displays/DisplayCore.cs b/RueI/RueI/Displays/DisplayCore.cs index 73dd8c0..9687bd2 100644 --- a/RueI/RueI/Displays/DisplayCore.cs +++ b/RueI/RueI/Displays/DisplayCore.cs @@ -90,7 +90,6 @@ public static IElemReference GetReference() /// The priority of the update - defaults to 100. public void Update(int priority = 100) { - ServerConsole.AddLog("updating"); if (IgnoreUpdate) { return; @@ -169,7 +168,6 @@ public void RemoveReference(IElemReference reference) internal void InternalUpdate() { string text = ElemCombiner.Combine(GetAllElements()); - ServerConsole.AddLog(text); UnityAlternative.Provider.ShowHint(Hub, text); Events.Events.OnDisplayUpdated(new(this)); } diff --git a/RueI/RueI/Displays/ElemCombiner.cs b/RueI/RueI/Displays/ElemCombiner.cs index 7b2bbf6..68df15b 100644 --- a/RueI/RueI/Displays/ElemCombiner.cs +++ b/RueI/RueI/Displays/ElemCombiner.cs @@ -11,6 +11,10 @@ /// /// Provides a means of combining s. /// +/// +/// The is a helper class that combines all of the s for a into a single string, +/// to be displayed as a hint. +/// public static class ElemCombiner { /// @@ -20,7 +24,6 @@ public static class ElemCombiner /// A with all of the combined s. public static string Combine(IEnumerable enumElems) { - ServerConsole.AddLog("hello world!!!"); List elements = ListPool.Shared.Rent(enumElems); if (!elements.Any()) @@ -33,15 +36,15 @@ public static string Combine(IEnumerable enumElems) float lastPosition = 0; float lastOffset = 0; - ServerConsole.AddLog("im kind of a big deal"); + elements.Sort(CompareElement); for (int i = 0; i < elements.Count; i++) { Element curElement = elements[i]; - ServerConsole.AddLog(curElement.ZIndex.ToString()); + ParsedData parsedData = curElement.GetParsedData(); - ServerConsole.AddLog(curElement.ZIndex.ToString()); + float funcPos = curElement.GetFunctionalPosition(); if (curElement.Options.HasFlagFast(Elements.Enums.ElementOptions.PreserveSpacing)) { @@ -64,13 +67,11 @@ public static string Combine(IEnumerable enumElems) totalOffset += parsedData.Offset; lastPosition = funcPos; lastOffset = parsedData.Offset; - ServerConsole.AddLog("What the fuck"); } ListPool.Shared.Return(elements); sb.Insert(0, $"\n"); sb.Append(Constants.ZeroWidthSpace); - ServerConsole.AddLog(sb.ToString()); return StringBuilderPool.Shared.ToStringReturn(sb); } diff --git a/RueI/RueI/Displays/Scheduling/Scheduler.cs b/RueI/RueI/Displays/Scheduling/Scheduler.cs index 09374f5..e8e45f4 100644 --- a/RueI/RueI/Displays/Scheduling/Scheduler.cs +++ b/RueI/RueI/Displays/Scheduling/Scheduler.cs @@ -189,7 +189,7 @@ private void UpdateBatches() } TimeSpan performAt = (currentBatches.First().PerformAt - Now).MaxIf(rateLimiter.Active, rateLimiter.TimeLeft); - ServerConsole.AddLog("Starting"); + performTask.Start(performAt, PerformFirstBatch); } diff --git a/RueI/RueI/Parsing/Parser.cs b/RueI/RueI/Parsing/Parser.cs index f179040..6bb4207 100644 --- a/RueI/RueI/Parsing/Parser.cs +++ b/RueI/RueI/Parsing/Parser.cs @@ -227,7 +227,6 @@ public static bool GetTagAttributes(string content, out DictionaryA containing information about the string. public ParsedData Parse(string text, ElementOptions options = ElementOptions.Default) { - ServerConsole.AddLog("what"); ParserState currentState = ParserState.CollectingTags; StringBuilder tagBuffer = StringBuilderPool.Shared.Rent(Constants.MAXTAGNAMESIZE); @@ -272,7 +271,6 @@ void FailTagMatch() // not a tag, unload buffer char[] chars = text.ToCharArray(); for (int i = 0; i < chars.Length; i++) { - ServerConsole.AddLog(chars[i].ToString()); char ch = chars[i]; if (ch == '\\') diff --git a/RueI/RueI/Parsing/ParserContext.cs b/RueI/RueI/Parsing/ParserContext.cs index 440af21..4726fe5 100644 --- a/RueI/RueI/Parsing/ParserContext.cs +++ b/RueI/RueI/Parsing/ParserContext.cs @@ -141,7 +141,6 @@ public void AddEndingTag(bool allowDuplicates = false) public void RemoveEndingTag() where T : NoParamsTag, new() { - ServerConsole.AddLog("doing the thing lol"); endingTags.Remove(SharedTag.Singleton); } diff --git a/RueI/RueI/Parsing/Tags/RichTextTagAttribute.cs b/RueI/RueI/Parsing/Tags/RichTextTagAttribute.cs index 9fbd7e0..c6cc7c5 100644 --- a/RueI/RueI/Parsing/Tags/RichTextTagAttribute.cs +++ b/RueI/RueI/Parsing/Tags/RichTextTagAttribute.cs @@ -3,6 +3,10 @@ /// /// Defines a for RueI. /// +/// +/// You can apply this to classes that inherit from to define a custom easily. +/// This attribute is used exclusive by the method. +/// [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] public class RichTextTagAttribute : Attribute { diff --git a/RueI/RueI/Patches/HintPatch.cs b/RueI/RueI/Patches/HintPatch.cs index 6b44f73..b413c30 100644 --- a/RueI/RueI/Patches/HintPatch.cs +++ b/RueI/RueI/Patches/HintPatch.cs @@ -19,6 +19,10 @@ /// /// Patches to detect when hints are shown. /// +/// +/// RueI patches the method so that it can get an accurate state of the player's hint display at any given time. +/// When a hint outside of RueI is shown, it schedules an update that occurs after 3 seconds. +/// [HarmonyPatch(typeof(HintDisplay), nameof(HintDisplay.Show))] public static class HintPatch { diff --git a/RueI/UnityAlternative.cs b/RueI/UnityAlternative.cs index 50a6d3c..bbafb3e 100644 --- a/RueI/UnityAlternative.cs +++ b/RueI/UnityAlternative.cs @@ -10,6 +10,10 @@ /// /// Defines the base class for a provider of methods that may or may not use Unity. /// +/// +/// The class is primarily intended for internal use within RueI. This enables certain features +/// to work even outside of SCP:SL and Unity, which is utilized primarily for unit-testing. +/// public abstract class UnityAlternative { /// @@ -18,7 +22,7 @@ public abstract class UnityAlternative public interface IAsyncOperation : IDisposable { /// - /// Gets a value indicating whether or not this operation is handling. + /// Gets a value indicating whether or not this operation is currently running. /// public bool IsRunning { get; } @@ -70,7 +74,7 @@ private static UnityAlternative GetProvider() { try { - _ = Object.FindObjectOfType(); + _ = Object.FindObjectOfType(); // errors if not in unity return new UnityProvider(); } catch(Exception) @@ -158,21 +162,7 @@ public class UnityProvider : UnityAlternative public override IAsyncOperation PerformAsync(TimeSpan span, Action action) => new MECAsyncOperation(span, action); /// - internal override void ShowHint(ReferenceHub hub, string message) - { - ServerConsole.AddLog("Showing"); - - string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - // Append text to an existing file named "WriteLines.txt". - using (StreamWriter outputFile = new(Path.Combine(docPath, "hello.txt"), true)) - { - outputFile.WriteLine(message); - } - - hub.connectionToClient.Send(new HintMessage(new TextHint(message, new HintParameter[] { new StringHintParameter(message) }, null, 99999))); - Log(message); - } // HintEffectPresets.FadeIn(0, 0, 1) + internal override void ShowHint(ReferenceHub hub, string message) => hub.connectionToClient.Send(new HintMessage(new TextHint(message, new HintParameter[] { new StringHintParameter(message) }, new HintEffect[] { HintEffectPresets.FadeIn(0, 0, 1) }, 99999))); /// /// Represents an async operation using a . diff --git a/RueI/docs.xml b/RueI/docs.xml index cee5eff..1bb6288 100644 --- a/RueI/docs.xml +++ b/RueI/docs.xml @@ -38,9 +38,8 @@ Display display = new(referenceHub); // Create a new display from a ReferenceHub - SetElement helloElem = new(300, zIndex: 10, "hello").AddTo(display); + SetElement helloElem = new(300, zIndex: 10, "hello").AddTo(display); SetElement worldElem = new(250, zIndex: 10, "world").AddTo(display); - display.Elements.Add(helloElem, worldElem); display.Update(); // Update the display