// Constructor internal TextFont() { Configuration cfg; Stream fontdata; StreamReader fontreader; string[] resnames; // Initialize characters = new FontCharacter[256]; // Make chars configuration cfg = new Configuration(); // Find a resource named Font.cfg resnames = General.ThisAssembly.GetManifestResourceNames(); foreach (string rn in resnames) { // Found it? if (rn.EndsWith(FONT_RESOURCE, StringComparison.InvariantCultureIgnoreCase)) { // Get a stream from the resource fontdata = General.ThisAssembly.GetManifestResourceStream(rn); fontreader = new StreamReader(fontdata, Encoding.ASCII); // Load configuration from stream cfg.InputConfiguration(fontreader.ReadToEnd()); // Done fontreader.Dispose(); fontdata.Dispose(); break; } } // Get the charset from configuration IDictionary cfgchars = cfg.ReadSetting("chars", new Hashtable()); // Go for all defined chars foreach (DictionaryEntry item in cfgchars) { // Get the character Hashtable IDictionary chr = (IDictionary)item.Value; int i = Convert.ToInt32(item.Key); // This is ancient code of mine. // The charater sizes were based on 800x600 resolution. characters[i].width = (float)(int)chr["width"] / 40f; characters[i].height = (float)(int)chr["height"] / 30f; characters[i].u1 = (float)chr["u1"]; characters[i].v1 = (float)chr["v1"]; characters[i].u2 = (float)chr["u2"]; characters[i].v2 = (float)chr["v2"]; } // We have no destructor GC.SuppressFinalize(this); }
// This saves colors to configuration internal void SaveColors(Configuration cfg) { // Write all colors to config for (int i = 0; i < colorscount; i++) { // Write color cfg.WriteSetting("colors.color" + i.ToString(CultureInfo.InvariantCulture), colors[i].ToInt()); } }
// Constructor for settings from configuration internal ColorCollection(Configuration cfg) { // Initialize colorscount = Enum.GetValues(typeof(EditorColor)).Length; thingcolorsoffset = colorscount - SpriteColorsCount; colors = new PixelColor[colorscount]; brightcolors = new PixelColor[colorscount]; darkcolors = new PixelColor[colorscount]; // Read all colors from config for (int i = 0; i < colorscount; i++) { // Read color colors[i] = PixelColor.FromInt(cfg.ReadSetting("colors.color" + i.ToString(CultureInfo.InvariantCulture), 0)); } // Set new colors if (colors[(int)EditorColor.SPRITECOLOR00].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR00] = PixelColor.FromColor(Color.DimGray); } if (colors[(int)EditorColor.SPRITECOLOR01].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR01] = PixelColor.FromColor(Color.RoyalBlue); } if (colors[(int)EditorColor.SPRITECOLOR02].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR02] = PixelColor.FromColor(Color.ForestGreen); } if (colors[(int)EditorColor.SPRITECOLOR03].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR03] = PixelColor.FromColor(Color.LightSeaGreen); } if (colors[(int)EditorColor.SPRITECOLOR04].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR04] = PixelColor.FromColor(Color.Firebrick); } if (colors[(int)EditorColor.SPRITECOLOR05].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR05] = PixelColor.FromColor(Color.DarkViolet); } if (colors[(int)EditorColor.SPRITECOLOR06].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR06] = PixelColor.FromColor(Color.DarkGoldenrod); } if (colors[(int)EditorColor.SPRITECOLOR07].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR07] = PixelColor.FromColor(Color.Silver); } if (colors[(int)EditorColor.SPRITECOLOR08].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR08] = PixelColor.FromColor(Color.Gray); } if (colors[(int)EditorColor.SPRITECOLOR09].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR09] = PixelColor.FromColor(Color.DeepSkyBlue); } if (colors[(int)EditorColor.SPRITECOLOR10].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR10] = PixelColor.FromColor(Color.LimeGreen); } if (colors[(int)EditorColor.SPRITECOLOR11].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR11] = PixelColor.FromColor(Color.PaleTurquoise); } if (colors[(int)EditorColor.SPRITECOLOR12].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR12] = PixelColor.FromColor(Color.Tomato); } if (colors[(int)EditorColor.SPRITECOLOR13].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR13] = PixelColor.FromColor(Color.Violet); } if (colors[(int)EditorColor.SPRITECOLOR14].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR14] = PixelColor.FromColor(Color.Yellow); } if (colors[(int)EditorColor.SPRITECOLOR15].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR15] = PixelColor.FromColor(Color.WhiteSmoke); } if (colors[(int)EditorColor.SPRITECOLOR16].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR16] = PixelColor.FromColor(Color.LightPink); } if (colors[(int)EditorColor.SPRITECOLOR17].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR17] = PixelColor.FromColor(Color.DarkOrange); } if (colors[(int)EditorColor.SPRITECOLOR18].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR18] = PixelColor.FromColor(Color.DarkKhaki); } if (colors[(int)EditorColor.SPRITECOLOR19].ToInt() == 0) { colors[(int)EditorColor.SPRITECOLOR19] = PixelColor.FromColor(Color.Goldenrod); } // Create assist colors CreateAssistColors(); // Create color correction table CreateCorrectionTable(); }