
#include <xtl.h>

#include <d3dx8.h>

// ----------------------------------------------------------------------------------
#ifdef _XBOX

#include "xbfont.h"
CXBFont m_Font;
DWORD color;


#define XFONT_TRUETYPE 

#include <xfont.h>

int lC = 86;
int rC = 109;
int lCWidth = 563;
int rCHeight = 394;
extern int sWidth;
extern int sHeight;
extern int HDMode;
extern IDirect3DSurface8 *DirectBack;
extern void ROMError(char* msg);

int FontInit(int i )
{
	if( FAILED( m_Font.Create("d:\\media\\fonts\\Font16.xpr") ) ) {
    }
	return 0;
}

void FontExit()
{
}

int FontSetColour(DWORD colour)
{
  color = colour;
  color |= 0xFF << 24;
  return 0;
}


int FontSmallText(WCHAR *text,int dx,int dy, int maxWidth)
{
float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.Begin();
  m_Font.DrawText( x, y, color, text, XBFONT_CENTER_X | XBFONT_TRUNCATED, maxWidth);
  m_Font.End();
  return 0;
}

float fontHeight = 0;

void SetFontHeight(float v) {
	m_Font.SetScaleFactors( v, v); 
	fontHeight = v;
}

float GetFontHeight() {
	return fontHeight;  
}

float GetFontWidth() {
	return 100;  
}

////616, 628, 640
int FontText(WCHAR *text,int dx,int dy, int maxWidth)
{
  float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.DrawText(x, y, color, text, XBFONT_LEFT | XBFONT_TRUNCATED, maxWidth);
  return 0;
}

int FontGUI(WCHAR *text,int dx,int dy, int maxWidth)
{
  float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.DrawText(x, y, color, text, XBFONT_CENTER_X | XBFONT_TRUNCATED, maxWidth);
  return 0;
}

int FontGuideText(WCHAR *text,int dx,int dy, int maxWidth)
{
   float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.Begin();
  m_Font.DrawText(x, y, color, text, XBFONT_LEFT, maxWidth);
  m_Font.End();
  return 0;
}

int FontCenteredText(WCHAR *text,int dx,int dy, int maxWidth)
{
float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.Begin();
  m_Font.DrawText( x, y, color, text, XBFONT_CENTER_X | XBFONT_TRUNCATED, maxWidth);
  m_Font.End();
  return 0;
}

int FontRightText(WCHAR *text,int dx,int dy, int maxWidth)
{
 float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.Begin();
  m_Font.DrawText(x, y, color, text, XBFONT_LEFT | XBFONT_TRUNCATED, maxWidth);
  m_Font.End();
  return 0;
}

int FontLeftText(WCHAR *text,int dx,int dy, int maxWidth)
{
 float x = 0;
  float y = 0;
  if(HDMode == 0) {
	 x = dx;
	 y = dy;
  }
  if(HDMode == 1) {//1280x720;	 
	 x = ((float)dx * 2.0f);
	 y = ((float)dy * 1.5f); 
  }
  if(HDMode == 2) { //1920x1080
	 x = ((float)dx * 3.0f);
	 y = ((float)dy * 2.25f); 
  }
  m_Font.Begin();
  m_Font.DrawText(x, y, color, text, XBFONT_LEFT | XBFONT_TRUNCATED, maxWidth);
  m_Font.End();
  return 0;
}

#endif


// ----------------------------------------------------------------------------------