internal static bool ShowAtPosition(ConditionsController con, Rect buttonRect)
        {
            long num = DateTime.Now.Ticks / 10000L;

            if (num >= ConditionEditorWindow.s_LastClosedTime + 50L)
            {
                if (Event.current != null)
                {
                    Event.current.Use();
                }
                if (lastDestroyConditions == null || con.Conditions != lastDestroyConditions)
                {
                    ConditionEditorWindow.s_ConditionEditor = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                }

                if (ConditionEditorWindow.s_ConditionEditor.Conditions == con.Conditions)
                {
                    DestroyImmediate(ConditionEditorWindow.s_ConditionEditor);
                    lastDestroyConditions = null;
                    return(false);
                }
                ConditionEditorWindow.s_ConditionEditor.Init(con, buttonRect);

                return(true);
            }
            return(false);
        }
Beispiel #2
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;
        }
        public void Init(Conditions con)
        {
            s_ConditionEditor            = EditorWindow.GetWindow <ConditionEditorWindow>();
            s_ConditionEditor.Conditions = con;

            ConditionEditorFactory.Intance.ResetInstance();
        }
        public void Init(Conditions con)
        {
            editor   = EditorWindow.GetWindow <ConditionEditorWindow>();
            editor.s = Color.black;

            editor.Conditions = con;

            ConditionEditorFactory.Intance.ResetInstance();
        }
        private void DoConditionsEditor(Rect rect, ConditionsController conditions)
        {
            var hasConditions = conditions.getBlocksCount() > 0;

            if (GUI.Button(rect, hasConditions ? conditionsTex : noConditionsTex, noBackgroundSkin.button))
            {
                ConditionEditorWindow.ShowAtPosition(conditions, new Rect(rect.x + rect.width, rect.y, 0, 0));
            }
        }
            public override void Draw(int aID)
            {
                var exit = Target as ExitDataControl;


                // Conditions
                GUILayout.Label(TC.get("Exit.EditConditions"));
                if (GUILayout.Button(exit.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                {
                    ConditionEditorWindow window =
                        (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                    window.Init(exit.getConditions());
                }

                GUILayout.Label(TC.get("Exit.ConditionsActive"));
                // Effects
                if (GUILayout.Button(TC.get("GeneralText.EditEffects")))
                {
                    EffectEditorWindow window = ScriptableObject.CreateInstance <EffectEditorWindow>();
                    window.Init(exit.getEffects());
                }

                // Post Effects
                if (GUILayout.Button(TC.get("Exit.EditPostEffects")))
                {
                    EffectEditorWindow window = ScriptableObject.CreateInstance <EffectEditorWindow>();
                    window.Init(exit.getPostEffects());
                }

                GUILayout.Label(TC.get("Exit.ConditionsInactive"));
                // HasNotEffets
                EditorGUI.BeginChangeCheck();
                var hasNotEffects = EditorGUILayout.BeginToggleGroup(TC.get("Exit.ActiveWhenConditionsArent"), exit.isHasNotEffects());

                if (EditorGUI.EndChangeCheck())
                {
                    exit.setHasNotEffects(hasNotEffects);
                }

                // Not Effects
                if (GUILayout.Button(TC.get("Exit.EditNotEffects")))
                {
                    EffectEditorWindow window = ScriptableObject.CreateInstance <EffectEditorWindow>();
                    window.Init(exit.getNotEffects());
                }

                EditorGUILayout.EndToggleGroup();
            }
Beispiel #7
0
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            descriptionRect      = new Rect(0f, 0.1f * windowHeight, windowWidth, 0.1f * windowHeight);
            rightPanelRect       = new Rect(0.9f * windowWidth, 0.2f * windowHeight, 0.08f * windowWidth, 0.15f * windowHeight);
            descriptionTableRect = new Rect(0f, 0.2f * windowHeight, 0.9f * windowWidth, 0.15f * windowHeight);
            settingsTable        = new Rect(0f, 0.35f * windowHeight, windowWidth, windowHeight * 0.65f);


            GUILayout.BeginArea(descriptionRect);
            GUILayout.Label(TC.get("Item.Documentation"));
            fullItemDescription = GUILayout.TextField(fullItemDescription);
            if (!fullItemDescription.Equals(fullItemDescriptionLast))
            {
                OnItemDescriptionChanged(fullItemDescription);
            }
            GUILayout.EndArea();

            /*
             * Desciptor table
             */
            GUILayout.BeginArea(descriptionTableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("DescriptionList.Descriptions"), GUILayout.Width(windowWidth * 0.44f));
            GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.44f));
            GUILayout.EndHorizontal();
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            for (int i = 0;
                 i <
                 Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                     GameRources.GetInstance().selectedItemIndex].getDescriptionController().getDescriptionCount();
                 i++)
            {
                if (i == selectedDescription)
                {
                    GUI.skin = selectedAreaSkin;
                }
                else
                {
                    GUI.skin = noBackgroundSkin;
                }

                tmpTex = (Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                              GameRources.GetInstance().selectedItemIndex].getDescriptionController()
                          .getDescriptionController(i)
                          .getConditionsController()
                          .getBlocksCount() > 0
                    ? conditionsTex
                    : noConditionsTex);

                GUILayout.BeginHorizontal();

                if (i == selectedDescription)
                {
                    if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                             GameRources.GetInstance().selectedItemIndex].getDescriptionController()
                                         .getDescriptionController(i)
                                         .getName(), GUILayout.Width(windowWidth * 0.44f)))
                    {
                        OnDescriptionSelectionChange(i);
                    }
                    if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.44f)))
                    {
                        ConditionEditorWindow window =
                            (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(
                            Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                GameRources.GetInstance().selectedItemIndex].getDescriptionController()
                            .getDescriptionController(i)
                            .getConditionsController());
                    }
                }
                else
                {
                    if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                             GameRources.GetInstance().selectedItemIndex].getDescriptionController()
                                         .getDescriptionController(i)
                                         .getName(), GUILayout.Width(windowWidth * 0.44f)))
                    {
                        OnDescriptionSelectionChange(i);
                    }
                    if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.44f)))
                    {
                        OnDescriptionSelectionChange(i);
                    }
                }
                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();



            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].getDescriptionController().addElement();
            }
            if (GUILayout.Button(duplicateTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].getDescriptionController().duplicateElement();
            }
            if (GUILayout.Button(clearTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].getDescriptionController().deleteElement();
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();



            /*
             * Properties panel
             */
            GUILayout.BeginArea(settingsTable);


            GUILayout.Label(TC.get("Item.Name"));
            GUILayout.BeginHorizontal();
            descriptionName = GUILayout.TextField(descriptionName, GUILayout.MaxWidth(0.6f * windowWidth));
            if (!descriptionName.Equals(descriptionNameLast))
            {
                OnDescriptionNameChanged(descriptionName);
            }
            if (!string.IsNullOrEmpty(descriptionSound))
            {
                audioTextureTmp = audioTexture;
            }
            else
            {
                audioTextureTmp = noAudioTexture;
            }
            GUILayout.Label(audioTextureTmp);
            GUILayout.Label(descriptionSound);
            if (GUILayout.Button(TC.get("Buttons.Select")))
            {
                ShowAssetChooser(AssetType.NAME_SOUND);
            }
            if (GUILayout.Button(clearTex))
            {
                OnDescriptorNameSoundChange("");
            }
            GUILayout.EndHorizontal();

            GUILayout.Label(TC.get("Item.Description"));
            GUILayout.BeginHorizontal();
            briefDescription = GUILayout.TextField(briefDescription, GUILayout.MaxWidth(0.6f * windowWidth));
            if (!briefDescription.Equals(briefDescriptionLast))
            {
                OnBriefDescriptionChanged(briefDescription);
            }
            if (!string.IsNullOrEmpty(briefDescriptionSound))
            {
                audioTextureTmp = audioTexture;
            }
            else
            {
                audioTextureTmp = noAudioTexture;
            }
            GUILayout.Label(audioTextureTmp);
            GUILayout.Label(briefDescriptionSound);
            if (GUILayout.Button(TC.get("Buttons.Select")))
            {
                ShowAssetChooser(AssetType.BRIEF_DESCRIPTION_SOUND);
            }
            if (GUILayout.Button(clearTex))
            {
                OnDescriptorBriefSoundChange("");
            }
            GUILayout.EndHorizontal();

            GUILayout.Label(TC.get("Item.DetailedDescription"));
            GUILayout.BeginHorizontal();
            detailedDescription = GUILayout.TextField(detailedDescription, GUILayout.MaxWidth(0.6f * windowWidth));
            if (!detailedDescription.Equals(detailedDescriptionLast))
            {
                OnDetailedDescriptionChanged(detailedDescription);
            }
            if (!string.IsNullOrEmpty(detailedDescriptionSound))
            {
                audioTextureTmp = audioTexture;
            }
            else
            {
                audioTextureTmp = noAudioTexture;
            }
            GUILayout.Label(audioTextureTmp);
            GUILayout.Label(detailedDescriptionSound);
            if (GUILayout.Button(TC.get("Buttons.Select")))
            {
                ShowAssetChooser(AssetType.DETAILED_DESCRIPTION_SOUND);
            }
            if (GUILayout.Button(clearTex))
            {
                OnDescriptorDetailedSoundChange("");
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.Label(TC.get("Item.ReturnsWhenDragged.Title"));
            GUILayout.Box(TC.get("Item.ReturnsWhenDragged.Description"));
            dragdropToogle = GUILayout.Toggle(dragdropToogle, TC.get("Item.ReturnsWhenDragged"));
            if (dragdropToogle != dragdropToogleLast)
            {
                OnDragAndDropToogleValueChange(dragdropToogle);
            }

            GUILayout.FlexibleSpace();

            GUILayout.Label(TC.get("Behaviour"));
            GUILayout.BeginHorizontal();
            selectedBehaviourType = EditorGUILayout.Popup(selectedBehaviourType, behaviourTypes,
                                                          GUILayout.MaxWidth(0.2f * windowWidth));
            if (selectedBehaviourType != selectedBehaviourTypeLast)
            {
                OnBehaviourChange(selectedBehaviourType);
            }
            GUILayout.Box(behaviourTypesDescription[selectedBehaviourType]);
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.Label(TC.get("Resources.TransitionTime"));
            GUILayout.Box(TC.get("Resources.TransitionTime.Description"));
            transitionTime = GUILayout.TextField(transitionTime);
            transitionTime = (Regex.Match(transitionTime, "^[0-9]{1,3}$").Success ? transitionTime : transitionTimeLast);
            if (!transitionTime.Equals(transitionTimeLast))
            {
                OnTransitionTimeChange(transitionTime);
            }


            GUILayout.EndArea();
        }
        public ScenesWindowExits(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor,
                                 params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, sceneEditor, aOptions)
        {
            new ExitTransitionComponent(Rect.zero, new GUIContent(""), aStyle);
            new ExitAppearanceComponent(Rect.zero, new GUIContent(""), aStyle);
            new ExitConditionsAndEffectsComponent(Rect.zero, new GUIContent(""), aStyle);
            new ExitPlayerPositionComponent(Rect.zero, new GUIContent(""), aStyle);

            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

            exitsList = new DataControlList()
            {
                RequestRepaint = Repaint,
                elementHeight  = 20,
                Columns        = new List <ColumnList.Column>()
                {
                    new ColumnList.Column() // Layer column
                    {
                        Text        = TC.get("ExitsList.NextScene"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column() // Enabled Column
                    {
                        Text        = TC.get("Conditions.Title"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    }
                },
                drawCell = (columnRect, row, column, isActive, isFocused) =>
                {
                    var element = exitsList.list[row] as ExitDataControl;
                    switch (column)
                    {
                    case 0:
                        if (isActive)
                        {
                            var selected = sceneNames.ToList().IndexOf(element.getNextSceneId());
                            EditorGUI.BeginChangeCheck();
                            var newId = sceneNames[EditorGUI.Popup(columnRect, selected == -1 ? 0 : selected, sceneNames)];
                            if (EditorGUI.EndChangeCheck())
                            {
                                element.setNextSceneId(newId == "---" ? "" : newId);
                            }
                        }
                        else
                        {
                            GUI.Label(columnRect, element.getNextSceneId());
                        }
                        break;

                    case 1:
                        if (GUI.Button(columnRect, element.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                        {
                            exitsList.index = row;
                            ConditionEditorWindow window =
                                (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                            window.Init(element.getConditions());
                        }
                        break;
                    }
                },
                onSelectCallback = (list) =>
                {
                    sceneEditor.SelectedElement = exitsList.list[list.index] as ExitDataControl;
                },
                onRemoveCallback = (list) =>
                {
                    sceneEditor.SelectedElement = null;
                }
            };

            sceneEditor.onSelectElement += (element) =>
            {
                if (element is ExitDataControl)
                {
                    exitsList.index = exitsList.list.IndexOf(element as ExitDataControl);
                }
                else
                {
                    exitsList.index = -1;
                }
            };
        }
Beispiel #9
0
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            tableRect            = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, windowHeight * 0.33f);
            rightPanelRect       = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.33f * windowHeight);
            infoPreviewRect      = new Rect(0f, 0.65f * windowHeight, windowWidth, windowHeight * 0.05f);
            previewRect          = new Rect(0f, 0.7f * windowHeight, windowWidth, windowHeight * 0.25f);
            actionRect           = new Rect(0f, 0.45f * windowHeight, 0.9f * windowWidth, windowHeight * 0.2f);
            actionRightPanelRect = new Rect(0.9f * windowWidth, 0.45f * windowHeight, 0.1f * windowWidth, windowHeight * 0.2f);

            GUILayout.BeginArea(tableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("ActiveAreasList.Id"), GUILayout.Width(windowWidth * 0.54f));
            GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.14f));
            GUILayout.Box(TC.get("ActiveAreasList.Documentation"), GUILayout.Width(windowWidth * 0.18f));
            GUILayout.EndHorizontal();
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0;
                 i <
                 Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                     GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreasList().Count;
                 i++)
            {
                if (i == selectedArea)
                {
                    GUI.skin = selectedAreaSkin;
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                         GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreasList()[i].getId(),
                                     GUILayout.Width(windowWidth * 0.54f)))
                {
                    OnSelectionChanged(i);
                }

                if (GUILayout.Button(conditionTex, GUILayout.Width(windowWidth * 0.14f)))
                {
                    OnSelectionChanged(i);

                    ConditionEditorWindow window =
                        (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                    window.Init(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreasList()[i]
                                .getConditions());
                }
                if (GUILayout.Button(TC.get("GeneralText.EditDocumentation"), GUILayout.Width(windowWidth * 0.18f)))
                {
                    OnSelectionChanged(i);
                }

                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();



            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTexture, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                ActiveAreaNewName window =
                    (ActiveAreaNewName)ScriptableObject.CreateInstance(typeof(ActiveAreaNewName));
                window.Init(this, "IdObject");
            }
            if (GUILayout.Button(duplicateImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList()
                .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                      GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]);
            }
            if (GUILayout.Button(moveUp, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList()
                .moveElementUp(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]);
            }
            if (GUILayout.Button(moveDown, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList()
                .moveElementDown(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                     GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]);
            }
            if (GUILayout.Button(clearImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList()
                .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea],
                               false);
                if (selectedArea >= 0)
                {
                    selectedArea--;
                }
                if (selectedAction >= 0)
                {
                    selectedAction--;
                }
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();

            /**
             * ACTION EDITOR
             */
            GUILayout.BeginArea(actionRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("Element.Action"), GUILayout.Width(windowWidth * 0.39f));
            GUILayout.Box(TC.get("ActionsList.NeedsGoTo"), GUILayout.Width(windowWidth * 0.39f));
            GUILayout.Box(TC.get("Element.Effects") + "/" + TC.get("SmallAction.Conditions"), GUILayout.Width(windowWidth * 0.1f));
            GUILayout.EndHorizontal();
            scrollPositionAction = GUILayout.BeginScrollView(scrollPositionAction, GUILayout.ExpandWidth(false));
            if (selectedArea >= 0)
            {
                // Action table
                for (int i = 0;
                     i < Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                         GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]
                     .getActionsList().getActions().Count;
                     i++)
                {
                    if (i == selectedAction)
                    {
                        GUI.skin = selectedAreaSkin;
                    }
                    else
                    {
                        GUI.skin = noBackgroundSkin;
                    }

                    GUILayout.BeginHorizontal();
                    if (i == selectedAction)
                    {
                        GUILayout.Label(
                            Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                selectedArea
                            ].getActionsList().getActions()[i].getTypeName(),
                            GUILayout.Width(windowWidth * 0.39f));
                        if (Controller.getInstance().playerMode() == Controller.FILE_ADVENTURE_1STPERSON_PLAYER)
                        {
                            if (GUILayout.Button(TC.get("ActionsList.NotRelevant"), GUILayout.Width(windowWidth * 0.39f)))
                            {
                                selectedAction = i;
                            }
                        }
                        else
                        {
                            GUILayout.BeginHorizontal(GUILayout.Width(windowWidth * 0.39f));
                            Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                selectedArea].getActionsList().getActions()[i].setNeedsGoTo(
                                GUILayout.Toggle(
                                    Controller.getInstance()
                                    .getSelectedChapterDataControl()
                                    .getScenesList()
                                    .getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getActiveAreasList()
                                    .getActiveAreas()[selectedArea].getActionsList().getActions()[i]
                                    .getNeedsGoTo(), ""));
                            Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                selectedArea].getActionsList().getActions()[i].setKeepDistance(
                                EditorGUILayout.IntField(
                                    Controller.getInstance()
                                    .getSelectedChapterDataControl()
                                    .getScenesList()
                                    .getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getActiveAreasList()
                                    .getActiveAreas()[selectedArea].getActionsList().getActions()[i]
                                    .getKeepDistance()));

                            GUILayout.EndHorizontal();
                        }


                        GUILayout.BeginVertical();
                        if (GUILayout.Button(TC.get("ActiveAreasList.Conditions"), GUILayout.Width(windowWidth * 0.1f)))
                        {
                            ConditionEditorWindow window =
                                (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                            window.Init(
                                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                    selectedArea
                                ].getActionsList().getActions()[i].getConditions());
                        }
                        if (GUILayout.Button(TC.get("Element.Effects"), GUILayout.Width(windowWidth * 0.1f)))
                        {
                            EffectEditorWindow window =
                                (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                            window.Init(
                                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                    selectedArea
                                ].getActionsList().getActions()[i].getEffects());
                        }
                        if (GUILayout.Button(TC.get("SmallAction.EditNotEffects"), GUILayout.Width(windowWidth * 0.1f)))
                        {
                            EffectEditorWindow window =
                                (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                            window.Init(
                                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                    selectedArea
                                ].getActionsList().getActions()[i].getNotEffectsController());
                        }
                        GUILayout.EndVertical();
                    }
                    else
                    {
                        if (
                            GUILayout.Button(
                                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                    selectedArea].getActionsList().getActions()[i].getTypeName(),
                                GUILayout.Width(windowWidth * 0.39f)))
                        {
                            selectedAction = i;
                        }

                        if (Controller.getInstance().playerMode() == Controller.FILE_ADVENTURE_1STPERSON_PLAYER)
                        {
                            if (GUILayout.Button(TC.get("ActionsList.NotRelevant"), GUILayout.Width(windowWidth * 0.39f)))
                            {
                                selectedAction = i;
                            }
                        }
                        else
                        {
                            if (
                                GUILayout.Button(
                                    Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[
                                        selectedArea].getActionsList().getActions()[i].getNeedsGoTo().ToString(),
                                    GUILayout.Width(windowWidth * 0.39f)))
                            {
                                selectedAction = i;
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUI.skin = defaultSkin;
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();

            /*
             * Right action panel
             */
            GUILayout.BeginArea(actionRightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTexture, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                addMenu.menu.ShowAsContext();
            }
            if (GUILayout.Button(duplicateImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]
                .getActionsList()
                .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                      GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]
                                  .getActionsList().getActions()[selectedAction]);
            }
            if (GUILayout.Button(clearImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]
                .getActionsList()
                .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getActiveAreasList().getActiveAreas()[selectedArea]
                               .getActionsList().getActions()[selectedAction], false);
                if (selectedAction >= 0)
                {
                    selectedAction--;
                }
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();



            if (backgroundPath != "")
            {
                GUILayout.BeginArea(infoPreviewRect);
                // Show preview dialog
                if (GUILayout.Button(TC.get("DefaultClickAction.ShowDetails") + "/" + TC.get("GeneralText.Edit")))
                {
                    ActiveAreasEditor window =
                        (ActiveAreasEditor)ScriptableObject.CreateInstance(typeof(ActiveAreasEditor));
                    window.Init(this, Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex], selectedArea);
                }
                GUILayout.EndArea();
                GUI.DrawTexture(previewRect, backgroundPreviewTex, ScaleMode.ScaleToFit);
            }
            else
            {
                GUILayout.BeginArea(infoPreviewRect);
                GUILayout.Button("No background!");
                GUILayout.EndArea();
            }
        }
        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();
                }
            }
        }
        public override void Draw(int aID)
        {
            if (GameRources.GetInstance().selectedSceneIndex >= 0)
            {
                currentIndex = GameRources.GetInstance().selectedSceneIndex;
                currentScene = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[currentIndex];
            }

            if (currentScene == null)
            {
                if (GameRources.GetInstance().selectedSceneIndex >= 0 && currentIndex != GameRources.GetInstance().selectedSceneIndex)
                {
                    currentIndex = GameRources.GetInstance().selectedSceneIndex;
                    currentScene = Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[currentIndex];
                }
                else
                {
                    return;
                }
            }

            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            tableRect       = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, windowHeight * 0.33f);
            rightPanelRect  = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.33f * windowHeight);
            infoPreviewRect = new Rect(0f, 0.45f * windowHeight, windowWidth, windowHeight * 0.05f);
            previewRect     = new Rect(0f, 0.5f * windowHeight, windowWidth, windowHeight * 0.45f);

            GUILayout.BeginArea(tableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("ElementList.Layer"), GUILayout.Width(windowWidth * 0.12f));
            GUILayout.Box("", GUILayout.Width(windowWidth * 0.06f));
            GUILayout.Box(TC.get("ElementList.Title"), GUILayout.Width(windowWidth * 0.39f));
            GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.29f));
            GUILayout.EndHorizontal();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            int i = 0;

            foreach (ElementContainer element in currentScene.getReferencesList().getAllReferencesDataControl())
            {
                if (element == selectedElement)
                {
                    GUI.skin = selectedElementSkin;
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(element.getLayer().ToString(), GUILayout.Width(windowWidth * 0.12f)))
                {
                    selectedElement = element;
                }

                if (element.getErdc() != null)
                {
                    // FOR ELEMENT ERDC
                    element.getErdc().setVisible(GUILayout.Toggle(element.getErdc().isVisible(), "", GUILayout.Width(windowWidth * 0.06f)));
                    if (GUILayout.Button(element.getErdc().getElementId(), GUILayout.Width(windowWidth * 0.39f)))
                    {
                        selectedElement = element;
                    }

                    if (GUILayout.Button(conditionTex, GUILayout.Width(windowWidth * 0.29f)))
                    {
                        selectedElement = element;
                        ConditionEditorWindow window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                        window.Init(element.getErdc().getConditions());
                    }
                }
                else
                {
                    if (GUILayout.Button("", GUILayout.Width(windowWidth * 0.06f)))
                    {
                        selectedElement = element;
                    }
                    if (GUILayout.Button("", GUILayout.Width(windowWidth * 0.39f)))
                    {
                        selectedElement = element;
                    }
                    if (GUILayout.Button(conditionTex, GUILayout.Width(windowWidth * 0.29f)))
                    {
                        selectedElement = element;
                    }
                }


                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();


            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTexture, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                addMenu.menu.ShowAsContext();
            }
            if (GUILayout.Button(moveUp, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                currentScene.getReferencesList().moveElementUp(selectedElement.getErdc());
            }
            if (GUILayout.Button(moveDown, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                currentScene.getReferencesList().moveElementDown(selectedElement.getErdc());
            }
            if (GUILayout.Button(clearImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                currentScene.getReferencesList().deleteElement(selectedElement.getErdc(), false);
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();


            if (backgroundPath != "")
            {
                GUILayout.BeginArea(infoPreviewRect);
                // Show preview dialog
                // Button visible only is there is at least 1 object
                if (currentScene != null && selectedElement != null)
                {
                    if (GUILayout.Button(TC.get("DefaultClickAction.ShowDetails") + "/" + TC.get("GeneralText.Edit")))
                    {
                        ObjectInSceneRefrencesEditor window = ScriptableObject.CreateInstance <ObjectInSceneRefrencesEditor>();
                        window.Init(this, currentScene, currentScene.getReferencesList().getAllReferencesDataControl().IndexOf(selectedElement));
                    }
                }
                GUILayout.EndArea();
                GUI.DrawTexture(previewRect, backgroundPreviewTex, ScaleMode.ScaleToFit);
            }
            else
            {
                GUILayout.BeginArea(infoPreviewRect);
                GUILayout.Button("No background!");
                GUILayout.EndArea();
            }
        }
        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();
        }
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            timerTableRect = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, 0.2f * windowHeight);
            rightPanelRect = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.2f * windowHeight);
            settingsTable  = new Rect(0f, 0.3f * windowHeight, windowWidth, windowHeight * 0.65f);

            /*
             * Timer table
             */
            GUILayout.BeginArea(timerTableRect);

            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("TimersList.Timer"), GUILayout.MaxWidth(windowWidth * 0.3f));
            GUILayout.Box(TC.get("TimersList.Time"), GUILayout.MaxWidth(windowWidth * 0.3f));
            GUILayout.Box(TC.get("TimersList.Display"), GUILayout.MaxWidth(windowWidth * 0.3f));
            GUILayout.EndHorizontal();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0;
                 i < Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers().Count;
                 i++)
            {
                if (i == selectedTimer)
                {
                    GUI.skin = selectedAreaSkin;
                }
                else
                {
                    GUI.skin = noBackgroundSkin;
                }

                GUILayout.BeginHorizontal();

                if (i == selectedTimer)
                {
                    if (GUILayout.Button("Timer #" + i, GUILayout.MaxWidth(windowWidth * 0.3f)))
                    {
                        OnTimerSelectedChange(i);
                    }

                    timerTime = GUILayout.TextField(timerTime, GUILayout.MaxWidth(windowWidth * 0.3f));
                    timerTime = (Regex.Match(timerTime, "^[0-9]{1,4}$").Success ? timerTime : timerTimeLast);
                    if (timerTime != timerTimeLast)
                    {
                        OnTimerTime(timerTime);
                    }

                    Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[i].setShowTime(GUILayout
                                                                                                                        .Toggle(
                                                                                                                            Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[i]
                                                                                                                            .isShowTime(),
                                                                                                                            "", GUILayout.MaxWidth(windowWidth * 0.3f)));
                }
                else
                {
                    if (GUILayout.Button("Timer #" + i, GUILayout.MaxWidth(windowWidth * 0.3f)))
                    {
                        OnTimerSelectedChange(i);
                    }
                    if (
                        GUILayout.Button(
                            Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[i].getTime()
                            .ToString(), GUILayout.MaxWidth(windowWidth * 0.3f)))
                    {
                        OnTimerSelectedChange(i);
                    }
                    if (
                        GUILayout.Button(
                            Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[i].isShowTime().ToString(), GUILayout.MaxWidth(windowWidth * 0.3f)))
                    {
                        OnTimerSelectedChange(i);
                    }
                }
                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }

            GUILayout.EndScrollView();

            GUILayout.EndArea();

            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getTimersList().addElement(Controller.TIMER, "");
            }
            if (GUILayout.Button(duplicateTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList()
                .duplicateElement(
                    Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[selectedTimer]);
            }
            if (GUILayout.Button(clearTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList()
                .deleteElement(
                    Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[selectedTimer],
                    false);
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();

            /*
             * Properties panel
             */

            if (selectedTimer != -1 &&
                Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[selectedTimer] != null)
            {
                GUILayout.BeginArea(settingsTable);

                GUILayout.Label(TC.get("Timer.Documentation"));
                fullTimerDescription = GUILayout.TextArea(fullTimerDescription, GUILayout.MinHeight(0.1f * windowHeight));
                if (fullTimerDescription != fullTimerDescriptionLast)
                {
                    OnTimerDocumentationChanged(fullTimerDescription);
                }


                GUILayout.FlexibleSpace();


                GUILayout.Label(TC.get("TimersList.Time"));

                GUILayout.BeginHorizontal();
                if (
                    !Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[selectedTimer]
                    .isShowTime())
                {
                    GUI.enabled = false;
                }
                GUILayout.Label(TC.get("Timer.DisplayName"));
                displayName = GUILayout.TextField(displayName);
                if (displayName != displayNameLast)
                {
                    OnTimerDisplayNameChanged(displayName);
                }

                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList().getTimers()[selectedTimer].setCountDown(GUILayout.Toggle(Controller.getInstance()
                                                                                          .getSelectedChapterDataControl()
                                                                                          .getTimersList().getTimers()[selectedTimer].isCountDown(), TC.get("Timer.CountDown")));

                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList().getTimers()[selectedTimer].setShowWhenStopped(GUILayout.Toggle(Controller.getInstance()
                                                                                                .getSelectedChapterDataControl()
                                                                                                .getTimersList().getTimers()[selectedTimer].isShowWhenStopped(), TC.get("Timer.ShowWhenStopped")));
                GUI.enabled = true;
                GUILayout.EndHorizontal();


                GUILayout.FlexibleSpace();


                GUILayout.Label(TC.get("Timer.LoopControl"));
                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList().getTimers()[selectedTimer].setMultipleStarts(GUILayout.Toggle(Controller.getInstance()
                                                                                               .getSelectedChapterDataControl()
                                                                                               .getTimersList().getTimers()[selectedTimer].isMultipleStarts(), TC.get("Timer.MultipleStarts")));
                GUILayout.Label(TC.get("Timer.MultipleStartsDesc"), smallFontStyle);
                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList().getTimers()[selectedTimer].setRunsInLoop(GUILayout.Toggle(Controller.getInstance()
                                                                                           .getSelectedChapterDataControl()
                                                                                           .getTimersList().getTimers()[selectedTimer].isRunsInLoop(), TC.get("Timer.RunsInLoop")));
                GUILayout.Label(
                    TC.get("Timer.RunsInLoopDesc"), smallFontStyle);


                GUILayout.FlexibleSpace();


                GUILayout.Label(TC.get("Timer.InitConditions"));
                if (GUILayout.Button(TC.get("GeneralText.EditInitConditions")))
                {
                    ConditionEditorWindow window =
                        (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                    window.Init(Controller.getInstance()
                                .getSelectedChapterDataControl()
                                .getTimersList().getTimers()[selectedTimer].getInitConditions());
                }


                GUILayout.FlexibleSpace();


                GUILayout.Label(TC.get("Timer.EndConditions"));
                Controller.getInstance()
                .getSelectedChapterDataControl()
                .getTimersList().getTimers()[selectedTimer].setUsesEndCondition(
                    GUILayout.Toggle(Controller.getInstance()
                                     .getSelectedChapterDataControl()
                                     .getTimersList().getTimers()[selectedTimer].isUsesEndCondition(),
                                     TC.get("Timer.UsesEndConditionShort")));
                if (
                    !Controller.getInstance().getSelectedChapterDataControl().getTimersList().getTimers()[selectedTimer]
                    .isUsesEndCondition())
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button(TC.get("GeneralText.EditEndConditions")))
                {
                    ConditionEditorWindow window =
                        (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                    window.Init(Controller.getInstance()
                                .getSelectedChapterDataControl()
                                .getTimersList().getTimers()[selectedTimer].getEndConditions());
                }
                GUI.enabled = true;


                GUILayout.FlexibleSpace();


                GUILayout.BeginHorizontal();
                GUILayout.Label(TC.get("Timer.Effects"), GUILayout.Width(0.45f * windowWidth));
                GUILayout.Label(TC.get("Timer.PostEffects"), GUILayout.Width(0.45f * windowWidth));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(TC.get("GeneralText.EditEffects"), GUILayout.Width(0.45f * windowWidth)))
                {
                    EffectEditorWindow window =
                        (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                    window.Init(Controller.getInstance()
                                .getSelectedChapterDataControl()
                                .getTimersList().getTimers()[selectedTimer].getEffects());
                }
                if (GUILayout.Button(TC.get("GeneralText.EditPostEffects"), GUILayout.Width(0.45f * windowWidth)))
                {
                    EffectEditorWindow window =
                        (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                    window.Init(Controller.getInstance()
                                .getSelectedChapterDataControl()
                                .getTimersList().getTimers()[selectedTimer].getPostEffects());
                }
                GUILayout.EndHorizontal();

                GUILayout.EndArea();
            }
        }
Beispiel #14
0
        public void draw()
        {
            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;
            }

            GUIStyle style = new GUIStyle();

            style.padding = new RectOffset(5, 5, 5, 5);

            EditorGUILayout.BeginVertical();

            EditorGUILayout.HelpBox(TC.get("ConversationEditor.AtLeastOne"), MessageType.None);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Question ID: ");
            //Controller.getInstance ().getIdentifierSummary ().add
            myNode.setXApiQuestion(EditorGUILayout.TextField(myNode.getXApiQuestion()));
            if (myNode.getXApiQuestion() == "")
            {
                var lastRect = GUILayoutUtility.GetLastRect();
                var guistyle = new GUIStyle(GUI.skin.label);
                guistyle.normal.textColor = Color.gray;
                GUI.Label(lastRect, " Required for analytics", guistyle);
            }
            GUILayout.EndHorizontal();
            bool infoShown = false;

            if (myNode.getLineCount() > 0)
            {
                bool isScrolling = false;

                if (myNode.getLineCount() > 10)
                {
                    scroll      = EditorGUILayout.BeginScrollView(scroll, GUILayout.MinWidth(360), GUILayout.Height(190));
                    isScrolling = true;
                }

                for (int i = 0; i < myNode.getLineCount(); i++)
                {
                    EditorGUILayout.BeginHorizontal();

                    bool showInfo = false;

                    EditorGUIUtility.labelWidth = GUI.skin.label.CalcSize(new GUIContent((i + 1) + ": ")).x;
                    myNode.getLine(i).setText(EditorGUILayout.TextField((i + 1) + ": ", myNode.getLine(i).getText(), GUILayout.Width(200)));
                    myNode.getLine(i).setXApiCorrect(EditorGUILayout.Toggle(myNode.getLine(i).getXApiCorrect()));
                    GUILayout.Space(5);

                    tmpTex = (myNode.getLine(i).getConditions().getConditionsList().Count > 0
                        ? conditionsTex
                        : noConditionsTex);

                    if (GUILayout.Button(tmpTex, noBackgroundSkin.button, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(myNode.getLine(i).getConditions());
                    }

                    if (GUILayout.Button(linkTex, noBackgroundSkin.button, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        parent.startSetChild(this.myNode, i);
                    }


                    if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        myNode.removeLine(i);
                        myNode.removeChild(i);
                    }
                    ;
                    EditorGUILayout.EndHorizontal();
                }
                if (isScrolling)
                {
                    EditorGUILayout.EndScrollView();
                }
            }

            EditorGUILayout.BeginHorizontal();
            GUIContent bttext = new GUIContent(TC.get("ConversationEditor.AddOptionChild"));
            Rect       btrect = GUILayoutUtility.GetRect(bttext, style);

            if (GUI.Button(btrect, bttext))
            {
                myNode.addLine(new ConversationLine("Player", ""));
                parent.addChild(this.myNode, new DialogueConversationNode());
            }
            ;

            tmpTex = (myNode.getEffects().getEffects().Count > 0
                ? effectTex
                : noEffectTex);
            if (GUILayout.Button(tmpTex, noBackgroundSkin.button, GUILayout.Width(24), GUILayout.Height(24)))
            {
                EffectEditorWindow window = (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                window.Init(myNode.getEffects());
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            actionTableRect = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, 0.5f * windowHeight);
            rightPanelRect  = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.5f * windowHeight);
            descriptionRect = new Rect(0f, 0.6f * windowHeight, 0.95f * windowWidth, 0.2f * windowHeight);
            effectsRect     = new Rect(0f, 0.8f * windowHeight, windowWidth, windowHeight * 0.15f);

            GUILayout.BeginArea(actionTableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("Element.Action"), GUILayout.Width(windowWidth * 0.39f));
            GUILayout.Box(TC.get("ActionsList.NeedsGoTo"), GUILayout.Width(windowWidth * 0.39f));
            GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.1f));
            GUILayout.EndHorizontal();
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandWidth(false));

            // Action table
            for (int i = 0;
                 i <
                 Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                     GameRources.GetInstance().selectedItemIndex].getActionsList().getActions().Count;
                 i++)
            {
                if (i == selectedAction)
                {
                    GUI.skin = selectedAreaSkin;
                }
                else
                {
                    GUI.skin = noBackgroundSkin;
                }

                tmpTex = (Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                              GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].getConditions()
                          .getBlocksCount() > 0
                    ? conditionsTex
                    : noConditionsTex);

                GUILayout.BeginHorizontal();
                if (i == selectedAction)
                {
                    int t = Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                        GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].getType();

                    if (t == Controller.ACTION_USE_WITH || t == Controller.ACTION_GIVE_TO || t == Controller.ACTION_DRAG_TO)
                    {
                        selectedTarget =
                            EditorGUILayout.Popup(
                                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                    GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i]
                                .getTypeName(),
                                selectedTarget, joinedNamesList,
                                GUILayout.Width(windowWidth * 0.39f));
                        if (selectedTarget != selectedTargetLast)
                        {
                            ChangeActionTarget(selectedTarget);
                        }
                    }
                    else
                    {
                        GUILayout.Label(
                            Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].getTypeName(),
                            GUILayout.Width(windowWidth * 0.39f));
                    }


                    if (Controller.getInstance().playerMode() == Controller.FILE_ADVENTURE_1STPERSON_PLAYER)
                    {
                        if (GUILayout.Button(TC.get("ActionsList.NotRelevant"), GUILayout.Width(windowWidth * 0.39f)))
                        {
                            OnActionSelectionChange(i);
                        }
                    }
                    else
                    {
                        GUILayout.BeginHorizontal(GUILayout.Width(windowWidth * 0.39f));

                        Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                            GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].setNeedsGoTo(
                            GUILayout.Toggle(
                                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                    GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i]
                                .getNeedsGoTo(), ""));
                        Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                            GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].setKeepDistance(
                            EditorGUILayout.IntField(
                                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                    GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i]
                                .getKeepDistance()));

                        GUILayout.EndHorizontal();
                    }

                    if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.1f)))
                    {
                        ConditionEditorWindow window =
                            (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                        GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].getConditions());
                    }
                }
                else
                {
                    if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                             GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i].getTypeName(),
                                         GUILayout.Width(windowWidth * 0.39f)))
                    {
                        OnActionSelectionChange(i);
                    }


                    if (Controller.getInstance().playerMode() == Controller.FILE_ADVENTURE_1STPERSON_PLAYER)
                    {
                        if (GUILayout.Button(TC.get("ActionsList.NotRelevant"), GUILayout.Width(windowWidth * 0.39f)))
                        {
                            OnActionSelectionChange(i);
                        }
                    }
                    else
                    {
                        if (
                            GUILayout.Button(
                                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                    GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[i]
                                .getNeedsGoTo().ToString(), GUILayout.Width(windowWidth * 0.39f)))
                        {
                            OnActionSelectionChange(i);
                        }
                    }
                    if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.1f)))
                    {
                        OnActionSelectionChange(i);
                    }
                }
                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                addMenu.menu.ShowAsContext();
            }
            if (GUILayout.Button(duplicateTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].getActionsList()
                .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                      GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[selectedAction]);
            }
            //if (GUILayout.Button(moveUp, GUILayout.MaxWidth(0.08f * windowWidth)))
            //{
            //    Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
            //      GameRources.GetInstance().selectedItemIndex].getActionsList().moveElementUp(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
            //          GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[selectedAction]);
            //}
            //if (GUILayout.Button(moveDown, GUILayout.MaxWidth(0.08f * windowWidth)))
            //{
            //    Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
            //      GameRources.GetInstance().selectedItemIndex].getActionsList().moveElementDown(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
            //          GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[selectedAction]);
            //}
            if (GUILayout.Button(clearTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].getActionsList()
                .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                   GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[selectedAction], false);
                if (selectedAction >= 0)
                {
                    selectedAction--;
                }
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();

            GUILayout.BeginArea(descriptionRect);
            GUILayout.Label(TC.get("Action.Documentation"));
            GUILayout.Space(20);
            documentation = GUILayout.TextArea(documentation);
            if (!documentation.Equals(documentationLast))
            {
                OnDocumentationChanged(documentation);
            }
            GUILayout.EndArea();

            GUILayout.BeginArea(effectsRect);
            if (selectedAction < 0)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button(TC.get("Element.Effects")))
            {
                EffectEditorWindow window =
                    (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                window.Init(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                GameRources.GetInstance().selectedItemIndex].getActionsList().getActions()[selectedAction].getEffects());
            }
            GUI.enabled = true;
            GUILayout.EndArea();
        }
