ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
text_rpg.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #if defined(ENABLE_EOB) || defined(ENABLE_LOL)
23 
24 #ifndef KYRA_TEXT_EOB_H
25 #define KYRA_TEXT_EOB_H
26 
27 #include "common/scummsys.h"
28 #include "kyra/graphics/screen.h"
29 
30 namespace Kyra {
31 
32 class KyraRpgEngine;
33 
34 class TextDisplayer_rpg {
35 public:
36  TextDisplayer_rpg(KyraRpgEngine *engine, Screen *scr);
37  virtual ~TextDisplayer_rpg();
38 
39  void setupField(int dim, bool mode);
40 
41  virtual void printDialogueText(int stringId, const char *pageBreakString, const char *pageBreakString2 = 0);
42  virtual void printDialogueText(const char *str, bool wait = false);
43  void printMessage(const char *str, int textColor = -1, ...);
44  virtual void printShadedText(const char *str, int x = -1, int y = -1, int textColor = -1, int shadowColor = -1, int pitchW = -1, int pitchH = -1, int marginRight = 0, bool screenUpdate = true) {}
45 
46  virtual int clearDim(int dim);
47  void clearCurDim();
48 
49  void resetDimTextPositions(int dim);
50  void resetPageBreakString();
51  void setPageBreakFlag();
52  void removePageBreakFlag();
53 
54  void allowPageBreak(bool mode) { _allowPageBreak = mode; }
55  void setWaitButtonMode(int mode) { _waitButtonMode = mode; }
56  int lineCount() const { return _lineCount; }
57  //const uint8 *colorMap() const { return _colorMap; }
58 
59  // These methods are ScummVM specific. They are supposed to make necessary modifications
60  // to the text displayer for the various Japanese and Chinese versions without too much
61  // hackery...
62  void setColorMapping(int sd, uint8 from, uint8 to);
63  void setShadowColor(int sd, int col) { applySetting(sd, kShadowColor, col); }
64  void setLineSpacing(int sd, int spacing) { applySetting(sd, kLineSpacing, spacing); }
65  void setVisualLineSpacingAdjust(int sd, int adj) { applySetting(sd, kVisualLineSpacingAdjust, adj); }
66  void setCharSpacing(int sd, int spacing) { applySetting(sd, kCharSpacing, spacing); }
67 
68 protected:
69  virtual KyraRpgEngine *vm() { return _vm; }
70  virtual Screen *screen() { return _screen; }
71 
72  virtual void displayText(char *str, ...);
73  char parseCommand();
74  void readNextPara();
75  void printLine(char *str);
76  virtual void textPageBreak();
77  void displayWaitButton();
78 
79  void convertString(char *str);
80 
81  char *_dialogueBuffer;
82 
83  const char *_tempString1;
84  const char *_tempString2;
85  char *_currentLine;
86  char _ctrl[3];
87 
88  uint16 _lineWidth;
89  uint32 _numCharsTotal;
90  uint32 _numCharsLeft;
91  uint32 _numCharsPrinted;
92 
93  bool _printFlag;
94  bool _twoByteLineBreakFlag;
95  const bool _pc98TextMode;
96 
97  Common::String _pageBreakString;
98  Common::String _scriptParaString;
99  int _lineCount;
100 
101  bool _allowPageBreak;
102  int _waitButtonSpace;
103  int _waitButtonMode;
104 
105  static const char _pageBreakDefault[3][5];
106 
107  struct TextDimData {
108  uint8 color1;
109  uint8 color2;
110  uint16 column;
111  uint8 line;
112  // These properties don't appear in the original code. The various Japanese and Chinese versions
113  // just had their modifications hacked in in whatever way the devs felt like. These properties
114  // help making the necessary adjustments without too much hackery...
115  int lineSpacing;
116  int visualLineSpacingAdjust; // LOL PC-98 has the worst hack here. The visual line spacing is different than the one that is used to measure the text field space.
117  int charSpacing;
118  int shadowColor;
119  int noHalfWidthLineEnd;
120  uint8 *colorMap;
121  };
122 
123  TextDimData *_textDimData;
124  const int _dimCount;
125  KyraRpgEngine *_vm;
126 
127 private:
128  bool isTwoByteChar(uint8 c) const;
129  void applySetting(int sd, int ix, int val);
130  uint8 remapColor(int sd, uint8 color) const;
131 
132  enum TextFieldVar {
133  kLineSpacing = 0,
134  kVisualLineSpacingAdjust,
135  kCharSpacing,
136  kShadowColor,
137  kNoHalfWidthLineEnd,
138  kOutOfRange
139  };
140 
141  Screen *_screen;
142  char *_table1;
143  char *_table2;
144 
145  Screen::FontId _waitButtonFont;
146 
147  uint8 _colorMap[256];
148 
149  bool _isChinese;
150 };
151 
152 } // End of namespace Kyra
153 
154 #endif
155 
156 #endif // ENABLE_EOB || ENABLE_LOL
Definition: str.h:59
Definition: atari-screen.h:60
Definition: detection.h:27