public static void PopParams() { if (parameterStack.Count > 0) { activeParameters = parameterStack.Pop(); } }
/** * Draws this item's representation */ public override void Draw() { Engine.PerformanceStatsInProgress.GuiUpdates++; if (ItemInstance != null) { var item = ItemInstance.Item; Sprite icon = CoM.Instance.ItemIconSprites[item.IconID]; DrawParameters dp = DrawParameters.Default; int offsetX = (int)((Width) - icon.rect.width) / 2; int offsetY = (int)((Height) - icon.rect.height) / 2; SmartUI.Color = Color; dp.Transform = ColorTransform; if (BeingDragged || !Enabled) { SmartUI.Color = Color.gray; dp = DrawParameters.BlackAndWhite; } SmartUI.Draw(X + offsetX, Y + offsetY, icon, dp); SmartUI.Color = Color.white; if (ItemInstance.Item.Usable) { GUIStyle myStyle = CoM.SubtextStyle; myStyle.alignment = TextAnchor.LowerLeft; SmartUI.TextWithShadow(new Rect(X + offsetX + 2, Y + offsetY, 40, 35), ItemInstance.RemainingCharges.ToString(), myStyle, 1); } } }
public override void Draw(DrawParameters p) { if (this.isTriggered) { base.Draw(p); } }
public CodeViewTab(ArmAssembly.ArmFileInfo progInfo, ApplicationJimulator jm) { JM = jm; _PI = progInfo; string fileName = progInfo.FileName; InitializeComponent(); this.SuspendLayout(); this.Location = new System.Drawing.Point(4, 22); this.Name = fileName; this.Size = new System.Drawing.Size(464, 312); this.TabIndex = 0; this.Text = Path.GetFileName(fileName); _codeViewList = new CodeViewList(this); _codeViewList.DrawItem += this.drawItem; _codeViewList.VisibleChanged += this.createLines; this.Controls.Add(_codeViewList); this.fileSystemWatcher1.Path = Path.GetDirectoryName(fileName); this.fileSystemWatcher1.Filter = Path.GetFileName(fileName); //_fileChanged = false; this.ResumeLayout(false); _drawParameters = new DrawParameters(_codeViewList.CreateGraphics(), _codeViewList.Font); }
public override void Draw(DrawingContext dc, DrawParameters parameters) { double radius = this.Radius; if (IsSelected) { // draw highlight dc.DrawEllipse(highlightBrush, null, Position, radius + 5, radius + 5); } dc.DrawEllipse(brush, null, Position, radius, radius); if (parameters.ZoomLevel > DetailThreshold) { // draw text //Point textPosition = new Point(Position.X - formattedText.Width / 2, Position.Y + radius); //dc.DrawText(formattedText, textPosition); // draw image if (image != null) { double width = radius * 1.4; double height = radius * 1.4; Rect imageRect = new Rect(Position.X - width / 2, Position.Y - height / 2, width, height); dc.DrawImage(image, imageRect); } } }
public void DrawDebug(DrawParameters p) { if (!(this is XImage) && !(this is XBlock)) { return; } tmpBounds = this.GetScreenBounds(); #if WINDOWS tmpVector1 = MouseProcessor.LastPosition; #else tmpVector1 = TouchPanelProcessor.LastPosition; #endif if (!tmpBounds.Contains((int)tmpVector1.X, (int)tmpVector1.Y)) { return; } Color c = Color.Red * 0.3f; p.SpriteBatch.Draw(p.Game.BlankTexture, tmpBounds, c); if (!string.IsNullOrEmpty(this.Id)) { tmpVector1.X = tmpBounds.X; tmpVector1.Y = tmpBounds.Y; p.SpriteBatch.DrawString(p.Game.SystemFont, this.Id, tmpVector1, Color.Yellow); } }
void DrawActualSize(DrawParameters p) { // we're using location this.tmpVector1.X = this.PropState.ScreenBounds.Value.X; this.tmpVector1.Y = this.PropState.ScreenBounds.Value.Y; p.SpriteBatch.Draw(this.texture.Image, this.tmpVector1, this.SourceRectangle, actualBackColor, (float)screenRotation, this.Origin, this.PropState.Scale, (SpriteEffects)this.FlipEffects, this.PropState.Depth + p.NextSystemImageDepth()); }
public override void Draw(DrawParameters p) { base.Draw(p); if (p.Game.GameObject.ShowDebugInfo && p.Game.DrawDebugInfo) { DrawDebug(p); } }
public override void Draw(DrawingContext dc, DrawParameters parameters) { dc.DrawLine(pen, From.Position, To.Position); //if (parameters.ZoomLevel > DetailThreshold) //{ // Point position = VectorTools.MidPoint(From.Position, To.Position); // Point textPosition = new Point(position.X - formattedText.Width / 2, position.Y - formattedText.Height / 2); // dc.DrawText(formattedText, textPosition); //} }
public override void Draw(DrawParameters p) { if (this.PropState.ScreenBounds.HasValue) { this.location.X = this.PropState.ScreenBounds.Value.X; this.location.Y = this.PropState.ScreenBounds.Value.Y; p.SpriteBatch.DrawString(this.font.Font, GetText(), this.location, actualColor, (float)screenRotation, this.Origin, this.PropState.Scale, (SpriteEffects)this.FlipEffects, this.Depth + p.NextSystemImageDepth()); } base.Draw(p); }
/// <summary> /// This method represents the draw stage of the four primary stages of the component lifecycle /// (hierarchy building, component initialization, update and draw, dispose). /// <remarks> /// The <see cref="Draw"/> method is responsible for rendering the component on the screen. This is where /// the XGAME framework integrates with thatever the underlying graphics technolody is used. /// </remarks> /// </summary> public virtual void Draw(DrawParameters p) { if (this.Subcomponents != null) { for (int i = 0; i < this.Subcomponents.Count; i++) { var subcomponent = this.Subcomponents[i]; if (subcomponent.Enabled) { subcomponent.Draw(p); } } } }
}//ctor lstLine for ARM instruction public ListLine(DrawParameters drawParameters, string text, uint address, string hexContents, CodeViewTab parent) : base(drawParameters, text, parent) { Address = address; this.hexContents = hexContents; if (hexContents.Length == 8) { opcodeBytes = 4; } else if (hexContents.Length == 4) { opcodeBytes = 2; } addressValid = true; }//ctor lstLine for ARM instruction
public override void Draw(DrawParameters p) { if (this.PropState.ScreenBounds.HasValue) { this.tmpBounds = this.PropState.ScreenBounds.Value; if (GameEngine.Instance.Scale2D != Vector2.One) { var bounds = this.PropState.ScreenBounds.Value; bounds.Width += 1; bounds.Height += 1; this.PropState.ScreenBounds = bounds; } // first resolve the actual way we want to draw the image XImageStretchMode actualStretchMode = this.StretchMode; if (actualStretchMode == XImageStretchMode.Auto) { if ((this.Bounds.X != 0 || this.Bounds.Y != 0) && this.Bounds.Width == 0 && this.Bounds.Height == 0) { actualStretchMode = XImageStretchMode.ActualSize; } else { actualStretchMode = XImageStretchMode.Stretch; } } // draw it if (actualStretchMode == XImageStretchMode.ActualSize) { DrawActualSize(p); } else if (actualStretchMode == XImageStretchMode.Stretch) { DrawStretched(p); } else { DrawTiles(p); } this.PropState.ScreenBounds = this.tmpBounds; } base.Draw(p); }
/** Draws the sprite */ public override void DrawContents() { if (Sprite != null) { DrawParameters dp = GetDrawParameters; dp.AlphaBlend = AlphaBlend; dp.Scale = new Vector2(ContentsFrame.width / Sprite.rect.width, ContentsFrame.height / Sprite.rect.height); dp.Rotation = Rotation; if (!ImageColorTransform.IsIdentity) { dp.Transform = dp.Transform + ImageColorTransform; } SmartUI.Color = Color * ImageColor; SmartUI.Draw(0, 0, Sprite, dp); SmartUI.Color = Color.white; } }
public static void Draw(Rect screenRect, GUIStyle style, DrawParameters dp, SmartStyleState state = SmartStyleState.Normal) { Texture2D texture = style.normal.background; switch (state) { case SmartStyleState.Deactivated: texture = style.active.background ?? texture; break; case SmartStyleState.Depressed: texture = style.focused.background ?? texture; break; case SmartStyleState.Selected: texture = style.onActive.background ?? texture; break; case SmartStyleState.Hover: texture = style.hover.background ?? texture; break; } if (texture == null) { return; } Rect uvFrame = new Rect(0, 0, texture.width, texture.height); if (style.fixedHeight != 0f) { screenRect.height = style.fixedHeight; } if (style.fixedWidth != 0f) { screenRect.width = style.fixedWidth; } screenRect = style.overflow.Add(screenRect); DrawMaster(screenRect, texture, uvFrame, dp, style.border); }
public override void Draw() { if (CompositeAlpha <= 0f) { return; } if (hasRenderTexture && SmartUI.isRepaint && !forceStandardDraw) { // setup for render texture draw var dp = (CacheMode == CacheMode.Solid) ? DrawParameters.NoAlpha : DrawParameters.Default; dp.Transform = CompositeColorTransform; if (repaintedTextureThisFrame && Settings.Advanced.ShowCacheRenders) { dp = new DrawParameters(ColorTransform.TintAndMultiply(Color.red, Color.gray)); } if (CompositeAlpha < 1f) { var colorOffset = dp.Transform.ColorOffset; colorOffset[3] = ((1f - colorOffset[3]) * CompositeAlpha) - 1f; dp.Transform.ColorOffset = colorOffset; dp.AlphaBlend = true; } SmartUI.Draw(Bounds, compositeRenderTexture, new Rect(0, 0, compositeRenderTexture.width, compositeRenderTexture.height), dp); } else { if (hasBackgroundChildren) { SmartUI.BeginGroup(Bounds, false); DrawChildren(-1); SmartUI.EndGroup(); } base.Draw(); } }
public override void Draw(DrawParameters p) { if (this.PropState.ScreenBounds.HasValue) { this.tmpBounds = this.PropState.ScreenBounds.Value; if (GameEngine.Instance.Scale2D != Vector2.One) { var bounds = this.PropState.ScreenBounds.Value; bounds.Width += 1; bounds.Height += 1; this.PropState.ScreenBounds = bounds; } // first resolve the actual way we want to draw the image XImageStretchMode actualStretchMode = this.StretchMode; if (actualStretchMode == XImageStretchMode.Auto) { if ((this.Bounds.X != 0 || this.Bounds.Y != 0) && this.Bounds.Width == 0 && this.Bounds.Height == 0) actualStretchMode = XImageStretchMode.ActualSize; else actualStretchMode = XImageStretchMode.Stretch; } // draw it if (actualStretchMode == XImageStretchMode.ActualSize) DrawActualSize(p); else if (actualStretchMode == XImageStretchMode.Stretch) DrawStretched(p); else DrawTiles(p); this.PropState.ScreenBounds = this.tmpBounds; } base.Draw(p); }
public static void PushParams(Color color, float duration) { parameterStack.Push(activeParameters); activeParameters = new DrawParameters(color, duration, true); }
}//ctor ObjectCodeLine public ObjectCodeLine(DrawParameters drawParameters, uint address, string op, string operands, CodeViewTab parent) : base(drawParameters, String.Format(" {0,-6} {1}", op, operands), address, parent) { } //ctor ObjectCodeLine
public ObjectCodeLine(DrawParameters drawParameters, uint address, uint hexContents, string contents, CodeViewTab parent) : base(drawParameters, contents, address, hexContents.ToString("X8"), parent) { }//ctor ObjectCodeLine
}//ctor lstLine public ListLine(DrawParameters drawParameters, string text, string hexContents, CodeViewTab parent) : base(drawParameters, text, parent) { this.hexContents = hexContents; addressValid = false; }//ctor lstLine for ARM instruction
public ListLine(DrawParameters drawParameters, string text, uint address, CodeViewTab parent) : base(drawParameters, text, parent) { Address = address; addressValid = true; }//ctor lstLine
private string hexContents = null; // hex contents of line public ListLine(DrawParameters drawParameters, string text, CodeViewTab parent) : base(drawParameters, text, parent) { }
//private readonly int col; public ErrorMsgLine(DrawParameters drawParameters, string errorMsg, CodeViewTab parent) : base(drawParameters, errorMsg, parent) { //this.col = col; }
public static void PushParams(Color color, float duration, bool depthTest) { parameterStack.Push(activeParameters); activeParameters = new DrawParameters(color, duration, depthTest); }
void DrawStretched(DrawParameters p) { p.SpriteBatch.Draw(this.texture.Image, this.PropState.ScreenBounds.Value, this.SourceRectangle, actualBackColor, screenRotation, this.Origin, (SpriteEffects)this.FlipEffects, this.PropState.Depth + p.NextSystemImageDepth()); }
/** * Draws a texture with given parameter * * @param uvFrame frame for UVs in texels. */ private static void DrawMaster(Rect screenRect, Texture texture, Rect uvFrame, DrawParameters dp, RectOffset origionalBorder = null) { //3ms for these 4 lines if (!isRepaint) { return; } if (texture == null) { return; } if (!dp.IsVisibile(texture)) { return; } if (dp.Scale.x * dp.Scale.y == 0) { return; } screenRect.width *= dp.Scale.x; screenRect.height *= dp.Scale.y; Material material = dp.GetPreparedMaterial(texture); // -------------------------------------- // Transform and clip. Vector4 clipping = Vector4.zero; Rect transformedRect = TransformTheRect(screenRect); Rect clippedRect = transformedRect; Rect sourceRect = new Rect(uvFrame); int borderLeft = origionalBorder == null ? 0 : origionalBorder.left; int borderRight = origionalBorder == null ? 0 : origionalBorder.right; int borderTop = origionalBorder == null ? 0 : origionalBorder.top; int borderBottom = origionalBorder == null ? 0 : origionalBorder.bottom; // No clipping for rotated sprites yet. bool disableClip = dp.Rotation != 0; if (!disableClip) { clippedRect = ClipTheRect(transformedRect, ref clipping); bool hasClipped = (clipping != Vector4.zero); //stub: /* * if (hasClipped) { * SmartUI.Color = Color.red; * if (screenRect.Contains(new Vector2(InputEx.mousePosition.x, InputEx.mousePosition.y))) * Trace.LogDebug("Clipped {0} to {1}", transformedRect, clippedRect); * } else * SmartUI.Color = Color.green; */ if ((clippedRect.width <= 0) || (clippedRect.height <= 0)) { return; } if (hasClipped) { // Calculate clipped UVs. sourceRect = new Rect(); sourceRect.min = PixelToUV(transformedRect, uvFrame, clippedRect.min, origionalBorder); sourceRect.max = PixelToUV(transformedRect, uvFrame, clippedRect.max, origionalBorder); // Upside down swap. This has something todo with the fact that the screen has (0,0) at the top left // and the texture has (0,0) at the bottom left. float newMin = uvFrame.yMin + (uvFrame.yMax - sourceRect.yMax); float newMax = uvFrame.yMax + (uvFrame.yMin - sourceRect.yMin); sourceRect.yMin = newMin; sourceRect.yMax = newMax; // Adjust border for clipping. if (origionalBorder != null) { clipping[0] /= dp.Scale.x; clipping[2] /= dp.Scale.x; clipping[1] /= dp.Scale.y; clipping[3] /= dp.Scale.y; borderLeft = Util.ClampInt(borderLeft - (int)clipping[0], 0, int.MaxValue); borderRight = Util.ClampInt(borderRight - (int)clipping[2], 0, int.MaxValue); borderTop = Util.ClampInt(borderTop - (int)clipping[1], 0, int.MaxValue); borderBottom = Util.ClampInt(borderBottom - (int)clipping[3], 0, int.MaxValue); } } } // Convert source rect to normalised. sourceRect.xMin *= texture.texelSize.x; sourceRect.xMax *= texture.texelSize.x; sourceRect.yMin *= texture.texelSize.y; sourceRect.yMax *= texture.texelSize.y; // Work out the best way to draw this. DrawMethod drawMethod = DrawMethod.Standard; if (origionalBorder != null) { drawMethod = DrawMethod.Bordered; } if ((origionalBorder != null) && (texture.HighDPI())) { drawMethod = DrawMethod.Native; } if (ShowGuiMaterial && !dp.IsDebugDraw) { drawMethod = DrawMethod.DebugColor; } // Apply rotation if (dp.Rotation != 0) { Engine.PushGUI(); var rotationMatrix = Extentions.GetTranslationMatrix(clippedRect.center.x, clippedRect.center.y, 0) * Extentions.GetRotationMatrix(0, 0, dp.Rotation) * Extentions.GetTranslationMatrix(-clippedRect.center.x, -clippedRect.center.y, 0); GUI.matrix *= rotationMatrix; } // Draw the thing. switch (drawMethod) { case DrawMethod.DebugColor: Color = dp.DebugColor; DrawMaster(screenRect, StockTexture.White, new Rect(0, 0, 2, 2), DrawParameters.DebugDraw); break; case DrawMethod.Standard: Graphics.DrawTexture(clippedRect, texture, sourceRect, 0, 0, 0, 0, SmartUI.Color, material); break; case DrawMethod.Bordered: Graphics.DrawTexture(clippedRect, texture, sourceRect, borderLeft, borderRight, borderTop, borderBottom, SmartUI.Color, material); break; // The native draw will reverse the DPI scaling on the Gui matrix and then draw the object at an adjusted size. // This allows things like bordered gui objects to display correctly without distortion. case DrawMethod.Native: const float scale = 2; Engine.PushGUI(); GUI.matrix *= Matrix4x4.Scale(Vector3.one / scale); clippedRect = clippedRect.Scaled(scale); Graphics.DrawTexture(clippedRect, texture, sourceRect, (int)(borderLeft * scale), (int)(borderRight * scale), (int)(borderTop * scale), (int)(borderBottom * scale), SmartUI.Color, material); Engine.PopGUI(); break; } if (ShowGuiBounds && !dp.IsDebugDraw) { Color = Color.red; DrawMaster(screenRect, StockTexture.SimpleRect, new Rect(0, 0, 4, 4), DrawParameters.DebugDraw, BORDER_2PX); } if (dp.Rotation != 0) { Engine.PopGUI(); } Color = Color.white; }
// ----------------------------------------- // texture drawing routines // ----------------------------------------- public static void Draw(Rect screenRect, Texture texture, Rect uvFrame, DrawParameters dp) { DrawMaster(screenRect, texture, uvFrame, dp); }
void DrawTiles(DrawParameters p) { var depth = this.PropState.Depth + p.NextSystemImageDepth(); var imageRes = this.texture.Image.Bounds; Rectangle screenBounds = Rectangle.Empty; this.PropState.ScreenBounds.Value.ToRectangle(ref screenBounds); // fill whole rows and cols first int wholeCols = screenBounds.Width / imageRes.Width; int wholeRows = screenBounds.Height / imageRes.Height; Vector2 loc = new Vector2(screenBounds.X, screenBounds.Y); Rectangle? srcRect = null; this.SourceRectangle.ToRectangle(ref srcRect); for(int row = 0; row < wholeRows; row++) { loc.X = screenBounds.X; for(int col = 0; col < wholeCols; col++) { p.SpriteBatch.Draw(this.texture.Image, loc, srcRect, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); loc.X += imageRes.Width; } loc.Y += imageRes.Height; } // fill margins int rightMargin = screenBounds.Width % imageRes.Width; int bottomMargin = screenBounds.Height % imageRes.Height; Rectangle sourceBounds = imageRes; if (rightMargin != 0) { loc.X = screenBounds.X + wholeCols * imageRes.Width; loc.Y = screenBounds.Y; sourceBounds.Width = rightMargin; for (int row = 0; row < wholeRows; row++) { p.SpriteBatch.Draw(this.texture.Image, loc, sourceBounds, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); loc.Y += imageRes.Height; } if (bottomMargin != 0) { sourceBounds.Height = bottomMargin; p.SpriteBatch.Draw(this.texture.Image, loc, sourceBounds, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); } } if (bottomMargin != 0) { loc.X = screenBounds.X; sourceBounds.Width = imageRes.Width; for (int col = 0; col < wholeCols; col++) { p.SpriteBatch.Draw(this.texture.Image, loc, sourceBounds, actualBackColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, depth); loc.X += imageRes.Width; } } }
public static void Draw(Rect screenRect, Sprite sprite, DrawParameters dp) { DrawMaster(screenRect, sprite.texture, sprite.rect, dp); }
protected CodeViewLine(DrawParameters drawParameters, string text, CodeViewTab parent) { _drawParameters = drawParameters; Text = text; _parent = parent; }
public ErrorLine(DrawParameters drawParameters, string text, int line, CodeViewTab parent) : base(drawParameters, text, parent) { mLine = line; }
public static void Draw(float x, float y, Sprite sprite, DrawParameters dp) { Draw(new Rect(x, y, sprite.rect.width, sprite.rect.height), sprite, dp); }