private void DrawDataEntry(EntityStatDictionary data, StatData stat, EntityStatValues selectedData) { if (selectedData != null) { //Draw data for Entity, if available using (new GUILayout.HorizontalScope("box")) { GUI.backgroundColor = Color.white; var obj = new SerializedObject(selectedData.value); obj.Update(); var serializedProp = obj.FindProperty("value"); EditorGUILayout.PropertyField( serializedProp, new GUIContent(string.Empty), GUILayout.MinWidth(TableEntryWidth), GUILayout.MaxWidth(TableEntryWidth)); obj.ApplyModifiedProperties(); } } else { //No data for Entity, draw "N/A" using (new GUILayout.HorizontalScope( "box", GUILayout.MinWidth(TableEntryWidth + 8), GUILayout.MaxWidth(TableEntryWidth + 8))) { GUI.backgroundColor = Color.white; GUILayout.Label("N/A"); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.MaxHeight(15))) { _entityData = data.entityData; _statData = stat; switch (stat.statTypeEnum) { case StatTypeEnum.BOOL: CreateBoolEntry(data.entityData.entityName, stat.Name); break; case StatTypeEnum.FLOAT: CreateFloatEntry(data.entityData.entityName, stat.Name); break; case StatTypeEnum.INT: CreateIntEntry(data.entityData.entityName, stat.Name); break; } } } } }
private void DrawMissingStatsPanel() { _showMissingStatsPanel = EditorGUILayout.Foldout(_showMissingStatsPanel, "Missing Stats"); if (!_showMissingStatsPanel) { return; } using (new GUILayout.HorizontalScope()) { //Cycle through Faction Buildings and add any that are missing from the Faction Data Dictionary if (GUILayout.Button("Fill Out Entities", GUILayout.MinWidth(150))) { foreach (var entity in _factionData[_factionSelection].factionBuildings) { if (_globalDictionary.data.Count(o => o.entityData == entity) > 0) { continue; } Debug.LogWarning($"Missing: {entity.entityName}"); var item = new EntityStatDictionary { entityData = entity, statValues = new List <EntityStatValues>() }; _globalDictionary.data.Add(item); } } GUI.color = Color.red; GUILayout.Label( $"Entities in Dictionary: {_globalDictionary.data.Count}/{_factionData[_factionSelection].factionBuildings.Count}"); GUI.color = Color.white; GUILayout.FlexibleSpace(); } if (GUILayout.Button("Fill Out Stats", GUILayout.MinWidth(150), GUILayout.MaxWidth(150))) { //TODO: Functionality to automatically create StatData for any missing entry } }
private void CreateStatEntry(string entityDataName, string statValue, StatType statTypeValue) { Undo.RecordObject(_globalDictionary, "Add new dictionary stat"); var statValues = new EntityStatValues { statData = _statData, value = statTypeValue }; AssetDatabase.CreateAsset( statValues.value, $"Assets/_SALVO/Data/Stat Values/{entityDataName}_{statValue}.asset"); EntityStatDictionary stat; //Create container if (!DoesEntityDataAlreadyExist(_entityData)) { stat = new EntityStatDictionary { entityData = _entityData, statValues = new List <EntityStatValues> { statValues } }; _globalDictionary.data.Add(stat); } else { //Entity Data - Already exists, just add to previous dictionaries stat = _globalDictionary.data.First(o => o.entityData == _entityData); stat.statValues.Add(statValues); } EditorUtility.SetDirty(_globalDictionary); AssetDatabase.SaveAssets(); }