Newline is not recognized.

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • It depends on what you are talking about, if you are talking about font rendering, the rendering library, or your own implementation must handle the new line character itself by re-positioning the 'pen'.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Like I said it is likely the DirectX font rendering (assuming Teapot Wars uses that).
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Sure, you could first look into whether DirectX supports parsing strings for commands, or you could write your own font renderer which does this, DirectX may even let you implement your own subclasses.

      Another option, is to simply render the new lines separately underneath one another, I do this as I use FTGL which does not parse strings either.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz

      The post was edited 1 time, last by mholley519 ().

    • Yeah, I think this is a font issue with DirectX 11. I seem to remember Mike running into a gauntlet of font issues when he was adding DirectX 11 into the mix. One thing you can try is running the game in Direct3D 9 mode. You can do this by opening Game/PlayerOptions.xml and changing the renderer to "Direct3D 9".

      -Rez
    • LOL it could be a simple issue of not escaping the slash too....
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • I couldn't get the DrawTextLine (which calls ID3DXFont::DrawText) to work with the newlines, so I bashed the display code with my broadsword to make it display the way I wanted:

      Source Code

      1. D3DRenderer::g_pTextHelper->DrawTextLine( helpRect, DT_RIGHT, g_pApp->GetString(_T("IDS_CONTROLS_HEADER")).c_str() );
      2. helpRect.top = g_pApp->GetScreenSize().y-15*7;
      3. D3DRenderer::g_pTextHelper->DrawTextLine( helpRect, DT_RIGHT, g_pApp->GetString(_T("IDS_CONTROLS_LINE1")).c_str() );
      4. helpRect.top += 15;
      5. D3DRenderer::g_pTextHelper->DrawTextLine( helpRect, DT_RIGHT, g_pApp->GetString(_T("IDS_CONTROLS_LINE2")).c_str() );
      6. helpRect.top += 15;
      7. D3DRenderer::g_pTextHelper->DrawTextLine( helpRect, DT_RIGHT, g_pApp->GetString(_T("IDS_CONTROLS_LINE3")).c_str() );
      8. helpRect.top += 15;
      9. D3DRenderer::g_pTextHelper->DrawTextLine( helpRect, DT_RIGHT, g_pApp->GetString(_T("IDS_CONTROLS_LINE4")).c_str() );
      10. helpRect.top += 15;
      11. D3DRenderer::g_pTextHelper->DrawTextLine( helpRect, DT_RIGHT, g_pApp->GetString(_T("IDS_CONTROLS_LINE5")).c_str() );
      Display All


      This is not THE solution but is A solution (if you're in love with the font). I didn't try changing the font to see if that would make a difference. I'm certain there is a more elegant approach.
      -Troy

      The post was edited 1 time, last by jacktc ().

    • Honestly when I made my first student project this was exactly what I did, however you don't want to do this directly, for me I had a helper class for drawing text which handled new line splitting directly. In my case I was using Freetype directly and cached my gliphs to textures, which were directly rendered as quads at a virtual cursor point, generally I would move the cursor ahead based on the current characters gliph advance width, and with a new line I would simply move the cursor down, and set the horizontal position to 0.

      With this being said, having to manually manage text like this for UI may be ok when it comes to a few lines, but you generally end up burying this in some sort of UI framework, whether it is your own home rolled UI framework, or something like a flash UI system (Scaleform, Iggy, GameSWF) or an HTML UI system (CoherentUI, Awesomium, CEW). These will manage everything including the rendering of your text and the placement of your text relative to some sort of object hierarchy (flash stage or html DOM). It may be beyond your current scope to integrate a UI framework but just know that it is generally best left to something like that when you are ready (Awesomium is free for indies).
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • I didn't say it was pretty... :)

      I did something similar when I was learning MFC in college. 1000 lines of code in OnPaint() later I had a dozen or so custom controls on the screen. I hadn't learned about architecture yet.

      For a 'roll-your-own' solution, the helper class is what I would do next. If DrawTextLIne won't parse my escape characters for me, I'll do it myself... :thumbsup:
      -Troy