private void OnInitialize()
        {
            treeScrollArea = new GUIScrollArea();
            GUI.AddElement(treeScrollArea);

            treeView = new GUISceneTreeView(GUIOption.FlexibleHeight(20), GUIOption.FlexibleWidth(20));
            treeScrollArea.Layout.AddElement(treeView);

            // Loading progress
            loadLabel       = new GUILabel(new LocEdString("Loading scene..."));
            loadProgressBar = new GUIProgressBar();

            progressLayout = GUI.AddLayoutY();
            progressLayout.AddFlexibleSpace();
            GUILayout loadLabelLayout = progressLayout.AddLayoutX();

            loadLabelLayout.AddFlexibleSpace();
            loadLabelLayout.AddElement(loadLabel);
            loadLabelLayout.AddFlexibleSpace();

            GUILayout progressBarLayout = progressLayout.AddLayoutX();

            progressBarLayout.AddFlexibleSpace();
            progressBarLayout.AddElement(loadProgressBar);
            progressBarLayout.AddFlexibleSpace();
            progressLayout.AddFlexibleSpace();

            progressLayout.Active = false;

            EditorVirtualInput.OnButtonUp += OnButtonUp;
        }
Beispiel #2
0
        /// <summary>
        /// Triggered when the user selects a new resource or a scene object, or deselects everything.
        /// </summary>
        /// <param name="objects">A set of new scene objects that were selected.</param>
        /// <param name="paths">A set of absolute resource paths that were selected.</param>
        private void OnSelectionChanged(SceneObject[] objects, string[] paths)
        {
            if (currentType == InspectorType.SceneObject && modifyState == InspectableState.NotModified)
            {
                UndoRedo.Global.PopCommand(undoCommandIdx);
            }

            Clear();
            modifyState = InspectableState.NotModified;

            if (objects.Length == 0 && paths.Length == 0)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea();
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("No object selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if ((objects.Length + paths.Length) > 1)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea();
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("Multiple objects selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if (objects.Length == 1)
            {
                if (objects[0] != null)
                {
                    UndoRedo.RecordSO(objects[0]);
                    undoCommandIdx = UndoRedo.Global.TopCommandId;

                    SetObjectToInspect(objects[0]);
                }
            }
            else if (paths.Length == 1)
            {
                SetObjectToInspect(paths[0]);
            }
        }
        private void OnInitialize()
        {
            GUILayout vertLayout   = GUI.AddLayoutY();
            GUILayout editorPanel  = vertLayout.AddPanel(GUIOption.FixedHeight(400));
            GUILayout buttonLayout = vertLayout.AddLayoutX(GUIOption.FixedHeight(40));

            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            CurveDrawOptions drawOptions = CurveDrawOptions.DrawKeyframes | CurveDrawOptions.DrawMarkers;

            if (curveB != null)
            {
                drawOptions |= CurveDrawOptions.DrawRange;
            }

            curveEditor = new GUICurveEditor(editorPanel, 600, 400, false, drawOptions);
            curveEditor.Redraw();

            EdCurveDrawInfo[] drawinfo;

            if (curveB != null)
            {
                drawinfo = new []
                {
                    new EdCurveDrawInfo(curveA, Color.BansheeOrange),
                    new EdCurveDrawInfo(curveB, Color.Green),
                };
            }
            else
            {
                drawinfo = new [] { new EdCurveDrawInfo(curveA, Color.BansheeOrange), };
            }

            curveEditor.SetCurves(drawinfo);
            curveEditor.CenterAndResize(true);

            buttonLayout.AddFlexibleSpace();
            buttonLayout.AddElement(guiOK);
            buttonLayout.AddSpace(10);
            buttonLayout.AddElement(guiCancel);
            buttonLayout.AddFlexibleSpace();

            EditorInput.OnPointerPressed     += OnPointerPressed;
            EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked;
            EditorInput.OnPointerMoved       += OnPointerMoved;
            EditorInput.OnPointerReleased    += OnPointerReleased;
            EditorInput.OnButtonUp           += OnButtonUp;
        }
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            if (InspectedObject != null)
            {
                importOptions = GetImportOptions();

                normalsField.OnChanged     += x => importOptions.ImportNormals = x;
                tangentsField.OnChanged    += x => importOptions.ImportTangents = x;
                skinField.OnChanged        += x => importOptions.ImportSkin = x;
                blendShapesField.OnChanged += x => importOptions.ImportBlendShapes = x;
                animationField.OnChanged   += x => importOptions.ImportAnimation = x;
                scaleField.OnChanged       += x => importOptions.Scale = x;
                cpuReadableField.OnChanged += x => importOptions.CPUReadable = x;
                collisionMeshTypeField.OnSelectionChanged += x => importOptions.CollisionMeshType = (CollisionMeshType)x;

                reimportButton.OnClick += TriggerReimport;

                Layout.AddElement(normalsField);
                Layout.AddElement(tangentsField);
                Layout.AddElement(skinField);
                Layout.AddElement(blendShapesField);
                Layout.AddElement(animationField);
                Layout.AddElement(scaleField);
                Layout.AddElement(cpuReadableField);
                Layout.AddElement(collisionMeshTypeField);
                Layout.AddSpace(10);

                GUILayout reimportButtonLayout = Layout.AddLayoutX();
                reimportButtonLayout.AddFlexibleSpace();
                reimportButtonLayout.AddElement(reimportButton);
            }
        }
Beispiel #5
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            importOptions = GetImportOptions();

            formatField.OnSelectionChanged            += x => importOptions.Format = (PixelFormat)x;
            generateMipsField.OnChanged               += x => importOptions.GenerateMips = x;
            maximumMipsField.OnChanged                += x => importOptions.MaxMip = x;
            srgbField.OnChanged                       += x => importOptions.SRGB = x;
            cpuCachedField.OnChanged                  += x => importOptions.CpuCached = x;
            isCubemapField.OnChanged                  += x => importOptions.Cubemap = x;
            cubemapSourceTypeField.OnSelectionChanged += x => importOptions.CubemapSourceType = (CubemapSourceType)x;
            reimportButton.OnClick                    += TriggerReimport;

            Layout.AddElement(formatField);
            Layout.AddElement(generateMipsField);
            Layout.AddElement(maximumMipsField);
            Layout.AddElement(srgbField);
            Layout.AddElement(cpuCachedField);
            Layout.AddElement(isCubemapField);
            Layout.AddElement(cubemapSourceTypeField);
            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
Beispiel #6
0
        /// <summary>
        /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
        /// use.
        /// </summary>
        /// <param name="keyFrame">Keyframe whose properties to edit.</param>
        /// <param name="updateCallback">Callback triggered when event values change.</param>
        internal void Initialize(KeyFrame keyFrame, Action <KeyFrame> updateCallback)
        {
            GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40, "");

            timeField.Value      = keyFrame.time;
            timeField.OnChanged += x => { keyFrame.time = x; updateCallback(keyFrame); };

            GUIFloatField valueField = new GUIFloatField(new LocEdString("Value"), 40, "");

            valueField.Value      = keyFrame.value;
            valueField.OnChanged += x => { keyFrame.value = x; updateCallback(keyFrame); };

            GUILayoutY vertLayout = GUI.AddLayoutY();

            vertLayout.AddFlexibleSpace();
            GUILayoutX horzLayout = vertLayout.AddLayoutX();

            horzLayout.AddFlexibleSpace();
            GUILayout contentLayout = horzLayout.AddLayoutY();
            GUILayout timeLayout    = contentLayout.AddLayoutX();

            timeLayout.AddSpace(5);
            timeLayout.AddElement(timeField);
            timeLayout.AddFlexibleSpace();
            GUILayout componentLayout = contentLayout.AddLayoutX();

            componentLayout.AddSpace(5);
            componentLayout.AddElement(valueField);
            componentLayout.AddFlexibleSpace();
            horzLayout.AddFlexibleSpace();
            vertLayout.AddFlexibleSpace();
        }
Beispiel #7
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            if (InspectedObject != null)
            {
                importOptions = GetImportOptions();

                formatField.OnSelectionChanged += x => importOptions.Format = (PixelFormat)x;
                generateMipsField.OnChanged    += x => importOptions.GenerateMipmaps = x;
                maximumMipsField.OnChanged     += x => importOptions.MaxMipmapLevel = x;
                srgbField.OnChanged            += x => importOptions.IsSRGB = x;
                cpuReadableField.OnChanged     += x => importOptions.CPUReadable = x;

                reimportButton.OnClick += TriggerReimport;

                Layout.AddElement(formatField);
                Layout.AddElement(generateMipsField);
                Layout.AddElement(maximumMipsField);
                Layout.AddElement(srgbField);
                Layout.AddElement(cpuReadableField);
                Layout.AddSpace(10);

                GUILayout reimportButtonLayout = Layout.AddLayoutX();
                reimportButtonLayout.AddFlexibleSpace();
                reimportButtonLayout.AddElement(reimportButton);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            normalsField           = new GUIToggleField(new LocEdString("Import Normals"));
            tangentsField          = new GUIToggleField(new LocEdString("Import Tangents"));
            skinField              = new GUIToggleField(new LocEdString("Import Skin"));
            blendShapesField       = new GUIToggleField(new LocEdString("Import Blend Shapes"));
            animationField         = new GUIToggleField(new LocEdString("Import Animation"));
            scaleField             = new GUIFloatField(new LocEdString("Scale"));
            cpuCachedField         = new GUIToggleField(new LocEdString("CPU cached"));
            cpuReadableField       = new GUIToggleField(new LocEdString("CPU readable"));
            collisionMeshTypeField = new GUIEnumField(typeof(CollisionMeshType), new LocEdString("Collision mesh"));
            keyFrameReductionField = new GUIToggleField(new LocEdString("Keyframe Reduction"));
            rootMotionField        = new GUIToggleField(new LocEdString("Import root motion"));
            reimportButton         = new GUIButton(new LocEdString("Reimport"));

            normalsField.OnChanged     += x => importOptions.ImportNormals = x;
            tangentsField.OnChanged    += x => importOptions.ImportTangents = x;
            skinField.OnChanged        += x => importOptions.ImportSkin = x;
            blendShapesField.OnChanged += x => importOptions.ImportBlendShapes = x;
            animationField.OnChanged   += x => importOptions.ImportAnimation = x;
            scaleField.OnChanged       += x => importOptions.Scale = x;
            cpuCachedField.OnChanged   += x => importOptions.CPUCached = x;
            cpuReadableField.OnChanged += x => importOptions.CPUReadable = x;
            collisionMeshTypeField.OnSelectionChanged += x => importOptions.CollisionMeshType = (CollisionMeshType)x;
            keyFrameReductionField.OnChanged          += x => importOptions.KeyframeReduction = x;
            rootMotionField.OnChanged += x => importOptions.ImportRootMotion = x;

            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(normalsField);
            Layout.AddElement(tangentsField);
            Layout.AddElement(skinField);
            Layout.AddElement(blendShapesField);
            Layout.AddElement(animationField);
            Layout.AddElement(scaleField);
            Layout.AddElement(cpuCachedField);
            Layout.AddElement(cpuReadableField);
            Layout.AddElement(collisionMeshTypeField);
            Layout.AddElement(keyFrameReductionField);
            Layout.AddElement(rootMotionField);

            splitInfos = importOptions.AnimationClipSplits;

            animSplitInfoField = GUIArrayField <AnimationSplitInfo, AnimSplitArrayRow> .Create(
                new LocEdString("Animation splits"), splitInfos, Layout);

            animSplitInfoField.OnChanged += x => { splitInfos = x; };
            animSplitInfoField.IsExpanded = Persistent.GetBool("animSplitInfos_Expanded");
            animSplitInfoField.OnExpand  += x => Persistent.SetBool("animSplitInfos_Expanded", x);

            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
        /// <summary>
        /// Triggered when the user selects a new resource or a scene object, or deselects everything.
        /// </summary>
        /// <param name="objects">A set of new scene objects that were selected.</param>
        /// <param name="paths">A set of absolute resource paths that were selected.</param>
        private void OnSelectionChanged(SceneObject[] objects, string[] paths)
        {
            Clear();
            modifyState = InspectableState.NotModified;

            if (objects.Length == 0 && paths.Length == 0)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("No object selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if ((objects.Length + paths.Length) > 1)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("Multiple objects selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if (objects.Length == 1)
            {
                if (objects[0] != null)
                {
                    SetObjectToInspect(objects[0]);
                }
            }
            else if (paths.Length == 1)
            {
                SetObjectToInspect(paths[0]);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
        private void SetObjectToInspect(String resourcePath)
        {
            activeResourcePath = resourcePath;
            if (!ProjectLibrary.Exists(resourcePath))
            {
                return;
            }

            ResourceMeta meta         = ProjectLibrary.GetMeta(resourcePath);
            Type         resourceType = meta.Type;

            currentType = InspectorType.Resource;

            inspectorScrollArea = new GUIScrollArea();
            GUI.AddElement(inspectorScrollArea);
            inspectorLayout = inspectorScrollArea.Layout;

            GUIPanel titlePanel = inspectorLayout.AddPanel();

            titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT);

            GUILayoutY titleLayout = titlePanel.AddLayoutY();

            titleLayout.SetPosition(PADDING, PADDING);

            string name = Path.GetFileNameWithoutExtension(resourcePath);
            string type = resourceType.Name;

            LocString title      = new LocEdString(name + " (" + type + ")");
            GUILabel  titleLabel = new GUILabel(title);

            titleLayout.AddFlexibleSpace();
            GUILayoutX titleLabelLayout = titleLayout.AddLayoutX();

            titleLabelLayout.AddElement(titleLabel);
            titleLayout.AddFlexibleSpace();

            GUIPanel titleBgPanel = titlePanel.AddPanel(1);

            GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg);

            titleBgPanel.AddElement(titleBg);

            inspectorLayout.AddSpace(COMPONENT_SPACING);

            inspectorResource       = new InspectorResource();
            inspectorResource.panel = inspectorLayout.AddPanel();

            var persistentProperties = persistentData.GetProperties(meta.UUID.ToString());

            inspectorResource.inspector = InspectorUtility.GetInspector(resourceType);
            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResourcePath, persistentProperties);

            inspectorLayout.AddFlexibleSpace();
        }
Beispiel #11
0
        /// <summary>
        /// Creates the reimport GUI elements in the provided layout.
        /// </summary>
        /// <param name="path">Path of the resource that can be reimported.</param>
        /// <param name="parent">Parent GUI layout to which to add the reimport GUI elements.</param>
        /// <param name="doReimport">User provided callback that triggers when the reimport button is clicked.</param>
        internal GUIReimportButton(string path, GUILayout parent, Action doReimport)
        {
            this.path = path;

            reimportButton.OnClick += () => doReimport();

            GUILayout reimportButtonLayout = parent.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
            reimportButtonLayout.AddElement(guiSpinner);

            bool isImporting = ProjectLibrary.GetImportProgress(path) < 1.0f;

            guiSpinner.Active     = isImporting;
            reimportButton.Active = !isImporting;
        }
Beispiel #12
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            LoadResource();

            ScriptCode scriptCode = InspectedObject as ScriptCode;

            if (scriptCode == null)
            {
                return;
            }

            importOptions = GetImportOptions();

            isEditorField.OnChanged += x =>
            {
                importOptions.EditorScript = x;
            };

            GUIPanel  textPanel   = Layout.AddPanel();
            GUILayout textLayoutY = textPanel.AddLayoutY();

            textLayoutY.AddSpace(5);
            GUILayout textLayoutX = textLayoutY.AddLayoutX();

            textLayoutX.AddSpace(5);
            textLayoutX.AddElement(textLabel);
            textLayoutX.AddSpace(5);
            textLayoutY.AddSpace(5);

            GUIPanel textBgPanel = textPanel.AddPanel(1);

            textBgPanel.AddElement(textBg);

            Layout.AddElement(isEditorField);

            GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));

            reimportButton.OnClick += TriggerReimport;

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddElement(reimportButton);
            reimportButtonLayout.AddFlexibleSpace();
        }
