1
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
#if UNITY_5_3_OR_NEWER && UNITY_WINDOW
|
||||
@@ -11,11 +12,13 @@ using AnotherFileBrowser.Windows;
|
||||
using BITKit.Mod;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.UIElements;
|
||||
using Pointer = UnityEngine.InputSystem.Pointer;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
public class UXModService:UIToolKitPanel,IDisposable
|
||||
public class UXModService:UIToolKitPanel
|
||||
{
|
||||
protected override string DocumentPath => "ux_mod_Service";
|
||||
private const string TemplatePath = "ux_mod_service_template";
|
||||
@@ -37,8 +40,7 @@ namespace BITKit.UX
|
||||
private Label _modDescriptionLabel;
|
||||
[UXBindPath("reload-mod-button",true)]
|
||||
private Button _reloadModButton;
|
||||
[UXBindPath("install-roslyn-fill")]
|
||||
private VisualElement _installRoslynFill;
|
||||
|
||||
|
||||
private readonly ConcurrentDictionary<string,VisualElement> _modContainers=new();
|
||||
public UXModService(IUXService uxService) : base(uxService)
|
||||
@@ -54,8 +56,6 @@ namespace BITKit.UX
|
||||
|
||||
private async UniTask InitializeAsync()
|
||||
{
|
||||
_installRoslynFill.style.width = 0;
|
||||
|
||||
_modTemplate =await ModService.LoadAsset<VisualTreeAsset>(TemplatePath);
|
||||
UXUtils.Inject(this);
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace BITKit.UX
|
||||
private VisualElement Create(IMod mod)
|
||||
{
|
||||
var container =_modsContainer.Create(_modTemplate);
|
||||
container.Get<Toggle>().SetValueWithoutNotify(ModService.Mods.Contains(mod));
|
||||
container.Get<Toggle>().RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
if (evt.newValue)
|
||||
@@ -145,6 +146,7 @@ namespace BITKit.UX
|
||||
ModService.UnLoad(mod);
|
||||
}
|
||||
});
|
||||
container.Get<Label>().text = mod.Name +"@"+mod.PackageName;
|
||||
container.tooltip = mod.Name+"\n"+mod.Description;
|
||||
|
||||
container.Get<Button>().clicked += () =>
|
||||
@@ -155,8 +157,9 @@ namespace BITKit.UX
|
||||
return container;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
ModService.OnModInstalled-=OnModInstalled;
|
||||
ModService.OnModUnInstalled-=OnModUnInstalled;
|
||||
ModService.OnModLoaded-=OnModLoaded;
|
||||
|
Reference in New Issue
Block a user