Exemplo n.º 1
0
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            Call t = target as Call;

            Flowchart flowchart = null;

            if (targetFlowchartProp.objectReferenceValue == null)
            {
                flowchart = (Flowchart)t.GetFlowchart();
            }
            else
            {
                flowchart = targetFlowchartProp.objectReferenceValue as Flowchart;
            }

            EditorGUILayout.PropertyField(targetFlowchartProp);

            if (flowchart != null)
            {
                BlockEditor.BlockField(targetBlockProp,
                                       new GUIContent("Target Block", "Block to call"),
                                       new GUIContent("<None>"),
                                       flowchart);

                EditorGUILayout.PropertyField(startLabelProp);

                EditorGUILayout.PropertyField(startIndexProp);
            }

            EditorGUILayout.PropertyField(callModeProp);

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 2
0
        public override void DrawCommandGUI()
        {
            if (flowchart == null)
            {
                return;
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(csvCommandKeyProp);
            EditorGUILayout.PropertyField(textProp);

            EditorGUILayout.PropertyField(descriptionProp);

            BlockEditor.BlockField(targetBlockProp,
                                   new GUIContent("Target Block", "Block to call when option is selected"),
                                   new GUIContent("<None>"),
                                   flowchart);

            EditorGUILayout.PropertyField(hideIfVisitedProp);
            EditorGUILayout.PropertyField(interactableProp);
            EditorGUILayout.PropertyField(setMenuDialogProp);
            EditorGUILayout.PropertyField(hideThisOptionProp);

            MenuExtend t = target as MenuExtend;

            EditorGUILayout.PropertyField(HasConditionProp);

            if (t.HasCondition == true)
            {
                EditorGUILayout.PropertyField(requireValueProp, new GUIContent("Require Gold"));
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 3
0
        public override void DrawCommandGUI()
        {
            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(textProp);

            EditorGUILayout.PropertyField(descriptionProp);

            BlockEditor.BlockField(targetBlockProp,
                                   new GUIContent("Target Block", "Block to call when option is selected"),
                                   new GUIContent("<None>"),
                                   flowchart);

            EditorGUILayout.PropertyField(hideIfVisitedProp);
            EditorGUILayout.PropertyField(interactableProp);
            EditorGUILayout.PropertyField(setMenuDialogProp);
            EditorGUILayout.PropertyField(hideThisOptionProp);

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 4
0
        public override void DrawCommandGUI()
        {
            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(textProp);

            EditorGUILayout.PropertyField(descriptionProp);

            EditorGUILayout.BeginHorizontal();
            BlockEditor.BlockField(targetBlockProp,
                                   new GUIContent("Target Block", "Block to call when option is selected"),
                                   new GUIContent("<None>"),
                                   flowchart);
            const int popupWidth = 17;

            if (targetBlockProp.objectReferenceValue == null && GUILayout.Button("+", GUILayout.MaxWidth(popupWidth)))
            {
                var fw = EditorWindow.GetWindow <FlowchartWindow>();
                var t  = (Menu)target;
                var activeFlowchart = t.GetFlowchart();
                var newBlock        = fw.CreateBlockSuppressSelect(activeFlowchart, t.ParentBlock._NodeRect.position - Vector2.down * 60);
                targetBlockProp.objectReferenceValue = newBlock;
                activeFlowchart.SelectedBlock        = t.ParentBlock;
            }
            EditorGUILayout.EndHorizontal();



            EditorGUILayout.PropertyField(hideIfVisitedProp);
            EditorGUILayout.PropertyField(interactableProp);
            EditorGUILayout.PropertyField(setMenuDialogProp);
            EditorGUILayout.PropertyField(hideThisOptionProp);

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 5
0
        public override void DrawCommandGUI()
        {
            var flowchart = FlowchartWindow.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            serializedObject.Update();

            EditorGUILayout.PropertyField(durationProp);

            BlockEditor.BlockField(targetBlockProp,
                                   new GUIContent("Target Block", "Block to call when timer expires"),
                                   new GUIContent("<None>"),
                                   flowchart);

            serializedObject.ApplyModifiedProperties();
        }
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            FungusChangeGameState t         = target as FungusChangeGameState;
            Flowchart             flowchart = t.GetFlowchart();

            if (flowchart != null)
            {
                BlockEditor.BlockField(succededBlockProp,
                                       new GUIContent("Succeded Block", "Block to call"),
                                       new GUIContent("<None>"),
                                       flowchart);

                BlockEditor.BlockField(failedBlockProp,
                                       new GUIContent("Failed Block", "Block to call"),
                                       new GUIContent("<None>"),
                                       flowchart);
            }
            serializedObject.ApplyModifiedProperties();
            base.DrawCommandGUI();
        }
        protected static List <KeyValuePair <System.Type, CommandInfoAttribute> > GetFilteredSupportedCommands(Flowchart flowchart)
        {
            List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = BlockEditor.GetFilteredCommandInfoAttribute(commandTypes);

            filteredAttributes.Sort(BlockEditor.CompareCommandAttributes);

            filteredAttributes = filteredAttributes.Where(x => flowchart.IsCommandSupported(x.Value)).ToList();

            return(filteredAttributes);
        }
Exemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            BlockInspector blockInspector = target as BlockInspector;

            if (blockInspector.block == null)
            {
                return;
            }

            var block = blockInspector.block;

            if (block == null)
            {
                return;
            }

            var flowchart = (Flowchart)block.GetFlowchart();

            if (flowchart.SelectedBlocks.Count > 1)
            {
                GUILayout.Label("Multiple blocks selected");
                return;
            }

            //if there is no selection but we are drawing, fix that
            if (flowchart.SelectedBlocks.Count == 0)
            {
                flowchart.AddSelectedBlock(block);
            }

            if (activeBlockEditor == null ||
                !block.Equals(activeBlockEditor.target))
            {
                DestroyImmediate(activeBlockEditor);
                activeBlockEditor = Editor.CreateEditor(block, typeof(BlockEditor)) as BlockEditor;
            }

            UpdateWindowHeight();

            float width = EditorGUIUtility.currentViewWidth;

            blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight));
            activeBlockEditor.DrawBlockName(flowchart);
            activeBlockEditor.DrawBlockGUI(flowchart);
            GUILayout.EndScrollView();

            Command inspectCommand = null;

            if (flowchart.SelectedCommands.Count == 1)
            {
                inspectCommand = flowchart.SelectedCommands[0];
            }

            if (Application.isPlaying &&
                inspectCommand != null &&
                !inspectCommand.ParentBlock.Equals(block))
            {
                Repaint();
                return;
            }

            // Only change the activeCommand at the start of the GUI call sequence
            if (Event.current.type == EventType.Layout)
            {
                activeCommand = inspectCommand;
            }

            DrawCommandUI(flowchart, inspectCommand);
        }
        public override void OnInspectorGUI()
        {
            BlockInspector blockInspector = target as BlockInspector;

            if (blockInspector.block == null)
            {
                return;
            }

            var block = blockInspector.block;

            if (block == null)
            {
                return;
            }

            var flowchart = (Flowchart)block.GetFlowchart();

            if (activeBlockEditor == null ||
                !block.Equals(activeBlockEditor.target))
            {
                DestroyImmediate(activeBlockEditor);
                activeBlockEditor = Editor.CreateEditor(block) as BlockEditor;
            }

            activeBlockEditor.DrawBlockName(flowchart);

            UpdateWindowHeight();

            float width  = EditorGUIUtility.currentViewWidth;
            float height = windowHeight;

            // Using a custom rect area to get the correct 5px indent for the scroll views
            Rect blockRect = new Rect(5, topPanelHeight, width - 5, height + 10);

            GUILayout.BeginArea(blockRect);

            blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight));
            activeBlockEditor.DrawBlockGUI(flowchart);
            GUILayout.EndScrollView();

            Command inspectCommand = null;

            if (flowchart.SelectedCommands.Count == 1)
            {
                inspectCommand = flowchart.SelectedCommands[0];
            }

            if (Application.isPlaying &&
                inspectCommand != null &&
                !inspectCommand.ParentBlock.Equals(block))
            {
                GUILayout.EndArea();
                Repaint();
                return;
            }

            // Only change the activeCommand at the start of the GUI call sequence
            if (Event.current.type == EventType.Layout)
            {
                activeCommand = inspectCommand;
            }

            DrawCommandUI(flowchart, inspectCommand);
        }
