protected override void Draw(GameTime gameTime)
        {
            Profiler.Start("Rendering", Color.LimeGreen);
            Time.GameTime = gameTime;
            //GraphicsDevice.Clear(Color.CornflowerBlue);

            base.Draw(gameTime);

            if (IsGameWorldloaded)
            {
                worldRenderer.RenderWorld(theWorld);
            }
            else
            {
                World.Draw(gameTime);
            }

            RenderUtils.Draw(Graphics.GraphicsDevice,
                             World.player.camera.ViewMatrix,
                             World.player.camera.ProjectionMatrix);

            if (IsGameWorldloaded)
            {
                theWorld.player.Draw();
            }
            else
            {
                if (World.player != null)
                {
                    World.player.Draw();
                }
            }

            //Render UI
            UiStateManager.Begin();
            foreach (GuiScreen ui in GUIs)
            {
                if (ui.visible)
                {
                    ui.Render();
                }
            }
            UiStateManager.End();

            LateDraw();
            Profiler.Stop("Rendering");
        }
        public static void RegisterUiMenus()
        {
            //Caching images requires us to start the spritebatch
            UiStateManager.Begin();
            //ORDER MATTERS!!

            //UI
            hotbarUI = new HotbarScreen();
            GameClient.Instance.RegisterGui(hotbarUI);

#if !DEBUG
            //If this is a release build, we add the debug UI on top of the hotbar but beneath all other UI elements
            debugUI = new DebugScreen();
            GameClient.Instance.RegisterGui(debugUI);
#endif

            pauseUI = new PauseScreen();
            GameClient.Instance.RegisterGui(pauseUI);

            mainMenuUI = new MainMenuScreen();
            GameClient.Instance.RegisterGui(mainMenuUI);

            multiplayerUI = new MultiplayerScreen();
            GameClient.Instance.RegisterGui(multiplayerUI);

            optionsUI = new OptionsScreen();
            GameClient.Instance.RegisterGui(optionsUI);

            languageUI = new LanguageScreen();
            GameClient.Instance.RegisterGui(languageUI);

            statsUI = new StatisticsScreen();
            GameClient.Instance.RegisterGui(statsUI);

            loadingUI = new LoadingScreen();
            GameClient.Instance.RegisterGui(loadingUI);

#if DEBUG
            //If we're in debug mode, the debug UI is added last for debugging reasons
            debugUI = new DebugScreen();
            GameClient.Instance.RegisterGui(debugUI);
#endif

            UiStateManager.End();
        }
Beispiel #3
0
        /// <summary>
        /// Renders the profiler graph
        /// TODO: Make the graph renderer prettier. ie border, background, and then scaling it
        /// </summary>
        public override void Draw()
        {
            //Draw the background
            UiStateManager.DrawImage(new Rectangle(location.X + GameSettings.UIScale, location.Y + GameSettings.UIScale, size.X - 2 * GameSettings.UIScale, size.Y - 2 * GameSettings.UIScale), TextureLoader.getWhitePixel(), BackgroundColor);

            //Draw the border
            UiStateManager.DrawImage(new Rectangle(location.X, location.Y, size.X, GameSettings.UIScale), TextureLoader.getWhitePixel(), BorderColor);
            UiStateManager.DrawImage(new Rectangle(location.X, location.Y + size.Y - GameSettings.UIScale, size.X, GameSettings.UIScale), TextureLoader.getWhitePixel(), BorderColor);
            UiStateManager.DrawImage(new Rectangle(location.X, location.Y, GameSettings.UIScale, size.Y), TextureLoader.getWhitePixel(), BorderColor);
            UiStateManager.DrawImage(new Rectangle(location.X + size.X - GameSettings.UIScale, location.Y, GameSettings.UIScale, size.Y), TextureLoader.getWhitePixel(), BorderColor);

            X_START = location.X + GameSettings.UIScale + Padding;
            int currentY = location.Y + GameSettings.UIScale + Padding / 2;

            foreach (string timerId in Profiler.Timers.Keys)
            {
                //Draw each line, and overlay the text
                UiStateManager.DrawImage(new Rectangle(X_START, currentY, (int)(Profiler.Timers[timerId].ElapsedTicks * ADJUSTMENT), 18), TextureLoader.getWhitePixel(), Profiler.ProfilerColors[timerId]);
                UiStateManager.DrawText(new Vector2(X_START, currentY - 3), Profiler.ProfilerColors[timerId].Invert(), timerId + "(" + Profiler.Timers[timerId].ElapsedMilliseconds + " ms)");
                Profiler.Timers[timerId].Reset();
                currentY += 20;
            }
        }
Beispiel #4
0
        public override void Draw(Texture2D screen)
        {
            int MinX = screen.Width / 2 - CrossHairWidth / 2;
            int MaxX = MinX + CrossHairWidth;

            int MinY = screen.Height / 2 - CrossHairWidth / 2;
            int MaxY = MinY + CrossHairWidth;

            int HeightMinY = screen.Height / 2 - CrossHairThickness / 2;
            int HeightMaxY = HeightMinY + CrossHairThickness;

            int WidthMinY = screen.Width / 2 - CrossHairThickness / 2;
            int WidthMaxY = WidthMinY + CrossHairThickness;

            base.Draw(screen);

            Texture2D pixel = TextureLoader.getWhitePixel();

            //spriteBatch.Begin(SpriteSortMode.Deferred, InvertBlendState);
            UiStateManager.Begin();
            UiStateManager.DrawImage(new Rectangle(new Point(MaxX, HeightMaxY), new Point(MinX - MaxX, HeightMinY - HeightMaxY)), pixel, Color.White);
            UiStateManager.DrawImage(new Rectangle(new Point(WidthMaxY, MaxY), new Point(WidthMinY - WidthMaxY, MinY - MaxY)), pixel, Color.White);
            UiStateManager.End();
        }