public override PresentationResult OnInspectorGui(PresentationParamater parameter) { AssetBundleGameItemPresentationData presentationData = parameter.PresentationData as AssetBundleGameItemPresentationData ?? new AssetBundleGameItemPresentationData(); Change change = new Change(); AssetBundleGameItem assetBundleGameItem = parameter.Instance as AssetBundleGameItem ?? new AssetBundleGameItem(); string[] bundleItems = new[] { "none" }.Concat(AssetDatabase.GetAllAssetBundleNames()).ToArray(); int bundleIndex = AssetDatabase.GetAllAssetBundleNames().IndexOf(s => s == assetBundleGameItem.AssetBundle) + 1; int newIndex = EditorGUILayout.Popup("Asset bundle", bundleIndex, bundleItems); string assetBundleName = newIndex > 0 ? AssetDatabase.GetAllAssetBundleNames()[newIndex - 1] : string.Empty; change.IsDataChanged |= newIndex != bundleIndex; assetBundleGameItem.AssetBundle = assetBundleName; if (newIndex > 0) { string[] assets = AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName).Select(s => Path.GetFileNameWithoutExtension(s)).ToArray(); string[] assetItems = new[] { "none" }.Concat(assets).ToArray(); int assetIndex = assets.IndexOf(s => s == assetBundleGameItem.ItemName) + 1; int newAssetIndex = EditorGUILayout.Popup("Asset", assetIndex, assetItems); assetBundleGameItem.ItemName = newAssetIndex == 0 ? string.Empty : assets[newAssetIndex - 1]; change.IsDataChanged |= assetIndex != newAssetIndex; } return(new PresentationResult { Change = change, PresentationData = presentationData, Result = assetBundleGameItem }); }
public override PresentationResult OnInspectorGui(PresentationParamater parameter) { PresentationData presentationData = parameter.PresentationData as PresentationData; if (presentationData == null) { presentationData = new PresentationData(); } LanguageItem languageItem = parameter.Instance as LanguageItem; Type itemType = parameter.DataType.GetProperty("Value").PropertyType; bool newLanguageItem = false; if (languageItem == null) { newLanguageItem = true; languageItem = (LanguageItem)Activator.CreateInstance(typeof(InfoLanguageItem <>).MakeGenericType(itemType)); } PresentationSite presentationSite = new PresentationSite { Base = languageItem, BaseSite = parameter.PresentationSite, BasePresentation = this, SiteType = PresentationSiteType.None }; Change change; OverridableLanguageAttribute overridableLanguageAttribute = parameter.DataType.GetCustomAttribute <OverridableLanguageAttribute>(); if (overridableLanguageAttribute == null) { PropertyInfo propertyInfo = parameter.PresentationSite.GetFirtTargetedPropertyInfo(); if (propertyInfo != null) { overridableLanguageAttribute = propertyInfo.GetCustomAttribute <OverridableLanguageAttribute>(); } } if (overridableLanguageAttribute == null) { change = ApplyNotOvveriededLanguageItem(parameter, languageItem, itemType, presentationSite, presentationData); } else { if (newLanguageItem) { ((IInfoLanguageItem)languageItem).UseOverridedValue = true; } change = ApplyOvveriededLanguageItem(parameter, languageItem, itemType, presentationSite, presentationData); } return(new PresentationResult { Change = change, PresentationData = presentationData, Result = languageItem }); }
public override PresentationResult OnInspectorGui(PresentationParamater parameter) { string[] valueDefenitions = (((string[])parameter.Instance) ?? new string[0]).ToArray(); PresentationResult presentationResult = base.OnInspectorGui(parameter); string[] newValueDefenitions = (string[])presentationResult.Result; if (!presentationResult.Change.IsDataChanged && presentationResult.Change.ChildrenChange.Any(change => change.IsDataChanged)) { Balance[] balances = TypeHelper.FindType(parameter.FortInspector.Targer, typeof(Balance)).Cast <Balance>().ToArray(); for (int i = 0; i < presentationResult.Change.ChildrenChange.Length; i++) { if (presentationResult.Change.ChildrenChange[i].IsDataChanged) { foreach (Balance balance in balances) { balance.SyncValueKey(valueDefenitions[i], newValueDefenitions[i]); } } } } return(presentationResult); }
public override PresentationResult OnInspectorGui(PresentationParamater parameter) { GUIStyle guiStyle = new GUIStyle(); Change change = new Change(); object presentationData = parameter.PresentationData; AchievementsPresentationData achievementPresentationData; if (presentationData != null && !((presentationData) is AchievementsPresentationData)) { presentationData = null; } if (presentationData != null) { achievementPresentationData = (AchievementsPresentationData)presentationData; _isFoldout = achievementPresentationData.IsFoldout; } else { achievementPresentationData = new AchievementsPresentationData { IsFoldout = _isFoldout }; } achievementPresentationData.IsFoldout = EditorGUILayout.Foldout(_isFoldout, "Achievements"); change.IsPresentationChanged |= _isFoldout != achievementPresentationData.IsFoldout; _isFoldout = achievementPresentationData.IsFoldout; AchievementInfo[] achievementInfos = (AchievementInfo[])parameter.Instance; if (achievementInfos == null) { achievementInfos = new AchievementInfo[0]; } EditorGUILayout.BeginHorizontal(guiStyle); GUILayout.Space(FortInspector.ItemSpacing); EditorGUILayout.BeginVertical(guiStyle); if (_isFoldout) { ConcretePresentation[] concretePresentations = _concretePresentations; _concretePresentations = new ConcretePresentation[achievementInfos.Length]; object[] innerPresentationData = achievementPresentationData.InnerPresentationData; achievementPresentationData.InnerPresentationData = new object[achievementInfos.Length]; for (int i = 0; i < achievementInfos.Length; i++) { if (i < innerPresentationData.Length) { achievementPresentationData.InnerPresentationData[i] = innerPresentationData[i]; } } for (int i = 0; i < _concretePresentations.Length; i++) { if (i < concretePresentations.Length) { _concretePresentations[i] = concretePresentations[i]; } if (_concretePresentations[i] == null) { _concretePresentations[i] = new ConcretePresentation(); } } change.ChildrenChange = new Change[achievementInfos.Length]; for (int i = 0; i < achievementInfos.Length; i++) { PresentationParamater concreteParamater = new PresentationParamater(achievementInfos[i], achievementPresentationData.InnerPresentationData[i], achievementInfos[i].GetType().Name, typeof(AchievementInfo), new PresentationSite { BaseSite = parameter.PresentationSite, Base = parameter.Instance, BasePresentation = this, SiteType = PresentationSiteType.None }, parameter.FortInspector); PresentationResult presentationResult = _concretePresentations[i].OnInspectorGui(concreteParamater); change.ChildrenChange[i] = presentationResult.Change; achievementPresentationData.InnerPresentationData[i] = presentationResult.PresentationData; achievementInfos[i] = (AchievementInfo)presentationResult.Result; } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); return(new PresentationResult { Change = change, PresentationData = achievementPresentationData, Result = achievementInfos }); }
private static Change ApplyNotOvveriededLanguageItem(PresentationParamater parameter, LanguageItem languageItem, Type itemType, PresentationSite presentationSite, PresentationData presentationData) { GUIStyle guiStyle = new GUIStyle(); Change change = new Change(); List <Change> changes = new List <Change>(); LanguageEditorInfo languageEditorInfo = EditorInfoResolver.Resolve <LanguageEditorInfo>(); LanguageInfo[] languageInfos = languageEditorInfo.Languages.Where(info => info != null).ToArray(); if (languageInfos.Length == 1) { ApplyLanguagePrenetation(parameter, languageInfos[0], languageItem, itemType, presentationSite, presentationData, changes, parameter.Title); Change last = changes.Last(); if (last.IsAnyDataChanged()) { for (int i = 0; i < InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages.Length; i++) { if (InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages[i].Id == languageInfos[0].Id) { InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages[i] = languageInfos[0]; } } if (InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage != null && InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage.Id == languageInfos[0].Id) { InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage = languageInfos[0]; } languageEditorInfo.Save(); InfoResolver.Resolve <FortInfo>().Save(); } } else { bool oldFoldout = presentationData.IsFoldout; presentationData.IsFoldout = EditorGUILayout.Foldout(presentationData.IsFoldout, parameter.Title); change.IsPresentationChanged = oldFoldout != presentationData.IsFoldout; if (presentationData.IsFoldout) { EditorGUILayout.BeginHorizontal(guiStyle); GUILayout.Space(FortInspector.ItemSpacing); EditorGUILayout.BeginVertical(guiStyle); foreach (LanguageInfo languageInfo in languageInfos) { ApplyLanguagePrenetation(parameter, languageInfo, languageItem, itemType, presentationSite, presentationData, changes, languageInfo.Name); Change last = changes.Last(); if (last.IsAnyDataChanged()) { for (int i = 0; i < InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages.Length; i++) { if (InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages[i].Id == languageInfo.Id) { InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages[i] = languageInfo; } } if (InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage != null && InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage.Id == languageInfo.Id) { InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage = languageInfo; } } } if (changes.Any(change1 => change1.IsAnyDataChanged())) { languageEditorInfo.Save(); InfoResolver.Resolve <FortInfo>().Save(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } } change.ChildrenChange = changes.ToArray(); return(change); }
private static Change ApplyOvveriededLanguageItem(PresentationParamater parameter, LanguageItem languageItem, Type itemType, PresentationSite presentationSite, PresentationData presentationData) { GUIStyle guiStyle = new GUIStyle(); Change change = new Change(); List <Change> changes = new List <Change>(); LanguageEditorInfo languageEditorInfo = EditorInfoResolver.Resolve <LanguageEditorInfo>(); LanguageInfo[] languageInfos = languageEditorInfo.Languages.Where(info => info != null).ToArray(); IInfoLanguageItem infoLanguageItem = (IInfoLanguageItem)languageItem; if (languageInfos.Length == 1) { if (!infoLanguageItem.UseOverridedValue) { change.IsDataChanged = true; //Remove Item From Languages foreach (LanguageInfo languageInfo in languageEditorInfo.Languages) { if (languageInfo.LanguageDatas.ContainsKey(languageItem.Id)) { languageInfo.LanguageDatas.Remove(languageItem.Id); } } } infoLanguageItem.UseOverridedValue = true; Presentation presentation = parameter.FortInspector.GetResolver() .Resolve(new PresentationResolverParameter(itemType, infoLanguageItem.GetOvverideValue(), presentationSite)); PresentationResult presentationResult = presentation.OnInspectorGui(new PresentationParamater(infoLanguageItem.GetOvverideValue(), presentationData.OvverideItemPresentationData, parameter.Title, itemType, presentationSite, parameter.FortInspector)); infoLanguageItem.SetOvverideValue(presentationResult.Result); presentationData.OvverideItemPresentationData = presentationResult.PresentationData; change.ChildrenChange = new[] { presentationResult.Change }; languageEditorInfo.SyncFortAndSave(false); } else { bool oldFoldout = presentationData.IsFoldout; presentationData.IsFoldout = EditorGUILayout.Foldout(presentationData.IsFoldout, parameter.Title); change.IsPresentationChanged = oldFoldout != presentationData.IsFoldout; if (presentationData.IsFoldout) { EditorGUILayout.BeginHorizontal(guiStyle); GUILayout.Space(FortInspector.ItemSpacing); EditorGUILayout.BeginVertical(guiStyle); bool oldUseOverridedValue = infoLanguageItem.UseOverridedValue; infoLanguageItem.UseOverridedValue = EditorGUILayout.Toggle("Ovveride", infoLanguageItem.UseOverridedValue); change.IsDataChanged |= oldUseOverridedValue != infoLanguageItem.UseOverridedValue; if (infoLanguageItem.UseOverridedValue) { Presentation presentation = parameter.FortInspector.GetResolver() .Resolve(new PresentationResolverParameter(itemType, infoLanguageItem.GetOvverideValue(), presentationSite)); PresentationResult presentationResult = presentation.OnInspectorGui(new PresentationParamater(infoLanguageItem.GetOvverideValue(), presentationData.OvverideItemPresentationData, parameter.Title, itemType, presentationSite, parameter.FortInspector)); infoLanguageItem.SetOvverideValue(presentationResult.Result); presentationData.OvverideItemPresentationData = presentationResult.PresentationData; change.ChildrenChange = new[] { presentationResult.Change }; languageEditorInfo.SyncFortAndSave(false); } else { infoLanguageItem.SetOvverideValue(itemType.GetDefault()); foreach (LanguageInfo languageInfo in languageInfos) { ApplyLanguagePrenetation(parameter, languageInfo, languageItem, itemType, presentationSite, presentationData, changes, languageInfo.Name); Change last = changes.Last(); if (last.IsAnyDataChanged()) { for (int i = 0; i < InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages.Length; i++) { if (InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages[i].Id == languageInfo.Id) { InfoResolver.Resolve <FortInfo>().Language.ActiveLanguages[i] = languageInfo; } } if (InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage != null && InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage.Id == languageInfo.Id) { InfoResolver.Resolve <FortInfo>().Language.DefaultLanguage = languageInfo; } } } if (changes.Any(change1 => change1.IsAnyDataChanged())) { languageEditorInfo.Save(); InfoResolver.Resolve <FortInfo>().Save(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } change.ChildrenChange = changes.ToArray(); } return(change); }
public override PresentationResult OnInspectorGui(PresentationParamater parameter) { GUIStyle guiStyle = new GUIStyle(); EditorGUILayout.BeginVertical(guiStyle); Change change = new Change(); BalancePresentationData balancePresentationData = parameter.PresentationData as BalancePresentationData ?? new BalancePresentationData(); bool isFoldout = balancePresentationData.IsFoldout; balancePresentationData.IsFoldout = EditorGUILayout.Foldout(balancePresentationData.IsFoldout, parameter.Title); change.IsPresentationChanged = isFoldout != balancePresentationData.IsFoldout; Balance balance = (Balance)parameter.Instance; if (balance == null) { balance = new Balance(); } balance.SyncValues(); Dictionary <string, int> values = balance.Values; NumberPresentation[] numberPresentations = _numberPresentations; _numberPresentations = new NumberPresentation[values.Count]; KeyValuePair <string, int>[] pairs = values.ToArray(); if (balancePresentationData.IsFoldout) { change.ChildrenChange = new Change[_numberPresentations.Length]; for (int i = 0; i < _numberPresentations.Length; i++) { if (i < numberPresentations.Length) { _numberPresentations[i] = numberPresentations[i]; } PresentationParamater presentationParamater = new PresentationParamater(pairs[i].Value, null, pairs[i].Key, typeof(int), new PresentationSite { Base = parameter.Instance, BaseSite = parameter.PresentationSite, BasePresentation = this, SiteType = PresentationSiteType.None }, parameter.FortInspector); if (_numberPresentations[i] == null) { _numberPresentations[i] = new NumberPresentation(); } EditorGUILayout.BeginHorizontal(guiStyle); GUILayout.Space(FortInspector.ItemSpacing); EditorGUILayout.BeginVertical(guiStyle); PresentationResult presentationResult = _numberPresentations[i].OnInspectorGui(presentationParamater); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); change.ChildrenChange[i] = presentationResult.Change; values[pairs[i].Key] = (int)presentationResult.Result; } } EditorGUILayout.EndVertical(); return(new PresentationResult { Change = change, PresentationData = balancePresentationData, Result = balance }); }