예제 #1
0
        public void Begin(int fixWidth = -1, int fixHeight = -1)
        {
            ImGuiHelper.AnimatingElement();
            var renderWidth  = Math.Max(120, (int)ImGui.GetWindowWidth() - MarginW);
            var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - MarginH);

            if (fixWidth > 0)
            {
                renderWidth = fixWidth;
            }
            if (fixHeight > 0)
            {
                renderHeight = fixHeight;
            }
            //Generate render target
            if (rh != renderHeight || rw != renderWidth)
            {
                if (RenderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(RenderTarget.Texture);
                    RenderTarget.Dispose();
                }
                RenderTarget = new RenderTarget2D(renderWidth, renderHeight);
                rid          = ImGuiHelper.RegisterTexture(RenderTarget.Texture);
                rw           = renderWidth;
                rh           = renderHeight;
            }
            if (mw.Config.MSAA != 0 && ((mrw != rw) || (mrh != rh) || (msamples != mw.Config.MSAA)))
            {
                if (msaa != null)
                {
                    msaa.Dispose();
                }
                msaa = new MultisampleTarget(rw, rh, mw.Config.MSAA);
            }
            else if (msaa != null)
            {
                msaa.Dispose();
                mrw      = mrh = -1;
                msamples = 0;
                msaa     = null;
            }
            cc = rstate.ClearColor;
            if (mw.Config.MSAA != 0)
            {
                rstate.RenderTarget = msaa;
            }
            else
            {
                rstate.RenderTarget = RenderTarget;
            }
            vps.Push(0, 0, rw, rh);
            rstate.Cull         = true;
            rstate.DepthEnabled = true;
            rstate.ClearColor   = Background;
            rstate.ClearAll();
        }
예제 #2
0
 public bool Draw()
 {
     ImGui.SetNextWindowSize(new Vector2(500, 400), ImGuiCond.FirstUseEver);
     if (ImGui.Begin($"Script##{unique}", ref isOpen))
     {
         if (doUpdate)
         {
             ImGuiHelper.AnimatingElement();          //Stops sleeping when running task on background thread
         }
         ImGui.Text(script.Info.Name);
         ImGui.Separator();
         if (running)
         {
             if (doUpdate)
             {
                 string text = "Running.";
                 var    t    = main.TotalTime - Math.Truncate(main.TotalTime);
                 if (t > 0.66)
                 {
                     text += "..";
                 }
                 else if (t > 0.33)
                 {
                     text += ".";
                 }
                 ImGui.Text(text);
             }
             else
             {
                 ImGui.Text("Finished");
             }
             ImGui.BeginChild($"##SCRIPTlog{unique}");
             ImGui.PushFont(ImGuiHelper.SystemMonospace);
             foreach (var line in lines)
             {
                 ImGui.TextWrapped(line);
             }
             if (lines.Count != lastCount && ImGui.GetScrollY() >= ImGui.GetScrollMaxY())
             {
                 ImGui.SetScrollHereY(1.0f);
             }
             lastCount = lines.Count;
             ImGui.PopFont();
             ImGui.EndChild();
         }
         else
         {
             for (int i = 0; i < arguments.Count; i++)
             {
                 arguments[i].Draw(i);
             }
             ImGui.Separator();
             if (ImGui.Button("Run"))
             {
                 Invoke();
             }
         }
         ImGui.End();
     }
     return(isOpen);
 }