#ifndef __FONERM_H__
#define __FONERM_H__
 
#ifdef  __cplusplus
extern "C" {
#endif
 
#define C_szFONVersion "FON V1.0.0" /* The format is XXX Va.b.c with Xxx is the Tag of the module */
#define C_szFONFullName  "2D-FONT module"/* the complete and clear name of the module */
#define C_szFONDate __DATE__ /*The format is "Mmm dd yyyy".You can use __DATE__ but be careful that you have the control of the compilation*/
 
#include "ERM.h"
 
#undef EXTERN
#if !defined(FON_MainFile)
#define EXTERN extern
#else /* !FON_MainFile */
#define EXTERN
#endif /* !FON_MainFile */
 
#define __FATAL_ERR_FON__
#define __WARNING1_ERR_FON__
 
/* error of the FON Module*/
enum e_uwFONErrNumber{
	E_uwFONFatalErr,	
#ifdef __FATAL_ERR_FON__
 /*     Fatals error :*/
 E_uwFONFatalNotAFatalError,
 E_uwFONWarningErrorIsNotAWarningError,
 E_uwFONTooMuchFonts,
 E_uwFONTooMuchFONs,
 E_uwFONMemoryError,
 E_uwFONNotEnoughStringSpace,
 E_uwFontScriptBadNumberOfArg,
 E_uwTooManyCharactersInFont,
#endif /*__FATAL_ERR_FON__*/
	E_uwFONStartOfWarning,/* important constant, it allows to recognize if an error is fatal or not.*/
#ifdef __WARNING1_ERR_FON__
 E_uwFONUnknownLetter,
 E_uwFONUnknownFON,
 E_uwFONUnknownFont,
 E_uwFONUnknownText,
 E_uwFONTooManyCharacterInFont,
 
 E_uwFONWarningShouldNotHappen,/* should never happen, but....*/
#endif /*__WARNING1_ERR_FON__*/
	E_uwFONErrNumber
};
 
EXTERN unsigned char g_ucFONModuleId /*number of identification of the Erm module*/
 #ifdef FON_MainFile
 = C_ucModuleNotInitialized
 #endif /*FON_MainFile*/
;
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN CPA_EXPORT  char * g_a_szFONInformationModule []
#if defined(FON_MainFile) && !defined(CPA_WANTS_IMPORT)
= {C_szFONVersion, C_szFONFullName, C_szFONDate}
#endif /*FON_MainFile &&  CPA_WANTS_IMPORT*/
;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN char * g_szFONModuleName /* Obliged syntax 'g_sz'+[Abbreviation of ModuleName]+'ModuleName'*/
 #ifdef FON_MainFile
 = "Module FON"
 #endif /*FON_MainFile*/
;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
#if defined(__ERROR_STRINGS__)
EXTERN tdstErrorMsg g_a_stFONTabErr [] 	/* Obliged syntax 'g_a_st'+[Abbreviation of ModuleName]+'TabErr'*/
 #ifdef FON_MainFile
={ 
  #ifdef __FATAL_ERR_FON__
	  E_uwFONFatalNotAFatalError, "This is not a valide FON Debug fatal error",
	  E_uwFONWarningErrorIsNotAWarningError,"M_GameWarningError : Try to raise a fatal or a information",
	  E_uwFONTooMuchFonts, "Too much fonts are defined",
	  E_uwFONTooMuchFONs, "Too much FONs are defined",
   E_uwFONMemoryError,"Not enough memory.",
   E_uwFONNotEnoughStringSpace,"No enough strings space",
   E_uwFontScriptBadNumberOfArg,"Script : bad number of arguments",
   E_uwTooManyCharactersInFont,"To many characters in font",
  #endif /*__FATAL_ERR_FON__*/
 
  E_uwFONStartOfWarning,"This is a strange FON Debug Warning",
  #ifdef __WARNING1_ERR_FON__
  E_uwFONUnknownLetter,"Unknown Letter",
  E_uwFONUnknownFON,"Unknown FON",
  E_uwFONUnknownFont,"Unknown font",
  E_uwFONUnknownText,"Unknown text",
  E_uwFONTooManyCharacterInFont,"To many characters in font",
 
  E_uwFONWarningShouldNotHappen,"This error should never happen!!!!",
  #endif /*__WARNING1_ERR_FON__*/
 
 	0xFFFF, "\0"/*fin*/
}
 #endif /*FON_MainFile*/
;
#endif /*__ERROR_STRINGS__*/
 
 
#define M_FONFatalError(ErrorNum) \
{ \
 if (ErrorNum>E_uwFONFatalErr&&ErrorNum<E_uwFONStartOfWarning) \
 { \
  Erm_M_ClearLastError(C_ucErmDefaultChannel);\
  Erm_M_UpdateLastError(FON,C_ucErmDefaultChannel,(unsigned short)ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
 } \
 else \
 { \
  Erm_M_ClearLastError((unsigned short)C_ucErmDefaultChannel);\
  Erm_M_UpdateLastError(FON,C_ucErmDefaultChannel,(unsigned short)E_uwFONFatalNotAFatalError,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
 } \
}
 
#define M_FONWarningError(ErrorNum) \
{ \
 if (ErrorNum>E_uwFONStartOfWarning&&ErrorNum<E_uwFONErrNumber) \
 { \
  Erm_M_ClearLastError((unsigned short)C_ucErmDefaultChannel);\
  Erm_M_UpdateLastError(FON,C_ucErmDefaultChannel,(unsigned short)ErrorNum,C_lErmNoDebugData,C_ucErmOpenInfoWindow,C_ucAllowStopForDebug, NULL);\
 } \
 else \
 { \
  M_FONFatalError(E_uwFONWarningErrorIsNotAWarningError); \
 } \
}
 
#define M_FONInformationErrorWithString(ErrorNum,szString) \
{ \
 if (ErrorNum>E_uwFONStartOfWarning&&ErrorNum<E_uwFONErrNumber) \
 { \
  Erm_M_UpdateLastError(FON,C_ucErmDefaultChannel,(unsigned short)ErrorNum,C_lErmNoDebugData,C_ucErmNoOpenInfoWindow,C_ucNeverStopForDebug, szString);\
  Erm_M_ClearLastError(C_ucErmDefaultChannel);\
 } \
 else \
 { \
  M_FONFatalError(E_uwFONWarningErrorIsNotAWarningError); \
 } \
}
 
#ifdef  __cplusplus
}/* extern "C" */
#endif
 
#endif /* __FONITEM_H__ */
