Files
SVSimServer/SVSim.BattleEngine/Engine/InputDialog.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

130 lines
2.9 KiB
C#

using System;
using Cute;
using UnityEngine;
public class InputDialog : MonoBehaviour
{
[SerializeField]
private UIToggle _toggle;
[SerializeField]
private UILabel _topLabel;
[SerializeField]
private UILabel _inputAreaLabel;
[SerializeField]
private UILabel _bottomLabel;
private bool _enableToggleSound = true;
private bool _isFirstOnChange = true;
public Action OnChangeToggleEvent;
public bool EnableToggleDisplay
{
set
{
_toggle.gameObject.SetActive(value: true);
}
}
public string TopLabelText
{
set
{
_topLabel.text = value;
}
}
public string InputAreaLabel
{
get
{
return _inputAreaLabel.text;
}
set
{
_inputAreaLabel.text = value;
}
}
public string BottomLabelText
{
set
{
_bottomLabel.text = value;
}
}
public bool ToggleChecked
{
get
{
return _toggle.value;
}
set
{
_enableToggleSound = false;
_toggle.value = value;
_enableToggleSound = true;
}
}
public static DialogBase Create(int charalimitinput, int charalimitfix, UIInput.KeyboardType keyboard = UIInput.KeyboardType.Default)
{
NguiObjs textInputDialogPrefab = UIManager.GetInstance().TextInputDialogPrefab;
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.DecisionBtn);
GameObject gameObject = NGUITools.AddChild(dialogBase.gameObject, textInputDialogPrefab.gameObject);
dialogBase.InputAreaObjs = gameObject.GetComponent<NguiObjs>();
dialogBase.InputAreaObjs.transform.localPosition = textInputDialogPrefab.transform.localPosition;
dialogBase.InputDialog = gameObject.GetComponent<InputDialog>();
UIInputWizard[] componentsInChildren = dialogBase.InputAreaObjs.GetComponentsInChildren<UIInputWizard>(includeInactive: true);
if (componentsInChildren != null)
{
EventDelegate item = new EventDelegate(delegate
{
TextInputLimitCheck(charalimitfix);
});
foreach (UIInputWizard obj in componentsInChildren)
{
obj.keyboardType = keyboard;
obj.characterLimit = charalimitinput;
obj.onSubmit.Add(item);
obj.onDeselect.Add(item);
}
}
return dialogBase;
}
public static void TextInputLimitCheck(int charalimitfix)
{
if (charalimitfix > 0 && !(null == UIInput.current) && charalimitfix < UIInput.current.value.Length)
{
UIInput.current.value = UIInput.current.value.Substring(0, charalimitfix);
UIInput.current.label.text = UIInput.current.value;
}
}
private void Awake()
{
_toggle.onChange.Add(new EventDelegate(delegate
{
OnClickToggle();
}));
_toggle.gameObject.SetActive(value: false);
}
private void OnClickToggle()
{
if (_enableToggleSound && !_isFirstOnChange)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(_toggle.value ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
}
_isFirstOnChange = false;
OnChangeToggleEvent.Call();
}
}