Ejemplo n.º 1
0
        /// <summary>
        /// Constructs the dialog box.
        /// </summary>
        /// <param name="title">Text to display in the title bar.</param>
        /// <param name="message">Message to display in the dialog box.</param>
        /// <param name="type">Type of dialog box that determines what buttons to display.</param>
        /// <param name="resultCallback">Callback to trigger when the user clicks on a dialog box button.</param>
        protected DialogBox(LocString title, LocString message, Type type, Action<ResultType> resultCallback)
            : base(false)
        {
            this.resultCallback = resultCallback;
            this.type = type;

            SetupGUI();

            Title = title;
            messageLabel.SetContent(message);

            Width = 280;
            Height = messageLabel.Bounds.height + 60;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new list box with the specified elements and a label.
 /// </summary>
 /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same 
 ///                        order as in the array.</param>
 /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
 ///                           </param>
 /// <param name="title">Content to display on the label.</param>
 /// <param name="titleWidth">Width of the title label in pixels.</param>
 /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
 ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
 ///                     default element style is used.</param>
 /// <param name="options">Options that allow you to control how is the element positioned and sized. This will 
 ///                       override any similar options set by style.</param>
 public GUIListBoxField(LocString[] elements, bool multiselect, GUIContent title, int titleWidth, string style = "",
     params GUIOption[] options)
 {
     Internal_CreateInstance(this, elements, multiselect, title, titleWidth, style, options, true);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a new item to the menu.
 /// </summary>
 /// <param name="path">Path that determines where to add the element. See class information on how to specify paths.
 ///                    All sub-elements of a path will be added automatically.</param>
 /// <param name="callback">Callback to trigger when the path element is selected.</param>
 /// <param name="shortcut">Keyboard shortcut to display next to the item name.</param>
 /// <param name="name">Localized name for the menu item.</param>
 public void AddItem(string path, Action callback, ShortcutKey shortcut, LocString name)
 {
     Internal_AddItem(mCachedPtr, path, callbacks.Count, ref shortcut);
     callbacks.Add(callback);
 }
Ejemplo n.º 4
0
            /// <summary>
            /// Constructs a new dictionary GUI.
            /// </summary>
            /// <param name="parent">Parent Inspector this field belongs to.</param>
            /// <param name="title">Label to display on the list GUI title.</param>
            /// <param name="path">Full path to this property (includes name of this property and all parent properties).
            /// </param>
            /// <param name="property">Serializable property referencing a dictionary</param>
            /// <param name="layout">Layout to which to append the list GUI elements to.</param>
            /// <param name="depth">Determines at which depth to render the background. Useful when you have multiple
            ///                     nested containers whose backgrounds are overlaping. Also determines background style,
            ///                     depths divisible by two will use an alternate style.</param>
            protected InspectableDictionaryGUI(Inspector parent, LocString title, string path, SerializableProperty property, 
                GUILayout layout, int depth = 0)
                : base(title, layout, depth)
            {
                this.property = property;
                this.parent = parent;
                this.path = path;

                dictionary = property.GetValue<IDictionary>();
                if (dictionary != null)
                    numElements = dictionary.Count;

                UpdateKeys();
            }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructs content with a string and a tooltip.
 /// </summary>
 /// <param name="text">Textual portion of the content to be displayed as label in GUI elements.</param>
 /// <param name="tooltip">Tooltip to be displayed when user hovers over a GUI element.</param>
 public GUIContent(LocString text, LocString tooltip)
 {
     this.text = text;
     this.tooltip = tooltip;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructs content with a string, an image and a tooltip.
 /// </summary>
 /// <param name="text">Textual portion of the content to be displayed as label in GUI elements.</param>
 /// <param name="image">Image to be displayed on top of the GUI element. Image will be placed to the right or to the 
 ///                     left of the text depending on active GUI style.</param>
 /// <param name="tooltip">Tooltip to be displayed when user hovers over a GUI element.</param>
 public GUIContent(LocString text, GUIContentImages image, LocString tooltip)
 {
     this.text = text;
     this.images = image;
     this.tooltip = tooltip;
 }
Ejemplo n.º 7
0
 private static extern void Internal_CreateInstance(LocString instance, string identifier, int tableId);
Ejemplo n.º 8
0
                /// <summary>
                /// Builds the GUI for the specified state style.
                /// </summary>
                /// <param name="title">Text to display on the title bar.</param>
                /// <param name="layout">Layout to append the GUI elements to.</param>
                public void BuildGUI(LocString title, GUILayout layout)
                {
                    foldout = new GUIToggle(title, EditorStyles.Foldout);
                    textureField = new GUIResourceField(typeof(SpriteTexture), new LocEdString("Texture"));
                    textColorField = new GUIColorField(new LocEdString("Text color"));

                    foldout.OnToggled += x =>
                    {
                        textureField.Active = x;
                        textColorField.Active = x;
                        isExpanded = x;
                    };

                    textureField.OnChanged += x =>
                    {
                        SpriteTexture texture = Resources.Load<SpriteTexture>(x);
                        state.Texture = texture;

                        if (OnChanged != null)
                            OnChanged(state);
                    };

                    textColorField.OnChanged += x =>
                    {
                        state.TextColor = x;

                        if (OnChanged != null)
                            OnChanged(state);
                    };

                    layout.AddElement(foldout);
                    layout.AddElement(textureField);
                    layout.AddElement(textColorField);

                    foldout.Value = isExpanded;
                    textureField.Active = isExpanded;
                    textColorField.Active = isExpanded;
                }
Ejemplo n.º 9
0
 private static extern void Internal_CreateInstance(GUIListBox instance, LocString[] elements, bool multiselect,
     string style, GUIOption[] options);
Ejemplo n.º 10
0
            /// <summary>
            /// Creates a new inspectable list GUI object that displays the contents of the provided serializable property.
            /// </summary>
            /// <param name="parent">Parent Inspector this field belongs to.</param>
            /// <param name="title">Label to display on the list GUI title.</param>
            /// <param name="path">Full path to this property (includes name of this property and all parent properties).
            /// </param>
            /// <param name="property">Serializable property referencing a list.</param>
            /// <param name="layout">Layout to which to append the list GUI elements to.</param>
            /// <param name="depth">Determines at which depth to render the background. Useful when you have multiple
            ///                     nested containers whose backgrounds are overlaping. Also determines background style,
            ///                     depths divisible by two will use an alternate style.</param>
            public static InspectableListGUI Create(Inspector parent, LocString title, string path, 
                SerializableProperty property, GUILayout layout, int depth)
            {
                InspectableListGUI listGUI = new InspectableListGUI(parent, title, path, property, layout, depth);
                listGUI.BuildGUI();

                return listGUI;
            }
Ejemplo n.º 11
0
            /// <summary>
            /// Constructs a new empty inspectable list GUI.
            /// </summary>
            /// <param name="parent">Parent Inspector this field belongs to.</param>
            /// <param name="title">Label to display on the list GUI title.</param>
            /// <param name="path">Full path to this property (includes name of this property and all parent properties).
            /// </param>
            /// <param name="property">Serializable property referencing a list.</param>
            /// <param name="layout">Layout to which to append the list GUI elements to.</param>
            /// <param name="depth">Determines at which depth to render the background. Useful when you have multiple
            ///                     nested containers whose backgrounds are overlaping. Also determines background style,
            ///                     depths divisible by two will use an alternate style.</param>
            public InspectableListGUI(Inspector parent, LocString title, string path, SerializableProperty property, 
                GUILayout layout, int depth)
                : base(title, layout, depth)
            {
                this.property = property;
                this.parent = parent;
                this.path = path;

                list = property.GetValue<IList>();
                if (list != null)
                    numElements = list.Count;
            }
Ejemplo n.º 12
0
 /// <summary>
 /// Opens a new dialog box.
 /// </summary>
 /// <param name="title">Text to display in the title bar.</param>
 /// <param name="message">Message to display in the dialog box.</param>
 /// <param name="type">Type of dialog box that determines what buttons to display.</param>
 /// <param name="resultCallback">Callback to trigger when the user clicks on a dialog box button.</param>
 /// <returns>Instance of the dialog box window.</returns>
 public static DialogBox Open(LocString title, LocString message, Type type, Action<ResultType> resultCallback = null)
 {
     return new DialogBox(title, message, type, resultCallback);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates a new localized string with the specified identifier in the editor string table. If the identifier 
 /// doesn't previously exist in the string table, identifier value will also be used for initializing the default 
 /// language version of the string.
 /// </summary>
 /// <param name="identifier">String you can use for later referencing the localized string.</param>
 public LocEdString(string identifier)
 {
     internalString = new LocString(identifier, EDITOR_STRING_TABLE_ID);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Creates a new empty localized string in the editor string table.
 /// </summary>
 public LocEdString()
 {
     internalString = new LocString(EDITOR_STRING_TABLE_ID);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Creates a new single-selection list box with the specified elements and a label.
 /// </summary>
 /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same 
 ///                        order as in the array.</param>
 /// <param name="title">Content to display on the label.</param>
 /// <param name="titleWidth">Width of the title label in pixels.</param>
 /// <param name="options">Options that allow you to control how is the element positioned and sized. This will 
 ///                       override any similar options set by style.</param>
 public GUIListBoxField(LocString[] elements, GUIContent title, int titleWidth = 100, params GUIOption[] options)
 {
     Internal_CreateInstance(this, elements, false, title, titleWidth, "", options, true);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a new list box with the specified elements.
 /// </summary>
 /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same 
 ///                        order as in the array.</param>
 /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
 ///                           </param>
 /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as 
 ///                     default layout options. Style will be retrieved from the active GUISkin. If not specified 
 ///                     default element style is used.</param>
 /// <param name="options">Options that allow you to control how is the element positioned and sized. This will 
 ///                       override any similar options set by style.</param>
 public GUIListBox(LocString[] elements, bool multiselect = false, string style = "", params GUIOption[] options)
 {
     Internal_CreateInstance(this, elements, multiselect, style, options);
 }
Ejemplo n.º 17
0
 private static extern void Internal_SetTitle(IntPtr nativeInstance, LocString title);
Ejemplo n.º 18
0
 /// <summary>
 /// Creates a new list box with the specified elements and no label.
 /// </summary>
 /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same 
 ///                        order as in the array.</param>
 /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
 ///                           </param>
 /// <param name="options">Options that allow you to control how is the element positioned and sized. This will 
 ///                       override any similar options set by style.</param>
 public GUIListBoxField(LocString[] elements, bool multiselect = false, params GUIOption[] options)
 {
     Internal_CreateInstance(this, elements, multiselect, null, 0, "", options, false);
 }
Ejemplo n.º 19
0
                /// <summary>
                /// Creates a new rectangle offset GUI.
                /// </summary>
                /// <param name="title">Text to display on the title bar.</param>
                /// <param name="layout">Layout to append the GUI elements to.</param>
                public RectOffsetGUI(LocString title, GUILayout layout)
                {
                    GUILayoutX rectLayout = layout.AddLayoutX();
                    rectLayout.AddElement(new GUILabel(title, GUIOption.FixedWidth(100)));
                    GUILayoutY rectContentLayout = rectLayout.AddLayoutY();

                    GUILayoutX rectTopRow = rectContentLayout.AddLayoutX();
                    GUILayoutX rectBotRow = rectContentLayout.AddLayoutX();

                    offsetLeftField = new GUIIntField(new LocEdString("Left"), 40);
                    offsetRightField = new GUIIntField(new LocEdString("Right"), 40);
                    offsetTopField = new GUIIntField(new LocEdString("Top"), 40);
                    offsetBottomField = new GUIIntField(new LocEdString("Bottom"), 40);

                    rectTopRow.AddElement(offsetLeftField);
                    rectTopRow.AddElement(offsetRightField);
                    rectBotRow.AddElement(offsetTopField);
                    rectBotRow.AddElement(offsetBottomField);

                    offsetLeftField.OnChanged += x =>
                    {
                        offset.left = x;

                        if(OnChanged != null)
                            OnChanged(offset);
                    };

                    offsetRightField.OnChanged += x =>
                    {
                        offset.right = x;

                        if (OnChanged != null)
                            OnChanged(offset);
                    };

                    offsetTopField.OnChanged += x =>
                    {
                        offset.top = x;

                        if (OnChanged != null)
                            OnChanged(offset);
                    };

                    offsetBottomField.OnChanged += x =>
                    {
                        offset.bottom = x;

                        if (OnChanged != null)
                            OnChanged(offset);
                    };

                    Action DoOnConfirmed = () =>
                    {
                        if (OnConfirmed != null)
                            OnConfirmed();
                    };

                    offsetLeftField.OnConfirmed += DoOnConfirmed;
                    offsetLeftField.OnFocusLost += DoOnConfirmed;
                    offsetRightField.OnConfirmed += DoOnConfirmed;
                    offsetRightField.OnFocusLost += DoOnConfirmed;
                    offsetTopField.OnConfirmed += DoOnConfirmed;
                    offsetTopField.OnFocusLost += DoOnConfirmed;
                    offsetBottomField.OnConfirmed += DoOnConfirmed;
                    offsetBottomField.OnFocusLost += DoOnConfirmed;
                }
Ejemplo n.º 20
0
 /// <summary>
 /// Updates the list box with a new set of elements.
 /// </summary>
 /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same 
 ///                        order as in the array.</param>
 public void SetElements(LocString[] elements)
 {
     Internal_SetElements(mCachedPtr, elements);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Constructs content with a string and an image.
 /// </summary>
 /// <param name="text">Textual portion of the content to be displayed as label in GUI elements.</param>
 /// <param name="image">Image to be displayed on top of the GUI element. Image will be placed to the right or to the 
 ///                     left of the text depending on active GUI style.</param>
 public GUIContent(LocString text, GUIContentImages image)
 {
     this.text = text;
     this.images = image;
 }
Ejemplo n.º 22
0
 private static extern void Internal_CreateInstance(GUIListBoxField instance, LocString[] entries, bool multiselect,
     GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
Ejemplo n.º 23
0
 /// <summary>
 /// Constructs content with just a string.
 /// </summary>
 /// <param name="text">Textual portion of the content to be displayed as label in GUI elements.</param>
 public GUIContent(LocString text)
 {
     this.text = text;
 }
Ejemplo n.º 24
0
 private static extern void Internal_SetElements(IntPtr nativeInstance, LocString[] elements);
Ejemplo n.º 25
0
 /// <summary>
 /// Constructs content with an image and a tooltip.
 /// </summary>
 /// <param name="image">Image to be displayed on top of the GUI element.</param>
 /// <param name="tooltip">Tooltip to be displayed when user hovers over a GUI element.</param>
 public GUIContent(GUIContentImages image, LocString tooltip)
 {
     this.images = image;
     this.tooltip = tooltip;
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Converts a set of normal strings to a set of localized strings.
        /// </summary>
        /// <param name="elements">Strings to convert.</param>
        /// <returns>Localized strings created from input strings.</returns>
        private LocString[] ToLocalizedElements(string[] elements)
        {
            if (elements == null)
                return null;

            LocString[] locElements = new LocString[elements.Length];
            for (int i = 0; i < locElements.Length; i++)
                locElements[i] = elements[i];

            return locElements;
        }
Ejemplo n.º 27
0
            /// <summary>
            /// Builds the inspectable dictionary GUI elements. Must be called at least once in order for the contents to 
            /// be populated.
            /// </summary>
            /// <param name="parent">Parent Inspector this field belongs to.</param>
            /// <param name="title">Label to display on the list GUI title.</param>
            /// <param name="path">Full path to this property (includes name of this property and all parent properties).
            /// </param>
            /// <param name="property">Serializable property referencing a dictionary</param>
            /// <param name="layout">Layout to which to append the list GUI elements to.</param>
            /// <param name="depth">Determines at which depth to render the background. Useful when you have multiple
            ///                     nested containers whose backgrounds are overlaping. Also determines background style,
            ///                     depths divisible by two will use an alternate style.</param>
            public static InspectableDictionaryGUI Create(Inspector parent, LocString title, string path, 
                SerializableProperty property, GUILayout layout, int depth = 0)
            {
                InspectableDictionaryGUI guiDictionary = new InspectableDictionaryGUI(parent, title, path, property,
                    layout, depth);
                guiDictionary.BuildGUI();

                return guiDictionary;
            }
Ejemplo n.º 28
0
        /// <summary>
        /// Sets a localized name of a specific menu element. If no localized name is set element labels will be displayed
        /// as their names.
        /// </summary>
        /// <param name="label">Label of the element.</param>
        /// <param name="name">Name to display when the menu is shown.</param>
        public void SetLocalizedName(string label, LocString name)
        {
            IntPtr namePtr = IntPtr.Zero;
            if (name != null)
                namePtr = name.GetCachedPtr();

            Internal_SetLocalizedName(mCachedPtr, label, namePtr);
        }