public TextureGridLayoutNode(GeneratorPreferences prefs, TextureGrid grid) { this.prefs = prefs; this.grid = grid ?? throw new ArgumentNullException(nameof(grid)); this.Margin = grid.FormattingMetaData.Margin ?? 0; this.ContentSize = ComputeContentSize(); this.TextAreaSize = ComputeTextSize(ContentSize); this.Size = ComputeGridSize(TextAreaSize, ContentSize); }
public static ITilePainter CreateTilePainter(this TextureGrid grid, GeneratorPreferences prefs) { var t = grid.Parent?.Parent?.TileType ?? TileType.Grid; switch (t) { case TileType.Grid: return(new TextureGridTilePainter(prefs, grid)); case TileType.Isometric: return(new IsoTilePainter(prefs, grid)); //case TileType.Hex: // return new GridTilePainter(prefs, grid); // todo Hex is not really supported here or in the base library for now. default: throw new ArgumentOutOfRangeException(); } }
public static bool ArrangeGrids(GeneratorPreferences prefs, TileTextureCollection c) { _ = prefs ?? throw new ArgumentNullException(nameof(prefs)); var grids = c.Grids.Select(g => new TextureGridLayoutNode(prefs, g)).OrderBy(e => - e.Size.Width).ToList(); foreach (var node in grids) { Logger.Verbose("Layout: {GridName} Weight: {Weight} Size:{Size}", node.Grid.Name, node.Size.Width * node.Size.Height, node.Size); } // All grids sorted by largest space consumed. var root = new ArrangeNode <TextureGridLayoutNode>(2048, 2048); var success = true; foreach (var grid in grids) { if (!root.Insert(grid.Size, grid)) { success = false; } root.Print(); } if (success) { root.Apply(n => { var content = n.Content; if (content != null) { content.Offset = new IntPoint(n.X, n.Y); } }); } return(success); }
public TextureGridTilePainter(GeneratorPreferences preferences, TextureGrid grid) : base(preferences, grid) { }
public TextureCollectionPainter(GeneratorPreferences prefs) { this.prefs = prefs ?? throw new ArgumentNullException(nameof(prefs)); }
public TextureGridPainter(GeneratorPreferences prefs, TextureGridLayoutNode node) { this.prefs = prefs; this.node = node ?? throw new ArgumentNullException(nameof(node)); this.grid = node.Grid; }
protected TilePainterBase(GeneratorPreferences preferences, TextureGrid grid) { this.Preferences = preferences; Grid = grid ?? throw new ArgumentNullException(nameof(grid)); }
public UserPreferences() { Preferences = new GeneratorPreferences(); RecentFiles = new ObservableCollection <RecentFileViewModel>(); }