public override void Draw(GameTime gameTime)
        {
            _renderer.BeginLayout(gameTime);

            DrawCVarWindow();
            DrawPlaybackControls();
            DrawConsole();
            DrawStatistics();
            DrawDebugCameraInfo();

            _renderer.EndLayout();

            base.Draw(gameTime);
        }
示例#2
0
        void DrawImGui(GameTime gameTime)
        {
            // ImGUI
            GuiRenderer.BeginLayout(gameTime);
            if (ImGui.CollapsingHeader("Program Settings", ImGuiTreeNodeFlags.DefaultOpen))
            {
                //_ = ImGui.Checkbox("Fullscreen", ref isFullScreen);
                //if (isFullScreen != graphics.IsFullScreen)
                //{
                //	graphics.ToggleFullScreen();
                //}
            }

            if (ImGui.CollapsingHeader("Map", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGui.Text($"Width={map.Width}");
                ImGui.Text($"Height={map.Height}");
                _ = ImGui.Checkbox($"DrawNoiseOnly={map.DrawNoiseOnly}", ref map.DrawNoiseOnly);
                //ImGui.Checkbox($"UseColourMap={map.UseColourMap}", ref map.UseColourMap);
            }

            if (ImGui.CollapsingHeader("Player", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGui.Text($"Name={player1.Name}");
                ImGui.Text($"Position={player1.Position}");
                ImGui.Text($"ScreenPosition={pos2}");
            }

            if (ImGui.CollapsingHeader("Animals", ImGuiTreeNodeFlags.DefaultOpen))
            {
                foreach (var v in animals)
                {
                    ImGui.Text($"Name={v.Name}");
                    ImGui.Text($"Position={v.Position}");
                }
            }

            if (ImGui.CollapsingHeader("Camera", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGui.Text($"Position={camera.Position}");
                ImGui.Text($"Zoom={camera.Zoom}");
                ImGui.Text($"VisibleArea={camera.VisibleArea}");
                ImGui.Text($"Bounds={camera.Bounds}");
            }

            if (ImGui.CollapsingHeader("Music", ImGuiTreeNodeFlags.DefaultOpen))
            {
                if (ImGui.Button("Play"))
                {
                    MediaPlayer.IsRepeating = true;
                    MediaPlayer.Play(GameServices.Songs["farm_music"]);
                }
                if (ImGui.Button("Stop"))
                {
                    MediaPlayer.Stop();
                }

                _ = ImGui.SliderFloat("Volume", ref volume, 0f, 1f);
                int currentPos = (int)MediaPlayer.PlayPosition.TotalSeconds;
                _ = ImGui.SliderInt("Position", ref currentPos, 0, (int)GameServices.Songs["farm_music"].Duration.TotalSeconds);
            }

            if (ImGui.CollapsingHeader("Noise Settings", ImGuiTreeNodeFlags.DefaultOpen))
            {
                _ = ImGui.SliderInt("Pixels", ref noiseSettings.NoiseSize, 1, 512);
                _ = ImGui.SliderInt("Octaves", ref noiseSettings.Octaves, 1, 8);
                _ = ImGui.SliderFloat("Initial Amplitude", ref noiseSettings.InitialAmplitude, 0f, 1f);
                _ = ImGui.SliderFloat("Initial Frequency", ref noiseSettings.InitialFrequency, 0f, 1f);
                _ = ImGui.SliderFloat("Lacunarity", ref noiseSettings.Lacunarity, 0f, 4f);
                _ = ImGui.SliderFloat("Persistence", ref noiseSettings.Persistence, 0f, 4f);
                _ = ImGui.SliderFloat("OffsetX", ref noiseSettings.Offset.Y, -100f, 100f);
                _ = ImGui.SliderFloat("OffsetY", ref noiseSettings.Offset.X, -100f, 100f);
                _ = ImGui.Checkbox($"UseKernel={noiseSettings.UseKernel}", ref noiseSettings.UseKernel);
            }

            if (ImGui.CollapsingHeader("Debug Data", ImGuiTreeNodeFlags.DefaultOpen))
            {
                //ImGui.Text($"Animation Offset={animationOffset}");
                ImGui.Text($"GameTime.TotalGameTime.TotalMilliseconds={gameTime.TotalGameTime.TotalMilliseconds}");
            }

            GuiRenderer.EndLayout();
        }
示例#3
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            //int drawCount = 0;
            sb.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);

            //sb.Draw(texLookup["pixel"], new Vector2(200, 200), Color.White);
            sb.Draw(texLookup["noiseTex"], new Rectangle(20, 20, 20 + 1024, 20 + 1024), null, Color.White);
            //DrawMap(sb, mapLookup["map1"]);
            //DrawDebugString(sb, fontLookup["Calibri"], $"DrawCount={drawCount}", new Vector2(8, 8));
            //sb.Draw(texLookup["terrain"], Vector2.Zero, Color.White);
            sb.End();

            base.Draw(gameTime);

            // ImGUI
            GuiRenderer.BeginLayout(gameTime);
            if (ImGui.CollapsingHeader("Program Settings", ImGuiTreeNodeFlags.DefaultOpen))
            {
                //_ = ImGui.Checkbox("Fullscreen", ref isFullScreen);
                //if (isFullScreen != graphics.IsFullScreen)
                //{
                //	graphics.ToggleFullScreen();
                //}
            }

            if (ImGui.CollapsingHeader("Animation Settings", ImGuiTreeNodeFlags.DefaultOpen))
            {
                _ = ImGui.Checkbox("Animate", ref animate);
                _ = ImGui.SliderFloat("Speed", ref animationSpeed, 0f, 100f);
                _ = ImGui.SliderFloat("Direction (radians)", ref animationDirection, 0f, (float)Math.PI * 2f);
            }

            if (ImGui.CollapsingHeader("Noise Settings", ImGuiTreeNodeFlags.DefaultOpen))
            {
                _ = ImGui.SliderInt("Pixels", ref noiseSettings.NoiseSize, 1, 512);
                _ = ImGui.SliderInt("Octaves", ref noiseSettings.Octaves, 1, 8);
                _ = ImGui.SliderFloat("Initial Amplitude", ref noiseSettings.InitialAmplitude, 0f, 1f);
                _ = ImGui.SliderFloat("Initial Frequency", ref noiseSettings.InitialFrequency, 0f, 1f);
                _ = ImGui.SliderFloat("Lacunarity", ref noiseSettings.Lacunarity, 0f, 4f);
                _ = ImGui.SliderFloat("Persistence", ref noiseSettings.Persistence, 0f, 4f);
                _ = ImGui.SliderFloat("OffsetX", ref noiseSettings.Offset.Y, -10f, 10f);
                _ = ImGui.SliderFloat("OffsetY", ref noiseSettings.Offset.X, -10f, 10f);
            }

            if (ImGui.CollapsingHeader("Colour Map", ImGuiTreeNodeFlags.DefaultOpen))
            {
                _ = ImGui.Checkbox("Enable", ref colourMapEnabled);
                _ = ImGui.ColorEdit3("Colour1", ref v1);
                _ = ImGui.ColorEdit3("Colour2", ref v2);
                _ = ImGui.ColorEdit3("Colour3", ref v3);
                _ = ImGui.ColorEdit3("Colour4", ref v4);
                _ = ImGui.ColorEdit3("Colour5", ref v5);
                _ = ImGui.ColorEdit3("Colour6", ref v6);

                _ = ImGui.SliderFloat("Position1", ref p1, 0f, p2);
                _ = ImGui.SliderFloat("Position2", ref p2, p1, p3);
                _ = ImGui.SliderFloat("Position3", ref p3, p2, p4);
                _ = ImGui.SliderFloat("Position4", ref p4, p3, 1f);
            }

            if (ImGui.CollapsingHeader("Debug Data", ImGuiTreeNodeFlags.DefaultOpen))
            {
                ImGui.Text($"Animation Offset {animationOffset}");
            }

            GuiRenderer.EndLayout();
        }