Example #1
0
 public void Draw(TimeSpan delta)
 {
     if (fCount > DELAY_FRAMES)
     {
         ui.RenderWidget();
     }
 }
Example #2
0
 public override void Draw(double delta)
 {
     RenderMaterial.VertexLighting = true;
     scene.Draw();
     ui.RenderWidget(delta);
     DoFade(delta);
     cur.Draw(Game.RenderContext.Renderer2D, Game.Mouse, Game.TotalTime);
 }
Example #3
0
        public void Draw(int width, int height)
        {
            //Set viewport
            height -= 30;
            if (width <= 0)
            {
                width = 1;
            }
            if (height <= 0)
            {
                height = 1;
            }
            if (width != rw || height != rh)
            {
                if (rtarget != null)
                {
                    ImGuiHelper.DeregisterTexture(rtarget.Texture);
                    rtarget.Dispose();
                }
                rtarget = new RenderTarget2D(width, height);
                rw      = width;
                rh      = height;
                rt      = ImGuiHelper.RegisterTexture(rtarget.Texture);
            }
            //Draw
            win.Viewport.Push(0, 0, width, height);
            ctx.ViewportWidth            = width;
            ctx.ViewportHeight           = height;
            ctx.RenderState.RenderTarget = rtarget;
            ctx.RenderState.ClearColor   = Color4.TransparentBlack;
            ctx.RenderState.ClearAll();
            ctx.RenderWidget();
            ctx.RenderState.RenderTarget = null;
            win.Viewport.Pop();
            //ImGui
            ImGui.Button("x##a");
            ImGui.SameLine();
            ImGui.Button("x##b");
            var cpos = ImGui.GetCursorPos();

            ImGui.Image((IntPtr)rt, new Vector2(width, height), new Vector2(0, 1), new Vector2(1, 0),
                        Color4.White);
            ImGui.SetCursorPos(cpos);
            ImGui.InvisibleButton("##navmap", new Vector2(width, height));
        }
Example #4
0
        public override void Draw(double delta)
        {
            RenderMaterial.VertexLighting = true;
            if (scene != null)
            {
                scene.Draw();
            }
            ui.RenderWidget(delta);
            DoFade(delta);
            if (letterboxAmount > 0)
            {
                var pct = Cutscene.LETTERBOX_HEIGHT * (float)letterboxAmount;
                int h   = (int)(Game.Height * pct);
                Game.RenderContext.Renderer2D.FillRectangle(new Rectangle(0, 0, Game.Width, h), Color4.Black);
                Game.RenderContext.Renderer2D.FillRectangle(new Rectangle(0, Game.Height - h, Game.Width, h), Color4.Black);
            }
            if (animatingLetterbox)
            {
                letterboxAmount -= delta * 3;
                if (letterboxAmount < 0)
                {
                    letterboxAmount    = -1;
                    animatingLetterbox = false;
                    ui.Visible         = true;
                }
            }
            Game.Debug.Draw(delta, () =>
            {
                ImGui.Text($"Room: {currentRoom.Nickname}");
                ImGui.Text($"Virtual: {virtualRoom ?? "NONE"}");
            });

            if (ui.Visible || ui.HasModal)
            {
                if (GetHotspot(Game.Mouse.X, Game.Mouse.Y) != null)
                {
                    talk_story.Draw(Game.RenderContext.Renderer2D, Game.Mouse, Game.TotalTime);
                }
                else
                {
                    cursor.Draw(Game.RenderContext.Renderer2D, Game.Mouse, Game.TotalTime);
                }
            }
        }
