public void Init(ProgressDataControl progressDataControl)
        {
            this.progress = progressDataControl;

            progressList = new DataControlList()
            {
                RequestRepaint = Repaint,
                Columns        = new List <ColumnList.Column>()
                {
                    new ColumnList.Column()
                    {
                        Text = "Analytics.Milestone.Time".Traslate()
                    }
                },
                drawCell = (rect, row, column, isActive, isFocused) =>
                {
                    var milestone = progressList.list[row] as MilestoneDataControl;
                    if (milestone == null)
                    {
                        return;
                    }

                    switch (column)
                    {
                    default:
                        if (GUI.Button(rect, milestone.getContent().ToString()))
                        {
                            MilestoneEditorWindow.ShowMilestoneEditor(rect, milestone);
                        }
                        break;

                    case 1:
                        EditorGUI.BeginChangeCheck();
                        var newProgress = EditorGUI.Slider(rect, "", milestone.getProgress(), 0, 1);
                        if (EditorGUI.EndChangeCheck())
                        {
                            milestone.setProgress(newProgress);
                        }
                        break;
                    }
                }
            };

            progressColumn = new ColumnList.Column()
            {
                Text = "Analytics.Completable.Progress".Traslate()
            };
        }
 protected void Awake()
 {
     scoresList = new DataControlList()
     {
         RequestRepaint = Repaint,
         Columns        = new List <ColumnList.Column>()
         {
             new ColumnList.Column()
             {
                 Text = "Sub scores"
             }
         },
         drawCell = (rect, row, column, isActive, isFocused) =>
         {
             CompletablesWindow.ScoreEditor(rect, scoresList.list[row] as ScoreDataControl);
         }
     };
 }
