public Border(IScreen screen, DisplayLayer drawOrder, Bounds bounds, int lineWidth, int padding, Color lineColor, Color outlineColor) : base(screen, drawOrder) { LineWidth = lineWidth; Padding = padding; lines = new Lines (screen, drawOrder, lineWidth, lineColor, outlineColor); Bounds = bounds; }
public MenuScreen(GameCore game) : base(game) { // die Linien lines = new Lines (screen: this, drawOrder: DisplayLayer.Dialog, lineWidth: 6); // der Mauszeiger pointer = new MousePointer (this); // häufig verwendete Positionen und Größen ScreenContentBounds = new Bounds (screen: this, relX: 0.075f, relY: 0.180f, relWidth: 0.850f, relHeight: 0.650f); ScreenTitleBounds = new Bounds (this, 0.075f, 0.075f, 0.900f, 0.050f); }
public void Bounds_FromDirection_Test() { //top Bounds compareBound = new Bounds (point, new ScreenPoint (fakeScreen, 1f, 0.9f)); Assert.IsTrue (boundsEqual (compareBound, bound.FromTop (0.9f)), "top"); //bottom compareBound = new Bounds (new ScreenPoint (fakeScreen, 0f, 0.1f), new ScreenPoint (fakeScreen, 1f, 0.9f)); Assert.IsTrue (boundsEqual (bound.FromBottom (0.9f), compareBound), "bottom"); //right compareBound = new Bounds (new ScreenPoint (fakeScreen, 0.1f, 0f), new ScreenPoint (fakeScreen, 0.9f, 1f)); Assert.IsTrue (boundsEqual (bound.FromRight (0.9f), compareBound), "right"); //left compareBound = new Bounds (point, new ScreenPoint (fakeScreen, 0.9f, 1f)); Assert.IsTrue (boundsEqual (bound.FromLeft (0.9f), compareBound), "left"); }
public override void Draw(GameTime time) { if (IsVisible) { spriteBatch.Begin (); // color tiles int i = 0; foreach (ScreenPoint tile in tiles) { Bounds tileBounds = new Bounds (Bounds.Position + tile, tileSize); Rectangle rect = tileBounds.Rectangle.Shrink (1); Texture2D dummyTexture = ContentLoader.CreateTexture (Screen.GraphicsDevice, colors [i]); spriteBatch.Draw (dummyTexture, rect, Color.White); ++i; } spriteBatch.End (); } }
public static void DrawStringInRectangle(this SpriteBatch spriteBatch, SpriteFont font, string text, Color color, Bounds bounds, HorizontalAlignment alignX, VerticalAlignment alignY) { Vector2 scaledPosition = bounds.Position.AbsoluteVector; Vector2 scaledSize = bounds.Size.AbsoluteVector; try { // finde die richtige Skalierung Vector2 scale = spriteBatch.ScaleStringInRectangle (font, text, color, bounds, alignX, alignY); // finde die richtige Position Vector2 textPosition = TextPosition ( font: font, text: text, scale: scale, position: scaledPosition, size: scaledSize, alignX: alignX, alignY: alignY ); // zeichne die Schrift spriteBatch.DrawString (font, text, textPosition, color, 0, Vector2.Zero, scale, SpriteEffects.None, 0.6f); } catch (ArgumentException exp) { Log.Debug (exp); } catch (InvalidOperationException exp) { Log.Debug (exp); } }
public Border(IScreen screen, DisplayLayer drawOrder, Bounds bounds, int lineWidth, int padding) : this(screen: screen, drawOrder: drawOrder, bounds: bounds, lineWidth: lineWidth, padding: lineWidth, lineColor: Design.DefaultLineColor, outlineColor: Design.DefaultOutlineColor) { }
/// <summary> /// Erzeugt ein neues CreativeLoadScreen-Objekt und initialisiert dieses mit einem Knot3Game-Objekt. /// </summary> public CreativeLoadScreen(GameCore game) : base(game) { savegameMenu = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu); savegameMenu.Bounds.Position = ScreenContentBounds.Position; savegameMenu.Bounds.Size = new ScreenPoint (this, 0.300f, ScreenContentBounds.Size.Relative.Y); savegameMenu.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f); savegameMenu.ItemAlignX = HorizontalAlignment.Left; savegameMenu.ItemAlignY = VerticalAlignment.Center; savegameMenu.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; savegameMenu.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; savegameMenu.RelativeItemHeight = Design.DataItemHeight; lines.AddPoints (.000f, .050f, .030f, .970f, .620f, .895f, .740f, .970f, .760f, .895f, .880f, .970f, .970f, .050f, 1.000f); title = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Load Knot"); title.Bounds.Position = ScreenTitleBounds.Position; title.Bounds.Size = ScreenTitleBounds.Size; title.ForegroundColorFunc = (s) => Color.White; infoTitle = new TextItem (screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, text: "Knot Info:"); infoTitle.Bounds.Position = new ScreenPoint (this, 0.45f, 0.62f); infoTitle.Bounds.Size = new ScreenPoint (this, 0.900f, 0.050f); infoTitle.ForegroundColorFunc = (s) => Color.White; knotInfo = new Menu (this, DisplayLayer.ScreenUI + DisplayLayer.Menu); knotInfo.Bounds.Position = new ScreenPoint (this, 0.47f, 0.70f); knotInfo.Bounds.Size = new ScreenPoint (this, 0.300f, 0.500f); knotInfo.Bounds.Padding = new ScreenPoint (this, 0.010f, 0.010f); knotInfo.ItemAlignX = HorizontalAlignment.Left; knotInfo.ItemAlignY = VerticalAlignment.Center; // Erstelle einen Parser für das Dateiformat KnotFileIO fileFormat = new KnotFileIO (); // Erstelle einen Spielstand-Loader loader = new SavegameLoader<Knot, KnotMetaData> (fileFormat, "index-knots"); // Preview Bounds previewBounds = new Bounds (this, 0.45f, 0.1f, 0.48f, 0.5f); previewWorld = new World ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.GameWorld, bounds: previewBounds ); previewRenderer = new KnotRenderer (screen: this, position: Vector3.Zero); previewWorld.Add (previewRenderer); previewBorder = new Border ( screen: this, drawOrder: DisplayLayer.GameWorld, bounds: previewBounds, lineWidth: 2, padding: 0 ); previewInput = new KnotInputHandler (screen: this, world: previewWorld); previewMouseHandler = new ModelMouseHandler (screen: this, world: previewWorld); backButton = new Button ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Back", onClick: (time) => NextScreen = Game.Screens.Where ((s) => !(s is CreativeLoadScreen)).ElementAt (0) ); backButton.AddKey (Keys.Escape); backButton.SetCoordinates (left: 0.770f, top: 0.910f, right: 0.870f, bottom: 0.960f); backButton.AlignX = HorizontalAlignment.Center; startButton = new Button ( screen: this, drawOrder: DisplayLayer.ScreenUI + DisplayLayer.MenuItem, name: "Load", onClick: (time) => NextScreen = new CreativeModeScreen (game: Game, knot: loader.FileFormat.Load (previewKnotMetaData.Filename)) ); startButton.IsVisible = false; startButton.AddKey (Keys.Enter); startButton.SetCoordinates (left: 0.630f, top: 0.910f, right: 0.730f, bottom: 0.960f); startButton.AlignX = HorizontalAlignment.Center; }
public Bounds In(Bounds container) { return new Bounds (Position + container.Position, Size, Padding); }
public void Bounds_Grow_Test() { FakeScreen screen2 = new FakeScreen (width: 1000, height: 1000); Bounds bounds = new Bounds (screen: screen2, relX: 0.100f, relY: 0.100f, relWidth: 0.300f, relHeight: 0.700f); Assert.IsTrue (boundsEqual (bounds.Grow (5), new Bounds (screen: screen2, relX: 0.095f, relY: 0.095f, relWidth: 0.310f, relHeight: 0.710f))); Assert.IsTrue (boundsEqual (bounds.Grow (5, 2), new Bounds (screen: screen2, relX: 0.095f, relY: 0.098f, relWidth: 0.310f, relHeight: 0.704f))); Assert.IsTrue (boundsEqual (bounds.Shrink (5), new Bounds (screen: screen2, relX: 0.105f, relY: 0.105f, relWidth: 0.290f, relHeight: 0.690f))); Assert.IsTrue (boundsEqual (bounds.Shrink (5, 2), new Bounds (screen: screen2, relX: 0.105f, relY: 0.102f, relWidth: 0.290f, relHeight: 0.696f))); }
private bool boundsEqual(Bounds a, Bounds b) { if (a.Position.Equals (b.Position) && a.Size.Equals (b.Size)) { return true; } else { return false; } }
public void Init() { fakeScreen = new FakeScreen (); point = new ScreenPoint (fakeScreen, 0, 0); size = new ScreenPoint (fakeScreen, 1, 1); testPoint = new ScreenPoint (fakeScreen, 0.5f, 0.5f); bound = new Bounds (point, size); }
public void Bounds_Set_Test() { ScreenPoint newSize = new ScreenPoint (fakeScreen, 1f, 0.9f); Bounds compareBound = new Bounds (point, newSize); bound.Size = newSize; Assert.AreEqual (true, boundsEqual (compareBound, bound)); }
public void Bounds_In_Test() { Bounds bound2 = new Bounds (point, size); Assert.AreEqual (true, boundsEqual (bound.In (bound),bound2)); }
public Bounds In(Bounds container) { return(new Bounds(Position + container.Position, Size, Padding)); }