OFONT.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OFONT.H
  21. //Description : Header file of Object Font
  22. #ifndef __OFONT_H
  23. #define __OFONT_H
  24. #ifndef __ALL_H
  25. #include <ALL.h>
  26. #endif
  27. #ifndef __OVGABUF_H
  28. #include <OVGABUF.h>
  29. #endif
  30. #ifndef __OTRANSL_H
  31. #include <OTRANSL.h>
  32. #endif
  33. //------- Define constant ------------//
  34. #define DEFAULT_LINE_SPACE 2 // 2 pixels space between lines
  35. // ###### patch begin Gilbert 20/2 ########//
  36. //#if( defined(FRENCH) || defined(SPANISH) )
  37. // change to 80-8f in french
  38. // #define FIRST_NATION_COLOR_CODE_IN_TEXT 0x80
  39. // #define LAST_NATION_COLOR_CODE_IN_TEXT 0x8f
  40. //#else
  41. // english and german uses f0-ff
  42. // #define FIRST_NATION_COLOR_CODE_IN_TEXT 0xF0 // 0xF0 to 0xFF are nation color code, must be this range as other ranges are used by foreign characters
  43. // #define LAST_NATION_COLOR_CODE_IN_TEXT 0xFF
  44. //#endif
  45. #define FIRST_NATION_COLOR_CODE_IN_TEXT 0x80
  46. #define LAST_NATION_COLOR_CODE_IN_TEXT 0x8f
  47. // ###### end begin Gilbert 20/2 ########//
  48. #define NATION_COLOR_BAR_WIDTH 13
  49. #define NATION_COLOR_BAR_HEIGHT 13
  50. //------ Define struct HyperField ------//
  51. #define MAX_HYPER_FIELD 30 // Maximum no. of hyper-text fields in a single page
  52. struct HyperField
  53. {
  54. short x1, y1, x2, y2;
  55. char* text_ptr; // pointer to the hyper-field name in the text
  56. short text_len; // length of the hyper-field name
  57. };
  58. //--------- Define class Font ----------//
  59. struct FontInfo;
  60. class Font
  61. {
  62. public:
  63. char init_flag;
  64. char* next_text_ptr; // these 3 vars are used for storing
  65. short next_text_y; // the result parameters after calling
  66. short line_count; // put_paragraph(). Refer to put_paragraph()
  67. short font_height; // height of a character
  68. short std_font_height;
  69. short max_font_height;
  70. short max_font_width; // width of the widest character in the font
  71. short space_width; // width of the space character
  72. short inter_char_space; // inter-character space
  73. unsigned short first_char; // the starting available character
  74. unsigned short last_char; // the ending available character
  75. FontInfo* font_info_array;
  76. char* font_bitmap_buf; // pointer to the buffer of the font
  77. public:
  78. static short hyper_field_count;
  79. static HyperField hyper_field_array[MAX_HYPER_FIELD];
  80. //---------------------------------------//
  81. public:
  82. Font(char* =NULL);
  83. ~Font();
  84. void init(char* fontName, int interCharSpace=1, int italicShift=0);
  85. void deinit();
  86. int height() { return font_height; }
  87. int width() { return space_width; }
  88. void use_std_height() { font_height = std_font_height; }
  89. void use_max_height() { font_height = max_font_height; }
  90. int text_width(char*, int= -1, int=0);
  91. int text_height(int=DEFAULT_LINE_SPACE);
  92. int put(int,int,char*,char=0,int= -1);
  93. int put(int x, int y, int value, char clearBack=0, int x2= -1)
  94. { return put( x, y, m.format(value), clearBack, x2 ); }
  95. void put_char(int,int,unsigned short);
  96. void right_put(int,int,char*);
  97. int d3_put(int,int,char*);
  98. void d3_put(int,int,int,int,char*);
  99. int center_put(int,int,int,int,char*,char clearBack=0);
  100. void put_paragraph(int,int,int,int,char*,int=DEFAULT_LINE_SPACE,int=1,char=1);
  101. void count_line(int x1, int y1, int x2, int y2, char *text,
  102. int lineSpace, int& totalLines, int& dispLines);
  103. void put_char_to_buffer(char* dest, int destPitch, int x1, int y1, unsigned short text);
  104. void put_to_buffer(char* dest, int destPitch, int x1, int y1, char *text);
  105. void center_put_to_buffer(char* dest, int destPitch, int x1, int y1, int x2, int y2, char *text);
  106. short translate_german_char(short textChar);
  107. //----------- <int> version -------------//
  108. void put_field(int,int,char*,int,int,int=1);
  109. void update_field(int,int,int,int,int);
  110. void field(int,int,char*,int,int,int,int,int,char* helpCode=NULL);
  111. int disp(int,int,int,int,int);
  112. //----- <short> version, call <int> version directly -----//
  113. void put_field(int a,int b,char* c,int d,short e,int f=1)
  114. { put_field(a,b,c,d,(int)e,f); }
  115. void update_field(int a,int b,short c,int d,int e)
  116. { update_field(a,b,(int)c,d,e); }
  117. void field(int a,int b,char* c,int d,short e,int f,int g,int h,char* helpCode=NULL)
  118. { field(a,b,c,d,(int)e,f,g,h); }
  119. int disp(int a,int b,short c,int d,int e)
  120. { return disp(a,b,(int)c,d,e); }
  121. //---- <long> version, call <int> version directly ------//
  122. void put_field(int a,int b,char* c,int d,long e,int f=1)
  123. { put_field(a,b,c,d,(int)e,f); }
  124. void update_field(int a,int b,long c,int d,int e)
  125. { update_field(a,b,(int)c,d,e); }
  126. void field(int a,int b,char* c,int d,long e,int f,int g,int h,char* helpCode=NULL)
  127. { field(a,b,c,d,(int)e,f,g,h); }
  128. int disp(int a,int b,long c,int d,int e)
  129. { return disp(a,b,(int)c,d,e); }
  130. //------------- <double> version ---------------//
  131. void put_field(int,int,char*,int,double,int=1);
  132. void update_field(int,int,double,int,int);
  133. void field(int,int,char*,int,double,int,int,int,char* helpCode=NULL);
  134. int disp(int,int,double,int,int);
  135. //-------------- <char*> version ---------------//
  136. void put_field(int,int,char*,int,char*);
  137. void update_field(int,int,char*,int);
  138. void field(int,int,char*,int,char*,int,int,char* helpCode=NULL);
  139. int disp(int,int,char*,int);
  140. };
  141. extern Font font_san, font_std, font_small, font_mid, font_news;
  142. extern Font font_hitpoint, font_bible, font_bard;
  143. #if( defined(GERMAN) || defined(FRENCH) || defined(SPANISH) )
  144. extern Font font_hall;
  145. #endif
  146. //------------------------------------------------//
  147. #endif