public void GivenSheet_WhenMappingDecimalValueBiggerThanMaxValue_ItSetsValidationError() { var columnName = "Decimal"; var sheetData = new SheetBuilder() .AddHeaders(columnName) .AddRow(r => r .AddCell(c => c.WithColumnIndex(0).WithRowIndex(0).WithValue(5.012m).Build()) .Build(0)) .Build(); var result = new SheetMapper() .AddConfigFor <TestModel>(cfg => cfg .HasHeaders() .MapColumn(column => column .WithHeader(columnName) .WithMaximum(5.011m) .IsRequired() .MapTo(t => t.DecimalProperty))) .Map <TestModel>(sheetData); result.ValidationErrors.Should().HaveCount(1); result.ValidationErrors.Single().PropertyName.Should().Be("DecimalProperty"); result.ValidationErrors.Single().CellValue.Should().Be(string.Empty); result.ValidationErrors.Single().ColumnName.Should().Be(columnName); }
public ExternalMods(string launchPath) { // Process.Start requires paths to not be quoted, even if they contain spaces if (launchPath.First() == '"' && launchPath.Last() == '"') { launchPath = launchPath.Substring(1, launchPath.Length - 2); } this.launchPath = launchPath; sheetBuilder = new SheetBuilder(SheetType.BGRA, 256); // Load registered mods var supportPath = Platform.ResolvePath(Path.Combine("^", "ModMetadata")); if (!Directory.Exists(supportPath)) { return; } foreach (var path in Directory.GetFiles(supportPath, "*.yaml")) { try { var yaml = MiniYaml.FromStream(File.OpenRead(path), path).First().Value; LoadMod(yaml); } catch (Exception e) { Log.Write("debug", "Failed to parse mod metadata file '{0}'", path); Log.Write("debug", e.ToString()); } } }
public void GivenSheet_WhenCustomEnumParserIsProvided_ValueIsConvertedToEnum() { var sheetData = new SheetBuilder() .AddHeaders("EnumProperty") .AddRow(r => r.AddCell(c => c.WithColumnIndex(0).WithRowIndex(1).WithValue("Second").Build()).Build(1)) .Build(); var result = new SheetMapper() .AddConfigFor <TestModel>(cfg => cfg .HasHeaders() .MapColumn(column => column .WithHeader("EnumProperty") .IsRequired() .ParseValueUsing(x => { switch (x) { case "First": return(EnumModel.First); case "Second": return(EnumModel.Second); case "Third": return(EnumModel.Third); default: return(EnumModel.Default); } }) .MapTo(t => t.EnumProperty))) .Map <TestModel>(sheetData); result.IsSuccess.Should().BeTrue(); result.ParsedModels.Should().HaveCount(1); result.ParsedModels.First().Value.EnumProperty.Should().Be(EnumModel.Second); }
public void GivenSheetMapper_WhenCreatingTwoConfigs_TheyBothExist() { var sheetDataModelOne = new SheetBuilder() .AddHeaders("ModelOnePropertyOne") .AddRow(r => r .AddCell(c => c.WithColumnIndex(0).WithRowIndex(0).WithValue("SomeValue").Build()) .Build(1)) .Build(); var sheetDataModelTwo = new SheetBuilder() .AddHeaders("ModelTwoPropertyOne") .AddRow(r => r .AddCell(c => c.WithColumnIndex(0).WithRowIndex(0).WithValue("1").Build()) .Build(1)) .Build(); var sheetMapper = new SheetMapper() .AddConfigFor <ModelOne>(cfg => cfg .HasHeaders() .MapColumn(column => column.WithHeader("ModelOnePropertyOne").IsRequired().MapTo(t => t.ModelOnePropertyOne))) .AddConfigFor <ModelTwo>(cfg => cfg .HasHeaders() .MapColumn(column => column.IsRequired().MapTo(t => t.ModelTwoPropertyOne))); var resultModelOne = sheetMapper.Map <ModelOne>(sheetDataModelOne); var resultModelTwo = sheetMapper.Map <ModelTwo>(sheetDataModelTwo); resultModelOne.IsSuccess.Should().BeTrue(); resultModelOne.ParsedModels.Single().Value.ModelOnePropertyOne.Should().Be("SomeValue"); resultModelTwo.IsSuccess.Should().BeTrue(); resultModelTwo.ParsedModels.Single().Value.ModelTwoPropertyOne.Should().Be(1); }
public void TestNotCreateEmptyCells() { IWorkbook wb = new HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet = new SheetBuilder(wb, testData).Build(); Assert.AreEqual(sheet.PhysicalNumberOfRows, 3); NPOI.SS.UserModel.IRow firstRow = sheet.GetRow(0); NPOI.SS.UserModel.ICell firstCell = firstRow.GetCell(0); Assert.AreEqual(firstCell.CellType, CellType.NUMERIC); Assert.AreEqual(1.0, firstCell.NumericCellValue, 0.00001); NPOI.SS.UserModel.IRow secondRow = sheet.GetRow(1); Assert.IsNotNull(secondRow.GetCell(0)); Assert.IsNull(secondRow.GetCell(2)); NPOI.SS.UserModel.IRow thirdRow = sheet.GetRow(2); Assert.AreEqual(CellType.STRING, thirdRow.GetCell(0).CellType); String cellValue = thirdRow.GetCell(0).StringCellValue; Assert.AreEqual(testData[2][0].ToString(), cellValue); Assert.AreEqual(CellType.FORMULA, thirdRow.GetCell(2).CellType); Assert.AreEqual("A1+B2", thirdRow.GetCell(2).CellFormula); }
public void TestIobExceptionOnInvalidIndex() { IWorkbook wb = new HSSFWorkbook(); ISheet sheet = new SheetBuilder(wb, numericCells).Build(); CellRangeAddress rangeAddress = CellRangeAddress.ValueOf("A2:E2"); IChartDataSource <double> numDataSource = DataSources.FromNumericCellRange(sheet, rangeAddress); IndexOutOfRangeException exception = null; try { numDataSource.GetPointAt(-1); } catch (IndexOutOfRangeException e) { exception = e; } Assert.IsNotNull(exception); exception = null; try { numDataSource.GetPointAt(numDataSource.PointCount); } catch (IndexOutOfRangeException e) { exception = e; } Assert.IsNotNull(exception); }
public void InitializeFonts(ModData modData) { if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } using (new PerfTimer("SpriteFonts")) { if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } fontSheetBuilder = new SheetBuilder(SheetType.BGRA); Fonts = modData.Manifest.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(x.Value.First, modData.DefaultFileSystem.Open(x.Value.First).ReadAllBytes(), x.Value.Second, Device.WindowScale, fontSheetBuilder)).AsReadOnly(); } Device.OnWindowScaleChanged += (before, after) => { foreach (var f in Fonts) { f.Value.SetScale(after); } }; }
public ExternalMods() { sheetBuilder = new SheetBuilder(SheetType.BGRA, 256); // Several types of support directory types are available, depending on // how the player has installed and launched the game. // Read registration metadata from all of them var sources = Enum.GetValues(typeof(SupportDirType)) .Cast <SupportDirType>() .Select(t => Platform.GetSupportDir(t)) .Distinct(); foreach (var source in sources) { var metadataPath = Path.Combine(source, "ModMetadata"); if (!Directory.Exists(metadataPath)) { continue; } foreach (var path in Directory.GetFiles(metadataPath, "*.yaml")) { try { var yaml = MiniYaml.FromStream(File.OpenRead(path), path).First().Value; LoadMod(yaml, path); } catch (Exception e) { Log.Write("debug", "Failed to parse mod metadata file '{0}'", path); Log.Write("debug", e.ToString()); } } } }
public void Handle(XPathNodeIterator it, SheetBuilder builder) { if (!string.IsNullOrWhiteSpace(it.Current.Value)) { builder.AddName(it.Current.Value); } }
public ExternalMods() { sheetBuilder = new SheetBuilder(SheetType.BGRA, 256); // If the player has defined a local support directory (in the game directory) // then this will override both the regular and system support dirs var sources = new[] { Platform.SystemSupportDir, Platform.SupportDir }; foreach (var source in sources.Distinct()) { var metadataPath = Path.Combine(source, "ModMetadata"); if (!Directory.Exists(metadataPath)) { continue; } foreach (var path in Directory.GetFiles(metadataPath, "*.yaml")) { try { var yaml = MiniYaml.FromStream(File.OpenRead(path), path).First().Value; LoadMod(yaml, path); } catch (Exception e) { Log.Write("debug", "Failed to parse mod metadata file '{0}'", path); Log.Write("debug", e.ToString()); } } } }
public ExternalMods() { // Don't try to load mod icons if we don't have a texture to put them in if (Game.Renderer != null) { sheetBuilder = new SheetBuilder(SheetType.BGRA, CreateSheet); } // Several types of support directory types are available, depending on // how the player has installed and launched the game. // Read registration metadata from all of them foreach (var source in GetSupportDirs(ModRegistration.User | ModRegistration.System)) { var metadataPath = Path.Combine(source, "ModMetadata"); if (!Directory.Exists(metadataPath)) { continue; } foreach (var path in Directory.GetFiles(metadataPath, "*.yaml")) { try { var yaml = MiniYaml.FromStream(File.OpenRead(path), path).First().Value; LoadMod(yaml, path); } catch (Exception e) { Log.Write("debug", "Failed to parse mod metadata file '{0}'", path); Log.Write("debug", e.ToString()); } } } }
public void TestFormulaCache() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = new SheetBuilder(wb, plotData).Build(); IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30); IChart chart = Drawing.CreateChart(anchor); IChartAxis bottomAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Bottom); IChartAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); IScatterChartData scatterChartData = chart.ChartDataFactory.CreateScatterChartData(); DataMarker xMarker = new DataMarker(sheet, CellRangeAddress.ValueOf("A1:E1")); DataMarker yMarker = new DataMarker(sheet, CellRangeAddress.ValueOf("A2:E2")); IScatterChartSerie serie = scatterChartData.AddSerie(xMarker, yMarker); chart.Plot(scatterChartData, bottomAxis, leftAxis); XSSFScatterChartData.Serie xssfScatterSerie = (XSSFScatterChartData.Serie)serie; XSSFNumberCache yCache = xssfScatterSerie.LastCalculatedYCache; Assert.AreEqual(5, yCache.PointCount); Assert.AreEqual(4.0, yCache.GetValueAt(3), 0.00001); Assert.AreEqual(16.0, yCache.GetValueAt(5), 0.00001); }
public GoogleProtectedSheetProviderSpecs() { var sheetServiceWrapperMock = new Mock <ISheetsServiceWrapper>(); sheetServiceWrapperMock .Setup(s => s.Get(It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.FromResult(new ValueRange())); _googleClientServiceCreatorMock = new Mock <ICreateGoogleClientService>(); _googleClientServiceCreatorMock .Setup(g => g.Create(It.IsAny <string>(), It.IsAny <string>())) .Returns(sheetServiceWrapperMock.Object); var sheetData = new SheetBuilder() .AddHeaders("header1", "header2") .AddRow(r => r .AddCell(c => c.WithValue("FirstRowFirstColumn").Build()) .AddCell(c => c.WithValue("FirstRowSecondColumn").Build()) .Build(0)) .AddRow(r => r .AddCell(c => c.WithValue("SecondRowFirstColumn").Build()) .AddCell(c => c.WithValue("SecondRowSecondColumn").Build()) .Build(1)) .Build(); _googleSheetConverterMock = new Mock <IConvertDataToSheet <ValueRange> >(); _googleSheetConverterMock.Setup(s => s.Convert(It.IsAny <ValueRange>())).Returns(sheetData); }
public void InitializeFonts(ModData modData) { if (Fonts != null) { foreach (var font in Fonts.Values) { font.Dispose(); } } using (new PerfTimer("SpriteFonts")) { fontSheetBuilder?.Dispose(); fontSheetBuilder = new SheetBuilder(SheetType.BGRA, 512); Fonts = modData.Manifest.Get <Fonts>().FontList.ToDictionary(x => x.Key, x => new SpriteFont(x.Value.Font, modData.DefaultFileSystem.Open(x.Value.Font).ReadAllBytes(), x.Value.Size, x.Value.Ascender, Window.EffectiveWindowScale, fontSheetBuilder)).AsReadOnly(); } Window.OnWindowScaleChanged += (oldNative, oldEffective, newNative, newEffective) => { Game.RunAfterTick(() => { ChromeProvider.SetDPIScale(newEffective); foreach (var f in Fonts) { f.Value.SetScale(newEffective); } }); }; }
public void TestOneSeriePlot() { IWorkbook wb = new XSSFWorkbook(); ISheet sheet = new SheetBuilder(wb, plotData).Build(); IDrawing Drawing = sheet.CreateDrawingPatriarch(); IClientAnchor anchor = Drawing.CreateAnchor(0, 0, 0, 0, 1, 1, 10, 30); IChart chart = Drawing.CreateChart(anchor); IChartAxis bottomAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Bottom); IChartAxis leftAxis = chart.ChartAxisFactory.CreateValueAxis(AxisPosition.Left); IScatterChartData <string, double> scatterChartData = chart.ChartDataFactory.CreateScatterChartData <string, double>(); IChartDataSource <String> xs = DataSources.FromStringCellRange(sheet, CellRangeAddress.ValueOf("A1:J1")); IChartDataSource <double> ys = DataSources.FromNumericCellRange(sheet, CellRangeAddress.ValueOf("A2:J2")); IScatterChartSeries <string, double> series = scatterChartData.AddSeries(xs, ys); Assert.IsNotNull(series); Assert.AreEqual(1, scatterChartData.GetSeries().Count); Assert.IsTrue(scatterChartData.GetSeries().Contains(series)); chart.Plot(scatterChartData, bottomAxis, leftAxis); }
public void TestSheetName() { String sheetName = "TEST SHEET NAME"; IWorkbook wb = new HSSFWorkbook(); ISheet sheet = new SheetBuilder(wb, testData).SetSheetName(sheetName).Build(); Assert.AreEqual(sheetName, sheet.SheetName); }
public void ImGuiSetup() { ImGuiIOPtr io = ImGui.GetIO(); io.KeyMap[(int)ImGuiKey.Tab] = (int)ConsoleKey.Tab; io.KeyMap[(int)ImGuiKey.LeftArrow] = (int)ConsoleKey.LeftArrow; io.KeyMap[(int)ImGuiKey.RightArrow] = (int)ConsoleKey.RightArrow; io.KeyMap[(int)ImGuiKey.UpArrow] = (int)ConsoleKey.UpArrow; io.KeyMap[(int)ImGuiKey.DownArrow] = (int)ConsoleKey.DownArrow; io.KeyMap[(int)ImGuiKey.PageUp] = (int)ConsoleKey.PageUp; io.KeyMap[(int)ImGuiKey.PageDown] = (int)ConsoleKey.PageDown; io.KeyMap[(int)ImGuiKey.Home] = (int)ConsoleKey.Home; io.KeyMap[(int)ImGuiKey.End] = (int)ConsoleKey.End; io.KeyMap[(int)ImGuiKey.Delete] = (int)ConsoleKey.Delete; io.KeyMap[(int)ImGuiKey.Backspace] = (int)ConsoleKey.Backspace; io.KeyMap[(int)ImGuiKey.Enter] = (int)ConsoleKey.Enter; io.KeyMap[(int)ImGuiKey.Escape] = (int)ConsoleKey.Escape; io.KeyMap[(int)ImGuiKey.A] = (int)ConsoleKey.A; io.KeyMap[(int)ImGuiKey.C] = (int)ConsoleKey.C; io.KeyMap[(int)ImGuiKey.V] = (int)ConsoleKey.V; io.KeyMap[(int)ImGuiKey.X] = (int)ConsoleKey.X; io.KeyMap[(int)ImGuiKey.Y] = (int)ConsoleKey.Y; io.KeyMap[(int)ImGuiKey.Z] = (int)ConsoleKey.Z; io.DisplaySize = new Vector2(Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height); ImFontPtr ret; ret = io.Fonts.AddFontDefault(); IntPtr pixels; int width; int height; int bytesPerPixel; io.Fonts.GetTexDataAsRGBA32(out pixels, out width, out height, out bytesPerPixel); // Store our identifier var sheetBuilder = new SheetBuilder(SheetType.Indexed, width, height); var byteArray = new byte[width * height * bytesPerPixel]; Marshal.Copy(pixels, byteArray, 0, width * height * bytesPerPixel); sp = sheetBuilder.AddRGBA(byteArray, new Size(width, height)); // sp.Sheet.AsPng().Save("imguifont.png"); io.Fonts.SetTexID(fontAtlasID); // текстура для шрифта будет уже второй, так как перед этим была установлена текстура палитры в Renderer.cs //Game.Renderer.ImguiSpriteRenderer.ns = 0; imguifonttextureLocation = Game.Renderer.ImguiSpriteRenderer.SetRenderStateForSprite(sp); // записываем sheet от нашего спрайта в шейдерную коллекцию sheets, чтобы спрайт ушел в первый аргумент шейдера //Game.Renderer.ImguiSpriteRenderer.sheets[1] = Game.worldRenderer.World.Map.Rules.Sequences.SpriteCache.SheetBuilder.sheets[0]; //Game.Renderer.ImguiSpriteRenderer.IncrementNumSheets(); // Game.Renderer.ImguiSpriteRenderer.sheets[1] = Game.Renderer.SpriteRenderer.sheets[1]; }
public MapCache(ModData modData) { this.modData = modData; var gridType = Exts.Lazy(() => modData.Manifest.Get <MapGrid>().Type); previews = new Cache <string, MapPreview>(uid => new MapPreview(modData, uid, gridType.Value, this)); sheetBuilder = new SheetBuilder(SheetType.BGRA); }
public void TestEmptyCells() { NPOI.SS.UserModel.IWorkbook wb = new HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet = new SheetBuilder(wb, testData).SetCreateEmptyCells(true).Build(); NPOI.SS.UserModel.ICell emptyCell = sheet.GetRow(1).GetCell(1); Assert.IsNotNull(emptyCell); Assert.AreEqual(CellType.BLANK, emptyCell.CellType); }
public PlayerBadge LoadBadge(MiniYaml yaml) { if (sheetBuilder == null) { sheetBuilder = new SheetBuilder(SheetType.BGRA, 128); // We must manually force the buffer creation to avoid a crash // that is indirectly triggered by rendering from a Sheet that // has not yet been written to. sheetBuilder.Current.CreateBuffer(); } var labelNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Label"); var icon24Node = yaml.Nodes.FirstOrDefault(n => n.Key == "Icon24"); if (labelNode == null || icon24Node == null) { return(null); } Sprite sprite; lock (syncObject) { if (!spriteCache.TryGetValue(icon24Node.Value.Value, out sprite)) { sprite = spriteCache[icon24Node.Value.Value] = sheetBuilder.Allocate(new Size(24, 24)); Action <DownloadDataCompletedEventArgs> onComplete = i => { if (i.Error != null) { return; } try { var icon = new Bitmap(new MemoryStream(i.Result)); if (icon.Width == 24 && icon.Height == 24) { Game.RunAfterTick(() => { Util.FastCopyIntoSprite(sprite, icon); sprite.Sheet.CommitBufferedData(); }); } } catch { } }; new Download(icon24Node.Value.Value, _ => { }, onComplete); } } return(new PlayerBadge(labelNode.Value.Value, sprite)); }
public void ShouldReturnModuleCodeWhenBuild() { var sheetBuilder = new SheetBuilder(); var workbookBuilder = new WorkbookBuilder(sheetBuilder); var moduleBuilder = new AssemblyCodeBuilder(workbookBuilder); var cSharpModule = moduleBuilder.Build("UnitTest", workbook); Assert.NotNull(cSharpModule); }
/// <summary> /// 设置表格的单元格合并 /// </summary> /// <param name="sheet"></param> /// <param name="merges"></param> public static void SetSheetMerges(this SheetBuilder sheet, List <ExcelHelperMergeModel> merges) { if (merges != null) { foreach (var merge in merges) { sheet.MergeCells(merge.FirstRow, merge.FirstColumn, merge.TotalRows, merge.TotalColumns); } } }
public VoxelLoader(IReadOnlyFileSystem fileSystem) { this.fileSystem = fileSystem; voxels = new Cache <Pair <string, string>, Voxel>(LoadFile); vertices = new List <Vertex[]>(); totalVertexCount = 0; cachedVertexCount = 0; sheetBuilder = CreateSheetBuilder(); }
public void InitializeLoaders() { // all this manipulation of static crap here is nasty and breaks // horribly when you use ModData in unexpected ways. ChromeMetrics.Initialize(Manifest.ChromeMetrics); ChromeProvider.Initialize(Manifest.Chrome); SheetBuilder = new SheetBuilder(SheetType.Indexed); SpriteLoader = new SpriteLoader(new string[] { ".shp" }, SheetBuilder); VoxelLoader = new VoxelLoader(); CursorProvider.Initialize(Manifest.Cursors); }
public MapCache(ModData modData) { this.modData = modData; var gridT = Exts.Lazy(() => modData.Manifest.Get <MapGrid>().Type); previews = new Cache <string, MapPreview>(uid => new MapPreview(modData, uid, gridT.Value, this)); sheetBuilder = new SheetBuilder(SheetT.BGRA); MapLocations = new ReadOnlyDictionary <IReadOnlyPackage, MapClassification>(mapLocations); }
public void Handle(XPathNodeIterator it, SheetBuilder builder) { var beats = it.Current.SelectSingleNode("time/beats"); var beat_type = it.Current.SelectSingleNode("time/beat-type"); var key = it.Current.SelectSingleNode("clef/sign"); var parsedKey = (SheetKey)Enum.Parse(typeof(SheetKey), key.Value); builder.AddKey(parsedKey); builder.AddTimeSignature((uint)beats.ValueAsInt, (uint)beat_type.ValueAsInt); builder.AddTempto(120); }
public void Handle(string token, SheetBuilder builder) { if (token.Contains("|")) { builder.AddBar(currentBar); currentBar.Clear(); } else { var noteBuidler = builder.GetNoteBuilder(); if (token[0] == 'r') { noteBuidler.AddRest(); } else { var pitch = (NotePitch)Enum.Parse(typeof(NotePitch), token[0].ToString().ToUpper()); noteBuidler.AddPitch(pitch); if (token.Contains("is")) { noteBuidler.AddModifier(NoteModifier.Sharp); } else if (token.Contains("es") || token.Contains("as")) { noteBuidler.AddModifier(NoteModifier.Flat); } } int up = token.Count(x => x == '\''); int down = token.Count(x => x == ','); int dots = token.Count(x => x == '.'); var numberMatches = Regex.Match(token, @"(\d+)"); var length = int.Parse(numberMatches.Groups[0].Value); noteBuidler.AddDotts((uint)dots); noteBuidler.AddOctave(4); noteBuidler.AddOctave(up + down); noteBuidler.AddBaseLength((uint)length); currentBar.Add(noteBuidler.Build()); } if (!CanParse(nextToken)) { builder.AddBar(currentBar); currentBar.Clear(); } }
public override void Init(ModData modData, Dictionary <string, string> info) { base.Init(modData, info); // Avoid standard loading mechanisms so we // can display the loadscreen as early as possible r = Game.Renderer; if (r == null) { return; } if (info.ContainsKey("Text")) { messages = info["Text"].Split(','); } if (info.ContainsKey("Palette")) { using (var stream = modData.DefaultFileSystem.Open(info["Palette"])) { palette = new ImmutablePalette(stream, new int[] { }); } hardwarePalette = new HardwarePalette(); hardwarePalette.AddPalette("loadscreen", palette, false); hardwarePalette.Initialize(); r.SetPalette(hardwarePalette); } if (info.ContainsKey("Image")) { using (var stream = modData.DefaultFileSystem.Open(info["Image"])) { CpsD2Loader loader = new CpsD2Loader(); if (!loader.TryParseSprite(stream, out frames)) { return; } } if (frames.Length == 0) { return; } sheetBuilder = new SheetBuilder(SheetType.Indexed, 512); logo = sheetBuilder.Add(frames[0]); logoPos = new float2((r.Resolution.Width - logo.Size.X) / 2, (r.Resolution.Height - logo.Size.Y) / 2); } }
public void InitializeFonts(Manifest m) { using (new Support.PerfTimer("SpriteFonts")) { if (fontSheetBuilder != null) { fontSheetBuilder.Dispose(); } fontSheetBuilder = new SheetBuilder(SheetType.BGRA); Fonts = m.Fonts.ToDictionary(x => x.Key, x => new SpriteFont(Platform.ResolvePath(x.Value.First), x.Value.Second, fontSheetBuilder)).AsReadOnly(); } }
public void ConstructorSinglePadding() { int expected = 25; SheetBuilder builder = new SheetBuilder(expected); Assert.IsNotNull(builder); int horizontalActual = builder.HorizontalPadding; Assert.AreEqual(expected, horizontalActual); int verticalActual = builder.VerticalPadding; Assert.AreEqual(expected, verticalActual); }