ORESTXT.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 : ORESTXT.H
  21. //Description : Header file of Object Text ResTxt
  22. #ifndef __ORESTXT_H
  23. #define __ORESTXT_H
  24. #ifndef __OFILE_H
  25. #include <OFILE.h>
  26. #endif
  27. //------ Begin of function TxtIndex ------//
  28. struct TxtIndex
  29. {
  30. enum { TITLE_LEN=40, PICT_NAME_LEN=8 };
  31. char title[TITLE_LEN+1]; // Title of the text article
  32. char pict_name[PICT_NAME_LEN+1];
  33. short text_size; // size of the text body
  34. long file_pos;
  35. };
  36. //--------- Define class ResTxt ----------//
  37. class ResTxt
  38. {
  39. public:
  40. int rec_count;
  41. private:
  42. enum { DEF_TXT_BUF_SIZE = 5120 }; // default buffer size : 5K
  43. // this size should be large enough for average text unit, also we don't need realloc very frequently
  44. char init_flag;
  45. char res_file_name[MAX_PATH+1]; // e.g. text file name, e.g. BOOK.RTX
  46. // we need to keep the file name, because the file is opened only when reading the content, and close when not necessary
  47. TxtIndex* txt_index_array;
  48. char* txt_buf;
  49. int txt_buf_size;
  50. File file_txt;
  51. char always_open_flag; // always open the text resource file or not
  52. public:
  53. ResTxt() { init_flag=0; }
  54. ~ResTxt() { deinit(); }
  55. void init(char*,int=1);
  56. void deinit();
  57. char* get_title(int);
  58. char* get_body(int);
  59. char* get_pict_name(int);
  60. int locate_topic(char*);
  61. };
  62. //-------------------------------------------//
  63. #endif