Beispiel #13
0
        /// <summary>
        /// Recreates all the GUI elements used by this inspector.
        /// </summary>
        private void BuildGUI()
        {
            Layout.Clear();

            fontSizes = GUIArrayField <int, FontSizeArrayRow> .Create(
                new LocEdString("Font sizes"), importOptions.FontSizes, Layout);

            fontSizes.OnChanged += x => importOptions.FontSizes = x;
            fontSizes.IsExpanded = Persistent.GetBool("fontSizes_Expanded");
            fontSizes.OnExpand  += x => Persistent.SetBool("fontSizes_Expanded", x);

            charRanges = GUIArrayField <CharRange, CharRangeArrayRow> .Create(
                new LocEdString("Character ranges"), importOptions.CharRanges, Layout);

            charRanges.OnChanged += x => importOptions.CharRanges = x;
            charRanges.IsExpanded = Persistent.GetBool("charRanges_Expanded");
            charRanges.OnExpand  += x => Persistent.SetBool("charRanges_Expanded", x);

            renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode"));
            renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x;

            boldField            = new GUIToggleField(new LocEdString("Bold"));
            boldField.OnChanged += x => importOptions.Bold = x;

            italicField            = new GUIToggleField(new LocEdString("Italic"));
            italicField.OnChanged += x => importOptions.Italic = x;

            dpiField            = new GUIIntField(new LocEdString("DPI"));
            dpiField.OnChanged += x => importOptions.DPI = x;

            reimportButton          = new GUIButton(new LocEdString("Reimport"));
            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(renderModeField);
            Layout.AddElement(boldField);
            Layout.AddElement(italicField);
            Layout.AddElement(dpiField);
            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
Beispiel #14
0
        /// <inheritdoc/>
        protected internal override void Initialize()
        {
            importOptions = GetImportOptions();

            formatField.OnSelectionChanged   += x => importOptions.Format = (AudioFormat)x;
            readModeField.OnSelectionChanged += x => importOptions.ReadMode = (AudioReadMode)x;
            bitDepthField.OnSelectionChanged += x => importOptions.BitDepth = (AudioBitDepth)x;
            is3DField.OnChanged += x => importOptions.Is3D = x;

            reimportButton.OnClick += TriggerReimport;

            Layout.AddElement(formatField);
            Layout.AddElement(readModeField);
            Layout.AddElement(bitDepthField);
            Layout.AddElement(is3DField);
            Layout.AddSpace(10);

            GUILayout reimportButtonLayout = Layout.AddLayoutX();

            reimportButtonLayout.AddFlexibleSpace();
            reimportButtonLayout.AddElement(reimportButton);
        }
        public GUIAnimComplexEntry(GUIAnimFieldLayouts layouts, string path, string[] childEntries, Color[] colors)
            : base(layouts, path, false, 20)
        {
            foldout            = new GUIToggle("", EditorStyles.Expand);
            foldout.OnToggled += Toggle;

            GUILabel spacer = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight()));

            foldoutLayout = layouts.overlay.AddLayoutX();

            foldoutLayout.AddSpace(5);
            foldoutLayout.AddElement(foldout);
            foldoutLayout.AddElement(spacer);
            foldoutLayout.AddFlexibleSpace();

            underlaySpacing = new GUILabel("", GUIOption.FixedHeight(GetEntryHeight()));
            layouts.underlay.AddElement(underlaySpacing);

            children = new GUIAnimSimpleEntry[childEntries.Length];
            for (int i = 0; i < childEntries.Length; i++)
            {
                Color color;
                if (i < colors.Length)
                {
                    color = colors[i];
                }
                else
                {
                    color = Color.White;
                }

                children[i] = new GUIAnimSimpleEntry(layouts, path + childEntries[i], color, true);
                children[i].OnEntrySelected += x => { OnEntrySelected?.Invoke(x); };
            }

            Toggle(false);
        }
Beispiel #16
0
        private void OnInitialize()
        {
            Title = "Project Manager";

            Width  = 500;
            Height = 290;

            GUILayout vertLayout = GUI.AddLayoutY();

            vertLayout.AddSpace(5);
            GUILayout firstRow = vertLayout.AddLayoutX();

            vertLayout.AddFlexibleSpace();
            GUILayout secondRow = vertLayout.AddLayoutX();

            vertLayout.AddSpace(5);
            GUILayout thirdRow = vertLayout.AddLayoutX();

            vertLayout.AddFlexibleSpace();
            GUILayout fourthRow = vertLayout.AddLayoutX();

            vertLayout.AddSpace(5);

            projectInputBox       = new GUITextField(new LocEdString("Project path"), 70, false, "", GUIOption.FixedWidth(398));
            projectInputBox.Value = EditorSettings.LastOpenProject;

            GUIButton openBtn = new GUIButton(new LocEdString("Open"), GUIOption.FixedWidth(75));

            openBtn.OnClick += OpenProject;

            firstRow.AddSpace(5);
            firstRow.AddElement(projectInputBox);
            firstRow.AddSpace(15);
            firstRow.AddElement(openBtn);
            firstRow.AddSpace(5);

            GUILabel recentProjectsLabel = new GUILabel(new LocEdString("Recent projects:"));

            secondRow.AddSpace(5);
            secondRow.AddElement(recentProjectsLabel);
            secondRow.AddFlexibleSpace();
            GUIButton browseBtn = new GUIButton(new LocEdString("Browse"), GUIOption.FixedWidth(75));

            browseBtn.OnClick += BrowseClicked;
            secondRow.AddElement(browseBtn);
            secondRow.AddSpace(5);

            thirdRow.AddSpace(5);
            GUIPanel recentProjectsPanel = thirdRow.AddPanel();

            thirdRow.AddSpace(15);
            GUILayoutY thirdRowVertical = thirdRow.AddLayoutY();
            GUIButton  createBtn        = new GUIButton(new LocEdString("Create new"), GUIOption.FixedWidth(75));

            createBtn.OnClick += CreateClicked;
            thirdRowVertical.AddElement(createBtn);
            thirdRowVertical.AddFlexibleSpace();
            thirdRow.AddSpace(5);

            recentProjectsArea = new GUIScrollArea(GUIOption.FixedWidth(385), GUIOption.FixedHeight(170));
            GUILayoutX recentProjectsLayout = recentProjectsPanel.AddLayoutX();

            recentProjectsLayout.AddSpace(10);
            GUILayoutY recentProjectsPanelY = recentProjectsLayout.AddLayoutY();

            recentProjectsPanelY.AddSpace(5);
            recentProjectsPanelY.AddElement(recentProjectsArea);
            recentProjectsPanelY.AddSpace(5);
            recentProjectsLayout.AddFlexibleSpace();

            GUIPanel   scrollAreaBgPanel = recentProjectsPanel.AddPanel(1);
            GUITexture scrollAreaBgTex   = new GUITexture(null, true, EditorStylesInternal.ScrollAreaBg);

            scrollAreaBgPanel.AddElement(scrollAreaBgTex);

            autoLoadToggle       = new GUIToggle("");
            autoLoadToggle.Value = EditorSettings.AutoLoadLastProject;

            GUILabel autoLoadLabel = new GUILabel(new LocEdString("Automatically load last open project"));

            GUIButton cancelBtn = new GUIButton(new LocEdString("Cancel"), GUIOption.FixedWidth(75));

            cancelBtn.OnClick += CancelClicked;

            fourthRow.AddSpace(5);
            fourthRow.AddElement(autoLoadToggle);
            fourthRow.AddElement(autoLoadLabel);
            fourthRow.AddFlexibleSpace();
            fourthRow.AddElement(cancelBtn);
            fourthRow.AddSpace(5);

            RefreshRecentProjects();
        }
        private void OnInitialize()
        {
            GUIToggle projectFoldout = new GUIToggle(new LocEdString("Project"), EditorStyles.Foldout);
            GUIToggle editorFoldout  = new GUIToggle(new LocEdString("Editor"), EditorStyles.Foldout);

            defaultHandleSizeField            = new GUIFloatField(new LocEdString("Handle size"), 200);
            defaultHandleSizeField.OnChanged += (x) => { EditorSettings.DefaultHandleSize = x; };

            autoLoadLastProjectField            = new GUIToggleField(new LocEdString("Automatically load last project"), 200);
            autoLoadLastProjectField.OnChanged += (x) => { EditorSettings.AutoLoadLastProject = x; };

            CodeEditorType[] availableEditors = CodeEditor.AvailableEditors;
            Array.Resize(ref availableEditors, availableEditors.Length + 1);
            availableEditors[availableEditors.Length - 1] = CodeEditorType.None;

            string[] availableEditorNames = new string[availableEditors.Length];
            for (int i = 0; i < availableEditors.Length; i++)
            {
                availableEditorNames[i] = Enum.GetName(typeof(CodeEditorType), availableEditors[i]);
            }

            codeEditorField = new GUIListBoxField(availableEditorNames, new LocEdString("Code editor"), 200);
            codeEditorField.OnSelectionChanged += x =>
            {
                EditorSettings.SetInt(ActiveCodeEditorKey, (int)availableEditors[x]);
                CodeEditor.ActiveEditor = availableEditors[x];
            };

            fpsLimitField              = new GUIIntField(new LocEdString("FPS limit"), 200);
            fpsLimitField.OnConfirmed += () => EditorSettings.FPSLimit = fpsLimitField.Value;
            fpsLimitField.OnFocusLost += () => EditorSettings.FPSLimit = fpsLimitField.Value;

            mouseSensitivityField            = new GUISliderField(0.2f, 2.0f, new LocEdString("Mouse sensitivity"));
            mouseSensitivityField.OnChanged += (x) => EditorSettings.MouseSensitivity = x;

            GUILayout mainLayout = GUI.AddLayoutY();

            mainLayout.AddElement(projectFoldout);
            GUILayout projectLayoutOuterY = mainLayout.AddLayoutY();

            projectLayoutOuterY.AddSpace(5);
            GUILayout projectLayoutOuterX = projectLayoutOuterY.AddLayoutX();

            projectLayoutOuterX.AddSpace(5);
            GUILayout projectLayout = projectLayoutOuterX.AddLayoutY();

            projectLayoutOuterX.AddSpace(5);
            projectLayoutOuterY.AddSpace(5);

            mainLayout.AddElement(editorFoldout);
            GUILayout editorLayoutOuterY = mainLayout.AddLayoutY();

            editorLayoutOuterY.AddSpace(5);
            GUILayout editorLayoutOuterX = editorLayoutOuterY.AddLayoutX();

            editorLayoutOuterX.AddSpace(5);
            GUILayout editorLayout = editorLayoutOuterX.AddLayoutY();

            editorLayoutOuterX.AddSpace(5);
            editorLayoutOuterY.AddSpace(5);

            mainLayout.AddFlexibleSpace();

            editorLayout.AddElement(defaultHandleSizeField);
            editorLayout.AddElement(autoLoadLastProjectField);
            editorLayout.AddElement(codeEditorField);
            editorLayout.AddElement(fpsLimitField);
            editorLayout.AddElement(mouseSensitivityField);

            projectFoldout.Value = true;
            editorFoldout.Value  = true;

            projectFoldout.OnToggled += (x) => projectLayout.Active = x;
            editorFoldout.OnToggled  += (x) => editorLayout.Active = x;
        }
