private void InitWindows()
        {
            Rect previous = new Rect(0, 25, 0, 100);

            for (int i = 0; i < effects.getEffects().Count; i++)
            {
                AbstractEffect myEffect = this.effects.getEffects()[i];

                EffectEditor editor = EffectEditorFactory.Intance.createEffectEditorFor(myEffect);
                editor.Effect = myEffect;

                if (i > 0)
                {
                    previous = editors[effects.getEffects()[i - 1]].Window;
                }

                Rect current = new Rect(previous.x + previous.width + 35, previous.y, 150, 0);
                if (!tmpRects.ContainsKey(effects.getEffects()[i]))
                {
                    tmpRects.Add(effects.getEffects()[i], current);
                }

                editor.Window = current;

                editor.Effect.setConditions(myEffect.getConditions());
                editors.Add(editor.Effect, editor);
            }
        }
        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();
        }
示例#3
0
    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);
            }

            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;
                }
                else
                {
                    editor.Window = tmpRects[myEffect];
                }

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

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

            foreach (List <Condition> cl in myEffect.getConditions().getConditionsList())
            {
                if (cl.Count > 1)
                {
                    GUILayout.BeginVertical(eitherConditionStyle);
                }
                for (int i = 0; i < cl.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    int preConEdiSel = ConditionEditorFactory.Intance.ConditionEditorIndex(cl[i]);
                    int conEdiSel    = EditorGUILayout.Popup(preConEdiSel,
                                                             ConditionEditorFactory.Intance.CurrentConditionEditors);

                    if (preConEdiSel != conEdiSel)
                    {
                        cl[i] = ConditionEditorFactory.Intance.Editors[conEdiSel].InstanceManagedCondition();
                    }

                    ConditionEditorFactory.Intance.getConditionEditorFor(cl[i]).draw(cl[i]);

                    if (GUILayout.Button("+", collapseStyle, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        cl.Add(new FlagCondition(""));
                    }

                    if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        cl.Remove(cl[i]);

                        if (cl.Count == 0)
                        {
                            myEffect.getConditions().getConditionsList().Remove(cl);
                        }
                    }

                    GUILayout.EndHorizontal();
                }
                if (cl.Count > 1)
                {
                    GUILayout.EndVertical();
                }
            }

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


            GUILayout.EndVertical();

            editor.draw();

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


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

        GUI.DragWindow();
    }