Skip to content

Commit

Permalink
0.17.0.0 release, Update the dll to have the png instead of using a m…
Browse files Browse the repository at this point in the history
…ore cumbersome framework. Remove ConfigEditor as it was never used. Remove Sentry dependencies that causes errors.
  • Loading branch information
HolloFox committed Jul 19, 2024
1 parent 64f6a07 commit 1545392
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 86 deletions.
Binary file added ConfigurationManager/Assets/plug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 1 addition & 22 deletions ConfigurationManager/ConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using BepInEx.Logging;
using ConfigurationManager.Patches.GameSetting;
using HarmonyLib;
using LordAshes;
using ModdingTales;
using PluginUtilities;
using Sentry;
using UnityEngine.SceneManagement;

namespace ConfigurationManager
Expand All @@ -19,19 +17,9 @@ namespace ConfigurationManager
/// any of the settings you expose, even keyboard shortcuts.
/// </summary>
[BepInPlugin(Guid, "Config Manager", Version)]
[BepInDependency(FileAccessPlugin.Guid)]
[BepInDependency(ConfigEditorPlugin.Guid)]
[BepInDependency(SetInjectionFlag.Guid)]
public sealed class ConfigurationManager : BaseUnityPlugin
{
public enum logToSentry
{
Inherited,
Disabled,

// Prompt,
Enabled
}

/// <summary>
/// GUID of this plugin
Expand All @@ -41,19 +29,10 @@ public enum logToSentry
/// <summary>
/// Version constant
/// </summary>
public const string Version = "0.16.0.0";
public const string Version = "0.17.0.0";

internal static ManualLogSource _logger;
internal static ConfigurationManager _instance;

internal static Action<Scope> _scope = scope =>
{
scope.User = new User
{
Username = UserNameManager.Username,
};
scope.Release = Version;
};

/// <inheritdoc />
public ConfigurationManager()
Expand Down
13 changes: 6 additions & 7 deletions ConfigurationManager/ConfigurationManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@
<ItemGroup>
<PackageReference Include="TaleSpire" Version="1.2.2"></PackageReference>
<PackageReference Include="Talespire.BepInEx" Version="5.4.22"></PackageReference>
<PackageReference Include="TaleSpire.Sentry" Version="1.0.0" />
<PackageReference Include="TaleSpire.SetInjectionFlagPlugin" Version="2.6.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="ConfigEditorPlugin">
<HintPath>C:\Users\ujkkj\AppData\Roaming\r2modmanPlus-local\TaleSpire\profiles\CMPDev\BepInEx\plugins\LordAshes-ConfigEditor\ConfigEditorPlugin.dll</HintPath>
</Reference>
<Reference Include="FileAccessPlugin">
<HintPath>C:\Users\ujkkj\AppData\Roaming\r2modmanPlus-local\TaleSpire\profiles\CMPDev\BepInEx\plugins\LordAshes-FileAccessPlugin\FileAccessPlugin.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\plug.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Assets\plug.png" />
</ItemGroup>
</Project>
22 changes: 18 additions & 4 deletions ConfigurationManager/Patches/UI/UI_SwitchButtonGroupStartPatch.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using BepInEx;
using BepInEx.Configuration;
using ConfigurationManager.UIFactory.CustomBehaviours;
using ConfigurationManager.Utilities;
using LordAshes;
using ModdingTales;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
Expand All @@ -33,6 +33,21 @@ internal static class UI_SwitchButtonGroupStartPatch
private static Vector3 pos;


public static Sprite LoadEmbeddedTexture(string texturePath)
{
Assembly _assembly = Assembly.GetExecutingAssembly();
Stream _stream = _assembly.GetManifestResourceStream(typeof(ConfigurationManager).Namespace + "." + texturePath.Replace("/", "."));
byte[] fileData;
using (MemoryStream ms = new MemoryStream())
{
_stream.CopyTo(ms);
fileData = ms.ToArray();
}
Texture2D tex = new Texture2D(1, 1);
tex.LoadImage(fileData);
return Sprite.Create(tex, new Rect(0f, 0f, tex.width, tex.height), new Vector2(0.5f, 0.5f));
}

private static void AddButton(UI_SwitchButtonGroup __instance, int i, Button template, string key,
ref List<Button> ____buttons, float distance)
{
Expand All @@ -51,8 +66,7 @@ private static void AddButton(UI_SwitchButtonGroup __instance, int i, Button tem
clone.onClick.AddListener(() => { Click(); });
var textOnHover = clone.gameObject.GetComponent<MouseTextOnHover>();
textOnHover.mouseHoverText = "Plugin Configurations";
clone.GetComponentsInChildren<Image>()[2].sprite =
FileAccessPlugin.Image.LoadSprite("Images/Icons/plug.png");
clone.GetComponentsInChildren<Image>()[2].sprite = LoadEmbeddedTexture("Assets/plug.png");

var scrollViewContent = template.transform.parent.parent.GetChild(0).GetChild(0).GetChild(0).GetChild(2);
_sectionHeader = scrollViewContent.GetChild(2).GetChild(0).GetChild(0).gameObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using BepInEx.Configuration;
using ConfigurationManager.Utilities;
using ModdingTales;
using SRF;
using TMPro;
using UnityEngine;
Expand Down
60 changes: 9 additions & 51 deletions ConfigurationManager/UIFactory/CustomBehaviours/TextBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BepInEx.Configuration;
using LordAshes;
using SRF;
using TMPro;
using UnityEngine;
Expand Down Expand Up @@ -34,8 +33,6 @@ private void Update()

private void OnGUI()
{
// Render Config Editor if open
ConfigEditorPlugin.Render();
}

internal void Setup()
Expand All @@ -57,58 +54,19 @@ internal void Setup()

var button = transform.GetChild(1).GetChild(1).GetComponent<Button>();
button.onClick.RemoveAllListeners();

if (Attributes?.IsJSON != null && Attributes.IsJSON.Value)
button.onClick.AddListener(() =>
{
button.onClick.RemoveAllListeners();
button.onClick.AddListener(() =>
{
SystemMessage.ClosePendingMessage();
ConfigEditorPlugin.Subscribe((s1, s2) =>
SystemMessage.AskForTextInput($"Update {Entry.Definition.Key} Config", "Enter the desired text",
"OK",
t =>
{
EditorCallback(s1, s2);
Save(t);

// Not covered by Config Manager's Sentry
Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
});
ConfigEditorPlugin.offsetXToEntry = 120;
ConfigEditorPlugin.Open(Entry.Definition.Key, (string)Entry.BoxedValue,
new[] { "Cancel", "Save" });
});
}
else
{
button.onClick.AddListener(() =>
{
SystemMessage.AskForTextInput($"Update {Entry.Definition.Key} Config", "Enter the desired text",
"OK",
t =>
{
Save(t);

// Not covered by Config Manager's Sentry
Attributes?.CallbackAction?.Invoke(Entry.BoxedValue);
},
null, "Cancel", null, Entry.BoxedValue.ToString());
});
}
}

private void EditorCallback(string button, string json)
{
switch (button)
{
case "Save":
Save(json);
ConfigEditorPlugin.Close();
break;
case "Cancel":
ConfigEditorPlugin.Close();
break;
default:
_logger.LogInfo($"Editor Callback for {Entry.Definition.Key} had a button with wrong text.");
break;
}
},
null, "Cancel", null, Entry.BoxedValue.ToString());
});
}

private void Save(string t)
Expand Down
Binary file not shown.

0 comments on commit 1545392

Please sign in to comment.