public void Draw(FontRenderer fontRenderer, int x, int y) { var uiRect = new Rectangle(x, y, Width, Height); fontRenderer.Scene.DrawUI(Sprite, uiRect, Color.White); Text.Draw(new Vector2(x + 4, y), fontRenderer); }
public void renderWindow(BufferedDisplayDriver display, IconRenderer ir, FontRenderer fr) { for (int i = 0; i <= width; i++) { for (int i2 = 0; i2 <= height; i2++) { display.setPixel(i + x, i2 + y, 63); } } for (int i = 0; i <= width; i++) { display.setPixel(i + x, y, 0); display.setPixel(i + x, y + 20, 0); display.setPixel(i + x, y + height, 0); } for (int i = 0; i <= height; i++) { display.setPixel(x, y + i, 0); display.setPixel(x + width, y + i, 0); } ir.renderIcon(x + width - 20, y, 'X', 2); ir.renderIcon(x + width - 40, y, 'M', 2); ir.renderIcon(x + width - 60, y, '_', 2); fr.renderString(x + 10, y + 12, "WINDOW"); }
private void Init() { //TODO - just a test - WORKS! //_installedMods.Add(new TestMod()); GlSetup(); _itemRegistry = new ItemRegistry(); _blockRegistry = new BlockRegistry(); _recipeRegistry = new RecipeRegistry(); LoadMods(); GameRegistry(); WorldRenderer = new WorldRenderer(); EntityRenderer = new EntityRenderer(); GuiRenderer = new GuiRenderer(); FontRenderer = new FontRenderer(); SettingsManager.Load(); //load settings Camera.SetTargetFov(SettingsManager.GetFloat("fov")); _sensitivity = SettingsManager.GetFloat("sensitivity"); WorldRenderer.RenderDistance = SettingsManager.GetInt("renderdistance"); OpenGuiScreen(new GuiScreenMainMenu()); }
internal override void LoadContent() { World = new World(); _locationSign = new LocationSign(); _locationSign.LoadContent(); World.MapChanged += MapChanged; World.WildPokemonEncountered += OnWildEncounter; World.TextDisplayed += (text) => ShowTextbox(text, false); Textbox = new Textbox(); Textbox.LoadContent(); StartMenu = new StartMenu(this); StartMenu.LoadContent(); World.LoadContent(); World.ChangeMap(Controller.ActivePlayer.Map); World.PlayerEntity.Position = Controller.ActivePlayer.Position + World.ActiveMap.Offset; _shader = new WorldShader(this); ((BasicEffect)_shader.Effect).LightingEnabled = false; _camera = new WorldCamera(World, World.PlayerEntity); //_camera = new TestCamera(); //_camera.Position = World.PlayerEntity.Position + new Vector3(0, 2, 0); _batch = new SpriteBatch(Controller.GraphicsDevice); _fontRenderer = new FontRenderer("main"); }
public Graphics(RenderForm form, int width, int height) { reset = () => form.Invoke(new Action(() => { device.Reset(presentParameters); fontRenderer.Flush(); textureRenderer.Flush(); resized = false; })); form.UserResized += (sender, args) => Resize(form.ClientSize.Width, form.ClientSize.Height); presentParameters = new PresentParameters { Windowed = true, SwapEffect = SwapEffect.Discard, BackBufferFormat = Format.A8R8G8B8, BackBufferCount = 1, BackBufferWidth = width, BackBufferHeight = height, PresentationInterval = PresentInterval.One, MultiSampleType = MultisampleType.None, MultiSampleQuality = 0, PresentFlags = PresentFlags.LockableBackBuffer }; direct3D = new Direct3DEx(); device = new DeviceEx(direct3D, 0, DeviceType.Hardware, form.Handle, CREATE_FLAGS, presentParameters); fontRenderer = new FontRenderer(device); textureRenderer = new TextureRenderer(device); renderLocker.Reset(); }
public TimingPoints() : base(800, 600, new OpenTK.Graphics.GraphicsMode(32, 8, 0, 8), "Timing Setup Panel") { Instance = this; OpenGuiScreen(new GuiScreenTimings()); Icon = Resources.icon; FontRenderer = new FontRenderer("main"); }
/** * Record the vertex, uv, and color information for a single character. */ private bool DrawChar(FontRenderer fr, char letter, float xPos, float yPos, Color letterColor, Script scriptType, Width fontWidth) { if (fontCharacters.ContainsKey(letter)) { Rect pos = new Rect(screenXOffset + xPos, screenYOffset - ((scriptType == Script.Superscript) ? yPos - fontLetterHalfHeight : yPos), (fontWidth == Width.Normal ? fontLetterWidth : (fontWidth == Width.Half ? fontLetterHalfWidth : fontLetterDoubleWidth)), (scriptType != Script.Normal) ? fontLetterHalfHeight : fontLetterHeight); fr.vertices.Add(new Vector3(pos.xMin, pos.yMin, 0.0f)); fr.vertices.Add(new Vector3(pos.xMax, pos.yMin, 0.0f)); fr.vertices.Add(new Vector3(pos.xMin, pos.yMax, 0.0f)); fr.vertices.Add(new Vector3(pos.xMax, pos.yMax, 0.0f)); Rect uv = fontCharacters[letter]; fr.uvs.Add(new Vector2(uv.xMin, uv.yMin)); fr.uvs.Add(new Vector2(uv.xMax, uv.yMin)); fr.uvs.Add(new Vector2(uv.xMin, uv.yMax)); fr.uvs.Add(new Vector2(uv.xMax, uv.yMax)); fr.colors.Add(letterColor); } else if (!characterWarnings.Contains(letter)) { JUtil.LogMessage(this, "Warning: Attempted to print a character \"{0}\" (u{1}) not present in the font.", letter.ToString(), letter); characterWarnings.Add(letter); return(false); } return(true); }
internal override void Draw(Microsoft.Xna.Framework.GameTime gameTime) { base.Draw(gameTime); MainGame.DefaultFont.Spacing = 0.8f; if (curTexture != null) { float unscaledOffset = (MainGame.OriginalAppHeight - curTexture.Height) / 2; int yPos = MainGame.ScaledOffsetY + (int)(unscaledOffset * MainGame.ScaleY); // Centered Position if (useVoiceOver == false) { yPos = 5; } Rectangle rect = new Rectangle(MainGame.ScaledOffsetX, yPos, (int)(curTexture.Width * MainGame.ScaleX), (int)(curTexture.Height * MainGame.ScaleY)); MainGame.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone); MainGame.SpriteBatch.Draw(curTexture, rect, Color.FromNonPremultiplied(new Vector4(Vector3.One, storyboard.CurrentAlpha))); MainGame.SpriteBatch.End(); if (useVoiceOver == false) { int yStart = 147; string introText = storyboard.GetCurrentIntroText(); FontRenderer.DrawStringDirect(MainGame.DefaultFont, introText, 0, yStart, MainGame.OriginalAppWidth, MainGame.OriginalAppHeight - yStart, Color.White); } } }
public static void DrawText(this SpriteBatch batch, FontRenderer fontRenderer, string text, Vector2 position, Color color) { var size = fontRenderer.MeasureText(text); var borders = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y); DrawText(batch, fontRenderer, text, borders, color); }
protected override void OnLoad() { base.OnLoad(); _frameTimeText = "Frame Time: "; _fontRenderer = new FontRenderer(ClientSize.X, ClientSize.Y); _shader = Shader.Load("Color", 2, "Assets/Shaders/color.vert", "Assets/Shaders/color.frag"); _shader.Use(); _shader.SetupUniforms(new string[] { "model", "viewproj", "color" }); _projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45.0f), (float)ClientSize.X / (float)ClientSize.Y, 0.1f, 1000.0f); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); debugDraw = new DebugDraw(); _plane = new Plane(10, 10, 2.0f); _plane.Load(); _camera = new OrbitCamera(new Vector3(0.0f, 20.0f, 0.0f), new Vector3(5.0f, 0.0f, 5.0f)); }
public override void Render() { Vector2 pos = ScaleVec2(0.22f, 0.01f); DrawShadow(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, 155, 24)); FontRenderer.Render(Fonts.White, "CP", pos, Color.White); pos.X += 25f; FontRenderer.Render(Fonts.White, String.Format("{0}/{1}", Race.Current.NextCheckpoint, Race.Current.ConfigFile.Checkpoints.Count), pos, Color.White); pos.X += 45f; FontRenderer.Render(Fonts.White, "LAP", pos, Color.White); pos.X += 35f; FontRenderer.Render(Fonts.White, String.Format("{0}/{1}", Race.Current.CurrentLap, Race.Current.ConfigFile.LapCount), pos, Color.White); pos = ScaleVec2(0.22f, 0.054f); DrawShadow(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, 155, 24)); FontRenderer.Render(Fonts.White, "WASTED", pos, Color.White); pos.X += 65f; FontRenderer.Render(Fonts.White, Race.Current.NbrDeadOpponents + "/" + Race.Current.NbrOpponents, pos, Color.White); pos.X += 240; DrawShadow(new Rectangle((int)pos.X - 5, (int)pos.Y - 5, 140, 24)); FontRenderer.Render(Fonts.White, Race.Current.NbrDeadPeds + "/" + Race.Current.Peds.Count, pos, Color.White); pos.X += 80; FontRenderer.Render(Fonts.White, "KILLS", pos, Color.White); }
public void LoadContent(ContentManager cm) { //Start by loading all textures //playerTexture = cm.Load<Texture2D>("player.png"); // fontTexture = cm.Load<Texture2D>("basicFont.png"); thirstTexture = cm.Load <Texture2D>("waterBottle.png"); hungerTexture = cm.Load <Texture2D>("apple.png"); string fontFilePath = Path.Combine(cm.RootDirectory, "Fonts/font.fnt"); fontFile = FontLoader.Load(fontFilePath); fontTexture = cm.Load <Texture2D>("Fonts/font_0.png"); fontRenderer = new FontRenderer(fontFile, fontTexture); sizingRectangle = new Rectangle(0, 0, 211, 40); displays = new List <Display>(); //addDisplay(0, 0, //testing //displays.Add(new Display(0, 0, "12S red")); //Then assign textures to NPCs depending on their tag // thePlayer.sprite = playerTexture; }
public void drawDesktop(IconRenderer ir, FontRenderer dfr) { ir.renderIcon(5, 20, 'C', 4); dfr.renderString(10, 65, "MY PC"); ir.renderIcon(65, 20, 'N', 4); dfr.renderString(62, 65, "NOTEPAD"); }
public UIScreen(Game g) { game = g; sceneManager = g.SceneManager; fontRenderer = new FontRenderer(g.ClientSize.X, g.ClientSize.Y); world = new EcsWorld(); systems = new EcsSystems(world); }
public HUDModule(TrueCraftGame game, FontRenderer font) { Game = game; Font = font; SpriteBatch = new SpriteBatch(game.GraphicsDevice); GUI = game.TextureMapper.GetTexture("gui/gui.png"); Icons = game.TextureMapper.GetTexture("gui/icons.png"); Items = game.TextureMapper.GetTexture("gui/items.png"); }
public TextBoxHelper(FontRenderer fontRenderer) { this.fontRenderer = fontRenderer; Text = ""; PasswordString = ""; CursorTimer = new Stopwatch(); CursorTimer.Start(); }
public DebugInfoModule(TrueCraftGame game, FontRenderer font) { Game = game; Font = font; SpriteBatch = new SpriteBatch(Game.GraphicsDevice); #if DEBUG Enabled = true; #endif }
public WindowModule(TrueCraftGame game, FontRenderer font) { Game = game; Font = font; SpriteBatch = new SpriteBatch(game.GraphicsDevice); Inventory = game.TextureMapper.GetTexture("gui/inventory.png"); Crafting = game.TextureMapper.GetTexture("gui/crafting.png"); Items = game.TextureMapper.GetTexture("gui/items.png"); SelectedSlot = -1; HeldItem = ItemStack.EmptyStack; }
public override void Render() { Rectangle rect = CenterRectX(0, 0.182f, 0.087f); DrawShadow(rect); TimeSpan ts = TimeSpan.FromSeconds(Race.Current.RaceTime.TimeRemaining); float nudge = ts.Minutes < 10 ? 13 * FontScale : 0; FontRenderer.Render(Fonts.Timer, String.Format("{0}/{1}", (int)ts.Minutes, ts.Seconds.ToString("00")), new Vector2(rect.X + 5 + nudge, rect.Y + 7), Color.White, FontScale); }
protected override void Draw() { base.Draw(); Vector2 screenPos = ScreenPosition; Color col = Color.FromNonPremultiplied(new Vector4(Vector3.One, CompositeAlpha)); Vector2 fullSize = (Font != null ? (Vector2)Font.MeasureString(Text) : Vector2.Zero); float textScale = 1.0f; if (AutoScaleFont) { textScale = this.Width / fullSize.X; } fullSize *= textScale; Vector2 position = new Vector2(0, screenPos.Y - 3); switch (TextAlignHorizontal) { case UITextAlignHorizontal.Center: position.X = screenPos.X + (Width / 2.0f - fullSize.X / 2.0f); break; case UITextAlignHorizontal.Left: position.X = screenPos.X; break; case UITextAlignHorizontal.Right: position.X = screenPos.X + (Width - fullSize.X); break; } switch (TextAlignVertical) { case UITextAlignVertical.Top: position.Y = screenPos.Y; break; case UITextAlignVertical.Center: position.Y = screenPos.Y + (Height / 2.0f - fullSize.Y / 2.0f); break; case UITextAlignVertical.Bottom: position.Y = screenPos.Y + Height - fullSize.Y; break; } FontRenderer.DrawStringDirect(renderConfig, Font, Text, position.X, position.Y, col, textScale, CompositeRotation); // }
public static void Initialize() { BasicTextureShader = Game.GraphicsDevice.CreateShaderFromInternal("DefaultVertexShader.glsl", "DefaultTextureShader.glsl"); BasicColorShader = Game.GraphicsDevice.CreateShaderFromInternal("DefaultVertexShader.glsl", "DefaultColorShader.glsl"); SimpleFloodLightShader = Game.GraphicsDevice.CreateShaderFromInternal("SimpleFloodLightVertex.glsl", "SimpleFloodLightFragment.glsl"); ParticleShader = Game.GraphicsDevice.CreateShaderFromInternal("ParticleVertexShader.glsl", "DefaultTextureShader.glsl"); LightPassTextureShader = Game.GraphicsDevice.CreateShaderFromInternal("DefaultVertexShader.glsl", "DefaultTextureShaderLightPass.glsl"); ImageBatch.Initialize(); ShapeBatch.Initialize(); LineBatch.Initialize(); FontRenderer = new FontRenderer(); }
public WindowManager(DisplayDriver dd, Desktop desk, FontRenderer fr) { display = dd; desktop = desk; fontRenderer = fr; sX = 10; sY = 10; eX = display.getWidth() - 10; eY = display.getHeight() - 10; backGroundWindows = new Window[0]; }
public void Render(float partialStep) { t.ResetTransformation(); string cursorText = "+"; FontRenderer f = FontRenderer.Instance; t.StartDrawingAlphaTexturedQuads("ascii"); Vector2 textSize = f.TextSize(cursorText); Vector2 Location = Input.Instance.InterpolatedMouseLocation(partialStep); f.RenderTextShadow(cursorText, Location.X - textSize.X / 2f, Location.Y - textSize.Y / 2f); t.Draw(); }
public ChatModule(TrueCraftGame game, FontRenderer font) { Game = game; Font = font; Messages = new List <Message>(); Background = new Texture2D(Game.GraphicsDevice, 1, 1); Background.SetData <Color>(new[] { new Color(Color.Black, 160) }); SpriteBatch = new SpriteBatch(Game.GraphicsDevice); Watch = new Stopwatch(); Watch.Start(); Text = string.Empty; Game.Client.ChatMessage += (sender, e) => AddMessage(e.Message); }
public ChatInterface(MultiplayerClient client, KeyboardComponent keyboard, FontRenderer font) { Client = client; Keyboard = keyboard; Font = font; Input = string.Empty; Messages = new List <ChatMessage>(); DummyTexture = new Texture2D(keyboard.Game.GraphicsDevice, 1, 1); DummyTexture.SetData(new[] { Color.White }); Client.ChatMessage += OnChatMessage; Keyboard.KeyDown += OnKeyDown; }
internal Component() { UpdateTexturePositionOnce = false; fontRenderer = new FontRenderer(); ResizeComponentSizeToTextSize = false; TotalInvisibleLettersLength = 0; DisableVerticalAlighment = false; rasterizerState = new RasterizerState() { ScissorTestEnable = true }; }
protected override void BeforeRun() { Console.WriteLine("Cosmos booted sucessfully, now starting Kernel"); display = new BufferedDisplayDriver(); display.init(); f = new BasicFont(); fr = new FontRenderer(display, f, 0); second = time.Second(); keyboard = new KeyboardDriver(); // mouse = new MouseDriver(display.getHeight(), display.getWidth()); // mr = new MouseRenderer(mouse, display, 63); }
public override void LoadContent(GraphicsDevice gd, ContentManager cm) { //Initialization for basicEffect basicEffect = new BasicEffect(gd); basicEffect.VertexColorEnabled = true; basicEffect.LightingEnabled = false; spriteBatch = new SpriteBatch(gd); string fontFilePath = Path.Combine(cm.RootDirectory, "Fonts/font.fnt"); fontFile = FontLoader.Load(fontFilePath); fontTexture = cm.Load <Texture2D>("Fonts/font_0.png"); fontRenderer = new FontRenderer(fontFile, fontTexture); logo = cm.Load <Texture2D>("LOGO.png"); bgTexture = cm.Load <Texture2D>("bg.png"); }
static async Task MainAsync(string[] args) { using (var output = File.OpenWrite("../../../../mona.gen.png")) { Bitmap bitmap = Bitmap.FromFile("../../../../mona.png"); int scale = Tx.GetPerfectPixelRatios(bitmap).OrderBy(val => val).ElementAt(0); ITextGenerator textGenerator = new BrightnessBasedGenerator( characters: Tx.CharacterSets.Basic, pixelSamplingRatio: scale ); ITextData textData = await textGenerator.GenerateTextAsync(bitmap); Font font = Font.FromTypeface(Typeface.FromName("Consolas")); ITextRenderer textRenderer = new FontRenderer(font); await textRenderer.RenderAsync(textData, output); } }
public override void Render() { GameEngine.SpriteBatch.Draw(_speedoTexture, ScaleRect(x, y, 0.145f, 0.16f), Color.White); DrawShadow(ScaleRect(x + 0.06f, y + 0.112f, 0.03f, 0.057f)); FontRenderer.RenderGear(_chassis.Motor.Gearbox.CurrentGear + 1, ScaleVec2(x + 0.065f, y + 0.118f), Color.White, FontScale * 2); DrawShadow(ScaleRect(x + 0.1f, y + 0.112f, 0.068f, 0.057f)); FontRenderer.Render(Fonts.Speedo, ((int)_chassis.Speed).ToString("000"), ScaleVec2(x + 0.102f, y + 0.118f), Color.White, FontScale); float rpmFactor = _chassis.Motor.Rpm / _chassis.Motor.RedlineRpm; float rotation = (float)(rpmFactor * 4f) + 0.5f; GameEngine.SpriteBatch.Draw(_speedoLineTexture, ScaleVec2(x + 0.07f, y + 0.09f), null, Color.White, rotation, Vector2.Zero, ScaleVec2(0.0037f, 0.075f), SpriteEffects.None, 0); }
public void start(ref ContentManager Content) { string[] names = { "GameBackground", "GrassPixel", "credit", "HowToPlay", "FINAL_MENU", "FINAL_MENU2", "skull", "floor", "square", "fillOval", "oval", "Pandas","FinalScorePink", "FinalScoreGreen", "FinalScoreBlue", "FinalScoreWhite","FinalScoreDraw"}; // load textures foreach(string n in names){ textures.Add(n,Content.Load<Texture2D>(n)); } bg = Game1.random.Next(2) == 0 ? textures["FINAL_MENU"].Name : textures["FINAL_MENU2"].Name; drawBackground.Add("background", () => Game1.batch.Draw(textures[bg], screen, Color.White)); drawBackground.Add("credit", () => Game1.batch.Draw(textures["credit"], screen, Color.White)); drawBackground.Add("how", () => Game1.batch.Draw(textures["HowToPlay"], screen, Color.White)); // the fontRenderer enables the drawing of text in monogame var fontFilePath = Path.Combine(Content.RootDirectory, "Arial.fnt"); var fontFile = FontLoader.Load(fontFilePath); var fontTexture = Content.Load<Texture2D>("Arial_0.png"); fontRenderer = new FontRenderer(fontFile, fontTexture); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); System.IO.StreamReader reader = new System.IO.StreamReader("font1.txt"); text = reader.ReadToEnd(); fonts = new Font[] { new Font(18, FontStyle.Regular, "1_Disney.ttf"), //new Font("����", 24, FontStyle.Regular), new Font("����", 32), new Font("���ź�", 18), new Font("���IJ���", 24), new Font("����", 18), }; renderer = new FontRenderer(GraphicsDevice); // TODO: use this.Content to load your game content here }
public void Run(Machine m) { machine = m; machine.Host = this; try { VisiblePitch = machine.VisiblePitch; ClipStart = machine.FirstScanline; LeftOffset = 0; FrameBuffer = new uint[VisiblePitch * machine.Scanlines]; FontRenderer = new FontRenderer(FrameBuffer, VisiblePitch, machine.Palette, 0); EffectiveFPS = machine.FrameHZ + EMU7800App.Instance.Settings.FrameRateAdjust; if (Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO | Sdl.SDL_INIT_AUDIO | Sdl.SDL_INIT_JOYSTICK) < 0) { throw new MariaCoreException("Couldn't initialize SDL: " + Sdl.SDL_GetError()); } int flags = Sdl.SDL_HWSURFACE; if (FULLSCREEN) flags |= Sdl.SDL_FULLSCREEN; if (IntPtr.Zero == Sdl.SDL_SetVideoMode(WIDTH, HEIGHT, 32, flags)) { throw new MariaCoreException("Couldn't set video mode: " + Sdl.SDL_GetError()); } Sdl.SDL_WM_SetCaption("Maria", "Maria"); // TODO : unhardcode ? Sdl.SDL_ShowCursor(FULLSCREEN ? Sdl.SDL_DISABLE : Sdl.SDL_ENABLE); // TODO : SdlNativeMethods.Open does some more shit...: //OpenJoystickDevice(0); //OpenJoystickDevice(1); FillRect(0, 0, 0, 0); // TODO : need to initialize sound somehow... /*SoundSampleRate = M.SoundSampleRate * EffectiveFPS / M.FrameHZ; WinmmNativeMethods.Open( SoundSampleRate, M.Scanlines << 1, EMU7800App.Instance.Settings.NumSoundBuffers );*/ Run(); } finally { // TODO : also clean up sound, joystick, whatnot. Sdl.SDL_Quit(); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here textureBuffer = new Texture2D(GraphicsDevice, emu.Video.width, emu.Video.height); palette = new Color[emu.Video.palette.Length]; for (int i = 0; i < palette.Length; i++) { palette[i].A = 0xff; palette[i].R = emu.Video.palette[i].R; palette[i].G = emu.Video.palette[i].G; palette[i].B = emu.Video.palette[i].B; } Rectangle rect = new Rectangle(0, 0, emu.Video.width, emu.Video.height); colorBuffer = new Color[rect.Width * rect.Height]; //textureBuffer.GetData<Color>(0, rect, colorBuffer, 0, colorBuffer.Length); var fontFilePath = System.IO.Path.Combine(Content.RootDirectory, "arial_bitmapfont.fnt"); var fontFile = FontLoader.Load(fontFilePath); var fontTexture = Content.Load<Texture2D>("arial_bitmapfont_0.png"); font = new FontRenderer(fontFile, fontTexture); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); #region Sprite Loading //_hiAt is attack square _hiAt = this.Content.Load<Texture2D>("HIatt"); //Player & enemy square _hi = this.Content.Load<Texture2D>("HI"); //Font renderer stuff, (fontFile, fontTexture) _fontRenderer = new FontRenderer(FontHandler.FontLoader.Load(Path.Combine(this.Content.RootDirectory, "text.xml")), this.Content.Load<Texture2D>("text_0")); //Temporarily loaded weed/MLG sprites var weed = this.Content.Load<Texture2D>("Weed"); var gun = this.Content.Load<Texture2D>("gun"); var dor = this.Content.Load<Texture2D>("doritos"); var mtn = this.Content.Load<Texture2D>("mtn"); var hit = this.Content.Load<Texture2D>("hit"); //Pass weed joke sprites to Weed class's sprite loader Weed.Sprites(weed, gun, dor, mtn, hit); #endregion // TODO: use this.Content to load your game content here }
/** * Record the vertex, uv, and color information for a single character. */ private void DrawChar(FontRenderer fr, char letter, float xPos, float yPos, Color letterColor, Script scriptType, Width fontWidth) { if (fontCharacters.ContainsKey(letter)) { Rect pos = new Rect(screenXOffset + xPos, screenYOffset - ((scriptType == Script.Superscript) ? yPos - fontLetterHalfHeight : yPos), (fontWidth == Width.Normal ? fontLetterWidth : (fontWidth == Width.Half ? fontLetterHalfWidth : fontLetterDoubleWidth)), (scriptType != Script.Normal) ? fontLetterHalfHeight : fontLetterHeight); fr.vertices.Add(new Vector3(pos.xMin, pos.yMin, 0.0f)); fr.vertices.Add(new Vector3(pos.xMax, pos.yMin, 0.0f)); fr.vertices.Add(new Vector3(pos.xMin, pos.yMax, 0.0f)); fr.vertices.Add(new Vector3(pos.xMax, pos.yMax, 0.0f)); Rect uv = fontCharacters[letter]; fr.uvs.Add(new Vector2(uv.xMin, uv.yMin)); fr.uvs.Add(new Vector2(uv.xMax, uv.yMin)); fr.uvs.Add(new Vector2(uv.xMin, uv.yMax)); fr.uvs.Add(new Vector2(uv.xMax, uv.yMax)); fr.colors.Add(letterColor); } else if (!characterWarnings.Contains(letter)) { JUtil.LogMessage(this, "Warning: Attempted to print a character \"{0}\" (u{1}) not present in the font.", letter.ToString(), letter); characterWarnings.Add(letter); } }
private void RefreshPreview(object objectParam) { var refreshPreviewParams = objectParam as FontRendererParams; var tableRenderer = new FontRenderer (refreshPreviewParams); string preview = tableRenderer.Render (); // Do this on the main thread! Gtk.Application.Invoke (delegate { previewimage.File = preview; labelWidth.LabelProp = previewimage.Pixbuf.Width.ToString (); labelHeight.LabelProp = previewimage.Pixbuf.Height.ToString (); labelCellSize.LabelProp = tableRenderer.CellSize.ToString (); outputframe.Sensitive = true; generatebutton.Sensitive = true; this.GdkWindow.Cursor = new Gdk.Cursor (Gdk.CursorType.Arrow); } ); }
/** * TextRenderer (constructor) * * Set up the TextRenderer object, and take care of the pre-computations needed. */ public TextRenderer(List<Texture2D> fontTexture, Vector2 fontLetterSize, string fontDefinitionString, int drawingLayer, int screenWidth, int screenHeight) { if (fontTexture.Count == 0) { throw new Exception("No font textures found"); } screenPixelWidth = screenWidth; screenPixelHeight = screenHeight; screenXOffset = (float)screenPixelWidth * -0.5f; screenYOffset = (float)screenPixelHeight * 0.5f - fontLetterSize.y; float fontLettersX = Mathf.Floor(fontTexture[0].width / fontLetterSize.x); float fontLettersY = Mathf.Floor(fontTexture[0].height / fontLetterSize.y); float pixelOffsetX = 0.5f / (float)fontTexture[0].width; float pixelOffsetY = 0.5f / (float)fontTexture[0].height; float letterSpanX = 1.0f / fontLettersX; float letterSpanY = 1.0f / fontLettersY; int lastCharacter = (int)fontLettersX * (int)fontLettersY; if (lastCharacter != fontDefinitionString.Length) { JUtil.LogMessage(this, "Warning, number of letters in the font definition does not match font bitmap size."); } // Precompute texture coordinates for all of the supported characters for (int i = 0; i < lastCharacter && i < fontDefinitionString.Length; i++) { int xSource = i % (int)fontLettersX; int ySource = (i - xSource) / (int)fontLettersX; if (!fontCharacters.ContainsKey(fontDefinitionString[i])) { fontCharacters[fontDefinitionString[i]] = new Rect(letterSpanX * (float)xSource + pixelOffsetX, letterSpanY * (fontLettersY - (float)ySource - 1.0f) + pixelOffsetY, letterSpanX, letterSpanY); } } fontLetterWidth = fontLetterSize.x; fontLetterHeight = fontLetterSize.y; fontLetterHalfHeight = fontLetterSize.y * 0.5f; fontLetterHalfWidth = fontLetterSize.x * 0.5f; fontLetterDoubleWidth = fontLetterSize.x * 2.0f; // Set up the camera cameraBody = new GameObject(); cameraBody.name = "RPMTextRender" + cameraBody.GetInstanceID(); cameraBody.layer = drawingLayer; textCamera = cameraBody.AddComponent<Camera>(); textCamera.enabled = false; textCamera.orthographic = true; textCamera.aspect = (float)screenWidth / (float)screenHeight; textCamera.eventMask = 0; textCamera.farClipPlane = 3f; textCamera.orthographicSize = (float)(screenHeight) * 0.5f; textCamera.cullingMask = 1 << drawingLayer; textCamera.clearFlags = CameraClearFlags.Nothing; textCamera.transparencySortMode = TransparencySortMode.Orthographic; textCamera.transform.position = Vector3.zero; textCamera.transform.LookAt(new Vector3(0.0f, 0.0f, 1.5f), Vector3.up); fontRenderer = new List<FontRenderer>(); for (int i = 0; i < fontTexture.Count; ++i) { FontRenderer fr = new FontRenderer(fontTexture[i], fontLetterSize, drawingLayer, cameraBody.transform); fontRenderer.Add(fr); } }
/// <summary> /// /// </summary> protected override void Initialize() { if (!initialized) { base.Initialize(); content = new ContentManager(Services, @"Gibbo.Content"); spriteBatch = new SpriteBatch(GraphicsDevice); //gameTime = new GameTime(); Camera = new Camera(); //SceneManager.Content = content; SceneManager.SpriteBatch = spriteBatch; SceneManager.GraphicsDevice = GraphicsDevice; SceneManager.ActiveCamera = this.Camera; EditorHandler.SelectedGameObjects = new List<GameObject>(); // Load ObjectIcons objectIcons["AudioObject"] = TextureLoader.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\Gibbo.Content\\audio.png"); FontFile fontFile = FontLoader.Load(AppDomain.CurrentDomain.BaseDirectory + "\\Gibbo.Content\\editorBMFont.fnt"); Texture2D fontTexture = TextureLoader.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\Gibbo.Content\\editorBMFont_0.png"); bmFontRenderer = new FontRenderer(fontFile, fontTexture); LoadContent(); this.CenterCamera(); initialized = true; this.MouseWheel += SceneEditorControl_MouseWheel; } }