コード例 #1
0
        /// <summary>
        /// Draws a dummy GUI layout element and measures its rect.
        /// If the current event is not the repaint event, then use the backup rect reference.
        /// </summary>
        public static U.Rect FindLayoutAreaRect(ref U.Rect backupRect, int border = 0)
        {
            //DRAW DUMMY LAYOUT GROUP TO GET THE RECT FROM
            Gl.BeginVertical(Gl.MaxWidth(U.Screen.width), Gl.MaxHeight(U.Screen.height));
            Gl.Label("");             //<- layout dummy
            Gl.EndVertical();
            U.Rect _fieldRect = U.GUILayoutUtility.GetLastRect();

            //rect update handling (ignore dummy rect at layout event)
            if (U.Event.current.type != U.EventType.Repaint)
            {
                _fieldRect = backupRect;
            }
            else
            {
                backupRect = _fieldRect;
            }

            _fieldRect.x      += border;
            _fieldRect.y      += border;
            _fieldRect.width  -= border * 2;
            _fieldRect.height -= border * 2;

            return(_fieldRect);
        }
コード例 #2
0
        void OnGUI()
        {
            if (!model.enable)
            {
                model.enable = ToggleLeft("Log", model.enable); return;
            }
            instance = this; // TODO: why do this here?
            BeginHorizontal();
            if (GL.Button("˂", GL.ExpandWidth(false)))
            {
                model.SelectPreviousFrame();
                SceneView.RepaintAll();
            }
            GL.Button(frameNo, GL.MaxWidth(48f));
            if (GL.Button("˃", GL.ExpandWidth(false)))
            {
                model.SelectNextFrame();
                SceneView.RepaintAll();
            }
            GL.FlexibleSpace();
            EndHorizontal();
            //
            scroll = BeginScrollView(scroll);
            GUI.backgroundColor = Color.black;
            var style = GUI.skin.textArea;
            var f     = font;

            if (f == null)
            {
                Debug.LogError("font not available");
            }
            style.font              = f;
            style.fontSize          = FontSize;
            style.normal.textColor  = Color.white * 0.9f;
            style.focused.textColor = Color.white;
            style.focused.textColor = Color.white;
            GL.TextArea(model.output, GL.ExpandHeight(true));
            EndScrollView();
            //
            GUI.backgroundColor = Color.white;
            //
            var w30 = GL.MaxWidth(30f);

            BeginHorizontal();
            model.enable = ToggleLeft($"Log", model.enable, GL.MaxWidth(60));
            model.trails = ToggleLeft("Trails", model.trails, GL.MaxWidth(50));
            GL.Label("Offset: ", GL.ExpandWidth(false));
            var rs = model.renderSettings;

            rs.offset = FloatField(model.renderSettings.offset, w30);
            GL.Label("Size: ", w30);
            rs.size = FloatField(rs.size, w30);
            GL.Label("Col: ", w30);
            rs.color = EditorGUILayout.ColorField(rs.color);
            EndHorizontal();
        }
コード例 #3
0
 public static GUILayoutOption MaxWidth(float v) => GL.MaxWidth(v);
コード例 #4
0
 public static GUILayoutOption[] Width(float min, float max) => new GUILayoutOption[]
 {
     GL.MinWidth(min), GL.MaxWidth(max)
 };
