using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using BITKit; using BITKit.Entities; using BITKit.Mod; using BITKit.UX; using Cysharp.Threading.Tasks; using Net.BITKit.Localization; using Project.B.Item; using Project.B.Player; using Project.B.UX; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UIElements; using Object = UnityEngine.Object; namespace Net.Project.B.UX { public class UXItemInspector : UIToolKitPanel, IUXItemInspector { private readonly IEntitiesService _entitiesService; private readonly IWrapper _playerSettings; private readonly ILocalizationService _localizationService; protected override string DocumentPath => "ui_item_inspector"; public override bool AllowCursor => true; private readonly IUXKeyMap _uxKeyMap; private Camera _rendererCamera; private UniTaskCompletionSource _closeSource; private readonly Dictionary _scriptableItems; public UXItemInspector(IUXService uxService, IUXKeyMap uxKeyMap, ILocalizationService localizationService, IWrapper playerSettings, IEntitiesService entitiesService) : base(uxService) { _uxKeyMap = uxKeyMap; _localizationService = localizationService; _playerSettings = playerSettings; _entitiesService = entitiesService; OnInitiated += Initiated; _scriptableItems = _entitiesService.QueryComponents().ToArray().ToDictionary(x => x.name); } private void Initiated() { var dropdown = RootVisualElement.Get(); if (dropdown is not null) { dropdown.choices.Clear(); { foreach (var lang in Enum.GetValues(typeof(Lang)).OfType()) { var code = lang.GetType().GetMember(lang.ToString())[0].GetCustomAttribute().Description; dropdown.choices.Add(code); } } dropdown.value = _playerSettings.Value.Language; dropdown.RegisterValueChangedCallback(x => { var label = RootVisualElement.Get