Beispiel #18
0
        private void OnInitialize()
        {
            mainLayout = GUI.AddLayoutY();

            GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View),
                                                 new LocEdString("View"));
            GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move),
                                                 new LocEdString("Move"));
            GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate),
                                                   new LocEdString("Rotate"));
            GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale),
                                                  new LocEdString("Scale"));

            GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local),
                                                  new LocEdString("Local"));
            GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World),
                                                  new LocEdString("World"));

            GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot),
                                                  new LocEdString("Pivot"));
            GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center),
                                                   new LocEdString("Center"));

            GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap),
                                                     new LocEdString("Move snap"));
            GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap),
                                                       new LocEdString("Rotate snap"));

            GUIToggleGroup handlesTG = new GUIToggleGroup();

            viewButton   = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveButton   = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            scaleButton  = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            GUIToggleGroup coordModeTG = new GUIToggleGroup();

            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));

            GUIToggleGroup pivotModeTG = new GUIToggleGroup();

            pivotButton  = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveSnapInput  = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateSnapInput  = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            GUIContent cameraOptionsIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.SceneCameraOptions), new LocEdString("Camera options"));

            cameraOptionsButton = new GUIButton(cameraOptionsIcon);

            viewButton.OnClick   += () => OnSceneToolButtonClicked(SceneViewTool.View);
            moveButton.OnClick   += () => OnSceneToolButtonClicked(SceneViewTool.Move);
            rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
            scaleButton.OnClick  += () => OnSceneToolButtonClicked(SceneViewTool.Scale);

            localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local);
            worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World);

            pivotButton.OnClick  += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot);
            centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center);

            moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active);
            moveSnapInput.OnChanged  += (float value) => OnMoveSnapValueChanged(value);

            rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
            rotateSnapInput.OnChanged  += (float value) => OnRotateSnapValueChanged(value);

            cameraOptionsButton.OnClick += () => OnCameraOptionsClicked();

            GUILayout handlesLayout = mainLayout.AddLayoutX();

            handlesLayout.AddElement(viewButton);
            handlesLayout.AddElement(moveButton);
            handlesLayout.AddElement(rotateButton);
            handlesLayout.AddElement(scaleButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(localCoordButton);
            handlesLayout.AddElement(worldCoordButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(pivotButton);
            handlesLayout.AddElement(centerButton);
            handlesLayout.AddFlexibleSpace();
            handlesLayout.AddElement(moveSnapButton);
            handlesLayout.AddElement(moveSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(rotateSnapButton);
            handlesLayout.AddElement(rotateSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(cameraOptionsButton);
            handlesLayout.SetHeight(viewButton.Bounds.height);

            GUIPanel mainPanel = mainLayout.AddPanel();

            rtPanel = mainPanel.AddPanel();

            // Loading progress
            loadLabel       = new GUILabel(new LocEdString("Loading scene..."));
            loadProgressBar = new GUIProgressBar("", GUIOption.FixedWidth(200));

            progressLayout = mainPanel.AddLayoutY();
            progressLayout.AddFlexibleSpace();
            GUILayout loadLabelLayout = progressLayout.AddLayoutX();

            loadLabelLayout.AddFlexibleSpace();
            loadLabelLayout.AddElement(loadLabel);
            loadLabelLayout.AddFlexibleSpace();

            GUILayout progressBarLayout = progressLayout.AddLayoutX();

            progressBarLayout.AddFlexibleSpace();
            progressBarLayout.AddElement(loadProgressBar);
            progressBarLayout.AddFlexibleSpace();
            progressLayout.AddFlexibleSpace();

            progressLayout.Active = false;

            selectionPanel = mainPanel.AddPanel(-1);

            sceneAxesPanel = mainPanel.AddPanel(-1);
            sceneAxesGUI   = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective);

            focusCatcher = new GUIButton("", EditorStyles.Blank);
            focusCatcher.OnFocusGained += () => hasContentFocus = true;
            focusCatcher.OnFocusLost   += () => hasContentFocus = false;

            GUIPanel focusPanel = GUI.AddPanel(-2);

            focusPanel.AddElement(focusCatcher);

            viewToolKey   = new VirtualButton(ViewToolBinding);
            moveToolKey   = new VirtualButton(MoveToolBinding);
            rotateToolKey = new VirtualButton(RotateToolBinding);
            scaleToolKey  = new VirtualButton(ScaleToolBinding);
            frameKey      = new VirtualButton(FrameBinding);

            UpdateRenderTexture(Width, Height - HeaderHeight);
            UpdateLoadingProgress();
        }
Beispiel #19
0
        private void OnInitialize()
        {
            GUILabel title    = new GUILabel(new LocEdString("Banshee Engine v0.4"), EditorStyles.TitleLabel);
            GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"),
                                             EditorStyles.LabelCentered);
            GUILabel license = new GUILabel(new LocEdString(
                                                "This program is licensed under the GNU Lesser General Public License V3"), EditorStyles.LabelCentered);
            GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2015 Marko Pintera. All rights reserved."),
                                              EditorStyles.LabelCentered);

            GUILabel authorLabel = new GUILabel(new LocEdString("Banshee was created, and is being actively developed by Marko Pintera."));
            GUILabel emailTitle  = new GUILabel(new LocEdString("E-mail"), GUIOption.FixedWidth(150));

            emailLabel = new GUITextBox();
            GUILabel  linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150));
            GUIButton linkedInBtn   = new GUIButton(new LocEdString("Profile"));

            GUIToggleGroup foldoutGroup         = new GUIToggleGroup(true);
            GUIToggle      contactFoldout       = new GUIToggle(new LocEdString("Author"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      thirdPartyFoldout    = new GUIToggle(new LocEdString("Used third party libraries"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      noticesFoldout       = new GUIToggle(new LocEdString("Third party notices"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      collaboratorsFoldout = new GUIToggle(new LocEdString("Collaborators"), foldoutGroup, EditorStyles.Foldout);

            contactFoldout.AcceptsKeyFocus       = false;
            thirdPartyFoldout.AcceptsKeyFocus    = false;
            noticesFoldout.AcceptsKeyFocus       = false;
            collaboratorsFoldout.AcceptsKeyFocus = false;

            GUILabel freeTypeNotice = new GUILabel(new LocEdString(
                                                       "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " +
                                                       "All rights reserved."), EditorStyles.MultiLineLabelCentered,
                                                   GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380));

            GUILabel fbxSdkNotice = new GUILabel(new LocEdString(
                                                     "This software contains Autodesk(R) FBX(R) code developed by Autodesk, Inc. Copyright 2013 Autodesk, Inc. " +
                                                     "All rights, reserved. Such code is provided \"as is\" and Autodesk, Inc. disclaims any and all warranties, " +
                                                     "whether express or implied, including without limitation the implied warranties of merchantability, " +
                                                     "fitness for a particular purpose or non-infringement of third party rights. In no event shall Autodesk, " +
                                                     "Inc. be liable for any direct, indirect, incidental, special, exemplary, or consequential damages " +
                                                     "(including, but not limited to, procurement of substitute goods or services; loss of use, data, or " +
                                                     "profits; or business interruption) however caused and on any theory of liability, whether in contract, " +
                                                     "strict liability, or tort (including negligence or otherwise) arising in any way out of such code."),
                                                 EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380));

            GUILayoutY mainLayout = GUI.AddLayoutY();

            mainLayout.AddSpace(10);
            mainLayout.AddElement(title);
            mainLayout.AddElement(subTitle);
            mainLayout.AddSpace(10);
            mainLayout.AddElement(license);
            mainLayout.AddElement(copyright);
            mainLayout.AddSpace(10);
            mainLayout.AddElement(contactFoldout);

            GUILayoutY contactLayout = mainLayout.AddLayoutY();

            contactLayout.AddSpace(15);
            GUILayout authorLayout = contactLayout.AddLayoutX();

            authorLayout.AddFlexibleSpace();
            authorLayout.AddElement(authorLabel);
            authorLayout.AddFlexibleSpace();
            contactLayout.AddSpace(15);
            GUILayout emailLayout = contactLayout.AddLayoutX();

            emailLayout.AddSpace(10);
            emailLayout.AddElement(emailTitle);
            emailLayout.AddElement(emailLabel);
            emailLayout.AddSpace(10);
            GUILayout linkedInLayout = contactLayout.AddLayoutX();

            linkedInLayout.AddSpace(10);
            linkedInLayout.AddElement(linkedInTitle);
            linkedInLayout.AddElement(linkedInBtn);
            linkedInLayout.AddSpace(10);

            mainLayout.AddSpace(5);
            mainLayout.AddElement(thirdPartyFoldout);
            GUILayoutY thirdPartyLayout = mainLayout.AddLayoutY();

            CreateThirdPartyGUI(thirdPartyLayout, "Autodesk FBX SDK",
                                "http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775847");
            CreateThirdPartyGUI(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/");
            CreateThirdPartyGUI(thirdPartyLayout, "FreeType", "http://www.freetype.org/");
            CreateThirdPartyGUI(thirdPartyLayout, "Mono", "http://www.mono-project.com/");
            CreateThirdPartyGUI(thirdPartyLayout, "NVIDIA Texture Tools",
                                "https://github.com/castano/nvidia-texture-tools");
            CreateThirdPartyGUI(thirdPartyLayout, "libFLAC", "https://xiph.org/flac/");
            CreateThirdPartyGUI(thirdPartyLayout, "libOgg", "https://www.xiph.org/ogg/");
            CreateThirdPartyGUI(thirdPartyLayout, "libVorbis", "http://www.vorbis.com/");
            CreateThirdPartyGUI(thirdPartyLayout, "OpenAL Soft", "http://kcat.strangesoft.net/openal.html");

            mainLayout.AddSpace(5);
            mainLayout.AddElement(noticesFoldout);
            GUILayout noticesLayout = mainLayout.AddLayoutY();

            noticesLayout.AddElement(freeTypeNotice);
            noticesLayout.AddSpace(10);
            noticesLayout.AddElement(fbxSdkNotice);

            mainLayout.AddSpace(5);
            mainLayout.AddElement(collaboratorsFoldout);
            GUILayoutY collaboratorsLayout = mainLayout.AddLayoutY();

            CreateCollaboratorGUI(collaboratorsLayout, "Danijel Ribic", "Logo, UI icons, 3D models & textures");
            CreateCollaboratorGUI(collaboratorsLayout, "Marco Bellan", "Bugfixes, editor enhancements");

            mainLayout.AddFlexibleSpace();

            contactLayout.Active      = false;
            contactFoldout.OnToggled += x =>
            {
                contactLayout.Active = x;
            };

            thirdPartyLayout.Active      = false;
            thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x;

            noticesLayout.Active      = false;
            noticesFoldout.OnToggled += x => noticesLayout.Active = x;

            collaboratorsLayout.Active      = false;
            collaboratorsFoldout.OnToggled += x => collaboratorsLayout.Active = x;

            emailLabel.Text      = "*****@*****.**";
            linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); };
        }
Beispiel #20
0
        /// <summary>
        /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
        /// use.
        /// </summary>
        /// <param name="animEvent">Event whose properties to edit.</param>
        /// <param name="componentNames">List of component names that the user can select from.</param>
        /// <param name="updateCallback">Callback triggered when event values change.</param>
        internal void Initialize(AnimationEvent animEvent, string[] componentNames, Action updateCallback)
        {
            int    selectedIndex = -1;
            string methodName    = "";

            if (!string.IsNullOrEmpty(animEvent.Name))
            {
                string[] nameEntries = animEvent.Name.Split('/');
                if (nameEntries.Length > 1)
                {
                    string typeName = nameEntries[0];
                    for (int i = 0; i < componentNames.Length; i++)
                    {
                        if (componentNames[i] == typeName)
                        {
                            selectedIndex = i;
                            break;
                        }
                    }

                    methodName = nameEntries[nameEntries.Length - 1];
                }
            }

            GUIFloatField timeField = new GUIFloatField(new LocEdString("Time"), 40, "");

            timeField.Value      = animEvent.Time;
            timeField.OnChanged += x => { animEvent.Time = x; updateCallback(); }; // TODO UNDOREDO

            GUIListBoxField componentField = new GUIListBoxField(componentNames, new LocEdString("Component"), 40);

            if (selectedIndex != -1)
            {
                componentField.Index = selectedIndex;
            }

            componentField.OnSelectionChanged += x =>
            {
                string compName = "";
                if (x != -1)
                {
                    compName = componentNames[x] + "/";
                }

                animEvent.Name = compName + x;
                updateCallback();
            };// TODO UNDOREDO

            GUITextField methodField = new GUITextField(new LocEdString("Method"), 40, false, "", GUIOption.FixedWidth(190));

            methodField.Value      = methodName;
            methodField.OnChanged += x =>
            {
                string compName = "";
                if (componentField.Index != -1)
                {
                    compName = componentNames[componentField.Index] + "/";
                }

                animEvent.Name = compName + x;
                updateCallback();
            }; // TODO UNDOREDO

            GUILayoutY vertLayout = GUI.AddLayoutY();

            vertLayout.AddFlexibleSpace();
            GUILayoutX horzLayout = vertLayout.AddLayoutX();

            horzLayout.AddFlexibleSpace();
            GUILayout contentLayout = horzLayout.AddLayoutY();
            GUILayout timeLayout    = contentLayout.AddLayoutX();

            timeLayout.AddSpace(5);
            timeLayout.AddElement(timeField);
            timeLayout.AddFlexibleSpace();
            GUILayout componentLayout = contentLayout.AddLayoutX();

            componentLayout.AddSpace(5);
            componentLayout.AddElement(componentField);
            componentLayout.AddFlexibleSpace();
            GUILayout methodLayout = contentLayout.AddLayoutX();

            methodLayout.AddSpace(5);
            methodLayout.AddElement(methodField);
            methodLayout.AddFlexibleSpace();
            horzLayout.AddFlexibleSpace();
            vertLayout.AddFlexibleSpace();
        }
Beispiel #21
0
        /// <summary>
        /// Refreshes the contents of the content area. Must be called at least once after construction.
        /// </summary>
        /// <param name="viewType">Determines how to display the resource tiles.</param>
        /// <param name="entriesToDisplay">Project library entries to display.</param>
        /// <param name="bounds">Bounds within which to lay out the content entries.</param>
        public void Refresh(ProjectViewType viewType, LibraryEntry[] entriesToDisplay, Rect2I bounds)
        {
            if (mainPanel != null)
            {
                mainPanel.Destroy();
            }

            entries.Clear();
            entryLookup.Clear();

            mainPanel = parent.Layout.AddPanel();

            GUIPanel contentPanel = mainPanel.AddPanel(1);

            overlay       = mainPanel.AddPanel(0);
            underlay      = mainPanel.AddPanel(2);
            deepUnderlay  = mainPanel.AddPanel(3);
            renameOverlay = mainPanel.AddPanel(-1);

            main = contentPanel.AddLayoutY();

            List <ResourceToDisplay> resourcesToDisplay = new List <ResourceToDisplay>();

            foreach (var entry in entriesToDisplay)
            {
                if (entry.Type == LibraryEntryType.Directory)
                {
                    resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single));
                }
                else
                {
                    FileEntry      fileEntry = (FileEntry)entry;
                    ResourceMeta[] metas     = fileEntry.ResourceMetas;

                    if (metas.Length > 0)
                    {
                        if (metas.Length == 1)
                        {
                            resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single));
                        }
                        else
                        {
                            resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.MultiFirst));

                            for (int i = 1; i < metas.Length - 1; i++)
                            {
                                string path = Path.Combine(entry.Path, metas[i].SubresourceName);
                                resourcesToDisplay.Add(new ResourceToDisplay(path, LibraryGUIEntryType.MultiElement));
                            }

                            string lastPath = Path.Combine(entry.Path, metas[metas.Length - 1].SubresourceName);
                            resourcesToDisplay.Add(new ResourceToDisplay(lastPath, LibraryGUIEntryType.MultiLast));
                        }
                    }
                }
            }

            if (viewType == ProjectViewType.List16)
            {
                tileSize           = 16;
                gridLayout         = false;
                elementsPerRow     = 1;
                horzElementSpacing = 0;
                int elemWidth  = bounds.width;
                int elemHeight = tileSize;

                main.AddSpace(TOP_MARGIN);

                for (int i = 0; i < resourcesToDisplay.Count; i++)
                {
                    ResourceToDisplay entry = resourcesToDisplay[i];

                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, elemWidth, elemHeight,
                                                                   entry.type);
                    entries.Add(guiEntry);
                    entryLookup[guiEntry.path] = guiEntry;

                    if (i != resourcesToDisplay.Count - 1)
                    {
                        main.AddSpace(LIST_ENTRY_SPACING);
                    }
                }

                main.AddFlexibleSpace();
            }
            else
            {
                int elemWidth       = 0;
                int elemHeight      = 0;
                int vertElemSpacing = 0;

                switch (viewType)
                {
                case ProjectViewType.Grid64:
                    tileSize           = 64;
                    elemWidth          = tileSize;
                    elemHeight         = tileSize + 36;
                    horzElementSpacing = 10;
                    vertElemSpacing    = 12;
                    break;

                case ProjectViewType.Grid48:
                    tileSize           = 48;
                    elemWidth          = tileSize;
                    elemHeight         = tileSize + 36;
                    horzElementSpacing = 8;
                    vertElemSpacing    = 10;
                    break;

                case ProjectViewType.Grid32:
                    tileSize           = 32;
                    elemWidth          = tileSize + 16;
                    elemHeight         = tileSize + 48;
                    horzElementSpacing = 6;
                    vertElemSpacing    = 10;
                    break;
                }

                gridLayout = true;

                int availableWidth = bounds.width;

                elementsPerRow = MathEx.FloorToInt((availableWidth - horzElementSpacing) / (float)(elemWidth + horzElementSpacing));
                elementsPerRow = Math.Max(elementsPerRow, 1);

                int numRows      = MathEx.CeilToInt(resourcesToDisplay.Count / (float)elementsPerRow);
                int neededHeight = numRows * elemHeight + TOP_MARGIN;
                if (numRows > 0)
                {
                    neededHeight += (numRows - 1) * vertElemSpacing;
                }

                bool requiresScrollbar = neededHeight > bounds.height;
                if (requiresScrollbar)
                {
                    availableWidth -= parent.ScrollBarWidth;
                    elementsPerRow  = MathEx.FloorToInt((availableWidth - horzElementSpacing) / (float)(elemWidth + horzElementSpacing));
                    elementsPerRow  = Math.Max(elementsPerRow, 1);
                }

                int extraRowSpace = availableWidth - (elementsPerRow * (elemWidth + horzElementSpacing) + horzElementSpacing);

                main.AddSpace(TOP_MARGIN);
                GUILayoutX rowLayout = main.AddLayoutX();
                rowLayout.AddSpace(horzElementSpacing);

                int elemsInRow = 0;
                for (int i = 0; i < resourcesToDisplay.Count; i++)
                {
                    if (elemsInRow == elementsPerRow && elemsInRow > 0)
                    {
                        main.AddSpace(vertElemSpacing);
                        rowLayout.AddSpace(extraRowSpace);
                        rowLayout = main.AddLayoutX();
                        rowLayout.AddSpace(horzElementSpacing);

                        elemsInRow = 0;
                    }

                    ResourceToDisplay entry = resourcesToDisplay[i];

                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entry.path, i, elemWidth, elemHeight,
                                                                   entry.type);
                    entries.Add(guiEntry);
                    entryLookup[guiEntry.path] = guiEntry;

                    rowLayout.AddSpace(horzElementSpacing);

                    elemsInRow++;
                }

                int extraElements = elementsPerRow - elemsInRow;
                rowLayout.AddSpace((elemWidth + horzElementSpacing) * extraElements + extraRowSpace);

                main.AddFlexibleSpace();
            }

            for (int i = 0; i < entries.Count; i++)
            {
                LibraryGUIEntry guiEntry = entries[i];
                guiEntry.Initialize();
            }
        }
        private void OnInitialize()
        {
            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            GUILayout mainVertLayout = GUI.AddLayoutY();

            mainVertLayout.AddSpace(10);

            GUILayout editorHorzLayout = mainVertLayout.AddLayoutX();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);
            GUIPanel gradientEditorPanel = editorHorzLayout.AddPanel();

            editorHorzLayout.AddSpace(EDITOR_HORZ_PADDING);

            mainVertLayout.AddSpace(15);

            GUILayout buttonHorzLayout = mainVertLayout.AddLayoutX();

            buttonHorzLayout.AddFlexibleSpace();
            buttonHorzLayout.AddElement(guiOK);
            buttonHorzLayout.AddSpace(10);
            buttonHorzLayout.AddElement(guiCancel);
            buttonHorzLayout.AddFlexibleSpace();

            mainVertLayout.AddFlexibleSpace();

            editorPanel = gradientEditorPanel.AddPanel(0);
            GUIPanel editorOverlay = gradientEditorPanel.AddPanel(-1);

            overlayCanvas = new GUICanvas();
            editorOverlay.AddElement(overlayCanvas);

            GUILayout editorVertLayout = editorPanel.AddLayoutY();

            GUILayout guiGradientLayout = editorVertLayout.AddLayoutX();

            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            texture       = Texture.Create2D(TEX_WIDTH, TEX_HEIGHT);
            spriteTexture = new SpriteTexture(texture);

            guiGradientTexture = new GUITexture(spriteTexture, GUITextureScaleMode.StretchToFit);
            guiGradientTexture.SetHeight(30);

            UpdateTexture();

            guiGradientLayout.AddElement(guiGradientTexture);
            guiGradientLayout.AddSpace(GradientKeyEditor.RECT_WIDTH / 2);

            editorVertLayout.AddSpace(10);

            editor = new GradientKeyEditor(editorVertLayout, gradient.GetKeys(), Width - EDITOR_HORZ_PADDING * 2, 20);
            editor.OnGradientModified += colorGradient =>
            {
                gradient = colorGradient;

                UpdateTexture();
                UpdateKeyLines();
            };

            editorVertLayout.AddFlexibleSpace();

            GUITexture containerBg     = new GUITexture(null, EditorStylesInternal.ContainerBg);
            Rect2I     containerBounds = editor.GetBounds(GUI);

            containerBounds.x      -= 2;
            containerBounds.y      -= 2;
            containerBounds.width  += 4;
            containerBounds.height += 6;
            containerBg.Bounds      = containerBounds;

            GUIPanel editorUnderlay = GUI.AddPanel(1);

            editorUnderlay.AddElement(containerBg);

            UpdateKeyLines();

            EditorInput.OnPointerPressed     += OnPointerPressed;
            EditorInput.OnPointerDoubleClick += OnPointerDoubleClicked;
            EditorInput.OnPointerMoved       += OnPointerMoved;
            EditorInput.OnPointerReleased    += OnPointerReleased;
            EditorInput.OnButtonUp           += OnButtonUp;
        }
