Compare commits

2 Commits
Author SHA256 Message Date
copecone 6c0347609d Add Auto Localization Initialization 2026-10-05 14:30:01 +09:00
copecone 92a4654f14 Add Auto UI Initialization 2026-10-05 14:28:18 +09:00
4 changed files with 42 additions and 16 deletions

No files matched your search

+3 -1
View File
@@ -9,6 +9,7 @@ using System.Linq;
using ADOFAIRenderer.API;
using ADOFAIRenderer.Data;
using ADOFAIRenderer.UI;
using ADOFAIRenderer.UI.Window;
using ADOFAIRenderer.Util;
using ADOFAIRenderer.Util.Audio;
using ADOFAIRenderer.Util.FFmpeg;
@@ -336,7 +337,8 @@ internal class RenderManager : MonoBehaviour
(Func<bool>)Delegate.CreateDelegate(typeof(Func<bool>), scnEditor.instance, targetMethod);
Application.wantsToQuit -= quitDelegate;
ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "Assets/Scenes/RenderSettingsScene.unity");
RenderConfigWindow.CreateWindow();
// ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "Assets/Scenes/RenderSettingsScene.unity");
});
}
+7 -2
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using MelonLoader;
using Newtonsoft.Json;
using UnityEngine;
@@ -33,6 +32,11 @@ internal static class LocalizationManager
private static bool _initialized;
static LocalizationManager()
{
Initialize();
}
/// <summary>
/// Initializes the localization system and loads embedded language dictionaries.
/// </summary>
@@ -115,7 +119,7 @@ internal static class LocalizationManager
localeCode = FallbackLocaleCode;
}
var isChanged = (language != CurrentLanguage) || (localeCode != CurrentLocaleCode);
var isChanged = language != CurrentLanguage || localeCode != CurrentLocaleCode;
CurrentLanguage = language;
CurrentLocaleCode = localeCode;
@@ -140,6 +144,7 @@ internal static class LocalizationManager
public static string Get(string key)
{
if (string.IsNullOrEmpty(key)) return string.Empty;
if (!_initialized) Initialize();
// 1. Try currently active locale
if (Locales.TryGetValue(CurrentLocaleCode, out var activeDict) && activeDict.TryGetValue(key, out var val))
+4 -4
View File
@@ -19,8 +19,6 @@ internal class RenderMod : MelonMod
{
public static AssetBundle FontBundle = null!;
// ReSharper disable once MemberCanBePrivate.Global
public static AssetBundle SceneBundle = null!;
// ReSharper disable once MemberCanBePrivate.Global
public static AssetBundle ShaderBundle = null!;
public static ComputeShader ColorConversionShader = null!;
public static bool IsFeatureDisabled = false;
@@ -29,23 +27,25 @@ internal class RenderMod : MelonMod
public override void OnInitializeMelon()
{
GlobalSettings.Load();
Localization.LocalizationManager.Initialize();
ffmpeg.RootPath = MelonEnvironment.UserLibsDirectory;
var renderManagerObj = new GameObject("Render Manager");
var updateHookerObj = new GameObject("Update Hooker");
var uiManagerObj = new GameObject("Renderer UI Manager");
Object.DontDestroyOnLoad(renderManagerObj);
Object.DontDestroyOnLoad(updateHookerObj);
Object.DontDestroyOnLoad(uiManagerObj);
renderManagerObj.AddComponent<RenderManager>();
updateHookerObj.AddComponent<FirstUpdateHook>();
uiManagerObj.AddComponent<UI.RendererUIManager>();
LoadBundles();
}
private static void LoadBundles()
{
FontBundle = BundleLoader.GetBundle("fonts");
SceneBundle = BundleLoader.GetBundle("scenes");
SceneBundle.GetAllScenePaths();
try
{
ShaderBundle = BundleLoader.GetBundle("shaders");
+28 -9
View File
@@ -1,4 +1,4 @@
using O5Kit.Core;
using O5Kit.Core;
namespace ADOFAIRenderer.UI;
@@ -6,15 +6,32 @@ using UnityEngine;
public class RendererUIManager : MonoBehaviour
{
public static RendererUIManager Instance { get; private set; } = null!;
private static RendererUIManager? _instance;
public static RendererUIManager Instance
{
get
{
if (_instance == null)
{
var go = new GameObject("RendererUIManager");
DontDestroyOnLoad(go);
_instance = go.AddComponent<RendererUIManager>();
}
return _instance;
}
private set => _instance = value;
}
public static O5Context Context = null!;
public O5WindowManager WindowManager = null!;
public static O5Context Context => Instance._context;
public O5WindowManager WindowManager => _windowManager;
private O5Context _context = null!;
private O5WindowManager _windowManager = null!;
private void Awake() {
Instance = this;
_instance = this;
Context = new O5Context(
_context = new O5Context(
config: new O5Config {
UIScale = 1.0f,
MiddleClickToDefault = true,
@@ -23,7 +40,7 @@ public class RendererUIManager : MonoBehaviour
theme: O5Theme.Dark
);
WindowManager = O5WindowManager.Create(Context, transform, "RendererMod_Canvas");
_windowManager = O5WindowManager.Create(_context, transform, "RendererMod_Canvas");
}
private void Update() {
@@ -33,7 +50,9 @@ public class RendererUIManager : MonoBehaviour
}
private void OnDestroy() {
WindowManager.Dispose();
Context.Dispose();
_windowManager.Dispose();
_context.Dispose();
if (_instance == this) _instance = null;
}
}