Esempio n. 1
0
    /// <summary>
    /// Renders the job.
    /// </summary>
    /// <param name="job">Job.</param>
    private void RenderJob(JobDisplay job)
    {
        if (null != job)
        {
            job.Refresh();

            using (var jobSection = new JuneHorizontalSection()) {
                using (var labelSection = new JuneVerticalSection()) {
                    GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                    if (_JOB_COLOUR.ContainsKey(job))
                    {
                        style.normal.textColor = _JOB_COLOUR[job];
                    }

                    EditorGUILayout.LabelField(job.Name, style);
                    EditorGUILayout.LabelField("Current", job.Content, style);
                    EditorGUILayout.LabelField("Paused", job.IsPaused.ToString(), style);
                }

                using (var isEnabled = new JuneDisabledGroup(isDisabled: false == job.ShouldRefresh)) {
                    if (GUILayout.Button(job.PausePlayButtonText))
                    {
                        job.TogglePause();
                    }
                }
            }
        }
    }
Esempio n. 2
0
        /// <summary>
        /// Renders the field.
        /// </summary>
        public void RenderField(bool renderCloseButton = true)
        {
            float windowWidth = (null != Instance) ? Instance.position.width : 800f;

            windowWidth -= CLOSE_BUTTON_WIDTH;
            float nameWidth  = windowWidth * 0.2f;
            float valueWidth = windowWidth * 0.6f;
            float typeWidth  = windowWidth * 0.2f;

            try {
                using (var gItemRender = new JuneHorizontalSection()) {
                    if (this.IsObject)
                    {
                        //var style = new GUIStyle(EditorStyles.foldout);
                        //style.fixedWidth = nameWidth;
                        _Foldout = EditorGUILayout.Foldout(_Foldout, this.Name);
                    }
                    else
                    {
                        EditorGUILayout.LabelField(this.Name, GUILayout.Width(nameWidth));
                    }

                    EditorGUILayout.LabelField(UIContent, GUILayout.Width(valueWidth));
                    EditorGUILayout.LabelField(this.FieldType.Name, GUILayout.Width(typeWidth));
                    if (renderCloseButton)
                    {
                        if (GUILayout.Button("X", GUILayout.Width(CLOSE_BUTTON_WIDTH)))
                        {
                            _WatchObjects.Remove(this);
                        }
                    }
                }

                if (this.IsObject && _Foldout)
                {
                    RenderChildren();
                }
            }
            catch (Exception ex) {
                Debug.Log("[ObjectWATCH] ERROR: " + Name + "\n" + ex.ToString());
                //Debug.Log(ex);
            }
        }