Example #5
0
        //RigidBody debugDrawBody;
        public override void Draw(TimeSpan delta)
        {
            RenderMaterial.VertexLighting = false;
            if (loading)
            {
                loader.Draw(delta);
                return;
            }
            sysrender.Draw();

            sysrender.DebugRenderer.StartFrame(camera, Game.RenderState);
            sysrender.DebugRenderer.Render();
            if ((Thn == null || !Thn.Running)) //HACK: Cutscene also updates the listener so we don't do it if one is running
            {
                Game.Sound.UpdateListener(delta, camera.Position, camera.CameraForward, camera.CameraUp);
            }

            if ((Thn == null || !Thn.Running) && ShowHud)
            {
                ui.RenderWidget();
            }
            Game.Renderer2D.Start(Game.Width, Game.Height);
            if ((Thn == null || !Thn.Running) && ShowHud)
            {
                string sel_obj = "None";
                if (selected != null)
                {
                    if (selected.Name == null)
                    {
                        sel_obj = "unknown object";
                    }
                    else
                    {
                        sel_obj = selected.Name;
                    }
                }
                DebugDrawing.DrawShadowedText(Game.Renderer2D, 16, string.Format(DEMO_TEXT, camera.Position.X, camera.Position.Y, camera.Position.Z, sys.Nickname, sys.Name, DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), Velocity, sel_obj, control.PlayerPitch, control.PlayerYaw, control.Roll, mouseFlight), 5, 5);
                //pyw.Draw(Game.Renderer2D);
                current_cur.Draw(Game.Renderer2D, Game.Mouse);
            }
            DoFade(delta);
            Game.Renderer2D.Finish();
        }
Example #6
0
        void DoViewport()
        {
            var szX = (int)ImGui.GetWindowContentRegionWidth();
            var szY = (int)ImGui.GetWindowHeight();

            if (rtX != szX || rtY != szY)
            {
                rtX = szX;
                rtY = szY;
                if (renderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(renderTarget.Texture);
                    renderTarget.Dispose();
                }
                renderTarget      = new RenderTarget2D(rtX, rtY);
                renderTargetImage = ImGuiHelper.RegisterTexture(renderTarget.Texture);
            }

            mainWindow.RenderState.RenderTarget = renderTarget;
            mainWindow.Viewport.Push(0, 0, rtX, rtY);
            mainWindow.RenderState.ClearColor = Color4.Black;
            mainWindow.RenderState.ClearAll();
            //Do drawing
            if (widget != null)
            {
                context.GlobalTime     = TimeSpan.FromSeconds(mainWindow.TotalTime);
                context.ViewportWidth  = rtX;
                context.ViewportHeight = rtY;
                context.RenderWidget();
            }
            //
            mainWindow.Viewport.Pop();
            mainWindow.RenderState.RenderTarget = null;
            //We don't use ImageButton because we need to be specific about sizing
            var cPos = ImGui.GetCursorPos();

            ImGui.Image((IntPtr)renderTargetImage, new Vector2(rtX, rtY), new Vector2(0, 1), new Vector2(1, 0));
            ImGui.SetCursorPos(cPos);
            var wPos = ImGui.GetWindowPos();
            var mX   = (int)(mainWindow.Mouse.X - cPos.X - wPos.X);
            var mY   = (int)(mainWindow.Mouse.Y - cPos.Y - wPos.Y);

            ImGui.InvisibleButton("##renderThing", new Vector2(rtX, rtY));
            if (ImGui.IsItemHovered())
            {
                context.Update(null, TimeSpan.FromSeconds(mainWindow.TotalTime), mX, mY, false);
                if (ImGui.IsItemClicked(0))
                {
                    context.OnMouseClick();
                }
                var isDown = ImGui.IsMouseDown(0);
                if (lastDown && !isDown)
                {
                    context.OnMouseUp();
                }
                if (isDown && !lastDown)
                {
                    context.OnMouseDown();
                }
                context.MouseLeftDown = isDown;
                lastDown = isDown;
            }
            else
            {
                context.Update(null, TimeSpan.FromSeconds(mainWindow.TotalTime), 0, 0, false);
                context.MouseLeftDown = false;
                if (lastDown)
                {
                    lastDown = false;
                    context.OnMouseUp();
                }
            }
        }
