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

File diff suppressed because one or more lines are too long

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)
{

View File

@@ -5,7 +5,7 @@
<ui:VisualElement name="Console" class="Console" style="width: 1024px; height: 768px; border-top-left-radius: 16px; border-bottom-left-radius: 16px; border-top-right-radius: 16px; border-bottom-right-radius: 16px; padding-left: 16px; padding-right: 16px; padding-top: 8px; padding-bottom: 8px; margin-left: auto; margin-right: auto; margin-top: auto; margin-bottom: auto;">
<ui:Label text="Console" display-tooltip-when-elided="true" class="Console-Text" />
<ui:ScrollView name="context-scrollview" class="Console-ScrollView" style="height: auto; flex-grow: 1; display: flex;">
<ui:Label text="This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text&#10;This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text&#10;This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text&#10;This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text&#10;This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text" display-tooltip-when-elided="true" name="Text" class="Console-Text" style="padding-left: 8px; padding-right: 8px; padding-top: 4px; padding-bottom: 4px; white-space: normal;" />
<ui:Label text="This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text&#10;This is Console&#10;This is &lt;size=24&gt;Rich Text&lt;/size&gt;&#10;This is &lt;color=yellow&gt;Warning&lt;/color&gt;&#10;This is &lt;color=red&gt;Error&lt;/color&gt;&#10;This is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text&#10;&lt;color=#add8e6ff&gt;&lt;b&gt;TypeName&lt;/b&gt;&lt;/color&gt;:MyMessage" display-tooltip-when-elided="true" name="Text" enable-rich-text="true" parse-escape-sequences="false" class="Console-Text" style="padding-left: 8px; padding-right: 8px; padding-top: 4px; padding-bottom: 4px; white-space: normal;" />
</ui:ScrollView>
<ui:TextField picking-mode="Ignore" value="filler text" text="filler text" name="TextField" class="Console-TextField" style="height: 48px;" />
</ui:VisualElement>

View File

@@ -58,7 +58,7 @@ TabBar Button:disabled {
padding-top: 32px;
padding-bottom: 32px;
-unity-font-definition: initial;
-unity-font: url('project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Regular.ttc?fileID=12800000&guid=170bacfb8afc52a468d956884ff0be08&type=3#SourceHanMono-Regular');
-unity-font: url("project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Regular.ttc?fileID=12800000&guid=170bacfb8afc52a468d956884ff0be08&type=3#SourceHanMono-Regular");
}
.pa-64 {
@@ -107,7 +107,7 @@ TabBar Button:disabled {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
-unity-font-definition: initial;
-unity-font: url('project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Regular.ttc?fileID=12800000&guid=170bacfb8afc52a468d956884ff0be08&type=3#SourceHanMono-Regular');
-unity-font: url("project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Regular.ttc?fileID=12800000&guid=170bacfb8afc52a468d956884ff0be08&type=3#SourceHanMono-Regular");
padding-left: 6px;
padding-right: 6px;
padding-top: 6px;
@@ -138,7 +138,7 @@ TabBar Button:disabled {
}
.unity-text-element {
-unity-font-definition: url('project://database/Assets/BITKit/Unity/Art/Fonts/SDF/SourceHanMono-Regular%20SDF.asset?fileID=11400000&guid=b3753d022dd4b4545b0e5f3f6e9a997f&type=2#Assets/BITKit/Unity/Art/Fonts/SDF/SourceHanMono-Regular SDF.asset');
-unity-font-definition: url("project://database/Assets/BITKit/Unity/Art/Fonts/SDF/Roboto-Regular%20SDF.asset?fileID=11400000&guid=5b449e7b33d231a4085b869a8ae2c94c&type=2#Roboto-Regular SDF");
}
#unity-text-input .unity-text-element {
@@ -147,12 +147,12 @@ TabBar Button:disabled {
.theme-light .unity-text-element {
color: rgb(31, 31, 31);
-unity-font: url('project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Medium.ttc?fileID=12800000&guid=c8058440fb1ea26488e022a5ee5b3b35&type=3#SourceHanMono-Medium');
-unity-font: url("project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Medium.ttc?fileID=12800000&guid=c8058440fb1ea26488e022a5ee5b3b35&type=3#SourceHanMono-Medium");
}
.theme-dark .unity-text-element {
color: rgb(231, 231, 231);
-unity-font: url('project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Medium.ttc?fileID=12800000&guid=c8058440fb1ea26488e022a5ee5b3b35&type=3#SourceHanMono-Medium');
-unity-font: url("project://database/Assets/BITKit/Unity/Art/Fonts/TTF/SourceHanMono/SourceHanMono-Medium.ttc?fileID=12800000&guid=c8058440fb1ea26488e022a5ee5b3b35&type=3#SourceHanMono-Medium");
}
.theme-dark DropdownField > VisualElement > VisualElement {