Beispiel #23
0
        /// <summary>
        /// Refreshes the contents of the content area. Must be called at least once after construction.
        /// </summary>
        /// <param name="viewType">Determines how to display the resource tiles.</param>
        /// <param name="entriesToDisplay">Project library entries to display.</param>
        /// <param name="bounds">Bounds within which to lay out the content entries.</param>
        public void Refresh(ProjectViewType viewType, LibraryEntry[] entriesToDisplay, Rect2I bounds)
        {
            if (mainPanel != null)
            {
                mainPanel.Destroy();
            }

            entries.Clear();
            entryLookup.Clear();

            mainPanel = parent.Layout.AddPanel();

            GUIPanel contentPanel = mainPanel.AddPanel(1);

            overlay       = mainPanel.AddPanel(0);
            underlay      = mainPanel.AddPanel(2);
            deepUnderlay  = mainPanel.AddPanel(3);
            renameOverlay = mainPanel.AddPanel(-1);

            main = contentPanel.AddLayoutY();

            List <ResourceToDisplay> resourcesToDisplay = new List <ResourceToDisplay>();

            foreach (var entry in entriesToDisplay)
            {
                if (entry.Type == LibraryEntryType.Directory)
                {
                    resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single));
                }
                else
                {
                    FileEntry      fileEntry = (FileEntry)entry;
                    ResourceMeta[] metas     = fileEntry.ResourceMetas;

                    if (metas.Length > 0)
                    {
                        if (metas.Length == 1)
                        {
                            resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single));
                        }
                        else
                        {
                            resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.MultiFirst));

                            for (int i = 1; i < metas.Length - 1; i++)
                            {
                                string path = Path.Combine(entry.Path, metas[i].SubresourceName);
                                resourcesToDisplay.Add(new ResourceToDisplay(path, LibraryGUIEntryType.MultiElement));
                            }

                            string lastPath = Path.Combine(entry.Path, metas[metas.Length - 1].SubresourceName);
                            resourcesToDisplay.Add(new ResourceToDisplay(lastPath, LibraryGUIEntryType.MultiLast));
                        }
                    }
                }
            }

            int minHorzElemSpacing = 0;

            if (viewType == ProjectViewType.List16)
            {
                tileSize           = 16;
                gridLayout         = false;
                elementsPerRow     = 1;
                minHorzElemSpacing = 0;
                int elemWidth  = bounds.width;
                int elemHeight = tileSize;

                main.AddSpace(TOP_MARGIN);

                for (int i = 0; i < resourcesToDisplay.Count; i++)
                {
                    ResourceToDisplay entry = resourcesToDisplay[i];

                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, elemWidth, elemHeight, 0,
                                                                   entry.type);
                    entries.Add(guiEntry);
                    entryLookup[guiEntry.path] = guiEntry;

                    if (i != resourcesToDisplay.Count - 1)
                    {
                        main.AddSpace(LIST_ENTRY_SPACING);
                    }
                }

                main.AddFlexibleSpace();
            }
            else
            {
                int elemWidth       = 0;
                int elemHeight      = 0;
                int vertElemSpacing = 0;

                switch (viewType)
                {
                case ProjectViewType.Grid64:
                    tileSize           = 64;
                    elemWidth          = tileSize;
                    elemHeight         = tileSize + 36;
                    minHorzElemSpacing = 10;
                    vertElemSpacing    = 12;
                    break;

                case ProjectViewType.Grid48:
                    tileSize           = 48;
                    elemWidth          = tileSize;
                    elemHeight         = tileSize + 36;
                    minHorzElemSpacing = 8;
                    vertElemSpacing    = 10;
                    break;

                case ProjectViewType.Grid32:
                    tileSize           = 32;
                    elemWidth          = tileSize + 16;
                    elemHeight         = tileSize + 48;
                    minHorzElemSpacing = 6;
                    vertElemSpacing    = 10;
                    break;
                }

                gridLayout = true;

                int availableWidth = bounds.width;
                elementsPerRow = MathEx.FloorToInt((availableWidth - minHorzElemSpacing) / (float)(elemWidth + minHorzElemSpacing));

                int numRows      = MathEx.CeilToInt(resourcesToDisplay.Count / (float)Math.Max(elementsPerRow, 1));
                int neededHeight = numRows * elemHeight + TOP_MARGIN;
                if (numRows > 0)
                {
                    neededHeight += (numRows - 1) * vertElemSpacing;
                }

                bool requiresScrollbar = neededHeight > bounds.height;
                if (requiresScrollbar)
                {
                    availableWidth -= parent.ScrollBarWidth;
                    elementsPerRow  = MathEx.FloorToInt((availableWidth - minHorzElemSpacing) / (float)(elemWidth + minHorzElemSpacing));
                }

                int extraRowSpace = availableWidth - minHorzElemSpacing * 2 - elementsPerRow * elemWidth;

                paddingLeft  = minHorzElemSpacing;
                paddingRight = minHorzElemSpacing;
                float horzSpacing = 0.0f;

                // Distribute the spacing to the padding, as there are not in-between spaces to apply it to
                if (extraRowSpace > 0 && elementsPerRow < 2)
                {
                    int extraPadding = extraRowSpace / 2;
                    paddingLeft  += extraPadding;
                    paddingRight += (extraRowSpace - extraPadding);

                    extraRowSpace = 0;
                }
                else
                {
                    horzSpacing = extraRowSpace / (float)(elementsPerRow - 1);
                }

                elementsPerRow = Math.Max(elementsPerRow, 1);

                main.AddSpace(TOP_MARGIN);
                GUILayoutX rowLayout = main.AddLayoutX();
                rowLayout.AddSpace(paddingLeft);

                float spacingCounter = 0.0f;
                int   elemsInRow     = 0;
                for (int i = 0; i < resourcesToDisplay.Count; i++)
                {
                    if (elemsInRow == elementsPerRow && elemsInRow > 0)
                    {
                        main.AddSpace(vertElemSpacing);
                        rowLayout = main.AddLayoutX();
                        rowLayout.AddSpace(paddingLeft);

                        elemsInRow     = 0;
                        spacingCounter = 0.0f;
                    }

                    ResourceToDisplay entry = resourcesToDisplay[i];
                    elemsInRow++;

                    if (elemsInRow != elementsPerRow)
                    {
                        spacingCounter += horzSpacing;
                    }

                    int spacing = (int)spacingCounter;
                    spacingCounter -= spacing;

                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entry.path, i, elemWidth, elemHeight,
                                                                   spacing, entry.type);
                    entries.Add(guiEntry);
                    entryLookup[guiEntry.path] = guiEntry;

                    if (elemsInRow == elementsPerRow)
                    {
                        rowLayout.AddSpace(paddingRight);
                    }

                    rowLayout.AddSpace(spacing);
                }

                int extraElements = elementsPerRow - elemsInRow;
                int extraSpacing  = 0;

                if (extraElements > 1)
                {
                    spacingCounter += (extraElements - 1) * horzSpacing;
                    extraSpacing   += (int)spacingCounter;
                }

                if (extraElements > 0)
                {
                    rowLayout.AddSpace(elemWidth * extraElements + extraSpacing + paddingRight);
                }

                main.AddFlexibleSpace();
            }

            // Fix bounds as that makes GUI updates faster
            underlay.Bounds      = main.Bounds;
            overlay.Bounds       = main.Bounds;
            deepUnderlay.Bounds  = main.Bounds;
            renameOverlay.Bounds = main.Bounds;

            for (int i = 0; i < entries.Count; i++)
            {
                LibraryGUIEntry guiEntry = entries[i];
                guiEntry.Initialize();
            }
        }