Exemplo n.º 10
0
        private static void ExportCommandInfo()
        {
            // Dump command info
            List <System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList();
            List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = BlockEditor.GetFilteredCommandInfoAttribute(menuTypes);

            filteredAttributes.Sort(BlockEditor.CompareCommandAttributes);

            // Build list of command categories
            List <string> commandCategories = new List <string>();

            foreach (var keyPair in filteredAttributes)
            {
                CommandInfoAttribute info = keyPair.Value;
                if (info.Category != "" &&
                    !commandCategories.Contains(info.Category))
                {
                    commandCategories.Add(info.Category);
                }
            }
            commandCategories.Sort();

            var sb = new System.Text.StringBuilder(@"# Command Reference

This is the reference documentation for all Fungus commands.

");

            // Output the commands in each category
            foreach (string category in commandCategories)
            {
                string markdown = "# " + category + " commands # {#" + category.ToLower() + "_commands}\n\n";
                markdown += "[TOC]\n";

                foreach (var keyPair in filteredAttributes)
                {
                    CommandInfoAttribute info = keyPair.Value;

                    if (info.Category == category ||
                        info.Category == "" && category == "Scripting")
                    {
                        markdown += "# " + info.CommandName + " # {#" + info.CommandName.Replace(" ", "") + "}\n";
                        markdown += info.HelpText + "\n\n";
                        markdown += "Defined in " + keyPair.Key.FullName + "\n";
                        markdown += GetPropertyInfo(keyPair.Key);
                    }
                }

                WriteFile(markdown, CommandRefDocPath, category.ToLower(), "_commands.md");
                sb.Append("* [").Append(category).Append("](").Append(category.ToLower()).AppendLine("_commands)");
            }

            sb.AppendLine();
            WriteFile(sb.ToString(), BaseDocPath, "", "command_reference.md");
        }
        public override void OnInspectorGUI () 
        {
            BlockInspector blockInspector = target as BlockInspector;
            if (blockInspector.block == null)
            {
                return;
            }

            var block = blockInspector.block;
            if (block == null)
            {
                return;
            }

            var flowchart = (Flowchart)block.GetFlowchart();

            if (flowchart.SelectedBlocks.Count > 1)
            {
                GUILayout.Label("Multiple blocks selected");
                return;
            }

            if (activeBlockEditor == null ||
                !block.Equals(activeBlockEditor.target))
            {
                DestroyImmediate(activeBlockEditor);
                activeBlockEditor = Editor.CreateEditor(block) as BlockEditor;
            }

            activeBlockEditor.DrawBlockName(flowchart);

            UpdateWindowHeight();

            float width = EditorGUIUtility.currentViewWidth;
            float height = windowHeight;

            // Using a custom rect area to get the correct 5px indent for the scroll views
            Rect blockRect = new Rect(5, topPanelHeight, width - 5, height + 10);
            GUILayout.BeginArea(blockRect);

            blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight));
            activeBlockEditor.DrawBlockGUI(flowchart);
            GUILayout.EndScrollView();

            Command inspectCommand = null;
            if (flowchart.SelectedCommands.Count == 1)
            {
                inspectCommand = flowchart.SelectedCommands[0];
            }

            if (Application.isPlaying &&
                inspectCommand != null &&
                !inspectCommand.ParentBlock.Equals(block))
            {
                GUILayout.EndArea();
                Repaint();
                return;
            }

            // Only change the activeCommand at the start of the GUI call sequence
            if (Event.current.type == EventType.Layout)
            {
                activeCommand = inspectCommand;
            }

            DrawCommandUI(flowchart, inspectCommand);
        }
