using System.Collections.Generic;
using UnityEngine;

namespace Wizard.Dialog.Setting;

public class SettingBase : MonoBehaviour
{
	public enum Type
	{
		NORMAL,
		SCENARIO,
		VIDEOHOSTING_SETTING_RECORD,
		VIDEOHOSTING_SETTING_PUBLISH,
		VIDEOHOSTING_MENU_RECORD,
		VIDEOHOSTING_MENU_PUBLISH
	}

	public enum ID
	{
		SOUND,
		BGM,
		SE,
		VOICE,
		MOVIE_SUBTITLES,
		BATTLE_EFFECT_DISPLAY,
		LEADER_ANIMATION_DISPLAY,
		PREDICTION_ICONS_DISPLAY,
		TURN_END_CONFIRM,
		TURN_END_WITHOUT_USING_HERO_SKILL_CONFIRM,
		EVOLVE_CONFIRM,
		FIXEDUSE_COST_INFO,
		OPPONENT_MESSAGE_DISPLAY,
		OPPONENT_SHOW_DEFAULT_SKIN,
		SHOW_FOIL_CARD_ANIMATION,
		SELECT_WSS,
		SELECT_IPV6,
		PURCHASE_ALERT,
		SCREEN_FIX,
		INVITATION_FRIEND_ROOM,
		INVITATION_IN_BATTLE,
		INVITATION_IN_OFFLINE,
		RECEIVED_FRIEND_APPLY,
		SHOW_PANEL_ALWAYS,
		SHOW_SIDE_LOG,
		SHOW_FUSION_CARD_PLAY_DIALOG,
		AUTO_MESSAGE,
		SIMPLE_STAGE,
		COLLABORATION_SOUND,
		USE_STAGE_SELECT,
		STAGE_SELECT,
		ENEMYNAME_DISPLAY,
		RECORD_MODE,
		RECORD_UPLOAD,
		RECORD_WATCH,
		RECORD_PAUSE,
		RECORD_RESUME,
		RECORD_STOP,
		RECORD_FACECAMERA,
		RECORD_MICROPHONE,
		RECORD_MICROPHONE_GAIN,
		RECORD_PAUSE_IN_MENU,
		RECORD_BUTTON_GRID,
		PUBLISH_MODE,
		PLAY_SOUND_IN_BG,
		FULLSCREEN,
		RESOLUTION,
		FPS,
		QRCode,
		MOUSE_CONTROL,
		MOUSE_SHORTCUT_PLAY,
		MOUSE_SHORTCUT_EVOLUTION,
		MOUSE_SHORTCUT_DETAIL,
		BATTLE_DETAIL_PANEL_SIZE,
		SHOW_DETAIL_LEFT_AND_RIGHT,
		KEYBOARD_CONTROL,
		KEYBOARD_SHORTCUT_EVOLUTION,
		KEYBOARD_SHORTCUT_SPACE,
		PLAY_BGM_ON_OTHER_BGM,
		BATTLE_PASS_SHOW_RESULT
	}

	[SerializeField]
	private GameObject m_scrollView;

	[SerializeField]
	private GameObject m_itemToggle;

	[SerializeField]
	private GameObject m_itemSlider;

	[SerializeField]
	private GameObject m_itemGrid;

	[SerializeField]
	private GameObject m_itemLabel;

	[SerializeField]
	private GameObject m_itemButton;

	[SerializeField]
	private GameObject _itemSelect;

	protected static readonly Vector3 CHILD_STATE_LABEL_POS = new Vector3(-297f, 0f, 0f);

	private Dictionary<ID, Item> m_dicItems = new Dictionary<ID, Item>();

	private Type m_type;

	private const string VOICE_NAME = "vo_test_01";

	protected DialogBase _dialogObject;

	private static readonly Vector3 PUBLISHMODE_STATELABEL_POS = new Vector3(80f, 0f, 0f);

	private static readonly Vector3 PUBLISHMODE_TOGGLE_POS = new Vector3(275f, 0f, 0f);