Beispiel #24
0
        /// <summary>
        /// Sets a scene object whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="so">Scene object to inspect.</param>
        private void SetObjectToInspect(SceneObject so)
        {
            if (so == null)
            {
                return;
            }

            currentType = InspectorType.SceneObject;
            activeSO    = so;

            inspectorScrollArea = new GUIScrollArea();
            scrollAreaHighlight = new GUITexture(Builtin.WhiteTexture);
            scrollAreaHighlight.SetTint(HIGHLIGHT_COLOR);
            scrollAreaHighlight.Active = false;

            GUI.AddElement(inspectorScrollArea);
            GUIPanel inspectorPanel = inspectorScrollArea.Layout.AddPanel();

            inspectorLayout = inspectorPanel.AddLayoutY();
            highlightPanel  = inspectorPanel.AddPanel(-1);
            highlightPanel.AddElement(scrollAreaHighlight);

            // SceneObject fields
            CreateSceneObjectFields();
            RefreshSceneObjectFields(true);

            // Components
            Component[] allComponents = so.GetComponents();
            for (int i = 0; i < allComponents.Length; i++)
            {
                inspectorLayout.AddSpace(COMPONENT_SPACING);

                InspectorComponent data = new InspectorComponent();
                data.instanceId = allComponents[i].InstanceId;
                data.folded     = false;

                data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout);
                data.foldout.AcceptsKeyFocus = false;

                SpriteTexture xBtnIcon = EditorBuiltin.GetEditorIcon(EditorIcon.X);
                data.removeBtn = new GUIButton(new GUIContent(xBtnIcon), GUIOption.FixedWidth(30));

                data.title = inspectorLayout.AddLayoutX();
                data.title.AddElement(data.foldout);
                data.title.AddElement(data.removeBtn);
                data.panel = inspectorLayout.AddPanel();

                var persistentProperties = persistentData.GetProperties(allComponents[i].InstanceId);

                data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType());
                data.inspector.Initialize(data.panel, allComponents[i], persistentProperties);

                bool isExpanded = data.inspector.Persistent.GetBool(data.instanceId + "_Expanded", true);
                data.foldout.Value = isExpanded;

                if (!isExpanded)
                {
                    data.inspector.SetVisible(false);
                }

                Type curComponentType = allComponents[i].GetType();
                data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);
                data.removeBtn.OnClick += () => OnComponentRemoveClicked(curComponentType);

                inspectorComponents.Add(data);
            }

            inspectorLayout.AddFlexibleSpace();

            UpdateDropAreas();
        }
Beispiel #25
0
        private void OnInitialize()
        {
            mainLayout = GUI.AddLayoutY();

            GUIContent viewIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.View), 
                new LocEdString("View"));
            GUIContent moveIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Move), 
                new LocEdString("Move"));
            GUIContent rotateIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Rotate), 
                new LocEdString("Rotate"));
            GUIContent scaleIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Scale), 
                new LocEdString("Scale"));

            GUIContent localIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Local), 
                new LocEdString("Local"));
            GUIContent worldIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.World), 
                new LocEdString("World"));

            GUIContent pivotIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Pivot), 
                new LocEdString("Pivot"));
            GUIContent centerIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.Center), 
                new LocEdString("Center"));

            GUIContent moveSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.MoveSnap), 
                new LocEdString("Move snap"));
            GUIContent rotateSnapIcon = new GUIContent(EditorBuiltin.GetSceneWindowIcon(SceneWindowIcon.RotateSnap), 
                new LocEdString("Rotate snap"));

            GUIToggleGroup handlesTG = new GUIToggleGroup();
            viewButton = new GUIToggle(viewIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveButton = new GUIToggle(moveIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateButton = new GUIToggle(rotateIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            scaleButton = new GUIToggle(scaleIcon, handlesTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            GUIToggleGroup coordModeTG = new GUIToggleGroup();
            localCoordButton = new GUIToggle(localIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));
            worldCoordButton = new GUIToggle(worldIcon, coordModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(75));

            GUIToggleGroup pivotModeTG = new GUIToggleGroup();
            pivotButton = new GUIToggle(pivotIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            centerButton = new GUIToggle(centerIcon, pivotModeTG, EditorStyles.Button, GUIOption.FlexibleWidth(35));

            moveSnapButton = new GUIToggle(moveSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            moveSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            rotateSnapButton = new GUIToggle(rotateSnapIcon, EditorStyles.Button, GUIOption.FlexibleWidth(35));
            rotateSnapInput = new GUIFloatField("", GUIOption.FlexibleWidth(35));

            viewButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.View);
            moveButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Move);
            rotateButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Rotate);
            scaleButton.OnClick += () => OnSceneToolButtonClicked(SceneViewTool.Scale);

            localCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.Local);
            worldCoordButton.OnClick += () => OnCoordinateModeButtonClicked(HandleCoordinateMode.World);

            pivotButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Pivot);
            centerButton.OnClick += () => OnPivotModeButtonClicked(HandlePivotMode.Center);

            moveSnapButton.OnToggled += (bool active) => OnMoveSnapToggled(active);
            moveSnapInput.OnChanged += (float value) => OnMoveSnapValueChanged(value);

            rotateSnapButton.OnToggled += (bool active) => OnRotateSnapToggled(active);
            rotateSnapInput.OnChanged += (float value) => OnRotateSnapValueChanged(value);

            GUILayout handlesLayout = mainLayout.AddLayoutX();
            handlesLayout.AddElement(viewButton);
            handlesLayout.AddElement(moveButton);
            handlesLayout.AddElement(rotateButton);
            handlesLayout.AddElement(scaleButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(localCoordButton);
            handlesLayout.AddElement(worldCoordButton);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(pivotButton);
            handlesLayout.AddElement(centerButton);
            handlesLayout.AddFlexibleSpace();
            handlesLayout.AddElement(moveSnapButton);
            handlesLayout.AddElement(moveSnapInput);
            handlesLayout.AddSpace(10);
            handlesLayout.AddElement(rotateSnapButton);
            handlesLayout.AddElement(rotateSnapInput);

            GUIPanel mainPanel = mainLayout.AddPanel();
            rtPanel = mainPanel.AddPanel();

            GUIPanel sceneAxesPanel = mainPanel.AddPanel(-1);
            sceneAxesGUI = new SceneAxesGUI(this, sceneAxesPanel, HandleAxesGUISize, HandleAxesGUISize, ProjectionType.Perspective);

            toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding);
            viewToolKey = new VirtualButton(ViewToolBinding);
            moveToolKey = new VirtualButton(MoveToolBinding);
            rotateToolKey = new VirtualButton(RotateToolBinding);
            scaleToolKey = new VirtualButton(ScaleToolBinding);
            duplicateKey = new VirtualButton(DuplicateBinding);
            deleteKey = new VirtualButton(DeleteBinding);
            frameKey = new VirtualButton(FrameBinding);

            UpdateRenderTexture(Width, Height - HeaderHeight);
            UpdateProfilerOverlay();
        }