Exemplo n.º 12
0
        public override void OnInspectorGUI()
        {
            BlockInspector blockInspector = target as BlockInspector;

            if (blockInspector.block == null)
            {
                return;
            }

            // 获取到,要显示的Block
            var block = blockInspector.block;

            if (block == null)
            {
                return;
            }

            // 获取到Block的Flowchart
            var flowchart = (Flowchart)block.GetFlowchart();

            // 检查,
            // 是否只选中了一个Block
            if (flowchart.SelectedBlocks.Count > 1)
            {
                GUILayout.Label("Multiple blocks selected");
                return;
            }

            // 创建BlockEditor!!!!
            //  * 这里的是,BlockEditorInspector
            if (activeBlockEditor == null ||
                !block.Equals(activeBlockEditor.target))
            {
                DestroyImmediate(activeBlockEditor);
                activeBlockEditor = Editor.CreateEditor(block) as BlockEditor;
            }

            UpdateWindowHeight();

            float width = EditorGUIUtility.currentViewWidth;

            // 画Inspector的上部
            blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight));
            {
                // Block Name:
                //  * 显示Block名称
                activeBlockEditor.DrawBlockName(flowchart);

                // 显示Inspector上方的
                // Block的界面
                activeBlockEditor.DrawBlockGUI(flowchart);

                GUILayout.EndScrollView();
            }


            Command inspectCommand = null;

            // 只能编辑一个命令
            if (flowchart.SelectedCommands.Count == 1)
            {
                inspectCommand = flowchart.SelectedCommands[0];
            }

            if (Application.isPlaying &&
                inspectCommand != null &&
                !inspectCommand.ParentBlock.Equals(block))
            {
                Repaint();
                return;
            }

            // Only change the activeCommand at the start of the GUI call sequence
            if (Event.current.type == EventType.Layout)
            {
                activeCommand = inspectCommand;
            }

            DrawCommandUI(flowchart, inspectCommand);
        }