Exemple #1
0
        protected override void DrawOpenNodeContent(Effects content, IEffect node)
        {
            var abstractEffect = node as AbstractEffect;

            if (abstractEffect != null)
            {
                GUILayout.BeginVertical(conditionStyle);
                GUILayout.Label("CONDITIONS");
                if (GUILayout.Button("Add Block"))
                {
                    abstractEffect.getConditions().Add(new FlagCondition(""));
                }

                //##################################################################################
                //############################### CONDITION HANDLING ###############################
                //##################################################################################

                var conditions = abstractEffect.getConditions();
                ConditionEditorWindow.LayoutConditionEditor(conditions);

                //##################################################################################

                GUILayout.EndVertical();
            }
            var prevLabelSize = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 75;
            if (editors.ContainsKey(node))
            {
                editors[node].draw();
            }
            EditorGUIUtility.labelWidth = prevLabelSize;
        }
        protected void OnGUI()
        {
            if (conditionStyle == null)
            {
                conditionStyle = new GUIStyle(GUI.skin.box);
                conditionStyle.normal.background = TextureUtil.MakeTex(1, 1, new Color(0.627f, 0.627f, 0.627f));
            }

            if (eitherConditionStyle == null)
            {
                eitherConditionStyle = new GUIStyle(GUI.skin.box);
                eitherConditionStyle.normal.background = TextureUtil.MakeTex(1, 1, new Color(0.568f, 0.568f, 0.568f));
                eitherConditionStyle.padding.left      = 15;
            }

            if (closeStyle == null)
            {
                closeStyle                   = new GUIStyle(GUI.skin.button);
                closeStyle.padding           = new RectOffset(0, 0, 0, 0);
                closeStyle.margin            = new RectOffset(0, 5, 2, 0);
                closeStyle.normal.textColor  = Color.red;
                closeStyle.focused.textColor = Color.red;
                closeStyle.active.textColor  = Color.red;
                closeStyle.hover.textColor   = Color.red;
            }

            if (collapseStyle == null)
            {
                collapseStyle                   = new GUIStyle(GUI.skin.button);
                collapseStyle.padding           = new RectOffset(0, 0, 0, 0);
                collapseStyle.margin            = new RectOffset(0, 5, 2, 0);
                collapseStyle.normal.textColor  = Color.blue;
                collapseStyle.focused.textColor = Color.blue;
                collapseStyle.active.textColor  = Color.blue;
                collapseStyle.hover.textColor   = Color.blue;
            }

            using (new GUILayout.VerticalScope())
            {
                var previous = Milestone.getType();
                GUILayout.Label("The milestone will be reached when");
                Milestone.setType((Completable.Milestone.MilestoneType)EditorGUILayout.Popup((int)Milestone.getType(), milestonetypes));
                if (previous != Milestone.getType())
                {
                    Milestone.setId("");
                }

                switch (Milestone.getType())
                {
                case Completable.Milestone.MilestoneType.CHARACTER:
                    SelectElement <NPC>(Milestone, "Character:");
                    break;

                case Completable.Milestone.MilestoneType.ITEM:
                    SelectElement <Item>(Milestone, "Item:");
                    break;

                case Completable.Milestone.MilestoneType.SCENE:
                    SelectElement <IChapterTarget>(Milestone, "Scene:");
                    break;

                case Completable.Milestone.MilestoneType.COMPLETABLE:
                    SelectElement <Completable>(Milestone, "Completable:");
                    break;

                case Completable.Milestone.MilestoneType.CONDITION:
                    if (Milestone.getConditions() == null)
                    {
                        Milestone.setConditions(new ConditionsController(new Conditions()));
                    }

                    using (new GUILayout.VerticalScope(conditionStyle))
                    {
                        GUILayout.Label("CONDITIONS");
                        if (GUILayout.Button("Add Block"))
                        {
                            Milestone.getConditions().Conditions.Add(new FlagCondition(""));
                        }

                        //##################################################################################
                        //############################### CONDITION HANDLING ###############################
                        //##################################################################################

                        var conditions = Milestone.getConditions().Conditions;
                        ConditionEditorWindow.LayoutConditionEditor(conditions);

                        //##################################################################################
                    }

                    break;
                }

                if (GUILayout.Button("Save milestone"))
                {
                    this.Close();
                }
            }
        }
        void nodeWindow(int id)
        {
            AbstractEffect myEffect = this.effects.getEffects()[id];

            EffectEditor editor = null;

            editors.TryGetValue(myEffect, out editor);

            if (editor != null && editor.Collapsed)
            {
                if (GUILayout.Button(TC.get("GeneralText.Open")))
                {
                    editor.Collapsed = false;
                }
            }
            else
            {
                string[] editorNames = EffectEditorFactory.Intance.CurrentEffectEditors;

                GUILayout.BeginHorizontal();
                int preEditorSelected = EffectEditorFactory.Intance.EffectEditorIndex(myEffect);
                int editorSelected    = EditorGUILayout.Popup(preEditorSelected, editorNames);

                if (GUILayout.Button("-", collapseStyle, GUILayout.Width(15), GUILayout.Height(15)))
                {
                    editor.Collapsed = true;
                }
                if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
                {
                    effects.getEffects().Remove(myEffect);
                    return;
                }

                GUILayout.EndHorizontal();

                GUILayout.BeginVertical(conditionStyle);
                GUILayout.Label("CONDITIONS");
                if (GUILayout.Button("Add Block"))
                {
                    myEffect.getConditions().add(new FlagCondition(""));
                }

                if (editor == null || preEditorSelected != editorSelected)
                {
                    editor = EffectEditorFactory.Intance.createEffectEditorFor(editorNames[editorSelected]);

                    if (editors.ContainsKey(myEffect))
                    {
                        editor.Window = editors[myEffect].Window;
                        editors.Remove(myEffect);
                    }
                    else
                    {
                        editor.Window = tmpRects[myEffect];
                    }

                    editors.Add(editor.Effect, editor);
                    editor.Effect.setConditions(myEffect.getConditions());
                }

                //##################################################################################
                //############################### CONDITION HANDLING ###############################
                //##################################################################################

                var toRemove      = new List <Condition>();
                var listsToRemove = new List <List <Condition> >();
                var conditions    = editor.Effect.getConditions();
                ConditionEditorWindow.LayoutConditionEditor(conditions);

                //##################################################################################


                GUILayout.EndVertical();

                editor.draw();

                this.effects.getEffects()[id] = editor.Effect;

                if (Event.current.type != EventType.layout)
                {
                    Rect lastRect = GUILayoutUtility.GetLastRect();
                    Rect myRect   = editor.Window;
                    myRect.height = lastRect.y + lastRect.height;
                    editor.Window = myRect;
                    this.Repaint();
                }
            }

            GUI.DragWindow();
        }