Beispiel #26
0
        private void OnInitialize()
        {
            guiColor          = new GUIColorField("", GUIOption.FixedWidth(100));
            guiSlider2DTex    = new GUITexture(null, GUIOption.FixedHeight(ColorBoxHeight), GUIOption.FixedWidth(ColorBoxWidth));
            guiSliderVertTex  = new GUITexture(null, GUIOption.FixedHeight(SliderSideHeight), GUIOption.FixedWidth(SliderSideWidth));
            guiSliderRHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderGHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderBHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));
            guiSliderAHorzTex = new GUITexture(null, GUIOption.FixedHeight(SliderIndividualHeight));

            guiColorBoxBtn  = new GUIButton(colorBoxMode.ToString());
            guiColorModeBtn = new GUIButton(sliderMode.ToString());

            guiSliderVert     = new GUISliderV(EditorStyles.ColorSliderVert);
            guiSliderRHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSliderGHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSliderBHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSliderAHorz    = new GUISliderH(EditorStyles.ColorSliderHorz);
            guiSlider2DHandle = new GUITexture(null, EditorStyles.ColorSlider2DHandle);

            guiLabelR = new GUILabel(new LocEdString("R"));
            guiLabelG = new GUILabel(new LocEdString("G"));
            guiLabelB = new GUILabel(new LocEdString("B"));
            guiLabelA = new GUILabel(new LocEdString("A"));

            guiInputR = new GUIIntField();
            guiInputG = new GUIIntField();
            guiInputB = new GUIIntField();
            guiInputA = new GUIIntField();

            guiOK     = new GUIButton(new LocEdString("OK"));
            guiCancel = new GUIButton(new LocEdString("Cancel"));

            guiColorBoxBtn.OnClick  += OnColorBoxModeChanged;
            guiColorModeBtn.OnClick += OnSliderModeChanged;

            guiSliderVert.OnChanged  += OnSliderVertChanged;
            guiSliderRHorz.OnChanged += OnSliderRHorzChanged;
            guiSliderGHorz.OnChanged += OnSliderGHorzChanged;
            guiSliderBHorz.OnChanged += OnSliderBHorzChanged;
            guiSliderAHorz.OnChanged += OnSliderAHorzChanged;

            guiInputR.OnChanged += OnInputRChanged;
            guiInputG.OnChanged += OnInputGChanged;
            guiInputB.OnChanged += OnInputBChanged;
            guiInputA.OnChanged += OnInputAChanged;

            guiOK.OnClick     += OnOK;
            guiCancel.OnClick += OnCancel;

            GUIPanel  mainPanel = GUI.AddPanel(0);
            GUILayout v0        = mainPanel.AddLayoutY();

            v0.AddSpace(5);

            GUILayout h0 = v0.AddLayoutX();

            h0.AddSpace(10);
            h0.AddElement(guiColor);
            h0.AddFlexibleSpace();
            h0.AddElement(guiColorBoxBtn);
            h0.AddElement(guiColorModeBtn);
            h0.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h1 = v0.AddLayoutX();

            h1.AddSpace(10);
            h1.AddElement(guiSlider2DTex);
            h1.AddFlexibleSpace();
            h1.AddElement(guiSliderVertTex);
            h1.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h2 = v0.AddLayoutX();

            h2.AddSpace(10);
            h2.AddElement(guiLabelR);
            h2.AddFlexibleSpace();
            h2.AddElement(guiSliderRHorzTex);
            h2.AddFlexibleSpace();
            h2.AddElement(guiInputR);
            h2.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h3 = v0.AddLayoutX();

            h3.AddSpace(10);
            h3.AddElement(guiLabelG);
            h3.AddFlexibleSpace();
            h3.AddElement(guiSliderGHorzTex);
            h3.AddFlexibleSpace();
            h3.AddElement(guiInputG);
            h3.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h4 = v0.AddLayoutX();

            h4.AddSpace(10);
            h4.AddElement(guiLabelB);
            h4.AddFlexibleSpace();
            h4.AddElement(guiSliderBHorzTex);
            h4.AddFlexibleSpace();
            h4.AddElement(guiInputB);
            h4.AddSpace(10);

            v0.AddSpace(5);

            GUILayout h5 = v0.AddLayoutX();

            h5.AddSpace(10);
            h5.AddElement(guiLabelA);
            h5.AddFlexibleSpace();
            h5.AddElement(guiSliderAHorzTex);
            h5.AddFlexibleSpace();
            h5.AddElement(guiInputA);
            h5.AddSpace(10);

            v0.AddSpace(10);

            GUILayout h6 = v0.AddLayoutX();

            h6.AddFlexibleSpace();
            h6.AddElement(guiOK);
            h6.AddSpace(10);
            h6.AddElement(guiCancel);
            h6.AddFlexibleSpace();

            v0.AddSpace(5);

            GUIPanel overlay = GUI.AddPanel(-1);

            overlay.SetWidth(Width);
            overlay.SetHeight(Height);

            overlay.AddElement(guiSliderVert);
            overlay.AddElement(guiSliderRHorz);
            overlay.AddElement(guiSliderGHorz);
            overlay.AddElement(guiSliderBHorz);
            overlay.AddElement(guiSliderAHorz);
            overlay.AddElement(guiSlider2DHandle);

            colorBox   = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight);
            sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight);

            sliderR = new ColorSlider1DHorz(guiSliderRHorzTex, guiSliderRHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderG = new ColorSlider1DHorz(guiSliderGHorzTex, guiSliderGHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderB = new ColorSlider1DHorz(guiSliderBHorzTex, guiSliderBHorz, SliderIndividualWidth, SliderIndividualHeight);
            sliderA = new ColorSlider1DHorz(guiSliderAHorzTex, guiSliderAHorz, SliderIndividualWidth, SliderIndividualHeight);

            colorBox.OnValueChanged += OnColorBoxValueChanged;

            Color startA = new Color(0, 0, 0, 1);
            Color stepA  = new Color(1, 1, 1, 0);

            sliderA.UpdateTexture(startA, stepA, false);
            guiInputA.SetRange(0, 255);
            guiInputA.Value        = 255;
            guiSliderAHorz.Percent = 1.0f;

            guiColor.Value = SelectedColor;
            UpdateInputBoxValues();
            Update2DSliderValues();
            Update1DSliderValues();
            UpdateSliderMode();
            Update2DSliderTextures();
            Update1DSliderTextures();
        }
Beispiel #27
0
        /// <summary>
        /// Refreshes the contents of the content area. Must be called at least once after construction.
        /// </summary>
        /// <param name="viewType">Determines how to display the resource tiles.</param>
        /// <param name="entriesToDisplay">Project library entries to display.</param>
        public void Refresh(ProjectViewType viewType, LibraryEntry[] entriesToDisplay)
        {
            if (mainPanel != null)
            {
                mainPanel.Destroy();
            }

            entries = new LibraryGUIEntry[entriesToDisplay.Length];
            entryLookup.Clear();

            mainPanel = parent.Layout.AddPanel();

            GUIPanel contentPanel = mainPanel.AddPanel(1);

            overlay       = mainPanel.AddPanel(0);
            underlay      = mainPanel.AddPanel(2);
            renameOverlay = mainPanel.AddPanel(-1);

            main = contentPanel.AddLayoutY();

            if (viewType == ProjectViewType.List16)
            {
                tileSize       = 16;
                gridLayout     = false;
                elementsPerRow = 1;
            }
            else
            {
                switch (viewType)
                {
                case ProjectViewType.Grid64:
                    tileSize = 64;
                    break;

                case ProjectViewType.Grid48:
                    tileSize = 48;
                    break;

                case ProjectViewType.Grid32:
                    tileSize = 32;
                    break;
                }

                gridLayout = true;

                Rect2I scrollBounds   = parent.Bounds;
                int    availableWidth = scrollBounds.width;

                int elemSize = tileSize + GRID_ENTRY_SPACING;
                elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
                elementsPerRow = Math.Max(elementsPerRow, 1);

                int numRows      = MathEx.CeilToInt(entriesToDisplay.Length / (float)elementsPerRow);
                int neededHeight = numRows * (elemSize);

                bool requiresScrollbar = neededHeight > scrollBounds.height;
                if (requiresScrollbar)
                {
                    availableWidth -= parent.ScrollBarWidth;
                    elementsPerRow  = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
                }

                if (elementsPerRow > 0)
                {
                    labelWidth = (availableWidth - (elementsPerRow + 1) * MIN_HORZ_SPACING) / elementsPerRow;
                }
                else
                {
                    labelWidth = 0;
                }
            }

            if (viewType == ProjectViewType.List16)
            {
                for (int i = 0; i < entriesToDisplay.Length; i++)
                {
                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entriesToDisplay[i], i, labelWidth);
                    entries[i] = guiEntry;
                    entryLookup[guiEntry.path] = guiEntry;

                    if (i != entriesToDisplay.Length - 1)
                    {
                        main.AddSpace(LIST_ENTRY_SPACING);
                    }
                }

                main.AddFlexibleSpace();
            }
            else
            {
                main.AddSpace(GRID_ENTRY_SPACING / 2);
                GUILayoutX rowLayout = main.AddLayoutX();
                main.AddSpace(GRID_ENTRY_SPACING);
                rowLayout.AddFlexibleSpace();

                int elemsInRow = 0;

                for (int i = 0; i < entriesToDisplay.Length; i++)
                {
                    if (elemsInRow == elementsPerRow && elemsInRow > 0)
                    {
                        rowLayout = main.AddLayoutX();
                        main.AddSpace(GRID_ENTRY_SPACING);

                        rowLayout.AddFlexibleSpace();
                        elemsInRow = 0;
                    }

                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entriesToDisplay[i], i, labelWidth);
                    entries[i] = guiEntry;
                    entryLookup[guiEntry.path] = guiEntry;

                    rowLayout.AddFlexibleSpace();

                    elemsInRow++;
                }

                int extraElements = elementsPerRow - elemsInRow;
                for (int i = 0; i < extraElements; i++)
                {
                    rowLayout.AddSpace(labelWidth);
                    rowLayout.AddFlexibleSpace();
                }

                main.AddFlexibleSpace();
            }

            for (int i = 0; i < entries.Length; i++)
            {
                LibraryGUIEntry guiEntry = entries[i];
                guiEntry.Initialize();
            }
        }
