This commit is contained in:
CortexCore
2025-03-10 22:42:42 +08:00
parent ad7065fa02
commit d83387500d
16 changed files with 233 additions and 39 deletions

View File

@@ -5,6 +5,7 @@ using BITKit.UX.Settings;
using Cysharp.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Net.BITKit.Localization;
using Net.Like.Xue.Tokyo.UX;
using Net.Project.B.UX;
using Project.B.Player;
@@ -61,6 +62,9 @@ namespace Net.Like.Xue.Tokyo
//获取服务提供者
await using var serviceProvider = BITApp.ServiceProvider = serviceCollection.BuildServiceProvider();
serviceProvider.GetRequiredService<CsvLocalizationService>().Url =
@"http://server.bitfall.icu:21982/net.like.xue.tokyo/net.like.xue.tokyo.localization.csv";
await global::Project.B.Program.BuildServiceProvider(serviceProvider,destroyCancellationToken);
var uxService = serviceProvider.GetRequiredService<IUXService>();
@@ -75,7 +79,7 @@ namespace Net.Like.Xue.Tokyo
serviceProvider.GetRequiredService<IUXHud>();
serviceProvider.GetRequiredService<IUXDialogue>();
serviceProvider.GetRequiredService<IUXDialogue>().SubtitleLanguage="zh-CN";
serviceProvider.GetRequiredService<IUXLoadingMap>();
@@ -85,6 +89,8 @@ namespace Net.Like.Xue.Tokyo
serviceProvider.GetRequiredService<IUXBuyStation>();
serviceProvider.GetRequiredService<UXEscMenu>();
serviceProvider.GetRequiredKeyedService<IUXMap>(nameof(IUXHud));
serviceProvider.GetRequiredKeyedService<IUXMap>(nameof(IUXMap));

View File

