protected override void Draw() { if (scale < destScale) { scale += 1f * Time.DeltaDrawTime; } if (scale > destScale) { scale -= 1f * Time.DeltaDrawTime; } element.Size = origSize * scale * MathF.Min(InnerDimensions.Width / origSize.X, InnerDimensions.Height / origSize.Y); Renderer2D.DrawQuadTL(Dimensions.Position, Dimensions.Size, BorderColor); Renderer2D.DrawQuadTL(Dimensions.Position + new Vector2(2f), Dimensions.Size - new Vector2(4f), IsMouseHovering ? HoveredColor : BackgroundColor); if (element is CircularMirror mirror) { mirror.UIDraw(); } else { element.Draw(); } Renderer2D.DrawQuadTL(Dimensions.Position + new Vector2(2f, Dimensions.Height - 22f), new Vector2(Dimensions.Width - 4f, 20f), IsMouseHovering ? HoveredColor : BackgroundColor); size = Renderer2D.DrawString(Localization.GetTranslation(element.GetType().Name), InnerDimensions.X + InnerDimensions.Width * 0.5f - size.X * 0.5f, InnerDimensions.Y + InnerDimensions.Height - size.Y - 2f, scale: 0.4f); }
protected override void Draw() { string choice = choices[index]; Renderer2D.DrawQuadTL(Dimensions.Position, Dimensions.Size, BorderColor); Renderer2D.DrawQuadTL(Dimensions.Position + new Vector2(2f), Dimensions.Size - new Vector2(4f), IsMouseHovering ? HoveredColor : BackgroundColor); size = Renderer2D.DrawString(Localization.GetTranslation(choice), Dimensions.X + Dimensions.Width * 0.5f - size.X * 0.5f, Dimensions.Y + Dimensions.Height * 0.5f - size.Y * 0.5f, scale: 0.75f); }
public override void OnRender() { Renderer2D.BeginScene(camera, shader); screen.InternalDraw(); Renderer2D.DrawString($"FPS: {1 / Time.DeltaDrawTime:F2}", 10f, 10f, scale: 0.5f); Renderer2D.EndScene(); }
protected override void OnRender(GameTime gameTime) { var transform = Matrix4x4.CreateOrthographicOffCenter(0, App.Window.Width, App.Window.Height, 0, -1, 1); _renderer.ProjectionMatrix = transform; _renderer.Begin(); _renderer.DrawString(_font, _fps, Vector2.Zero, Color.White); _renderer.End(); }
protected override void Draw() { Renderer2D.DrawQuadTL(Dimensions.Position, Dimensions.Size, BorderColor); Renderer2D.DrawQuadTL(Dimensions.Position + new Vector2(2f), Dimensions.Size - new Vector2(4f), IsMouseHovering ? HoveredColor : BackgroundColor); string text = Localization.GetTranslation(Text.entry); if (!string.IsNullOrWhiteSpace(text)) { size = Renderer2D.DrawString(text, Dimensions.X + Dimensions.Width * 0.5f - size.X * 0.5f, Dimensions.Y + Dimensions.Height * 0.5f - size.Y * 0.5f, scale: 0.75f); } }
protected override void OnRender(GameTime gameTime) { // TODO: word-wrap var text = _text; var measure = _font.MeasureString(text); var rect = new Rectangle(0, App.Window.Height - measure.Y, App.Window.Width, measure.Y); _renderer.ProjectionMatrix = Matrix4x4.CreateOrthographicOffCenter(0, App.Window.Width, App.Window.Height, 0, -1, 1); _renderer.Begin(); _renderer.FillRectangle(rect, Color.Gray); _renderer.DrawString(_font, text, rect.Location, Color.White); _renderer.End(); }
public void DrawString(Font font, string text, Vector2 position, Color color, int dropShadow = 0) { if (string.IsNullOrWhiteSpace(text)) { return; } var tint = GetProperTint(color); if (tint.A <= 0) { return; } if (dropShadow != 0) { DrawString(font, text, position + new Vector2(dropShadow, dropShadow), Color.Black); } _spriteBatch.DrawString(font, text, position, tint); }
public void Render(Renderer2D renderer) { Color objColor = new Color(0.6f, 0.4f, 0.9f, 1.0f); foreach (Layer layer in _scene.Layers) { foreach (GameObject obj in layer.Objects) { Color col = new Color(0.5f, 0.5f, 0.5f, 1.0f); if (SelectedGameObject == obj) { col = new Color(0.9f, 0.9f, 0.9f, 1.0f); } renderer.DrawRectangle( obj.Position, obj.Width, obj.Height, col, new Vector2(1, 1), SelectionBoxThickness); float strWidth = _viewportFont.MeasureString(obj.Name).X; Vector2 namePos = new Vector2(obj.Position.X - strWidth, obj.Position.Y + obj.Height + 10); namePos.X += (strWidth / 2) + (obj.Width / 2); renderer.DrawString(obj.Name, _viewportFont, namePos, col); } } }
protected override void Draw(double elapsed) { Viewport.Replace(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); imGui.NewFrame(elapsed); Renderer2D.Start(Width, Height); Renderer2D.DrawString("Arial", 16, "Librelancer", new Vector2(8), Color4.Black); Renderer2D.DrawString("Arial", 16, "Librelancer", new Vector2(6), Color4.White); var startY = Renderer2D.LineHeight("Arial", 16) + 8; Renderer2D.Finish(); ImGui.PushFont(ImGuiHelper.Noto); var size = (Vector2)ImGui.GetIO().DisplaySize; ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - startY), ImGuiCond.Always); ImGui.SetNextWindowPos(new Vector2(0, startY), ImGuiCond.Always, Vector2.Zero); bool childopened = true; ImGui.Begin("screen", ref childopened, ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoBringToFrontOnFocus | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoBackground); if (ImGui.BeginPopupModal("Error", ref openError, ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.Text(errorText); if (ImGui.Button("Ok")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } ImGui.AlignTextToFramePadding(); ImGui.Text("Freelancer Directory: "); ImGui.SameLine(); freelancerFolder.InputText("##folder", ImGuiInputTextFlags.None, 280); ImGui.SameLine(); if (ImGui.Button("...")) { string newFolder; if ((newFolder = FileDialog.ChooseFolder()) != null) { freelancerFolder.SetText(newFolder); } } ImGui.AlignTextToFramePadding(); ImGui.Text("Resolution: "); ImGui.SameLine(); ImGui.PushItemWidth(130); ImGui.InputInt("##resX", ref resolutionX, 0, 0); resolutionX = MathHelper.Clamp(resolutionX, 600, 16384); ImGui.SameLine(); ImGui.Text("x"); ImGui.SameLine(); ImGui.InputInt("##resY", ref resolutionY, 0, 0); resolutionY = MathHelper.Clamp(resolutionY, 400, 16384); ImGui.PopItemWidth(); SoundSlider("Master Volume: ", ref masterVolume); SoundSlider("Music Volume: ", ref musicVolume); SoundSlider("Sfx Volume: ", ref sfxVolume); ImGui.Checkbox("VSync", ref vsync); if (Program.introForceDisable) { ImGui.Text("Intro Movies Disabled"); } else { ImGui.Checkbox("Skip Intro Movies", ref skipIntroMovies); } ImGui.Dummy(new Vector2(16)); ImGui.Dummy(new Vector2(1)); ImGui.SameLine(ImGui.GetWindowWidth() - 70); if (ImGui.Button("Launch")) { LaunchClicked(); } ImGui.End(); ImGui.PopFont(); imGui.Render(RenderState); }