83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
using BrewMonster.Network;
|
|
using BrewMonster.Scripts;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace BrewMonster.UI
|
|
{
|
|
/// <summary>
|
|
/// Warehouse open password (C++ CDlgStoragePW / Win_InputString).
|
|
/// Dialog id for <see cref="CECUIManager.ShowUI"/>: <see cref="DialogId"/>.
|
|
/// </summary>
|
|
public class DlgStoragePW : AUIDialog
|
|
{
|
|
public const string DialogId = "DlgStoragePW";
|
|
|
|
[SerializeField] private TMP_InputField passwordInput;
|
|
[SerializeField] private Button confirmButton;
|
|
[SerializeField] private Button cancelButton;
|
|
[SerializeField] private Button closeButton;
|
|
|
|
public static DlgStoragePW GetDialog()
|
|
{
|
|
return EC_Game.GetGameRun()?.GetUIManager()?.GetInGameUIMan()?.GetDialog(DialogId) as DlgStoragePW;
|
|
}
|
|
|
|
public override void Awake()
|
|
{
|
|
base.Awake();
|
|
ResolveControls();
|
|
WireButtons();
|
|
}
|
|
|
|
public override void OnShowDialogue()
|
|
{
|
|
base.OnShowDialogue();
|
|
WireButtons();
|
|
ClearFields();
|
|
}
|
|
|
|
void ResolveControls()
|
|
{
|
|
passwordInput = DlgStoragePasswordUiHelper.FindInputField(transform, passwordInput, "DEFAULT_Txt_Input");
|
|
DlgStoragePasswordUiHelper.ConfigurePasswordField(passwordInput);
|
|
|
|
DlgStoragePasswordUiHelper.ResolveButton(ref confirmButton, transform, "confirm", "btn_decide", "btn_confirm", "ok");
|
|
DlgStoragePasswordUiHelper.ResolveButton(ref cancelButton, transform, "cancel", "idcanel", "btn_cancel", "btn_exit");
|
|
DlgStoragePasswordUiHelper.ResolveButton(ref closeButton, transform, "btn_close", "close");
|
|
}
|
|
|
|
void WireButtons()
|
|
{
|
|
DlgStoragePasswordUiHelper.ResolveButton(ref confirmButton, transform, "confirm", "btn_decide", "btn_confirm", "ok");
|
|
DlgStoragePasswordUiHelper.WireConfirmButton(transform, OnConfirm, confirmButton);
|
|
DlgStoragePasswordUiHelper.WireCancelButtons(transform, OnCancel);
|
|
}
|
|
|
|
void ClearFields()
|
|
{
|
|
if (passwordInput != null)
|
|
passwordInput.SetTextWithoutNotify(string.Empty);
|
|
}
|
|
|
|
void OnConfirm()
|
|
{
|
|
string password = passwordInput != null ? passwordInput.text : string.Empty;
|
|
UnityGameSession.c2s_CmdNPCSevOpenTrash(password);
|
|
CloseDialog();
|
|
}
|
|
|
|
void OnCancel()
|
|
{
|
|
CECUIManager.Instance?.EndNpcTalkAfterStorageService();
|
|
}
|
|
|
|
void CloseDialog()
|
|
{
|
|
CECUIManager.Instance?.EndNpcTalkAfterStorageService();
|
|
}
|
|
}
|
|
}
|