123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using com.workman.cm3d2.button;
- using UnityEngine;
- public class SaveAndLoadCtrl : BaseCreateViewerCtrl
- {
- public bool Kasiduki
- {
- set
- {
- this.kasiduki = value;
- }
- }
- public bool IsTitleScene
- {
- get
- {
- return this.isTitleScene;
- }
- }
- public bool GetIsLoading()
- {
- return this.isLoading;
- }
- public void Init(SaveAndLoadMgr saveAndLoadMgr, GameObject goSaveAndLoadPanel)
- {
- this.m_mgr = saveAndLoadMgr;
- this.m_goPanel = goSaveAndLoadPanel;
- }
- private void InitViewer()
- {
- this.m_goTitleSave = UTY.GetChildObject(this.m_goPanel, "TitleGroup/TitleSave", false);
- this.m_goTitleLoad = UTY.GetChildObject(this.m_goPanel, "TitleGroup/TitleLoad", false);
- this.m_listAllButton = new List<ButtonEnable>();
- this.m_goDisplaySave = UTY.GetChildObject(this.m_goPanel, "DisplayButtonGroup/DisplaySave", false);
- this.m_goDisplayLoad = UTY.GetChildObject(this.m_goPanel, "DisplayButtonGroup/DisplayLoad", false);
- BoxCollider component3;
- ButtonEnable item;
- if (this.isTitleScene)
- {
- this.m_goDisplaySave.SetActive(false);
- this.m_goDisplayLoad.SetActive(false);
- }
- else
- {
- UIButton component = this.m_goDisplaySave.GetComponent<UIButton>();
- EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_mgr.OpenSavePanel));
- UIButton component2 = this.m_goDisplayLoad.GetComponent<UIButton>();
- EventDelegate.Add(component2.onClick, new EventDelegate.Callback(this.m_mgr.OpenLoadPanel));
- component3 = this.m_goDisplaySave.GetComponent<BoxCollider>();
- item = new ButtonEnable(component, component3);
- this.m_listAllButton.Add(item);
- component3 = this.m_goDisplayLoad.GetComponent<BoxCollider>();
- item = new ButtonEnable(component2, component3);
- this.m_listAllButton.Add(item);
- }
- this.m_dicPageButton = new Dictionary<SaveAndLoadMgr.PageNo, SaveAndLoadCtrl.PageButton>();
- bool flag = false;
- IEnumerator enumerator = Enum.GetValues(typeof(SaveAndLoadMgr.PageNo)).GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- SaveAndLoadMgr.PageNo pageNo = (SaveAndLoadMgr.PageNo)obj;
- GameObject childObject = UTY.GetChildObject(this.m_goPanel, "PageGroup/PageButtonParent/" + pageNo.ToString(), false);
- UIButton component4 = childObject.GetComponent<UIButton>();
- EventDelegate.Add(component4.onClick, new EventDelegate.Callback(this.m_mgr.ClickPageNo));
- GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
- childObject2.SetActive(false);
- SaveAndLoadCtrl.PageButton pageButton = new SaveAndLoadCtrl.PageButton();
- pageButton.pageNo = pageNo;
- pageButton.btnPageNo = component4;
- pageButton.selectCursor = childObject2;
- this.m_dicPageButton.Add(pageButton.pageNo, pageButton);
- component3 = childObject.GetComponent<BoxCollider>();
- item = new ButtonEnable(component4, component3);
- this.m_listAllButton.Add(item);
- if (!flag)
- {
- this.activeColor = new Color(component4.defaultColor.r, component4.defaultColor.g, component4.defaultColor.b, 1f);
- this.inActiveColor = component4.defaultColor;
- flag = true;
- }
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- GameObject childObject3 = UTY.GetChildObject(this.m_goPanel, "Cancel", false);
- UIButton component5 = childObject3.GetComponent<UIButton>();
- EventDelegate.Add(component5.onClick, new EventDelegate.Callback(this.m_mgr.CloseSaveAndLoadPanel));
- component3 = childObject3.GetComponent<BoxCollider>();
- item = new ButtonEnable(component5, component3);
- this.m_listAllButton.Add(item);
- this.m_unitPrefabPath = "SceneDaily/SaveAndLoad/Prefab/DataUnit";
- this.m_goEmptyPrefab = (Resources.Load("SceneDaily/SaveAndLoad/Prefab/EmptyUnit") as GameObject);
- this.m_goUnitParent = UTY.GetChildObject(this.m_goPanel, "DataViewer/DataUnitParent", false);
- }
- public void CreateSaveAndLoadDataViewer(Dictionary<string, SaveAndLoadCtrl.LoadDataUnit> dicData, SaveAndLoadMgr.ViewType viewType)
- {
- if (!this.m_bInit)
- {
- this.InitViewer();
- this.m_bInit = true;
- }
- this.m_dicLoadData = dicData;
- this.m_selectedViewType = viewType;
- base.CreateViewerWhenDataNotExist<string, SaveAndLoadCtrl.LoadDataUnit>(dicData);
- bool saveUI = false;
- if (viewType != SaveAndLoadMgr.ViewType.Save)
- {
- if (viewType == SaveAndLoadMgr.ViewType.Load)
- {
- saveUI = false;
- this.isLoading = false;
- }
- }
- else
- {
- saveUI = true;
- }
- this.SetSaveUI(saveUI);
- this.SetPageButtonActive(this.m_mgr.GetCurrentPageNo());
- }
- private void SetSaveUI(bool active)
- {
- this.m_goTitleSave.SetActive(active);
- this.m_goTitleLoad.SetActive(!active);
- if (!this.isTitleScene)
- {
- this.m_goDisplaySave.SetActive(!active);
- this.m_goDisplayLoad.SetActive(active);
- }
- }
- protected override void SetDataForViewer()
- {
- foreach (KeyValuePair<string, SaveAndLoadCtrl.LoadDataUnit> keyValuePair in this.m_dicLoadData)
- {
- string key = keyValuePair.Key;
- SaveAndLoadCtrl.LoadDataUnit value = keyValuePair.Value;
- GameObject gameObject;
- if (value.isEmpty)
- {
- gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goEmptyPrefab);
- }
- else
- {
- gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
- }
- gameObject.name = key;
- base.SetTransformInfo(gameObject);
- if (Product.supportMultiLanguage)
- {
- UIWFPositionStore componentInChildren = gameObject.GetComponentInChildren<UIWFPositionStore>();
- if (componentInChildren != null)
- {
- componentInChildren.Apply();
- }
- }
- GameObject childObject = UTY.GetChildObject(gameObject, "Content/SelectCursor", false);
- childObject.SetActive(false);
- value.selectCursor = childObject;
- UIButton component = gameObject.GetComponent<UIButton>();
- value.btnLoadData = component;
- EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_mgr.ClickSaveOrLoadData));
- if (value.isEmpty)
- {
- if (this.m_selectedViewType == SaveAndLoadMgr.ViewType.Load)
- {
- component.enabled = false;
- gameObject.GetComponent<BoxCollider>().enabled = false;
- }
- }
- else
- {
- GameObject childObject2 = UTY.GetChildObject(gameObject, "NewLabel", false);
- if (value.isLatest)
- {
- childObject2.SetActive(true);
- }
- UILabel component2 = UTY.GetChildObject(gameObject, "Content/DataInfo/Date", false).GetComponent<UILabel>();
- component2.text = value.createAt;
- UILabel component3 = UTY.GetChildObject(gameObject, "Content/DataInfo/LapsedDays/Number", false).GetComponent<UILabel>();
- component3.text = value.lapsedDays.ToString();
- UILabel component4 = UTY.GetChildObject(gameObject, "Content/DataInfo/Manager/Name", false).GetComponent<UILabel>();
- component4.text = value.managerName;
- UILabel component5 = UTY.GetChildObject(gameObject, "Content/DataInfo/NumberOfEmployees/Number", false).GetComponent<UILabel>();
- component5.text = value.numberOfEmployees.ToString();
- GameObject childObject3 = UTY.GetChildObject(gameObject, "Content/Comment/InputField", false);
- UIEventTrigger uieventTrigger = childObject3.AddComponent<UIEventTrigger>();
- EventDelegate.Add(uieventTrigger.onClick, new EventDelegate.Callback(this.m_mgr.ClickComment));
- UIInput component6 = childObject3.GetComponent<UIInput>();
- component6.value = value.comment;
- component6.name = "Comment_" + key;
- value.uiComment = component6;
- BoxCollider component7 = gameObject.GetComponent<BoxCollider>();
- ButtonEnable item = new ButtonEnable(component, component7);
- this.m_listAllButton.Add(item);
- EventDelegate.Add(component6.onChange, new EventDelegate.Callback(this.m_mgr.OnChangeComment));
- GameObject childObject4 = UTY.GetChildObject(gameObject, "NotUsePanel", false);
- if (childObject4 != null)
- {
- childObject4.SetActive(value.productTypeID != (int)Product.type);
- if (childObject4.activeSelf)
- {
- component7.size = Vector3.zero;
- }
- }
- }
- }
- }
- private void SetPageButtonActive(SaveAndLoadMgr.PageNo pageNo)
- {
- SaveAndLoadCtrl.PageButton pageButton = null;
- if (this.m_dicPageButton.TryGetValue(pageNo, out pageButton))
- {
- foreach (KeyValuePair<SaveAndLoadMgr.PageNo, SaveAndLoadCtrl.PageButton> keyValuePair in this.m_dicPageButton)
- {
- SaveAndLoadCtrl.PageButton value = keyValuePair.Value;
- if (value.pageNo == pageNo)
- {
- value.selectCursor.SetActive(true);
- value.btnPageNo.defaultColor = this.activeColor;
- }
- else
- {
- value.selectCursor.SetActive(false);
- value.btnPageNo.defaultColor = this.inActiveColor;
- }
- }
- }
- }
- public void SaveComment(string commentName, string comment)
- {
- if (this.MAX_COMMENT_LENGTH < comment.Length)
- {
- comment = comment.Substring(0, this.MAX_COMMENT_LENGTH);
- }
- string key = this.ToButtonName(commentName);
- SaveAndLoadCtrl.LoadDataUnit loadDataUnitByKey = this.GetLoadDataUnitByKey(key);
- GameMain.Instance.SaveDataCommentSave(loadDataUnitByKey.serialNo, comment);
- }
- private string ToButtonName(string commentName)
- {
- return commentName.Replace("Comment_", string.Empty);
- }
- public void SaveAndLoad(SaveAndLoadMgr.ViewType currentView, string buttonName)
- {
- string messageTerm = string.Empty;
- SystemDialog.OnClick f_dgOk = null;
- SaveAndLoadCtrl.LoadDataUnit loadDataUnit = null;
- if (!this.m_dicLoadData.TryGetValue(buttonName, out loadDataUnit))
- {
- Debug.LogError(string.Format("不適切なデータがクリックされました。クリックされたデータ名={0}", buttonName));
- }
- if (currentView != SaveAndLoadMgr.ViewType.Save)
- {
- if (currentView == SaveAndLoadMgr.ViewType.Load)
- {
- if (loadDataUnit.isEmpty)
- {
- return;
- }
- this.m_loadDataNo = buttonName;
- if (this.kasiduki)
- {
- messageTerm = "Dialog/このエンパイアクラブでゲストモードを開始しますか?";
- f_dgOk = new SystemDialog.OnClick(this.LoadDataOnKasizuli);
- }
- else
- {
- messageTerm = "Dialog/セーブロード/データをロードしますか?";
- f_dgOk = new SystemDialog.OnClick(this.LoadData);
- }
- }
- }
- else
- {
- if (loadDataUnit.isEmpty)
- {
- messageTerm = "Dialog/セーブロード/データを保存しますか?";
- }
- else
- {
- messageTerm = "Dialog/セーブロード/上書きして保存しますが宜しいですか?";
- }
- this.m_saveDataNo = buttonName;
- f_dgOk = new SystemDialog.OnClick(this.SaveData);
- }
- GameMain.Instance.SysDlg.ShowFromLanguageTerm(messageTerm, null, SystemDialog.TYPE.OK_CANCEL, f_dgOk, new SystemDialog.OnClick(this.CloseDialog));
- }
- public void SetSaveOrLoadDataActive(string buttonName)
- {
- SaveAndLoadCtrl.LoadDataUnit loadDataUnit = null;
- if (this.m_dicLoadData.TryGetValue(buttonName, out loadDataUnit))
- {
- foreach (KeyValuePair<string, SaveAndLoadCtrl.LoadDataUnit> keyValuePair in this.m_dicLoadData)
- {
- string key = keyValuePair.Key;
- SaveAndLoadCtrl.LoadDataUnit value = keyValuePair.Value;
- if (key == buttonName)
- {
- value.selectCursor.SetActive(true);
- if (value.isEmpty)
- {
- value.btnLoadData.defaultColor = this.activeColor;
- }
- }
- else
- {
- value.selectCursor.SetActive(false);
- if (value.isEmpty)
- {
- value.btnLoadData.defaultColor = this.inActiveColor;
- }
- }
- }
- }
- else
- {
- Debug.LogError(string.Format("不適切なデータがクリックされました。クリックされたデータ名={0}", buttonName));
- }
- }
- private void SaveData()
- {
- SaveAndLoadCtrl.LoadDataUnit loadDataUnit = this.m_dicLoadData[this.m_saveDataNo];
- string f_strComment = string.Empty;
- if (!loadDataUnit.isEmpty)
- {
- f_strComment = loadDataUnit.uiComment.value;
- }
- GameMain.Instance.Serialize(loadDataUnit.serialNo, f_strComment);
- this.m_mgr.PageUpper();
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/セーブロード/データが保存されました。", null, SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.CloseDialog), null);
- this.m_saveDataNo = string.Empty;
- }
- public void LoadData()
- {
- this.SetAllButtonEnable(false);
- GameMain.Instance.SysDlg.Close();
- GameMain.Instance.MainCamera.FadeOut(0.5f, false, null, true, default(Color));
- int serialNoByKey = this.GetSerialNoByKey(this.m_loadDataNo);
- this.isLoading = true;
- this.m_loadDataNo = string.Empty;
- this.m_mgr.ClosePanelAfterAction<int>(new Func<int, bool>(this.GameStart), serialNoByKey);
- DanceSelect.ChallengeDay = 0;
- }
- private bool GameStart(int loadDataNo)
- {
- bool result = GameMain.Instance.Deserialize(loadDataNo, false);
- GameMain.Instance.CharacterMgr.status.SetFlag("傅きモード", (int)Convert.ToInt16(this.kasiduki));
- GameMain.Instance.ScriptMgr.adv_kag.Exec();
- return result;
- }
- private void LoadDataOnKasizuli()
- {
- GameMain.Instance.SysDlg.Close();
- int serialNoByKey = this.GetSerialNoByKey(this.m_loadDataNo);
- this.isLoading = true;
- this.m_loadDataNo = string.Empty;
- this.m_mgr.ClosePanelAfterAction<int>(delegate(int dataNo)
- {
- bool result = GameMain.Instance.Deserialize(dataNo, false);
- this.m_mgr.OpenLoadPanelKasizukiLocal();
- return result;
- }, serialNoByKey);
- }
- public void CloseReset()
- {
- this.m_saveDataNo = (this.m_loadDataNo = string.Empty);
- this.SetAllButtonEnable(true);
- this.isLoading = false;
- UICamera.InputEnable = true;
- }
- private SaveAndLoadCtrl.LoadDataUnit GetLoadDataUnitByKey(string key)
- {
- SaveAndLoadCtrl.LoadDataUnit result = null;
- if (this.m_dicLoadData.TryGetValue(key, out result))
- {
- return result;
- }
- Debug.LogError(string.Format("不適切なキーが指定されました。指定されたキー={0}", key));
- return result;
- }
- private int GetSerialNoByKey(string key)
- {
- return this.GetLoadDataUnitByKey(key).serialNo;
- }
- private void CloseDialog()
- {
- this.m_mgr.SetCurrentActiveData(string.Empty);
- GameMain.Instance.SysDlg.Close();
- }
- public void SetAllButtonEnable(bool enabled)
- {
- foreach (ButtonEnable buttonEnable in this.m_listAllButton)
- {
- buttonEnable.SetEnable(enabled);
- }
- }
- public bool ExistData(string buttonName)
- {
- SaveAndLoadCtrl.LoadDataUnit loadDataUnit = null;
- if (this.m_dicLoadData.TryGetValue(buttonName, out loadDataUnit))
- {
- return !loadDataUnit.isEmpty;
- }
- Debug.LogError(string.Format("不適切なボタンが右クリックされました。クリックされたボタン名={0}", buttonName));
- return false;
- }
- public void DeleteSaveOrLoadData(string btnName)
- {
- this.SetSaveOrLoadDataActive(btnName);
- SaveAndLoadCtrl.LoadDataUnit loadDataUnit = null;
- if (this.m_dicLoadData.TryGetValue(btnName, out loadDataUnit))
- {
- this.m_deleteSerialNo = loadDataUnit.serialNo;
- }
- GameMain.Instance.SysDlg.ShowFromLanguageTerm("Dialog/セーブロード/データを削除しますが宜しいですか?", null, SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.DeleteData), new SystemDialog.OnClick(this.CloseDialog));
- }
- private void DeleteData()
- {
- GameMain.Instance.DeleteSerializeData(this.m_deleteSerialNo);
- this.CloseDialog();
- this.m_mgr.PageUpper();
- }
- public void OnDisablePanel()
- {
- if (this.m_goUnitParent != null)
- {
- base.DelChildGameObject(this.m_goUnitParent);
- }
- }
- [SerializeField]
- private bool isTitleScene;
- [SerializeField]
- private bool kasiduki;
- private SaveAndLoadMgr m_mgr;
- private GameObject m_goPanel;
- private GameObject m_goTitleSave;
- private GameObject m_goTitleLoad;
- private GameObject m_goDisplaySave;
- private GameObject m_goDisplayLoad;
- private GameObject m_goEmptyPrefab;
- private Dictionary<SaveAndLoadMgr.PageNo, SaveAndLoadCtrl.PageButton> m_dicPageButton;
- private Dictionary<string, SaveAndLoadCtrl.LoadDataUnit> m_dicLoadData;
- private List<ButtonEnable> m_listAllButton;
- private bool isLoading;
- private const string DATA_UNIT_PARENT_PATH = "DataViewer/DataUnitParent";
- private const string DATA_UNIT_PREFAB_PATH = "SceneDaily/SaveAndLoad/Prefab/DataUnit";
- private const string EMPTY_UNIT_PREFAB_PATH = "SceneDaily/SaveAndLoad/Prefab/EmptyUnit";
- private const string PAGE_BUTTON_PARENT_PATH = "PageGroup/PageButtonParent/";
- private const string SYSTEM_UI_ROOT_PATH = "__GameMain__/SystemUI Root";
- private const string DIALOG_MESSAGE_TO_SAVE_NORMAL = "データを保存しますか?";
- private const string DIALOG_MESSAGE_TO_SAVE_OVERWRITE = "上書きして保存しますが宜しいですか?";
- private const string DIALOG_MESSAGE_TO_LOAD = "データをロードしますか?";
- private const string DIALOG_MESSAGE_TO_LOAD_KASIDUKI = "このエンパイアクラブでゲストモードを開始しますか?";
- private const string DIALOG_MESSAGE_RESULT_SAVE = "データが保存されました。";
- private const string DIALOG_MESSAGE_RESULT_LOAD = "データをロードしました。";
- private const string DIALOG_MESSAGE_TO_DELETE = "データを削除しますが宜しいですか?";
- private const string PREFIX_COMMENT = "Comment_";
- private Color activeColor;
- private Color inActiveColor;
- private SaveAndLoadMgr.ViewType m_selectedViewType;
- private bool m_bInit;
- private string m_saveDataNo;
- private string m_loadDataNo;
- private int m_deleteSerialNo;
- private int MAX_COMMENT_LENGTH = 25;
- public class PageButton
- {
- public SaveAndLoadMgr.PageNo pageNo;
- public UIButton btnPageNo;
- public GameObject selectCursor;
- }
- public class LoadDataUnit
- {
- public int pageNo;
- public int serialNo;
- public bool isLatest;
- public string createAt;
- public int lapsedDays;
- public string managerName;
- public int numberOfEmployees;
- public string comment;
- public bool isEmpty;
- public int nVer;
- public int productTypeID;
- public GameObject selectCursor;
- public UIButton btnLoadData;
- public UIInput uiComment;
- }
- }
|