Ejemplo n.º 1
0
 protected override void OnDisable()
 {
     if (activePanel != null)
     {
         activePanel.DisableImmediate();
     }
     activePanel                   = null;
     pauseStyle                    = null;
     pauseRect                     = null;
     Time.timeScale                = 1f;
     Screen.lockCursor             = leaving ? false : (IN_GAME_MAIN_CAMERA.CameraMode >= CameraType.TPS);
     Screen.showCursor             = leaving;
     IN_GAME_MAIN_CAMERA.isPausing = false;
     InputManager.MenuOn           = false;
     if (IN_GAME_MAIN_CAMERA.MainCamera != null && !IN_GAME_MAIN_CAMERA.MainCamera.enabled)
     {
         IN_GAME_MAIN_CAMERA.SpecMov.disable = false;
         IN_GAME_MAIN_CAMERA.Look.disable    = false;
     }
     if (leaving)
     {
         if (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer)
         {
             PhotonNetwork.Disconnect();
         }
         IN_GAME_MAIN_CAMERA.GameType      = GameType.Stop;
         FengGameManagerMKII.FGM.GameStart = false;
         Object.Destroy(FengGameManagerMKII.FGM);
         Application.LoadLevel("menu");
     }
     if (!leaving)
     {
         Configuration.Settings.Apply();
     }
 }
Ejemplo n.º 2
0
        public static bool Enable(GUIBase gui)
        {
            if (gui.IsActive)
            {
                return(false);
            }
            if (Instance == null)
            {
                onAwakeAdds += delegate()
                {
                    Enable(gui);
                };
                return(false);
            }
            lock (activeGUIs)
            {
                if (activeGUIs == null || activeGUIs.Length == 0)
                {
                    activeGUIs = new GUIBase[] { gui };
                    gui.Drawer.Enable();
                    UpdateDepths();
                    return(true);
                }

                for (int i = 0; i < activeGUIs.Length; i++)
                {
                    if (activeGUIs[i] == gui)
                    {
                        return(false);
                    }
                }

                var list = activeGUIs.ToList();
                list.Add(gui);
                activeGUIs = list
                             .OrderBy(x => x.Layer)
                             .ToArray();

                if (activeGUIs.Last() == gui)
                {
                    if (activeGUIs.Length >= 2)
                    {
                        gui.Drawer.Enable(activeGUIs[activeGUIs.Length - 2].Drawer.Depth - 1);
                    }
                    else
                    {
                        gui.Drawer.Enable();
                        UpdateDepths();
                    }
                }
                else
                {
                    gui.Drawer.Enable();
                    UpdateDepths();
                }

                return(true);
            }
        }
Ejemplo n.º 3
0
 protected override void OnEnable()
 {
     activePanel          = null;
     boxPosition          = Helper.GetScreenMiddle(Width, Height);
     pauseRect            = new SmartRect(boxPosition.x + 10f, boxPosition.y + 25f, boxPosition.width - 20f, 50f - Style.VerticalMargin, Style.HorizontalMargin, Style.VerticalMargin);
     pauseStyle           = new GUIStyle(Style.Button);
     pauseStyle.fontSize  = Style.FontSize * 2;
     pauseStyle.fontStyle = FontStyle.Bold;
     leaving = false;
 }
Ejemplo n.º 4
0
        private static System.Collections.IEnumerator WaitAndEnable(GUIBase baseG)
        {
            yield return(new WaitForEndOfFrame());

            baseG.DisableImmediate();
            baseG.OnUpdateScaling();
            yield return(new WaitForEndOfFrame());

            baseG.EnableImmediate();
        }
Ejemplo n.º 5
0
 public static void DropdownMenuScrollable(GUIBase baseGUI, SmartRect rect, Setting <int> selection, string[] selections, int showItems, bool move = true)
 {
     if (Button(rect, selections[selection.Value], false))
     {
         ScrollableDropdownSelection.CreateNew(baseGUI, rect.ToRect(), selections, selection, showItems);
     }
     if (move)
     {
         rect.MoveY();
     }
 }
Ejemplo n.º 6
0
 public static void DropdownMenuScrollable(GUIBase baseGUI, SmartRect rect, Setting <int> selection, string[] selections, string label, float horizontalOffest, int showItems, bool move = true)
 {
     Label(rect, label, false);
     rect.MoveOffsetX(horizontalOffest);
     if (Button(rect, selections[selection.Value], false))
     {
         ScrollableDropdownSelection.CreateNew(baseGUI, rect.ToRect(), selections, selection, showItems);
     }
     rect.ResetX();
     if (move)
     {
         rect.MoveY();
     }
 }
Ejemplo n.º 7
0
 public static bool Enable(GUIBase gui)
 {
     if (gui.Active)
     {
         return(false);
     }
     if (Instance == null)
     {
         onAwakeAdds += delegate()
         {
             Enable(gui);
         };
         return(false);
     }
     lock (activeGUIs)
     {
         if (activeGUIs == null || activeGUIs.Length == 0)
         {
             if (!Instance.gameObject.activeInHierarchy)
             {
                 Instance.gameObject.SetActive(true);
             }
             activeGUIs = new GUIBase[] { gui };
             return(true);
         }
         for (int i = 0; i < activeGUIs.Length; i++)
         {
             if (activeGUIs[i] == gui)
             {
                 return(false);
             }
         }
         var  copy  = new Queue <GUIBase>(activeGUIs);
         var  tmp   = new Queue <GUIBase>();
         bool added = false;
         for (int i = 0; i < activeGUIs.Length + 1; i++)
         {
             if (!added && (copy.Count == 0 || gui.Layer < copy.Peek().Layer))
             {
                 added = true;
                 tmp.Enqueue(gui);
                 continue;
             }
             tmp.Enqueue(copy.Dequeue());
         }
         activeGUIs = tmp.ToArray();
         return(added);
     }
 }
