1
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
@@ -9,4 +11,22 @@ namespace BITKit
|
||||
string GetConfig(params object[] args);
|
||||
void Configure(params object[] args);
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public sealed class ConfigProviders:IConfigProvider
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IConfigProvider[] providers;
|
||||
public string GetConfig(params object[] args)
|
||||
{
|
||||
return string.Join("\n",providers.Select(x=>x.GetConfig(args)));
|
||||
}
|
||||
|
||||
public void Configure(params object[] args)
|
||||
{
|
||||
foreach (var provider in providers)
|
||||
{
|
||||
provider.Configure(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,6 @@ namespace BITKit
|
||||
public float Sensitivity = 1.81f;
|
||||
public float TouchSensitivity = 0.22f;
|
||||
public float M_Yaw = 0.022f;
|
||||
public float Fov = 75;
|
||||
public float Fov = 90;
|
||||
}
|
||||
}
|
@@ -3,12 +3,29 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BITKit;
|
||||
using BITKit.Core.Tuple;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public sealed class CommandConfigProvider:IConfigProvider
|
||||
{
|
||||
[SerializeField] private UnityTuple<string, string>[] pairs;
|
||||
public string GetConfig(params object[] args)
|
||||
{
|
||||
return string.Join("\n",pairs);
|
||||
}
|
||||
|
||||
public void Configure(params object[] args)
|
||||
{
|
||||
foreach (var pair in pairs)
|
||||
{
|
||||
BITCommands.Excute($"set {pair.Item1} {pair.Item2}");
|
||||
}
|
||||
}
|
||||
}
|
||||
public class ScriptableExec : MonoBehaviour
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IConfigProvider configProvider;
|
||||
|
@@ -1,12 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if RH_SerializedDictionary
|
||||
using RotaryHeart.Lib.SerializableDictionary;
|
||||
#endif
|
||||
using AYellowpaper.SerializedCollections;
|
||||
namespace BITKit
|
||||
{
|
||||
public sealed class TranslateSO : ScriptableObject
|
||||
{
|
||||
#if RH_SerializedDictionary
|
||||
public SerializableDictionaryBase<string, string> dictionary = new();
|
||||
#else
|
||||
public SerializedDictionary<string, string> dictionary = new();
|
||||
#endif
|
||||
public string Get(string text, bool isLocalization = true)
|
||||
{
|
||||
foreach (var word in dictionary)
|
||||
@@ -14,7 +22,11 @@ namespace BITKit
|
||||
var value = word.Value;
|
||||
if (isLocalization)
|
||||
{
|
||||
value = DI.Get<ITranslator>().Translate(value);
|
||||
try
|
||||
{
|
||||
value = DI.Get<ITranslator>().Translate(value);
|
||||
}
|
||||
catch (NullReferenceException){}
|
||||
}
|
||||
text = text.Replace(word.Key, value);
|
||||
}
|
||||
@@ -22,11 +34,18 @@ namespace BITKit
|
||||
}
|
||||
public string GetAt(string key, bool isLocalization = true)
|
||||
{
|
||||
var translater = DI.Get<ITranslator>();
|
||||
|
||||
if (dictionary.TryGetValue(key, out var value))
|
||||
{
|
||||
if (isLocalization)
|
||||
value = translater.Translate(value);
|
||||
try
|
||||
{
|
||||
if (isLocalization)
|
||||
{
|
||||
var translater = DI.Get<ITranslator>();
|
||||
value = translater.Translate(value);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException){}
|
||||
return value;
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user