using System; using System.Collections; using System.Collections.Generic; using BITKit; using BITKit.Mod; using BITKit.UX; using Cysharp.Threading.Tasks; using Microsoft.Extensions.Logging; using Net.Project.B.UX; using Project.B.Map; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UIElements; using IUXDialogue = BITKit.UX.IUXDialogue; namespace Project.B.UX { public class UXInitialize : UIToolKitPanel,ILogger, IUXInitialize { protected override string DocumentPath => "ui_initialize"; private readonly IGameMapService _gameMapService; private readonly IUXDialogue _dialogue; private readonly DoubleBuffer _lastMessage = new(); [UXBindPath("state-label")] private Label _stateLabel; public UXInitialize(IUXService uxService, IGameMapService gameMapService) : base(uxService) { _gameMapService = gameMapService; OnInitiated +=Initiated; } private void Initiated() { if (_lastMessage.TryGetRelease(out var message)) { _stateLabel.text = message; } } [HideInCallstack] public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) { switch (logLevel) { case LogLevel.Error: Debug.LogError(state.ToString()); break; case LogLevel.Warning: Debug.LogWarning(state.ToString()); break; case LogLevel.Critical: Debug.LogException(exception); break; default: Debug.Log(state.ToString()); break; } if (_stateLabel is null) { _lastMessage.Release(state.ToString()); } else { _stateLabel.text = state.ToString(); } } public bool IsEnabled(LogLevel logLevel) => IsEntered; public IDisposable BeginScope(TState state) where TState : notnull => null; } }