1
This commit is contained in:
56
Src/Unity/Scripts/UX/ApplicationFile/UXApplicationFile.cs
Normal file
56
Src/Unity/Scripts/UX/ApplicationFile/UXApplicationFile.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.IO;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.UX
|
||||
{
|
||||
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(IStorageFile arg1, IStorageFile arg2)
|
||||
{
|
||||
await UniTask.SwitchToMainThread();
|
||||
if (destroyCancellationToken.IsCancellationRequested) return;
|
||||
if (arg2 is not null)
|
||||
{
|
||||
_savePathLabel.text = arg2.GetPath();
|
||||
_reloadButton.SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_reloadButton.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2894e80bc1f4e5f469a6bbfe4e7f3b46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user