This commit is contained in:
CortexCore
2024-03-05 15:27:29 +08:00
parent 7766082e9d
commit 2c8dfd3c86
45 changed files with 6760 additions and 138 deletions

View File

@@ -22,6 +22,11 @@ namespace BITKit.Console
{
public class BITConsole : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod]
private static void Reload()
{
Application.logMessageReceivedThreaded += EnqueueLog;
}
private class CommandSelector
{
public VisualElement Container { get; set; }
@@ -163,17 +168,6 @@ namespace BITKit.Console
}
private void OnEnable()
{
Application.logMessageReceived += EnqueueLog;
}
private void OnDisable()
{
Application.logMessageReceived -= EnqueueLog;
}
private void OnNextLine()
{
if (outputString.Count is not 0 && outputString.Last() != string.Empty)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,16 @@
{
"name": "I18N",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [
"Editor"
],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

Binary file not shown.

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
@@ -17,6 +18,15 @@ namespace BITKit.Mod
[SerializeField] private bool loadLocalPackageOnStart;
private async void Start()
{
if (Application.isEditor is false)
{
BIT4Log.Log<UnityModService>($"UnityPlayer所在位置:{Application.dataPath}");
BIT4Log.Log<UnityModService>($"{nameof(System.Linq)}位于{typeof(Enumerable).Assembly.Location}");
}
foreach (var x in referencedAssemblies)
{
var dllName = x.Value.Contains(".dll") ? x.Value : $"{x.Value}.dll";

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using BITKit.Net.LAN;
using Cysharp.Threading.Tasks;
@@ -23,8 +24,10 @@ namespace BITKit.Mod
_broadcaster.StartListen();
}
private void OnReceive(EndPoint arg1, byte[] bytes)
private async void OnReceive(EndPoint arg1, byte[] bytes)
{
await UniTask.SwitchToMainThread();
if(destroyCancellationToken.IsCancellationRequested) return;
var command = BITBinary.ReadAsValue(bytes);
switch (command)
{
@@ -32,6 +35,17 @@ namespace BITKit.Mod
BIT4Log.Log<UnityWorkshopClient>($"收到加载命令:{loadFromFolderCommand.FolderPath}");
ModService.LoadFromPackage(loadFromFolderCommand.FolderPath).Forget();
break;
case UninstallPackageCommand uninstallPackageCommand:
BIT4Log.Log<UnityWorkshopClient>($"收到卸载命令:{uninstallPackageCommand.PackageName}");
var mod = ModService.Mods.SingleOrDefault(x=>x.PackageName == uninstallPackageCommand.PackageName);
if (mod is null)
{
BIT4Log.Warning<UnityWorkshopClient>($"未找到包:{uninstallPackageCommand.PackageName}");
return;
}
ModService.UnLoad(mod);
ModService.UnInstall(mod);
break;
default:
BIT4Log.Log<UnityWorkshopClient>($"未知命令:{command}");
break;

View File

@@ -99,15 +99,26 @@ namespace BITKit.UX
{
await UniTask.SwitchToMainThread();
if (destroyCancellationToken.IsCancellationRequested) return;
_modContainers.GetOrAdd(obj.Name,_=> Create(obj));
var container = _modContainers.GetOrAdd(obj.Name,_=> Create(obj));
container.visualElement.RegisterCallback<MouseDownEvent>(x =>
{
if (x.button != 1) return;
ContextMenuBuilder.Create().BuildAction("卸载", () =>
{
ModService.UnLoad(obj);
ModService.UnInstall(obj);
}).Build();
});
}
private async void OnModUnLoaded(IMod obj)
{
await UniTask.SwitchToMainThread();
if (destroyCancellationToken.IsCancellationRequested) return;
var container = _modContainers.GetOrAdd(obj.Name,_=> Create(obj));
container.toggle.SetValueWithoutNotify(false);
//var container = _modContainers.GetOrAdd(obj.Name,_=> Create(obj));
if(_modContainers.TryGetValue(obj.Name,out var container))
{
container.toggle.SetValueWithoutNotify(false);
}
}
private async void OnModLoaded(IMod obj)

View File

@@ -27,9 +27,9 @@ namespace BITKit
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError =true,
StandardErrorEncoding = System.Text.Encoding.UTF8,
StandardInputEncoding = System.Text.Encoding.UTF8,
StandardOutputEncoding = System.Text.Encoding.UTF8,
StandardErrorEncoding = System.Text.Encoding.GetEncoding("gb2312"),
//StandardInputEncoding = System.Text.Encoding.GetEncoding("gb2312"),
StandardOutputEncoding = System.Text.Encoding.GetEncoding("gb2312"),
};
if(arguments != null)
{