Beispiel #28
0
        private void OnInitialize()
        {
            EditorApplication.OnProjectSave += SaveSettings;

            SceneWindow sceneWindow = SceneWindow.GetWindow <SceneWindow>();

            if (sceneWindow != null)
            {
                viewSettings   = sceneWindow.Camera.ViewSettings;
                moveSettings   = sceneWindow.Camera.MoveSettings;
                renderSettings = sceneWindow.Camera.RenderSettings;
                gizmoSettings  = sceneWindow.GizmoDrawSettings;
            }
            else
            {
                viewSettings   = ProjectSettings.GetObject <SceneCameraViewSettings>(SceneCamera.ViewSettingsKey);
                moveSettings   = ProjectSettings.GetObject <SceneCameraMoveSettings>(SceneCamera.MoveSettingsKey);
                renderSettings = ProjectSettings.GetObject <RenderSettings>(SceneCamera.RenderSettingsKey);

                if (ProjectSettings.HasKey(SceneWindow.GizmoDrawSettingsKey))
                {
                    gizmoSettings = ProjectSettings.GetObject <GizmoDrawSettings>(SceneWindow.GizmoDrawSettingsKey);
                }
                else
                {
                    gizmoSettings = GizmoDrawSettings.Default();
                }
            }

            expandStates = ProjectSettings.GetObject <SerializableProperties>(ExpandStatesKey);
            InspectableContext inspectableContext = new InspectableContext(expandStates);

            GUILayout mainLayout = GUI.AddLayoutY();

            GUIScrollArea scrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);

            mainLayout.AddElement(scrollArea);

            GUILayoutX horzPadLayout = scrollArea.Layout.AddLayoutX(GUIOption.FlexibleWidth(100, 400));

            horzPadLayout.AddSpace(5);

            GUILayout vertLayout = horzPadLayout.AddLayoutY();

            horzPadLayout.AddSpace(5);

            vertLayout.AddSpace(5);

            vertLayout.AddElement(new GUILabel(new LocEdString("View Settings"), EditorStyles.LabelBold));
            GUILayoutY viewSettingsLayout = vertLayout.AddLayoutY();

            vertLayout.AddSpace(10);

            vertLayout.AddElement(new GUILabel(new LocEdString("Gizmo Settings"), EditorStyles.LabelBold));
            GUILayoutY gizmoSettingsLayout = vertLayout.AddLayoutY();

            vertLayout.AddSpace(10);

            vertLayout.AddElement(new GUILabel(new LocEdString("Move Settings"), EditorStyles.LabelBold));
            GUILayoutY moveSettingsLayout = vertLayout.AddLayoutY();

            vertLayout.AddSpace(10);

            vertLayout.AddElement(new GUILabel(new LocEdString("Render Settings"), EditorStyles.LabelBold));
            GUILayoutY renderSettingsLayout = vertLayout.AddLayoutY();

            guiViewSettings     = new InspectorFieldDrawer(inspectableContext, viewSettingsLayout);
            guiGizmoSettings    = new InspectorFieldDrawer(inspectableContext, gizmoSettingsLayout);
            guiMovementSettings = new InspectorFieldDrawer(inspectableContext, moveSettingsLayout);
            guiRenderSettings   = new InspectorFieldDrawer(inspectableContext, renderSettingsLayout);

            objGizmoSettings = gizmoSettings;

            guiViewSettings.AddDefault(viewSettings);
            guiGizmoSettings.AddDefault(objGizmoSettings);
            guiMovementSettings.AddDefault(moveSettings);
            guiRenderSettings.AddDefault(renderSettings);

            mainLayout.AddSpace(5);
            GUILayout buttonCenterLayout = mainLayout.AddLayoutX();

            mainLayout.AddSpace(5);

            GUIButton resetToDefaultBtn = new GUIButton(new LocEdString("Reset to defaults"));

            resetToDefaultBtn.OnClick += () => ConfirmResetToDefault(ResetToDefault, null);

            buttonCenterLayout.AddFlexibleSpace();
            buttonCenterLayout.AddElement(resetToDefaultBtn);
            buttonCenterLayout.AddFlexibleSpace();
        }
        private void RebuildGUI()
        {
            GUI.Clear();
            guiCurveEditor  = null;
            guiFieldDisplay = null;

            if (selectedSO == null)
            {
                GUILabel warningLbl = new GUILabel(new LocEdString("Select an object to animate in the Hierarchy or Scene windows."));

                GUILayoutY vertLayout = GUI.AddLayoutY();
                vertLayout.AddFlexibleSpace();
                GUILayoutX horzLayout = vertLayout.AddLayoutX();
                vertLayout.AddFlexibleSpace();

                horzLayout.AddFlexibleSpace();
                horzLayout.AddElement(warningLbl);
                horzLayout.AddFlexibleSpace();

                return;
            }

            // Top button row
            GUIContent playIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Play),
                                                 new LocEdString("Play"));
            GUIContent recordIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.Record),
                                                   new LocEdString("Record"));

            GUIContent prevFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameBack),
                                                      new LocEdString("Previous frame"));
            GUIContent nextFrameIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.FrameForward),
                                                      new LocEdString("Next frame"));

            GUIContent addKeyframeIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddKeyframe),
                                                        new LocEdString("Add keyframe"));
            GUIContent addEventIcon = new GUIContent(EditorBuiltin.GetAnimationWindowIcon(AnimationWindowIcon.AddEvent),
                                                     new LocEdString("Add event"));

            GUIContent optionsIcon = new GUIContent(EditorBuiltin.GetLibraryWindowIcon(LibraryWindowIcon.Options),
                                                    new LocEdString("Options"));

            playButton   = new GUIButton(playIcon);
            recordButton = new GUIButton(recordIcon);

            prevFrameButton = new GUIButton(prevFrameIcon);
            frameInputField = new GUIIntField();
            nextFrameButton = new GUIButton(nextFrameIcon);

            addKeyframeButton = new GUIButton(addKeyframeIcon);
            addEventButton    = new GUIButton(addEventIcon);

            optionsButton = new GUIButton(optionsIcon);

            playButton.OnClick += () =>
            {
                // TODO
                // - Record current state of the scene object hierarchy
                // - Evaluate all curves manually and update them
                // - On end, restore original values of the scene object hierarchy
            };

            recordButton.OnClick += () =>
            {
                // TODO
                // - Every frame read back current values of all the current curve's properties and assign it to the current frame
            };

            prevFrameButton.OnClick += () =>
            {
                SetCurrentFrame(currentFrameIdx - 1);
            };

            frameInputField.OnChanged += SetCurrentFrame;

            nextFrameButton.OnClick += () =>
            {
                SetCurrentFrame(currentFrameIdx + 1);
            };

            addKeyframeButton.OnClick += () =>
            {
                guiCurveEditor.AddKeyFrameAtMarker();
            };

            addEventButton.OnClick += () =>
            {
                guiCurveEditor.AddEventAtMarker();
            };

            optionsButton.OnClick += () =>
            {
                Vector2I         openPosition = ScreenToWindowPos(Input.PointerPosition);
                AnimationOptions dropDown     = DropDownWindow.Open <AnimationOptions>(this, openPosition);
                dropDown.Initialize(this);
            };

            // Property buttons
            addPropertyBtn = new GUIButton(new LocEdString("Add property"));
            delPropertyBtn = new GUIButton(new LocEdString("Delete selected"));

            addPropertyBtn.OnClick += () =>
            {
                Action openPropertyWindow = () =>
                {
                    Vector2I             windowPos      = ScreenToWindowPos(Input.PointerPosition);
                    FieldSelectionWindow fieldSelection = DropDownWindow.Open <FieldSelectionWindow>(this, windowPos);
                    fieldSelection.OnFieldSelected += OnFieldAdded;
                };

                if (clipInfo.clip == null)
                {
                    LocEdString title   = new LocEdString("Warning");
                    LocEdString message =
                        new LocEdString("Selected object doesn't have an animation clip assigned. Would you like to create" +
                                        " a new animation clip?");

                    DialogBox.Open(title, message, DialogBox.Type.YesNoCancel, type =>
                    {
                        if (type == DialogBox.ResultType.Yes)
                        {
                            string clipSavePath;
                            if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.asset", out clipSavePath))
                            {
                                clipSavePath = Path.ChangeExtension(clipSavePath, ".asset");

                                AnimationClip newClip = new AnimationClip();

                                ProjectLibrary.Create(newClip, clipSavePath);
                                LoadAnimClip(newClip);

                                Animation animation = selectedSO.GetComponent <Animation>();
                                if (animation == null)
                                {
                                    animation = selectedSO.AddComponent <Animation>();
                                }

                                animation.DefaultClip = newClip;
                                EditorApplication.SetSceneDirty();

                                openPropertyWindow();
                            }
                        }
                    });
                }
                else
                {
                    if (clipInfo.isImported)
                    {
                        LocEdString title   = new LocEdString("Warning");
                        LocEdString message =
                            new LocEdString("You cannot add/edit/remove curves from animation clips that" +
                                            " are imported from an external file.");

                        DialogBox.Open(title, message, DialogBox.Type.OK);
                    }
                    else
                    {
                        openPropertyWindow();
                    }
                }
            };

            delPropertyBtn.OnClick += () =>
            {
                if (clipInfo.clip == null)
                {
                    return;
                }

                if (clipInfo.isImported)
                {
                    LocEdString title   = new LocEdString("Warning");
                    LocEdString message =
                        new LocEdString("You cannot add/edit/remove curves from animation clips that" +
                                        " are imported from an external file.");

                    DialogBox.Open(title, message, DialogBox.Type.OK);
                }
                else
                {
                    LocEdString title   = new LocEdString("Warning");
                    LocEdString message = new LocEdString("Are you sure you want to remove all selected fields?");

                    DialogBox.Open(title, message, DialogBox.Type.YesNo, x =>
                    {
                        if (x == DialogBox.ResultType.Yes)
                        {
                            RemoveSelectedFields();
                        }
                    });
                }
            };

            GUIPanel mainPanel       = GUI.AddPanel();
            GUIPanel backgroundPanel = GUI.AddPanel(1);

            GUILayout mainLayout = mainPanel.AddLayoutY();

            buttonLayout = mainLayout.AddLayoutX();
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(playButton);
            buttonLayout.AddElement(recordButton);
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(prevFrameButton);
            buttonLayout.AddElement(frameInputField);
            buttonLayout.AddElement(nextFrameButton);
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(addKeyframeButton);
            buttonLayout.AddElement(addEventButton);
            buttonLayout.AddSpace(5);
            buttonLayout.AddElement(optionsButton);
            buttonLayout.AddFlexibleSpace();

            buttonLayoutHeight = playButton.Bounds.height;

            GUITexture buttonBackground = new GUITexture(null, EditorStyles.HeaderBackground);

            buttonBackground.Bounds = new Rect2I(0, 0, Width, buttonLayoutHeight);
            backgroundPanel.AddElement(buttonBackground);

            GUILayout contentLayout      = mainLayout.AddLayoutX();
            GUILayout fieldDisplayLayout = contentLayout.AddLayoutY(GUIOption.FixedWidth(FIELD_DISPLAY_WIDTH));

            guiFieldDisplay = new GUIAnimFieldDisplay(fieldDisplayLayout, FIELD_DISPLAY_WIDTH,
                                                      Height - buttonLayoutHeight * 2, selectedSO);
            guiFieldDisplay.OnEntrySelected += OnFieldSelected;

            GUILayout bottomButtonLayout = fieldDisplayLayout.AddLayoutX();

            bottomButtonLayout.AddElement(addPropertyBtn);
            bottomButtonLayout.AddElement(delPropertyBtn);

            horzScrollBar = new GUIResizeableScrollBarH();
            horzScrollBar.OnScrollOrResize += OnHorzScrollOrResize;

            vertScrollBar = new GUIResizeableScrollBarV();
            vertScrollBar.OnScrollOrResize += OnVertScrollOrResize;

            GUITexture separator = new GUITexture(null, EditorStyles.Separator, GUIOption.FixedWidth(3));

            contentLayout.AddElement(separator);

            GUILayout curveLayout         = contentLayout.AddLayoutY();
            GUILayout curveLayoutHorz     = curveLayout.AddLayoutX();
            GUILayout horzScrollBarLayout = curveLayout.AddLayoutX();

            horzScrollBarLayout.AddElement(horzScrollBar);
            horzScrollBarLayout.AddFlexibleSpace();

            editorPanel = curveLayoutHorz.AddPanel();
            curveLayoutHorz.AddElement(vertScrollBar);
            curveLayoutHorz.AddFlexibleSpace();

            scrollBarHeight = horzScrollBar.Bounds.height;
            scrollBarWidth  = vertScrollBar.Bounds.width;

            Vector2I curveEditorSize = GetCurveEditorSize();

            guiCurveEditor = new GUICurveEditor(this, editorPanel, curveEditorSize.x, curveEditorSize.y);
            guiCurveEditor.OnFrameSelected += OnFrameSelected;
            guiCurveEditor.OnEventAdded    += OnEventsChanged;
            guiCurveEditor.OnEventModified += EditorApplication.SetProjectDirty;
            guiCurveEditor.OnEventDeleted  += OnEventsChanged;
            guiCurveEditor.OnCurveModified += EditorApplication.SetProjectDirty;
            guiCurveEditor.Redraw();

            horzScrollBar.SetWidth(curveEditorSize.x);
            vertScrollBar.SetHeight(curveEditorSize.y);

            UpdateScrollBarSize();
        }