Beispiel #16
0
        public AdvancedFeaturesWindowGlobalStates(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, aOptions)
        {
            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

            globalStateList = new DataControlList()
            {
                RequestRepaint = Repaint,
                footerHeight   = 25,
                elementHeight  = 40,
                Columns        = new System.Collections.Generic.List <ColumnList.Column>()
                {
                    new ColumnList.Column()
                    {
                        Text        = TC.get("GlobalStatesList.ID"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.Width(150) }
                    },
                    new ColumnList.Column()
                    {
                        Text        = TC.get("GlobalState.Documentation"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column()
                    {
                        Text        = TC.get("GlobalState.Conditions"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.Width(220) }
                    }
                },
                drawCell = (rect, index, column, isActive, isFocused) =>
                {
                    var globalState = globalStateList.list[index] as GlobalStateDataControl;
                    switch (column)
                    {
                    case 0:
                        EditorGUI.BeginChangeCheck();
                        var id = EditorGUI.DelayedTextField(rect, globalState.getId());
                        if (EditorGUI.EndChangeCheck())
                        {
                            globalState.setId(id);
                        }
                        break;

                    case 1:
                        EditorGUI.BeginChangeCheck();
                        var documentation = EditorGUI.TextArea(rect, globalState.getDocumentation() ?? string.Empty);
                        if (EditorGUI.EndChangeCheck())
                        {
                            globalState.setDocumentation(documentation);
                        }
                        break;

                    case 2:
                        if (GUI.Button(rect, globalState.getController().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                        {
                            ConditionEditorWindow window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                            window.Init(globalState.getController());
                        }
                        break;
                    }
                }
            };
        }
Beispiel #17
0
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            tableRect       = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, windowHeight * 0.33f);
            rightPanelRect  = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.33f * windowHeight);
            infoPreviewRect = new Rect(0f, 0.45f * windowHeight, windowWidth, windowHeight * 0.05f);
            previewRect     = new Rect(0f, 0.5f * windowHeight, windowWidth, windowHeight * 0.45f);

            GUILayout.BeginArea(tableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("Barrier.Title"), GUILayout.Width(windowWidth * 0.45f));
            GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.45f));
            GUILayout.EndHorizontal();
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0;
                 i <
                 Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                     GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriersList().Count;
                 i++)
            {
                if (i == selectedArea)
                {
                    GUI.skin = selectedAreaSkin;
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                         GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriersList()[i].getId(),
                                     GUILayout.Width(windowWidth * 0.44f)))
                {
                    selectedArea = i;
                }

                if (GUILayout.Button(conditionTex, GUILayout.Width(windowWidth * 0.44f)))
                {
                    selectedArea = i;
                    ConditionEditorWindow window =
                        (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                    window.Init(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriersList()[i].getConditions());
                }

                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();



            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTexture, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                BarrierNewName window =
                    (BarrierNewName)ScriptableObject.CreateInstance(typeof(BarrierNewName));
                window.Init(this, "IdBarrier");
            }
            if (GUILayout.Button(duplicateImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getBarriersList()
                .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                      GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriers()[selectedArea]);
            }
            if (GUILayout.Button(moveUp, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getBarriersList()
                .moveElementUp(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriers()[selectedArea]);
            }
            if (GUILayout.Button(moveDown, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getBarriersList()
                .moveElementDown(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                     GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriers()[selectedArea]);
            }
            if (GUILayout.Button(clearImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getBarriersList()
                .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getBarriersList().getBarriers()[selectedArea],
                               false);
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();


            if (backgroundPath != "")
            {
                GUILayout.BeginArea(infoPreviewRect);
                // Show preview dialog
                if (GUILayout.Button(TC.get("DefaultClickAction.ShowDetails") + "/" + TC.get("GeneralText.Edit")))
                {
                    //
                    BarrierEditor window =
                        (BarrierEditor)ScriptableObject.CreateInstance(typeof(BarrierEditor));
                    window.Init(this, Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex], selectedArea);
                }
                GUILayout.EndArea();
                GUI.DrawTexture(previewRect, backgroundPreviewTex, ScaleMode.ScaleToFit);
            }
            else
            {
                GUILayout.BeginArea(infoPreviewRect);
                GUILayout.Button("No background!");
                GUILayout.EndArea();
            }
        }
        public void draw()
        {
            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 (buttonstyle == null)
            {
                buttonstyle         = new GUIStyle();
                buttonstyle.padding = new RectOffset(5, 5, 5, 5);
            }

            GUIStyle style = new GUIStyle();

            style.padding = new RectOffset(5, 5, 5, 5);

            EditorGUILayout.BeginVertical();

            EditorGUILayout.HelpBox(TC.get("ConversationEditor.AtLeastOne"), MessageType.None);
            bool infoShown = false;

            if (myNode.getLineCount() > 0)
            {
                bool isScrolling = false;

                if (myNode.getLineCount() > 10)
                {
                    scroll      = EditorGUILayout.BeginScrollView(scroll, GUILayout.MinWidth(360), GUILayout.Height(190));
                    isScrolling = true;
                }

                for (int i = 0; i < myNode.getLineCount(); i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    //myNode.getLine(i).IsEntityFragment = EditorGUILayout.Toggle("Is entity: ", frg.IsEntityFragment);

                    bool showInfo = false;
                    EditorGUIUtility.labelWidth = GUI.skin.label.CalcSize(new GUIContent(TC.get("ConversationEditor.Speaker"))).x;
                    myNode.getLine(i).setName(npc[EditorGUILayout.Popup(TC.get("ConversationEditor.Speaker"), npc.IndexOf(myNode.getLine(i).getName()), npc.ToArray())]);

                    EditorGUIUtility.labelWidth = GUI.skin.label.CalcSize(new GUIContent(TC.get("ConversationEditor.Line"))).x;
                    myNode.getLine(i).setText(EditorGUILayout.TextField(TC.get("ConversationEditor.Line"), myNode.getLine(i).getText(), GUILayout.Width(200)));

                    tmpTex = (myNode.getLine(i).getConditions().getConditionsList().Count > 0
                        ? conditionsTex
                        : noConditionsTex);

                    if (GUILayout.Button(tmpTex, noBackgroundSkin.button, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(myNode.getLine(i).getConditions());
                    }

                    if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        myNode.removeLine(i);
                    }
                    ;
                    EditorGUILayout.EndHorizontal();
                }
                if (isScrolling)
                {
                    EditorGUILayout.EndScrollView();
                }
            }


            GUIContent bttext = new GUIContent(TC.get("ConversationLine.DefaultText"));
            Rect       btrect = GUILayoutUtility.GetRect(bttext, style);

            if (GUI.Button(btrect, bttext))
            {
                myNode.addLine(new ConversationLine(TC.get("ConversationLine.PlayerName"), ""));
            }
            ;


            EditorGUILayout.HelpBox(TC.get("ConversationEditor.NodeOption"), MessageType.None);

            EditorGUILayout.BeginHorizontal();
            GUI.enabled = (myNode.getChildCount() == 0) || myNode.getType() == ConversationNodeViewEnum.OPTION;
            bttext      = new GUIContent(TC.get("ConversationEditor.CreateChild"));
            btrect      = GUILayoutUtility.GetRect(bttext, buttonstyle);
            if (GUI.Button(btrect, bttext))
            {
                parent.addChild(myNode, new DialogueConversationNode());
            }
            GUI.enabled = true;

            bttext = new GUIContent(TC.get("ConversationEditor.SetChild"));
            btrect = GUILayoutUtility.GetRect(bttext, buttonstyle);
            if (GUI.Button(btrect, bttext))
            {
                parent.startSetChild(this.myNode, 0);
            }

            tmpTex = (myNode.getEffects().getEffects().Count > 0
                ? effectTex
                : noEffectTex);
            if (GUILayout.Button(tmpTex, noBackgroundSkin.button, GUILayout.Width(24), GUILayout.Height(24)))
            {
                EffectEditorWindow window = (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                window.Init(myNode.getEffects());
            }

            GUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
            public ReferenceList()
            {
                conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
                noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");
                icons           = new Dictionary <Type, Texture2D>()
                {
                    { typeof(PlayerDataControl), Resources.Load <Texture2D>("EAdventureData/img/icons/player-old") },
                    { typeof(ItemDataControl), Resources.Load <Texture2D>("EAdventureData/img/icons/item") },
                    { typeof(AtrezzoDataControl), Resources.Load <Texture2D>("EAdventureData/img/icons/atrezzo-1") },
                    { typeof(NPCDataControl), Resources.Load <Texture2D>("EAdventureData/img/icons/npc") }
                };
                elementHeight = 20;
                Columns       = new List <ColumnList.Column>()
                {
                    new ColumnList.Column() // Layer column
                    {
                        Text        = TC.get("ElementList.Layer"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.Width(50) }
                    },
                    new ColumnList.Column() // Enabled Column
                    {
                        Text        = "Enabled",
                        SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) }
                    },
                    new ColumnList.Column() // Element name
                    {
                        Text        = TC.get("ElementList.Title"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column() // Enabled Column
                    {
                        Text        = TC.get("Conditions.Title"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    }
                };
                drawCell = (columnRect, row, column, isActive, isFocused) =>
                {
                    var element = list[row] as ElementContainer;
                    var erdc    = element.getErdc();

                    switch (column)
                    {
                    case 0:
                        GUI.Label(columnRect, element.getLayer().ToString());
                        break;

                    case 1: /* TODO */ break;

                    case 2:
                        var iconSpace = new Rect(columnRect);
                        var nameSpace = new Rect(columnRect);
                        iconSpace.size      = new Vector2(16, nameSpace.size.y);
                        nameSpace.position += new Vector2(16, 0);
                        nameSpace.size     += new Vector2(-16, 0);

                        if (erdc == null)
                        {
                            GUI.Label(iconSpace, icons[typeof(PlayerDataControl)]);
                            GUI.Label(nameSpace, TC.get("Element.Name26"));
                        }
                        else
                        {
                            Texture2D icon = null;
                            var       type = erdc.getReferencedElementDataControl().GetType();
                            if (icons.ContainsKey(type))
                            {
                                icon = icons[type];
                            }
                            if (icon != null)
                            {
                                GUI.Label(iconSpace, icons[type]);
                            }
                            GUI.Label(icon != null ? nameSpace : columnRect, erdc.getElementId());
                        }
                        break;

                    case 3:
                        using (new EditorGUI.DisabledScope(erdc == null))
                        {
                            if (GUI.Button(columnRect, erdc == null ? noConditionsTex : erdc.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                            {
                                this.reorderableList.index = row;
                                ConditionEditorWindow window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                                window.Init(erdc.getConditions());
                            }
                        }
                        break;
                    }
                };
            }
Beispiel #20
0
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            tableRect       = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, windowHeight * 0.33f);
            rightPanelRect  = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.33f * windowHeight);
            infoPreviewRect = new Rect(0f, 0.45f * windowHeight, windowWidth, windowHeight * 0.05f);
            previewRect     = new Rect(0f, 0.5f * windowHeight, windowWidth, windowHeight * 0.45f);

            GUILayout.BeginArea(tableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("ExitsList.NextScene"), GUILayout.Width(windowWidth * 0.24f));
            GUILayout.Box(TC.get("ExitsList.Transition"), GUILayout.Width(windowWidth * 0.14f));
            GUILayout.Box(TC.get("ExitsList.Appearance"), GUILayout.Width(windowWidth * 0.34f));
            GUILayout.Box(TC.get("ExitsList.ConditionsAndEffects"), GUILayout.Width(windowWidth * 0.14f));
            GUILayout.EndHorizontal();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0;
                 i <
                 Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                     GameRources.GetInstance().selectedSceneIndex].getExitsList().getExitsList().Count;
                 i++)
            {
                if (i == selectedExit)
                {
                    GUI.skin = selectedAreaSkin;
                }
                else
                {
                    GUI.skin = noBackgroundSkin;
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                         GameRources.GetInstance().selectedSceneIndex].getExitsList().getExitsList()[i].getNextSceneId(),
                                     GUILayout.Width(windowWidth * 0.24f)))
                {
                    ChangeExitSelection(i);
                }

                // When is selected - show transition menu
                if (selectedExit == i)
                {
                    GUILayout.BeginVertical();
                    selectedTransitionType = EditorGUILayout.Popup(selectedTransitionType, transitionTypes,
                                                                   GUILayout.Width(windowWidth * 0.12f), GUILayout.MaxWidth(windowWidth * 0.12f));
                    if (selectedTransitionType != selectedTransitionTypeLast)
                    {
                        ChangeSelectedTransitionType(selectedTransitionType);
                    }
                    transitionTimeString = GUILayout.TextField(transitionTimeString, 3, GUILayout.Width(windowWidth * 0.12f),
                                                               GUILayout.MaxWidth(windowWidth * 0.12f));
                    transitionTimeString = Regex.Replace(transitionTimeString, @"[^0-9 ]", "");
                    if (!transitionTimeString.Equals(transitionTimeStringLast))
                    {
                        ChangeSelectedTransitionTime(transitionTimeString);
                    }
                    GUILayout.EndVertical();
                }
                // When is not selected - show normal text
                else
                {
                    if (GUILayout.Button(TC.get("GeneralText.Edit"), GUILayout.Width(windowWidth * 0.14f)))
                    {
                        ChangeExitSelection(i);
                    }
                }

                if (GUILayout.Button(TC.get("GeneralText.Edit"), GUILayout.Width(windowWidth * 0.34f)))
                {
                    ChangeExitSelection(i);
                    ExitsAppearance window =
                        (ExitsAppearance)ScriptableObject.CreateInstance(typeof(ExitsAppearance));
                    window.Init(this, "", selectedExit);
                }
                if (selectedExit == i)
                {
                    GUILayout.BeginVertical();
                    if (GUILayout.Button(TC.get("Exit.EditConditions"), GUILayout.Width(windowWidth * 0.14f)))
                    {
                        ConditionEditorWindow window =
                            (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getExitsList().getExitsList()[i].getConditions());
                    }
                    if (GUILayout.Button(TC.get("GeneralText.EditEffects"), GUILayout.Width(windowWidth * 0.14f)))
                    {
                        EffectEditorWindow window =
                            (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                        window.Init(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getExitsList().getExitsList()[i].getEffects());
                    }
                    if (GUILayout.Button(TC.get("Exit.EditPostEffects"), GUILayout.Width(windowWidth * 0.14f)))
                    {
                        EffectEditorWindow window =
                            (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                        window.Init(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getExitsList().getExitsList()[i].getPostEffects());
                    }
                    if (GUILayout.Button(TC.get("Exit.EditNotEffects"), GUILayout.Width(windowWidth * 0.14f)))
                    {
                        EffectEditorWindow window =
                            (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                        window.Init(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                        GameRources.GetInstance().selectedSceneIndex].getExitsList().getExitsList()[i].getNotEffects());
                    }
                    GUILayout.EndVertical();
                }
                else
                {
                    if (GUILayout.Button(TC.get("GeneralText.Edit"), GUILayout.Width(windowWidth * 0.14f)))
                    {
                        ChangeExitSelection(i);
                    }
                }

                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();



            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTexture, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                ExitNewLinkTo window =
                    (ExitNewLinkTo)ScriptableObject.CreateInstance(typeof(ExitNewLinkTo));
                window.Init(this);
            }
            if (GUILayout.Button(duplicateImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getExitsList()
                .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                      GameRources.GetInstance().selectedSceneIndex].getExitsList().getExits()[selectedExit]);
            }
            if (GUILayout.Button(moveUp, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getExitsList()
                .moveElementUp(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getExitsList().getExits()[selectedExit]);
            }
            if (GUILayout.Button(moveDown, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getExitsList()
                .moveElementDown(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                     GameRources.GetInstance().selectedSceneIndex].getExitsList().getExits()[selectedExit]);
            }
            if (GUILayout.Button(clearImg, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                    GameRources.GetInstance().selectedSceneIndex].getExitsList()
                .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                   GameRources.GetInstance().selectedSceneIndex].getExitsList().getExits()[selectedExit], false);
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();


            if (backgroundPath != "")
            {
                GUILayout.BeginArea(infoPreviewRect);
                // Show preview dialog
                if (GUILayout.Button(TC.get("DefaultClickAction.ShowDetails") + "/" + TC.get("GeneralText.Edit")))
                {
                    ExitsEditor window =
                        (ExitsEditor)ScriptableObject.CreateInstance(typeof(ExitsEditor));
                    window.Init(this, Controller.getInstance().getSelectedChapterDataControl().getScenesList().getScenes()[
                                    GameRources.GetInstance().selectedSceneIndex], selectedExit);
                }
                GUILayout.EndArea();
                GUI.DrawTexture(previewRect, backgroundPreviewTex, ScaleMode.ScaleToFit);
            }
            else
            {
                GUILayout.BeginArea(infoPreviewRect);
                GUILayout.Button("No background!");
                GUILayout.EndArea();
            }
        }
