home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 July & August / PCWorld_2006-07-08_cd.bin / temacd / planearcade / planearcade.exe / Tank3.bmp / dxfont.cpp < prev    next >
C/C++ Source or Header  |  2004-08-18  |  2KB  |  93 lines

  1.  
  2. #include "main.h"
  3.  
  4.  
  5. //------------------------------------------------------------------
  6. // Name: DXFONT()
  7. // Desc: konstruktor
  8. //------------------------------------------------------------------
  9. DXFONT::DXFONT()
  10. {
  11.     Font = NULL;
  12. }
  13.  
  14. //------------------------------------------------------------------
  15. // Name: ~DXFONT()
  16. // Desc: destruktor
  17. //------------------------------------------------------------------
  18. DXFONT::~DXFONT()
  19. {
  20.  
  21.     if(Font != NULL)
  22.         Font->Release();
  23.     Font = NULL;
  24.  
  25.  
  26. }
  27. /*
  28. AtributeFlag - FW_NORMAL, FW_BOLD
  29. FontFace - Arial, CourierNew
  30. */
  31. //------------------------------------------------------------------
  32. // Name: Create()
  33. // Desc: inicializacia fontu
  34. //------------------------------------------------------------------
  35. void DXFONT::Create(int Size,DWORD AtributeFlag,char *FontFace)
  36. {
  37.  
  38.     LogPrint("Vytvaram DXFONT");
  39.  
  40.     HFONT hFont = CreateFont(Size, 0, 0, 0, AtributeFlag, false, false, false, 
  41.                             DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
  42.                             DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
  43.     if(!hFont)
  44.     {
  45.         LogPrint("  Chyba pri vytvarani fontu");
  46.     }
  47.  
  48.     if(FAILED(D3DXCreateFont(g_pd3dDevice, hFont, &Font)))
  49.     {
  50.         LogPrint("  Chyba pri vytvarani fontu");
  51.     }
  52.    
  53.     DeleteObject(hFont);
  54.  
  55.     FontPosition.top = 0;
  56.     FontPosition.left = 0;
  57.     FontPosition.right = Engine.Width;
  58.     FontPosition.bottom = Engine.Height;
  59.  
  60.  
  61. }
  62.  
  63. //------------------------------------------------------------------
  64. // Name: Print()
  65. // Desc: vytlacenie na obrazovku
  66. //------------------------------------------------------------------
  67. void DXFONT::Print(int x,int y,COLOR Color,char *Text)
  68. {
  69.  
  70.     FontPosition.left = x;
  71.     FontPosition.top = y;
  72.     Font->DrawText(TEXT(Text), -1, &FontPosition, DT_LEFT, D3DXCOLOR(Color.R,Color.G,Color.B,Color.A));
  73.  
  74.  
  75. }
  76.  
  77. //------------------------------------------------------------------
  78. // Name: PrintCenter()
  79. // Desc: vytlacenie na obrazovku
  80. //------------------------------------------------------------------
  81. void DXFONT::PrintCenter(int x,int y,COLOR Color,char *Text)
  82. {
  83.  
  84.     FontPosition.left = 0;
  85.     FontPosition.top = y;
  86.     Font->DrawText(TEXT(Text), -1, &FontPosition, DT_CENTER, D3DXCOLOR(Color.R,Color.G,Color.B,Color.A));
  87.  
  88.  
  89. }
  90.  
  91.  
  92.  
  93.