Beispiel #30
0
        private void OnInitialize()
        {
            GUILabel title    = new GUILabel(new LocEdString("Banshee Editor " + EngineVersion.GetFullVersionString()), EditorStyles.TitleLabel);
            GUILabel subTitle = new GUILabel(new LocEdString("A modern open-source game development toolkit"),
                                             EditorStyles.LabelCentered);
            GUILabel bsfVersion = new GUILabel(new LocEdString("Powered by bs::framework " + FrameworkVersion.GetFullVersionString()), EditorStyles.LabelCentered);
            GUILabel license    = new GUILabel(new LocEdString(
                                                   "This program is licensed under the GNU Lesser General Public License V3 or later"), EditorStyles.LabelCentered);
            GUILabel copyright = new GUILabel(new LocEdString("Copyright (C) 2014 - " + EngineVersion.GetCurrentReleaseYearNumber() + " Jonathan Harrison and contributors. All rights reserved."),
                                              EditorStyles.LabelCentered);

            GUILabel editorContributorsLabel    = new GUILabel(new LocEdString("Editor contributors"), EditorStyles.TitleLabel);
            GUILabel frameworkContributorsLabel = new GUILabel(new LocEdString("Framework contributors"), EditorStyles.TitleLabel);
            GUILabel engineLabel    = new GUILabel(new LocEdString("Editor and engine"), EditorStyles.TitleLabel);
            GUILabel frameworkLabel = new GUILabel(new LocEdString("Framework"), EditorStyles.TitleLabel);


            GUILabel authorLabel = new GUILabel(new LocEdString("Banshee was created, and is being actively developed by Jonathan Harrison."));
            GUILabel emailTitle  = new GUILabel(new LocEdString("E-mail"), GUIOption.FixedWidth(150));

            emailLabel = new GUITextBox();
            GUILabel  linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150));
            GUIButton linkedInBtn   = new GUIButton(new LocEdString("Profile"));
            GUIButton patreonBtn    = new GUIButton(new LocEdString("Support us on Patreon!"), GUIOption.FixedWidth(210));
            GUIButton paypalBtn     = new GUIButton(new LocEdString("Donate via PayPal!"), GUIOption.FixedWidth(210));

            GUIScrollArea  scrollArea          = new GUIScrollArea();
            GUIToggleGroup foldoutGroup        = new GUIToggleGroup(true);
            GUIToggle      contactFoldout      = new GUIToggle(new LocEdString("Main author"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      thirdPartyFoldout   = new GUIToggle(new LocEdString("Used third party libraries"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      noticesFoldout      = new GUIToggle(new LocEdString("Third party notices"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      contributorsFoldout = new GUIToggle(new LocEdString("Contributors"), foldoutGroup, EditorStyles.Foldout);
            GUIToggle      socialFoldout       = new GUIToggle(new LocEdString("Social"), foldoutGroup, EditorStyles.Foldout);

            contactFoldout.AcceptsKeyFocus      = false;
            thirdPartyFoldout.AcceptsKeyFocus   = false;
            noticesFoldout.AcceptsKeyFocus      = false;
            contributorsFoldout.AcceptsKeyFocus = false;
            socialFoldout.AcceptsKeyFocus       = false;

            GUILabel freeTypeNotice = new GUILabel(new LocEdString(
                                                       "Portions of this software are copyright (C) 2019 The FreeType Project (www.freetype.org). " +
                                                       "All rights reserved."), EditorStyles.MultiLineLabelCentered,
                                                   GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380));

            GUILabel fbxSdkNotice = new GUILabel(new LocEdString(
                                                     "This software contains Autodesk(R) FBX(R) code developed by Autodesk, Inc. Copyright 2019 Autodesk, Inc. " +
                                                     "All rights, reserved. Such code is provided \"as is\" and Autodesk, Inc. disclaims any and all warranties, " +
                                                     "whether express or implied, including without limitation the implied warranties of merchantability, " +
                                                     "fitness for a particular purpose or non-infringement of third party rights. In no event shall Autodesk, " +
                                                     "Inc. be liable for any direct, indirect, incidental, special, exemplary, or consequential damages " +
                                                     "(including, but not limited to, procurement of substitute goods or services; loss of use, data, or " +
                                                     "profits; or business interruption) however caused and on any theory of liability, whether in contract, " +
                                                     "strict liability, or tort (including negligence or otherwise) arising in any way out of such code."),
                                                 EditorStyles.MultiLineLabelCentered, GUIOption.FlexibleHeight(), GUIOption.FixedWidth(380));

            string[ , ] contributorListEditor = new string[, ]
            {
                { "Danijel Ribic", "Logo, UI icons, 3D models & textures" },
                { "Marco Bellan", "Bugfixes, editor enhancements" },
                { "Robert Campbell", "Editor enhancements" },
                { "James Mitchell", "Build enhancements" },
                { "Patrick Recko", "Minor enhancements" }
            };

            string[] contributorListFramework = new string[]
            {
                "Marc Legendre",
                "Florian Will",
                "Marco Bellan",
                "Artur K. (@nemerle)",
                "Michael Jones",
                "Connor Fitzgerald",
                "Paolo Paoletto",
                "Patrick Recko",
                "Guillaume Meunier",
                "Andre Taulien",
                "James Mitchell",
                "and others..."
            };

            GUILayoutY mainLayout = GUI.AddLayoutY();

            mainLayout.AddSpace(10);
            mainLayout.AddElement(title);
            mainLayout.AddElement(subTitle);
            mainLayout.AddSpace(10);
            mainLayout.AddElement(bsfVersion);
            mainLayout.AddSpace(10);
            mainLayout.AddElement(license);
            mainLayout.AddSpace(5);
            mainLayout.AddElement(copyright);
            mainLayout.AddSpace(10);
            GUILayoutX donateButtonLayoutX = mainLayout.AddLayoutX();

            donateButtonLayoutX.AddSpace(10);
            donateButtonLayoutX.AddElement(patreonBtn);
            donateButtonLayoutX.AddSpace(10);
            donateButtonLayoutX.AddElement(paypalBtn);
            donateButtonLayoutX.AddSpace(10);
            mainLayout.AddSpace(10);

            mainLayout.AddElement(scrollArea);
            scrollArea.Layout.AddElement(contactFoldout);
            GUILayoutY contactLayout = scrollArea.Layout.AddLayoutY();

            contactLayout.AddSpace(15);
            GUILayout authorLayout = contactLayout.AddLayoutX();

            authorLayout.AddFlexibleSpace();
            authorLayout.AddElement(authorLabel);
            authorLayout.AddFlexibleSpace();
            contactLayout.AddSpace(15);
            GUILayout emailLayout = contactLayout.AddLayoutX();

            emailLayout.AddSpace(10);
            emailLayout.AddElement(emailTitle);
            emailLayout.AddElement(emailLabel);
            emailLayout.AddSpace(10);
            GUILayout linkedInLayout = contactLayout.AddLayoutX();

            linkedInLayout.AddSpace(10);
            linkedInLayout.AddElement(linkedInTitle);
            linkedInLayout.AddElement(linkedInBtn);
            linkedInLayout.AddSpace(10);

            scrollArea.Layout.AddSpace(5);
            scrollArea.Layout.AddElement(thirdPartyFoldout);
            GUILayoutY thirdPartyLayout = scrollArea.Layout.AddLayoutY();

            thirdPartyLayout.AddSpace(5);
            CreateNameURLBtnPair(thirdPartyLayout, "Autodesk FBX SDK",
                                 "https://www.autodesk.com/products/fbx/overview", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "FreeImage", "http://freeimage.sourceforge.net/", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "FreeType", "http://www.freetype.org/", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "Mono", "http://www.mono-project.com/", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "NVIDIA Texture Tools",
                                 "https://github.com/castano/nvidia-texture-tools", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "libFLAC", "https://xiph.org/flac/", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "libOgg", "https://www.xiph.org/ogg/", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "libVorbis", "http://www.vorbis.com/", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "OpenAL Soft", "http://kcat.strangesoft.net/openal.html", "Website");
            CreateNameURLBtnPair(thirdPartyLayout, "NVIDIA PhysX", "https://developer.nvidia.com/physx-sdk", "Website");

            scrollArea.Layout.AddSpace(5);
            scrollArea.Layout.AddElement(noticesFoldout);
            GUILayout noticesLayout = scrollArea.Layout.AddLayoutY();

            noticesLayout.AddSpace(5);
            noticesLayout.AddElement(freeTypeNotice);
            noticesLayout.AddSpace(10);
            noticesLayout.AddElement(fbxSdkNotice);

            scrollArea.Layout.AddSpace(5);
            scrollArea.Layout.AddElement(contributorsFoldout);
            GUILayoutY contributorsLayout = scrollArea.Layout.AddLayoutY();

            contributorsLayout.AddSpace(5);
            contributorsLayout.AddElement(editorContributorsLabel);
            contributorsLayout.AddSpace(5);
            for (int i = 0; i < contributorListEditor.Length / 2; i++)
            {
                CreateEditorContributorGUI(contributorsLayout, contributorListEditor[i, 0], contributorListEditor[i, 1]);
                contributorsLayout.AddSpace(5);
            }
            contributorsLayout.AddSpace(10);
            contributorsLayout.AddElement(frameworkContributorsLabel);
            contributorsLayout.AddSpace(5);
            for (int i = 0; i < contributorListFramework.Length; i++)
            {
                CreateFrameworkContributorGUI(contributorsLayout, contributorListFramework[i]);
                contributorsLayout.AddSpace(5);
            }

            scrollArea.Layout.AddSpace(5);
            scrollArea.Layout.AddElement(socialFoldout);
            GUILayoutY socialLayout = scrollArea.Layout.AddLayoutY();

            socialLayout.AddSpace(10);
            CreateNameURLBtnPair(socialLayout, "Discord", "https://discord.gg/8Xyf5gF", "Enter");
            socialLayout.AddSpace(10);
            socialLayout.AddElement(engineLabel);
            socialLayout.AddSpace(5);
            CreateNameURLBtnPair(socialLayout, "Website", "http://www.banshee3d.com", "Enter");
            CreateNameURLBtnPair(socialLayout, "Repository", "https://github.com/BearishSun/BansheeEngine", "Enter");
            CreateNameURLBtnPair(socialLayout, "Forums", "https://forum.banshee3d.com", "Enter");
            CreateNameURLBtnPair(socialLayout, "Twitter", "https://twitter.com/Banshee3D", "Enter");
            CreateNameURLBtnPair(socialLayout, "Facebook", "https://www.facebook.com/Banshee3D", "Enter");
            socialLayout.AddSpace(10);
            socialLayout.AddElement(frameworkLabel);
            socialLayout.AddSpace(5);
            CreateNameURLBtnPair(socialLayout, "Website", "http://www.bsframework.io", "Enter");
            CreateNameURLBtnPair(socialLayout, "Repository", "https://github.com/GameFoundry/bsf", "Enter");
            CreateNameURLBtnPair(socialLayout, "Forums", "https://discourse.bsframework.io/", "Enter");
            CreateNameURLBtnPair(socialLayout, "Twitter", "https://twitter.com/thebsframework", "Enter");
            CreateNameURLBtnPair(socialLayout, "Facebook", "https://www.facebook.com/bsframework", "Enter");
            mainLayout.AddFlexibleSpace();

            contactLayout.Active      = false;
            contactFoldout.OnToggled += x => contactLayout.Active = x;

            thirdPartyLayout.Active      = false;
            thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x;

            noticesLayout.Active      = false;
            noticesFoldout.OnToggled += x => noticesLayout.Active = x;

            contributorsLayout.Active      = false;
            contributorsFoldout.OnToggled += x => contributorsLayout.Active = x;

            socialLayout.Active      = false;
            socialFoldout.OnToggled += x => socialLayout.Active = x;

            emailLabel.Text      = "*****@*****.**";
            linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("https://www.linkedin.com/in/markopintera"); };
            patreonBtn.OnClick  += () => { System.Diagnostics.Process.Start("https://www.patreon.com/bsf"); };
            paypalBtn.OnClick   += () => { System.Diagnostics.Process.Start("https://www.paypal.me/MarkoPintera/10"); };
        }