This commit is contained in:
CortexCore
2025-03-15 20:09:18 +08:00
parent 7979e09be4
commit 824ff2e4c7
106 changed files with 4793 additions and 1618 deletions

View File

@@ -13,8 +13,11 @@ using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UIElements;
using System.Linq;
using AHD2TimeOfDay;
using BITKit.Entities;
using BITKit.Mod;
using BITKit.StateMachine;
using Microsoft.Extensions.Logging;
using Net.BITKit.Localization;
using Project.B.CharacterController;
using Project.B.Entities;
@@ -25,6 +28,7 @@ namespace Net.Like.Xue.Tokyo.UX
{
public class UXEscMenu : UIToolKitPanel,IDisposable
{
private readonly ILogger<UXEscMenu> _logger;
private readonly IPlayerFactory _playerFactory;
private readonly IEntitiesService _entitiesService;
private readonly ILocalizationService _localizationService;
@@ -48,13 +52,15 @@ namespace Net.Like.Xue.Tokyo.UX
private Toggle _enableChsToggle;
[UXBindPath("enable-tps-toggle")]
private Toggle _enableTpsToggle;
[UXBindPath("time-slider")]
private Slider _timeSlider;
private VisualTreeAsset _template;
[Inject]
private IPlayerCharacterController _playerCharacterController;
public UXEscMenu(IUXService uxService, IUXDialogue uxDialogue, IGameMapService gameMapService, IUXKeyMap<InputAction> uxKeyMap, IDialogueService dialogueService, ILocalizationService localizationService, IEntitiesService entitiesService, IPlayerFactory playerFactory) : base(uxService)
public UXEscMenu(IUXService uxService, IUXDialogue uxDialogue, IGameMapService gameMapService, IUXKeyMap<InputAction> uxKeyMap, IDialogueService dialogueService, ILocalizationService localizationService, IEntitiesService entitiesService, IPlayerFactory playerFactory, ILogger<UXEscMenu> logger) : base(uxService)
{
_uxDialogue = uxDialogue;
_gameMapService = gameMapService;
@@ -63,6 +69,7 @@ namespace Net.Like.Xue.Tokyo.UX
_localizationService = localizationService;
_entitiesService = entitiesService;
_playerFactory = playerFactory;
_logger = logger;
OnInitiated += Initiated;
OnInitiatedAsync += InitiatedAsync;
@@ -73,6 +80,8 @@ namespace Net.Like.Xue.Tokyo.UX
playerFactory.OnEntityCreated += OnEntityCreated;
}
private UniTask OnEntityCreated(string arg1, IEntity arg2)
{
arg2.Inject(this);
@@ -90,6 +99,29 @@ arg2.Inject(this);
{
_template =await ModService.LoadAsset<VisualTreeAsset>("ui_esc_menu_dialogue-template");
_dialogueContainer.Clear();
_timeSlider.RegisterValueChangedCallback(OnTime);
}
public override void OnStateEntry(IState old)
{
base.OnStateEntry(old);
var enable = _entitiesService.QueryComponents<TODController>().Length > 0;
_timeSlider.SetEnabled(enable);
_timeSlider.tooltip = enable ? string.Empty : "这个地图没有开启昼夜系统";
}
private void OnTime(ChangeEvent<float> evt)
{
var controllers = _entitiesService.QueryComponents<TODController>();
foreach (var todController in controllers)
{
var par = todController.todGlobalParameters;
par.CurrentTime = evt.newValue;
todController.todGlobalParameters = par;
todController.SetGlobalParameters();
}
}
private UniTask OnDialogueStart(IDialogueData arg)
@@ -170,7 +202,7 @@ arg2.Inject(this);
_enableChsToggle.RegisterValueChangedCallback(x =>
{
_uxDialogue.SubtitleLanguage = x.newValue ? "zh-CN" : string.Empty;
_uxDialogue.SubtitleLanguages = x.newValue ? _localizationService.LocalizedStrings.Keys.ToArray() : null;
});
_enableTpsToggle.RegisterValueChangedCallback(x =>