// Draw public override void Draw() { // Top layer GUI.depth = 0; // Set GUI font if (GUI.skin.font != Config.instance.font) { GUI.skin.font = Config.instance.font; } GUIArea.width = Screen.width; GUIArea.height = Screen.height; if (introEnabled) { return; } // Always draw the invisible focus control GUIHelper.UnityFocusFix(); // Clear focus ClearFocus(); // Exit button and version number DrawExitButtonAndVersion(); // Clearing popup menu bool popupClear = false; if ( popupMenu != null && ( (Event.current.isMouse && Event.current.type == EventType.MouseUp && Event.current.button == 0) || (Event.current.isKey && Event.current.keyCode == KeyCode.Escape) ) ) { popupClear = true; } // General keys UpdateGeneralKeys(); // State switch (GameManager.currentState) { case State.ConnectingToLobby: ConnectingToLobbyGUI(); break; case State.Disconnected: DisconnectedGUI(); break; case State.Update: PleaseUpdateGUI(); break; case State.LogIn: LoginGUI(); break; case State.Register: RegisterGUI(); break; case State.License: LicenseGUI(); break; case State.Lobby: LobbyGUI(); break; case State.Game: /*if(Event.current.isKey && Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t' && !gameLobby.lobbyChat.chatInputFocused) { * if(GameManager.serverType != ServerType.Town || Player.main == null || !Player.main.talkingWithNPC) { * GUIHelper.Focus(GUI.GetNameOfFocusedControl()); * Event.current.Use(); * } * }*/ if (MainMenu.instance != null && (MainMenu.instance.currentState == InGameMenuState.Lobby)) { using (new GUIArea(Screen.width * 0.95f, Screen.height * 0.95f)) { LobbyGUI(); } } // On 1366 x 768 laptop screen you should use // 0.85f width for profile at least, 0.91f for artifacts // 0.75f height max if (Player.main != null && Player.main.talkingWithNPC) { using (new GUIArea(Screen.width * 0.91f, Screen.height * 0.75f)) { Player.main.talkingWithNPC.Draw(); } } break; } // Changelog DrawChangeLog(); // Popup menu if (popupMenu != null) { popupMenu.Draw(); if (popupClear && popupMenu != null) { popupMenu.Close(); } } // Tooltip DrawTooltip(); // Popup window if (popupWindow != null) { // Dim background DimBackground(); using (new GUIArea(new Rect(GUIArea.width * 0.25f, GUIArea.height * 0.25f, GUIArea.width * 0.5f, GUIArea.height * 0.5f))) { using (new GUIVerticalCenter()) { using (new GUIHorizontalCenter()) { popupWindow.DrawAll(); } } } } // Disable game input when GUI is active if (GUIUtility.hotControl != 0 || GUIUtility.keyboardControl != 0) { InputManager.ignoreInput = true; InputManager.instance.Clear(); } else { InputManager.ignoreInput = false; } // Debug if (Debugger.instance.debugGUI && Event.current.type == EventType.Layout) { Debugger.Label("FocusedControl: " + GUI.GetNameOfFocusedControl()); Debugger.Label("HotControl: " + GUIUtility.hotControl.ToString()); Debugger.Label("KeyboardControl: " + GUIUtility.keyboardControl.ToString()); } // Debugger Debugger.instance.Draw(); }