public CardTypesEditor(GameConfiguration config) : base(config) { cardTypesList = EditorUtils.SetupReorderableList("Card types", gameConfig.cardTypes, ref currentCardType, (rect, x) => { EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight), x.name); }, (x) => { currentCardType = x; currentCardTypeProperty = null; currentCardTypeStat = null; currentCardTypeDestroyCondition = null; CreateCurrentCardTypePropertiesList(); CreateCurrentCardTypeStatsList(); CreateCurrentCardTypeDestroyConditionsList(); }, () => { var cardType = new CardType(); gameConfig.cardTypes.Add(cardType); }, (x) => { currentCardType = null; currentCardTypeProperty = null; currentCardTypeStat = null; currentCardTypeDestroyCondition = null; }); }
private void DrawDestroyCardCondition(DestroyCardCondition condition) { var oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; GUILayout.BeginVertical(); var fields = condition.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); for (var i = 0; i < fields.Length; i++) { var attribute = Attribute.GetCustomAttribute(fields[i], typeof(FieldAttribute)) as FieldAttribute; if (attribute != null) { GUILayout.BeginHorizontal(); attribute.Draw(gameConfig, condition, ref fields[i]); GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); EditorGUIUtility.labelWidth = oldLabelWidth; }
private void CreateCurrentCardTypeDestroyConditionsList() { currentCardTypeDestroyConditionsList = EditorUtils.SetupReorderableList("Destroy conditions", currentCardType.destroyConditions, ref currentCardTypeDestroyCondition, (rect, x) => { EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight), x.GetReadableString(gameConfig)); }, (x) => { currentCardTypeDestroyCondition = x; }, () => { var menu = new GenericMenu(); var effectTypes = AppDomain.CurrentDomain.GetAllDerivedTypes(typeof(DestroyCardCondition)); foreach (var type in effectTypes) { menu.AddItem(new GUIContent(StringUtils.DisplayCamelCaseString(type.Name)), false, CreateDestroyConditionCallback, type); } menu.ShowAsContext(); }, (x) => { currentCardTypeDestroyCondition = null; }); }