Ejemplo n.º 8
0
 private void CheckEnabled(GUIBase obj, GUIBase[] toCheck)
 {
     if (obj.IsActive)
     {
         obj.Disable();
         return;
     }
     for (int i = 0; i < toCheck.Length; i++)
     {
         if (toCheck[i].IsActive)
         {
             toCheck[i].EnableNext(obj);
             return;
         }
     }
     obj.Enable();
 }
Ejemplo n.º 9
0
 public void EnableNext(GUIBase next)
 {
     if (!Active)
     {
         return;
     }
     OnGUI = animator.StartClose(() =>
     {
         if (UIManager.Disable(this))
         {
             OnDisable();
             locale.Unload();
             Active = false;
             next.Enable();
         }
     });
 }
Ejemplo n.º 10
0
        //private void OnGUI()
        //{
        //    if(Style.CustomStyles != null)
        //    {
        //        UnityEngine.GUI.skin.customStyles = Style.CustomStyles;
        //    }
        //}


        public static bool Disable(GUIBase gui)
        {
            if (!gui.IsActive)
            {
                return(false);
            }
            if (Instance == null)
            {
                onAwakeRms += delegate()
                {
                    Disable(gui);
                };
                return(false);
            }
            lock (activeGUIs)
            {
                bool wasLast = activeGUIs
                               .OrderBy(g => g.Layer)
                               .LastOrDefault() == gui;

                int oldCount = activeGUIs.Length;

                activeGUIs = activeGUIs
                             .Where(x => x != gui)
                             .ToArray();

                bool wasRemoved = oldCount != activeGUIs.Length;

                if (wasRemoved)
                {
                    gui.Disable();
                }
                if (activeGUIs.Length == 0)
                {
                    activeGUIs = new GUIBase[0];
                    return(wasRemoved);
                }
                if (!wasLast)
                {
                    UpdateDepths();
                }
                return(wasRemoved);
            }
        }
Ejemplo n.º 11
0
 public static bool Disable(GUIBase gui)
 {
     if (!gui.Active)
     {
         return(false);
     }
     if (Instance == null)
     {
         onAwakeRms += delegate()
         {
             Disable(gui);
         };
         return(false);
     }
     lock (activeGUIs)
     {
         bool wasRemoved = false;
         var  list       = new List <GUIBase>();
         for (int i = 0; i < activeGUIs.Length; i++)
         {
             if (activeGUIs[i] == gui)
             {
                 wasRemoved = true;
                 continue;
             }
             list.Add(activeGUIs[i]);
         }
         if (list.Count == 0)
         {
             activeGUIs = new GUIBase[0];
             CheckIfNeedDisable();
             return(wasRemoved);
         }
         activeGUIs = list.ToArray();
         return(wasRemoved);
     }
 }
Ejemplo n.º 12
0
 public static Texture2D LoadTexture(GUIBase @base, string name, string ext = "png")
 {
     return(@base.LoadTexture(name, ext));
 }
Ejemplo n.º 13
0
 protected internal override void Draw()
 {
     if (activePanel != null && activePanel.Active)
     {
         return;
     }
     GUI.Box(boxPosition, locale["title"]);
     pauseRect.Reset();
     if (PauseButton(pauseRect, "btnContinue"))
     {
         Continue();
         return;
     }
     if (PauseButton(pauseRect, "profile"))
     {
         if (activePanel != null)
         {
             activePanel.DisableImmediate();
         }
         activePanel = AnarchyManager.ProfilePanel;
         activePanel.Enable();
     }
     if (PauseButton(pauseRect, "skins"))
     {
         if (activePanel != null)
         {
             activePanel.DisableImmediate();
         }
         activePanel = new SkinsPanel();
         activePanel.Enable();
     }
     if (PauseButton(pauseRect, "custom"))
     {
         if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single || (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient))
         {
             if (activePanel != null)
             {
                 activePanel.DisableImmediate();
             }
             activePanel = new CustomPanel();
             activePanel.Enable();
         }
     }
     if (PauseButton(pauseRect, "gameSettings"))
     {
         if (IN_GAME_MAIN_CAMERA.GameType == GameType.Single || (IN_GAME_MAIN_CAMERA.GameType == GameType.MultiPlayer && PhotonNetwork.IsMasterClient))
         {
             if (activePanel != null)
             {
                 activePanel.DisableImmediate();
             }
             activePanel = new GameModesPanel();
             activePanel.Enable();
         }
     }
     if (PauseButton(pauseRect, "settings"))
     {
         if (activePanel != null)
         {
             activePanel.DisableImmediate();
         }
         activePanel = AnarchyManager.SettingsPanel;
         activePanel.Enable();
     }
     if (PauseButton(pauseRect, "btnQuit"))
     {
         Quit();
         return;
     }
 }
Ejemplo n.º 14
0
 public GUIDrawer(GUIBase myBase)
 {
     owner = myBase;
 }