	private static readonly Vector3 RECORDMODE_STATELABEL_POS = new Vector3(80f, 0f, 0f);

	private static readonly Vector3 RECORDMODE_TOGGLE_POS = new Vector3(275f, 0f, 0f);

	private static readonly Vector3 SPRITE_POS_RECORD_PLAYPAUSE = new Vector3(-93f, 0f, 0f);

	private static readonly Vector3 SPRITE_POS_RECORD_STOP = new Vector3(-93f, 0f, 0f);

	private static readonly Vector3 LABEL_POS_RECORD_PLAYPAUSE = new Vector3(20f, 0f, 0f);

	private static readonly Vector3 LABEL_POS_RECORD_STOP = new Vector3(20f, 0f, 0f);

	protected GameObject SingleTabRoot => m_scrollView;

	public static DialogBase CreateDialog(Type type = Type.NORMAL)
	{
		SettingBase settingBase = null;
		settingBase = ((type != Type.NORMAL) ? Object.Instantiate(UIManager.GetInstance().SettingPrefab) : Object.Instantiate(UIManager.GetInstance().OptionSettingPrefab));
		settingBase.Create(type);
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(Data.SystemText.Get("OtherTop_0003"));
		dialogBase.SetObj(settingBase.gameObject, settingBase.transform.localPosition);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		settingBase.SettingDialogObject(dialogBase);
		return dialogBase;
	}

	public void SettingDialogObject(DialogBase dialog)
	{
		_dialogObject = dialog;
	}

	private void Start()
	{
		GameMgr.GetIns().GetSoundMgr().LoadVoice("vo_test_01");
	}

	public virtual void Create()
	{
	}

	public virtual void Create(Type type)
	{
		m_type = type;
		Create();
		if (m_type != Type.NORMAL)
		{
			if (m_type == Type.SCENARIO)
			{
				CreateToggle_AutoMessage(isDispSeparatorLine: true);
				CreateToggle_MovieSubtitles(isDispSeparatorLine: true, m_scrollView.gameObject);
				CreateSoundItem(m_scrollView.gameObject);
			}
			else if (m_type == Type.VIDEOHOSTING_SETTING_RECORD)
			{
				CreateVideoHostingSettingRecord();
			}
			else if (m_type == Type.VIDEOHOSTING_SETTING_PUBLISH)
			{
				CreateVideoHostingSettingPublish();
			}
			else if (m_type == Type.VIDEOHOSTING_MENU_RECORD)
			{
				CreateVideoHostingMenuRecord();
			}
			else if (m_type == Type.VIDEOHOSTING_MENU_PUBLISH)
			{
				CreateVideoHostingMenuPublish();
			}
		}
	}

	protected void ResetScroll()
	{
		m_scrollView.GetComponent<UIScrollView>().ResetPosition();
	}

	protected virtual void OnDestroy()
	{
		GameMgr.GetIns().GetSoundMgr().UnloadVoice("vo_test_01");
	}

	protected void CreateSoundItem(GameObject parent)
	{
		ItemToggle soundToggle = CreateToggle_Sound(isDispSeparatorLine: true, parent);
		ItemSlider bgmSlider = AddSlider_BGM(isDispSeparatorLine: false, parent);
		ItemSlider seSlider = AddSlider_SE(isDispSeparatorLine: false, parent);
		ItemSlider voiceSlider = AddSlider_Voice(isDispSeparatorLine: true, parent);
		soundToggle.AddChangeCallback(delegate
		{
			bool value = soundToggle.GetValue();
			bgmSlider.SetLooks(value);
			seSlider.SetLooks(value);
			voiceSlider.SetLooks(value);
		});
	}

	public Item FindItem(ID id)
	{
		if (!m_dicItems.ContainsKey(id))
		{
			return null;
		}
		return m_dicItems[id];
	}

