public override void OnGUIScrollView() { if (Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.UpArrow && Event.current.type == EventType.KeyUp) { MoveDown(); } if (Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.DownArrow && Event.current.type == EventType.KeyUp) { MoveUp(); } if (AllowNode) { if ( GUIHelpers.DoTriggerButton(new UFStyle() { Label = "[NONE]", IsWindow = true, FullWidth = true, BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall })) { SelectedAction(null); IsClosing = true; } } if (ItemGroups == null) { return; } var index = 0; //var isFirst = true; foreach (var group in ItemGroups) { if (group.Any()) { if (string.IsNullOrEmpty(_SearchText)) { if (GUIHelpers.DoToolbarEx(group.Key)) { foreach (var item in group) { var item1 = item; if (item == null) { continue; } if ( GUIHelpers.DoTriggerButton(new UFStyle() { Label = item.Title, IsWindow = true, FullWidth = true, BackgroundStyle = index == HighlightedIndex ? ElementDesignerStyles.Item1 : ElementDesignerStyles.EventButtonStyleSmall })) { SelectedAction(item1); IsClosing = true; } if (index == HighlightedIndex && Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return) { SelectedAction(item1); } //isFirst = false; index++; } } } else { foreach (var item in group) { if (item == null) { continue; } var item1 = item; if (GUIHelpers.DoTriggerButton(new UFStyle() { Label = item.Group + " : " + item.Title, IsWindow = true, FullWidth = true, BackgroundStyle = index == HighlightedIndex ? ElementDesignerStyles.Item1 : ElementDesignerStyles.EventButtonStyleSmall })) { SelectedAction(item1); IsClosing = true; } if (index == HighlightedIndex && Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return) { SelectedAction(item1); IsClosing = true; } //isFirst = false; index++; } } } } }
private void DrawPlayModeGui() { if (EditorApplication.isPlaying) { var t = target as ViewBase; if (t != null && t.ViewModelObject != null) { if (GUIHelpers.DoToolbarEx("View Model Properties")) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Id", t.ViewModelObject.Identifier); EditorGUILayout.LabelField("# References", t.ViewModelObject.References.ToString()); DoViewModelGUI(t.ViewModelObject); } if (Commands != null) { if (GUIHelpers.DoToolbarEx("Commands")) { foreach (var command in Commands) { var type = command.ParameterType; if (type != null && type != typeof(void)) { // TODO REWRITE PARAMETERS //if (!(command.Command is IParameterCommand)) continue; //EditorGUI.BeginChangeCheck(); //object newValue = null; //object currentValue = ((IParameterCommand)command.Command).Parameter ?? GetDefaultValue(type);//Activator.CreateInstance(type); //var propertyName = "Parameter"; //var isEnum = false; //newValue = DoTypeInspector(type, propertyName, currentValue, isEnum); //if (EditorGUI.EndChangeCheck()) //{ // ((IParameterCommand) command.Command).Parameter = newValue; //} } if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), command.Name, ElementDesignerStyles.ButtonStyle)) { command.Signal.Publish(); } } //foreach (var command in Commands) //{ // if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), command.Key, // ElementDesignerStyles.ButtonStyle)) // { // var commandWith = command.Value as ICommandWith<object>; // Target.ExecuteCommand(command.Value); // } //} } } //if (t.ViewModelObject != null) //{ // foreach (var item in t.ViewModelObject.Bindings) // { // if (GUIHelpers.DoToolbarEx(item.Key == -1 // ? "Controller" // : EditorUtility.InstanceIDToObject(item.Key).name)) // { // foreach (var binding in item.Value) // { // if (GUIHelpers.DoTriggerButton(new UFStyle() // { // Label = binding.GetType().Name + ": " + binding.ModelMemberName, // //IconStyle = bi // })) // { // } // } // } // } //} } else { EditorGUILayout.HelpBox("View Model not initialized yet.", MessageType.Info); Repaint(); } } Repaint(); return; }
public void OnGUI() { if (m_EditableParametersForEachListItem == null || m_EditableParametersForEachListItem.Length == 0) { using (new EditorGUI.DisabledScope(true)) { EditorGUI.indentLevel++; EditorGUILayout.LabelField($"No {m_ItemName}s have been added."); EditorGUI.indentLevel--; } } else { for (var i = 0; i < m_EditableParametersForEachListItem.Length; i++) { var editableParams = m_EditableParametersForEachListItem[i]; EditorGUILayout.BeginHorizontal(); if (editableParams.hasUIToShow) { editableParams.visible = EditorGUILayout.Foldout(editableParams.visible, editableParams.name, true, Styles.s_FoldoutStyle); } else { GUILayout.Space(16); EditorGUILayout.LabelField(editableParams.name, EditorStyles.boldLabel); } GUILayout.FlexibleSpace(); using (new EditorGUI.DisabledScope(i == 0)) { if (GUILayout.Button(m_UpButton, Styles.s_UpDownButtonStyle)) { SwapEntry(i, i - 1); } } using (new EditorGUI.DisabledScope(i == m_EditableParametersForEachListItem.Length - 1)) { if (GUILayout.Button(m_DownButton, Styles.s_UpDownButtonStyle)) { SwapEntry(i, i + 1); } } if (GUILayout.Button(m_DeleteButton, EditorStyles.label)) { // Unfocus controls, because otherwise, the editor can get confused and have text from a text field // on the deleted item leak to a different field. GUI.FocusControl(null); ArrayHelpers.EraseAt(ref m_ParametersForEachListItem, i); ArrayHelpers.EraseAt(ref m_EditableParametersForEachListItem, i); m_Apply(); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); if (editableParams.visible) { EditorGUI.indentLevel++; editableParams.OnGUI(); EditorGUI.indentLevel--; } GUIHelpers.DrawLineSeparator(); } } }
public ROMHandler(string fn) { #if !DEBUG try #endif { reload: DMATableAddress = FileNameTableAddress = SceneTableAddress = -1; Filename = fn; /* Initialize segment and rendering systems */ SegmentMapping = new Hashtable(); Renderer = new F3DEX2Interpreter(this); /* Read ROM */ System.IO.BinaryReader br = new System.IO.BinaryReader(System.IO.File.Open(fn, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)); if (br.BaseStream.Length < MinROMSize) { throw new ROMHandlerException(string.Format("File size is less than {0}MB; ROM appears to be invalid.", (MinROMSize / 0x100000))); } Data = new byte[br.BaseStream.Length]; br.Read(Data, 0, (int)br.BaseStream.Length); br.Close(); /* Detect byte order */ DetectByteOrder(); if (DetectedByteOrder != ByteOrder.BigEndian) { if (MessageBox.Show("The ROM file you have selected uses an incompatible byte order, and needs to be converted to Big Endian format to be used." + Environment.NewLine + Environment.NewLine + "Convert the ROM now? (You will be asked for the target filename; the converted ROM will also be reloaded.)", "Byte Order Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { /* Ask for new filename */ string fnnew = GUIHelpers.ShowSaveFileDialog("Nintendo 64 ROMs (*.z64;*.bin)|*.z64;*.bin|All Files (*.*)|*.*"); if (fnnew != string.Empty) { fn = fnnew; /* Perform byte order conversion */ byte[] datanew = new byte[Data.Length]; byte[] conv = null; for (int i = 0, j = 0; i < Data.Length; i += 4, j += 4) { if (DetectedByteOrder == ByteOrder.MiddleEndian) { conv = new byte[4] { Data[i + 1], Data[i], Data[i + 3], Data[i + 2] } } ; else if (DetectedByteOrder == ByteOrder.LittleEndian) { conv = new byte[4] { Data[i + 3], Data[i + 2], Data[i + 1], Data[i] } } ; Buffer.BlockCopy(conv, 0, datanew, j, conv.Length); } /* Save converted ROM, then reload it */ System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.Create(fn)); bw.Write(datanew); bw.Close(); goto reload; } } else { /* Wrong byte order, no conversion performed */ throw new ByteOrderException(string.Format("Incompatible byte order {0} detected; ROM cannot be used.", DetectedByteOrder)); } } else { /* Read header */ ReadROMHeader(); /* Create XML actor definition reader */ XMLActorDefReader = new XMLActorDefinitionReader(System.IO.Path.Combine("XML", "ActorDefinitions", GameID.Substring(1, 2))); if (XMLActorDefReader.Definitions.Count > 0) { /* Create remaining XML-related objects */ XMLActorNames = new XMLHashTableReader(System.IO.Path.Combine("XML", "GameDataGeneric", GameID.Substring(1, 2)), "ActorNames.xml"); XMLObjectNames = new XMLHashTableReader(System.IO.Path.Combine("XML", "GameDataGeneric", GameID.Substring(1, 2)), "ObjectNames.xml"); XMLSongNames = new XMLHashTableReader(System.IO.Path.Combine("XML", "GameDataGeneric", GameID.Substring(1, 2)), "SongNames.xml"); XMLSceneNames = new XMLHashTableReader(System.IO.Path.Combine("XML", "GameDataSpecific", string.Format("{0}{1:X1}", GameID, Version)), "SceneNames.xml"); XMLRoomNames = new XMLHashTableReader(System.IO.Path.Combine("XML", "GameDataSpecific", string.Format("{0}{1:X1}", GameID, Version)), "RoomNames.xml"); XMLStageDescriptions = new XMLHashTableReader(System.IO.Path.Combine("XML", "GameDataSpecific", string.Format("{0}{1:X1}", GameID, Version)), "StageDescriptions.xml"); /* Determine if ROM uses z64tables hack */ HasZ64TablesHack = (Version == 15 && Endian.SwapUInt32(BitConverter.ToUInt32(Data, 0x1238)) != 0x0C00084C); /* Find and read build information, DMA table, etc. */ FindBuildInfo(); FindFileNameTable(); ReadDMATable(); ReadFileNameTable(); /* Try to identify files */ foreach (DMATableEntry dte in Files) { dte.Identify(this); } /* Find the code file */ FindCodeFile(); /* Find other Zelda-specific stuff */ FindActorTable(); FindObjectTable(); FindSceneTable(); ReadEntranceTable(); /* Some sanity checking & exception handling*/ if (Scenes == null || Scenes.Count == 0) { throw new ROMHandlerException("No valid scenes could be recognized in the ROM."); } /* Done */ Loaded = true; } } } #if !DEBUG catch (Exception ex) { Loaded = false; if (MessageBox.Show(ex.Message + "\n\n" + "Show detailed information?", "Exception", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { MessageBox.Show(ex.ToString(), "Exception Details", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } #endif }
public void DrawInspector(Object target) { GUIHelpers.IsInspector = true; var entityComponent = target as Entity; if (entityComponent != null) { //if (Repository != null) //{ // EditorGUILayout.HelpBox("0 = Auto Assign At Runtime", MessageType.Info); //} //if (GUILayout.Button("Create New Component")) //{ // if (TreeModel == null) // { // TreeModel = new TreeViewModel() // { // Data = Container.Resolve<IRepository>().AllOf<ModuleNode>().Select(item=>new SelectionMenuItem(item, // () => // { // })).Cast<IItem>().ToList() // }; // } // else // { // TreeModel = null; // } //} //if (TreeModel != null) //{ // var lastRect = GUILayoutUtility.GetLastRect(); // var rect = GUILayoutUtility.GetRect(lastRect.x, lastRect.y, 300, 500); // Signal<IDrawTreeView>(_=>_.DrawTreeView(rect,TreeModel,(p,x)=>{ // var item = (x as SelectionMenuItem).DataObject as IDiagramNode; // Execute(new NavigateToNodeCommand() // { // Node = item as IDiagramNode // }); // Execute(new CreateNodeCommand() // { // NodeType = typeof(ComponentNode), // GraphData = InvertGraphEditor.CurrentDiagramViewModel.GraphData, // }); // TreeModel = null; // })); //} } var component = target as EcsComponent; //if (component != null) //{ if (Repository != null) { var attribute = target.GetType().GetCustomAttributes(typeof(uFrameIdentifier), true).OfType <uFrameIdentifier>().FirstOrDefault(); if (attribute != null) { var item = Repository.GetSingle <ComponentNode>(attribute.Identifier); if (component != null) { //var inspectorBounds = new Rect(0, 0, Screen.width, Screen.height); //var iconBounds = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(inspectorBounds); //Drawer.DrawImage(iconBounds,"CommandIcon",true); //if (GUIHelpers.DoToolbarEx("System Handlers")) //{ // foreach ( // var handlerNode in // Repository.All<HandlerNode>() // .Where(p => p.EntityGroup != null && p.EntityGroup.Item == item)) // { // if (GUILayout.Button(handlerNode.Name)) // { // Execute(new NavigateToNodeCommand() // { // Node = handlerNode, // Select = true // }); // } // } //} if (GUIHelpers.DoToolbarEx("uFrame Designer")) { var toolbarButton = ComponentEditorToolbarButtonStyle; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Serving Handlers:"); EditorGUILayout.EndHorizontal(); foreach ( var handlerNode in Repository.All <HandlerNode>() .Where(p => p.HandlerInputs.Any(x => x.Item != null && x.Item.SelectComponents.Contains(item)))) { EditorGUILayout.BeginHorizontal(); var text = handlerNode.Name; if (GUILayout.Button(text, toolbarButton)) { Execute(new NavigateToNodeCommand() { Node = handlerNode, Select = true }); } var descRect = GUILayoutUtility.GetLastRect(); //GUILayout.FlexibleSpace(); var meta = handlerNode.Meta as EventMetaInfo; if (meta != null && meta.Dispatcher && component.gameObject.GetComponent(meta.SystemType) == null) { Drawer.DrawImage(new Rect().WithSize(16, 16).InnerAlignWithCenterLeft(descRect).Translate(4, 0), "RedDotIcon", true); var cb = GUI.backgroundColor; GUI.backgroundColor = CachedStyles.GetColor(NodeColor.Carrot); //if (GUILayout.Button("+ " + meta.SystemType.Name,EditorStyles.toolbarButton)) if (GUILayout.Button(new GUIContent("Add", string.Format("Add {0} which is used to invoke the corresponding event", meta.SystemType.Name)), EditorStyles.toolbarButton, GUILayout.Width(60))) { component.gameObject.AddComponent(meta.SystemType); } GUI.backgroundColor = cb; } else { Drawer.DrawImage(new Rect().WithSize(16, 16).InnerAlignWithCenterLeft(descRect).Translate(4, 0), "GreenDotIcon", true); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.Label(""); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); var cachedBackgroundColor = GUI.backgroundColor; GUI.backgroundColor = CachedStyles.GetColor(NodeColor.SgiTeal); if (GUILayout.Button("Edit In Designer", EditorStyles.toolbarButton)) { Execute(new NavigateToNodeCommand() { Node = item, Select = true }); } GUI.backgroundColor = cachedBackgroundColor; EditorGUILayout.EndHorizontal(); } } } } //} }
public static void uFrameSettings() { ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition); var s = InvertGraphEditor.Settings; if (s != null) { if (GUIHelpers.DoToolbarEx("Color Settings")) { s.BackgroundColor = EditorGUILayout.ColorField("Background Color", s.BackgroundColor); EditorGUI.BeginChangeCheck(); s.TabTextColor = EditorGUILayout.ColorField("Tab Text Color", s.TabTextColor); s.SectionItemColor = EditorGUILayout.ColorField("Item Text Color", s.SectionItemColor); //s.SectionItemTypeColor = EditorGUILayout.ColorField("Item Type Text Color", s.SectionItemTypeColor); s.SectionTitleColor = EditorGUILayout.ColorField("Section Title Color", s.SectionTitleColor); if (EditorGUI.EndChangeCheck()) { ElementDesignerStyles.TabStyle = null; ElementDesignerStyles.ItemTextEditingStyle = null; ElementDesignerStyles.HeaderStyle = null; ElementDesignerStyles.GraphTitleLabel = null; } s.UseGrid = EditorGUILayout.BeginToggleGroup("Grid", s.UseGrid); s.GridLinesColor = EditorGUILayout.ColorField("Grid Lines Color", s.GridLinesColor); s.GridLinesColorSecondary = EditorGUILayout.ColorField("Grid Lines Secondary Color", s.GridLinesColorSecondary); EditorGUILayout.EndToggleGroup(); //s.AssociationLinkColor = EditorGUILayout.ColorField("Association Link Color", s.AssociationLinkColor); //s.DefinitionLinkColor = EditorGUILayout.ColorField("Definition Link Color", s.DefinitionLinkColor); //s.InheritanceLinkColor = EditorGUILayout.ColorField("Inheritance Link Color", s.InheritanceLinkColor); //s.SubSystemLinkColor = EditorGUILayout.ColorField("SubSystem Link Color", s.SubSystemLinkColor); //s.TransitionLinkColor = EditorGUILayout.ColorField("Transition Link Color", s.TransitionLinkColor); //s.ViewLinkColor = EditorGUILayout.ColorField("View Link Color", s.ViewLinkColor); } } else { EditorGUILayout.HelpBox("Settings not available.", MessageType.Info); } //if (GUIHelpers.DoToolbarEx("Plugins - Enabled")) //{ foreach ( var plugin in InvertApplication.Plugins.Where(p => !p.Required && !p.Ignore).OrderBy(p => p.Title)) // { // var totalLoadTime = (plugin.InitializeTime); //EditorGUILayout.LabelField("Initializing Time", string.Format("{0} Seconds {1} Milliseconds" ,totalLoadTime.Seconds,totalLoadTime.Milliseconds)); //EditorGUILayout.LabelField("Load Time", string.Format("{0} Seconds {1} Milliseconds" ,plugin.LoadTime.Seconds,plugin.LoadTime.Milliseconds)); DoPlugin(plugin); } //} //if (GUIHelpers.DoToolbarEx("Plugins - Disabled")) //{ // foreach ( // var plugin in InvertApplication.Plugins.Where(p => !p.Required && !p.Enabled).OrderBy(p => p.LoadPriority)) // { // DoPlugin(plugin); // } //} //if (GUIHelpers.DoToolbarEx("Registered Nodes")) //{ // foreach (var plugin in InvertGraphEditor.Container.ResolveAll<NodeConfigBase>()) // { // GUIHelpers.DoTriggerButton(new UFStyle(plugin.Name + " : " + plugin.NodeType.Name, // ElementDesignerStyles.EventButtonStyleSmall) // { // IsWindow = true, // FullWidth = true // }); // } //} //if (GUIHelpers.DoToolbarEx("Loaded Assemblies")) //{ // foreach (var plugin in InvertApplication.CachedAssemblies) // { // GUIHelpers.DoTriggerButton(new UFStyle(plugin.FullName, ElementDesignerStyles.EventButtonStyleSmall) // { // IsWindow = true, // FullWidth = true // }); // } //} EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { GUIHelpers.IsInsepctor = true; //base.OnInspectorGUI(); DrawTitleBar("UFrame MVVM Kernel"); serializedObject.Update(); if (!UnityEditor.EditorBuildSettings.scenes.Any(s => { return(s.path.EndsWith("KernelScene.unity")); })) { Warning("Please add this scene to the build settings!"); } if (Application.isPlaying) { if (!uFrameKernel.IsKernelLoaded) { Warning("Kernel is not loaded!"); } if (uFrameKernel.Instance == null) { return; } if (GUIHelpers.DoToolbarEx("Services")) { foreach (var instance in uFrameKernel.Instance.Services) { if (GUIHelpers.DoTriggerButton(new UFStyle() { BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall, Label = string.Format("{0}", instance.GetType().Name) })) { Selection.activeGameObject = (instance as MonoBehaviour).gameObject; } } } if (GUIHelpers.DoToolbarEx("Systems")) { foreach (var instance in uFrameKernel.Instance.SystemLoaders) { if (GUIHelpers.DoTriggerButton(new UFStyle() { BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall, Label = string.Format("{0}", instance.GetType().Name.Replace("Loader", "")) })) { Selection.activeGameObject = (instance as MonoBehaviour).gameObject; } } } if (GUIHelpers.DoToolbarEx("Scene Loaders")) { if (GUIHelpers.DoTriggerButton(new UFStyle() { BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall, Label = string.Format("{0}", "DefaultSceneLoader") })) { } //foreach (var instance in uFrameMVVMKernel.Instance.SceneLoaders) //{ // if (GUIHelpers.DoTriggerButton(new UFStyle() // { // BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall, // Label = string.Format("{0}", instance.GetType().Name) // })) // { // Selection.activeGameObject = (instance as MonoBehaviour).gameObject; // } //} } if (GUIHelpers.DoToolbarEx("Dependency Container - Instances", defOn: false)) { foreach (var instance in uFrameKernel.Container.Instances) { if (GUIHelpers.DoTriggerButton(new UFStyle() { Label = string.Format("'{0}': {1}->{2}", instance.Key.Item1, instance.Key.Item2, instance.Value.GetType().Name), BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall })) { Debug.Log(instance.Value); } } } if (GUIHelpers.DoToolbarEx("Dependency Container - Mappings", defOn: false)) { foreach (var instance in uFrameKernel.Container.Mappings) { if (GUIHelpers.DoTriggerButton(new UFStyle() { BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall, Label = string.Format("{0}: {1}->{2}", instance.Key.Item2, instance.Key.Item1.Name, instance.Value.Name) })) { } } } } else { } if (serializedObject.ApplyModifiedProperties()) { //var t = Target as GameManager; //t.ApplyRenderSettings(); } GUIHelpers.IsInsepctor = false; }
public override void OnInspectorGUI() { GUIHelpers.IsInsepctor = true; DrawTitleBar("Scene Manager"); base.OnInspectorGUI(); if (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode) { //if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), "Serialize To String", ElementDesignerStyles.ButtonStyle)) //{ // var sm = (target as SceneManager); // sm.SaveState(new TextAssetStorage() { AssetPath = "Assets/TestData.txt" }, new JsonStream() { UseReferences = true }); //} //if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), "Load From String", ElementDesignerStyles.ButtonStyle)) //{ // var sm = (target as SceneManager); // sm.LoadState(new TextAssetStorage() { AssetPath = "Assets/TestData.txt" }, new JsonStream() { UseReferences = true }); //} if (GUIHelpers.DoToolbarEx("Persistable Views")) { foreach (var viewBase in GameManager.ActiveSceneManager.PersistantViews) { if (viewBase == null) { continue; } if (GUIHelpers.DoTriggerButton(new UFStyle(viewBase.Identifier + ": " + viewBase.name, UBStyles.EventButtonStyleSmall, null, null, null, false, TextAnchor.MiddleCenter) { })) { //var fileStorage = new TextAssetStorage(); var stringStorage = new StringSerializerStorage(); var stream = new JsonStream(); viewBase.Write(stream); stringStorage.Save(stream); Debug.Log(stringStorage); } } } if (GUIHelpers.DoToolbarEx("Persistable View-Models")) { foreach (var viewBase in GameManager.ActiveSceneManager.PersistantViewModels) { if (viewBase == null) { continue; } if (GUIHelpers.DoTriggerButton(new UFStyle(viewBase.Identifier + ": " + viewBase.GetType().Name, UBStyles.EventButtonStyleSmall, null, null, null, false, TextAnchor.MiddleCenter) { })) { //var fileStorage = new TextAssetStorage(); var stringStorage = new StringSerializerStorage(); var stream = new JsonStream(); viewBase.Write(stream); stringStorage.Save(stream); Debug.Log(stringStorage); } } } } GUIHelpers.IsInsepctor = false; }
public override void OnInspectorGUI() { GUIHelpers.IsInsepctor = true; //base.OnInspectorGUI(); DrawTitleBar("Game Manager"); serializedObject.Update(); if (Application.isPlaying) { if (GUIHelpers.DoToolbarEx("Dependency Container - Instances")) { foreach (var instance in GameManager.Container.Instances) { if (GUIHelpers.DoTriggerButton(new UFStyle() { Label = string.Format("'{0}': {1}->{2}", instance.Key.Item1, instance.Key.Item2, instance.Value.GetType().Name), BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall })) { Debug.Log(instance.Value); } } } if (GUIHelpers.DoToolbarEx("Dependency Container - Mappings")) { foreach (var instance in GameManager.Container.Mappings) { if (GUIHelpers.DoTriggerButton(new UFStyle() { BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall, Label = string.Format("{0}: {1}->{2}", instance.Key.Item2, instance.Key.Item1.Name, instance.Value.Name) })) { } } } } else { EditorGUILayout.HelpBox("The View to load when the scene starts.", MessageType.None); var p = serializedObject.FindProperty("_Start"); if (p.objectReferenceValue == null) { EditorGUILayout.HelpBox("Error start scene manager is not set.", MessageType.Error); } EditorGUILayout.PropertyField(p); EditorGUILayout.HelpBox("The loading scene that will be used when switching scenes via GameManager.SwitchSceneAndLevel<View>().", MessageType.None); p = serializedObject.FindProperty("_LoadingLevel"); EditorGUILayout.PropertyField(p); EditorGUILayout.HelpBox("Pro Users: Will use non asynchronous loading.", MessageType.None); p = serializedObject.FindProperty("_DontUseAsyncLoading"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_ShowLogs"); EditorGUILayout.PropertyField(p); EditorGUILayout.HelpBox("The render settings that will apply when the scene loads.", MessageType.None); //_RenderSettingsOpen = Toggle("Render Settings", _RenderSettingsOpen); if (GUIHelpers.DoToolbarEx("Render Settings")) { p = serializedObject.FindProperty("_Fog"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_FogColor"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_FogMode"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_FogDensity"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_LinearFogStart"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_LinearFogEnd"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_AmbientLight"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_SkyboxMaterial"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_HaloStrength"); EditorGUILayout.PropertyField(p); p = serializedObject.FindProperty("_FlareStrength"); EditorGUILayout.PropertyField(p); if (GUILayout.Button("Load From Scene")) { var t = Target as GameManager; t.LoadRenderSettings(); } } } if (serializedObject.ApplyModifiedProperties()) { //var t = Target as GameManager; //t.ApplyRenderSettings(); } GUIHelpers.IsInsepctor = false; }
public void ReadGameDirectory(string path) { DataPath = path; IsInitialized = false; System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); System.Threading.Thread workerThread = null; loadWaitWorker = new BackgroundWorker(); loadWaitWorker.WorkerReportsProgress = true; loadWaitWorker.DoWork += ((s, e) => { try { System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture; workerThread = System.Threading.Thread.CurrentThread; loadWaitWorker.ReportProgress(-1, "Reading game directory..."); ReadHeaderIdentify(); PrepareDirectoryUnpack(); loadWaitWorker.ReportProgress(-1, "Generating character map..."); EtrianString.GameVersion = Version; loadWaitWorker.ReportProgress(-1, "Initializing font renderers..."); ushort characterCount = (ushort)((SmallFontInfoOffset - MainFontInfoOffset) / 2); MainFontRenderer = new FontRenderer(this, Path.Combine(path, MainFontFilename + ".ntft"), MainFontInfoOffset, characterCount); SmallFontRenderer = new FontRenderer(this, Path.Combine(path, SmallFontFilename + ".ntft"), SmallFontInfoOffset, characterCount); MessageFiles = ReadDataTablesByExtension(new string[] { ".mbb", ".tbb" }, messageDirs); dataTableFiles = ReadDataTablesByExtension(new string[] { ".tbb" }, dataDirs); archives = ReadArchiveFiles(archiveDirs); EnsureMessageTableIntegrity(); GenerateDictionariesLists(); changedMessageFiles = new List <TableFile>(); ParsedData = ParseDataTables(); changedParsedData = new List <BaseParser>(); MapDataFiles = ReadMapDataFiles(mapDataDirs); MapTileData = ParseMapData(); changedMapTileData = new List <BaseTile>(); TextureFilePaths = FindTextureFiles(textureDataDirs); CleanStringDictionaries(); GenerateOtherDictionaries(); loadWaitWorker.ReportProgress(-1, "Finished loading."); IsInitialized = true; } catch (System.Threading.ThreadAbortException) { } catch (Exceptions.GameDataManagerException gameException) { GUIHelpers.ShowErrorMessage( "Application Error", "An error occured while loading the game data.", "Please ensure you've selected a valid game data directory.", gameException.Message, gameException.ToString(), (IntPtr)Program.MainForm.Invoke(new Func <IntPtr>(() => { return(Program.MainForm.Handle); }))); } #if !DEBUG catch (Exception exception) { GUIHelpers.ShowErrorMessage( "Application Error", "The application performed an illegal operation.", "Please contact a developer with the details of this message.", exception.Message, exception.ToString(), (IntPtr)Program.MainForm.Invoke(new Func <IntPtr>(() => { return(Program.MainForm.Handle); }))); } #endif }); loadWaitWorker.ProgressChanged += ((s, e) => { string message = (e.UserState as string); if (loadWaitDialog.Cancel) { workerThread.Abort(); Program.Logger.LogMessage("Loading aborted."); Program.MainForm.StatusText = "Ready"; return; } loadWaitDialog.Details = message; Program.Logger.LogMessage(true, message); }); loadWaitWorker.RunWorkerCompleted += ((s, e) => { loadWaitDialog.Close(); stopwatch.Stop(); Program.Logger.LogMessage("Game directory read in {0:0.000} sec...", stopwatch.Elapsed.TotalSeconds); }); loadWaitWorker.RunWorkerAsync(); loadWaitDialog = new ProgressDialog() { Title = "Loading", InstructionText = "Loading game data.", Text = "Please wait while the game data is being loaded...", ParentForm = Program.MainForm }; loadWaitDialog.Show(Program.MainForm); }
public override void OnInspectorGUI() { serializedObject.Update(); SpriteLibrary controller = target as SpriteLibrary; // EditorGUIUtility.LookLikeInspector(); // EditorGUIUtility.LookLikeControls(); // SerializedProperty tps = serializedObject.FindProperty ("buildingSprites"); // buildingSpritesList.value EditorGUI.BeginChangeCheck(); // EditorGUILayout.PropertyField(tps, true); EditorGUILayout.LabelField("Buildings"); for (int i = 0; i < buildingSpritesList.arraySize; i++) { SerializedProperty buildingSprite = buildingSpritesList.GetArrayElementAtIndex(i); // buildingSprite. SerializedProperty buildingSpriteType = buildingSprite.FindPropertyRelative("type"); // SerializedProperty buildingSpriteSprite = buildingSprite.FindPropertyRelative("sprite"); // SerializedProperty buildingSpriteDestroyedSprite = buildingSprite.FindPropertyRelative("destroyedSprite"); GUIStyle style = new GUIStyle(); style.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField("" + buildingSpriteType.enumDisplayNames[buildingSpriteType.enumValueIndex], style); GUIHelpers.ClassField <BuildingSprite>(buildingSprite); // buildingSprite // EditorGUILayout.PropertyField( buildingSpriteType ); // buildingSpriteType.enumValueIndex = (int)(BuildingType)EditorGUILayout.EnumPopup("Type:", (BuildingType)Enum.GetValues(typeof(BuildingType)).GetValue(buildingSpriteType.enumValueIndex)); // buildingSpriteType.enumValueIndex = (int)EditorGUILayout.EnumPopup("",(BuildingType) buildingSpriteType.enumValueIndex); // buildingSpriteSprite.objectReferenceValue = // EditorGUILayout.PropertyField(buildingSpriteSprite); // EditorGUILayout.PropertyField(buildingSpriteDestroyedSprite); // EditorGUILayout.EnumPopup(testInt); } if (GUILayout.Button("Add")) { buildingSpritesList.InsertArrayElementAtIndex(buildingSpritesList.arraySize); } EditorGUILayout.LabelField("Enemies"); for (int i = 0; i < enemySpritesList.arraySize; i++) { SerializedProperty bldProp = enemySpritesList.GetArrayElementAtIndex(i); // buildingSprite. for (int j = 0; j < typeof(EnemySprite).GetFields().Length; j++) { System.Reflection.FieldInfo field = typeof(EnemySprite).GetFields()[j]; SerializedProperty serProp = bldProp.FindPropertyRelative(field.Name); EditorGUILayout.PropertyField(serProp); } } if (GUILayout.Button("Add")) { enemySpritesList.InsertArrayElementAtIndex(enemySpritesList.arraySize); } EditorGUILayout.LabelField("Projectiles"); for (int i = 0; i < projectileSpritesList.arraySize; i++) { SerializedProperty projectileSprite = projectileSpritesList.GetArrayElementAtIndex(i); GUIHelpers.ClassField <ProjectileSprite>(projectileSprite); } if (GUILayout.Button("Add")) { projectileSpritesList.InsertArrayElementAtIndex(projectileSpritesList.arraySize); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } // EditorGUIUtility.LookLikeControls(); //Update our list // getTarget.Update(); // // //Choose how to display the list<> Example purposes only // EditorGUILayout.Space (); // EditorGUILayout.Space (); // DisplayFieldType = (displayFieldType)EditorGUILayout.EnumPopup("",DisplayFieldType); // // //Resize our list // EditorGUILayout.Space (); // EditorGUILayout.Space (); // EditorGUILayout.LabelField("Define the list size with a number"); // ListSize = ThisList.arraySize; // ListSize = EditorGUILayout.IntField ("List Size", ListSize); // // if(ListSize != ThisList.arraySize){ // while(ListSize > ThisList.arraySize){ // ThisList.InsertArrayElementAtIndex(ThisList.arraySize); // } // while(ListSize < ThisList.arraySize){ // ThisList.DeleteArrayElementAtIndex(ThisList.arraySize - 1); // } // } // // EditorGUILayout.Space (); // EditorGUILayout.Space (); // EditorGUILayout.LabelField("Or"); // EditorGUILayout.Space (); // EditorGUILayout.Space (); // // //Or add a new item to the List<> with a button // EditorGUILayout.LabelField("Add a new item with a button"); // // if(GUILayout.Button("Add New")){ // t.MyList.Add(new CustomList.MyClass()); // } // // EditorGUILayout.Space (); // EditorGUILayout.Space (); // // //Display our list to the inspector window // // for(int i = 0; i < ThisList.arraySize; i++){ // SerializedProperty MyListRef = ThisList.GetArrayElementAtIndex(i); // SerializedProperty MyInt = MyListRef.FindPropertyRelative("AnInt"); // SerializedProperty MyFloat = MyListRef.FindPropertyRelative("AnFloat"); // SerializedProperty MyVect3 = MyListRef.FindPropertyRelative("AnVector3"); // SerializedProperty MyGO = MyListRef.FindPropertyRelative("AnGO"); // SerializedProperty MyArray = MyListRef.FindPropertyRelative("AnIntArray"); // // // // Display the property fields in two ways. // // if(DisplayFieldType == 0){// Choose to display automatic or custom field types. This is only for example to help display automatic and custom fields. // //1. Automatic, No customization <-- Choose me I'm automatic and easy to setup // EditorGUILayout.LabelField("Automatic Field By Property Type"); // EditorGUILayout.PropertyField(MyGO); // EditorGUILayout.PropertyField(MyInt); // EditorGUILayout.PropertyField(MyFloat); // EditorGUILayout.PropertyField(MyVect3); // // // Array fields with remove at index // EditorGUILayout.Space (); // EditorGUILayout.Space (); // EditorGUILayout.LabelField("Array Fields"); // // if(GUILayout.Button("Add New Index",GUILayout.MaxWidth(130),GUILayout.MaxHeight(20))){ // MyArray.InsertArrayElementAtIndex(MyArray.arraySize); // MyArray.GetArrayElementAtIndex(MyArray.arraySize -1).intValue = 0; // } // // for(int a = 0; a < MyArray.arraySize; a++){ // EditorGUILayout.PropertyField(MyArray.GetArrayElementAtIndex(a)); // if(GUILayout.Button("Remove (" + a.ToString() + ")",GUILayout.MaxWidth(100),GUILayout.MaxHeight(15))){ // MyArray.DeleteArrayElementAtIndex(a); // } // } // }else{ // //Or // // //2 : Full custom GUI Layout <-- Choose me I can be fully customized with GUI options. // EditorGUILayout.LabelField("Customizable Field With GUI"); // MyGO.objectReferenceValue = EditorGUILayout.ObjectField("My Custom Go", MyGO.objectReferenceValue, typeof(GameObject), true); // MyInt.intValue = EditorGUILayout.IntField("My Custom Int",MyInt.intValue); // MyFloat.floatValue = EditorGUILayout.FloatField("My Custom Float",MyFloat.floatValue); // MyVect3.vector3Value = EditorGUILayout.Vector3Field("My Custom Vector 3",MyVect3.vector3Value); // // // // Array fields with remove at index // EditorGUILayout.Space (); // EditorGUILayout.Space (); // EditorGUILayout.LabelField("Array Fields"); // // if(GUILayout.Button("Add New Index",GUILayout.MaxWidth(130),GUILayout.MaxHeight(20))){ // MyArray.InsertArrayElementAtIndex(MyArray.arraySize); // MyArray.GetArrayElementAtIndex(MyArray.arraySize -1).intValue = 0; // } // // for(int a = 0; a < MyArray.arraySize; a++){ // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField("My Custom Int (" + a.ToString() + ")",GUILayout.MaxWidth(120)); // MyArray.GetArrayElementAtIndex(a).intValue = EditorGUILayout.IntField("",MyArray.GetArrayElementAtIndex(a).intValue, GUILayout.MaxWidth(100)); // if(GUILayout.Button("-",GUILayout.MaxWidth(15),GUILayout.MaxHeight(15))){ // MyArray.DeleteArrayElementAtIndex(a); // } // EditorGUILayout.EndHorizontal(); // } // } // // EditorGUILayout.Space (); // // //Remove this index from the List // EditorGUILayout.LabelField("Remove an index from the List<> with a button"); // if(GUILayout.Button("Remove This Index (" + i.ToString() + ")")){ // ThisList.DeleteArrayElementAtIndex(i); // } // EditorGUILayout.Space (); // EditorGUILayout.Space (); // EditorGUILayout.Space (); // EditorGUILayout.Space (); // } // // //Apply the changes to our list // GetTarget.ApplyModifiedProperties(); }
void OnGUI() { GUI.enabled = BrowserUtility.guiEnabled; if (!initGUIStyle) { InitializeStyle(); LoadSettings(); } scrollPosition1 = GUILayout.BeginScrollView(scrollPosition1, false, false, GUI.skin.horizontalScrollbar, blankScrollbar, GUILayout.Height(110)); #region Main button row GUILayout.BeginHorizontal(); DisplayButtons(); GUILayout.EndHorizontal(); #endregion GUILayout.Space(12); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(3)); #region Repository location, initialization GUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(BrowserUtility.repositoryLocation)) { GUILayout.Label(versionControlTypeLogo); GUILayout.Space(10); GUILayout.Label(BrowserUtility.repositoryShortName); GUILayout.FlexibleSpace(); /* TODO: Put this in the settings window * * if (viewMode != BrowserViewMode.ArtistMode) * { * if (GUILayout.Button("Reinitialize")) * BrowserUtility.OnButton_Init(this); * } */ var vm = (BrowserViewMode)EditorGUILayout.EnumPopup(viewMode); if (vm != viewMode) { viewMode = vm; EditorPrefs.SetInt("UnityVersionControl.BrowserViewMode", (int)viewMode); } } else { GUI.color = Color.red; GUILayout.Label("No project repository found!"); GUI.color = Color.white; GUILayout.FlexibleSpace(); // Todo, make initialization UI prettier if (GUILayout.Button("Initialize")) { BrowserUtility.OnButton_Init(this); } var vm = (BrowserViewMode)EditorGUILayout.EnumPopup(viewMode); if (vm != viewMode) { viewMode = vm; EditorPrefs.SetInt("UnityVersionControl.BrowserViewMode", (int)viewMode); } } GUILayout.EndHorizontal(); #endregion GUILayout.EndScrollView(); mainScrollPosition = GUILayout.BeginScrollView(mainScrollPosition); GUILayout.BeginHorizontal(); if (viewMode != BrowserViewMode.ArtistMode && showDiff) { GUILayout.BeginVertical(GUILayout.Width(horizontalResizeWidget1 - 3)); } else { GUILayout.BeginVertical(); } #region First scroll area - Staged files (git) if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.BeginVertical(GUILayout.Height(verticalResizeWidget1 - 3)); GUILayout.BeginHorizontal(); GUILayout.Label("Staged files", EditorStyles.toolbarButton); stagedFilesFilter = (FileState)EditorGUILayout.EnumMaskField(stagedFilesFilter, EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.EndHorizontal(); scrollPosition2 = GUILayout.BeginScrollView(scrollPosition2, false, false); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUI.backgroundColor *= .5f; GUILayout.Label("State", EditorStyles.toolbarButton, GUILayout.Width(80)); GUILayout.Label("File", EditorStyles.toolbarButton, GUILayout.Width(300)); GUILayout.Label("Path", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); filteredStagedFiles.Clear(); filteredStagedFiles.AddRange(BrowserUtility.stagedFiles.Values); FilterFileList(filteredStagedFiles, true); for (int i = 0; i < filteredStagedFiles.Count; i++) { DisplayFile(filteredStagedFiles[i], i, true, filteredStagedFiles); } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } #endregion #region Resize widget if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { Rect r = new Rect(position.x, position.y - 220, position.width, position.height); bool drag = GUIHelpers.ResizeWidget(drag1, ref verticalResizeWidget1, 60, position.height - 180, 6, true, r, this); if (drag != drag1) { drag1 = drag; EditorPrefs.SetFloat("UnityVersionControl.VWidget1", verticalResizeWidget1); } } #endregion #region Second scroll area - Working tree if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.BeginVertical(GUILayout.Height(position.height - 126 - verticalResizeWidget1 - 3)); } GUILayout.BeginHorizontal(); GUILayout.Label("Working tree", EditorStyles.toolbarButton); workingTreeFilter = (FileState)EditorGUILayout.EnumMaskField(workingTreeFilter, EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.EndHorizontal(); scrollPosition3 = GUILayout.BeginScrollView(scrollPosition3, false, false); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUI.backgroundColor *= .5f; GUILayout.Label("State", EditorStyles.toolbarButton, GUILayout.Width(80)); if (viewMode != BrowserViewMode.ArtistMode) { GUILayout.Label("File", EditorStyles.toolbarButton, GUILayout.Width(300)); } GUILayout.Label("Path", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); filteredWorkingTree.Clear(); filteredWorkingTree.AddRange(BrowserUtility.workingTree.Values); FilterFileList(filteredWorkingTree, false); for (int i = 0; i < filteredWorkingTree.Count; i++) { DisplayFile(filteredWorkingTree[i], i, false, filteredWorkingTree); } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (VersionControl.versionControlType == VersionControlType.Git && viewMode != BrowserViewMode.ArtistMode && showStagedFiles) { GUILayout.EndVertical(); } #endregion GUILayout.EndVertical(); #region Resize widget if (viewMode != BrowserViewMode.ArtistMode && showDiff) { bool drag = GUIHelpers.ResizeWidget(drag2, ref horizontalResizeWidget1, 80, position.width - 80, 4, false, position, this); if (drag != drag2) { drag2 = drag; EditorPrefs.SetFloat("UnityVersionControl.HWidget1", horizontalResizeWidget1); } } #endregion #region 3rd scroll area - Diff if (viewMode != BrowserViewMode.ArtistMode && showDiff) { GUILayout.BeginVertical(GUILayout.Width(position.width - horizontalResizeWidget1)); GUILayout.BeginHorizontal(); GUILayout.Label("Diff", EditorStyles.toolbarButton, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); scrollPosition4 = GUILayout.BeginScrollView(scrollPosition4, false, false); EditorGUILayout.SelectableLabel(BrowserUtility.diffString, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUILayout.EndVertical(); } #endregion GUILayout.EndHorizontal(); GUILayout.EndScrollView(); #region Status bar DisplayStatusBar(); #endregion GUI.enabled = BrowserUtility.guiEnabled; if (BrowserUtility.guiEnabled) { BrowserUtility.ProcessKeyboardEvents(ref lastSelectedIndex, filteredStagedFiles, filteredWorkingTree); } }
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { Event evt = Event.current; int controlID = GUIUtility.GetControlID(FocusType.Passive); EventType evtType = evt.GetTypeForControl(controlID); r = AudioCurveRendering.BeginCurveFrame(r); float thr = 4.0f; bool changed = false; float x = evt.mousePosition.x - r.x; if (evtType == EventType.MouseDown && r.Contains(evt.mousePosition) && evt.button == 0) { float lf = (float)GUIHelpers.MapNormalizedFrequency(lowFreq, samplerate, useLogScale, false) * r.width; float hf = (float)GUIHelpers.MapNormalizedFrequency(highFreq, samplerate, useLogScale, false) * r.width; dragOperation = DragOperation.Mid; if (x < lf + thr) { dragOperation = DragOperation.Low; } else if (x > hf - thr) { dragOperation = DragOperation.High; } GUIUtility.hotControl = controlID; EditorGUIUtility.SetWantsMouseJumping(1); evt.Use(); } else if (evtType == EventType.MouseDrag && GUIUtility.hotControl == controlID) { if (dragOperation == DragOperation.Low || dragOperation == DragOperation.Mid) { lowFreq = Mathf.Clamp((float)GUIHelpers.MapNormalizedFrequency(GUIHelpers.MapNormalizedFrequency(lowFreq, samplerate, useLogScale, false) + evt.delta.x / r.width, samplerate, useLogScale, true), 10.0f, highFreq); } if (dragOperation == DragOperation.Low) { lowGain = Mathf.Clamp(lowGain - evt.delta.y * 0.5f, -100.0f, 100.0f); } if (dragOperation == DragOperation.Mid) { midGain = Mathf.Clamp(midGain - evt.delta.y * 0.5f, -100.0f, 100.0f); } if (dragOperation == DragOperation.Mid || dragOperation == DragOperation.High) { highFreq = Mathf.Clamp((float)GUIHelpers.MapNormalizedFrequency(GUIHelpers.MapNormalizedFrequency(highFreq, samplerate, useLogScale, false) + evt.delta.x / r.width, samplerate, useLogScale, true), lowFreq, samplerate * 0.5f); } if (dragOperation == DragOperation.High) { highGain = Mathf.Clamp(highGain - evt.delta.y * 0.5f, -100.0f, 100.0f); } changed = true; evt.Use(); } else if (evtType == EventType.MouseUp && evt.button == 0 && GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; EditorGUIUtility.SetWantsMouseJumping(0); evt.Use(); } if (Event.current.type == EventType.Repaint) { float blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; // Mark bands (low, medium and high bands) Color lowColor = new Color(0.0f, 0.0f, 0.0f, blend); Color midColor = new Color(0.5f, 0.5f, 0.5f, blend); Color highColor = new Color(1.0f, 1.0f, 1.0f, blend); DrawBandSplitMarker(plugin, r, (float)GUIHelpers.MapNormalizedFrequency(lowFreq, samplerate, useLogScale, false) * r.width, thr, GUIUtility.hotControl == controlID && (dragOperation == DragOperation.Low || dragOperation == DragOperation.Mid), lowColor); DrawBandSplitMarker(plugin, r, (float)GUIHelpers.MapNormalizedFrequency(highFreq, samplerate, useLogScale, false) * r.width, thr, GUIUtility.hotControl == controlID && (dragOperation == DragOperation.High || dragOperation == DragOperation.Mid), highColor); const float dbRange = 40.0f; const float magScale = 1.0f / dbRange; float[] liveData; plugin.GetFloatBuffer("LiveData", out liveData, 6); float[] coeffs; plugin.GetFloatBuffer("Coeffs", out coeffs, 20); if (GUIUtility.hotControl == controlID) { DrawFilterCurve( r, coeffs, (dragOperation == DragOperation.Low) ? Mathf.Pow(10.0f, 0.05f * lowGain) : 0.0f, (dragOperation == DragOperation.Mid) ? Mathf.Pow(10.0f, 0.05f * midGain) : 0.0f, (dragOperation == DragOperation.High) ? Mathf.Pow(10.0f, 0.05f * highGain) : 0.0f, new Color(1.0f, 1.0f, 1.0f, 0.2f * blend), true, samplerate, magScale); } DrawFilterCurve(r, coeffs, Mathf.Pow(10.0f, 0.05f * lowGain) * liveData[0], 0.0f, 0.0f, lowColor, false, samplerate, magScale); DrawFilterCurve(r, coeffs, 0.0f, Mathf.Pow(10.0f, 0.05f * midGain) * liveData[1], 0.0f, midColor, false, samplerate, magScale); DrawFilterCurve(r, coeffs, 0.0f, 0.0f, Mathf.Pow(10.0f, 0.05f * highGain) * liveData[2], highColor, false, samplerate, magScale); DrawFilterCurve( r, coeffs, Mathf.Pow(10.0f, 0.05f * lowGain) * liveData[0], Mathf.Pow(10.0f, 0.05f * midGain) * liveData[1], Mathf.Pow(10.0f, 0.05f * highGain) * liveData[2], ScaleAlpha(AudioCurveRendering.kAudioOrange, 0.5f), false, samplerate, magScale); DrawFilterCurve( r, coeffs, Mathf.Pow(10.0f, 0.05f * lowGain), Mathf.Pow(10.0f, 0.05f * midGain), Mathf.Pow(10.0f, 0.05f * highGain), AudioCurveRendering.kAudioOrange, false, samplerate, magScale); if (showSpectrum) { int specLen = (int)r.width; float[] spec; plugin.GetFloatBuffer("InputSpec", out spec, specLen); DrawSpectrum(r, useLogScale, spec, dbRange, samplerate, 0.3f, 1.0f, 0.3f, 0.5f * blend, 0.0f); plugin.GetFloatBuffer("OutputSpec", out spec, specLen); DrawSpectrum(r, useLogScale, spec, dbRange, samplerate, 1.0f, 0.3f, 0.3f, 0.5f * blend, 0.0f); } GUIHelpers.DrawFrequencyTickMarks(r, samplerate, useLogScale, new Color(1.0f, 1.0f, 1.0f, 0.3f * blend)); } AudioCurveRendering.EndCurveFrame(); return(changed); }
/// <summary>This will: loop assemblies, /// loop types, /// filter types that are a subclass of RotationBase and not the abstract, /// create an instance of a RotationBase subclass so we can interigate KeySpell within the RotationBase subclass, /// Check if the character has the Keyspell, /// Set the active rotation to the matching RotationBase subclass.</summary> private void QueryClassTree() { try { Type type = typeof(RotationBase); //no need to get ALL Assemblies, need only the executed ones IEnumerable <Type> types = Assembly.GetExecutingAssembly().GetTypes().Where(p => p.IsSubclassOf(type)); //_rotations.AddRange(new TypeLoader<RotationBase>(null)); this._rotations = new List <RotationBase>(); foreach (Type x in types) { ConstructorInfo constructorInfo = x.GetConstructor(new Type[] { }); if (constructorInfo != null) { var rb = constructorInfo.Invoke(new object[] { }) as RotationBase; if (rb != null && SpellManager.HasSpell(rb.KeySpellId)) { CLULogger.TroubleshootLog(" Using " + rb.Name + " rotation. Character has " + rb.KeySpell); this._rotations.Add(rb); } else { if (rb != null) { //TroubleshootLog(" Skipping " + rb.Name + " rotation. Character is missing " + rb.KeySpell); } } } } // If there is more than one rotation then display the selector for the user, otherwise just load the one and only. if (this._rotations.Count > 1) { string value = "null"; if ( GUIHelpers.RotationSelector ("[CLU] " + Version + " Rotation Selector", this._rotations, "Please select your prefered rotation:", ref value) == DialogResult.OK) { this.SetActiveRotation(this._rotations.First(x => value != null && x.Name == value)); } } else { if (this._rotations.Count == 0) { CLULogger.Log("Couldn't finde a rotation for you, Contact us!"); StopBot("Unable to find Active Rotation"); } else { RotationBase r = this._rotations.FirstOrDefault(); if (r != null) { CLULogger.Log("Found rotation: " + r.Name); this.SetActiveRotation(r); } } } } catch (ReflectionTypeLoadException ex) { var sb = new StringBuilder(); foreach (Exception exSub in ex.LoaderExceptions) { sb.AppendLine(exSub.Message); if (exSub is FileNotFoundException) { var exFileNotFound = exSub as FileNotFoundException; if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { sb.AppendLine("CLU Log:"); sb.AppendLine(exFileNotFound.FusionLog); } } sb.AppendLine(); } string errorMessage = sb.ToString(); CLULogger.Log(" Woops, we could not set the rotation."); CLULogger.Log(errorMessage); StopBot(" Unable to find Active Rotation: " + ex); } }
public override void OnInspectorGUI() { MenuBar.OnGUI("288078-fabricmanager", true, this.fabricManager.gameObject); AudioManagerEngineEditor.GetManagerInstance(); this.undoManager.CheckUndo(); GUILayout.BeginVertical("Box", new GUILayoutOption[0]); this.fabricManager._dontDestroyOnLoad = EditorGUILayout.Toggle("Dont Destroy OnLoad: ", this.fabricManager._dontDestroyOnLoad, new GUILayoutOption[0]); this.fabricManager._showAllInstances = EditorGUILayout.Toggle("Show All Instances: ", this.fabricManager._showAllInstances, new GUILayoutOption[0]); this.fabricManager._enableVirtualization = EditorGUILayout.Toggle("AudioComponent Virtualization: ", this.fabricManager._enableVirtualization, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this.fabricManager._createEventListeners = EditorGUILayout.Toggle("Create Event Listeners: ", this.fabricManager._createEventListeners, new GUILayoutOption[0]); if (this.fabricManager._createEventListeners) { this.fabricManager._useFullPathForEventListeners = EditorGUILayout.Toggle("Use full path for name:", this.fabricManager._useFullPathForEventListeners, new GUILayoutOption[0]); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this.fabricManager.enableTimelineAssetLoader = EditorGUILayout.Toggle("Timeline Loader: ", this.fabricManager.enableTimelineAssetLoader, new GUILayoutOption[0]); if (this.fabricManager.enableTimelineAssetLoader && GUILayout.Button("Import ftp Project: ", new GUILayoutOption[0])) { string text = EditorUtility.OpenFilePanel("import ftp Project", "", "ftp"); if (text.Length != 0) { TimelineLoader.LoadFtpProject(text); } } GUILayout.EndHorizontal(); this.fabricManager._enableDebugLog = EditorGUILayout.Toggle("Debug Log: ", this.fabricManager._enableDebugLog, new GUILayoutOption[0]); this.fabricManager._allowExternalGroupComponents = EditorGUILayout.Toggle("External Groups: ", this.fabricManager._allowExternalGroupComponents, new GUILayoutOption[0]); int languageByIndex = EditorGUILayout.Popup("Language: ", this.fabricManager.GetLanguageIndex(), this.fabricManager.GetLanguageNames(), new GUILayoutOption[0]); this.fabricManager.SetLanguageByIndex(languageByIndex); this.fabricManager._transitionThreshold = (double)EditorGUILayout.Slider("Transition Threshold (sec): ", (float)this.fabricManager._transitionThreshold, 0.01f, 1f, new GUILayoutOption[0]); this.fabricManager._volumeThreshold = (double)EditorGUILayout.Slider("Volume Threshold: ", (float)this.fabricManager._volumeThreshold, 0f, 1f, new GUILayoutOption[0]); this.fabricManager._onApplicationPauseBehavior = (FabricManager.OnApplicationPauseBehavior)EditorGUILayout.EnumPopup("On Application Pause: ", this.fabricManager._onApplicationPauseBehavior, new GUILayoutOption[0]); bool flag = EditorGUILayout.Toggle("Bake Component Inst: ", this.fabricManager._bakeComponentInstances, new GUILayoutOption[0]); if (flag != this.fabricManager._bakeComponentInstances) { if (flag) { this.fabricManager.BakeComponentInstances(); } else { this.fabricManager.CleanBakedComponentInstances(); } } this.fabricManager._bakeComponentInstances = flag; bool flag2 = EditorGUILayout.Toggle("Playmode Persistence: ", FabricEditorData.GetData()._playmodePersistance, new GUILayoutOption[0]); if (flag2 != FabricEditorData.GetData()._playmodePersistance) { FabricEditorData.GetData()._playmodePersistance = flag2; FabricEditorData.ApplyChanges(); } FabricEditorData.GetData()._enableHiearchyIcons = EditorGUILayout.Toggle("Show Component Icons: ", FabricEditorData.GetData()._enableHiearchyIcons, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.LabelField("Editor Path: " + this.fabricManager._fabricEditorPath, new GUILayoutOption[0]); if (GUILayout.Button("Set Path", new GUILayoutOption[0])) { this.fabricManager._fabricEditorPath = AudioManagerEngineEditor.SetFabricEditorPath(this.fabricManager._fabricEditorPath); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); this.AddRemoveAudioMixerDebugLogComponents(); GUILayout.BeginHorizontal("Box", new GUILayoutOption[0]); this.fabricManager._forceAxisVector = EditorGUILayout.Vector3Field("Force Axis: ", this.fabricManager._forceAxisVector, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.BeginVertical("Music Time Settings", "Box", new GUILayoutOption[0]); GUILayout.Space(15f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); this.musicSettingName = EditorGUILayout.TextField("Name: ", this.musicSettingName, new GUILayoutOption[0]); if (GUILayout.Button("Add", new GUILayoutOption[0])) { MusicTimeSittings musicTimeSittings = new MusicTimeSittings(); musicTimeSittings._name = this.musicSettingName; this.fabricManager._musicTimeSignatures.Add(musicTimeSittings); } GUILayout.EndHorizontal(); GUILayout.Space(5f); int count = this.fabricManager._musicTimeSignatures.Count; if (count > 0) { string[] array = new string[count]; for (int i = 0; i < count; i++) { array[i] = this.fabricManager._musicTimeSignatures[i]._name; } this.selectedMusicSetting = EditorGUILayout.Popup("Music Time Settings: ", this.selectedMusicSetting, array, new GUILayoutOption[0]); MusicTimeSittings musicTimeSittings2 = this.fabricManager._musicTimeSignatures[this.selectedMusicSetting]; musicTimeSittings2._name = EditorGUILayout.TextField("Name:", musicTimeSittings2._name, new GUILayoutOption[0]); musicTimeSittings2._bpm = EditorGUILayout.FloatField("Tempo: ", musicTimeSittings2._bpm, new GUILayoutOption[0]); musicTimeSittings2._syncType = (MusicSyncType)EditorGUILayout.EnumPopup("Sync Type: ", musicTimeSittings2._syncType, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.LabelField("Time Signature: ", new GUILayoutOption[] { GUILayout.MaxWidth(148f) }); string[] array2 = new string[17]; for (int j = 1; j < 17; j++) { array2[j] = j.ToString(); } musicTimeSittings2._timeSignatureLower = EditorGUILayout.Popup(musicTimeSittings2._timeSignatureLower, array2, new GUILayoutOption[] { GUILayout.MaxWidth(30f) }); EditorGUILayout.LabelField(" / ", new GUILayoutOption[] { GUILayout.MaxWidth(25f) }); string[] array3 = new string[] { "2", "4", "8" }; int num = 0; for (int k = 0; k < array3.Length; k++) { if (array3[k] == musicTimeSittings2._timeSignatureUpper.ToString()) { num = k; break; } } num = EditorGUILayout.Popup(num, array3, new GUILayoutOption[] { GUILayout.MaxWidth(30f) }); musicTimeSittings2._timeSignatureUpper = int.Parse(array3[num]); GUILayout.EndHorizontal(); GUILayout.Space(5f); AudioManagerEngineEditor.MusicSyncToTarget(musicTimeSittings2); GUILayout.Space(5f); if (this.selectedMusicSetting >= 0 && GUILayout.Button("Delete", new GUILayoutOption[0])) { this.fabricManager._musicTimeSignatures.RemoveAt(this.selectedMusicSetting); this.selectedMusicSetting = 0; } } GUILayout.Space(5f); GUILayout.EndVertical(); GUILayout.Space(5f); GUILayout.BeginVertical("AudioSource Pool", "Box", new GUILayoutOption[0]); GUILayout.Space(20f); this.fabricManager._audioSourcePool = EditorGUILayout.IntField("Size: ", this.fabricManager._audioSourcePool, new GUILayoutOption[0]); AudioSourcePoolEditor.DisplayProperties(this.fabricManager); GUILayout.EndVertical(); GUILayout.Space(5f); GUILayout.BeginVertical("Manager Info", "Box", new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.Label("Total gameObjects used: " + this.fabricManager._totalNumberOfGameObjectsUsed, new GUILayoutOption[0]); GUILayout.Space(5f); float num2 = this.fabricManager._totalMemoryUsed / 1024f / 1024f; GUILayout.Label("Total memory used: " + num2 + " Mb", new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.Label("CPU:" + this.fabricManager.profiler.percent.ToString("0.000") + "% - ms:" + this.fabricManager.profiler.msPerFrame.ToString("0.000"), new GUILayoutOption[0]); GUILayout.EndVertical(); GUIHelpers.CheckGUIHasChanged(this.fabricManager.gameObject); this.undoManager.CheckDirty(); }