public PlayerNameState(GameEngine engine, MainMenuState ms) { eng = engine; mouse = eng.Mouse; savedGameStates = new Stack<XmlNodeList>(); savedGameChoices = new Stack<string>(); _ms = ms; Assembly assembly = Assembly.GetExecutingAssembly(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); lookat = new Vector3(0, 0, 2); eye = new Vector3(0, 0, 5); _old_state = OpenTK.Input.Keyboard.GetState(); // Get the current state of the keyboard eng.StateTextureManager.LoadTexture("menu", assembly.GetManifestResourceStream("U5Designs.Resources.Textures.menu.png")); menu = eng.StateTextureManager.GetTexture("menu"); saveFont = QFont.FromQFontFile("Fonts/myHappySans.qfont", new QFontLoaderConfiguration(true)); saveFont.Options.DropShadowActive = true; start_x = saveFont.Measure("Name: ").Width; //title = QFont.FromQFontFile("myHappySans.qfont", new QFontLoaderConfiguration(true)); title = QFont.FromQFontFile("Fonts/myRock.qfont", new QFontLoaderConfiguration(true)); title.Options.DropShadowActive = true; name = ""; numOfButtons = savedGameChoices.Count - 1; }
public static void Draw(QFont font, string text, QFontAlignment alignment, Vector2 position) { position.Y -= font.Measure(text, alignment).Height / 2; font.Options.UseDefaultBlendFunction = false; font.Print(text, alignment, position); }
private void PrintCommentWithLine(QFont font, string comment, QFontAlignment alignment, float xOffset, ref float yOffset) { GL.PushMatrix(); yOffset += 20; GL.Translate((int)xOffset, yOffset, 0f); font.Print(comment, alignment); var bounds = font.Measure(comment, Width-60, alignment); GL.Disable(EnableCap.Texture2D); GL.Begin(BeginMode.Lines); GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, 0f); GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, bounds.Height + 20f); GL.End(); yOffset += bounds.Height; GL.PopMatrix(); }
private void PrintComment(QFont font, string comment,QFontAlignment alignment, ref float yOffset){ GL.PushMatrix(); yOffset += 20; GL.Translate(30f, yOffset, 0f); font.Print(comment, Width - 60, alignment); yOffset += font.Measure(comment, Width - 60, alignment).Height; GL.PopMatrix(); }
private void PrintWithBounds(QFont font, string text, RectangleF bounds, QFontAlignment alignment, ref float yOffset) { GL.Disable(EnableCap.Texture2D); GL.Color4(1.0f, 0f, 0f, 1.0f); float maxWidth = bounds.Width; float height = font.Measure(text, maxWidth, alignment).Height; GL.Begin(BeginMode.LineLoop); GL.Vertex3(bounds.X, bounds.Y, 0f); GL.Vertex3(bounds.X + bounds.Width, bounds.Y, 0f); GL.Vertex3(bounds.X + bounds.Width, bounds.Y + height, 0f); GL.Vertex3(bounds.X, bounds.Y + height, 0f); GL.End(); font.Print(text, maxWidth, alignment, new Vector2(bounds.X,bounds.Y)); yOffset += height; }
private void PrintWithBounds(QFont font, string text, RectangleF bounds, QFontAlignment alignment, ref float yOffset) { GL.Disable(EnableCap.Texture2D); GL.Color4(1.0f, 0f, 0f, 1.0f); float maxWidth = bounds.Width; float height = font.Measure(text, maxWidth, alignment).Height; GL.Begin(BeginMode.LineLoop); GL.Vertex3(bounds.X, bounds.Y, 0f); GL.Vertex3(bounds.X + bounds.Width, bounds.Y, 0f); GL.Vertex3(bounds.X + bounds.Width, bounds.Y + height, 0f); GL.Vertex3(bounds.X, bounds.Y + height, 0f); GL.End(); font.Print(text, maxWidth, alignment, new Vector2(bounds.X, bounds.Y)); // Print ENTER string s = "[ Press Enter ]"; font.Print(s, maxWidth, alignment, new Vector2(-bounds.X - (font.Measure(s).Width + 10), bounds.Height + 2 * font.Measure(text).Height)); //font.Print(s, maxWidth, QFontAlignment.Right, new Vector2(bounds.X + bounds.Width - font.Measure(s).Height, bounds.Y + bounds.Height - font.Measure(s).Height)); yOffset += height; }
private void PrintWithBounds(QFont font, string text, RectangleF bounds, QFontAlignment alignment, ref float yOffset) { float maxWidth = bounds.Width; float height = font.Measure(text, new SizeF(maxWidth, -1), alignment).Height; //gl.begin(beginmode.lineloop); //gl.vertex3(bounds.x, bounds.y, 0f); //gl.vertex3(bounds.x + bounds.width, bounds.y, 0f); //gl.vertex3(bounds.x + bounds.width, bounds.y + height, 0f); //gl.vertex3(bounds.x, bounds.y + height, 0f); //gl.end(); var dp = new QFontDrawingPimitive(font); dp.Print(text, new Vector3(bounds.X, Height - yOffset, 0), new SizeF(maxWidth, float.MaxValue), alignment); drawing.DrawingPimitiveses.Add(dp); yOffset += height; }
private void PrintCommentWithLine(QFont font, string comment, QFontAlignment alignment, float xOffset, ref float yOffset, QFontRenderOptions opts) { yOffset += 20; var dp = new QFontDrawingPimitive(font, opts); //if (doSpacing) // dp.Options.CharacterSpacing = 0.05f; dp.Print(comment, new Vector3(xOffset, Height - yOffset, 0f), new SizeF(Width - 60, -1), alignment); drawing.DrawingPimitiveses.Add(dp); var bounds = font.Measure(comment, new SizeF(Width - 60, float.MaxValue), alignment); //GL.Disable(EnableCap.Texture2D); //GL.Begin(BeginMode.Lines); //GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, 0f); //GL.Color4(1.0f, 0f, 0f, 1f); GL.Vertex2(0f, bounds.Height + 20f); //GL.End(); yOffset += bounds.Height; }