	protected ItemToggle CreateToggle(ID id, bool isDispSeparatorLine, GameObject parent)
	{
		ItemToggle component = NGUITools.AddChild(parent, m_itemToggle).GetComponent<ItemToggle>();
		component.SetScrollView(m_scrollView.GetComponent<UIScrollView>());
		component.name = id.ToString();
		component.SetActive_SeparatorLine(isDispSeparatorLine);
		m_dicItems.Add(id, component);
		return component;
	}

	protected ItemSlider CreateSlider(ID id, bool isDispSeparatorLine, GameObject parent)
	{
		ItemSlider component = NGUITools.AddChild(parent, m_itemSlider).GetComponent<ItemSlider>();
		component.SetScrollView(m_scrollView.GetComponent<UIScrollView>());
		component.name = id.ToString();
		component.SetActive_SeparatorLine(isDispSeparatorLine);
		m_dicItems.Add(id, component);
		return component;
	}

	protected ItemGrid CreateGrid(ID id, bool isDispSeparatorLine, GameObject parent)
	{
		ItemGrid component = NGUITools.AddChild(parent, m_itemGrid).GetComponent<ItemGrid>();
		component.name = id.ToString();
		component.SetActive_SeparatorLine(isDispSeparatorLine);
		m_dicItems.Add(id, component);
		return component;
	}

	protected ItemButton CreateButton(ID id, bool isDispSeparatorLine, GameObject parent)
	{
		ItemButton component = NGUITools.AddChild(parent, m_itemButton).GetComponent<ItemButton>();
		component.name = id.ToString();
		component.SetActive_SeparatorLine(isDispSeparatorLine);
		m_dicItems.Add(id, component);
		return component;
	}

	private ItemLabel CreateLabel(ID id, bool isDispSeparatorLine)
	{
		ItemLabel component = NGUITools.AddChild(m_scrollView, m_itemLabel).GetComponent<ItemLabel>();
		component.name = id.ToString();
		component.SetActive_SeparatorLine(isDispSeparatorLine);
		m_dicItems.Add(id, component);
		return component;
	}

	protected ItemSelect CreateSelect(ID id, bool isDispSeparatorLine, GameObject parent)
	{
		ItemSelect component = NGUITools.AddChild(parent, _itemSelect).GetComponent<ItemSelect>();
		component.SetScrollView(m_scrollView.GetComponent<UIScrollView>());
		component.name = id.ToString();
		component.SetActive_SeparatorLine(isDispSeparatorLine);
		m_dicItems.Add(id, component);
		return component;
	}

