This commit is contained in:
CortexCore
2024-11-03 16:42:23 +08:00
commit b125894cc3
5904 changed files with 1070129 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.IO;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UIElements;
namespace BITKit.UX
{
#if UNITY_5_3_OR_NEWER
public class UXApplicationFile : MonoBehaviour
{
[SerializeReference, SubclassSelector] private IApplicationFile applicationFile;
[UXBindPath("save-button")]
private Button _saveButton;
[UXBindPath("save-as-button")]
private Button _saveAsButton;
[UXBindPath("reload-button")]
private Button _reloadButton;
[UXBindPath("load-button")]
private Button _loadButton;
[UXBindPath("save-path-label")]
private Label _savePathLabel;
private void Start()
{
UXUtils.Inject(this);
_saveButton.clicked += applicationFile.Save;
_loadButton.clicked += ()=>applicationFile.Load();
_saveAsButton.clicked += ()=>applicationFile.SaveAs();
_reloadButton.clicked += applicationFile.Reload;
applicationFile.OnPathChanged+=OnPathChanged;
OnPathChanged(null,applicationFile.Current);
_reloadButton.SetEnabled(false);
}
private async void OnPathChanged(string arg1, string arg2)
{
await UniTask.SwitchToMainThread();
if (destroyCancellationToken.IsCancellationRequested) return;
if (arg2 is not null)
{
_savePathLabel.text = arg2;
_reloadButton.SetEnabled(true);
}
else
{
_reloadButton.SetEnabled(false);
}
}
}
#endif
}