コード例 #5
0
        void OnGUI()
        {
            if (!Config.enable)
            {
                Config.enable = ToggleLeft("Enable Logging", Config.enable); return;
            }
            //
            model.current = Selection.activeGameObject;
            instance      = this;
            BeginHorizontal();
            Config.useSelection = ToggleLeft("Use Selection", Config.useSelection,
                                             GL.MaxWidth(90f));
            Config.allFrames = ToggleLeft("History", Config.allFrames,
                                          GL.MaxWidth(60));
            // TODO - make return type filtering available with the global history
            if (model.applicableSelection)
            {
                GL.Label("→", GL.MaxWidth(25f));
                Config.rtypeIndex = Popup(Config.rtypeIndex, rtypeOptions);
            }
            EndHorizontal();
            if (!Config.useSelection)
            {
                model.current = null;
            }
            BeginHorizontal();
            int frameNo = browsing ? selectedFrame.index : Time.frameCount;

            if (GL.Button("˂", GL.ExpandWidth(false)))
            {
                SelectPrev();
            }
            GL.Button($"#{frameNo}", GL.MaxWidth(48f));
            if (GL.Button("˃", GL.ExpandWidth(false)))
            {
                SelectNext();
            }
            GL.FlexibleSpace();
            Config.step = ToggleLeft("Step", Config.step, GL.MaxWidth(48f));
            EndHorizontal();
            scroll = BeginScrollView(scroll);
            GUI.backgroundColor = Color.black;
            var style = GUI.skin.textArea;
            var f     = font;

            if (f == null)
            {
                Debug.LogError("font not available");
            }
            style.font              = f;
            style.fontSize          = FontSize;
            style.normal.textColor  = Color.white * 0.9f;
            style.focused.textColor = Color.white;
            style.focused.textColor = Color.white;
            string log = model.Output(useHistory, rtypeOptions[Config.rtypeIndex]);

            if (currentLog != log && Config.step)
            {
                Ed.isPaused = true;
            }
            currentLog = log;
            GL.TextArea(browsing ? selectedFrame.Format() : log,
                        GL.ExpandHeight(true));
            EndScrollView();
            GUI.backgroundColor = Color.white;
            BeginHorizontal();
            Config.enable = ToggleLeft(
                $"Enable Logging ({Logger.injectionTimeMs}ms)",
                Config.enable, GL.ExpandWidth(true));
            if (!Application.isPlaying)
            {
                if (GL.Button($"Clear", GL.MaxWidth(90f)))
                {
                    Clear();
                }
            }
            EndHorizontal();
            BeginHorizontal();
            GL.Label("Trail offset: ", GL.MaxWidth(60f));
            Config.trailOffset = FloatField(Config.trailOffset,
                                            GL.MaxWidth(30f));
            GL.Label("Size: ", GL.MaxWidth(30f));
            Config.handleSize = FloatField(Config.handleSize, GL.MaxWidth(30f));
            EndHorizontal();
        }
コード例 #6
0
 public void OnGUI(UnityModManager.ModEntry modEntry)
 {
     if (!Mod.Enabled)
     {
         return;
     }
     if (!Game.Instance.Player.ControllableCharacters.Any())
     {
         GL.Label(Local["Menu_Lbl_NotInGame"]);
         return;
     }
     using (new GL.VerticalScope("box"))
     {
         GUILayout.Label(Local["Menu_Txt_Search"]);
         using (new GL.HorizontalScope())
         {
             bool isDirty = false;
             GUIHelper.TextField(ref searchString, () => isDirty = true);
             if (isDirty && searchString.Length > 2)
             {
                 results = Vendors.VendorInject.SearchItems(searchString);
             }
         }
         try
         {
             if (results != null && results.Count > 0)
             {
                 GUILayout.Label(Local["Menu_Txt_VendorPick"], falseWidth);
                 vendorToolbar = GUILayout.Toolbar(vendorToolbar, vendors, new GUIStyle(GUI.skin.button)
                 {
                     wordWrap = true, fixedHeight = 50f
                 }, new GUILayoutOption[] { GL.MaxWidth(800f) });
                 if (GUILayout.Button(string.Format(Local["Menu_Btn_AddAll"], vendors[vendorToolbar]), falseWidth))
                 {
                     results = Vendors.VendorInject.SearchItems(searchString);
                     foreach (KeyValuePair <string, string> item in results)
                     {
                         Vendors.VendorInject.AddItemToVendor(item.Key, Vendors.VendorInject.VendorTableIds[vendors[vendorToolbar]]);
                     }
                 }
                 foreach (KeyValuePair <string, string> item in results.OrderBy(x => x.Value))
                 {
                     using (new GL.HorizontalScope())
                     {
                         GUILayout.TextField(item.Key, new GUIStyle(GUI.skin.textField)
                         {
                             fixedWidth = 250f
                         });
                         bool flagAdd = GUILayout.Button(string.Format(Local["Menu_Txt_AddToVendor"], item.Value, vendors[vendorToolbar]), falseWidth);
                         if (flagAdd)
                         {
                             Vendors.VendorInject.AddItemToVendor(item.Key, Vendors.VendorInject.VendorTableIds[vendors[vendorToolbar]]);
                             itemAdded = item.Key;
                         }
                         if (item.Key.Equals(itemAdded))
                         {
                             GUILayout.Label(Local["Menu_Txt_ItemAdded"], falseWidth);
                         }
                     }
                 }
             }
             else
             {
                 GUILayout.Label(Local["Menu_Lbl_Noresult"]);
             }
         }
         catch (Exception ex)
         {
             Main.Mod.Error(ex.Message);
         }
     }
 }
コード例 #7
0
ファイル: UI+Wrappers.cs プロジェクト: ThyWoof/ToyBox
 public static GUILayoutOption MaxWidth(float v)
 {
     return(GL.MaxWidth(v));
 }
コード例 #8
0
ファイル: UI+Wrappers.cs プロジェクト: ThyWoof/ToyBox
 public static GUILayoutOption[] Width(float min, float max)
 {
     return(new GUILayoutOption[] { GL.MinWidth(min), GL.MaxWidth(max) });
 }