@@ -13,12 +13,18 @@ using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UIElements;
using System.Linq;
using BITKit.Entities;
using BITKit.Mod;
using Net.BITKit.Localization;
using YooAsset;
using IUXDialogue = Net.Project.B.UX.IUXDialogue;
namespace Net.Like.Xue.Tokyo.UX
{
public class UXEscMenu : UIToolKitPanel,IDisposable
{
private readonly IEntitiesService _entitiesService;
private readonly ILocalizationService _localizationService;
private readonly IDialogueService _dialogueService;
private readonly IGameMapService _gameMapService;
private readonly IUXDialogue _uxDialogue;
@@ -29,35 +35,90 @@ namespace Net.Like.Xue.Tokyo.UX
private readonly IUXKeyMap<InputAction> _uxKeyMap;
private readonly ConcurrentDictionary<int, IDialogueData> _dialogues = new();
[UXBindPath("dialogue-container")]
private VisualElement _dialogueContainer;
[UXBindPath("return-button")]
private Button _returnButton;
[UXBindPath("exit-button")]
private Button _exitButton;
[UXBindPath("log-label")]
private Label _logLabel;
private VisualTreeAsset _template;
public UXEscMenu(IUXService uxService, IUXDialogue uxDialogue, IGameMapService gameMapService, IUXKeyMap<InputAction> uxKeyMap, IDialogueService dialogueService) : base(uxService)
public UXEscMenu(IUXService uxService, IUXDialogue uxDialogue, IGameMapService gameMapService, IUXKeyMap<InputAction> uxKeyMap, IDialogueService dialogueService, ILocalizationService localizationService, IEntitiesService entitiesService) : base(uxService)
{
_uxDialogue = uxDialogue;
_gameMapService = gameMapService;
_uxKeyMap = uxKeyMap;
_dialogueService = dialogueService;
_localizationService = localizationService;
_entitiesService = entitiesService;
_uxDialogue.OnSubtitle += OnSubtitle;
OnInitiated += Initiated;
OnInitiatedAsync += InitiatedAsync;
_dialogueService.OnDialogueStart += OnDialogueStart;
}
private async UniTask InitiatedAsync()
{
_template =await ModService.LoadAsset<VisualTreeAsset>("ui_esc_menu_dialogue-template");
_dialogueContainer.Clear();
}
private UniTask OnDialogueStart(IDialogueData arg)
{
_dialogues.TryAdd(arg.Identity, arg);
_logLabel.text = string.Join("\n", _dialogues.Values.Select(x => x.Text));
var actorName = arg.ActorIdentity.ToString();
try
{
if (arg.ActorIdentity != 0)
{
foreach (var idComponent in _entitiesService.QueryComponents<IdComponent>())
{
if (idComponent.Id == arg.ActorIdentity)
{
actorName = idComponent.Name;
throw new OperationCanceledException();
}
}
}
actorName = _entitiesService.QueryComponents<IdComponent, LocalPlayerComponent>()[0].Item1.Name;
}
catch (OperationCanceledException)
{
}
var container = _dialogueContainer.Create(_template);
container.Get<Label>().text = actorName;
container = container.Get<VisualElement>();
container.Clear();
foreach (var dictionary in _localizationService.LocalizedStrings.Values)
{
if (dictionary.TryGetValue(arg.Text, out var text))
{
container.Create<Label>().text = text;
}
else
{
container.Create<Label>().text = arg.Text;
}
}
return UniTask.CompletedTask;
}

View File

@@ -17,7 +17,7 @@ namespace Net.Like.Xue.Tokyo.UX
{
private readonly IGameMapService _gameMapService;
private readonly IEntitiesService _entitiesService;
public UXLevel(IUXService uxService, IGameMapService gameMapService, IEntitiesService entitiesService) : base(uxService)
{
_gameMapService = gameMapService;

View File

@@ -1,3 +1,42 @@
Button {
background-color: rgba(0, 0, 0, 0);
color: rgb(255, 255, 255);
border-left-color: rgba(255, 255, 255, 0.78);
border-right-color: rgba(255, 255, 255, 0.78);
border-top-color: rgba(255, 255, 255, 0.78);
border-bottom-color: rgba(255, 255, 255, 0.78);
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
}
Button:hover {
color: rgb(0, 0, 0);
border-left-color: rgba(255, 255, 255, 0.78);
border-right-color: rgba(255, 255, 255, 0.78);
border-top-color: rgba(255, 255, 255, 0.78);
border-bottom-color: rgba(255, 255, 255, 0.78);
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
background-color: rgb(255, 255, 255);
}
Button:active {
color: rgba(255, 255, 255, 0.5);
border-left-color: rgba(255, 255, 255, 0.78);
border-right-color: rgba(255, 255, 255, 0.78);
border-top-color: rgba(255, 255, 255, 0.78);
border-bottom-color: rgba(255, 255, 255, 0.78);
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
background-color: rgba(255, 255, 255, 0.5);
}
Label {
-unity-font-definition: url("project://database/Assets/Artists/Arts/Fonts/Meiryo%20UI%20W53%20Regular%20SDF.asset?fileID=11400000&guid=80d4eed6ab6a2c248b81331b3aab1c8c&type=2#Meiryo UI W53 Regular SDF");
}
@@ -15,9 +54,9 @@ Label {
margin-left: 0;
transition-duration: 0.2s;
-unity-background-scale-mode: scale-and-crop;
-unity-text-outline-width: 0.5px;
-unity-text-outline-color: rgba(0, 0, 0, 0);
height: auto;
min-width: 256px;
font-size: 48px;
}
.level-button > Button:hover {
@@ -42,7 +81,7 @@ Label {
color: rgb(128, 128, 128);
}
Button {
.lobby Button {
width: 300px;
height: 100px;
background-image: url("project://database/Assets/Arts/Artsystack%20-Modern%20Multiplayer%20GUI/ResourcesData/Sprites/components/button_yellow.png?fileID=21300000&guid=ad4e0d1615e1e9e4783475cbe9454ff6&type=3#button_yellow");
@@ -53,14 +92,14 @@ Button {
border-left-width: 0;
font-size: 32px;
color: rgb(255, 255, 255);
-unity-font-style: bold;
-unity-font-definition: url("project://database/Assets/Artists/Arts/Fonts/Meiryo%20UI%20W53%20Regular%20SDF.asset?fileID=11400000&guid=80d4eed6ab6a2c248b81331b3aab1c8c&type=2#Meiryo UI W53 Regular SDF");
}
Button:hover {
.lobby Button:hover {
font-size: 36px;
}
Button:active {
.lobby Button:active {
opacity: 0.5;
font-size: 32px;
}
@@ -75,8 +114,8 @@ TabBar > Button {
border-bottom-width: 0;
border-left-width: 0;
color: rgb(255, 255, 255);
-unity-font-style: bold-and-italic;
background-image: none;
-unity-font-style: italic;
}
TabBar > Button:disabled {
@@ -116,6 +155,10 @@ Button.color-secondary {
width: 200px;
height: 200px;
background-image: none;
margin-top: 12px;
margin-right: 12px;
margin-bottom: 12px;
margin-left: 12px;
}
.inventory-item {

View File

@@ -1,8 +1,8 @@
<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&amp;guid=a3a69d3518fd02b489e721f3c5b0b539&amp;type=3#Common" />
<Style src="project://database/Assets/Artists/UX/Style.uss?fileID=7433441132597879392&amp;guid=506d41b7c5d56a44bb5845e69055a5eb&amp;type=3#Style" />
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button--0" class="cosmetics-button" style="background-image: url(&quot;project://database/Assets/Arts/Artsystack%20-Modern%20Multiplayer%20GUI/ResourcesData/Sprites/components/dr_box_1.png?fileID=21300000&amp;guid=9a95df3a0adf20d43adaf5df02b90c0f&amp;type=3#dr_box_1&quot;); margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0;">
<ui:VisualElement name="VisualElement--0" class="root" style="margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; background-image: url(&quot;project://database/Assets/Arts/Artsystack%20-Modern%20Multiplayer%20GUI/ResourcesData/Sprites/colored_icon/coins%202.png?fileID=21300000&amp;guid=118635b51bd9c044582a7131270d3749&amp;type=3#coins 2&quot;);" />
<ui:Label tabindex="-1" text="Skin" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--0" style="position: absolute; left: 0; right: 0; bottom: 0; background-image: url(&quot;project://database/Assets/BITKit/Unity/Art/Backgrounds/BG_Gradient_Half_BT_.png?fileID=21300000&amp;guid=d19ac049792985540825b54b0b002529&amp;type=3#BG_Gradient_Half_BT_&quot;); -unity-background-image-tint-color: rgb(0, 0, 0);" />
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button--0" class="cosmetics-button" style="border-top-left-radius: 32px; border-top-right-radius: 32px; border-bottom-right-radius: 32px; border-bottom-left-radius: 32px; border-left-color: rgba(0, 155, 255, 0.78); border-right-color: rgba(0, 155, 255, 0.78); border-top-color: rgba(0, 155, 255, 0.78); border-bottom-color: rgba(0, 155, 255, 0.78); border-top-width: 8px; border-right-width: 8px; border-bottom-width: 8px; border-left-width: 8px; background-color: rgb(83, 236, 255); background-image: url(&quot;project://database/Assets/BITKit/Unity/Art/Backgrounds/BG_Gradient_Half_BT_.png?fileID=21300000&amp;guid=d19ac049792985540825b54b0b002529&amp;type=3#BG_Gradient_Half_BT_&quot;);">
<ui:VisualElement name="VisualElement--0" class="root" style="margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; background-image: url(&quot;project://database/Assets/Arts/Artsystack%20-Modern%20Multiplayer%20GUI/ResourcesData/Sprites/colored_icon/coins%202.png?fileID=21300000&amp;guid=118635b51bd9c044582a7131270d3749&amp;type=3#coins 2&quot;); left: -8px; top: -8px; right: -8px; bottom: -8px;" />
<ui:Label tabindex="-1" text="Skin" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--0" style="position: absolute; left: -4px; right: -4px; bottom: -4px; background-image: url(&quot;project://database/Assets/BITKit/Unity/Art/Backgrounds/BG_Gradient_Half_BT_.png?fileID=21300000&amp;guid=d19ac049792985540825b54b0b002529&amp;type=3#BG_Gradient_Half_BT_&quot;); -unity-background-image-tint-color: rgb(0, 0, 0); font-size: 24px;" />
</ui:Button>
</ui:UXML>

View File

@@ -1,3 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:VisualElement name="cosmetics-container" style="flex-direction: row; flex-wrap: wrap; width: 512px;" />
<ui:Template name="ui_cosmetics-template" src="project://database/Assets/Artists/UX/ui_cosmetics-template.uxml?fileID=9197481963319205126&amp;guid=7bc8fe7ad4997e34cb78a89ef29419ab&amp;type=3#ui_cosmetics-template" />
<ui:VisualElement name="cosmetics-container" style="width: 512px; flex-direction: row; flex-wrap: wrap;">
<ui:Instance template="ui_cosmetics-template" name="ui_cosmetics-template" />
<ui:Instance template="ui_cosmetics-template" name="ui_cosmetics-template" />
<ui:Instance template="ui_cosmetics-template" name="ui_cosmetics-template" />
<ui:Instance template="ui_cosmetics-template" name="ui_cosmetics-template" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -0,0 +1,10 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<Kamgam.UIToolkitBlurredBackground.BlurredBackground Blur-Tint="#000000C8" style="min-height: 64px; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px;">
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--0" class="tl" />
<ui:VisualElement name="VisualElement--0">
<ui:Label tabindex="-1" text="Chinese" parse-escape-sequences="true" display-tooltip-when-elided="true" enable-rich-text="false" />
<ui:Label tabindex="-1" text="Japanese" parse-escape-sequences="true" display-tooltip-when-elided="true" />
<ui:Label tabindex="-1" text="English" parse-escape-sequences="true" display-tooltip-when-elided="true" />
</ui:VisualElement>
</Kamgam.UIToolkitBlurredBackground.BlurredBackground>
</ui:UXML>

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 024cac2b9659e2d4595f190bafb2508e
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View File

@@ -1,8 +1,8 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/BITKit/Unity/UX/Common/Common.uss?fileID=7433441132597879392&amp;guid=a3a69d3518fd02b489e721f3c5b0b539&amp;type=3#Common" />
<Style src="project://database/Assets/Artists/UX/Style.uss?fileID=7433441132597879392&amp;guid=506d41b7c5d56a44bb5845e69055a5eb&amp;type=3#Style" />
<ui:VisualElement class="root">
<ui:VisualElement name="level-container" class="level-button" style="flex-direction: row; justify-content: flex-start; flex-grow: 1; align-items: stretch;">
<ui:VisualElement picking-mode="Ignore" class="root" style="right: 20%;">
<ui:VisualElement name="level-container" picking-mode="Ignore" class="level-button" style="flex-direction: row; justify-content: flex-start; flex-grow: 1; align-items: stretch;">
<ui:Button text="秋叶原" parse-escape-sequences="true" display-tooltip-when-elided="true" view-data-key="map_city_crossing" style="background-image: url(&quot;project://database/Assets/Artists/Arts/Textures/texture_akiba.jpg?fileID=21300000&amp;guid=4f4c68ed2c65cee4d98fa5dc45e00c8b&amp;type=3#texture_akiba&quot;);" />
<ui:Button text="街道" parse-escape-sequences="true" display-tooltip-when-elided="true" view-data-key="map_street" style="background-image: url(&quot;project://database/Assets/Artists/Arts/Textures/texture_street.jpg?fileID=21300000&amp;guid=4b7dac409ae6a5849b3088d55792c00b&amp;type=3#texture_street&quot;);" />
<ui:Button text="郊区" parse-escape-sequences="true" display-tooltip-when-elided="true" style="background-image: url(&quot;project://database/Assets/Artists/Arts/Textures/texture_suburb.jpg?fileID=21300000&amp;guid=8de2e8ea76d2fbb4f946bfb49bab55fd&amp;type=3#texture_suburb&quot;);" />

View File

@@ -1,17 +1,20 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Template name="ui_esc_menu_dialogue-template" src="project://database/Assets/Artists/UX/ui_esc_menu_dialogue-template.uxml?fileID=9197481963319205126&amp;guid=024cac2b9659e2d4595f190bafb2508e&amp;type=3#ui_esc_menu_dialogue-template" />
<Style src="project://database/Assets/BITKit/Unity/UX/Common/Common.uss?fileID=7433441132597879392&amp;guid=a3a69d3518fd02b489e721f3c5b0b539&amp;type=3#Common" />
<Style src="project://database/Assets/Artists/UX/Style.uss?fileID=7433441132597879392&amp;guid=506d41b7c5d56a44bb5845e69055a5eb&amp;type=3#Style" />
<ui:VisualElement name="Shadow" picking-mode="Ignore" class="default-background" />
<ui:VisualElement class="flex-center" style="flex-direction: row;">
<ui:VisualElement style="min-width: 512px;">
<ui:Label tabindex="-1" text="对话日志:" parse-escape-sequences="true" display-tooltip-when-elided="true" class="tl" />
<ui:VisualElement class="flex-center" style="flex-direction: row; min-height: 512px; min-width: 1024px;">
<ui:VisualElement style="min-width: 512px; flex-grow: 1;">
<ui:Label tabindex="-1" text="对话日志:" parse-escape-sequences="true" display-tooltip-when-elided="true" class="tl" style="font-size: 44px;" />
<ui:VisualElement style="flex-grow: 1;">
<ui:ScrollView>
<ui:Label tabindex="-1" text="等待对话中" parse-escape-sequences="true" display-tooltip-when-elided="true" name="log-label" class="tl" />
<ui:VisualElement name="dialogue-container">
<ui:Instance template="ui_esc_menu_dialogue-template" name="ui_esc_menu_dialogue-template" />
</ui:VisualElement>
</ui:ScrollView>
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement>
<ui:VisualElement style="width: 256px;">
<ui:Button text="返回游戏" parse-escape-sequences="true" display-tooltip-when-elided="true" name="return-button" />
<ui:VisualElement style="flex-grow: 1;" />
<ui:Button text="返回主菜单" parse-escape-sequences="true" display-tooltip-when-elided="true" name="exit-button" />

View File

@@ -1,6 +1,10 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement style="flex-direction: row; align-items: center; font-size: 20px;">
<ui:Label tabindex="-1" text="Actor" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--0" />
<ui:Label tabindex="-1" text="Statement" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--1" style="white-space: normal;" />
<ui:VisualElement style="flex-direction: row; align-items: center; font-size: 20px; margin-top: 4px; margin-right: 5px; margin-bottom: 5px; margin-left: 5px;">
<ui:Label tabindex="-1" text="Actor" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--0" style="margin-top: 4px; margin-right: 4px; margin-bottom: 4px; margin-left: 4px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; -unity-text-align: middle-left;" />
<ui:Label tabindex="-1" text=":" parse-escape-sequences="true" display-tooltip-when-elided="true" style="margin-top: 4px; margin-right: 4px; margin-bottom: 4px; margin-left: 4px; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; -unity-text-align: middle-left;" />
<ui:VisualElement style="flex-grow: 1;">
<ui:Label tabindex="-1" text="Statement" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--1" style="white-space: normal; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; -unity-text-align: middle-left;" />
<ui:Label tabindex="-1" text="Subtitle" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Label--2" style="white-space: normal; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; -unity-text-align: middle-left;" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
<Style src="project://database/Assets/BITKit/Unity/UX/Common/Common.uss?fileID=7433441132597879392&amp;guid=a3a69d3518fd02b489e721f3c5b0b539&amp;type=3#Common" />
<Style src="project://database/Assets/Artists/UX/Style.uss?fileID=7433441132597879392&amp;guid=506d41b7c5d56a44bb5845e69055a5eb&amp;type=3#Style" />
<ui:VisualElement>
<ui:Button text="开始" parse-escape-sequences="true" display-tooltip-when-elided="true" name="play-button" />
<ui:Button text="开始" parse-escape-sequences="true" display-tooltip-when-elided="true" name="play-button" view-data-key="Lobby_Play" class="localized" />
</ui:VisualElement>
<ui:VisualElement name="money-container" class="money-container" style="flex-direction: row-reverse; width: 450px; justify-content: space-between;">
<ui:VisualElement style="width: 200px; height: 48px; background-image: url(&quot;project://database/Assets/Arts/Artsystack%20-Modern%20Multiplayer%20GUI/ResourcesData/Sprites/components/Rounded%20Rectangle%201.png?fileID=21300000&amp;guid=7766860c1224b1e42b0d77fa49d9e350&amp;type=3#Rounded Rectangle 1&quot;);">