Example #7
0
        void Player(double delta)
        {
            bool childopened = true;

            ImGui.Begin("playwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            var szX = Math.Max((int)ImGui.GetWindowContentRegionWidth(), 32);
            var szY = Math.Max((int)ImGui.GetWindowHeight() - (int)(20 * ImGuiHelper.Scale), 32);

            if (rtX != szX || rtY != szY)
            {
                rtX = szX;
                rtY = szY;
                if (renderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(renderTarget.Texture);
                    renderTarget.Dispose();
                }
                renderTarget      = new RenderTarget2D(rtX, rtY);
                renderTargetImage = ImGuiHelper.RegisterTexture(renderTarget.Texture);
            }
            RenderContext.RenderTarget = renderTarget;
            RenderContext.PushViewport(0, 0, rtX, rtY);
            RenderContext.ClearColor = Color4.Black;
            RenderContext.ClearAll();
            //Do drawing
            _playContext.GlobalTime     = TotalTime;
            _playContext.ViewportWidth  = rtX;
            _playContext.ViewportHeight = rtY;
            _playContext.RenderWidget(delta);
            //
            RenderContext.PopViewport();
            RenderContext.RenderTarget = null;
            //We don't use ImageButton because we need to be specific about sizing
            var cPos = ImGui.GetCursorPos();

            ImGui.Image((IntPtr)renderTargetImage, new Vector2(rtX, rtY), new Vector2(0, 1), new Vector2(1, 0));
            ImGui.SetCursorPos(cPos);
            var wPos = ImGui.GetWindowPos();
            var mX   = (int)(Mouse.X - cPos.X - wPos.X);
            var mY   = (int)(Mouse.Y - cPos.Y - wPos.Y);

            ImGui.InvisibleButton("##renderThing", new Vector2(rtX, rtY));
            if (ImGui.IsItemHovered())
            {
                if (ImGui.GetIO().MouseWheel != 0)
                {
                    _playContext.OnMouseWheel(ImGui.GetIO().MouseWheel);
                }
                _playContext.Update(null, TotalTime, mX, mY, false);
                mouseWanted = _playContext.MouseWanted(mX, mY);
                if (ImGui.IsItemClicked(0))
                {
                    _playContext.OnMouseClick();
                }
                var isDown = ImGui.IsMouseDown(0);
                if (lastDown && !isDown)
                {
                    _playContext.OnMouseUp();
                }
                if (isDown && !lastDown)
                {
                    _playContext.OnMouseDown();
                }
                _playContext.MouseLeftDown = isDown;
                lastDown = isDown;
            }
            else
            {
                mouseWanted = false;
                _playContext.Update(null, TotalTime, 0, 0, false);
                _playContext.MouseLeftDown = false;
                if (lastDown)
                {
                    lastDown = false;
                    _playContext.OnMouseUp();
                }
            }
            ImGui.End();
        }
Example #8
0
        public void Draw(int width, int height, double delta)
        {
            //Set viewport
            height -= 30;
            if (width <= 0)
            {
                width = 1;
            }
            if (height <= 0)
            {
                height = 1;
            }
            if (width != rw || height != rh)
            {
                if (rtarget != null)
                {
                    ImGuiHelper.DeregisterTexture(rtarget.Texture);
                    rtarget.Dispose();
                }
                rtarget = new RenderTarget2D(width, height);
                rw      = width;
                rh      = height;
                rt      = ImGuiHelper.RegisterTexture(rtarget.Texture);
            }
            //Draw
            win.RenderContext.PushViewport(0, 0, width, height);
            ctx.ViewportWidth              = width;
            ctx.ViewportHeight             = height;
            ctx.RenderContext.RenderTarget = rtarget;
            ctx.RenderContext.ClearColor   = Color4.TransparentBlack;
            ctx.RenderContext.ClearAll();
            ctx.RenderWidget(delta);
            ctx.RenderContext.RenderTarget = null;
            win.RenderContext.PopViewport();
            //ImGui
            //TODO: Implement in Navmap then add buttons

            /*
             * NavButton("nav_labels", "Show Labels", true);
             * ImGui.SameLine();
             * ImGui.Dummy(new Vector2(72, 16)); //padding
             * ImGui.SameLine();
             * NavButton("nav_physical", "Physical Map", false);
             * ImGui.SameLine();
             * NavButton("nav_political", "Political Map", false);
             * ImGui.SameLine();
             * NavButton("nav_patrol", "Patrol Paths", false);
             * ImGui.SameLine();
             * NavButton("nav_mining", "Mining Zones", false);
             * ImGui.SameLine();
             * NavButton("nav_legend", "Legend", false);
             * ImGui.SameLine();
             * NavButton("nav_knownbases", "Known Bases", false);
             */
            var cpos = ImGui.GetCursorPos();

            ImGui.Image((IntPtr)rt, new Vector2(width, height), new Vector2(0, 1), new Vector2(1, 0),
                        Color4.White);
            ImGui.SetCursorPos(cpos);
            ImGui.InvisibleButton("##navmap", new Vector2(width, height));
        }