Esempio n. 3
0
    /// <summary>
    /// Raises the GU event.
    /// </summary>
    public void OnGUI()
    {
        var assembly = GetAssembly();

        // --------------
        // POPULATE TYPES
        // --------------
        var types = GetTypes(assembly);

        string[] typeNames = null;
        if (null == types || types.Length == 0)
        {
            typeNames  = new string[] { NO_TYPES_FOUND };
            _TypeIndex = 0;
        }
        else
        {
            typeNames = types.Select(t => t.FullName).ToArray();
        }

        using (var gTypeSelection = new JuneHorizontalSection()) {
            EditorGUILayout.LabelField("Type", GUILayout.MaxWidth(50), GUILayout.ExpandWidth(false));
            _TypeIndex   = EditorGUILayout.Popup(_TypeIndex, typeNames, STYLE_TYPE);
            _IS_FILTERED = EditorGUILayout.ToggleLeft("Filter Types", _IS_FILTERED, GUILayout.MaxWidth(140f), GUILayout.ExpandWidth(false));
        }

        // -----------------
        // SET SELECTED TYPE
        // -----------------
        Type selectedType = null;

        if (null != types && _TypeIndex >= 0 && _TypeIndex < types.Length)
        {
            selectedType = types[_TypeIndex];
            //Debug.Log("Selected - " + selectedType.Name);
            //Debug.Log("Selected Methods - " + selectedType.GetMethods().Where(m => m.IsPublic && m.IsStatic).Count());
        }

        // ------------------------------
        // POPULATE SELECTED TYPE FIELDS
        // ------------------------------
        var fields = GetFieldsAndProperties(selectedType);

        string[] fieldNames = null;
        if (null == fields || fields.Count == 0)
        {
            fieldNames  = new string[] { NO_STATIC_VARIABLES };
            _FieldIndex = 0;
        }
        else
        {
            try {
                fieldNames = fields.Select(f => _FULL_FIELD_NAME ? f.FullName : f.Name).ToArray();
            }
            catch (Exception ex) {
                Debug.Log(ex);
            }
        }

        using (var gVarSelection = new JuneHorizontalSection()) {
            EditorGUILayout.LabelField("Variables", GUILayout.MaxWidth(50), GUILayout.ExpandWidth(false));
            _FieldIndex      = EditorGUILayout.Popup(_FieldIndex, fieldNames, GUILayout.ExpandWidth(true));
            _FULL_FIELD_NAME = EditorGUILayout.ToggleLeft("Full Variable Signature", _FULL_FIELD_NAME, GUILayout.MaxWidth(140f), GUILayout.ExpandWidth(false));
        }

        if (null == fields || _FieldIndex >= fields.Count)
        {
            _FieldIndex = 0;
        }

        // -------------------
        // SET SELECTED FIELD
        // -------------------
        GUIClassField selectedField = null;

        if (null != fields && _FieldIndex >= 0 && _FieldIndex < fields.Count)
        {
            selectedField = fields[_FieldIndex];
        }

        using (var gAddObject = new JuneHorizontalSection()) {
            if (GUILayout.Button("Add"))
            {
                if (null != selectedField && false == _WatchObjects.Contains(selectedField))
                {
                    _WatchObjects.Add(selectedField);
                }
            }
        }

        EditorGUILayout.Separator();

        var normalColor = GUI.color;

        GUI.color = Color.yellow;
        using (var gHeader = new JuneHorizontalSection()) {
            EditorGUILayout.LabelField("Name");
            EditorGUILayout.LabelField("Value");
            EditorGUILayout.LabelField("Type");
            if (GUILayout.Button("Refresh", GUILayout.Width(CLOSE_BUTTON_WIDTH + 15)))
            {
                _WatchObjects.ForEach(o => o.Refresh());
            }
            if (GUILayout.Button("Clear", GUILayout.Width(CLOSE_BUTTON_WIDTH)))
            {
                _WatchObjects.Clear();
            }
        }
        GUI.color = normalColor;

        EditorGUILayout.Separator();

        if (null != _WatchObjects && _WatchObjects.Count > 0)
        {
            using (var gScrollView = new JuneScrollView(ref _ScrollPosition)) {
                try {
                    for (int i = 0; i < _WatchObjects.Count; i++)
                    {
                        var item = _WatchObjects[i];
                        using (var gObj = new JuneVerticalSection()) {
                            item.RenderField();
                        }
                    }
                }
                catch (Exception ex) {
                    Debug.Log(ex);
                }
            }
        }

        // -------------------------
        // DISPLAY METHOD PARAMETERS
        // -------------------------

        /*
         * var parameters = GetParameters(selectedMethod);
         * EditorGUILayout.BeginVertical();
         * {
         *
         *      EditorGUILayout.HelpBox(GetMethodStr(selectedMethod), MessageType.None);
         *
         *      EditorGUILayout.Separator();
         *
         *      if (null != parameters && parameters.Length > 0) {
         *
         *              if (null == paramValues || paramValues.Length != parameters.Length) {
         *                      paramValues = new object[parameters.Length];
         *              }
         *
         *              for (int i = 0; i < parameters.Length; i++) {
         *                      EditorGUILayout.BeginHorizontal();
         *                      {
         *                              PopulateField(ref paramValues[i], parameters[i]);
         *                      }
         *                      EditorGUILayout.EndHorizontal();
         *              }
         *      }
         *      else {
         *              EditorGUILayout.LabelField("No parameters.");
         *      }
         *
         *      if (GUILayout.Button("Invoke")) {
         *              try {
         *                      //if(null == Dispatcher.Instance) {
         *                      Dispatcher.Initialize();
         *                      //}
         *
         *                      Result = selectedMethod.Invoke(null, paramValues);
         *                      //Result = "Invoked";
         *                      //EditorCoroutine.start(Util.ExecuteGetCommand("http://yahoo.com", www => {
         *                      //	Debug.Log("[CALLBACK] " + www.ToString());
         *                      //	EditorUtility.DisplayDialog("Callback", www.text, "ok");
         *                      //}));
         *              }
         *              catch (Exception ex) {
         *                      Result = ex.ToString();
         *              }
         *      }
         *      EditorGUILayout.Separator();
         *      EditorGUILayout.LabelField("Result");
         *      EditorGUILayout.TextArea((null == Result) ? "<NULL>" : Result.ToString(), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
         * }
         * EditorGUILayout.EndVertical();
         */
    }