	protected ItemToggle CreateToggle_ScreenFix(bool isDispSeparatorLine, GameObject parent)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.SCREEN_FIX, isDispSeparatorLine, parent);
		item.SetTitleLabel(systemText.Get("OtherConfig_0011"));
		item.SetValue(PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.DEVICE_ORIENTATION));
		item.AddChangeCallback(delegate
		{
			PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.DEVICE_ORIENTATION, item.GetValue());
			UIManager.GetInstance().SetDeviceOrientation();
		});
		return item;
	}

	protected ItemToggle CreateToggle_MovieSubtitles(bool isDispSeparatorLine, GameObject parent)
	{
		ItemToggle item = CreateToggle(ID.MOVIE_SUBTITLES, isDispSeparatorLine, parent);
		item.SetTitleLabel(Data.SystemText.Get("OtherConfig_0063"));
		item.SetValue(PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.MOVIE_SUBTITLES));
		item.AddChangeCallback(delegate
		{
			PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.MOVIE_SUBTITLES, item.GetValue());
		});
		return item;
	}

	private ItemToggle CreateToggle_Sound(bool isDispSeparatorLine, GameObject parent)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.SOUND, isDispSeparatorLine, parent);
		item.SetTitleLabel(systemText.Get("OtherConfig_0017"));
		item.SetValue(!PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SOUND_MUTE));
		item.AddChangeCallback(delegate
		{
			bool flag = !item.GetValue();
			PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.SOUND_MUTE, flag);
			GameMgr.GetIns().GetSoundMgr().AllMute(flag);
		});
		return item;
	}

	private ItemSlider AddSlider_BGM(bool isDispSeparatorLine, GameObject parent)
	{
		SystemText systemText = Data.SystemText;
		SoundMgr soundMgr = GameMgr.GetIns().GetSoundMgr();
		ItemSlider item = CreateSlider(ID.BGM, isDispSeparatorLine, parent);
		item.SetTitleLabel(systemText.Get("OtherConfig_0001"));
		item.SetValue(soundMgr.GetBgmVolume());
		item.AddChangeCallback(delegate
		{
			float value = item.GetValue();
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.BGM_VOLUME, value);
			soundMgr.SetBgmVolume(value);
		});
		return item;
	}

	private ItemSlider AddSlider_SE(bool isDispSeparatorLine, GameObject parent)
	{
		SystemText systemText = Data.SystemText;
		SoundMgr soundMgr = GameMgr.GetIns().GetSoundMgr();
		ItemSlider item = CreateSlider(ID.SE, isDispSeparatorLine, parent);
		item.SetTitleLabel(systemText.Get("OtherConfig_0002"));
		item.SetValue(soundMgr.GetSeVolume());
		item.AddChangeCallback(delegate
		{
			float value = item.GetValue();
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.SE_VOLUME, value);
			soundMgr.SetSeVolume(value);
		});
		return item;
	}

	private ItemSlider AddSlider_Voice(bool isDispSeparatorLine, GameObject parent)
	{
		SystemText systemText = Data.SystemText;
		SoundMgr soundMgr = GameMgr.GetIns().GetSoundMgr();
		ItemSlider item = CreateSlider(ID.VOICE, isDispSeparatorLine, parent);
		item.SetTitleLabel(systemText.Get("OtherConfig_0003"));
		item.SetValue(soundMgr.GetVoiceVolume());
		item.AddChangeCallback(delegate
		{
			float value = item.GetValue();
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.VOICE_VOLUME, value);
			soundMgr.SetVoiceVolume(value);
		});
		item.AddDragFinishedCallback(delegate
		{
			soundMgr.PlayVoiceScenario("vo_test_01");
		});
		return item;
	}

	private ItemToggle CreateToggle_AutoMessage(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.AUTO_MESSAGE, isDispSeparatorLine, m_scrollView.gameObject);
		item.SetTitleLabel(systemText.Get("OtherConfig_0014"));
		item.SetValue(PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.AUTO_MESSAGE));
		item.AddChangeCallback(delegate
		{
			PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.AUTO_MESSAGE, item.GetValue());
		});
		return item;
	}

	private void CreateVideoHostingSettingRecord()
	{
	}

	private void CreateVideoHostingSettingPublish()
	{
	}

	private void CreateVideoHostingMenuRecord()
	{
	}

	private void CreateVideoHostingMenuPublish()
	{
	}

	private void CreateSetting_Publish_NicoNico()
	{
		CreateToggle_PublishMode(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
	}

	private void CreateSetting_Record_NicoNico()
	{
		CreateToggle_RecordMode(isDispSeparatorLine: true);
		CreateToggle_RecordFaceCamera(isDispSeparatorLine: true);
		CreateToggle_RecordMicrophone(isDispSeparatorLine: true);
		CreateToggle_RecordPauseInMenu(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
	}

	private void CreateMenu_Record_NicoNico_iOS()
	{
		ItemGrid itemGrid = CreateGrid_RecordButton(isDispSeparatorLine: true);
		CreateButton_RecordPlayPause(isDispSeparatorLine: false, itemGrid.GetUIGrid().gameObject);
		CreateButton_RecordStop(isDispSeparatorLine: false, itemGrid.GetUIGrid().gameObject);
		CreateToggle_RecordPauseInMenu(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
		CreateSlider_RecordMicrophoneGain(isDispSeparatorLine: false);
	}

	private void CreateSetting_Record_EveryPlay_iOS()
	{
		CreateToggle_RecordMode(isDispSeparatorLine: true);
		CreateToggle_RecordFaceCamera(isDispSeparatorLine: true);
		CreateToggle_RecordMicrophone(isDispSeparatorLine: true);
		CreateToggle_RecordPauseInMenu(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
	}

	private void CreateSetting_Record_EveryPlay_Android()
	{
		CreateToggle_RecordMode(isDispSeparatorLine: true);
		CreateToggle_RecordPauseInMenu(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
	}

	private void CreateMenu_Record_EveryPlay_iOS()
	{
		ItemGrid itemGrid = CreateGrid_RecordButton(isDispSeparatorLine: true);
		CreateButton_RecordPlayPause(isDispSeparatorLine: false, itemGrid.GetUIGrid().gameObject);
		CreateButton_RecordStop(isDispSeparatorLine: false, itemGrid.GetUIGrid().gameObject);
		CreateToggle_RecordPauseInMenu(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
	}

	private void CreateMenu_Record_EveryPlay_Android()
	{
		ItemGrid itemGrid = CreateGrid_RecordButton(isDispSeparatorLine: true);
		CreateButton_RecordPlayPause(isDispSeparatorLine: false, itemGrid.GetUIGrid().gameObject);
		CreateButton_RecordStop(isDispSeparatorLine: false, itemGrid.GetUIGrid().gameObject);
		CreateToggle_RecordPauseInMenu(isDispSeparatorLine: true);
		CreateToggle_EnemyNameDisplay(isDispSeparatorLine: true);
	}

	private ItemToggle CreateToggle_EnemyNameDisplay(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.ENEMYNAME_DISPLAY, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0013"));
		item.SetTitleTextLocalPos(CHILD_STATE_LABEL_POS);
		item.SetButtonEnable(isEnable: false);
		item.SetValue(VideoHostingUtil.GetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.EnemyNameDisplay));
		item.AddChangeCallback(delegate
		{
			VideoHostingUtil.SetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.EnemyNameDisplay, item.GetValue());
		});
		return item;
	}

	private ItemToggle CreateToggle_RecordMode(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.RECORD_MODE, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0006"));
		item.SetStateText(systemText.Get("VideoHosting_0010"), systemText.Get("VideoHosting_0011"));
		item.SetActive_StateText(isActive: true);
		item.SetButtonEnable(isEnable: false);
		item.SetToggleLocalPos(RECORDMODE_TOGGLE_POS);
		item.SetStateTextLocalPos(RECORDMODE_STATELABEL_POS);
		item.SetSpriteONName("btn_check_03_on", isMakePixelPerfect: true, isCollisionResize: true);
		item.SetSpriteOFFName("btn_check_03_off", isMakePixelPerfect: true, isCollisionResize: true);
		item.SetValue(VideoHostingUtil.GetRecordModeEnable());
		item.AddChangeCallback(delegate
		{
			bool value = item.GetValue();
			VideoHostingUtil.SetRecordModeEnable(value);
			if (value)
			{
				VideoHostingUtil.SetPublishModeEnable(isEnable: false);
			}
			_SetItemToggleLooks(ID.RECORD_FACECAMERA, value);
			_SetItemToggleLooks(ID.RECORD_MICROPHONE, value);
			_SetItemToggleLooks(ID.ENEMYNAME_DISPLAY, value);
			_SetItemToggleLooks(ID.RECORD_PAUSE_IN_MENU, value);
			VideoHostingUtil.CheckAndCreateHUD(VideoHostingUtil.HUDScene.Home);
			UpdateRecordingFaceCameraStatus();
		});
		return item;
	}

	private ItemButton CreateButton_RecordPlayPause(bool isDispSeparatorLine, GameObject parent)
	{
		ItemButton item = CreateButton(ID.RECORD_PAUSE, isDispSeparatorLine, parent);
		item.SetSpriteName("btn_common_04_m_off", isMakePixelPerfect: true, isCollisionResize: true);
		item.SetSpriteNameOnPress("btn_common_04_m_on");
		item.SetActive_SpriteOnButton(isActive: true);
		ChangeSpriteNameRecordPlayPause(item);
		item.SetLabelPos(LABEL_POS_RECORD_PLAYPAUSE);
		item.SetSpriteOnButtonPos(SPRITE_POS_RECORD_PLAYPAUSE);
		item.AddChangeCallback(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
			if (SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecording() && !SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecordingPause())
			{
				SingletonMonoBehaviour<VideoHostingManager>.instance.PauseRecording();
			}
			else
			{
				SingletonMonoBehaviour<VideoHostingManager>.instance.ResumeRecording();
				UIManager.GetInstance().CloseLatestDialog();
			}
			ChangeSpriteNameRecordPlayPause(item);
		});
		return item;
	}

	private void ChangeSpriteNameRecordPlayPause(ItemButton item)
	{
		if (SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecording() && !SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecordingPause())
		{
			item.SetValue(Data.SystemText.Get("VideoHosting_0030"));
			item.SetSpriteOnButtonName("icon_button_rec_stop", isMakePixelPerfect: true);
		}
		else
		{
			item.SetValue(Data.SystemText.Get("VideoHosting_0031"));
			item.SetSpriteOnButtonName("icon_button_rec_resume", isMakePixelPerfect: true);
		}
	}

	private ItemButton CreateButton_RecordStop(bool isDispSeparatorLine, GameObject parent)
	{
		SystemText systemText = Data.SystemText;
		ItemButton itemButton = CreateButton(ID.RECORD_STOP, isDispSeparatorLine, parent);
		itemButton.SetValue(systemText.Get("VideoHosting_0020"));
		itemButton.SetSpriteName("btn_common_02_m_off", isMakePixelPerfect: true, isCollisionResize: true);
		itemButton.SetSpriteNameOnPress("btn_common_02_m_on");
		itemButton.SetSpriteOnButtonName("icon_button_rec_end", isMakePixelPerfect: true);
		itemButton.SetActive_SpriteOnButton(isActive: true);
		itemButton.SetLabelPos(LABEL_POS_RECORD_STOP);
		itemButton.SetSpriteOnButtonPos(SPRITE_POS_RECORD_STOP);
		itemButton.AddChangeCallback(delegate
		{
			if (SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecording())
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
				SingletonMonoBehaviour<VideoHostingManager>.instance.StopRecording();
				VideoHostingUtil.CreateDialogStopRecording(VideoHostingUtil.CheckHUDSceneUploadEnable(VideoHostingUtil.GetHUDScene()), isTimeOut: false);
				UIManager.GetInstance().GetVideoHostingHUD().CloseSettingMenuDialog();
			}
		});
		return itemButton;
	}

	private ItemToggle CreateToggle_RecordFaceCamera(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.RECORD_FACECAMERA, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0015"));
		item.SetTitleTextLocalPos(CHILD_STATE_LABEL_POS);
		item.SetButtonEnable(isEnable: false);
		item.SetValue(VideoHostingUtil.GetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.UseRecordingFaceCamera));
		item.AddChangeCallback(delegate
		{
			VideoHostingUtil.SetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.UseRecordingFaceCamera, item.GetValue());
			UpdateRecordingFaceCameraStatus();
		});
		return item;
	}

	private ItemToggle CreateToggle_RecordMicrophone(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.RECORD_MICROPHONE, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0016"));
		item.SetTitleTextLocalPos(CHILD_STATE_LABEL_POS);
		item.SetButtonEnable(isEnable: false);
		item.SetValue(VideoHostingUtil.GetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.UseRecordingMicrophone));
		item.AddChangeCallback(delegate
		{
			VideoHostingUtil.SetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.UseRecordingMicrophone, item.GetValue());
			UpdateRecordingFaceCameraStatus();
		});
		return item;
	}

	private void UpdateRecordingFaceCameraStatus()
	{
		bool isEnableCamera = VideoHostingUtil.GetRecordModeEnable() && VideoHostingUtil.GetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.UseRecordingFaceCamera);
		bool isEnableMicrophone = VideoHostingUtil.GetRecordModeEnable() && VideoHostingUtil.GetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.UseRecordingMicrophone);
		SingletonMonoBehaviour<VideoHostingManager>.instance.SetRecordingFaceCameraMicrophoneStatus(isEnableCamera, isEnableMicrophone);
		SingletonMonoBehaviour<VideoHostingManager>.instance.SetFaceCameraWindowVisible(isVisible: false);
	}

	private ItemSlider CreateSlider_RecordMicrophoneGain(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemSlider item = CreateSlider(ID.RECORD_MICROPHONE_GAIN, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0033"));
		item.SetLooks(isOn: true);
		item.SetValue(PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.VIDEOHOSTING_MICROPHONE_GAIN));
		item.AddChangeCallback(delegate
		{
			float value = item.GetValue();
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.VIDEOHOSTING_MICROPHONE_GAIN, value);
			SingletonMonoBehaviour<VideoHostingManager>.instance.SetRecordingMicrophoneGain(value);
		});
		return item;
	}

	private ItemToggle CreateToggle_RecordPauseInMenu(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.RECORD_PAUSE_IN_MENU, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0017"));
		item.SetTitleTextLocalPos(CHILD_STATE_LABEL_POS);
		item.SetButtonEnable(isEnable: false);
		item.SetValue(VideoHostingUtil.GetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.RecordPauseInMenu));
		item.AddChangeCallback(delegate
		{
			VideoHostingUtil.SetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.RecordPauseInMenu, item.GetValue());
		});
		return item;
	}

	private ItemGrid CreateGrid_RecordButton(bool isDispSeparatorLine)
	{
		ItemGrid itemGrid = CreateGrid(ID.RECORD_BUTTON_GRID, isDispSeparatorLine, m_scrollView);
		itemGrid.SetArangement(UIGrid.Arrangement.Horizontal);
		itemGrid.SetCellWidth(300f);
		return itemGrid;
	}

	private ItemToggle CreateToggle_PublishMode(bool isDispSeparatorLine)
	{
		SystemText systemText = Data.SystemText;
		ItemToggle item = CreateToggle(ID.PUBLISH_MODE, isDispSeparatorLine, SingleTabRoot);
		item.SetTitleLabel(systemText.Get("VideoHosting_0009"));
		item.SetStateText(systemText.Get("VideoHosting_0010"), systemText.Get("VideoHosting_0011"));
		item.SetActive_StateText(isActive: true);
		item.SetButtonEnable(isEnable: false);
		item.SetToggleLocalPos(PUBLISHMODE_TOGGLE_POS);
		item.SetStateTextLocalPos(PUBLISHMODE_STATELABEL_POS);
		item.SetSpriteONName("btn_check_03_on", isMakePixelPerfect: true, isCollisionResize: true);
		item.SetSpriteOFFName("btn_check_03_off", isMakePixelPerfect: true, isCollisionResize: true);
		item.SetValue(VideoHostingUtil.GetPublishModeEnable());
		item.AddChangeCallback(delegate
		{
			bool value = item.GetValue();
			VideoHostingUtil.SetPublishModeEnable(value);
			if (value)
			{
				VideoHostingUtil.SetRecordModeEnable(isEnable: false);
				UpdateRecordingFaceCameraStatus();
			}
			_SetItemToggleLooks(ID.ENEMYNAME_DISPLAY, value);
			VideoHostingUtil.CheckAndCreateHUD(VideoHostingUtil.HUDScene.Home);
		});
		return item;
	}

	protected void _SetItemToggleLooks(ID id, bool isNormal)
	{
		ItemToggle itemToggle = FindItem(id) as ItemToggle;
		if (!(null == itemToggle))
		{
			itemToggle.SetToggleLooks(isNormal);
			itemToggle.SetLabelLooks(isNormal);
		}
	}
}
