protected override SceneObject makeSceneObject() { var pressOffset = this.isPressed && this.isHovered ? new Vector2(PressOffsetX, PressOffsetY) : new Vector2(0, 0); var background = this.isHovered ? this.BackgroundHover : this.mBackgroundNormal; var soBuilder = new SceneObjectBuilder(). PixelSize(1 / SettingsWinforms.Get.GuiScale). Clip(this.Position.ClipArea). //TODO(v0.8) add press offset to clip area StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center + pressOffset). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (!string.IsNullOrWhiteSpace(this.Text)) { soBuilder.StartText(this.Text, -0.5f, 0.5f, this.Z0 - this.ZRange / 2, this.ZRange / 2, this.TextColor). Scale(this.TextHeight). Translate(this.Position.Center + new Vector2(0, this.textSize.Y / 2f * this.TextHeight)); } if (this.mForgroundImage.HasValue) { soBuilder. StartSimpleSprite(this.Z0 - this.ZRange / 2, this.mForgroundImage.Value, Color.White). Scale(this.Position.Size - new Vector2(2 * this.paddingX, 2 * this.paddingY)). Translate(this.Position.Center); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { var background = this.mBackgroundNormal; if (this.isHovered) { background = this.mBackgroundHover; } if (this.isToggled) { background = this.mBackgroundToggled; } var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (this.mForgroundImage != null) { soBuilder. StartSprite(this.Z0 - this.ZRange / 2, this.mForgroundImage.Sprite.Id, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(this.mForgroundImage, this.Position.Size.X, this.Position.Size.Y)); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { var pressOffset = this.isPressed && this.isHovered ? new Vector2(PressOffsetX, PressOffsetY) : new Vector2(0, 0); var background = this.isHovered ? this.BackgroundHover : this.mBackgroundNormal; var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). //TODO(v0.8) add press offset to clip area StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center + pressOffset). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (!string.IsNullOrWhiteSpace(this.Text)) { //TODO(later) split single line if it doesn't fit var lines = this.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None); for (int i = 0; i < lines.Length; i++) { soBuilder.StartText(lines[i], this.fontSize(), -0.5f, this.Z0 - this.ZRange / 2, TextRenderUtil.Get.TextureId, this.TextColor, Matrix4.Identity). Scale(this.fontHeight, this.fontHeight). Translate(this.Position.Center + new Vector2(0, (lines.Length / 2f - i) * this.fontHeight)); } } if (this.mForgroundImage.HasValue) { soBuilder. StartSimpleSprite(this.Z0 - this.ZRange / 2, this.mForgroundImage.Value, Color.White). Scale(this.Position.Size - new Vector2(2 * this.paddingX, 2 * this.paddingY)). Translate(this.Position.Center); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { if (this.mBackground != null) { return(new SceneObjectBuilder(). Clip(this.Position.ClipArea). StartSprite(this.Z0, this.mBackground.Sprite.Id, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(this.mBackground, this.Position.Size.X, this.Position.Size.Y)). Build()); } else { return(null); } }
protected override SceneObject makeSceneObject() { var railWidth = this.Position.Size.X - this.knobSize; var knobColor = this.mReadOnly ? Color.White : Color.DarkGray; var panelSprite = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 2); //TODO(v0.8) maybe make readonly mode have no knob but a fill from 0 to value return(new SceneObjectBuilder(). Clip(this.Position.ClipArea). StartSimpleSprite(this.Z0, GalaxyTextures.Get.PanelBackground, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(panelSprite, railWidth, this.Position.Size.Y - 4)). StartSprite(this.Z0 - this.ZRange / 2, GalaxyTextures.Get.PanelBackground.Id, knobColor). Translate(this.Position.Center + new Vector2(railWidth * (this.mValue - 0.5f), 0)). AddVertices(SpriteHelpers.GuiBackground(panelSprite, this.knobSize, this.knobSize)). Build()); }
protected override SceneObject makeSceneObject() { var pressOffset = this.isPressed && this.isHovered ? new Vector2(PressOffsetX, PressOffsetY) : new Vector2(0, 0); var background = this.isHovered ? this.BackgroundHover : this.mBackgroundNormal; var soBuilder = new SceneObjectBuilder(). Clip(this.Position.ClipArea). //TODO(v0.8) add press offset to clip area StartSprite(this.Z0, background.Sprite.Id, Color.White). Translate(this.Position.Center + pressOffset). AddVertices(SpriteHelpers.GuiBackground(background, this.Position.Size.X, this.Position.Size.Y)); if (this.forgroundImage.HasValue) { soBuilder. StartSimpleSprite(this.Z0 - this.ZRange / 2, this.forgroundImage.Value, Color.White). Scale(this.Position.Size - new Vector2(2 * this.mPadding, 2 * this.mPadding)). Translate(this.Position.Center); } return(soBuilder.Build()); }
protected override SceneObject makeSceneObject() { var railX = this.direction; var railY = this.direction.PerpendicularLeft; var railLength = Math.Abs(Vector2.Dot(this.Position.Size, railX)) - this.knobSize; var railWidth = Math.Abs(Vector2.Dot(this.Position.Size, railY)) - 4; var railSize = railX * railLength + railY * railWidth; var knobColor = this.mReadOnly ? Color.White : Color.DarkGray; var panelSprite = new BackgroundTexture(GalaxyTextures.Get.PanelBackground, 2); //TODO(v0.9) maybe make readonly mode have no knob but a fill from 0 to value return(new SceneObjectBuilder(). Clip(this.Position.ClipArea). StartSprite(this.Z0, GalaxyTextures.Get.PanelBackground.Id, Color.White). Translate(this.Position.Center). AddVertices(SpriteHelpers.GuiBackground(panelSprite, railSize.X, railSize.Y)). StartSprite(this.Z0 - this.ZRange / 2, GalaxyTextures.Get.PanelBackground.Id, knobColor). Translate(this.Position.Center + railX * railLength * (this.mValue - 0.5f)). AddVertices(SpriteHelpers.GuiBackground(panelSprite, this.knobSize, this.knobSize)). Build()); }