Beispiel #3
0
        public GeoElementWindowActions(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");

            var actionsColumns = new List <ColumnList.Column>
            {
                new ColumnList.Column
                {
                    Text        = "Geo.GeoElementWindow.Actions.Column.Name".Traslate(),
                    SizeOptions = new[] { GUILayout.Width(150) }
                },
                new ColumnList.Column
                {
                    Text = "Geo.GeoElementWindow.Actions.Column.Parameters".Traslate()
                },
                new ColumnList.Column
                {
                    Text        = "Geo.GeoElementWindow.Actions.Column.Effects".Traslate(),
                    SizeOptions = new[] { GUILayout.Width(150) }
                },
                new ColumnList.Column
                {
                    Text        = "Geo.GeoElementWindow.Actions.Column.Conditions".Traslate(),
                    SizeOptions = new[] { GUILayout.Width(150) }
                }
            };

            geoActionsList = new DataControlList
            {
                elementHeight = 60,
                Columns       = actionsColumns,
                drawCell      = DrawActionColumn
            };
        }
    protected void Awake()
    {
        conditionsTex   = (Texture2D)Resources.Load("EAdventureData/img/icons/conditions-24x24", typeof(Texture2D));
        noConditionsTex = (Texture2D)Resources.Load("EAdventureData/img/icons/no-conditions-24x24", typeof(Texture2D));

        appearanceList = new DataControlList()
        {
            RequestRepaint = Repaint,
            headerHeight   = 20,
            footerHeight   = 20,
            Columns        = new List <ColumnList.Column>()
            {
                new ColumnList.Column()
                {
                    Text        = TC.get("Item.LookPanelTitle"),
                    SizeOptions = new GUILayoutOption[]
                    {
                        GUILayout.ExpandWidth(true)
                    }
                },
                new ColumnList.Column()
                {
                    Text        = TC.get("Conditions.Title"),
                    SizeOptions = new GUILayoutOption[]
                    {
                        GUILayout.ExpandWidth(true)
                    }
                }
            },
            drawCell = (rect, index, col, isActive, isFocused) =>
            {
                var resources = dataControl.getResources()[index];
                switch (col)
                {
                case 0:
                    if (index == appearanceList.index)
                    {
                        EditorGUI.BeginChangeCheck();
                        var newname = EditorGUI.TextField(rect, "Resources " + (index + 1), resources.getName());
                        if (EditorGUI.EndChangeCheck())
                        {
                            resources.renameElement(newname);
                        }
                    }
                    else
                    {
                        EditorGUI.LabelField(rect, "Resources " + (index + 1) + ": " + resources.getName());
                    }
                    break;

                case 1:
                    if (GUI.Button(rect, resources.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                    {
                        appearanceList.index = index;
                        ConditionEditorWindow window = CreateInstance <ConditionEditorWindow>();
                        window.Init(resources.getConditions());
                    }
                    break;
                }
            },
            onSelectCallback = (list) =>
            {
                if (list.index == -1)
                {
                    list.index = 0;
                }
                dataControl.setSelectedResources(list.index);
                if (onAppearanceSelected != null)
                {
                    onAppearanceSelected(dataControl);
                }
            }
        };
    }
Beispiel #5
0
        public GeoElementWindowGeometry(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, MapEditor mapEditor, params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, mapEditor, aOptions)
        {
            PreviewTitle = "Item.Preview".Traslate();

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

            typeNames = Enum.GetNames(typeof(GMLGeometry.GeometryType)).Select(n => TC.get("Geo.GeoElement.Geometry.Type." + n + ".Name")).ToArray();

            AbstractEditorComponent.RegisterComponent(this);

            geometriesList = new DataControlList
            {
                Columns = new List <ColumnList.Column>
                {
                    new ColumnList.Column
                    {
                        Text = "Name"
                    },
                    new ColumnList.Column
                    {
                        Text = "Type"
                    },
                    new ColumnList.Column
                    {
                        Text = "Conditions"
                    }
                },
                drawCell = (rect, row, column, active, focused) =>
                {
                    var geometry = this.geometriesList.list[row] as GMLGeometryDataControl;
                    switch (column)
                    {
                    case 0:
                    {
                        if (active)
                        {
                            var indexRect = new Rect(rect.position, new Vector2(30, rect.height));
                            var nameRect  = new Rect(rect.position + Vector2.right * 30, new Vector2(rect.width - 30, rect.height));
                            EditorGUI.BeginChangeCheck();
                            GUI.Label(indexRect, (row + 1) + ":");
                            var newName = GUI.TextField(nameRect, geometry.Name);
                            if (EditorGUI.EndChangeCheck())
                            {
                                geometry.Name = newName;
                            }
                        }
                        else
                        {
                            GUI.Label(rect, (row + 1) + ":" + geometry.Name);
                        }
                    }
                    break;

                    case 1:
                    {
                        GUI.Label(rect, TC.get("Geo.GeoElement.Geometry.Type." + geometry.Type + ".Name"));
                    }
                    break;

                    case 2:
                        if (GUI.Button(rect,
                                       geometry.Conditions.getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                        {
                            this.geometriesList.index = row;
                            var window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                            window.Init(geometry.Conditions);
                        }
                        break;
                    }
                },
                onSelectCallback = list =>
                {
                    if (list.index > -1)
                    {
                        workingGeoElement.SelectedGeometry = list.index;
                        Center(workingGeoElement.GMLGeometries[workingGeoElement.SelectedGeometry]);
                    }
                },
                onRemoveCallback = list =>
                {
                    if (workingGeoElement.SelectedGeometry > -1)
                    {
                        workingGeoElement.SelectedGeometry = Mathf.Max(0, workingGeoElement.SelectedGeometry - 1);
                        Center(workingGeoElement.GMLGeometries[workingGeoElement.SelectedGeometry]);
                        list.index = workingGeoElement.SelectedGeometry;
                    }
                }
            };
        }
        public MapSceneWindowReferences(Rect rect, GUIContent content, GUIStyle style, MapEditor componentBasedEditor, params GUILayoutOption[] options)
            : base(rect, content, style, componentBasedEditor, options)
        {
            conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
            noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");
            centerTex       = Resources.Load <Texture2D>("EAdventureData/img/icons/center-24x24");

            icons = new Dictionary <Type, Texture2D>()
            {
                { typeof(GeoElementDataControl), Resources.Load <Texture2D>("EAdventureData/img/icons/poi") },
                { 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") }
            };

            new MapReferenceComponent(rect, null, style, null);

            mapElements = new DataControlList
            {
                Columns = new List <ColumnList.Column>
                {
                    new ColumnList.Column
                    {
                        Text = TC.get("ElementList.Title")
                    },
                    new ColumnList.Column
                    {
                        Text        = TC.get("Geo.MapScene.ReferenceList.Column.Center"),
                        SizeOptions = new [] { GUILayout.Width(24f) },
                    },
                    new ColumnList.Column()
                    {
                        Text = TC.get("Conditions.Title")
                    }
                },
                drawCell = (cellRect, row, column, active, focused) =>
                {
                    var mapElement = mapElements.list[row] as MapElementDataControl;
                    switch (column)
                    {
                    case 0:
                        var iconSpace = new Rect(cellRect);
                        var nameSpace = new Rect(cellRect);
                        iconSpace.size      = new Vector2(16, nameSpace.size.y);
                        nameSpace.position += new Vector2(16, 0);
                        nameSpace.size     += new Vector2(-16, 0);

                        Texture2D icon = null;
                        var       type = mapElement.ReferencedDataControl.GetType();
                        if (icons.ContainsKey(type))
                        {
                            icon = icons[type];
                        }
                        if (icon != null)
                        {
                            GUI.Label(iconSpace, icons[type]);
                        }
                        GUI.Label(icon != null ? nameSpace : cellRect, mapElement.ReferencedId);
                        break;

                    case 1:
                        var elementReference = mapElement as ExtElementRefDataControl;

                        if ((elementReference == null || elementReference.TransformManager.PositionManagerName == "WorldPositioned") &&
                            GUI.Button(cellRect, centerTex))
                        {
                            Center(componentBasedEditor, mapElement);
                        }
                        break;

                    case 2:
                        if (GUI.Button(cellRect,
                                       mapElement.Conditions.getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                        {
                            this.mapElements.index = row;
                            var window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                            window.Init(mapElement.Conditions);
                        }
                        break;
                    }
                }
            };
            mapElements.onSelectCallback += list =>
            {
                componentBasedEditor.SelectedElement = (DataControl)(mapElements.index == -1 ? null : mapElements.list[mapElements.index]);
            };

            componentBasedEditor.onSelectElement += elem =>
            {
                mapElements.index = mapElements.list.IndexOf(elem);
            };
        }
    public void Awake()
    {
        resourcesEditor = new ResourcesEditor {
            ShowResourcesList = true
        };
        conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
        noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

        actionsList = new DataControlList()
        {
            footerHeight  = 25,
            elementHeight = 40,
            Columns       = new System.Collections.Generic.List <ColumnList.Column>()
            {
                new ColumnList.Column()
                {
                    Text        = TC.get("ActionsList.ActionName"),
                    SizeOptions = new GUILayoutOption[] { GUILayout.Width(150) }
                },
                new ColumnList.Column()
                {
                    Text        = TC.get("DescriptionList.Description"),
                    SizeOptions = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }
                },
                new ColumnList.Column()
                {
                    Text        = TC.get("ActionsList.NeedsGoTo"),
                    SizeOptions = new GUILayoutOption[] { GUILayout.Width(120) }
                },
                new ColumnList.Column()
                {
                    Text        = TC.get("ActionsList.Conditions"),
                    SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) }
                },
                new ColumnList.Column()
                {
                    Text        = TC.get("Element.Effects"),
                    SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) }
                }
            },
            drawCell = (rect, index, column, isActive, isFocused) =>
            {
                var action = actionsList.list[index] as ActionDataControl;
                switch (column)
                {
                case 0:
                {
                    var name = action.getContent() is CustomAction ? ((CustomAction)action.getContent()).getName() : action.getTypeName();

                    var leftHalf = new Rect(rect);
                    leftHalf.width /= 2f;
                    var rightHalf = new Rect(leftHalf);
                    rightHalf.x += leftHalf.width;

                    if (action.hasIdTarget())
                    {
                        rightHalf.height = 25;
                        EditorGUI.LabelField(leftHalf, name);
                        if (!isActive)
                        {
                            EditorGUI.LabelField(rightHalf, !string.IsNullOrEmpty(action.getIdTarget()) ? action.getIdTarget() : "---");
                        }
                        else
                        {
                            EditorGUI.BeginChangeCheck();
                            string   selected = string.Empty;
                            string[] choices  = new string[0];
                            switch ((action.getContent() as Action).getType())
                            {
                            case Action.DRAG_TO:
                            case Action.CUSTOM_INTERACT:
                                choices = Controller.Instance.IdentifierSummary.combineIds(new System.Type[] { typeof(Item), typeof(NPC), typeof(ActiveArea) });
                                break;

                            case Action.GIVE_TO:
                                choices = Controller.Instance.IdentifierSummary.getIds <NPC>();
                                break;

                            case Action.USE_WITH:
                                choices = Controller.Instance.IdentifierSummary.combineIds(new System.Type[] { typeof(Item), typeof(ActiveArea) });
                                break;
                            }

                            var selectedIndex = EditorGUI.Popup(rightHalf, System.Array.FindIndex(choices, action.getIdTarget().Equals), choices);
                            if (EditorGUI.EndChangeCheck())
                            {
                                if (selectedIndex >= 0 && selectedIndex < choices.Length)
                                {
                                    selected = choices[selectedIndex];
                                    action.setIdTarget(selected);
                                }
                            }
                        }
                    }
                    else if (action.getType() == Controller.ACTION_TALK_TO)
                    {
                        EditorGUI.LabelField(leftHalf, name);
                        var triggerConversationEffect = action.getEffects().getEffects().Find(e => e is TriggerConversationEffect) as TriggerConversationEffect;
                        if (triggerConversationEffect != null)
                        {
                            var conversationId = triggerConversationEffect.getTargetId();
                            if (GUI.Button(rightHalf, "Open"))
                            {
                                var conversationsList = Controller.Instance.SelectedChapterDataControl.getConversationsList();
                                var conversation      = conversationsList.getConversations().Find(c => c.getId() == conversationId);
                                Controller.Instance.SelectElement(conversation);
                            }
                        }
                    }
                    else
                    {
                        EditorGUI.LabelField(rect, name);
                    }
                }
                break;

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

                case 2:
                    if (Controller.Instance.PlayerMode == Controller.FILE_ADVENTURE_1STPERSON_PLAYER)
                    {
                        EditorGUI.LabelField(rect, TC.get("ActionsList.NotRelevant"));
                    }
                    else
                    {
                        var leftHalf = new Rect(rect);
                        leftHalf.width /= 2f;
                        var rightHalf = new Rect(leftHalf);
                        rightHalf.x += leftHalf.width;

                        EditorGUI.BeginChangeCheck();
                        var needsToGo = EditorGUI.Toggle(leftHalf, action.getNeedsGoTo());
                        if (EditorGUI.EndChangeCheck())
                        {
                            action.setNeedsGoTo(needsToGo);
                        }

                        EditorGUI.BeginChangeCheck();
                        var distance = EditorGUI.IntField(rightHalf, action.getKeepDistance());
                        if (EditorGUI.EndChangeCheck())
                        {
                            action.setKeepDistance(distance);
                        }
                        ;
                    }
                    break;

                case 3:
                    if (GUI.Button(rect, action.getConditions().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                    {
                        ConditionEditorWindow window = ScriptableObject.CreateInstance <ConditionEditorWindow>();
                        window.Init(action.getConditions());
                    }
                    break;

                case 4:
                    if (GUI.Button(rect, "Effects"))
                    {
                        EffectEditorWindow window = ScriptableObject.CreateInstance <EffectEditorWindow>();
                        window.Init(action.getEffects());
                    }
                    break;
                }
            }
        };

        actionsList.onSelectCallback += (list) =>
        {
            var i       = list.index;
            var actions = ActionsListDataControl.getActions();
            customAction = i != -1 && actions[i] is CustomActionDataControl ? actions[i] as CustomActionDataControl : null;
            if (customAction != null)
            {
                resourcesEditor.Data = customAction;
            }
        };

        actionsList.onRemoveCallback += (list) =>
        {
            customAction = null;
        };
    }
Beispiel #8
0
    private void Awake()
    {
        conditionsTex   = Resources.Load <Texture2D>("EAdventureData/img/icons/conditions-24x24");
        noConditionsTex = Resources.Load <Texture2D>("EAdventureData/img/icons/no-conditions-24x24");

        descriptionsList = new DataControlList()
        {
            RequestRepaint = Repaint,
            elementHeight  = 20,
            Columns        = new List <ColumnList.Column>()
            {
                new ColumnList.Column()
                {
                    Text = TC.get("Item.Name")
                },
                new ColumnList.Column()
                {
                    Text = TC.get("Conditions.Title")
                }
            },
            drawCell = (rect, index, column, isActive, isFocused) =>
            {
                var description = descriptions.getDescriptionController(index);
                switch (column)
                {
                case 0:
                    if (index == descriptionsList.index)
                    {
                        description.renameElement(EditorGUI.TextField(rect, description.getName()));
                    }
                    else
                    {
                        EditorGUI.LabelField(rect, description.getName());
                    }
                    break;

                case 1:
                    if (GUI.Button(rect, description.getConditionsController().getBlocksCount() > 0 ? conditionsTex : noConditionsTex))
                    {
                        ConditionEditorWindow window =
                            (ConditionEditorWindow)ScriptableObject.CreateInstance(typeof(ConditionEditorWindow));
                        window.Init(description.getConditionsController());
                    }
                    break;
                }
            },
            onSelectCallback = (list) =>
            {
                descriptions.setSelectedDescription(list.index);
                description = descriptions.getSelectedDescriptionController();
            }
        };

        descriptionsList.index = 0;

        nameField = new TextWithSoundField()
        {
            Label    = TC.get("Item.Name"),
            FileType = FileType.ITEM_DESCRIPTION_NAME_SOUND
        };

        briefField = new TextWithSoundField()
        {
            Label    = TC.get("Item.Description"),
            FileType = FileType.ITEM_DESCRIPTION_BRIEF_SOUND
        };

        fullField = new TextWithSoundField()
        {
            Label    = TC.get("Item.DetailedDescription"),
            FileType = FileType.ITEM_DESCRIPTION_DETAILED_SOUND
        };
    }
        public CompletablesWindow(Rect aStartPos, GUIContent aContent, GUIStyle aStyle, params GUILayoutOption[] aOptions)
            : base(aStartPos, aContent, aStyle, aOptions)
        {
            completablesList = new DataControlList()
            {
                RequestRepaint = Repaint,
                Columns        = new List <ColumnList.Column>()
                {
                    new ColumnList.Column()
                    {
                        Text = TC.get("Analytics.Completable.Id")
                    },
                    new ColumnList.Column()
                    {
                        Text = TC.get("Analytics.Completable.Start")
                    },
                    new ColumnList.Column()
                    {
                        Text = TC.get("Analytics.Completable.End")
                    },
                    new ColumnList.Column()
                    {
                        Text = TC.get("Analytics.Completable.Progress")
                    },
                    new ColumnList.Column()
                    {
                        Text = TC.get("Analytics.Completable.Score")
                    },
                    new ColumnList.Column()
                    {
                        Text        = TC.get("Repeatable"),
                        SizeOptions = new GUILayoutOption[] { GUILayout.Width(70) }
                    }
                },
                drawCell = (rect, row, column, isActive, isFocused) =>
                {
                    var completable = completablesList.list[row] as CompletableDataControl;
                    switch (column)
                    {
                    case 0:
                        completable.renameElement(EditorGUI.TextField(rect, completable.getId()));
                        break;

                    case 1:
                        if (GUI.Button(rect, completable.getStart().getContent().ToString()))
                        {
                            MilestoneEditorWindow.ShowMilestoneEditor(rect, completable.getStart());
                        }
                        break;

                    case 2:
                        if (GUI.Button(rect, completable.getEnd().getContent().ToString()))
                        {
                            MilestoneEditorWindow.ShowMilestoneEditor(rect, completable.getEnd());
                        }
                        break;

                    case 3:
                        if (GUI.Button(rect, TC.get("Analytics.Completable.Define")))
                        {
                            ProgressEditorWindow.ShowProgressEditor(rect, completable.getProgress());
                        }
                        break;

                    case 4:
                    {
                        if (Available)
                        {
                            ScoreEditor(rect, completable.getScore());
                        }
                        else
                        {
                            EditorGUI.HelpBox(rect, TC.get("Condition.Var.Warning"), MessageType.Error);
                        }
                    }
                    break;

                    case 5:
                        completable.setRepeatable(GUI.Toggle(rect, completable.getRepeatable(), "?"));
                        break;
                    }
                }
            };
        }