Code updates

This commit is contained in:
pan.codes 2025-06-08 21:39:06 +02:00
parent c7b2028f4d
commit e9b551d3f0
3 changed files with 21 additions and 3 deletions

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>AudioSettings</AssemblyName>
<Description>My first plugin</Description>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

View file

@ -19,6 +19,8 @@ namespace AudioSettings
SliderCount = 0;
}
public ConfigEntry<float> Volume { get; set; }
public ConfigEntry<string> TranslatedName { get; set; }
public ConfigEntry<string> TranslatedDescription { get; set; }
public void Add(AudioSource source, float multiplier)
{
if (Sources.Any(x => x.source == source))
@ -44,6 +46,8 @@ namespace AudioSettings
Description = description;
Console.WriteLine("Volume slider \"" + name + "\" initiated.");
Volume = Config.Bind(name, "Volume", 1f, description + "\nValue goes from 0 to 1.");
TranslatedName = Translator.Config.Bind(name, "Name", name);
TranslatedDescription = Translator.Config.Bind(name, "Description", description);
Volume.SettingChanged += Volume_SettingChanged;
ValueLastTick = Volume.Value;
}
@ -67,9 +71,9 @@ namespace AudioSettings
var rectDescLabel = new Rect(10, SliderCount * 50 + 30, width, 25);
var rectPercLabel = new Rect(width * (2f / 7f), SliderCount * 50 + 10, width * (0.5f / 7f), 25);
GUI.Label(rectNameLabel, Name, new GUIStyle { alignment = TextAnchor.MiddleLeft, normal = font });
GUI.Label(rectNameLabel, TranslatedName.Value, new GUIStyle { alignment = TextAnchor.MiddleLeft, normal = font });
GUI.Label(rectPercLabel, Volume.Value.ToString("##0%"), new GUIStyle { alignment = TextAnchor.MiddleRight, normal = font });
GUI.Label(rectDescLabel, Description, new GUIStyle { alignment = TextAnchor.MiddleLeft, normal = font });
GUI.Label(rectDescLabel, TranslatedDescription.Value, new GUIStyle { alignment = TextAnchor.MiddleLeft, normal = font });
var rect = new Rect(width * (2.5f / 7f) + 10, SliderCount * 50 + 16, width * (4.5f / 7f), 25);
var style = new GUIStyle(GUI.skin.horizontalSlider);

View file

@ -1,4 +1,5 @@
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using MyBox;
using System;
@ -10,6 +11,19 @@ using UnityEngine.UIElements;
namespace AudioSettings
{
[BepInPlugin(TRANSLATOR_GUID, TRANSLATOR_NAME, TRANSLATOR_VERSION)]
public class Translator : BaseUnityPlugin
{
public const string TRANSLATOR_GUID = PluginInfo.PLUGIN_GUID + ".Translations";
public const string TRANSLATOR_NAME = PluginInfo.PLUGIN_NAME + " Translations";
public const string TRANSLATOR_VERSION = PluginInfo.PLUGIN_VERSION;
public static ConfigFile Config { get; private set; }
public void Awake()
{
//Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");
Config = base.Config;
}
}
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{