47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using BITKit.Mod;
|
|
using BITKit.StateMachine;
|
|
using BITKit.UX;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace Net.Project.B.PDA
|
|
{
|
|
public abstract class PDAApp<T>:StateAsync,IAppClass<T> where T:IApp,new()
|
|
{
|
|
public Type AppType => typeof(T);
|
|
public readonly T App = new T();
|
|
|
|
protected PDAApp()
|
|
{
|
|
Routes = new[] {$"/{GetType().Name}" };
|
|
}
|
|
|
|
|
|
public IReadOnlyList<string> Routes { get; }
|
|
public virtual UniTask<object> GetPage(string route)
|
|
{
|
|
RootVisualElement.Navigate(route);
|
|
|
|
return UniTask.FromResult<object>(RootVisualElement);
|
|
}
|
|
|
|
protected abstract string DocumentPath { get; }
|
|
protected VisualElement RootVisualElement { get; private set; }
|
|
public override async UniTask InitializeAsync()
|
|
{
|
|
var template = await ModService.LoadAsset<VisualTreeAsset>(DocumentPath);
|
|
|
|
RootVisualElement = template.CloneTree();
|
|
|
|
UXUtils.Inject(this,RootVisualElement);
|
|
}
|
|
|
|
}
|
|
|
|
}
|