NXEngine v1.0.0.6
[NXEngine.git] / TextBox / TextBox.h
blob8461d969bb4b0e0a3eeef5ba85a21e9cdc7e8690
2 #ifndef _TEXTBOX_H
3 #define _TEXTBOX_H
5 #include "YesNoPrompt.h"
6 #include "ItemImage.h"
7 #include "StageSelect.h"
8 #include "SaveSelect.h"
10 #define MSG_W 244
11 #define MSG_H 64
12 #define MSG_X ((SCREEN_WIDTH / 2) - (MSG_W / 2))
13 #define MSG_NORMAL_Y ((SCREEN_HEIGHT - MSG_H) - 2)
14 #define MSG_UPPER_Y 24
16 #define MSG_NLINES 4
17 #define MSG_LINE_SPACING 16
19 enum TBFlags
21 TB_DEFAULTS = 0x00,
23 TB_DRAW_AT_TOP = 0x01,
24 TB_NO_BORDER = 0x02,
26 TB_LINE_AT_ONCE = 0x04,
27 TB_VARIABLE_WIDTH_CHARS = 0x08,
28 TB_CURSOR_NEVER_SHOWN = 0x10
31 class TextBox
33 public:
34 bool Init();
35 void Deinit();
37 void SetVisible(bool enable, uint8_t flags = TB_DEFAULTS);
38 void ResetState();
40 void AddText(const char *str);
41 void SetText(const char *str);
42 void ClearText();
44 void SetFace(int newface);
46 void SetFlags(uint8_t flags, bool enable);
47 void SetFlags(uint8_t flags);
48 void ShowCursor(bool enable);
50 TB_YNJPrompt YesNoPrompt;
51 TB_ItemImage ItemImage;
52 TB_StageSelect StageSelect;
53 TB_SaveSelect SaveSelect;
55 bool IsVisible();
56 bool IsBusy();
58 void Draw();
59 static void DrawFrame(int x, int y, int w, int h);
61 uint8_t GetFlags() { return fFlags; }
62 void SetCanSpeedUp(bool newstate);
64 private:
65 void DrawTextBox();
66 int GetMaxLineLen();
67 void AddNextChar();
69 bool fVisible;
70 uint8_t fFlags;
72 uint8_t fFace; // current NPC face or 0 if none
73 int fFaceXOffset; // for face slide-in animation
75 // currently visible lines
76 char fLines[MSG_NLINES][80];
77 int fCurLine;
78 int fCurLineLen;
80 // handles scrolling lines off
81 bool fScrolling;
82 int fTextYOffset;
84 // chars waiting to be added
85 char fCharsWaiting[256];
86 uint8_t fCWHead, fCWTail;
88 int fTextTimer;
89 bool fCanSpeedUp;
91 // blinking cursor control
92 bool fCursorVisible;
93 int fCursorTimer;
95 struct
97 int x, y;
98 int w, h;
100 fCoords;
104 #define MSG_NONE 0
105 #define MSG_NORMAL 1
106 #define MSG_UPPER_INVISIBLE 2
107 #define MSG_UPPER 3
109 #define MSG_NLINES 4
111 #define NOYESNO 0
112 #define YESNO_APPEAR 1
113 #define YESNO_WAIT 2
114 #define YESNO_YES 3
115 #define YESNO_NO 4
117 struct MessageBox
119 int x, y, w, h;
121 // 0 - no text box
122 // 1 - normal text box
123 // 2 - upper text box, box is invisible
124 // 3 - upper text box, box is visible
125 char displaystate;
127 int line_spacing;
128 int maxlinelen;
129 char useautospacing;
131 uchar face; // current face or 0 if none
132 int face_xoff; // for face slide-in animation
134 char instantline; // instead of a char at a type, we do a line at a time
136 char line[MSG_NLINES][80];
137 int curline;
138 int curlinelen;
140 char scrolling;
141 int text_yoffset;
143 char chars_waiting[256];
144 uchar cwhead, cwtail;
145 int texttimer;
146 char canspeedup;
148 struct
150 char show;
151 char inhibit;
152 int timer;
153 } cursor;
155 struct
157 char state;
158 int y;
159 int timer;
160 char answer;
161 } yesno;
163 struct
165 int x, y;
166 int sprite, frame;
167 int yoff;
168 } item;
175 #endif