private void ReadSprites() { string[] newSprites = config.ReadSection("Sprites", true); foreach (string nSprite in newSprites) { var s = GetKeyValue(nSprite, "="); IRenderSprite sprite = renderer.CreateSprite(s.Key); IseSprite iseSprite; if (usePlaceHolders) { iseSprite = new IseText(sprite, globalFontCorrection); } else { switch (s.Value.ToLower()) { case "text": iseSprite = new IseText(sprite, globalFontCorrection); break; default: iseSprite = new IseSprite(sprite); break; } } Sprites.Add(s.Key, iseSprite); } }
private void ReadSpriteValuesFromSection(string section, IseSprite iseSprite) { if (config.HasSection(section)) { Trace.TraceInformation($"reading sprite data from section [{section}]"); if (readVector3(config, section, "Position", out Vector3 vPos)) { iseSprite.Position = vPos; } if (readVector3(config, section, "Center", out Vector3 vCenter)) { iseSprite.Sprite.CenterPoint = vCenter; } if (readFloat(config, section, "Alpha", out float vAlpha)) { iseSprite.Sprite.Alpha = vAlpha; } if (readBool(config, section, "Visible", out bool vVisible)) { iseSprite.Sprite.Visible = vVisible; } if (readVector3(config, section, "MaxSize", out Vector3 vSize)) { iseSprite.MaxSize = vSize; } if (ReadEnum(config, section, "Alignment", out BoxAlignment aMode)) { iseSprite.Alignment = aMode; } if (usePlaceHolders) { iseSprite.Sprite.Tint = iseSprite.TagColor; iseSprite.Text = section; iseSprite.AspectCorrection = ResizeMode.None; } else { if (readARGB(config, section, "Tint", out ARGB vTint)) { iseSprite.Sprite.Tint = vTint; } if (ReadEnum(config, section, "AspectCorrection", out ResizeMode rMode)) { iseSprite.AspectCorrection = rMode; } if (iseSprite is IseText) { var iText = (iseSprite as IseText); if (readFloat(config, section, "FontSize", out float fSize)) { iText.FontSize = fSize; } if (readString(config, section, "FontName", out string vFontName)) { iText.RenderText.FontName = vFontName; } if (readString(config, section, "Text", out string vText)) { iText.Text = vText; } if (readARGB(config, section, "TextFColor", out ARGB vTFColor)) { iText.RenderText.ForeColor = vTFColor; } if (readARGB(config, section, "TextBColor", out ARGB vTBColor)) { iText.RenderText.BackColor = vTBColor; } } else { string imageFileName = config.ReadString(section, "Image", string.Empty); if (!string.IsNullOrEmpty(imageFileName)) { iseSprite.LoadImage(Path.Combine(assetDirectory, imageFileName)); } } } } }