private void LocationView() { EditorGUILayout.LabelField("Backgrounds", _title); GUILayout.Space(10); EditorGUILayout.BeginHorizontal("BOX"); if (GUILayout.Button("Define Background")) { VNDatabasePopUpWindow.InitNodePopup(DataContainerType.Location); } if (_locationContainer.data.Count == 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("You don't have a background defined.", MessageType.Warning); return; } var locations = _locationContainer.data.Select(x => x as DLocation).ToArray(); var names = locations.Select(x => x.GetIdentificator()).ToArray(); _locationSelected = EditorGUILayout.Popup("Locations:", _locationSelected, names); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (_toDelete) { if (GUILayout.Button("Delete")) { _toDelete = false; var temp = locations[_locationSelected]; _locationContainer.data.Remove(temp); EditorUtility.SetDirty(_locationContainer); _locationSelected = 0; var graphs = Resources.LoadAll("Data").Select(x => x as EngineGraph).Where(x => x != null); foreach (var item in graphs) { var change = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Change_Background) .Select(x => x as NChangeBackground) .Where(x => x.locationGroups == temp); foreach (var node in change) { node.locationGroups = null; EditorUtility.SetDirty(node); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); VNDatabaseUtilitie.DeleteElem(temp); return; } if (GUILayout.Button("Cancel")) { _toDelete = false; } } else { if (GUILayout.Button("Save Locations")) { EditorUtility.SetDirty(_locationContainer); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (GUILayout.Button("Delete Background")) { _toDelete = true; } } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); var name = locations[_locationSelected].GetIdentificator(); name = EditorGUILayout.TextField("Background name:", name); locations[_locationSelected].SetIdentificator(name); GUILayout.Space(5); GUILayout.Label(" Sprites", _subTitle); EditorGUI.DrawRect(GUILayoutUtility.GetRect(25, 2), Color.black); GUILayout.Space(6); EditorGUILayout.BeginVertical("BOX"); var sprites = locations[_locationSelected].Foreach(); if (sprites.Any()) { foreach (var sprite in sprites) { EditorGUILayout.BeginHorizontal("BOX"); EditorGUILayout.BeginVertical(); sprite.Item2 = (Sprite)EditorGUILayout.ObjectField(sprite.Item2, typeof(Sprite), true); if (!sprite.Item2) { EditorGUILayout.HelpBox("The sprite can't be null", MessageType.Error); } else if (sprites.Where(x => x != sprite).Any(x => x.Item2 == sprite.Item2)) { EditorGUILayout.HelpBox("The location already contains this sprite", MessageType.Warning); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); sprite.Item1 = EditorGUILayout.TextField("Name:", sprite.Item1); if (!sprite.Item1.Any() || sprite.Item1 == " ") { EditorGUILayout.HelpBox("The name can't be null or a backspace", MessageType.Error); } else if (sprites.Where(x => x != sprite).Any(x => x.Item1 == sprite.Item1)) { EditorGUILayout.HelpBox("The location already contains this name", MessageType.Warning); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Unsuscribe")) { locations[_locationSelected].UnsuscribeBackground(sprite); return; } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("The background don't have sprites.", MessageType.Warning); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Suscribe sprite")) { locations[_locationSelected].SuscribeBackground("", default(Sprite)); } }
private void SoundView() { EditorGUILayout.LabelField("Sounds", _title); GUILayout.Space(10); EditorGUILayout.BeginHorizontal("BOX"); if (GUILayout.Button("Define Sound Group")) { VNDatabasePopUpWindow.InitNodePopup(DataContainerType.Soundtrack); } if (_soundContainer.data.Count == 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("You don't have a sound group defined.", MessageType.Warning); return; } var sounds = _soundContainer.data.Select(x => x as DSoundtrack).ToArray(); var names = sounds.Select(x => x.GetIdentificator()).ToArray(); _soundSelected = EditorGUILayout.Popup("Sound group:", _soundSelected, names); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (_toDelete) { if (GUILayout.Button("Delete")) { _toDelete = false; var temp = sounds[_soundSelected]; _soundContainer.data.Remove(temp); EditorUtility.SetDirty(_soundContainer); _soundSelected = 0; var graphs = Resources.LoadAll("Data").Select(x => x as EngineGraph).Where(x => x != null); foreach (var item in graphs) { var playMusic = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Play_Music) .Select(x => x as NPlayMusic) .Where(x => x.musicGroup == temp); foreach (var node in playMusic) { node.musicGroup = null; EditorUtility.SetDirty(node); } var playSound = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Play_Sound) .Select(x => x as NPlaySound) .Where(x => x.soundGroup == temp); foreach (var node in playSound) { node.soundGroup = null; EditorUtility.SetDirty(node); } var playVoice = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Play_Voice) .Select(x => x as NPlayVoice) .Where(x => x.voiceGroup == temp); foreach (var node in playVoice) { node.voiceGroup = null; EditorUtility.SetDirty(node); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); VNDatabaseUtilitie.DeleteElem(temp); return; } if (GUILayout.Button("Cancel")) { _toDelete = false; } } else { if (GUILayout.Button("Save Sounds group")) { EditorUtility.SetDirty(_soundContainer); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (GUILayout.Button("Delete Sound Group")) { _toDelete = true; } } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); var name = sounds[_soundSelected].GetIdentificator(); name = EditorGUILayout.TextField("Sound group name:", name); sounds[_soundSelected].SetIdentificator(name); GUILayout.Space(5); var soundsChannel = new string[3] { "Music", "SoundFX", "Voice" }; sounds[_soundSelected].Channel = (SoundChannelEnum)EditorGUILayout.Popup("Channel:", (int)sounds[_soundSelected].Channel, soundsChannel); GUILayout.Label(" Sounds", _subTitle); EditorGUI.DrawRect(GUILayoutUtility.GetRect(25, 2), Color.black); GUILayout.Space(6); EditorGUILayout.BeginVertical("BOX"); var clips = sounds[_soundSelected].Foreach(); if (clips.Any()) { foreach (var clip in clips) { EditorGUILayout.BeginHorizontal("BOX"); EditorGUILayout.BeginVertical(); clip.Item2 = (AudioClip)EditorGUILayout.ObjectField(clip.Item2, typeof(AudioClip), true); if (!clip.Item2) { EditorGUILayout.HelpBox("The clip can't be null", MessageType.Error); } else if (clips.Where(x => x != clip).Any(x => x.Item2 == clip.Item2)) { EditorGUILayout.HelpBox("The sound group already contains this clip", MessageType.Warning); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); clip.Item1 = EditorGUILayout.TextField("Sound name:", clip.Item1); if (!clip.Item1.Any() || clip.Item1 == " ") { EditorGUILayout.HelpBox("The name can't be null or a backspace", MessageType.Error); } else if (clips.Where(x => x != clip).Any(x => x.Item1 == clip.Item1)) { EditorGUILayout.HelpBox("The sound group already contains this name", MessageType.Warning); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Unsuscribe")) { sounds[_soundSelected].UnsuscribeSound(clip); return; } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("The sound group don't have sounds.", MessageType.Warning); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Suscribe sound")) { sounds[_soundSelected].SuscribeSound("", default(AudioClip)); } }
private void CharacterView() { EditorGUILayout.LabelField("Characters", _title); GUILayout.Space(10); EditorGUILayout.BeginHorizontal("BOX"); if (GUILayout.Button("Define Character")) { VNDatabasePopUpWindow.InitNodePopup(DataContainerType.Character); } if (_characterContainer.data.Count == 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("You don't have a character defined.", MessageType.Warning); return; } var characters = _characterContainer.data.Select(x => x as DCharacter).ToArray(); var names = characters.Select(x => x.GetIdentificator()).ToArray(); _characterSelected = EditorGUILayout.Popup("Character:", _characterSelected, names); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (_toDelete) { if (GUILayout.Button("Delete")) { _toDelete = false; var temp = characters[_characterSelected]; _characterContainer.data.Remove(temp); EditorUtility.SetDirty(_characterContainer); _characterSelected = 0; var graphs = Resources.LoadAll("Data").Select(x => x as EngineGraph).Where(x => x != null); foreach (var item in graphs) { var show = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Show_Character) .Select(x => x as NShowCharacter) .Where(x => x.character == temp); foreach (var node in show) { node.character = null; EditorUtility.SetDirty(node); } var hide = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Hide_Character) .Select(x => x as NHideCharacter) .Where(x => x.character == temp); foreach (var node in hide) { node.character = null; EditorUtility.SetDirty(node); } var change = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Change_Character_Sprite) .Select(x => x as NChangeCharacterSprite) .Where(x => x.character == temp); foreach (var node in change) { node.character = null; EditorUtility.SetDirty(node); } var move = item.nodes.Where(x => x.nodeType == ParadoxEngine.Utilities.EnumNodeType.Move_Character) .Select(x => x as NMoveCharacter) .Where(x => x.character == temp); foreach (var node in move) { node.character = null; EditorUtility.SetDirty(node); } } VNDatabaseUtilitie.DeleteElem(temp); return; } if (GUILayout.Button("Cancel")) { _toDelete = false; } } else { if (GUILayout.Button("Save Characters")) { EditorUtility.SetDirty(_characterContainer); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (GUILayout.Button("Delete Character")) { _toDelete = true; } } EditorGUILayout.EndHorizontal(); GUILayout.Space(20); var name = characters[_characterSelected].GetIdentificator(); characters[_characterSelected].SetIdentificator(EditorGUILayout.TextField("Character name:", name)); GUILayout.Space(5); #region Sprite label GUILayout.Label(" Sprites", _subTitle); EditorGUI.DrawRect(GUILayoutUtility.GetRect(25, 2), Color.black); GUILayout.Space(6); EditorGUILayout.BeginVertical("BOX"); var sprites = characters[_characterSelected].SpriteForeach(); if (sprites.Any()) { foreach (var sprite in sprites) { EditorGUILayout.BeginHorizontal("BOX"); EditorGUILayout.BeginVertical(); sprite.Item2 = (Sprite)EditorGUILayout.ObjectField(sprite.Item2, typeof(Sprite), true); if (!sprite.Item2) { EditorGUILayout.HelpBox("The sprite can't be null", MessageType.Error); } else if (sprites.Where(x => x != sprite).Any(x => x.Item2 == sprite.Item2)) { EditorGUILayout.HelpBox("The character already contains this sprite", MessageType.Warning); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); sprite.Item1 = EditorGUILayout.TextField("Name:", sprite.Item1); if (!sprite.Item1.Any() || sprite.Item1 == " ") { EditorGUILayout.HelpBox("The name can't be null or a backspace.", MessageType.Error); } else if (sprites.Where(x => x != sprite).Any(x => x.Item1 == sprite.Item1)) { EditorGUILayout.HelpBox("The character already contains this name.", MessageType.Warning); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Unsuscribe")) { characters[_characterSelected].UnsuscribeSprite(sprite); return; } EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.HelpBox("The character don't have sprites.", MessageType.Warning); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Suscribe sprite")) { characters[_characterSelected].SuscribeSprite("", default(Sprite)); } #endregion }