private void DrawMissingDataCreation() { bool missingaudio = Manager.AudioTree == null; bool missingaudioEvent = Manager.EventTree == null; bool missingbus = Manager.BusTree == null; bool missingbankLink = Manager.BankLinkTree == null; bool areAnyMissing = missingaudio | missingaudioEvent | missingbus | missingbankLink; if (areAnyMissing) { string missingAudioInfo = missingaudio ? "Audio Data\n" : ""; string missingEventInfo = missingaudioEvent ? "Event Data\n" : ""; string missingBusInfo = missingbus ? "Bus Data\n" : ""; string missingBankInfo = missingbankLink ? "BankLink Data\n" : ""; EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox(missingAudioInfo + missingEventInfo + missingBusInfo + missingBankInfo + "is missing.", MessageType.Error, true); bool areAllMissing = missingaudio && missingaudioEvent && missingbus && missingbankLink; if (!areAllMissing) { if (GUILayout.Button("Create missing content", GUILayout.Height(30))) { int levelSize = 3; //How many subfolders by default will be created. Number is only a hint for new people if (missingbus) { CreateBusPrefab(); } if (missingaudio) { CreateAudioPrefab(levelSize, Manager.BusTree); } if (missingaudioEvent) { CreateEventPrefab(levelSize); } if (missingbankLink) { CreateBankLinkPrefab(); } Manager.Load(true); if (missingaudio) { NodeWorker.AssignToNodes(Manager.AudioTree, node => node.Bus = Manager.BusTree); } if (Manager.AudioTree != null && Manager.BankLinkTree != null) { NodeWorker.AssignToNodes(Manager.AudioTree, node => node.BankLink = Manager.BankLinkTree.GetChildren[0]); } EditorApplication.SaveCurrentSceneIfUserWantsTo(); } } DrawStartFromScratch(); EditorGUILayout.EndVertical(); } }
private static StatusThreadsThread StatusThreadsThreadFromNodeWorker(NodeWorker worker) { StatusThreadsThread thread = new StatusThreadsThread(); thread.State = worker.StateString; if (worker.State == true) { if (thread.HowLong > 0) { thread.HowLong = worker.HowLong; thread.HowLongSpecified = true; } else { thread.HowLongSpecified = false; } thread.TaskIdSpecified = true; thread.TaskId = worker.TaskId; thread.ProblemInstanceId = worker.ProblemInstanceId; thread.ProblemInstanceIdSpecified = true; thread.ProblemType = worker.ProblemType; } else { thread.TaskIdSpecified = false; thread.HowLongSpecified = false; thread.ProblemInstanceIdSpecified = false; } return(thread); }
protected override void OnDrop(AudioBus node, Object[] objects) { var target = objects[0] as AudioBus; Undo.RegisterUndo(new Object[] { node, target, target.Parent }, "Bus Move"); NodeWorker.ReasignNodeParent(target, node); }
protected override void OnDrop(AudioBankLink node, Object[] objects) { AudioBankLink target = objects[0] as AudioBankLink; //Undo.RegisterUndo(new Object[] { node, target, target.Parent}, "Drag and Drop bank move"); NodeWorker.ReasignNodeParent(target, node); }
public static AudioNode Duplicate(AudioNode audioNode) { return(NodeWorker.DuplicateHierarchy(audioNode, (@oldNode, newNode) => { newNode.NodeData = audioNode.gameObject.AddComponent(newNode.NodeData.GetType()) as NodeTypeData; EditorUtility.CopySerialized(oldNode.NodeData, newNode.NodeData); })); }
protected override void OnDrop(InAudioBus dropOn, Object[] objects) { var beingDragged = objects[0] as InAudioBus; UndoHelper.RecordObject(new Object[] { dropOn, beingDragged, beingDragged.Parent }, "Bus drag n drop"); NodeWorker.ReasignNodeParent(beingDragged, dropOn); }
protected override bool CanDropObjects(AudioBus node, Object[] objects) { if (objects != null && objects.Length > 0 && objects[0] as AudioBus != null) { return(!NodeWorker.IsChildOf(objects[0] as AudioBus, node)); } return(false); }
private void DrawStartFromScratch() { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Start over from scratch", GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("Create new project?", "This will delete ALL data!", "Start from scratch", "Do nothing")) { FolderSettings.DeleteFolderContent(Application.dataPath + FolderSettings.BankDeleteFolder); int levelSize = 3; GameObject go1 = new GameObject(); GameObject go2 = new GameObject(); GameObject go3 = new GameObject(); GameObject go4 = new GameObject(); Manager.BusTree = AudioBusWorker.CreateTree(go3); Manager.BankLinkTree = AudioBankWorker.CreateTree(go4); Manager.AudioTree = AudioNodeWorker.CreateTree(go1, levelSize, Manager.BusTree); Manager.EventTree = AudioEventWorker.CreateTree(go2, levelSize); SaveAndLoad.CreateDataPrefabs(Manager.AudioTree.gameObject, Manager.EventTree.gameObject, Manager.BusTree.gameObject, Manager.BankLinkTree.gameObject); Manager.Load(true); if (Manager.BankLinkTree != null) { var bankLink = AudioBankWorker.CreateBank(Manager.BankLinkTree.gameObject, Manager.BankLinkTree, GUIDCreator.Create()); bankLink.Name = "Default - Auto loaded"; bankLink.AutoLoad = true; var bankLink2 = AudioBankWorker.CreateBank(Manager.BankLinkTree.gameObject, Manager.BankLinkTree, GUIDCreator.Create()); bankLink2.Name = "Extra"; NodeWorker.AssignToNodes(Manager.AudioTree, node => node.BankLink = Manager.BankLinkTree.GetChildren[0]); } else { Debug.LogError("There was a problem creating the data."); } NodeWorker.AssignToNodes(Manager.AudioTree, node => node.Bus = Manager.BusTree); AssetDatabase.Refresh(); EditorApplication.SaveCurrentSceneIfUserWantsTo(); } } }
public static AudioNode CreateNode(GameObject go, AudioNode parent, int guid, AudioNodeType type) { var node = go.AddComponent <AudioNode>(); node.GUID = guid; node.Type = type; node.Bus = parent.Bus; NodeWorker.AssignParent(node, parent); return(node); }
public static AudioEvent Duplicate(AudioEvent audioEvent) { return(NodeWorker.DuplicateHierarchy(audioEvent, (@oldNode, newNode) => { newNode.ActionList.Clear(); for (int i = 0; i < oldNode.ActionList.Count; i++) { newNode.ActionList.Add(NodeWorker.CopyComponent(oldNode.ActionList[i])); } })); }
private static AudioBankLink CreateNode(GameObject go, AudioBankLink parent, int guid) { var node = go.AddComponent <AudioBankLink>(); node.GUID = guid; node.Parent = parent; node.IsFoldedOut = true; node.Name = "Name"; NodeWorker.AssignParent(node, parent); return(node); }
private void LawView_Load(object sender, EventArgs e) { //mh = new Utity.MouseHook(); //mh.SetHook(); //mh.MouseMoveEvent += Mh_MouseMoveEvent; //this.Text += "-"+law.title + " " + law.version; lbl_title.Text = law.title + " " + law.version; lbl_welcome.Text += Global.user.Xm; if (law != null) { //如果在线,且未下载到本地,则从远程获取章节信息,并入库 if (Global.online && "0" == law.isLocal) { List <Node> nodes = RemoteWorker.getBookContent(law.lawId); //获取法规整体章节结构 RemoteWorker.getNodeDetail(nodes.Select(n => n.Id).ToList()); //再获取每个章节的内容 } nodes = db.getNodeByLawId(law.lawId); //绑定关系 tags = NodeWorker.buildRelationFromNode(nodes); bindTagsToDGW(); //绑定树结构 string content = NodeWorker.buildFromNodeContext(NodeTree, nodes); //绑定法规内容 wb.DocumentText = content; SetAutoWrap(true); if (Global.online)// && string.IsNullOrEmpty(law.isLocal)) { //远程获取评论 RemoteWorker.getOpinionList(law.lawId); //加载评论 loadComment(); } //加载文档信息 lawInfo1.law = law; lawInfo1.parentForm = this.parentForm; lawInfo1.fillLawVersion(laws); lawInfo1.fillLawInfo(); lawInfo1.bindState = true; //写入阅读历史 ViewHistory history = new ViewHistory() { Id = law.lawId, LawID = law.lawId, UserID = Global.user.Id, ViewDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; if (db.saveHistory(history)) { ((LibraryList)parentForm).addHistory(history); } } }
public static bool CanDropObjects(AudioEvent audioEvent, Object[] objects) { if (objects.Length == 0 || audioEvent == null) { return(false); } if (audioEvent.Type == EventNodeType.Event) { var audioNodes = GetConvertedList <AudioNode>(objects.ToList()); bool audioNodeDrop = audioNodes.TrueForAll(node => node != null && node.IsPlayable); var audioBankLinks = GetConvertedList <AudioBankLink>(objects.ToList()); bool bankLinkDrop = audioBankLinks.TrueForAll(node => node != null && node.Type == AudioBankTypes.Link); var busNodes = GetConvertedList <AudioBus>(objects.ToList()); bool audioBusDrop = busNodes.TrueForAll(node => node != null); return(audioNodeDrop | bankLinkDrop | audioBusDrop); } else if (audioEvent.Type == EventNodeType.Folder || audioEvent.Type == EventNodeType.Root) { var draggingEvent = objects[0] as AudioEvent; if (draggingEvent == null) { return(false); } if (draggingEvent.Type == EventNodeType.Event) { return(true); } if ((draggingEvent.Type == EventNodeType.Folder && !NodeWorker.IsChildOf(draggingEvent, audioEvent)) || draggingEvent.Type == EventNodeType.EventGroup) { return(true); } } else if (audioEvent.Type == EventNodeType.EventGroup) { var draggingEvent = objects[0] as AudioEvent; if (draggingEvent == null) { return(false); } if (draggingEvent.Type == EventNodeType.Event) { return(true); } } return(false); }
protected override bool CanDropObjects(AudioBankLink node, Object[] objects) { if (node == null || objects == null) { return(false); } if (objects.Length > 0 && objects[0] as AudioBankLink != null && node.Type != AudioBankTypes.Link) { return(!NodeWorker.IsChildOf(objects[0] as AudioBankLink, node)); } return(false); }
protected override void OnDrop(AudioNode node, UnityEngine.Object[] objects) { if (objects[0] as AudioNode != null) //Drag N Drop internally in the tree, change the parent { node.IsFoldedOut = true; var nodeToMove = objects[0] as AudioNode; var oldBank = AudioBankWorker.GetParentBank(nodeToMove); AudioBankLink newBank = null; if (nodeToMove.OverrideParentBank) { newBank = AudioBankWorker.GetParentBank(nodeToMove); } else { newBank = AudioBankWorker.GetParentBank(node); } Undo.RegisterUndo(new UnityEngine.Object[] { node, nodeToMove, nodeToMove.Parent, oldBank, newBank }, "Audio Node Move"); NodeWorker.ReasignNodeParent(nodeToMove, node); AudioBankWorker.MoveNode(nodeToMove, oldBank); } else if (node.Type != AudioNodeType.Audio) //Create new audio nodes when we drop clips { for (int i = 0; i < objects.Length; ++i) { var clip = objects[i] as AudioClip; var child = AudioNodeWorker.CreateChild(node, AudioNodeType.Audio); var path = AssetDatabase.GetAssetPath(clip); try { //Try and get the name of the clip. Gets the name and removes the end. Assets/IntroSound.mp3 -> IntroSound int lastIndex = path.LastIndexOf('/') + 1; child.Name = path.Substring(lastIndex, path.LastIndexOf('.') - lastIndex); } catch (Exception) //If it happens to be a mutant path. Not even sure if this is possible, but better safe than sorry { child.Name = node.Name + " Child"; } (child.NodeData as AudioData).EditorClip = clip; AudioBankWorker.AddNodeToBank(child, clip); Event.current.Use(); } } else //Then it must be an audio clip dropped on an audio node, so assign the clip to that node { var bank = AudioBankWorker.GetParentBank(node); Undo.RegisterUndo(new UnityEngine.Object[] { node, bank.LazyBankFetch, node.NodeData }, "Undo Changing Node In Bank"); (node.NodeData as AudioData).EditorClip = objects[0] as AudioClip; AudioBankWorker.SwapClipInBank(node, objects[0] as AudioClip); } }
public static void DeleteBus(AudioBus bus, AudioNode root) { HashSet <AudioBus> toDelete = new HashSet <AudioBus>(); GetBussesToDelete(toDelete, bus); List <AudioNode> affectedNodes = new List <AudioNode>(); NodeWorker.FindAllNodes(root, node => toDelete.Contains(node.Bus), affectedNodes); for (int i = 0; i < affectedNodes.Count; ++i) { affectedNodes[i].Bus = bus.Parent; } ActualDelete(bus); }
protected override bool CanDropObjects(AudioNode node, UnityEngine.Object[] objects) { if (node == null || objects == null) { return(false); } if (node.Type == AudioNodeType.Voice) { return(false); } int clipCount = DragAndDrop.objectReferences.Count(p => p is AudioClip); int nodeCount = DragAndDrop.objectReferences.Count(p => p is AudioNode); if (DragAndDrop.objectReferences.Length == 0) { return(false); } if (clipCount == objects.Length) //Handle clip count { if (node.Type == AudioNodeType.Audio && clipCount != 1) { return(false); } return(true); } else if (nodeCount == objects.Length) //Handle audio node drag n drop { if (node.Type == AudioNodeType.Audio) //Can't drop on an audionode as it can't have children { return(false); } if (node == objects[0] as AudioNode) { return(false); } return(!NodeWorker.IsChildOf(objects[0] as AudioNode, node)); } return(false); }
public static void AddNewParent(AudioNode node, AudioNodeType parentType) { var newParent = CreateNode(node.gameObject, node.Parent, parentType); var oldParent = node.Parent; newParent.Bus = node.Bus; newParent.FoldedOut = true; newParent.BankLink = AudioBankWorker.GetParentBank(oldParent); int index = oldParent.Children.FindIndex(node); NodeWorker.RemoveFromParent(node); NodeWorker.AssignParent(node, newParent); OnRandomNode(newParent); NodeWorker.RemoveFromParent(newParent); oldParent.Children.Insert(index, newParent); }
protected override string ReceivedSolvePartialProblems(SolvePartialProblems solvePartialProblems) { ///// Hey here is the problem to solve! (undivided, everything is in CommonData) string problem = Utilities.Base64Decode(solvePartialProblems.CommonData); globalProblem = problem; //solvePartialProblems.Id; NodeWorker worker = new NodeWorker(solvePartialProblems.Id); worker.problemObject = ProblemLoader.loadnewExampleString(globalProblem); Workers.Add(worker); double sol = worker.calculateAlgorithm(); Solutions solutions = new Solutions(); solutions.Id = solvePartialProblems.Id; solutions.CommonData = Utilities.Base64Encode(sol.ToString()); Console.WriteLine("How Long = " + this.Workers.First().HowLong); CMSocket.Instance.SendMessage(this.Port, this.IP, solutions.SerializeToXML(), this); return(null); }
public static void OnDrop(AudioEvent audioevent, Object[] objects) { if (objects.Length == 1) { if (objects[0] as AudioEvent) { var movingEvent = objects[0] as AudioEvent; Undo.RegisterUndo(new Object[] { audioevent, movingEvent, movingEvent.Parent }, "Event Move"); NodeWorker.ReasignNodeParent((AudioEvent)objects[0], audioevent); audioevent.IsFoldedOut = true; } var audioNode = objects[0] as AudioNode; if (audioNode != null && audioNode.IsPlayable) { var action = AddEventAction <EventAudioAction>(audioevent, EventActionTypes.Play); action.Node = audioNode; } var audioBank = objects[0] as AudioBankLink; if (audioBank != null) { var action = AddEventAction <EventBankAction>(audioevent, EventActionTypes.LoadBank); action.BankLink = audioBank; } var audioBus = objects[0] as AudioBus; if (audioBus != null) { var action = AddEventAction <EventBusAction>(audioevent, EventActionTypes.SetBusVolume); action.Bus = audioBus; } Event.current.Use(); } }
public static bool Draw <T>(T node, bool isSelected) where T : Object, InITreeNode <T> { if (noMargain == null) { noMargain = new GUIStyle(); noMargain.margin = new RectOffset(0, 0, 0, 0); } Rect area = EditorGUILayout.BeginHorizontal(); if (isSelected) { GUI.DrawTexture(area, EditorResources.Background); } GUILayout.Space(EditorGUI.indentLevel * 16); bool folded = node.IsFoldedOut; Texture picture; if (folded || node.GetChildren.Count == 0) { picture = EditorResources.Minus; } else { picture = EditorResources.Plus; } GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height), GUILayout.Width(EditorResources.Minus.width)); Rect foldRect = GUILayoutUtility.GetLastRect(); if (Event.current.ClickedWithin(foldRect)) { folded = !folded; Event.current.Use(); } Texture icon = TreeNodeDrawerHelper.LookUpIcon(node); TreeNodeDrawerHelper.DrawIcon(GUILayoutUtility.GetLastRect(), icon, noMargain); EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect labelArea = GUILayoutUtility.GetLastRect(); Rect buttonArea = labelArea; if (!node.IsRoot) { buttonArea.x = buttonArea.x + 56 + EditorGUI.indentLevel * 16; buttonArea.width = 20; buttonArea.height = 14; GUI.Label(buttonArea, EditorResources.Up, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneUp(node); Event.current.Use(); } buttonArea.y += 15; GUI.Label(buttonArea, EditorResources.Down, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneDown(node); Event.current.Use(); } labelArea.x += 20; } labelArea.y += 6; labelArea.x += 65; EditorGUI.LabelField(labelArea, node.GetName); return(folded); }
public static bool EventFoldout(InAudioEventNode node, bool isSelected) { if (noMargain == null) { noMargain = new GUIStyle(); noMargain.margin = new RectOffset(0, 0, 0, 0); } Rect area = EditorGUILayout.BeginHorizontal(); if (isSelected) { GUI.DrawTexture(area, EditorResources.Background); } if (node.Type != EventNodeType.Event) { GUILayout.Space(EditorGUI.indentLevel * 16); } else { GUILayout.Space(EditorGUI.indentLevel * 24); } bool folded = node.IsFoldedOut; if (node.Type != EventNodeType.Event) { Texture picture; if (folded || node.Children.Count == 0) { picture = EditorResources.Minus; } else { picture = EditorResources.Plus; } GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height), GUILayout.Width(EditorResources.Minus.width)); Rect foldRect = GUILayoutUtility.GetLastRect(); if (Event.current.ClickedWithin(foldRect)) { folded = !folded; Event.current.Use(); } TreeNodeDrawerHelper.DrawIcon(GUILayoutUtility.GetLastRect(), EditorResources.Folder, noMargain); } GUILayout.Space(30); EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect labelArea = GUILayoutUtility.GetLastRect(); Rect buttonArea = GUILayoutUtility.GetLastRect(); if (!node.IsRoot) { buttonArea.x = buttonArea.x + 56 + EditorGUI.indentLevel * 16; buttonArea.width = 20; buttonArea.height = 14; if (node.Type != EventNodeType.Event) { GUI.Label(buttonArea, EditorResources.Up, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneUp(node); Event.current.Use(); } buttonArea.y += 15; GUI.Label(buttonArea, EditorResources.Down, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneDown(node); Event.current.Use(); } } else { buttonArea.x -= 10; GUI.Label(buttonArea, EditorResources.Up, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneUp(node); Event.current.Use(); } buttonArea.x += 15; GUI.Label(buttonArea, EditorResources.Down, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneDown(node); Event.current.Use(); } } labelArea.x += 25; } if (node.Type != EventNodeType.Event)//As Events are smaller { labelArea.y += 6; } labelArea.x += 65; EditorGUI.LabelField(labelArea, node.Name); return(folded); }
public static bool Draw(InAudioBus node, bool isSelected) { if (noMargain == null) { noMargain = new GUIStyle(); noMargain.margin = new RectOffset(0, 0, 0, 0); } Rect area = EditorGUILayout.BeginHorizontal(); if (isSelected) { GUI.DrawTexture(area, EditorResources.Background); } GUILayout.Space(EditorGUI.indentLevel * 16); bool folded = node.FoldedOut; Texture picture; if (folded || node.Children.Count == 0) { picture = EditorResources.Minus; } else { picture = EditorResources.Plus; } GUILayout.Label(picture, noMargain, GUILayout.Height(EditorResources.Minus.height), GUILayout.Width(EditorResources.Minus.width)); Rect foldRect = GUILayoutUtility.GetLastRect(); if (Event.current.ClickedWithin(foldRect)) { folded = !folded; Event.current.Use(); } EditorGUILayout.EndHorizontal(); Rect labelArea = GUILayoutUtility.GetLastRect(); Rect buttonArea = labelArea; Rect sliderArea = buttonArea; buttonArea.x = buttonArea.x + 45 + EditorGUI.indentLevel * 16; if (!node.IsRoot) { //buttonArea.x = buttonArea.x + 45 + EditorGUI.indentLevel * 16; buttonArea.width = 20; buttonArea.height = 14; GUI.Label(buttonArea, EditorResources.Up, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneUp(node); Event.current.Use(); } buttonArea.y += 15; GUI.Label(buttonArea, EditorResources.Down, noMargain); if (Event.current.ClickedWithin(buttonArea)) { NodeWorker.MoveNodeOneDown(node); Event.current.Use(); } labelArea.x += 25; } else { buttonArea.y += 15; } buttonArea.height = 36; buttonArea.width = 36; buttonArea.y -= 18; buttonArea.x -= 26; GUI.Label(buttonArea, EditorResources.Bus, noMargain); labelArea.y += 6; labelArea.x += 50; EditorGUI.LabelField(labelArea, node.Name); GUI.enabled = false; sliderArea.y += 6; sliderArea.x = labelArea.x + 100; sliderArea.height = 16; sliderArea.width = 180; if (!Application.isPlaying) { float parentVolume = 1.0f; if (node.Parent != null) { parentVolume = node.Parent.CombinedVolume; if (node.Parent.Mute) { parentVolume = 0; } } node.CombinedVolume = node.Volume * node.SelfVolume * parentVolume; float volume = node.CombinedVolume; if (node.Mute) { volume = 0; } EditorGUI.Slider(sliderArea, volume, 0.0f, 1.0f); } else { EditorGUI.Slider(sliderArea, node.FinalVolume, 0.0f, 1.0f); } GUI.enabled = true; return(folded); }