private static Dictionary <string, Dictionary <int, SpriteFont> > Fonts = new Dictionary <string, Dictionary <int, SpriteFont> >(); //Ref, size to font static void InitStatic(GraphicsControl control) { if (StaticInitialized) { return; } StaticInitialized = true; //Load effect /*string code = Properties.Resources.horizontalBorderEffect; * CompiledEffect cEffect = * Effect.CompileEffectFromSource(code, null, null, * CompilerOptions.None, TargetPlatform.Windows); * if (!cEffect.Success) * cEffect = cEffect; * * Effect = new Effect(control.GraphicsDevice, cEffect.GetEffectCode(), CompilerOptions.None, null); * //Save effect code * byte[] effectCode = cEffect.GetEffectCode(); * FileStream stream = File.Open("compiledEffect", FileMode.Create); * stream.Write(effectCode, 0, effectCode.Length); * stream.Close(); * stream.Dispose();*/ Effect = new Effect(control.GraphicsDevice, Properties.Resources.compiledEffect, CompilerOptions.None, null); //Load fonts string[] fontRefferences = new[] { @"UI\Fonts\Eurostile-Bol.otf", @"UI\Fonts\Eurostile-Reg.otf", @"UI\Fonts\EurostileExt-Med.otf", @"UI\Fonts\EurostileExt-Reg.otf", @"UI\Fonts\bl.ttf" }; string[] fontNames = new[] { "FontHeader", "FontStandard", "FontHeaderExtended", "FontStandardExtended", "FontInternational" }; int[] fontSizes = new[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 48, 50, 52, 56, 60, 62, 64, 68 }; ContentManager contentManager = new ContentManager(control.Services); for (int i = 0; i < fontRefferences.Length; i++) { FontNames[fontRefferences[i]] = fontNames[i]; Fonts[fontRefferences[i]] = new Dictionary <int, SpriteFont>(); foreach (int fontSize in fontSizes) { string name = fontNames[i] + fontSize; if (File.Exists("Fonts\\" + name + ".xnb")) { Fonts[fontRefferences[i]][fontSize] = contentManager.Load <SpriteFont>("Fonts\\" + name); } } } defaultTexture = new Texture2D(control.GraphicsDevice, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color); defaultTexture.SetData(new[] { new Color(0.5f, 0.5f, 1, 1) }); }
private static Dictionary <string, Dictionary <int, SpriteFont> > Fonts = new Dictionary <string, Dictionary <int, SpriteFont> >(); //Ref, size to font static void InitStatic(GraphicsControl control) { if (StaticInitialized) { return; } StaticInitialized = true; //Load effect /* * string code = Properties.Resources.horizontalBorderEffect; * * CompiledEffect cEffect = * Effect.CompileEffectFromSource(code, null, null, * CompilerOptions.None, TargetPlatform.Windows); * if (!cEffect.Success) * cEffect = cEffect; * * Effect = new Effect(control.GraphicsDevice, cEffect.GetEffectCode(), CompilerOptions.None, null); * //Save effect code * byte[] effectCode = cEffect.GetEffectCode(); * FileStream stream = File.Open("compiledEffect", FileMode.Create); * stream.Write(effectCode, 0, effectCode.Length); * stream.Close(); * stream.Dispose();*/ //Effect = new Effect(control.GraphicsDevice, Properties.Resources.compiledEffect, CompilerOptions.None, null); //byte[] ce = Properties.Resources.compiledEffect; //Effect = new Effect(control.GraphicsDevice, ce); //windywell load effect System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); string code = enc.GetString( util.Util.ReadAllBytes(File.Open("Effects\\Effects_ps3.0.fx", FileMode.Open)) // Properties.Resources.horizontalBorderEffect; ); code = code.Remove(0, 3); EffectProcessor ep = new EffectProcessor(); var effect = ep.Process(new EffectContent { EffectCode = code }, new CatalogContext()); byte[] ec = effect.GetEffectCode(); Effect = new Effect(control.GraphicsDevice, ec); //Load fonts string[] fontRefferences = new[] { @"UI\Fonts\Eurostile-Bol.otf", @"UI\Fonts\Eurostile-Reg.otf", @"UI\Fonts\EurostileExt-Med.otf", @"UI\Fonts\EurostileExt-Reg.otf", @"UI\Fonts\bl.ttf" }; string[] fontNames = new[] { "FontHeader", "FontStandard", "FontHeaderExtended", "FontStandardExtended", "FontInternational" }; int[] fontSizes = new[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 43, 44, 47, 48, 50, 52, 56, 60, 62, 64, 68 }; //{ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 48, 50, 52, 56, 60, 62, 64, 68 }; ContentManager contentManager = new ContentManager(control.Services); for (int i = 0; i < fontRefferences.Length; i++) { FontNames[fontRefferences[i]] = fontNames[i]; Fonts[fontRefferences[i]] = new Dictionary <int, SpriteFont>(); foreach (int fontSize in fontSizes) { string name = fontNames[i] + fontSize; if (File.Exists("Fonts\\" + name + ".xnb")) { Fonts[fontRefferences[i]][fontSize] = contentManager.Load <SpriteFont>("Fonts\\" + name); } } } //defaultTexture = new Texture2D(control.GraphicsDevice, 1, 1, true, TextureUsage.None, SurfaceFormat.Color); defaultTexture = new Texture2D(control.GraphicsDevice, 1, 1, true, SurfaceFormat.Color); defaultTexture.SetData(new[] { new Color(0.5f, 0.5f, 1, 1) }); }
static void InitStatic(GraphicsControl control) { if (StaticInitialized) return; StaticInitialized = true; //Load effect /*string code = Properties.Resources.horizontalBorderEffect; CompiledEffect cEffect = Effect.CompileEffectFromSource(code, null, null, CompilerOptions.None, TargetPlatform.Windows); if (!cEffect.Success) cEffect = cEffect; Effect = new Effect(control.GraphicsDevice, cEffect.GetEffectCode(), CompilerOptions.None, null); //Save effect code byte[] effectCode = cEffect.GetEffectCode(); FileStream stream = File.Open("compiledEffect", FileMode.Create); stream.Write(effectCode, 0, effectCode.Length); stream.Close(); stream.Dispose();*/ Effect = new Effect(control.GraphicsDevice, Properties.Resources.compiledEffect, CompilerOptions.None, null); //Load fonts string[] fontRefferences = new[] { @"UI\Fonts\Eurostile-Bol.otf", @"UI\Fonts\Eurostile-Reg.otf", @"UI\Fonts\EurostileExt-Med.otf", @"UI\Fonts\EurostileExt-Reg.otf", @"UI\Fonts\bl.ttf" }; string[] fontNames = new[] { "FontHeader", "FontStandard", "FontHeaderExtended", "FontStandardExtended", "FontInternational" }; int[] fontSizes = new[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 48, 50, 52, 56, 60, 62, 64, 68 }; ContentManager contentManager = new ContentManager(control.Services); for (int i = 0; i < fontRefferences.Length; i++) { FontNames[fontRefferences[i]] = fontNames[i]; Fonts[fontRefferences[i]] = new Dictionary<int, SpriteFont>(); foreach (int fontSize in fontSizes) { string name = fontNames[i] + fontSize; if (File.Exists("Fonts\\" + name + ".xnb")) Fonts[fontRefferences[i]][fontSize] = contentManager.Load<SpriteFont>("Fonts\\" + name); } } defaultTexture = new Texture2D(control.GraphicsDevice, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color); defaultTexture.SetData(new[] { new Color(0.5f, 0.5f, 1, 1) }); }