1153 lines
29 KiB
C#
1153 lines
29 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Cute;
|
|
using UnityEngine;
|
|
using Wizard;
|
|
using Wizard.UI.Dialog.ImageSelection;
|
|
|
|
public class DialogBase : MonoBehaviour
|
|
{
|
|
public enum DialogScene
|
|
{
|
|
OPEN,
|
|
WAIT,
|
|
CLOSE }
|
|
|
|
public enum Size
|
|
{
|
|
S,
|
|
M,
|
|
L,
|
|
XL }
|
|
|
|
public enum ButtonLayout
|
|
{
|
|
NONE,
|
|
OkBtn,
|
|
DecisionBtn,
|
|
CloseBtn,
|
|
BackToTitleBtn,
|
|
GrayBtn,
|
|
RedBtn,
|
|
YellowBtn,
|
|
BlueBtn_CancelBtn,
|
|
RedBtn_CancelBtn,
|
|
BlueBtn_GrayBtn,
|
|
BlueBtn_RedBtn,
|
|
GrayBtn_GrayBtn,
|
|
BlueBtn_RedBtn_GrayBtn,
|
|
GrayBtn_CancelBtn_BlueBtn,
|
|
GrayBtn_GrayBtn_BlueBtn,
|
|
BattleEvolveConfirm,
|
|
BlueButton,
|
|
BlueButton_BlueButton,
|
|
BlueButton_BlueButton_BlueButton
|
|
}
|
|
|
|
private enum ButtonSprite
|
|
{
|
|
BLUE,
|
|
GRAY,
|
|
RED,
|
|
YELLOW,
|
|
BLUE_S,
|
|
RED_S
|
|
}
|
|
|
|
public enum ButtonType
|
|
{
|
|
Blue,
|
|
Red,
|
|
Gray,
|
|
Yellow,
|
|
OK,
|
|
Decision,
|
|
Close,
|
|
Cancel,
|
|
Retry,
|
|
BackToTitle,
|
|
BackToHome,
|
|
QuitApplication,
|
|
VersionUp,
|
|
RecommendedList
|
|
}
|
|
|
|
private class UIPanelAlphaController
|
|
{
|
|
private UIPanel _panel;
|
|
|
|
private float _originalAlpha;
|
|
|
|
public UIPanelAlphaController(UIPanel panel)
|
|
{
|
|
_panel = panel;
|
|
_originalAlpha = _panel.alpha;
|
|
}
|
|
|
|
public void SetAlpha(float alpha)
|
|
{
|
|
_panel.alpha = alpha;
|
|
}
|
|
}
|
|
|
|
public enum KeyboardDialogSelect
|
|
{
|
|
}
|
|
|
|
private class Button
|
|
{
|
|
private ButtonType Type { get; set; }
|
|
|
|
public ButtonSprite Sprite { get; private set; }
|
|
|
|
public string Text { get; private set; }
|
|
|
|
public int SE { get; private set; }
|
|
|
|
public Action OnClick { get; private set; }
|
|
|
|
public Action OnDestroy { get; private set; }
|
|
|
|
public Button(ButtonType type, string text)
|
|
{
|
|
Type = type;
|
|
SystemText systemText = Data.SystemText;
|
|
switch (type)
|
|
{
|
|
case ButtonType.Blue:
|
|
Sprite = ButtonSprite.BLUE;
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Red:
|
|
Sprite = ButtonSprite.RED;
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Gray:
|
|
Sprite = ButtonSprite.GRAY;
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Yellow:
|
|
Sprite = ButtonSprite.YELLOW;
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.OK:
|
|
Sprite = ButtonSprite.BLUE;
|
|
Text = systemText.Get("Common_0004");
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Decision:
|
|
Sprite = ButtonSprite.BLUE;
|
|
Text = systemText.Get("Common_0003");
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Close:
|
|
Sprite = ButtonSprite.GRAY;
|
|
Text = systemText.Get("Common_0008");
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Cancel:
|
|
Sprite = ButtonSprite.GRAY;
|
|
Text = systemText.Get("Common_0005");
|
|
SE = 0;
|
|
break;
|
|
case ButtonType.Retry:
|
|
Sprite = ButtonSprite.BLUE;
|
|
Text = systemText.Get("Common_0133");
|
|
SE = 0;
|
|
OnClick = delegate
|
|
{
|
|
UIManager.GetInstance().StartCoroutine(Toolbox.NetworkManager.Retry());
|
|
};
|
|
|
|
OnDestroy = delegate
|
|
{
|
|
|
|
};
|
|
break;
|
|
case ButtonType.BackToTitle:
|
|
Sprite = ButtonSprite.GRAY;
|
|
Text = systemText.Get("Common_0131");
|
|
SE = 0;
|
|
OnClick = delegate
|
|
{
|
|
SoftwareReset.exec();
|
|
};
|
|
break;
|
|
case ButtonType.BackToHome:
|
|
Sprite = ButtonSprite.GRAY;
|
|
Text = systemText.Get("Common_0132");
|
|
SE = 0;
|
|
OnClick = delegate
|
|
{
|
|
// Pre-Phase-5b: back-to-home dialog kicked off BattleEndCoroutine when in a
|
|
// battle scene. Headless has no scene, no BattleCtrl (Chunk 7 stubbed it), and
|
|
// no BattleEndCoroutine to run — collapse to the else branch.
|
|
UIManager.GetInstance().closeInSceneCenterLoading();
|
|
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.MyPage);
|
|
};
|
|
break;
|
|
case ButtonType.QuitApplication:
|
|
Sprite = ButtonSprite.GRAY;
|
|
Text = systemText.Get("Common_0135");
|
|
SE = 0;
|
|
OnClick = delegate
|
|
{
|
|
if (Toolbox.mute != null)
|
|
{
|
|
Toolbox.mute.Close();
|
|
Toolbox.mute = null;
|
|
}
|
|
UIManager.ApplicationQuit();
|
|
};
|
|
break;
|
|
case ButtonType.VersionUp:
|
|
Sprite = ButtonSprite.BLUE;
|
|
Text = systemText.Get("Common_0136");
|
|
SE = 0;
|
|
OnClick = delegate
|
|
{
|
|
Toolbox.NetworkManager.GoToStore();
|
|
};
|
|
|
|
break;
|
|
case ButtonType.RecommendedList:
|
|
Sprite = ButtonSprite.BLUE;
|
|
Text = systemText.Get("Common_0134");
|
|
SE = 0;
|
|
OnClick = delegate
|
|
{
|
|
UIManager.GetInstance().WebViewHelper.CreateOpenURLWindow(WebViewHelper.UrlType.RECOMMENDED_DEVICE);
|
|
};
|
|
break;
|
|
}
|
|
if (text != null)
|
|
{
|
|
Text = text;
|
|
}
|
|
}
|
|
}
|
|
|
|
[HideInInspector]
|
|
public NguiObjs InputAreaObjs;
|
|
|
|
[SerializeField]
|
|
public UISprite WindowSprite;
|
|
|
|
[SerializeField]
|
|
private UIButton CloseButton;
|
|
|
|
[SerializeField]
|
|
private UILabel titleLabel;
|
|
|
|
[SerializeField]
|
|
private GameObject backViewOriginal;
|
|
|
|
[HideInInspector]
|
|
public GameObject backView;
|
|
|
|
[SerializeField]
|
|
private GameObject _collider;
|
|
|
|
[SerializeField]
|
|
private UILabel DetailMsg;
|
|
|
|
[SerializeField]
|
|
private GameObject ButtonBase;
|
|
|
|
[SerializeField]
|
|
public UIButton button1;
|
|
|
|
[SerializeField]
|
|
private UILabel button1_Label;
|
|
|
|
[SerializeField]
|
|
private UIButton button2;
|
|
|
|
[SerializeField]
|
|
private UILabel button2_Label;
|
|
|
|
[SerializeField]
|
|
private UIButton button3;
|
|
|
|
[SerializeField]
|
|
private UILabel button3_Label;
|
|
|
|
[SerializeField]
|
|
private UIButton contactButton;
|
|
|
|
[SerializeField]
|
|
private UILabel contactButton_Label;
|
|
|
|
[SerializeField]
|
|
private UIButton webviewBackButton;
|
|
|
|
[SerializeField]
|
|
private UISprite buttonLine;
|
|
|
|
[SerializeField]
|
|
public UISprite titleLine;
|
|
|
|
[SerializeField]
|
|
private UIRect scrollRect;
|
|
|
|
[SerializeField]
|
|
private UIRect scrollBarRect;
|
|
|
|
[SerializeField]
|
|
private UISlider vScrollBar;
|
|
|
|
[SerializeField]
|
|
private UIScrollView scrollView;
|
|
|
|
private DialogScene dialogNowScene;
|
|
|
|
private ButtonLayout dialogLayout;
|
|
|
|
private static Vector2[] Sizes = new Vector2[5]
|
|
{
|
|
new Vector2(624f, 360f),
|
|
new Vector2(850f, 564f),
|
|
new Vector2(1080f, 504f),
|
|
new Vector2(1125f, 605f),
|
|
new Vector2(600f, 600f)
|
|
};
|
|
|
|
private static int[] DETAIL_LABEL_SIZE = new int[5] { 540, 766, 996, 1041, 516 };
|
|
|
|
private GameObject returnObj;
|
|
|
|
private string returnMsg_Btn1;
|
|
|
|
private string returnMsg_Btn2;
|
|
|
|
private string returnMsg_Btn3;
|
|
|
|
public Action OnCloseStart;
|
|
|
|
public Action OnClose;
|
|
|
|
private Action OnClose_ForSystem;
|
|
|
|
public Action onPushButton1;
|
|
|
|
public Action onPushButton2;
|
|
|
|
public Action onPushButton3;
|
|
|
|
public Action onCloseWithoutSelect;
|
|
|
|
private Action onFirstUpdate;
|
|
|
|
private string closeMsg;
|
|
|
|
private bool isOpenAnim = true;
|
|
|
|
public bool isNotCloseWindowButton1;
|
|
|
|
public bool isNotCloseWindowButton2;
|
|
|
|
public bool isNotCloseWindowButton3;
|
|
|
|
private int _buttonNum;
|
|
|
|
private List<Button> _buttonList = new List<Button>();
|
|
|
|
private int? _layer;
|
|
|
|
private List<UIPanelAlphaController> _insideObjectUIPanelAlphaControllerList = new List<UIPanelAlphaController>();
|
|
|
|
public InputDialog InputDialog { get; set; }
|
|
|
|
public bool IsCloseByCloseButton { get; private set; }
|
|
|
|
public UIScrollView ScrollView => scrollView;
|
|
|
|
public int OpenSe { get; set; }
|
|
|
|
public int CloseSe { get; set; }
|
|
|
|
public int ClickSe_Btn1 { get; set; }
|
|
|
|
public int ClickSe_Btn2 { get; set; }
|
|
|
|
public int ClickSe_Btn3 { get; set; }
|
|
|
|
public GameObject InsideObject { get; private set; }
|
|
|
|
public bool IsPossibleToCloseByAndroidBackKey { get; set; }
|
|
|
|
public bool Button2Grey
|
|
{
|
|
set
|
|
{
|
|
UIManager.SetObjectToGrey(button2.gameObject, value);
|
|
}
|
|
}
|
|
|
|
public DialogBase()
|
|
{
|
|
OpenSe = 0;
|
|
CloseSe = 0;
|
|
IsPossibleToCloseByAndroidBackKey = true;
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
SetButtonSprite();
|
|
SetSize(Size.S);
|
|
CloseOnOff(flag: true);
|
|
SetScrollBottomAnchor(isExistButton: false);
|
|
SetTitleLabel(Data.SystemText.Get("Common_0021"));
|
|
button1.onClick.Clear();
|
|
button1.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
if (dialogNowScene == DialogScene.WAIT)
|
|
{
|
|
|
|
if (returnObj != null && returnMsg_Btn1 != "")
|
|
{
|
|
returnObj.SendMessage(returnMsg_Btn1);
|
|
}
|
|
if (onPushButton1 != null)
|
|
{
|
|
onPushButton1();
|
|
}
|
|
if (!isNotCloseWindowButton1)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}));
|
|
button2.onClick.Clear();
|
|
button2.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
if (dialogNowScene == DialogScene.WAIT)
|
|
{
|
|
|
|
if (returnObj != null && !string.IsNullOrEmpty(returnMsg_Btn2))
|
|
{
|
|
returnObj.SendMessage(returnMsg_Btn2);
|
|
}
|
|
if (onPushButton2 != null)
|
|
{
|
|
onPushButton2();
|
|
}
|
|
if (!isNotCloseWindowButton2)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}));
|
|
button3.onClick.Clear();
|
|
button3.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
if (dialogNowScene == DialogScene.WAIT)
|
|
{
|
|
|
|
if (returnObj != null && !string.IsNullOrEmpty(returnMsg_Btn3))
|
|
{
|
|
returnObj.SendMessage(returnMsg_Btn3);
|
|
}
|
|
if (onPushButton3 != null)
|
|
{
|
|
onPushButton3();
|
|
}
|
|
if (!isNotCloseWindowButton3)
|
|
{
|
|
Close();
|
|
}
|
|
}
|
|
}));
|
|
CloseButton.onClick.Clear();
|
|
CloseButton.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
if (dialogNowScene == DialogScene.WAIT)
|
|
{
|
|
CloseNotSelect(isCloseButton: true);
|
|
}
|
|
}));
|
|
backView = UnityEngine.Object.Instantiate(backViewOriginal);
|
|
backView.transform.parent = UIManager.GetInstance().transform;
|
|
backView.transform.localPosition = Vector3.zero;
|
|
backView.transform.localScale = new Vector3(1f, 1f, 1f);
|
|
backView.layer = base.gameObject.layer;
|
|
backView.GetComponent<NguiObjs>().sprites[0].alpha = 0.8f;
|
|
if (isOpenAnim)
|
|
{
|
|
backView.gameObject.GetComponent<UIPanel>().alpha = 0.01f;
|
|
}
|
|
if (backView != null && CloseButton.gameObject.activeSelf)
|
|
{
|
|
UIButton uIButton = backView.GetComponentInChildren<UISprite>().gameObject.AddMissingComponent<UIButton>();
|
|
uIButton.dragHighlight = false;
|
|
uIButton.hover = uIButton.defaultColor;
|
|
uIButton.pressed = uIButton.defaultColor;
|
|
uIButton.onClick.Clear();
|
|
uIButton.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
CloseNotSelect(isCloseButton: false);
|
|
}));
|
|
}
|
|
if (isOpenAnim)
|
|
{
|
|
base.gameObject.GetComponent<UIPanel>().alpha = 0.01f;
|
|
}
|
|
_collider.GetComponent<UISprite>().spriteName = null;
|
|
}
|
|
|
|
private void CloseNotSelect(bool isCloseButton)
|
|
{
|
|
IsCloseByCloseButton = isCloseButton;
|
|
|
|
Close();
|
|
if (returnObj != null && !string.IsNullOrEmpty(closeMsg))
|
|
{
|
|
returnObj.SendMessage(closeMsg);
|
|
}
|
|
if (onCloseWithoutSelect != null)
|
|
{
|
|
onCloseWithoutSelect();
|
|
}
|
|
}
|
|
|
|
public bool IsOpen()
|
|
{
|
|
if (dialogNowScene != DialogScene.OPEN)
|
|
{
|
|
return dialogNowScene == DialogScene.WAIT;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void SetSize(Size s)
|
|
{
|
|
Vector2 vector = Sizes[(int)s];
|
|
SetDimensionsFinal((int)vector.x, (int)vector.y);
|
|
DetailMsg.width = DETAIL_LABEL_SIZE[(int)s];
|
|
}
|
|
|
|
private void SetDimensionsFinal(int w, int h)
|
|
{
|
|
base.transform.localScale = new Vector3(1f, 1f, 1f);
|
|
WindowSprite.SetDimensions(w, h);
|
|
buttonLine.ResetAndUpdateAnchors();
|
|
titleLine.ResetAndUpdateAnchors();
|
|
scrollView.GetComponent<UIPanel>().ResetAndUpdateAnchors();
|
|
}
|
|
|
|
public void SetTitleLabel(string str)
|
|
{
|
|
titleLabel.text = str;
|
|
}
|
|
|
|
public void SetObj(GameObject obj)
|
|
{
|
|
SetObj(obj, new Vector3(0f, 0f, 0f));
|
|
}
|
|
|
|
public void SetObj(GameObject obj, Vector3 localPos)
|
|
{
|
|
obj.transform.parent = base.transform;
|
|
obj.transform.localPosition = localPos;
|
|
obj.transform.localScale = new Vector3(1f, 1f, 1f);
|
|
obj.layer = base.gameObject.layer;
|
|
InsideObject = obj;
|
|
if (_layer.HasValue)
|
|
{
|
|
UIManager.GetInstance().SetLayerRecursive(obj.transform, _layer.Value);
|
|
}
|
|
UIPanel component = obj.GetComponent<UIPanel>();
|
|
if (component != null)
|
|
{
|
|
UIPanelAlphaController uIPanelAlphaController = new UIPanelAlphaController(component);
|
|
uIPanelAlphaController.SetAlpha(0.01f);
|
|
_insideObjectUIPanelAlphaControllerList.Add(uIPanelAlphaController);
|
|
}
|
|
if (UIManager.GetInstance().IsCurrentScene(UIManager.ViewScene.QuestSelectionPage))
|
|
{
|
|
AllLabelColorChanger.ChangeAllLabel(base.gameObject);
|
|
}
|
|
}
|
|
|
|
public void SetText(string text, bool isWrapText = false)
|
|
{
|
|
DetailMsg.transform.localPosition = Vector3.zero;
|
|
DetailMsg.gameObject.SetActive(value: true);
|
|
if (!isWrapText)
|
|
{
|
|
DetailMsg.text = text;
|
|
}
|
|
else
|
|
{
|
|
onFirstUpdate = (Action)Delegate.Combine(onFirstUpdate, (Action)delegate
|
|
{
|
|
DetailMsg.SetWrapText(text);
|
|
});
|
|
}
|
|
onFirstUpdate = (Action)Delegate.Combine(onFirstUpdate, (Action)delegate
|
|
{
|
|
if (scrollView.enabled)
|
|
{
|
|
scrollView.ResetPosition();
|
|
scrollView.UpdateScrollbars(recalculateBounds: true);
|
|
if (scrollView.shouldMoveVertically)
|
|
{
|
|
vScrollBar.value = 0f;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void SetButtonLayout(ButtonLayout btLayout)
|
|
{
|
|
dialogLayout = btLayout;
|
|
_buttonNum = 0;
|
|
_buttonList.Clear();
|
|
_ = Data.SystemText;
|
|
switch (dialogLayout)
|
|
{
|
|
case ButtonLayout.NONE:
|
|
ButtonBase.SetActive(value: false);
|
|
break;
|
|
case ButtonLayout.OkBtn:
|
|
AddButton(ButtonType.OK);
|
|
break;
|
|
case ButtonLayout.DecisionBtn:
|
|
AddButton(ButtonType.Decision);
|
|
break;
|
|
case ButtonLayout.CloseBtn:
|
|
AddButton(ButtonType.Close);
|
|
break;
|
|
case ButtonLayout.BackToTitleBtn:
|
|
AddButton(ButtonType.BackToTitle);
|
|
break;
|
|
case ButtonLayout.GrayBtn:
|
|
AddButton(ButtonType.Gray);
|
|
break;
|
|
case ButtonLayout.RedBtn:
|
|
AddButton(ButtonType.Red);
|
|
break;
|
|
case ButtonLayout.YellowBtn:
|
|
AddButton(ButtonType.Yellow);
|
|
break;
|
|
case ButtonLayout.BlueBtn_CancelBtn:
|
|
AddButton(ButtonType.Blue, isReflect: false);
|
|
AddButton(ButtonType.Cancel);
|
|
break;
|
|
case ButtonLayout.RedBtn_CancelBtn:
|
|
AddButton(ButtonType.Red, isReflect: false);
|
|
AddButton(ButtonType.Cancel);
|
|
break;
|
|
case ButtonLayout.BattleEvolveConfirm:
|
|
AddButton(ButtonType.Yellow, isReflect: false);
|
|
AddButton(ButtonType.Cancel);
|
|
break;
|
|
case ButtonLayout.BlueBtn_GrayBtn:
|
|
AddButton(ButtonType.Blue, isReflect: false);
|
|
AddButton(ButtonType.Gray);
|
|
break;
|
|
case ButtonLayout.BlueBtn_RedBtn:
|
|
AddButton(ButtonType.Blue, isReflect: false);
|
|
AddButton(ButtonType.Red);
|
|
break;
|
|
case ButtonLayout.GrayBtn_GrayBtn:
|
|
AddButton(ButtonType.Gray, isReflect: false);
|
|
AddButton(ButtonType.Gray);
|
|
break;
|
|
case ButtonLayout.BlueBtn_RedBtn_GrayBtn:
|
|
AddButton(ButtonType.Blue, isReflect: false);
|
|
AddButton(ButtonType.Red, isReflect: false);
|
|
AddButton(ButtonType.Gray);
|
|
break;
|
|
case ButtonLayout.GrayBtn_CancelBtn_BlueBtn:
|
|
AddButton(ButtonType.Gray, isReflect: false);
|
|
AddButton(ButtonType.Cancel, isReflect: false);
|
|
AddButton(ButtonType.Blue);
|
|
break;
|
|
case ButtonLayout.GrayBtn_GrayBtn_BlueBtn:
|
|
AddButton(ButtonType.Gray, isReflect: false);
|
|
AddButton(ButtonType.Gray, isReflect: false);
|
|
AddButton(ButtonType.Blue);
|
|
break;
|
|
case ButtonLayout.BlueButton:
|
|
AddButton(ButtonType.Blue);
|
|
break;
|
|
case ButtonLayout.BlueButton_BlueButton:
|
|
AddButton(ButtonType.Blue);
|
|
AddButton(ButtonType.Blue);
|
|
break;
|
|
case ButtonLayout.BlueButton_BlueButton_BlueButton:
|
|
AddButton(ButtonType.Blue);
|
|
AddButton(ButtonType.Blue);
|
|
AddButton(ButtonType.Blue);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void SetButtonText(string text_btn1, string text_btn2 = null, string text_btn3 = null)
|
|
{
|
|
if (text_btn1 != null)
|
|
{
|
|
button1_Label.text = text_btn1;
|
|
}
|
|
if (text_btn2 != null)
|
|
{
|
|
button2_Label.text = text_btn2;
|
|
}
|
|
if (text_btn3 != null)
|
|
{
|
|
button3_Label.text = text_btn3;
|
|
}
|
|
}
|
|
|
|
public void SetReturnMsg(GameObject obj, string msg_btn1, string msg_btn2 = "", string msg_btn3 = "", string msg_close = "")
|
|
{
|
|
returnObj = obj;
|
|
returnMsg_Btn1 = msg_btn1;
|
|
returnMsg_Btn2 = msg_btn2;
|
|
returnMsg_Btn3 = msg_btn3;
|
|
closeMsg = msg_close;
|
|
}
|
|
|
|
public void SetButtonDelegate(EventDelegate method_btn1, EventDelegate method_btn2 = null, EventDelegate method_btn3 = null, EventDelegate methodClose = null)
|
|
{
|
|
EventDelegate.Add(button1.onClick, method_btn1);
|
|
if (method_btn2 != null)
|
|
{
|
|
EventDelegate.Add(button2.onClick, method_btn2);
|
|
}
|
|
if (method_btn3 != null)
|
|
{
|
|
EventDelegate.Add(button3.onClick, method_btn3);
|
|
}
|
|
if (methodClose != null)
|
|
{
|
|
EventDelegate.Add(CloseButton.onClick, methodClose);
|
|
}
|
|
}
|
|
|
|
public void SetButtonDelegate(Action method_btn1, Action method_btn2 = null, Action method_btn3 = null, Action method_close = null)
|
|
{
|
|
if (method_btn1 != null)
|
|
{
|
|
onPushButton1 = method_btn1;
|
|
}
|
|
if (method_btn2 != null)
|
|
{
|
|
onPushButton2 = method_btn2;
|
|
}
|
|
if (method_btn3 != null)
|
|
{
|
|
onPushButton3 = method_btn3;
|
|
}
|
|
if (method_close != null)
|
|
{
|
|
OnClose = method_close;
|
|
}
|
|
}
|
|
|
|
private void SetButtonDestroyDelegate(params Action[] methods)
|
|
{
|
|
OnClose_ForSystem = null;
|
|
for (int i = 0; i < methods.Length; i++)
|
|
{
|
|
OnClose_ForSystem = (Action)Delegate.Combine(OnClose_ForSystem, methods[i]);
|
|
}
|
|
}
|
|
|
|
public void SetButtonDisable(bool isEnableOK, bool isEnableCancel = false, bool isEnableEtc = false, bool isEnableClose = false)
|
|
{
|
|
UIManager.SetObjectToGrey(button1.gameObject, isEnableOK);
|
|
UIManager.SetObjectToGrey(button2.gameObject, isEnableCancel);
|
|
UIManager.SetObjectToGrey(button3.gameObject, isEnableEtc);
|
|
UIManager.SetObjectToGrey(CloseButton.gameObject, isEnableClose);
|
|
}
|
|
|
|
private void SetButtonSprite(ButtonSprite btn1 = ButtonSprite.BLUE, ButtonSprite btn2 = ButtonSprite.GRAY, ButtonSprite btn3 = ButtonSprite.GRAY)
|
|
{
|
|
button1.normalSprite = (button1.hoverSprite = GetButtonString(btn1));
|
|
button1.pressedSprite = GetButtonStringPush(btn1);
|
|
button2.normalSprite = (button2.hoverSprite = GetButtonString(btn2));
|
|
button2.pressedSprite = GetButtonStringPush(btn2);
|
|
button3.normalSprite = (button3.hoverSprite = GetButtonString(btn3));
|
|
button3.pressedSprite = GetButtonStringPush(btn3);
|
|
}
|
|
|
|
private string GetButtonString(ButtonSprite style)
|
|
{
|
|
return style switch
|
|
{
|
|
ButtonSprite.BLUE => "btn_common_02_m_off",
|
|
ButtonSprite.GRAY => "btn_common_01_m_off",
|
|
ButtonSprite.RED => "btn_common_04_m_off",
|
|
ButtonSprite.YELLOW => "btn_common_03_m_off",
|
|
ButtonSprite.BLUE_S => "btn_common_02_s_off",
|
|
ButtonSprite.RED_S => "btn_common_04_s_off",
|
|
_ => null,
|
|
};
|
|
}
|
|
|
|
private string GetButtonStringPush(ButtonSprite style)
|
|
{
|
|
return style switch
|
|
{
|
|
ButtonSprite.BLUE => "btn_common_02_m_on",
|
|
ButtonSprite.GRAY => "btn_common_01_m_on",
|
|
ButtonSprite.RED => "btn_common_04_m_on",
|
|
ButtonSprite.YELLOW => "btn_common_03_m_on",
|
|
ButtonSprite.BLUE_S => "btn_common_02_s_on",
|
|
ButtonSprite.RED_S => "btn_common_04_s_on",
|
|
_ => null,
|
|
};
|
|
}
|
|
|
|
private void Display_1_Button(ButtonSprite sprite_btn1, string text_btn1, int se_btn1, Action onClick_btn1, Action onDestroy_btn1)
|
|
{
|
|
ButtonBase.SetActive(value: true);
|
|
button1.gameObject.SetActive(value: true);
|
|
button2.gameObject.SetActive(value: false);
|
|
button3.gameObject.SetActive(value: false);
|
|
UISprite component = button1.GetComponent<UISprite>();
|
|
component.leftAnchor.absolute = -128;
|
|
component.rightAnchor.absolute = 128;
|
|
SetButtonSprite(sprite_btn1);
|
|
SetButtonText(text_btn1);
|
|
SetButtonSe(se_btn1);
|
|
SetButtonDelegate(onClick_btn1);
|
|
SetButtonDestroyDelegate(onDestroy_btn1);
|
|
}
|
|
|
|
private void Display_1_Button(Button btn1)
|
|
{
|
|
Display_1_Button(btn1.Sprite, btn1.Text, btn1.SE, btn1.OnClick, btn1.OnDestroy);
|
|
}
|
|
|
|
private void Display_2_Buttons(ButtonSprite sprite_btn1, string text_btn1, int se_btn1, Action onClick_btn1, Action onDestroy_btn1, ButtonSprite sprite_btn2, string text_btn2, int se_btn2, Action onClick_btn2, Action onDestroy_btn2)
|
|
{
|
|
ButtonBase.SetActive(value: true);
|
|
button1.gameObject.SetActive(value: true);
|
|
button2.gameObject.SetActive(value: true);
|
|
button3.gameObject.SetActive(value: false);
|
|
UISprite component = button1.GetComponent<UISprite>();
|
|
component.leftAnchor.absolute = 8;
|
|
component.rightAnchor.absolute = 264;
|
|
UISprite component2 = button2.GetComponent<UISprite>();
|
|
component2.leftAnchor.absolute = -264;
|
|
component2.rightAnchor.absolute = -8;
|
|
SetButtonSprite(sprite_btn1, sprite_btn2);
|
|
SetButtonText(text_btn1, text_btn2);
|
|
SetButtonSe(se_btn1, se_btn2);
|
|
SetButtonDelegate(onClick_btn1, onClick_btn2);
|
|
SetButtonDestroyDelegate(onDestroy_btn1, onDestroy_btn2);
|
|
}
|
|
|
|
private void Display_2_Buttons(Button btn1, Button btn2)
|
|
{
|
|
Display_2_Buttons(btn1.Sprite, btn1.Text, btn1.SE, btn1.OnClick, btn1.OnDestroy, btn2.Sprite, btn2.Text, btn2.SE, btn2.OnClick, btn2.OnDestroy);
|
|
}
|
|
|
|
private void Display_3_Buttons(ButtonSprite sprite_btn1, string text_btn1, int se_btn1, Action onClick_btn1, Action onDestroy_btn1, ButtonSprite sprite_btn2, string text_btn2, int se_btn2, Action onClick_btn2, Action onDestroy_btn2, ButtonSprite sprite_btn3, string text_btn3, int se_btn3, Action onClick_btn3, Action onDestroy_btn3)
|
|
{
|
|
ButtonBase.SetActive(value: true);
|
|
button1.gameObject.SetActive(value: true);
|
|
button2.gameObject.SetActive(value: true);
|
|
button3.gameObject.SetActive(value: true);
|
|
UISprite component = button1.GetComponent<UISprite>();
|
|
component.leftAnchor.absolute = -128;
|
|
component.rightAnchor.absolute = 128;
|
|
UISprite component2 = button2.GetComponent<UISprite>();
|
|
component2.leftAnchor.absolute = -398;
|
|
component2.rightAnchor.absolute = -142;
|
|
UISprite component3 = button3.GetComponent<UISprite>();
|
|
component3.leftAnchor.absolute = 142;
|
|
component3.rightAnchor.absolute = 398;
|
|
SetButtonSprite(sprite_btn1, sprite_btn2, sprite_btn3);
|
|
SetButtonText(text_btn1, text_btn2, text_btn3);
|
|
SetButtonSe(se_btn1, se_btn2, se_btn3);
|
|
SetButtonDelegate(onClick_btn1, onClick_btn2, onClick_btn3);
|
|
SetButtonDestroyDelegate(onDestroy_btn1, onDestroy_btn2, onDestroy_btn3);
|
|
}
|
|
|
|
private void Display_3_Buttons(Button btn1, Button btn2, Button btn3)
|
|
{
|
|
Display_3_Buttons(btn1.Sprite, btn1.Text, btn1.SE, btn1.OnClick, btn1.OnDestroy, btn2.Sprite, btn2.Text, btn2.SE, btn2.OnClick, btn2.OnDestroy, btn3.Sprite, btn3.Text, btn3.SE, btn3.OnClick, btn3.OnDestroy);
|
|
}
|
|
|
|
public void AddButton(ButtonType type, bool isReflect = true, string text = null)
|
|
{
|
|
_buttonNum++;
|
|
_buttonList.Add(new Button(type, text));
|
|
if (_buttonNum == 1)
|
|
{
|
|
SetScrollBottomAnchor(isExistButton: true);
|
|
}
|
|
if (isReflect)
|
|
{
|
|
if (_buttonNum == 1)
|
|
{
|
|
Display_1_Button(_buttonList[0]);
|
|
}
|
|
else if (_buttonNum == 2)
|
|
{
|
|
Display_2_Buttons(_buttonList[0], _buttonList[1]);
|
|
}
|
|
else
|
|
{
|
|
Display_3_Buttons(_buttonList[0], _buttonList[1], _buttonList[2]);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SetScrollBottomAnchor(bool isExistButton)
|
|
{
|
|
UIRect.AnchorPoint bottomAnchor = scrollRect.bottomAnchor;
|
|
UIRect.AnchorPoint bottomAnchor2 = scrollBarRect.bottomAnchor;
|
|
if (isExistButton)
|
|
{
|
|
bottomAnchor.target = (bottomAnchor2.target = buttonLine.transform);
|
|
bottomAnchor.relative = (bottomAnchor2.relative = 1f);
|
|
bottomAnchor.absolute = -2;
|
|
}
|
|
else
|
|
{
|
|
bottomAnchor.target = (bottomAnchor2.target = WindowSprite.transform);
|
|
bottomAnchor.relative = (bottomAnchor2.relative = 0f);
|
|
bottomAnchor.absolute = 8;
|
|
}
|
|
scrollRect.ResetAnchors();
|
|
scrollRect.UpdateAnchors();
|
|
scrollBarRect.ResetAnchors();
|
|
scrollBarRect.UpdateAnchors();
|
|
}
|
|
|
|
private void SetButtonSe(int btn1 = 0, int btn2 = 0, int btn3 = 0)
|
|
{
|
|
ClickSe_Btn1 = btn1;
|
|
ClickSe_Btn2 = btn2;
|
|
ClickSe_Btn3 = btn3;
|
|
}
|
|
|
|
public void SetVisibleContactButton(bool isVisible, string errorCode)
|
|
{
|
|
contactButton.gameObject.SetActive(isVisible);
|
|
contactButton.onClick.Clear();
|
|
contactButton.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
DialogBase dialogBase = DialogSupport.Create(errorCode);
|
|
dialogBase.SetPanelDepth(6100);
|
|
dialogBase.SetPanelSortingOrder(2);
|
|
}));
|
|
contactButton_Label.text = Data.SystemText.Get("OtherTop_0007");
|
|
scrollView.GetComponent<UIPanel>().bottomAnchor.absolute += (int)contactButton.GetComponent<BoxCollider>().size.y;
|
|
}
|
|
|
|
public void SetVisibleWebViewBackButton(string url, bool isVisible)
|
|
{
|
|
webviewBackButton.gameObject.SetActive(isVisible);
|
|
if (!isVisible)
|
|
{
|
|
return;
|
|
}
|
|
webviewBackButton.onClick.Clear();
|
|
webviewBackButton.onClick.Add(new EventDelegate(delegate
|
|
{
|
|
WebViewManager instance = WebViewManager.getInstance();
|
|
if (instance != null)
|
|
{
|
|
if (url == null)
|
|
{
|
|
if (instance.CanGoBack())
|
|
{
|
|
instance.GoBack();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
instance.LoadWeb(url);
|
|
}
|
|
SetVisibleWebViewBackButton(null, isVisible: false);
|
|
}
|
|
}));
|
|
}
|
|
|
|
public void CloseWithoutSelect()
|
|
{
|
|
if (!(this == null))
|
|
{
|
|
Close();
|
|
if (onCloseWithoutSelect != null)
|
|
{
|
|
onCloseWithoutSelect();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
dialogNowScene = DialogScene.CLOSE;
|
|
if (!base.gameObject.activeInHierarchy)
|
|
{
|
|
SetActive(inActive: true);
|
|
}
|
|
if (!(UIManager.GetInstance() != null) || !(this != null) || !(this == UIManager.GetInstance().ApplicationFinishManager.QuitDialog))
|
|
{
|
|
UIManager.GetInstance().CloseInSceneLoadingMatching();
|
|
}
|
|
_collider.SetActive(value: true);
|
|
if (OnCloseStart != null)
|
|
{
|
|
OnCloseStart();
|
|
}
|
|
}
|
|
|
|
public void CloseOnOff(bool flag)
|
|
{
|
|
CloseButton.gameObject.SetActive(flag);
|
|
}
|
|
|
|
public void SetPanelDepth(int depth, bool isSetBackViewDepthImmediately = false)
|
|
{
|
|
GetComponent<UIPanel>().depth = depth;
|
|
scrollView.GetComponent<UIPanel>().depth = depth + 1;
|
|
if (isSetBackViewDepthImmediately)
|
|
{
|
|
backViewDepth();
|
|
}
|
|
else
|
|
{
|
|
Invoke("backViewDepth", 0.1f);
|
|
}
|
|
}
|
|
|
|
private void backViewDepth()
|
|
{
|
|
UIPanel component = GetComponent<UIPanel>();
|
|
if (component != null && backView != null && backView.GetComponent<UIPanel>() != null)
|
|
{
|
|
backView.GetComponent<UIPanel>().depth = component.depth - 1;
|
|
}
|
|
}
|
|
|
|
public void SetPanelSortingOrder(int order)
|
|
{
|
|
GetComponent<UIPanel>().sortingOrder = order;
|
|
scrollRect.GetComponent<UIPanel>().sortingOrder = order;
|
|
backView.GetComponent<UIPanel>().sortingOrder = order;
|
|
}
|
|
|
|
public void SetLayer(string layerName)
|
|
{
|
|
int num = LayerMask.NameToLayer(layerName);
|
|
UIManager.GetInstance().SetLayerRecursive(base.transform, num);
|
|
SetBackViewLayer(num);
|
|
_layer = num;
|
|
}
|
|
|
|
public void SetBackViewLayer(int layer)
|
|
{
|
|
backView.layer = layer;
|
|
}
|
|
|
|
public void SetScrollViewActive(bool b)
|
|
{
|
|
scrollView.verticalScrollBar.gameObject.SetActive(b);
|
|
scrollView.enabled = b;
|
|
if (b)
|
|
{
|
|
scrollView.ResetPosition();
|
|
scrollView.UpdateScrollbars(recalculateBounds: true);
|
|
}
|
|
}
|
|
|
|
public void SetActive(bool inActive)
|
|
{
|
|
base.gameObject.SetActive(inActive);
|
|
backView.SetActive(inActive);
|
|
}
|
|
|
|
public void AttachToScrollView(Transform t)
|
|
{
|
|
t.parent = scrollView.transform;
|
|
t.localScale = Vector3.one;
|
|
t.localPosition = Vector3.zero;
|
|
}
|
|
|
|
public void SetFadeButtonEnabled(bool flag)
|
|
{
|
|
CloseOnOff(flag);
|
|
IsPossibleToCloseByAndroidBackKey = flag;
|
|
if (!(backView == null))
|
|
{
|
|
UIButton componentInChildren = backView.GetComponentInChildren<UIButton>();
|
|
if (!(componentInChildren == null))
|
|
{
|
|
componentInChildren.enabled = flag;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetBackViewToNotCloseDialog()
|
|
{
|
|
backView.GetComponentInChildren<UIButton>().enabled = false;
|
|
}
|
|
|
|
public static DialogBase CreateImageSelectionDialog(ImageSelection imageSelection, string titleTextId, Size dialogSize = Size.M)
|
|
{
|
|
GameObject selectionObj = imageSelection.gameObject;
|
|
Transform selectionTrans = imageSelection.transform;
|
|
TransformBackup backup = new TransformBackup();
|
|
backup.Save(selectionTrans);
|
|
SystemText systemText = Data.SystemText;
|
|
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
|
|
dialogBase.SetSize(dialogSize);
|
|
dialogBase.SetTitleLabel(systemText.Get(titleTextId));
|
|
dialogBase.SetButtonLayout(ButtonLayout.DecisionBtn);
|
|
dialogBase.OnClose = delegate
|
|
{
|
|
imageSelection.Close();
|
|
backup.Restore(selectionTrans);
|
|
selectionObj.SetActive(value: false);
|
|
};
|
|
dialogBase.SetObj(selectionObj, selectionTrans.localPosition);
|
|
selectionObj.SetActive(value: true);
|
|
UIManager.GetInstance().SetLayerRecursive(dialogBase.transform, dialogBase.gameObject.layer);
|
|
imageSelection.Open();
|
|
return dialogBase;
|
|
}
|
|
|
|
public static DialogBase CreateFilteringImageSelectionDialog(FilteringImageSelection selection, string titleTextId, bool isOpenSelection = true)
|
|
{
|
|
TransformBackup backup = new TransformBackup();
|
|
backup.Save(selection.transform);
|
|
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
|
|
dialogBase.SetSize(Size.XL);
|
|
dialogBase.SetTitleLabel(Data.SystemText.Get(titleTextId));
|
|
dialogBase.SetButtonLayout(ButtonLayout.DecisionBtn);
|
|
selection.DialogCloseButton = dialogBase.CloseButton;
|
|
dialogBase.OnClose = delegate
|
|
{
|
|
selection.DestroyDialogCloseButtonCopy();
|
|
selection.RegisterFavoriteChanges();
|
|
backup.Restore(selection.transform);
|
|
selection.gameObject.SetActive(value: false);
|
|
};
|
|
dialogBase.SetObj(selection.gameObject, selection.transform.localPosition);
|
|
selection.gameObject.SetActive(value: true);
|
|
UIManager.GetInstance().SetLayerRecursive(dialogBase.transform, dialogBase.gameObject.layer);
|
|
if (isOpenSelection)
|
|
{
|
|
selection.Open();
|
|
}
|
|
return dialogBase;
|
|
}
|
|
|
|
public void SetDialogNoClose()
|
|
{
|
|
SetBackViewToNotCloseDialog();
|
|
CloseButton.enabled = false;
|
|
IsPossibleToCloseByAndroidBackKey = false;
|
|
}
|
|
}
|