Esempio n. 4
0
    void OnGUI()
    {
        using (var canvas = new JuneHorizontalSection(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))) {
            using (var buttonSection = new JuneVerticalSection(GUILayout.ExpandWidth(true))) {
                GUILayout.Label("Publish Messages");

                GUILayout.Space(_PADDING);

                if (GUILayout.Button("Publish " + Messages.HOME))
                {
                    June.MessageBroker.Publish(Messages.HOME);
                }

                if (GUILayout.Button("Publish " + Messages.HOME_BUTTON))
                {
                    June.MessageBroker.Publish(Messages.HOME_BUTTON);
                }

                if (GUILayout.Button("Publish " + Messages.STORE))
                {
                    June.MessageBroker.Publish(Messages.STORE);
                }

                if (GUILayout.Button("Publish " + Messages.STORE_BUTTON))
                {
                    June.MessageBroker.Publish(Messages.STORE_BUTTON, Messages.Parameters.Store.SECTION, "combos");
                }

                if (GUILayout.Button("Publish " + Messages.STORE_PURCHASE_SUCCESS))
                {
                    June.MessageBroker.Publish(
                        Messages.STORE_PURCHASE_SUCCESS,
                        new Dictionary <string, object>()
                    {
                        { Messages.Parameters.Store.Purchase.ITEM, "Ultimate Combo" },
                        { Messages.Parameters.Store.Purchase.PRICE, 0.99f }
                    });
                }

                if (GUILayout.Button("Publish *" + Messages.STORE_PURCHASE_SUCCESS + "*"))
                {
                    June.MessageBroker.Publish(
                        Messages.STORE_PURCHASE_SUCCESS,
                        new Dictionary <string, object>()
                    {
                        { Messages.Parameters.Store.Purchase.ITEM, "Special" },
                        { Messages.Parameters.Store.Purchase.PRICE, 9.99f }
                    });
                }
            }

            GUILayout.Space(_PADDING);

            using (var logSection = new JuneVerticalSection(GUILayout.ExpandWidth(true))) {
                GUILayout.Label("LOG", GUILayout.ExpandWidth(true));

                GUILayout.Space(_PADDING);

                GUILayout.TextArea(_LOG.ToString(), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            }
        }

        GUILayout.Space(_PADDING);

        using (var subscriberSection = new JuneVerticalSection(GUILayout.ExpandWidth(true))) {
            GUILayout.Label("Subscribers");

            GUILayout.Space(_PADDING);

            GUILayout.Label(((June.IMessageBroker)June.MessageBroker.Instance).ToString(), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        }
    }