1
This commit is contained in:
@@ -38,7 +38,7 @@ namespace BITKit.Apps
|
||||
_cancelDownloadButton.clicked+=OnCancelDownload;
|
||||
destroyCancellationToken.Register(Dispose);
|
||||
|
||||
_container.Entry("entry-container");
|
||||
_container.Navigate("entry-container");
|
||||
}
|
||||
|
||||
private void Dispose()
|
||||
@@ -50,7 +50,7 @@ namespace BITKit.Apps
|
||||
}
|
||||
private void OnDownloadLatest(string obj)
|
||||
{
|
||||
_container.Entry("download-container");
|
||||
_container.Navigate("download-container");
|
||||
}
|
||||
|
||||
private void ConfirmDownload()
|
||||
@@ -67,7 +67,7 @@ namespace BITKit.Apps
|
||||
|
||||
private void OnDownloadComplete(string obj)
|
||||
{
|
||||
_container.Entry("complete-container");
|
||||
_container.Navigate("complete-container");
|
||||
}
|
||||
|
||||
private void OnDownloadProgress(float obj)
|
||||
@@ -83,16 +83,16 @@ namespace BITKit.Apps
|
||||
if (Application.version != obj)
|
||||
{
|
||||
_latestVersionLabel.text =obj;
|
||||
_container.Entry("entryDownload-container");
|
||||
_container.Navigate("entryDownload-container");
|
||||
}
|
||||
else
|
||||
{
|
||||
_container.Entry(null);
|
||||
_container.Navigate(null);
|
||||
}
|
||||
}
|
||||
private void OnCancelDownload()
|
||||
{
|
||||
_container.Entry(null);
|
||||
_container.Navigate(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ namespace Net.BITKit.Quadtree
|
||||
{
|
||||
|
||||
private readonly IEntitiesService _entitiesService;
|
||||
private readonly ConcurrentDictionary<int, Transform> _transforms = new();
|
||||
private readonly Dictionary<int, Transform> _transforms = new();
|
||||
private readonly ITicker _ticker;
|
||||
public QuadTreeService(IEntitiesService entitiesService, ITicker ticker)
|
||||
{
|
||||
@@ -45,16 +45,16 @@ namespace Net.BITKit.Quadtree
|
||||
|
||||
private void OnTick(float obj)
|
||||
{
|
||||
foreach (var (id,transform) in _transforms)
|
||||
{
|
||||
Quadtree.Remove(id);
|
||||
Quadtree.Insert(id,((float3)transform.position).xz);
|
||||
}
|
||||
foreach (var (id, transform) in _transforms)
|
||||
{
|
||||
Quadtree.Remove(id);
|
||||
Quadtree.Insert(id, ((float3)transform.position).xz);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRemove(IEntity obj)
|
||||
{
|
||||
_transforms.TryRemove(obj.Id,out _);
|
||||
_transforms.TryRemove(obj.Id);
|
||||
Quadtree.Remove(obj.Id);
|
||||
}
|
||||
|
||||
|
69
Src/Unity/Scripts/UX/Library/AdaptiveGrid.cs
Normal file
69
Src/Unity/Scripts/UX/Library/AdaptiveGrid.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Net.BITKit.UX
|
||||
{
|
||||
public class AdaptiveGrid : VisualElement
|
||||
{
|
||||
public new class UxmlFactory : UxmlFactory<AdaptiveGrid, UxmlTraits>
|
||||
{
|
||||
}
|
||||
|
||||
public AdaptiveGrid()
|
||||
{
|
||||
style.flexDirection = FlexDirection.Row;
|
||||
style.flexWrap = Wrap.Wrap;
|
||||
|
||||
RegisterCallback<GeometryChangedEvent>(_ => UpdateLayout());
|
||||
RegisterCallback<AttachToPanelEvent>(_ => UpdateLayout());
|
||||
RegisterCallback<DetachFromPanelEvent>(_ => UpdateLayout());
|
||||
}
|
||||
|
||||
private void UpdateLayout()
|
||||
{
|
||||
var width = resolvedStyle.width;
|
||||
|
||||
if (childCount == 0 || width <= 0) return;
|
||||
|
||||
var sampleVisualElement = contentContainer[0];
|
||||
|
||||
var max = sampleVisualElement.resolvedStyle.maxWidth.value;
|
||||
var min = sampleVisualElement.resolvedStyle.minHeight.value;
|
||||
|
||||
if (max == 0)
|
||||
{
|
||||
max = sampleVisualElement.resolvedStyle.width;
|
||||
}
|
||||
if(min == 0)
|
||||
{
|
||||
min = max * 0.8f;
|
||||
}
|
||||
|
||||
var count= Mathf.FloorToInt(width / min);
|
||||
|
||||
var remainder = width % count;
|
||||
var itemWidth = (width - remainder) / count;
|
||||
var itemHeight = itemWidth * 0.8f;
|
||||
|
||||
var spacing = (width - itemWidth * count) / (count - 1);
|
||||
spacing = spacing < 0 ? 0 : spacing;
|
||||
|
||||
for (var i = 0; i < childCount; i++)
|
||||
{
|
||||
var child =contentContainer[i];
|
||||
child.style.width = itemWidth-spacing;
|
||||
child.style.height = itemHeight-spacing;
|
||||
|
||||
if (i % count != 0)
|
||||
{
|
||||
child.style.marginRight = spacing;
|
||||
child.style.marginBottom = spacing;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
11
Src/Unity/Scripts/UX/Library/AdaptiveGrid.cs.meta
Normal file
11
Src/Unity/Scripts/UX/Library/AdaptiveGrid.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc041fa6dfb99954099521c02c33ea1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -39,10 +39,9 @@ namespace BITKit.UX
|
||||
{
|
||||
UXService = uxService;
|
||||
uxService.Register(this);
|
||||
InitializeAsync().Forget();
|
||||
}
|
||||
|
||||
private async UniTask InitializeAsync()
|
||||
public override async UniTask InitializeAsync()
|
||||
{
|
||||
await _isBusy;
|
||||
using var b = _isBusy.GetHandle();
|
||||
|
@@ -33,14 +33,6 @@ namespace BITKit.UX
|
||||
_windowEntryGroup.OnStateChanged += OnWindowEntry;
|
||||
_ticker.Add(OnTick);
|
||||
}
|
||||
|
||||
private void OnWindowExit(IUXPanel obj)
|
||||
{
|
||||
BITAppForUnity.AllowCursor.RemoveElement(_windowEntryGroup);
|
||||
if (obj.AllowInput is false)
|
||||
BITInputSystem.AllowInput.RemoveDisableElements(_windowEntryGroup);
|
||||
}
|
||||
|
||||
private void OnWindowEntry(IUXPanel prev, IUXPanel next)
|
||||
{
|
||||
BITAppForUnity.AllowCursor.SetElements(_windowEntryGroup, next is { AllowCursor: true });
|
||||
|
@@ -426,15 +426,6 @@ namespace BITKit
|
||||
}
|
||||
return default;
|
||||
}
|
||||
public static bool TryGetComponentsInParent<T>(this GameObject self, out T[] components)
|
||||
{
|
||||
return TryGetComponentsInParent(self.transform, out components);
|
||||
}
|
||||
public static bool TryGetComponentsInParent<T>(this Component self, out T[] components)
|
||||
{
|
||||
components = self.GetComponentsInParent<T>();
|
||||
return components.IsValid();
|
||||
}
|
||||
public static bool TryGetComponentAny<T>(this Component self, out T component)
|
||||
{
|
||||
component = self.GetComponentInChildren<T>(true);
|
||||
@@ -597,24 +588,60 @@ namespace BITKit
|
||||
self.Add(clone);
|
||||
return clone;
|
||||
}
|
||||
public static bool Entry(this VisualElement self, string name,bool visibleOnEmpty=false)
|
||||
|
||||
public static bool Navigate(this VisualElement self, string name)
|
||||
{
|
||||
var result=false;
|
||||
foreach (var x in self.Children())
|
||||
while (true)
|
||||
{
|
||||
if (string.Equals(x.name, name))
|
||||
var result = false;
|
||||
|
||||
var split = name.Split("/");
|
||||
if (split.Length > 1)
|
||||
{
|
||||
x.SetActive(true);
|
||||
result = true;
|
||||
var root = self;
|
||||
var last = string.Empty;
|
||||
foreach (var path in split)
|
||||
{
|
||||
var ve = root.Q(path);
|
||||
if (ve is not null)
|
||||
{
|
||||
root = ve;
|
||||
last = path;
|
||||
}
|
||||
}
|
||||
|
||||
if (root != self)
|
||||
{
|
||||
self = root.parent;
|
||||
name = last;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x.SetActive(false);
|
||||
foreach (var x in self.Children())
|
||||
{
|
||||
if (string.Equals(x.name, name, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
x.SetActive(true);
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
x.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
self.SetActive(visibleOnEmpty || result);
|
||||
return result;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static T Get<T>(this VisualElement self ,int index = 0) where T : VisualElement => self.Q<T>($"{typeof(T).Name}--{index}");
|
||||
public static T Create<T>(this VisualElement self, string name = Constant.EmetyString) where T : VisualElement,new()
|
||||
{
|
||||
@@ -649,10 +676,12 @@ namespace BITKit
|
||||
public static void SetOpacity(this VisualElement self, float value) => self.style.opacity = new(value);
|
||||
public static void ScrollToBottom(this ScrollView self)
|
||||
{
|
||||
self.verticalScroller.value =
|
||||
self.verticalScroller.highValue > 0 ? self.verticalScroller.highValue : 0;
|
||||
self.schedule.Execute(() =>
|
||||
{
|
||||
self.scrollOffset = new Vector2(0, float.MaxValue);
|
||||
});
|
||||
}
|
||||
public static async void ScrollToBottomAutomatic(this ScrollView self, float delay = 0.02f)
|
||||
public static void ScrollToBottomAutomatic(this ScrollView self, float delay = 0.02f)
|
||||
{
|
||||
switch (true)
|
||||
{
|
||||
@@ -661,7 +690,6 @@ namespace BITKit
|
||||
case true when Math.Abs(self.verticalScroller.value - self.verticalScroller.highValue) < 0.01f:
|
||||
try
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(delay), BITApp.CancellationToken);
|
||||
ScrollToBottom(self);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
29
Src/Unity/Scripts/Win64/GetWindowsWallPaper.cs
Normal file
29
Src/Unity/Scripts/Win64/GetWindowsWallPaper.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
|
||||
public class GetWindowsWallPaper
|
||||
{
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool SystemParametersInfo(int uAction, int uParam, StringBuilder lpvParam, int fuWinIni);
|
||||
|
||||
const int SPI_GETDESKWALLPAPER = 0x0073;
|
||||
const int MAX_PATH = 260;
|
||||
|
||||
public static string GetWallpaperPath()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(MAX_PATH);
|
||||
if (SystemParametersInfo(SPI_GETDESKWALLPAPER, sb.Capacity, sb, 0))
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
11
Src/Unity/Scripts/Win64/GetWindowsWallPaper.cs.meta
Normal file
11
Src/Unity/Scripts/Win64/GetWindowsWallPaper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45155c6ffea0e34428dd2cfabd1b7deb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,11 +1,11 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<Style src="project://database/Assets/BITKit/Unity/UX/Common/Common.uss?fileID=7433441132597879392&guid=a3a69d3518fd02b489e721f3c5b0b539&type=3#Common" />
|
||||
<Style src="project://database/Assets/BITKit/Unity/UX/BITQuest.uss?fileID=7433441132597879392&guid=5c2d746d52de8e340b788034994ee23e&type=3#BITQuest" />
|
||||
<Kamgam.UIToolkitBlurredBackground.BlurredBackground name="quest-element" Blur-Tint="#000000C8" class="quest" style="padding-top: 4px; padding-right: 8px; padding-bottom: 4px; padding-left: 8px; margin-top: 4px; margin-right: 8px; margin-bottom: 4px; margin-left: 8px;">
|
||||
<ui:VisualElement name="quest-element" Blur-Tint="#000000C8" class="quest" style="padding-top: 4px; padding-right: 8px; padding-bottom: 4px; padding-left: 8px; margin-top: 4px; margin-right: 8px; margin-bottom: 4px; margin-left: 8px;">
|
||||
<ui:VisualElement name="Header" class="flex-horizontal">
|
||||
<ui:VisualElement name="VisualElement--0" class="quest-icon game-icon" />
|
||||
<ui:Label text="NewQuest" display-tooltip-when-elided="true" name="Label--0" class="quest-title" />
|
||||
</ui:VisualElement>
|
||||
<ui:Label text="Fnish This Quest" display-tooltip-when-elided="true" name="Label--1" class="quest-description" />
|
||||
</Kamgam.UIToolkitBlurredBackground.BlurredBackground>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@@ -7,6 +7,14 @@ ScrollView {
|
||||
--unity-metrics-single_line-height: 500px;
|
||||
}
|
||||
|
||||
ScrollView Scroller.unity-scroller{
|
||||
width: 8;
|
||||
}
|
||||
|
||||
ScrollView Scroller.unity-scroller * {
|
||||
width: 8;
|
||||
}
|
||||
|
||||
TabBar Button:disabled {
|
||||
opacity: 1;
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ Slider.material {
|
||||
}
|
||||
|
||||
.material Button {
|
||||
background-color: rgba(26, 115, 232, 0.06);
|
||||
background-color: rgba(26, 115, 232, 0.13);
|
||||
border-left-width: 0;
|
||||
border-right-width: 0;
|
||||
border-top-width: 0;
|
||||
@@ -219,3 +219,23 @@ Slider.material {
|
||||
min-width: 128px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.unity-base-field.variant-text #unity-text-input {
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
border-top-width: 0;
|
||||
border-right-width: 0;
|
||||
border-bottom-width: 0;
|
||||
border-left-width: 0;
|
||||
}
|
||||
|
||||
.material TabBar.variable-square Button {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
max-width: 64px;
|
||||
max-height: 64px;
|
||||
min-width: 64px;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
border-bottom-right-radius: 10px;
|
||||
border-bottom-left-radius: 10px;
|
||||
}
|
||||
|
Reference in New Issue
Block a user