Beispiel #21
0
        public DialogNodeEditor()
        {
            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

            effectTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/effects/32x32/has-macro");
            noEffectTex = Resources.Load <Texture2D>("EAdventureData/img/icons/effects/32x32/macro");

            noBackgroundSkin = Resources.Load <GUISkin>("EAdventureData/skin/EditorNoBackgroundSkin");
            noBackgroundSkin.button.margin  = new RectOffset(1, 1, 1, 1);
            noBackgroundSkin.button.padding = new RectOffset(0, 0, 0, 0);

            closeStyle = new GUIStyle(GUI.skin.button)
            {
                padding = new RectOffset(0, 0, 0, 0),
                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;

            buttonstyle = new GUIStyle()
            {
                padding = new RectOffset(5, 5, 5, 5)
            };

            linesList = new DataControlList
            {
                Columns = new List <ColumnList.Column>
                {
                    new ColumnList.Column
                    {
                        Text        = "Speaker",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MaxWidth(60) }
                    },
                    new ColumnList.Column
                    {
                        Text        = "Emote",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MaxWidth(30) }
                    },
                    new ColumnList.Column
                    {
                        Text        = "Line",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MinWidth(250), GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column
                    {
                        Text        = "Cond.",
                        SizeOptions = new GUILayoutOption[] { GUILayout.MaxWidth(30) }
                    }
                },
                drawCell = (rect, index, column, isActive, isFocused) =>
                {
                    var        line       = this.linesList.list[index] as ConversationLineDataControl;
                    BubbleType bubbleType = GetBubbleType(line);
                    var        text       = line.getText();

                    // Mark the line as selected as soon as any click is performed in the line
                    if (Event.current.isMouse && Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                    {
                        linesList.index = index;
                    }

                    // Extract the bubble type
                    if (bubbleType.Identifier != "-")
                    {
                        text = text.Remove(0, bubbleType.Identifier.Length + 2);
                    }

                    switch (column)
                    {
                    case 0:     // Speaker

                        var npc = new List <string> {
                            TC.get("ConversationLine.PlayerName")
                        };
                        npc.AddRange(Controller.Instance.IdentifierSummary.getIds <NPC>());

                        var speaker = line.getName().Equals("Player") ? 0 : npc.IndexOf(line.getName());
                        EditorGUI.BeginChangeCheck();
                        var newSpeaker = EditorGUI.Popup(rect, speaker, npc.ToArray());
                        if (EditorGUI.EndChangeCheck())
                        {
                            var newSpeakerName = newSpeaker == 0 ? "Player" : npc[newSpeaker];
                            line.setName(newSpeakerName);
                        }
                        break;

                    case 1:     // Bubble type
                        // Control
                        if (GUI.Button(rect, bubbleType.Identifier))
                        {
                            bubbleType = BubbleTypes.FirstOrDefault(b => bubbleType.Next == b.Identifier);
                            // Reinsert the bubble type
                            if (bubbleType.Identifier != "-")
                            {
                                text = "#" + bubbleType.Identifier + " " + text;
                            }
                            line.setText(text);
                        }

                        break;

                    case 2:     // Text
                        EditorGUI.BeginChangeCheck();
                        var newText = EditorGUI.TextField(rect, text);
                        if (EditorGUI.EndChangeCheck())
                        {
                            // Reinsert the bubble type
                            if (bubbleType.Identifier != "-")
                            {
                                newText = "#" + bubbleType.Identifier + " " + newText;
                            }
                            line.setText(newText);
                        }
                        break;

                    case 3:     // Conditions
                        var hasConditions = line.getConditions().getBlocksCount() > 0;
                        if (GUI.Button(rect, hasConditions ? conditionsTex : noConditionsTex, noBackgroundSkin.button))
                        {
                            ConditionEditorWindow.ShowAtPosition(line.getConditions(), new Rect(rect.x + rect.width, rect.y, 0, 0));
                        }
                        break;
                    }
                }
            };
        }
Beispiel #22
0
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            globalStatesTableRect = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, 0.5f * windowHeight);
            rightPanelRect        = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.5f * windowHeight);
            descriptionRect       = new Rect(0f, 0.6f * windowHeight, 0.95f * windowWidth, 0.2f * windowHeight);
            conditionsRect        = new Rect(0f, 0.8f * windowHeight, windowWidth, windowHeight * 0.15f);

            GUILayout.BeginArea(globalStatesTableRect);
            GUILayout.Box(TC.get("GlobalStatesList.ID"), GUILayout.Width(0.85f * windowWidth));

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            for (int i = 0;
                 i <
                 Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl().getGlobalStates().Count;
                 i++)
            {
                if (i != selectedGlobalState)
                {
                    GUI.skin = noBackgroundSkin;

                    if (
                        GUILayout.Button(
                            Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl().getGlobalStates()[
                                i].getId(), GUILayout.Width(0.85f * windowWidth)))
                    {
                        OnSelectedGlobalStateChanged(i);
                    }
                }
                else
                {
                    GUI.skin = selectedAreaSkin;

                    globalStateName = GUILayout.TextField(globalStateName, GUILayout.Width(0.85f * windowWidth));
                    if (!globalStateName.Equals(globalStateNameLast))
                    {
                        OnGlobalStateNameChanged(globalStateName);
                    }
                }
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl()
                .addElement(Controller.GLOBAL_STATE, "GlobalState" + Random.Range(0, 10000).ToString());
            }
            if (GUILayout.Button(duplicateTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl()
                .duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl().getGlobalStates()[selectedGlobalState]);
            }
            if (GUILayout.Button(clearTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl()
                .deleteElement(Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl().getGlobalStates()[selectedGlobalState], false);
                selectedGlobalState = -1;
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();

            if (selectedGlobalState != -1)
            {
                GUILayout.Space(10);
                GUILayout.BeginArea(descriptionRect);
                GUILayout.Label(TC.get("GlobalState.Documentation"));
                GUILayout.Space(10);
                globalStateDocumentation = GUILayout.TextArea(globalStateDocumentation, GUILayout.MinHeight(0.15f * windowHeight));
                if (!globalStateDocumentation.Equals(globalStateDocumentationLast))
                {
                    OnGlobalStateDocumentationChanged(globalStateDocumentation);
                }
                GUILayout.EndArea();

                GUILayout.BeginArea(conditionsRect);
                if (GUILayout.Button(TC.get("GlobalState.Conditions")))
                {
                    ConditionEditorWindow window =
                        (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                    window.Init(Controller.getInstance()
                                .getSelectedChapterDataControl()
                                .getGlobalStatesListDataControl().getGlobalStates()[selectedGlobalState].getController());
                }
                GUILayout.EndArea();
            }
        }
        public override void Draw(int aID)
        {
            var workingTimerList = Controller.Instance.SelectedChapterDataControl.getTimersList();

            timerList.SetData(workingTimerList, (data) => (data as TimersListDataControl).getTimers().Cast <DataControl>().ToList());
            timerList.DoList(220);

            using (new EditorGUI.DisabledScope(timerList.index < 0 || timerList.index >= workingTimerList.getTimers().Count))
            {
                var workingTimer = timerList.index >= 0 ? workingTimerList.getTimers()[timerList.index] : new TimerDataControl(new Timer());

                // ################
                // ### Time section
                // ################

                EditorGUI.BeginChangeCheck();
                var showTime = EditorGUILayout.BeginToggleGroup(TC.get("TimersList.Display"), workingTimer.isShowTime());
                if (EditorGUI.EndChangeCheck())
                {
                    workingTimer.setShowTime(showTime);
                }
                {
                    EditorGUI.indentLevel++;

                    // Display name
                    EditorGUI.BeginChangeCheck();
                    var id = EditorGUILayout.TextField(TC.get("Item.Name"), workingTimer.getDisplayName());
                    if (EditorGUI.EndChangeCheck())
                    {
                        workingTimer.setDisplayName(id);
                    }

                    // CountDown
                    EditorGUI.BeginChangeCheck();
                    var countDown = EditorGUILayout.ToggleLeft(TC.get("Timer.CountDown"), workingTimer.isCountDown());
                    if (EditorGUI.EndChangeCheck())
                    {
                        workingTimer.setCountDown(countDown);
                    }

                    // Show when stopped
                    EditorGUI.BeginChangeCheck();
                    var shownWhenStopped = EditorGUILayout.ToggleLeft(TC.get("Timer.ShowWhenStopped"), workingTimer.isShowWhenStopped());
                    if (EditorGUI.EndChangeCheck())
                    {
                        workingTimer.setShowWhenStopped(shownWhenStopped);
                    }

                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndToggleGroup();

                // ################
                // ### Loop Control
                // ################

                GUILayout.Label(TC.get("Timer.LoopControl"));
                {
                    EditorGUI.indentLevel++;

                    // Show when stopped
                    EditorGUI.BeginChangeCheck();
                    var multipleStarts = EditorGUILayout.ToggleLeft(TC.get("Timer.MultipleStarts"), workingTimer.isMultipleStarts());
                    if (EditorGUI.EndChangeCheck())
                    {
                        workingTimer.setMultipleStarts(multipleStarts);
                    }

                    EditorGUILayout.HelpBox(TC.get("Timer.MultipleStartsDesc"), MessageType.Info);

                    // Show when stopped
                    EditorGUI.BeginChangeCheck();
                    var runsInLoop = EditorGUILayout.ToggleLeft(TC.get("Timer.RunsInLoop"), workingTimer.isRunsInLoop());
                    if (EditorGUI.EndChangeCheck())
                    {
                        workingTimer.setRunsInLoop(runsInLoop);
                    }

                    EditorGUILayout.HelpBox(TC.get("Timer.RunsInLoopDesc"), MessageType.Info);

                    EditorGUI.indentLevel--;
                }

                // ################
                // ### Conditions
                // ################

                // Init conditions
                GUILayout.Label(TC.get("Timer.InitConditions"));
                {
                    EditorGUI.indentLevel++;

                    if (GUILayout.Button(TC.get("GeneralText.EditInitConditions")))
                    {
                        ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(workingTimer.getInitConditions());
                    }

                    EditorGUI.indentLevel--;
                }

                // End conditions
                GUILayout.Label(TC.get("Timer.EndConditions"));
                {
                    EditorGUI.indentLevel++;

                    EditorGUI.BeginChangeCheck();
                    var usesEndCondition = EditorGUILayout.BeginToggleGroup(TC.get("Timer.UsesEndConditionShort"), workingTimer.isUsesEndCondition());
                    if (EditorGUI.EndChangeCheck())
                    {
                        workingTimer.setUsesEndCondition(usesEndCondition);
                    }

                    if (GUILayout.Button(TC.get("GeneralText.EditEndConditions")))
                    {
                        ConditionEditorWindow window = (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(workingTimer.getEndConditions());
                    }

                    EditorGUILayout.EndToggleGroup();
                    EditorGUI.indentLevel--;
                }

                // ################
                // ### Effects
                // ################

                // Header
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.Label(TC.get("Timer.Effects"));
                GUILayout.FlexibleSpace();
                GUILayout.Label(TC.get("Timer.PostEffects"));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                // Buttons
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(TC.get("GeneralText.EditEffects")))
                {
                    EffectEditorWindow window =
                        (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                    window.Init(workingTimer.getEffects());
                }
                if (GUILayout.Button(TC.get("GeneralText.EditPostEffects")))
                {
                    EffectEditorWindow window =
                        (EffectEditorWindow)ScriptableObject.CreateInstance(typeof(EffectEditorWindow));
                    window.Init(workingTimer.getPostEffects());
                }
                GUILayout.EndHorizontal();


                GUILayout.Label(TC.get("Timer.Documentation"));
                EditorGUI.BeginChangeCheck();
                var newDocumentation = GUILayout.TextArea(workingTimer.getDocumentation() ?? string.Empty, GUILayout.ExpandHeight(true));
                if (EditorGUI.EndChangeCheck())
                {
                    workingTimer.setDocumentation(newDocumentation);
                }
            }
        }
        public override void Draw(int aID)
        {
            var windowWidth  = m_Rect.width;
            var windowHeight = m_Rect.height;

            appearanceTableRect = new Rect(0f, 0.1f * windowHeight, 0.9f * windowWidth, 0.2f * windowHeight);
            rightPanelRect      = new Rect(0.9f * windowWidth, 0.1f * windowHeight, 0.08f * windowWidth, 0.2f * windowHeight);
            propertiesTable     = new Rect(0f, 0.3f * windowHeight, 0.95f * windowWidth, 0.3f * windowHeight);
            previewRect         = new Rect(0f, 0.6f * windowHeight, windowWidth, windowHeight * 0.35f);

            GUILayout.BeginArea(appearanceTableRect);
            GUILayout.BeginHorizontal();
            GUILayout.Box(TC.get("Item.LookPanelTitle"), GUILayout.Width(windowWidth * 0.44f));
            GUILayout.Box(TC.get("Conditions.Title"), GUILayout.Width(windowWidth * 0.44f));
            GUILayout.EndHorizontal();
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            // Appearance table
            for (int i = 0; i < Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[GameRources.GetInstance().selectedItemIndex].getResourcesCount(); i++)
            {
                if (i == selectedAppearance)
                {
                    GUI.skin = selectedAreaSkin;
                }
                else
                {
                    GUI.skin = noBackgroundSkin;
                }

                tmpTex = (Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                              GameRources.GetInstance().selectedItemIndex].getResources()[i].getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex);

                GUILayout.BeginHorizontal();

                if (i == selectedAppearance)
                {
                    if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                             GameRources.GetInstance().selectedItemIndex].getResources()[i].getName(), GUILayout.Width(windowWidth * 0.44f)))
                    {
                        OnAppearanceSelectionChange(i);
                    }
                    if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.44f)))
                    {
                        ConditionEditorWindow window =
                            (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                        GameRources.GetInstance().selectedItemIndex].getResources()[i].getConditions());
                    }
                }
                else
                {
                    if (GUILayout.Button(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                             GameRources.GetInstance().selectedItemIndex].getResources()[i].getName(), GUILayout.Width(windowWidth * 0.44f)))
                    {
                        OnAppearanceSelectionChange(i);
                    }
                    if (GUILayout.Button(tmpTex, GUILayout.Width(windowWidth * 0.44f)))
                    {
                        OnAppearanceSelectionChange(i);
                    }
                }
                GUILayout.EndHorizontal();
                GUI.skin = defaultSkin;
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();

            /*
             * Right panel
             */
            GUILayout.BeginArea(rightPanelRect);
            GUI.skin = noBackgroundSkin;
            if (GUILayout.Button(addTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].addElement(Controller.RESOURCES, "");
            }
            if (GUILayout.Button(duplicateTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].duplicateElement(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                                                                      GameRources.GetInstance().selectedItemIndex].getResources()[selectedAppearance]);
            }
            if (GUILayout.Button(clearTex, GUILayout.MaxWidth(0.08f * windowWidth)))
            {
                Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                    GameRources.GetInstance().selectedItemIndex].deleteElement(Controller.getInstance().getSelectedChapterDataControl().getItemsList().getItems()[
                                                                                   GameRources.GetInstance().selectedItemIndex].getResources()[selectedAppearance], false);
            }
            GUI.skin = defaultSkin;
            GUILayout.EndArea();


            GUILayout.Space(30);


            GUILayout.BeginArea(propertiesTable);
            // Background chooser
            GUILayout.Label(TC.get("Resources.DescriptionItemImage"));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(clearTex, GUILayout.Width(0.05f * windowWidth)))
            {
                imagePath = "";
            }
            GUILayout.Box(imagePath, GUILayout.Width(0.7f * windowWidth));
            if (GUILayout.Button(TC.get("Buttons.Select"), GUILayout.Width(0.19f * windowWidth)))
            {
                ShowAssetChooser(AssetType.ITEM);
            }
            GUILayout.EndHorizontal();

            // Icon chooser
            GUILayout.Label(TC.get("Resources.DescriptionItemIcon"));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(clearTex, GUILayout.Width(0.05f * windowWidth)))
            {
                inventoryIconPath = "";
            }
            GUILayout.Box(inventoryIconPath, GUILayout.Width(0.7f * windowWidth));
            if (GUILayout.Button(TC.get("Buttons.Select"), GUILayout.Width(0.19f * windowWidth)))
            {
                ShowAssetChooser(AssetType.ICON);
            }
            GUILayout.EndHorizontal();

            // Image over chooser
            GUILayout.Label(TC.get("Resources.DescriptionItemImageOver"));
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(clearTex, GUILayout.Width(0.05f * windowWidth)))
            {
                imageWhenOverPath = "";
            }
            GUILayout.Box(imageWhenOverPath, GUILayout.Width(0.7f * windowWidth));
            if (GUILayout.Button(TC.get("Buttons.Select"), GUILayout.Width(0.19f * windowWidth)))
            {
                ShowAssetChooser(AssetType.ITEM_OVER);
            }
            GUILayout.EndHorizontal();

            GUILayout.EndArea();

            if (imagePath != "")
            {
                GUI.DrawTexture(previewRect, imageTex, ScaleMode.ScaleToFit);
            }
        }
        public ScenesWindowBarriers(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor,
                                    params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, sceneEditor, aOptions)
        {
            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");
            PreviewTitle    = "Scene.Preview".Traslate();

            barriersList = new DataControlList()
            {
                RequestRepaint = Repaint,
                elementHeight  = 20,
                Columns        = new List <ColumnList.Column>()
                {
                    new ColumnList.Column() // Layer column
                    {
                        Text        = TC.get("Barriers.Name"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column() // Enabled Column
                    {
                        Text        = TC.get("Conditions.Title"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    }
                },
                drawCell = (columnRect, row, column, isActive, isFocused) =>
                {
                    var element = barriersList.list[row] as BarrierDataControl;
                    switch (column)
                    {
                    case 0:
                        EditorGUI.LabelField(columnRect, "Barrier: " + (row + 1));
                        break;

                    case 1:
                        if (GUI.Button(columnRect, element.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                        {
                            barriersList.index = row;
                            ConditionEditorWindow window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                            window.Init(element.getConditions());
                        }
                        break;
                    }
                },
                onSelectCallback = (list) =>
                {
                    sceneEditor.SelectedElement = barriersList.list[list.index] as BarrierDataControl;
                },
                onRemoveCallback = (list) =>
                {
                    sceneEditor.SelectedElement = null;
                }
            };

            sceneEditor.onSelectElement += (element) =>
            {
                if (element is BarrierDataControl)
                {
                    barriersList.index = barriersList.list.IndexOf(element as BarrierDataControl);
                }
                else
                {
                    barriersList.index = -1;
                }
            };
        }
Beispiel #26
0
        public ScenesWindowActiveAreas(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, SceneEditor sceneEditor,
                                       params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, sceneEditor, aOptions)
        {
            new ActiveAreaActionsComponent(Rect.zero, new GUIContent(""), aStyle);
            new ActiveAreaDescriptionsComponent(Rect.zero, new GUIContent(""), aStyle);

            PreviewTitle = "Scene.Preview".Traslate();

            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

            activeAreasList = new DataControlList()
            {
                RequestRepaint = Repaint,
                elementHeight  = 20,
                Columns        = new List <ColumnList.Column>()
                {
                    new ColumnList.Column() // Layer column
                    {
                        Text        = TC.get("ElementList.Layer"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.Width(50) }
                    },
                    new ColumnList.Column() // Element name
                    {
                        Text        = TC.get("ElementList.Title"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    },
                    new ColumnList.Column() // Enabled Column
                    {
                        Text        = TC.get("Conditions.Title"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                    }
                },
                drawCell = (columnRect, row, column, isActive, isFocused) =>
                {
                    var element = activeAreasList.list[row] as ActiveAreaDataControl;
                    switch (column)
                    {
                    case 0: GUI.Label(columnRect, row.ToString()); break;

                    case 1:
                        if (isActive)
                        {
                            EditorGUI.BeginChangeCheck();
                            var newId = EditorGUI.DelayedTextField(columnRect, element.getId());
                            if (EditorGUI.EndChangeCheck())
                            {
                                element.renameElement(newId);
                            }
                        }
                        else
                        {
                            GUI.Label(columnRect, element.getId());
                        }

                        break;

                    case 2:
                        if (GUI.Button(columnRect, element.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                        {
                            ConditionEditorWindow window =
                                (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                            window.Init(element.getConditions());
                        }
                        break;
                    }
                },
                onSelectCallback = (list) =>
                {
                    sceneEditor.SelectedElement = activeAreasList.list[list.index] as ExitDataControl;
                },
                onRemoveCallback = (list) =>
                {
                    sceneEditor.SelectedElement = null;
                }
            };

            sceneEditor.onSelectElement += (element) =>
            {
                if (element is ActiveAreaDataControl)
                {
                    activeAreasList.index = activeAreasList.list.IndexOf(element as ActiveAreaDataControl);
                }
                else
                {
                    activeAreasList.index = -1;
                }
            };
        }