Mercurial > otakunoraifu
annotate scn2k/scn2k_text.cc @ 53:ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
* ParseMoji moved to TextStream
* Some cleaning (0 -> NULL when needed, removal of useless returns, ...)
author | thib |
---|---|
date | Sun, 19 Apr 2009 11:44:05 +0000 |
parents | 15a18fbe6f21 |
children | f1a27ee7e03c |
rev | line source |
---|---|
0 | 1 /* |
2 TODO: | |
3 ÆüÉդΥé¥Ù¥ë¤¬²èÌÌÀÚ¤êÂؤ¨»þ¤Ë·ç¤±¤ë¤Î¤ò½¤Àµ | |
4 ²èÁü¸ú²Ì : ¿Í´Ö¤ÎÆþ¤ì´¹¤ï¤ê¤Ê¤É | |
5 kcursor ¤ÎÁàºî¤ò WidText ¥¯¥é¥¹¤ËǤ¤»¤ë | |
6 WidText ¥¯¥é¥¹¤Ë¤Ï¿·¤¿¤Ë°Ê²¼¤ÎÁàºî¤ò²Ã¤¨¤ë | |
7 ¡¦¥¦¥§¥¤¥È½ªÎ»¸å¡¢¥¯¥ê¥¢¤Ê¤·¤Ë¿·¤¿¤Ê¥Æ¥¥¹¥È¤òÄɲᢿ·¤¿¤Ëstart-wait¤¹¤ë | |
8 ¡¦Ê¸»ú¤ÎÉÁ²è (Start) ¤È Wait(¥«¡¼¥½¥ëɽ¼¨ÂÔ¤Á)¤ÎʬΥ¡£ | |
9 Start ¤¹¤ë¤Èʸ»ú¤òÉÁ²è³«»Ï¤¹¤ë¡£¥¯¥ê¥Ã¥¯¤ÇÁ´ÉÁ²è¡£ | |
10 Flush ¤¹¤ë¤È¥Ð¥Ã¥Õ¥¡Æâ¤Îʸ»ú¤ò¤¹¤Ù¤ÆÉÁ²è¤¹¤ë | |
11 Wait ¤¹¤ë¤ÈÁ´ÉÁ²è¸å¡¢¥¯¥ê¥Ã¥¯¤µ¤ì¤ë¤Þ¤Ç¥«¡¼¥½¥ë¤òɽ¼¨¤¹¤ë¤Þ¤ÇÂÔ¤Ä | |
12 TextImpl ¦¤Î¾õÂ֤Ȥ·¤Æ¤Ï Wait ¤Î¤ß¤ò»ý¤Ä (PREPARE¤ËÌá¤ë¤Î¤òÂÔ¤Ä) | |
13 ¤¿¤À¤·¡¢Skip ¤Î¸¢Íø¤Ï¤É¤Ã¤Á¤¬¤â¤Ä¡©¡Ê¸½¾õ¤Ï¡©¡Ë | |
14 | |
15 GrpObj: NextObj ¤È GrpObj ¤òʬΥ¡£CreateObj ¤Ï¸½¾õÄ̤ꡢVisible=1 »þ¤Ë¹Ô¤¦¡£ | |
16 ¤½¤ì¤¾¤ì num=0 (screen) ¤Î»Þleaf ¤È¤·¤Æ¼ÂÁõ¡£delete»þ¤Ï¿Æ¤Îdelete¤Î¤ß¤ò | |
17 ¹Ô¤¤¡¢»Ò¤ÏGrpObj¤Î¼ÂÂΤÀ¤±¤òºï½ü¤¹¤ë | |
18 Visible ¸å¤Îhide ¤Ï¼ÂºÝ¤Ë hide ¤È¤¹¤ë | |
19 ExecReservedCmd() ¤Ï¤Ê¤¯¤»¤ë¤Ï¤º¡£Delete() ¤â¤Ê¤¯¤Ê¤ë¡£ | |
20 ¥«¥Î¥®¡§ReBlit() ¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¤»¤¤¤Ç̾Á°¥¦¥£¥ó¥É¥¦¤¬¾Ã¤¨¤¿»þ¤ÎÇطʤ¬¤Ê¤¯¤Ê¤ë | |
21 | |
22 ¤¯¤é¡§²óÁÛɽ¼¨ | |
23 SEL²èÁü¸ú²Ì | |
24 DONE: | |
25 ¤È¤â¤è¤Î¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¼ÂÁõ¡¢¥Ü¥¿¥ó¼ÂÁõ | |
26 shake ¤Î²èÁü¸ú²Ì | |
27 ¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Î¥Æ¥¥¹¥È¿§¤Î¼ÂÁõ | |
28 ²èÁü¸ú²Ì¤Î²þÁ± | |
29 */ | |
30 | |
31 /* | |
32 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
33 * All rights reserved. | |
34 * | |
35 * Redistribution and use in source and binary forms, with or without | |
36 * modification, are permitted provided that the following conditions | |
37 * are met: | |
38 * 1. Redistributions of source code must retain the above copyright | |
39 * notice, this list of conditions and the following disclaimer. | |
40 * 2. Redistributions in binary form must reproduce the above copyright | |
41 * notice, this list of conditions and the following disclaimer in the | |
42 * documentation and/or other materials provided with the distribution. | |
43 * 3. The name of the author may not be used to endorse or promote products | |
44 * derived from this software without specific prior written permission. | |
45 * | |
46 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
47 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
48 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
49 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
50 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
51 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
52 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
53 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
54 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
55 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
56 */ | |
57 | |
52 | 58 #include "window/event.h" |
59 #include "window/picture.h" | |
60 #include "window/widget.h" | |
61 #include "system/file.h" | |
62 #include "system/system_config.h" | |
63 #include "scn2k.h" | |
0 | 64 |
52 | 65 #include <string> |
0 | 66 using namespace std; |
67 | |
68 // kanji conv : ¥Ç¥Ð¥Ã¥°É½¼¨ÍÑ | |
69 void kconv(const unsigned char* src, unsigned char* dest); | |
70 void kconv_rev(const unsigned char* src, unsigned char* dest); | |
71 string kconv(const string& s); | |
72 string kconv_rev(const string& s); | |
73 // render.cc | |
74 void DSurfaceFillA(Surface* src, const Rect& rect, int r, int g, int b, int a); // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦ÇطʤÎÀßÄê | |
75 void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); // ¥³¥Ô¡¼ | |
76 | |
77 /**************************************************************:: | |
78 ** | |
79 ** TextImpl(interface) | |
80 */ | |
81 struct TimerAtom { | |
82 int from; | |
83 int to; | |
84 unsigned int start_time; | |
85 unsigned int total_time; | |
86 }; | |
87 | |
88 struct TextWindow { | |
89 /* @@@ : SetWindowColor ¤Ç¤Î surface ºÆÀßÄê¤ËÃí°Õ */ | |
90 WidText* wid; | |
91 bool name_visible; | |
92 WidLabel* name; | |
93 PicContainer* name_container; | |
94 PicBase* face; | |
95 PicBase* face_pics[8]; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
96 TextWindow(PicContainer& parent, Event::Container& event, int window_no, void* callback); |
0 | 97 ~TextWindow() { |
52 | 98 if (name_container != NULL) { |
99 delete name_container; | |
100 name_container = NULL; | |
0 | 101 } |
52 | 102 int i; |
103 for (i=0; i<8; i++) { | |
104 if (face_pics[i] != NULL) { | |
105 delete face_pics[i]; | |
106 face_pics[i] = NULL; | |
107 } | |
108 } | |
109 if (wid != NULL) { | |
110 delete wid; | |
111 wid = NULL; | |
112 } | |
0 | 113 } |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
114 Rect WakuSize(PicContainer& pic, int waku_no); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
115 void MakeWaku(PicContainer& pic, Event::Container& event, int waku_no,int window_no, bool* use_btn, void* callback); |
0 | 116 void show(void) { |
117 wid->show(); | |
118 if (name_container && name_visible) name_container->show(); | |
119 if (face) face->show(); | |
120 } | |
121 void hide(void) { | |
122 wid->hide(); | |
123 if (name_container) name_container->hide(); | |
124 if (face) face->hide(); | |
125 } | |
126 void ShowFace(const char* path) { | |
127 if (!face) return; | |
128 face->SetSurface( path, 0,0); | |
129 } | |
130 void ResetFace(void) { | |
131 if (!face) return; | |
132 face->SetSurface( (Surface*)0, 0,0); | |
133 } | |
134 void StartText(const TextStream& _stream) { | |
135 wid->Clear(); | |
136 wid->stream = _stream; | |
137 if (name_container) { | |
138 char namestr[1024]; | |
139 namestr[0] = 0; | |
140 wid->stream.RemoveName(namestr, 1024); | |
141 if (namestr[0] == 0) { | |
142 name_container->hide(); | |
143 } else { | |
144 if (name) { | |
145 name_container->show_all(); | |
146 name->SetText(namestr); | |
147 } | |
148 } | |
149 } | |
150 wid->Start(); | |
151 } | |
152 void SetName(const char* n) { | |
153 if (name_container && name) { | |
154 if (n[0]) { | |
155 name_container->show(); | |
156 name->SetText(n); | |
157 name_visible = true; | |
158 } else { | |
159 name_container->hide(); | |
160 name_visible = false; | |
161 } | |
162 } | |
163 } | |
164 }; | |
165 | |
166 class TextImpl { | |
52 | 167 public: |
168 TextWindow* text; | |
169 typedef enum {NORMAL=0, WAIT_TEXT=1, WAIT=2, | |
170 WAIT_CLICK=3, WAIT_ABORT=4, WAIT_CLICK_MOUSEPOS = 5, | |
171 WAIT_CLICK_MOUSEPOSEND_L = 6, WAIT_CLICK_MOUSEPOSEND_R = 7, | |
172 WAIT_SELECT_INBOX = 10, WAIT_SELECT_OUTBOX=11, WAIT_SELECT_VALUE = 12, | |
173 WAIT_EXTRN_MASK = 64, SAVEMASK = 128, LOADMASK = 256, SKIPMASK = 512, | |
174 CLEARSCR_MASK = 1024, STATSAVE_MASK = 2048, CLEARSCR_WAIT_MASK=(1<<12), | |
175 SKIPEND_MASK = (1<<13), BACKLOG_MASK=(1<<14), BACKLOG_MASK_FWD=(1<<15), | |
176 BACKLOG_MASK_KOE=(1<<16), BACKLOG_WAIT_MASK=(1<<17), | |
177 ALLMASK = (CLEARSCR_MASK | WAIT_EXTRN_MASK | SAVEMASK | LOADMASK | SKIPMASK | BACKLOG_MASK | BACKLOG_MASK_FWD | BACKLOG_MASK_KOE | BACKLOG_WAIT_MASK | STATSAVE_MASK | CLEARSCR_WAIT_MASK | SKIPEND_MASK) | |
178 } Status; | |
179 Status status, status_saved, status_mask; | |
180 private: | |
181 std::string ruby_text; | |
182 bool ruby_text_flag; | |
183 unsigned int wait_time; | |
184 unsigned int old_time; | |
185 unsigned int base_time; | |
186 int text_window_number; | |
187 bool text_parsing; | |
188 TextStream text_stream; | |
189 SkipMode skip_mode; | |
190 int save_selectcount; | |
0 | 191 |
52 | 192 std::map<int, TimerAtom> timer_var; |
193 std::vector<WidTextButton*> selects; | |
194 std::vector<int> sel_backlog_pos; | |
195 string replace_name[26]; | |
196 string replace_name2[26]; | |
197 PicContainer* sel_widget; | |
198 PicWidget* backlog_widget; | |
0 | 199 |
52 | 200 vector<BacklogItem>& backlog; |
201 BacklogItem& backlog_item; | |
202 BacklogItem cur_backlog_item; | |
203 BacklogItem drawn_backlog_item; | |
0 | 204 |
52 | 205 public: |
206 PicContainer& parent; | |
207 Event::Container& event; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
208 AyuSysConfig *config; |
52 | 209 private: |
210 TextWindow* widgets[32]; | |
211 WidTimeCursor* kcursor; | |
212 Surface* sel_bg1; | |
213 Surface* sel_bg2; | |
214 Rect sel_bg_rect; | |
0 | 215 |
52 | 216 void SetCursor(int num); |
217 VarInfo wait_savedvar[2]; | |
0 | 218 |
52 | 219 public: |
220 void AddText(const char* str); | |
0 | 221 |
52 | 222 static void PressFuncSkip(void* pointer, WidButton* from); |
223 static void PressFuncLoad(void* pointer, WidButton* from); | |
224 static void PressFuncSave(void* pointer, WidButton* from); | |
225 static void PressFuncBacklog(void* pointer, WidButton* from); | |
226 static void PressFuncBacklogFwd(void* pointer, WidButton* from); | |
227 private: | |
228 static void PressFuncButton(void* pointer, WidButton* from); | |
229 static bool PressFunc(int x, int y, void* pointer); | |
0 | 230 |
52 | 231 public: |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
232 TextImpl(Event::Container& _event, PicContainer& _parent, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item); |
52 | 233 ~TextImpl(); |
234 void InitWindow(void); | |
235 void SetWindowColor(int r, int g, int b, int a, bool is_transparent); | |
236 void SetTextSpeed(int new_speed); | |
237 void SetTextWait(int new_wait); | |
238 void CreateSelect(Cmd& cmd); | |
239 void Exec(Cmd& cmd); | |
240 bool Wait(unsigned int current_time, Cmd& cmd); | |
241 void hide(void); | |
242 void show(void) { show(text_window_number); } | |
243 void show(int num); | |
244 void DrawBacklog(BacklogItem& item, Cmd& cmd); | |
245 void Save(std::string& str, bool select_save); | |
246 void Load(const char* str); | |
247 void SetSkipMode(SkipMode _mode); | |
248 void CreateSelBG(void); | |
0 | 249 }; |
250 | |
251 /**************************************************************:: | |
252 ** | |
253 ** TextImpl(implementation) | |
254 */ | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
255 TextImpl::TextImpl(Event::Container& _event, PicContainer& _parent, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item) : |
0 | 256 text(0),status(TextImpl::NORMAL), status_saved(TextImpl::NORMAL), status_mask(TextImpl::NORMAL), ruby_text_flag(false), |
257 old_time(0), base_time(0), text_window_number(0), text_parsing(false), skip_mode(SKIP_NO), save_selectcount(0), sel_widget(0), | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
258 backlog_widget(0), backlog(parent_backlog), backlog_item(parent_backlog_item), parent(_parent), event(_event), |
0 | 259 kcursor(0), sel_bg1(0), sel_bg2(0), sel_bg_rect(0,0,0,0) { |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
260 config = AyuSysConfig::GetInstance(); |
0 | 261 int i; |
262 for (i=0; i<32; i++) { | |
263 widgets[i] = 0; | |
264 } | |
265 text_stream.kanji_type = TextStream::sjis; | |
266 event.RegisterGlobalPressFunc(&PressFunc, (void*)this); | |
267 } | |
268 | |
269 TextImpl::~TextImpl() { | |
270 if (sel_widget) delete sel_widget; | |
271 int i; | |
272 for (i=0; i<32; i++) { | |
273 if (widgets[i]) delete widgets[i]; | |
274 } | |
275 if (backlog_widget) delete backlog_widget; | |
276 if (sel_bg1) parent.Root().DeleteSurface(sel_bg1); | |
277 if (sel_bg2) parent.Root().DeleteSurface(sel_bg2); | |
278 event.DeleteGlobalPressFunc(&PressFunc, (void*)this); | |
279 } | |
280 | |
281 bool TextImpl::PressFunc(int x, int y, void* pointer) { | |
282 TextImpl* t = (TextImpl*)pointer; | |
283 if (t->status == WAIT_CLICK) { | |
284 t->status = WAIT_ABORT; | |
285 } else if (t->status == WAIT_CLICK_MOUSEPOS) { | |
286 t->status = WAIT_CLICK_MOUSEPOSEND_L; | |
287 } else if (t->status_mask & CLEARSCR_WAIT_MASK) { | |
288 t->status_mask = Status(t->status_mask & (~CLEARSCR_WAIT_MASK)); | |
289 if (t->text) t->text->show(); | |
290 if (t->kcursor) { | |
291 if (t->status == WAIT_TEXT) t->kcursor->show(); | |
292 } | |
293 if (t->sel_widget) t->sel_widget->show(); | |
294 if (t->backlog_widget) t->backlog_widget->show(); | |
295 } else if (t->status_mask & BACKLOG_WAIT_MASK) { | |
296 t->status_mask = Status(t->status_mask | BACKLOG_MASK_KOE); | |
297 } else if ( (t->skip_mode & SKIP_TEXT) && (!(t->skip_mode & SKIP_IN_MENU)) ) { | |
298 if (t->status == WAIT_SELECT_INBOX) ; | |
299 else if (t->status == WAIT_SELECT_OUTBOX) ; | |
300 else if (t->status == WAIT_SELECT_VALUE) ; | |
301 else t->status_mask = Status(t->status_mask | SKIPEND_MASK); | |
302 } | |
303 return true; // event not deleted | |
304 } | |
305 void TextImpl::PressFuncButton(void* pointer, WidButton* from) { | |
306 TextImpl* t = (TextImpl*)pointer; | |
307 if (t->status != WAIT_SELECT_INBOX && t->status != WAIT_SELECT_OUTBOX) return; | |
308 vector<WidTextButton*>::iterator it; | |
309 int sel = 0; | |
310 for (it=t->selects.begin(); it != t->selects.end(); it++, sel++) { | |
311 if (from == *it) break; | |
312 } | |
313 if (it == t->selects.end()) { | |
314 fprintf(stderr,"TextImpl::PressFuncButton: Cannot find select widget\n"); | |
315 return; | |
316 } | |
317 t->status = Status(WAIT_SELECT_VALUE + sel); | |
318 return; | |
319 } | |
320 | |
321 void TextImpl::SetSkipMode(SkipMode _mode) { | |
322 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) { | |
323 if (status_mask & BACKLOG_WAIT_MASK) { // backlog mode ¤«¤éÉüµ¢ | |
324 status_mask = Status(status_mask & (~(BACKLOG_MASK|BACKLOG_MASK_FWD|BACKLOG_MASK_KOE|BACKLOG_WAIT_MASK))); | |
325 text->wid->Clear(); | |
52 | 326 if (status == WAIT_TEXT && text != NULL) { |
0 | 327 text->StartText(text_stream); |
328 text->ShowFace(backlog_item.face.c_str()); | |
329 text->wid->Flush(); | |
330 if (kcursor) kcursor->show(); | |
331 } | |
332 drawn_backlog_item.Clear(); | |
333 } | |
334 if (text) text->wid->activate(); | |
335 if (sel_widget) { | |
336 sel_widget->show(); | |
337 if (kcursor) kcursor->hide(); | |
338 } | |
339 if (backlog_widget) backlog_widget->show(); | |
340 if (status_mask & STATSAVE_MASK) { | |
341 status_mask = Status(status_mask & (~STATSAVE_MASK)); | |
342 status = status_saved; | |
343 } | |
344 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) { | |
345 if (text) text->wid->deactivate(); | |
346 if (sel_widget) sel_widget->hide(); | |
347 if (backlog_widget) backlog_widget->hide(); | |
348 } | |
349 skip_mode = _mode; | |
350 } | |
351 | |
352 /* hash_map ¤¬Íߤ·¤¤¡Ä¡Ä*/ | |
52 | 353 #include <map> |
354 #include <list> | |
0 | 355 struct SaveFaceHash { // ¥Ð¥Ã¥¯¥í¥°¥»¡¼¥Ö»þ¤Î´é²èÁü´ÉÍý¤ò¹Ô¤¦ |
356 map<string, int> facetonum; | |
357 typedef pair<string,int> Node; | |
358 typedef list<Node> List; | |
359 List container; | |
360 int id_max; | |
361 static int size_max; | |
362 SaveFaceHash() : id_max(0) { | |
363 } | |
364 void NewNode(string face, int face_id) { | |
365 facetonum[face] = face_id; | |
366 container.push_front(Node(face, face_id)); | |
367 if (container.size() > size_max) { | |
368 Node remove = container.back(); | |
369 container.pop_back(); | |
370 facetonum.erase(remove.first); | |
371 } | |
372 } | |
373 int Add(string face) { | |
374 int id; int ret = -1; | |
375 int i; List::iterator it; | |
376 if (face.empty()) return -1; | |
377 if (facetonum.find(face) == facetonum.end()) { | |
378 id = ++id_max; | |
379 NewNode(face, id); | |
380 ret = -1; | |
381 } else { | |
382 id = facetonum[face]; | |
383 for (i=0, it=container.begin(); it != container.end(); i++, it++) { | |
384 if (it->second == id) { | |
385 ret = i; | |
386 Node n = *it; | |
387 container.erase(it); | |
388 container.push_front(n); | |
389 break; | |
390 } | |
391 } | |
392 } | |
393 return ret; | |
394 } | |
395 string Get(int num) { | |
396 if (num < 0) return ""; | |
397 List::iterator it = container.begin(); | |
398 for (; it != container.end(); it++) { | |
399 if (num == 0) return it->first; | |
400 num--; | |
401 } | |
402 return ""; | |
403 } | |
404 }; | |
52 | 405 |
0 | 406 int SaveFaceHash::size_max = 20; |
407 | |
408 void TextImpl::Save(string& str, bool rollback_save) { | |
409 char buf[1024]; | |
410 str = "\n"; | |
411 str += "[TextImpl Window]\n"; | |
412 sprintf(buf, "TextImplWindow=%d\n",text_window_number); | |
413 str += buf; | |
414 if (rollback_save) { | |
415 ++save_selectcount; | |
416 BacklogItem save_item; | |
417 save_item.SetSavepos(save_selectcount); | |
418 backlog.push_back(save_item); | |
419 } | |
420 sprintf(buf, "SaveSelectCount=%d\n",save_selectcount); | |
421 | |
422 str += buf; | |
423 int i; | |
424 for (i=0; i<26; i++) { | |
425 if (replace_name2[i].empty()) continue; | |
426 sprintf(buf, "RName.%c=%s\n",i+'A',replace_name2[i].c_str()); | |
427 str += buf; | |
428 } | |
429 int cnt = 0; | |
430 vector<BacklogItem>::iterator it; | |
431 it = backlog.begin(); | |
432 if (!rollback_save) { | |
433 SaveFaceHash face_log; | |
434 do { | |
435 int cur_scn = -1; int cur_pos = -1; | |
436 sprintf(buf, "Backlog.%d=",++cnt); | |
437 str += buf; | |
438 for (; it != backlog.end(); it++) { | |
439 buf[0] = 0; int buflen = 0; | |
440 if (it->scn == -1) continue; | |
441 if (it->pos == -1 && it->scn != 0) continue; | |
442 | |
443 buf[buflen++] = ';'; | |
444 if (it->scn == 0 && it->pos == -1) { | |
445 buflen += snprintf(buf+buflen, 1000-buflen, "\"%s\".", it->text.Save().c_str()); | |
446 } else { | |
447 if (cur_scn != -1 && cur_scn != it->scn) break; // scn change | |
448 if (cur_pos != -1 && cur_pos/5000 != it->pos/5000) break; // pos exceeded | |
449 if (!it->text.container.empty()) { | |
450 buflen += snprintf(buf+buflen, 1000-buflen, "\"%s\"", it->text.Save().c_str()); | |
451 } | |
452 if (cur_scn == -1) { // scene change | |
453 buflen += snprintf(buf+buflen, 1000-buflen, ":%d:%d",it->scn,it->pos); | |
454 cur_scn = it->scn; | |
455 } else { | |
456 buflen += snprintf(buf+buflen, 1000-buflen, "%d",it->pos); | |
457 } | |
458 cur_pos = it->pos; | |
459 } | |
460 if (it->koe != -1) | |
461 buflen += snprintf(buf+buflen, 1000-buflen, ",%d",it->koe); | |
462 if (!it->face.empty()) { | |
463 if (it->koe == -1) buf[buflen++] = ','; | |
464 int face_num = face_log.Add(it->face); | |
465 if (face_num >= 0 && face_num < 20) | |
466 buflen += snprintf(buf+buflen, 1000-buflen, ",%c", 'A'+face_num); | |
467 else | |
468 buflen += snprintf(buf+buflen, 1000-buflen, ",\"%s\"", it->face.c_str()); | |
469 } | |
470 buf[buflen++] = '\0'; | |
471 if (buflen >= 1000) { // Ëü¤¬°ì¡¢¥Ð¥Ã¥¯¥í¥°£±¥¢¥¤¥Æ¥à¤ÎÂ礤µ¤¬ 1000byte ¤ò±Û¤¨¤ë¤È¤ | |
472 fprintf(stderr,"Fatal : Cannot save backlog crrectly; Please send bug report to the author.\n"); | |
473 } else str += buf; | |
474 } | |
475 str += "\n"; | |
476 } while(it != backlog.end()); | |
477 } | |
478 return; | |
479 } | |
52 | 480 |
0 | 481 void TextImpl::Load(const char* str) { |
482 if (text) text->wid->Clear(); | |
483 hide(); | |
484 text_window_number = 0; | |
485 save_selectcount = 0; | |
52 | 486 if (sel_widget != NULL) { |
0 | 487 selects.clear(); |
488 sel_backlog_pos.clear(); | |
489 delete sel_widget; | |
52 | 490 sel_widget = NULL; |
0 | 491 } |
52 | 492 if (backlog_widget != NULL) { |
0 | 493 delete backlog_widget; |
52 | 494 backlog_widget = NULL; |
0 | 495 } |
496 status = NORMAL; | |
497 status_mask = NORMAL; | |
498 status_saved = NORMAL; | |
499 text_parsing = false; | |
500 text_stream.Clear(); | |
501 // backlog.clear(); | |
502 vector<BacklogItem> new_backlog; | |
503 backlog_item.Clear(); | |
504 cur_backlog_item.Clear(); | |
505 drawn_backlog_item.Clear(); | |
506 | |
507 str = strstr(str, "\n[TextImpl Window]\n"); | |
508 | |
509 if (str) { | |
510 SaveFaceHash face_log; | |
511 str += strlen("\n[TextImpl Window]\n"); | |
512 const char* strend = str; | |
513 do { | |
514 str = strend; | |
515 | |
516 strend = strchr(str, '\n'); | |
52 | 517 if (strend == NULL) strend = str + strlen(str); |
0 | 518 else strend++; |
519 | |
520 if (str[0] == '[') break; // next section | |
521 if (strncmp(str, "TextImplWindow=",15) == 0) { | |
522 str += 15; | |
523 sscanf(str, "%d", &text_window_number); | |
524 } else if (strncmp(str, "SaveSelectCount=",16) == 0) { | |
525 str += 16; | |
526 sscanf(str, "%d", &save_selectcount); | |
527 } else if (strncmp(str, "RName.", 6) == 0) { | |
528 int n = str[6]-'A'; | |
529 if (n >= 0 && n < 26 && str[7] == '=') { | |
530 const char* s = strchr(str, '\n'); | |
531 int len = -1; | |
532 if (s) len = s-(str+8); | |
533 if (len > 0) { | |
534 replace_name2[n].assign(str+8, len); | |
535 } | |
536 } | |
537 } else if (strncmp(str, "Backlog.", 8) == 0) { | |
538 int cur_scn = -1; | |
539 int n = -1; | |
540 sscanf(str+8, "%d", &n); /* not used */ | |
541 const char* next_str = strchr(str, ';'); | |
52 | 542 while(next_str != NULL && next_str < strend) { |
0 | 543 str = next_str + 1; |
544 next_str = strchr(str, ';'); | |
52 | 545 if (next_str == NULL) next_str = strend; |
0 | 546 |
547 BacklogItem item; | |
548 if (str[0] == '"') { | |
549 const char* send = strchr(str+1, '"'); | |
52 | 550 if (send == NULL || send > next_str) continue; |
0 | 551 string tmp_str; tmp_str.assign(str+1, send-str-1); |
552 item.DeleteTextPos(); | |
553 item.text.Load(tmp_str); | |
554 str = send + 1; | |
555 } | |
556 if (str[0] == '.') { | |
557 item.DeleteTextPos(); | |
558 str++; | |
559 } else if (str[0] == ':') { | |
560 sscanf(str, ":%d:%d", &item.scn, &item.pos); | |
561 cur_scn = item.scn; | |
562 | |
563 } else { | |
564 item.scn = cur_scn; | |
565 sscanf(str, "%d", &item.pos); | |
566 } | |
567 str = strchr(str, ','); | |
52 | 568 if (str == NULL || str > next_str) goto backlog_store; |
0 | 569 str++; |
570 if (str[0] == ';' || str[0] == ',') | |
571 item.koe = -1; | |
572 else | |
573 sscanf(str, "%d", &item.koe); | |
574 str = strchr(str, ','); | |
52 | 575 if (str == NULL || str > next_str) goto backlog_store; |
0 | 576 str++; |
577 if (*str == '"') { | |
578 const char* send = strchr(str+1, '"'); | |
579 if (send) { | |
580 item.face.assign(str+1, send-str-1); | |
581 } | |
582 } else if (*str >= 'A' && *str <= 'Z') { | |
583 item.face = face_log.Get(*str - 'A'); | |
584 } | |
585 face_log.Add(item.face); | |
586 backlog_store: | |
587 new_backlog.push_back(item); | |
588 } | |
589 } | |
590 } while (*strend != 0); | |
591 } | |
592 if (new_backlog.empty() && (!backlog.empty())) { // empty ¤Ê¤é save_selectcount ¤Þ¤Ç backlog ¤ò´¬¤Ì᤹ | |
593 vector<BacklogItem>::iterator it = backlog.end(); | |
594 do { | |
595 it--; | |
596 if (it->scn == BacklogItem::SaveSelect && it->pos == save_selectcount) { | |
597 // Save °ÌÃÖ¤ò¸«¤Ä¤±¤¿¤é¤½¤ì°Ê¹ß¤ò erase | |
598 backlog.erase(it, backlog.end()); | |
599 break; | |
600 } | |
601 } while(it != backlog.begin()); | |
602 --save_selectcount; | |
603 } else { | |
604 backlog.swap(new_backlog); | |
605 } | |
606 // backlog.clear(); | |
607 } | |
608 | |
609 void TextImpl::hide(void) { | |
610 if (text) text->hide(); | |
611 if (kcursor) kcursor->hide(); | |
52 | 612 text = NULL; |
0 | 613 } |
614 void TextImpl::show(int num) { | |
615 if (num != text_window_number) { | |
616 hide(); | |
617 if (num >= 0 && num < 32 && widgets[num] != 0) { | |
618 text_window_number = num; | |
619 } | |
620 } | |
621 text = widgets[text_window_number]; | |
622 text->show(); | |
623 if (kcursor) { | |
624 int kx, ky, d; | |
625 char key[1024]; | |
626 sprintf(key, "#WINDOW.%03d.KEYCUR_MOD", text_window_number); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
627 config->GetParam(key, 3, &d, &kx, &ky); |
0 | 628 // Àµ¤·¤¯¤Ê¤¤µ¤¤¬¤¹¤ë |
629 kx += text->wid->Pic()->PosX(); | |
630 ky += text->wid->Pic()->PosY(); | |
631 // Èù̯¤Ë²¼¤Ë¤¹¤ë | |
632 ky += 8; | |
633 kcursor->Pic()->Move(kx, ky); | |
634 } | |
635 } | |
52 | 636 |
0 | 637 void TextImpl::DrawBacklog(BacklogItem& item, Cmd& cmd) { |
18 | 638 show(); |
0 | 639 text->wid->deactivate(); |
640 status_mask = Status(status_mask | BACKLOG_WAIT_MASK); | |
641 drawn_backlog_item = item; | |
642 if (item.text.container.empty()) { | |
643 // cmd ¤«¤é text ÆâÍƤòºÆ¹½À® | |
644 TextStream saved_text = text_stream; | |
645 text_stream.Clear(); | |
646 AddText(cmd.Str(cmd.args[0])); | |
647 item.text = text_stream; | |
648 text_stream = saved_text; | |
649 } | |
18 | 650 item.text.InsertColor(0, item.text.container.size(), 0xff,0xff,0); |
17 | 651 text->StartText(item.text); |
0 | 652 text->wid->Flush(); |
653 if (item.face.empty()) text->ResetFace(); | |
654 else text->ShowFace(item.face.c_str()); | |
655 if (kcursor) kcursor->hide(); | |
656 } | |
657 | |
658 void TextImpl::CreateSelBG(void) { | |
52 | 659 if (sel_bg1 != NULL || sel_bg2 != NULL) return; |
0 | 660 |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
661 const char* btnfile1 = config->GetParaStr("#SELBTN.000.NAME"); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
662 const char* btnfile2 = config->GetParaStr("#SELBTN.000.BACK"); |
0 | 663 char path[1024]; |
664 strcpy(path, btnfile1); | |
665 sel_bg1 = parent.Root().NewSurface(path); | |
52 | 666 if (sel_bg1 == NULL) { |
0 | 667 sprintf(path,"%s.g00",btnfile1); |
668 sel_bg1 = parent.Root().NewSurface(path); | |
669 } | |
670 strcpy(path, btnfile2); | |
671 sel_bg2 = parent.Root().NewSurface(path); | |
52 | 672 if (sel_bg2 == NULL) { |
0 | 673 sprintf(path,"%s.g00",btnfile2); |
674 sel_bg2 = parent.Root().NewSurface(path); | |
675 } | |
676 sel_bg_rect = Rect(0,0,0,0); | |
677 if (sel_bg1) sel_bg_rect.join(Rect(*sel_bg1)); | |
678 if (sel_bg2) sel_bg_rect.join(Rect(*sel_bg2)); | |
679 } | |
680 | |
681 void TextImpl::CreateSelect(Cmd& cmd) { | |
682 char key[1024]; | |
683 sprintf(key, "#WINDOW.%03d.SELCOM_USE",text_window_number); | |
684 int sel_type = 0; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
685 if (cmd.cmd3 == 1) config->GetParam(key, 1, &sel_type); |
38
658272d883ed
* Support (more or less) button style selects (fuuko's ones)
thib
parents:
18
diff
changeset
|
686 else if (cmd.cmd3 == 3) sel_type = 0; |
0 | 687 |
688 int sel_size = cmd.args.size() / 2; | |
689 int i; | |
690 // cur_backlog_item ¤Ë¼¡¤Ëbacklog¤ËÆþ¤ë¤Ù¤ÆâÍƤòºîÀ® | |
691 // CreateSelect() ¸å¡¢SAVEPOINT ¤Ê¤Î¤Ç¸½ºß¤Îbacklog¤ÎÆâÍÆ(Á°¤Î¥á¥Ã¥»¡¼¥¸)¤¬ | |
692 // backlog ¤ËÂåÆþ¤µ¤ì¤ë¡£¤½¤Î¸å¡¢backlog_item ¤Ë cur_backlog_item ¤ÎÆâÍƤ¬¥»¥Ã¥È¤µ¤ì¤ë(Wait()Æâ) | |
693 char backlog_sel_text[11] = {0x81,0x69,0x91,0x49,0x91,0xf0,0x8e,0x88,0x81,0x6a,0x00}; | |
694 cur_backlog_item.Clear(); | |
695 cur_backlog_item.AddTextPos(cmd); | |
696 cur_backlog_item.text.Add(backlog_sel_text); | |
697 cur_backlog_item.text.AddReturn(); | |
698 sel_backlog_pos.clear(); | |
699 for (i=0; i<sel_size; i++) { | |
700 sel_backlog_pos.push_back(cur_backlog_item.text.container.size()); | |
701 cur_backlog_item.text.Add(cmd.Str(cmd.args[i*2])); | |
702 cur_backlog_item.text.AddReturn(); | |
703 } | |
704 sel_backlog_pos.push_back(cur_backlog_item.text.container.size()); | |
705 | |
706 if (sel_type == 0) { // Princess Bride: ÁªÂò¥¦¥£¥ó¥É¥¦¤òÊÌɽ¼¨ | |
707 External_select: | |
708 CreateSelBG(); | |
709 hide(); // ¤Ê¤Î¤Ç¡¢¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Ï¾Ãµî | |
40 | 710 int baseposx, baseposy, repposx, repposy, centerx, centery; |
0 | 711 int mojisize, col1, col2; |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
712 config->GetParam("#SELBTN.000.CENTERING", 2, ¢erx, ¢ery); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
713 config->GetParam("#SELBTN.000.BASEPOS", 2, &baseposx, &baseposy); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
714 config->GetParam("#SELBTN.000.REPPOS", 2, &repposx, &repposy); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
715 config->GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
716 config->GetParam("#SELBTN.000.MOJIDEFAULTCOL", 1, &col1); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
717 config->GetParam("#SELBTN.000.MOJISELECTCOL", 1, &col2); |
0 | 718 if (col1 == col2) col2 = 1; // CLANNAD ¤Ç¤È¤ê¤¢¤¨¤º¡£ |
719 int r, g, b; | |
720 sprintf(key, "#COLOR_TABLE.%03d", col1); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
721 config->GetParam(key, 3, &r, &g, &b); |
0 | 722 Color fore(r,g,b); |
723 sprintf(key, "#COLOR_TABLE.%03d", col2); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
724 config->GetParam(key, 3, &r, &g, &b); |
0 | 725 Color seled(r,g,b); |
726 | |
727 /* ¥¦¥£¥¸¥Ã¥ÈºîÀ® */ | |
728 /* ¥¦¥£¥ó¥É¥¦ÇطʤÎÂ礤µ¤òµá¤á¤ë */ | |
729 if (baseposx == 0 && sel_bg_rect.width() != 0) | |
730 baseposx = (parent.Width()-sel_bg_rect.width()) / 2; // ¥Ü¥¿¥ó°ÌÃÖ¤ò¥»¥ó¥¿¥ê¥ó¥° | |
40 | 731 if (centerx) |
732 baseposx = (parent.Width()-sel_bg_rect.width()-sel_size*repposx) / 2; | |
733 if (centery) | |
734 baseposy = (parent.Height()-sel_bg_rect.height()-sel_size*repposy) / 2; | |
0 | 735 |
736 sel_widget = parent.create_node( Rect(0, 0, parent.Width(), parent.Height()),0); | |
737 | |
738 for (i=0; i<sel_size; i++) { | |
739 PicBase* p; | |
740 // ÇطʺîÀ® | |
741 if (sel_bg2) { | |
742 p = sel_widget->create_node(Rect(baseposx, baseposy, baseposx+sel_bg_rect.width(), baseposy+sel_bg_rect.height()),0); | |
743 p->SetSurface(sel_bg2, 0, 0); | |
744 } | |
745 if (sel_bg1) { | |
746 p = sel_widget->create_node(Rect(baseposx, baseposy, baseposx+sel_bg_rect.width(), baseposy+sel_bg_rect.height()),0); | |
747 p->SetSurface(sel_bg1, 0, 0); | |
748 } | |
749 /* ¥Ü¥¿¥óºîÀ® */ | |
750 const char* str = cmd.Str(cmd.args[i*2]); | |
751 int value = cmd.args[i*2+1].value; | |
752 while(selects.size() <= value) selects.push_back(0); // vector ¤ÎÂ礤µ¤ò¹¤²¤ë | |
753 | |
754 kconv( (const unsigned char*)str, (unsigned char*)key); | |
755 selects[value] = new WidTextButton(event, sel_widget, key, mojisize, WidTextButton::CENTER, | |
756 Rect(baseposx, baseposy, baseposx+sel_bg_rect.width(), baseposy+sel_bg_rect.height()), 1, fore, seled, Color(0,0,0,0)); | |
757 selects[value]->press_func = &PressFuncButton; | |
758 selects[value]->press_pointer = (void*)this; | |
759 | |
760 baseposx += repposx; | |
761 baseposy += repposy; | |
762 } | |
763 sel_widget->show_all(); | |
764 status = WAIT_SELECT_OUTBOX; | |
765 } else { // CLANNAD: ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦Æâ¤ËÁªÂò»èɽ¼¨ | |
766 int mojisize; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
767 config->GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize); |
0 | 768 Color fore(0xff,0xff,0xff); |
769 Color seled(0xff,0xff,0xff); | |
770 | |
771 show(); | |
52 | 772 if (text == NULL) goto External_select; // ¥Æ¥¥¹¥È¡¦¥¦¥£¥ó¥É¥¦¤òɽ¼¨¤Ç¤¤Ê¤±¤ì¤Ð³°ÉôÁªÂò»è¤Ë¤¹¤ë |
0 | 773 text->wid->Clear(); |
774 if (kcursor) kcursor->hide(); | |
775 /* ¥¦¥£¥¸¥Ã¥ÈºîÀ® : ¥Æ¥¥¹¥Èɽ¼¨ÈϰϤÈƱ¤¸*/ | |
776 int posx = text->wid->pictext->PosX(); | |
777 int posy = text->wid->pictext->PosY(); | |
778 int sel_w = text->wid->pictext->Width(); | |
779 int sel_h = text->wid->pictext->Height(); | |
780 sel_widget = text->wid->PicNode()->create_node(Rect(posx, posy, posx+sel_w, posy+sel_h), 0); | |
781 | |
782 int sel_y = 0; | |
783 for (i=0; i<sel_size; i++) { | |
784 /* ¥Ü¥¿¥óºîÀ® */ | |
785 const char* str = cmd.Str(cmd.args[i*2]); | |
786 int value = cmd.args[i*2+1].value; | |
787 while(selects.size() <= value) selects.push_back(0); // vector ¤ÎÂ礤µ¤ò¹¤²¤ë | |
788 | |
789 kconv( (const unsigned char*)str, (unsigned char*)key); | |
790 selects[value] = new WidTextButton(event, sel_widget, key, mojisize, WidTextButton::Attribute(WidTextButton::REVERSE | WidTextButton::NOPADDING), | |
791 Rect(0, sel_y, sel_w, sel_y), 1, fore, seled, Color(0,0,0,0)); | |
792 selects[value]->press_func = &PressFuncButton; | |
793 selects[value]->press_pointer = (void*)this; | |
794 | |
795 sel_y += selects[value]->Pic()->Height() + 1; | |
796 } | |
797 sel_widget->show_all(); | |
798 status = WAIT_SELECT_INBOX; | |
799 } | |
800 } | |
801 | |
802 void TextImpl::AddText(const char* str_o) { | |
803 char str[10001]; | |
52 | 804 if (text == NULL) return; |
0 | 805 /* ¤Þ¤º¡¢replace string ¤òÊÑ´¹ */ |
806 int i; | |
807 int cnt = 0; | |
808 /* ¡ö = 81 96 A-Z = 0x82 [0x60-0x79] */ | |
809 /* ¡ó = 81 93 A-Z = 0x82 [0x60-0x79] */ | |
810 for (i=0; cnt<10000 && str_o[i] != 0; i++) { | |
811 if (str_o[i] < 0) { | |
812 if ( (unsigned char)str_o[i] == 0x81 && (unsigned char)str_o[i+1] == 0x96 && (unsigned char)str_o[i+2] == 0x82) { | |
813 int c = str_o[i+3]; | |
814 if (c >= 0x60 && c <= 0x79 && replace_name[c-0x60].length() != 0) { // ̾Á°ÊÑ´¹ | |
815 i += 3; | |
816 strcpy(str+cnt, replace_name[c-0x60].c_str()); | |
817 cnt += replace_name[c-0x60].length(); | |
818 continue; | |
819 } | |
820 } else if ( (unsigned char)str_o[i] == 0x81 && (unsigned char)str_o[i+1] == 0x93 && (unsigned char)str_o[i+2] == 0x82) { | |
821 int c = str_o[i+3]; | |
822 if (c >= 0x60 && c <= 0x79 && replace_name2[c-0x60].length() != 0) { // ̾Á°ÊÑ´¹£² | |
823 i += 3; | |
824 strcpy(str+cnt, replace_name2[c-0x60].c_str()); | |
825 cnt += replace_name2[c-0x60].length(); | |
826 continue; | |
827 } | |
828 } | |
829 str[cnt++] = str_o[i++]; | |
830 } | |
831 str[cnt++] = str_o[i]; | |
832 } | |
833 str[cnt] = 0; | |
834 str[10000] = 0; | |
835 char* str_top = str; | |
836 | |
837 for (char* s = str_top; *s != 0; s++) { | |
838 // if (*(unsigned char*)s == 0xa1 && *(unsigned char*)(s+1) == 0xda) { /* euc */ | |
839 if (*(unsigned char*)s == 0x81 && *(unsigned char*)(s+1) == 0x79) { /* sjis */ | |
840 // ̾Á° | |
841 *s = 0; | |
842 if (s != str_top) text_stream.Add(str_top); | |
843 s += 2; | |
844 char* name_top = s; | |
845 for (; *s != 0; s++) { | |
846 // if (*(unsigned char*)s == 0xa1 && *(unsigned char*)(s+1) == 0xdb) { /* euc */ | |
847 if (*(unsigned char*)s == 0x81 && *(unsigned char*)(s+1) == 0x7a) { /* sjis */ | |
848 *s = 0; | |
849 s += 2; | |
850 text_stream.AddName(name_top); | |
851 break; | |
852 } | |
853 if (*s < 0 && s[1] != 0) s++; // Á´³Ñʸ»ú¤Ê¤é£²»úÈô¤Ð¤¹ | |
854 } | |
855 str_top = s; | |
856 } | |
857 if (*s == 0x0a) { | |
858 *s = 0; | |
859 text_stream.Add(str_top); | |
860 text_stream.AddReturn(); | |
861 str_top = s; | |
862 } else if (*s < 0 && s[1] != 0) s++; | |
863 } | |
864 text_stream.Add(str_top); | |
865 } | |
866 | |
867 void TextImpl::Exec(Cmd& cmd) { | |
868 if (cmd.cmd_type == CMD_TEXT) { | |
52 | 869 if (text == NULL) { |
0 | 870 show(); |
871 } | |
872 if (cmd.args.size() != 1) return; | |
873 if (ruby_text_flag) { | |
874 ruby_text = cmd.Str(cmd.args[0]); | |
875 ruby_text_flag = 0; | |
876 cmd.clear(); | |
877 return; | |
878 } | |
879 cur_backlog_item.AddTextPos(cmd); | |
880 AddText(cmd.Str(cmd.args[0])); | |
881 char debug[1024]; | |
882 kconv( (unsigned char*)cmd.Str(cmd.args[0]), (unsigned char*)debug); | |
883 eprintf("text: %s\n",debug); | |
884 if (text_parsing) | |
885 cmd.clear(); | |
886 else | |
887 cmd.cmd_type = CMD_SAVEPOINT; | |
888 text_parsing = true; /* ¥Æ¥¥¹¥ÈÂÔ¤Áľ¸å¤Î¥Æ¥¥¹¥È°ÌÃ֡᥻¡¼¥Ö°ÌÃÖ */ | |
889 return; | |
890 } | |
891 if (cmd.cmd_type != CMD_OTHER) return; | |
892 /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤ò¾Ãµî¤¹¤ë¥³¥Þ¥ó¥ÉÎà¤ò¥Á¥§¥Ã¥¯¤¹¤ë */ | |
893 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x21) { | |
894 if (cmd.cmd3 == 0x49 || cmd.cmd3 == 0x4b || cmd.cmd3 == 0x4c) { | |
895 if (text) text->ResetFace(); | |
896 cur_backlog_item.face = ""; | |
897 hide(); | |
898 } | |
899 } | |
900 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x17 && cmd.cmd3 == 0 && cmd.cmd4 == 1) { | |
901 // PlayKoe ; À¼½ÐÎÏ¥³¥Þ¥ó¥É¤ò¥Á¥§¥Ã¥¯¤¹¤ë */ | |
902 cur_backlog_item.koe = cmd.args[0].value; | |
903 } | |
904 if (cmd.cmd1 == 0 && cmd.cmd2 == 3 && cmd.cmd3 == 0x97) { // ¤¤¤¤¤Î¤«¤Ê¡¼ | |
905 | |
906 if (text) { | |
907 text->ResetFace(); | |
908 text->wid->Clear(); | |
909 } | |
910 cur_backlog_item.face = ""; | |
911 text_stream.Clear(); | |
912 hide(); | |
913 } | |
914 if (cmd.cmd1 == 0 && cmd.cmd2 == 3) { | |
915 if (cmd.cmd3 == 0x11) { // ¥Æ¥¥¹¥Èɽ¼¨¡¢¥¯¥ê¥Ã¥¯ÂÔ¤Á | |
916 if (text) { | |
917 eprintf("start\n"); | |
918 text->StartText(text_stream); | |
919 if (skip_mode & SKIP_TEXT) text->wid->Flush(); | |
920 else if (kcursor) kcursor->show(); | |
921 status = WAIT_TEXT; | |
922 text_parsing = false; | |
923 } | |
924 backlog_item = cur_backlog_item; | |
925 if (cur_backlog_item.scn == 0 && cur_backlog_item.pos == -1) backlog_item.text = text_stream; | |
926 cur_backlog_item.Clear(); | |
927 | |
928 cmd.clear(); | |
929 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // ²èÁüÉÁ²è¤ËÌá¤ë(skip»þ¤Ë¥Æ¥¥¹¥È¤¬ÉÁ²è¤µ¤ì¤ä¤¹¤¯¤¹¤ë¤¿¤á) | |
930 // ¤³¤ì¤À¤È£±¥Õ¥ì¡¼¥à£±¥Æ¥¥¹¥È¤·¤«É½¼¨¤µ¤ì¤Ê¤¯¤Ê¤ë¤Î¤ÇÃí°Õ | |
931 } else if (cmd.cmd3 == 3 || cmd.cmd3 == 0xc9) { // ¥ê¥¿¡¼¥óÁÞÆþ | |
932 text_stream.AddReturn(); | |
933 cur_backlog_item.DeleteTextPos(); | |
934 cmd.clear(); | |
935 } else if (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3e9) { // ´é¥°¥é¥Õ¥£¥Ã¥¯Êѹ¹ | |
52 | 936 if (text == NULL) { |
0 | 937 show(); |
938 } | |
939 if (cmd.cmd3 == 0x3e8) { | |
940 string s = cmd.Str(cmd.args[0]); | |
941 s += ".g00"; | |
942 if (text) text->ShowFace(s.c_str()); | |
943 cur_backlog_item.face = s; | |
944 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
945 } else if (cmd.cmd3 == 0x3e9) { // ´é¥°¥é¥Õ¥£¥Ã¥¯¾Ãµî | |
946 if (text) text->ResetFace(); | |
947 cur_backlog_item.face = ""; | |
948 cmd.cmd_type = CMD_SAVECMD_ONCE; | |
949 } | |
950 } else if (cmd.cmd3 == 0x78) { // ¥ë¥Ó´ØÏ¢ | |
52 | 951 if (text == NULL) { |
0 | 952 show(); |
953 } | |
954 if (cmd.cmd4 == 1) { | |
955 ruby_text_flag = true; | |
956 eprintf("SetRubyTextImpl."); | |
957 cmd.clear(); | |
958 } else if (cmd.cmd4 == 0) { | |
959 if (ruby_text.length() == 0) { // ¥ë¥Ó¤ò¿¶¤ë¥Æ¥¥¹¥È¤¬¤Ê¤¤ | |
960 eprintf("Cannot find ruby text.\n"); | |
961 return; | |
962 } | |
963 if (cmd.args.size() != 1) return; | |
964 char debug1[1024], debug2[1024]; | |
965 kconv( (unsigned char*)ruby_text.c_str(), (unsigned char*)debug1); | |
966 kconv( (unsigned char*)cmd.Str(cmd.args[0]), (unsigned char*)debug2); | |
967 eprintf("SetRuby. %s, %s",debug1, debug2); | |
968 text_stream.AddRuby(ruby_text.c_str(), cmd.Str(cmd.args[0])); | |
969 cur_backlog_item.DeleteTextPos(); | |
970 cmd.clear(); | |
971 } | |
972 } else if (cmd.cmd3 == 0x66) { // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î·Á | |
973 if (cmd.cmd4 == 0) { | |
974 eprintf("set text window <- %d\n",cmd.args[0].value); | |
975 if (text) show(cmd.args[0].value); | |
976 else text_window_number = cmd.args[0].value; | |
977 } else if (cmd.cmd4 == 1) { // default value | |
978 eprintf("set text window <- default\n"); | |
979 if (text) show(0); | |
980 else text_window_number = 0; | |
981 } | |
982 cmd.clear(); | |
983 } else if (cmd.cmd3 == 0x67) { // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦É½¼¨¡© | |
984 show(); | |
985 // ɽ¼¨¤ÎºÝ¤Ï¥Æ¥¥¹¥È¤ò¥¯¥ê¥¢¤·¤Ê¤¤¡© | |
986 // if (text) text->wid->Clear(); | |
987 // text_stream.Clear(); | |
988 cmd.clear(); | |
989 } else if (cmd.cmd3 == 0x68) { // ¥Æ¥¥¹¥Èɽ¼¨¡© | |
990 // Á´¥Æ¥¥¹¥Èɽ¼¨ | |
991 if (text) { | |
992 text->StartText(text_stream); | |
993 text->wid->Flush(); | |
994 } | |
995 cmd.clear(); | |
996 } else if (cmd.cmd3 == 0x98) { // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¥¯¥ê¥¢¡© | |
997 show(); | |
998 if (text) text->wid->Clear(); | |
999 text_stream.Clear(); | |
1000 cmd.clear(); | |
1001 } | |
1002 } else if (cmd.cmd1 == 0 && cmd.cmd2 == 2 && (cmd.cmd3 == 1 || cmd.cmd3 == 3) && cmd.cmd4 == 0) { | |
1003 // ÁªÂò»è | |
1004 CreateSelect(cmd); | |
39 | 1005 //FIXME: Check if it's really clean |
1006 if (text_parsing) { | |
1007 show(); | |
1008 text->StartText(text_stream); | |
1009 if (skip_mode & SKIP_TEXT) text->wid->Flush(); | |
1010 else if (kcursor) kcursor->hide(); | |
1011 text_parsing = false; | |
1012 text_stream.Clear(); | |
1013 } | |
0 | 1014 cmd.cmd_type = CMD_ROLLBACKPOINT; /* ÁªÂò»è¤Ï¥»¡¼¥Ö°ÌÃÖ / ¥·¥Ê¥ê¥ª´¬¤Ìᤷ°ÌÃÖ */ |
1015 // cmd.clear(); | |
1016 } else if (cmd.cmd1 == 0 && cmd.cmd2 == 4) { | |
1017 if (cmd.cmd3 == 0x44c) { // ¥Æ¥¥¹¥È¥¹¥¥Ã¥×³«»Ï | |
1018 status_mask = Status(SKIPMASK | status_mask); | |
1019 cmd.clear(); | |
1020 } else if (cmd.cmd3 == 0x3e8) { // ¥¦¥£¥ó¥É¥¦¾Ãµî | |
1021 status_mask = Status(CLEARSCR_MASK | status_mask); | |
1022 cmd.clear(); | |
1023 } | |
1024 } else if (cmd.cmd1 == 1 && cmd.cmd2 == 0x04) { | |
1025 /* ¥¦¥§¥¤¥È´ØϢ̿Îá */ | |
1026 if (cmd.cmd3 == 0x64 || cmd.cmd3 == 0x6f || cmd.cmd3 == 0x79) { | |
1027 eprintf("wait %dmsec\n",cmd.args[0].value); | |
1028 if (cmd.cmd3 == 0x64 && text) { | |
1029 /* 0x64 ¤À¤Èʸ»úÉÁ²èÃæ¤ÎÂÔ¤Á¤Ë»È¤¦¤³¤È¤¬¤¢¤ë */ | |
1030 text->StartText(text_stream); | |
1031 text->wid->Flush(); | |
1032 } | |
1033 if (cmd.cmd3 == 0x6f || cmd.cmd3 == 0x79) wait_time = base_time + cmd.args[0].value; | |
1034 else wait_time = old_time + cmd.args[0].value; | |
1035 status = WAIT; | |
1036 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // ²èÁüÉÁ²è¤ËÌá¤ë(skip»þ¤Ë¥Æ¥¥¹¥È¤¬ÉÁ²è¤µ¤ì¤ä¤¹¤¯¤¹¤ë¤¿¤á) | |
1037 } else if (cmd.cmd3 == 0x65 || cmd.cmd3 == 0x70) { | |
1038 eprintf("wait %dmsec(click stop)\n",cmd.args[0].value); | |
1039 if (cmd.cmd3 == 0x70) wait_time = base_time + cmd.args[0].value; | |
1040 else wait_time = old_time + cmd.args[0].value; | |
1041 status = WAIT_CLICK; | |
1042 cmd.cmd_type = CMD_WAITFRAMEUPDATE; // ²èÁüÉÁ²è¤ËÌá¤ë(skip»þ¤Ë¥Æ¥¥¹¥È¤¬ÉÁ²è¤µ¤ì¤ä¤¹¤¯¤¹¤ë¤¿¤á) | |
1043 } else if (cmd.cmd3 == 0x83) { | |
1044 /* ¥Þ¥¦¥¹¤¬¥¯¥ê¥Ã¥¯¤µ¤ì¤ë¤Þ¤ÇÂÔ¤Ä */ | |
1045 eprintf("wait and get mouse pos at click\n"); | |
1046 wait_time = old_time + 1000 * 1000; | |
1047 status = WAIT_CLICK_MOUSEPOS; | |
1048 wait_savedvar[0] = cmd.args[0]; | |
1049 wait_savedvar[1] = cmd.args[1]; | |
1050 cmd.clear(); | |
1051 } else if (cmd.cmd3 == 0x1fe) { | |
1052 eprintf("get timer value[%d]\n",cmd.args[0].value); | |
1053 if (timer_var.find(cmd.args[0].value) == timer_var.end()) { | |
1054 cmd.SetSysvar(0); | |
1055 } else { | |
1056 TimerAtom& atom = timer_var[cmd.args[0].value]; | |
1057 if (atom.total_time <= 0) atom.total_time = 1; | |
1058 int cur_tm = old_time - atom.start_time; | |
1059 if (cur_tm < 0) cur_tm = atom.total_time; // ¥¨¥é¡¼¤Ê¤éºÇ½ª»þ´Ö¤Ë¹ç¤ï¤»¤ë | |
1060 if (cur_tm > atom.total_time) cur_tm = atom.total_time; | |
1061 // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit. | |
1062 int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time); | |
1063 cmd.SetSysvar(v); | |
1064 } | |
1065 /* From rldev-1.40, reallive.kfn | |
1066 0x72 fun Timer (store) <1:Sys:00114, 1> ('counter') () | |
1067 0x73 fun CmpTimer (store) <1:Sys:00115, 1> ('time') ('time', 'counter') | |
1068 0x74 fun SetTimer <1:Sys:00116, 1> ('time') ('time', 'counter') | |
1069 | |
1070 0x78 fun ResetExTimer <1:Sys:00120, 1> ('counter') () | |
1071 0x79 fun timeEx <1:Sys:00121, 1> ('time') ('time', 'counter') | |
1072 0x7a fun timeExC (store) <1:Sys:00122, 1> ('time') ('time', 'counter') | |
1073 0x7b fun timeExC2 (store) <1:Sys:00123, 1> ('time') ('time', 'counter') // UNDOCUMENTED | |
1074 0x7c fun ExTimer (store) <1:Sys:00124, 1> ('counter') () | |
1075 0x7d fun CmpExTimer (store) <1:Sys:00125, 1> ('time') ('time', 'counter') | |
1076 0x7e fun SetExTimer <1:Sys:00126, 1> ('time') ('time', 'counter') | |
1077 */ | |
1078 | |
1079 } else if (cmd.cmd3 == 0x6e || cmd.cmd3 == 0x78) { // set basetime | |
1080 if (cmd.cmd4 == 1) { | |
1081 eprintf("set basetime\n"); | |
1082 base_time = old_time; | |
1083 cmd.clear(); | |
1084 } else if (cmd.cmd4 == 0) { // n-th base time | |
1085 int index = cmd.args[0].value; | |
1086 eprintf("set basetime (%d)\n",index); | |
1087 TimerAtom& atom = timer_var[index]; | |
1088 atom.from = 0; | |
1089 atom.to = 0; | |
1090 atom.total_time = 0; | |
1091 atom.start_time = old_time; | |
1092 cmd.clear(); | |
1093 } | |
1094 } else if (cmd.cmd3 == 0x72 || cmd.cmd3 == 0x7c) { // get time | |
1095 if (cmd.cmd4 == 1) { // get time | |
1096 eprintf("get time\n"); | |
1097 cmd.SetSysvar(old_time - base_time); | |
1098 } else if (cmd.cmd4 == 0) { // n-th get time | |
1099 int index = cmd.args[0].value; | |
1100 eprintf("get time %dth\n",index); | |
1101 if (timer_var.find(index) == timer_var.end()) cmd.SetSysvar(0); | |
1102 else cmd.SetSysvar(old_time - timer_var[index].start_time); | |
1103 } | |
1104 } else if (cmd.cmd3 == 0x26c || cmd.cmd3 == 0x270) { // set basetime(multi) | |
1105 int j = 0; | |
1106 eprintf("set basetime\n"); | |
1107 int i; for (i=0; i<cmd.argc; i++) { | |
1108 int cnt = cmd.args[j++].value; // £³¤Ê¤Î¤Ç̵»ë | |
1109 int num = cmd.args[j++].value; | |
1110 TimerAtom& atom = timer_var[num]; | |
1111 atom.from = cmd.args[j++].value; | |
1112 atom.to = cmd.args[j++].value; | |
1113 atom.total_time = cmd.args[j++].value; | |
1114 atom.start_time = old_time; | |
1115 } | |
1116 cmd.clear(); | |
1117 } else if (cmd.cmd3 == 0x276) { // get time (multi) | |
1118 eprintf("get timer value\n"); | |
1119 vector<VarInfo> args = cmd.args; | |
1120 vector<VarInfo>::iterator it = args.begin(); | |
1121 int argc = cmd.argc; | |
1122 int active_timers = 0; | |
1123 int i; for (i=0; i<argc; i++) { | |
1124 int cnt = (it++)->value; | |
1125 int num = (it++)->value; | |
1126 | |
1127 if (timer_var.find(num) == timer_var.end()) { | |
1128 cmd.SetFlagvar(*it++, 0); | |
1129 } else { | |
1130 TimerAtom& atom = timer_var[num]; | |
1131 if (atom.total_time <= 0) atom.total_time = 1; | |
1132 int cur_tm = old_time - atom.start_time; | |
1133 if (cur_tm < 0) cur_tm = atom.total_time; // ¥¨¥é¡¼¤Ê¤éºÇ½ª»þ´Ö¤Ë¹ç¤ï¤»¤ë | |
1134 if (cur_tm > atom.total_time) cur_tm = atom.total_time; | |
1135 // use 'long long'(64bit) or 'double'(80bit) type, since total_time, to and from is 32 bit. | |
1136 int v = atom.from + (long long)(atom.to-atom.from)*cur_tm/int(atom.total_time); | |
1137 cmd.SetFlagvar(*it++, v); | |
1138 if (atom.total_time != -1 && cur_tm < atom.total_time) active_timers++; | |
1139 } | |
1140 } | |
1141 if (active_timers) active_timers = 1; | |
1142 cmd.SetSysvar(active_timers); | |
1143 } else if (cmd.cmd3 == 0x1f4) { | |
1144 TimerAtom& atom = timer_var[cmd.args[0].value]; | |
1145 atom.from = cmd.args[1].value; | |
1146 atom.to = cmd.args[2].value; | |
1147 atom.total_time = cmd.args[3].value; | |
1148 atom.start_time = old_time; | |
1149 cmd.clear(); | |
1150 } else if (cmd.cmd3 == 0x3e8) { | |
1151 /* rand() */ | |
1152 int min = 0, max; | |
1153 if (cmd.args.size() == 2) { | |
1154 min = cmd.args[0].value; | |
1155 max = cmd.args[1].value; | |
1156 } else { | |
1157 max = cmd.args[1].value; | |
1158 } | |
1159 if (min > max) { | |
1160 int tmp = max; | |
1161 max = min; | |
1162 min = tmp; | |
1163 } | |
1164 int r = random(); | |
1165 if (min == max) r = min; | |
1166 else r = (r % (max-min)) + min; | |
1167 cmd.SetSysvar(r); | |
1168 } else if (cmd.cmd3 == 0x3ea) { | |
1169 int val = cmd.args[0].value; | |
1170 if (val < 0) val = -val; | |
1171 cmd.SetSysvar(val); | |
1172 } else if (cmd.cmd3 == 0x3ec) { | |
1173 /* min ¤À¤è¤Ê¤¢¡¦¡¦¡¦*/ | |
1174 int min = cmd.args[0].value; | |
1175 int max = cmd.args[1].value; | |
1176 if (max < min) min = max; | |
1177 cmd.SetSysvar(min); | |
1178 } else if (cmd.cmd3 == 0x3ef) { | |
1179 /* min */ | |
1180 int min = cmd.args[0].value; | |
1181 int max = cmd.args[1].value; | |
1182 if (max < min) min = max; | |
1183 cmd.SetSysvar(min); | |
1184 } else if (cmd.cmd3 == 0x320) { | |
1185 /* range conversion : ÈæΨ¤Ë´Ý¤á¤ë */ | |
1186 // ¥¢¥ë¥´¥ê¥º¥à¤Ï´Ö°ã¤¨¤Æ¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë | |
1187 // | |
1188 if (cmd.args.size() >= 7) { | |
1189 int val = cmd.args[0].value; | |
1190 int offset = cmd.args[1].value; | |
1191 int r_min = cmd.args[2].value; | |
1192 int v_min = cmd.args[3].value; | |
1193 int v_max = cmd.args[4].value; | |
1194 int r_max = cmd.args[5].value; | |
1195 int mode = cmd.args[6].value; | |
1196 // rldev : mode == 1,3 : 'acceralating curve', 2,3: 'decelerating curve' | |
1197 // Ê£¿ô¤Î°ú¿ô¥ê¥¹¥È(r_min¤«¤émode¤Þ¤Ç¤Î¥ê¥¹¥È)¤â¤Ä¤³¤È¤â¤¢¤ê¡¢¤½¤Î¾ì¹ç¤Ï | |
1198 // "cancel out in some way" ¤é¤·¤¤ | |
1199 if (mode == 1 || mode == 3) val += offset; | |
1200 else if (mode == 2 || mode == 4) val -= offset; | |
1201 if (cmd.args.size() != 7) | |
1202 fprintf(stderr,"\n%d/%d: cmd 01-04:0320 : XXXX NOT SUPPORTED LIST : DOUBLE RANGE CONVERSION! XXXXXXXXXXX\n",cmd.scn,cmd.pos); | |
1203 if (val < v_min) val = v_min; | |
1204 if (val > v_max) val = v_max; | |
1205 val = (r_max-r_min)*(val-v_min)/(v_max-v_min) + r_min; | |
1206 cmd.SetSysvar(val); | |
1207 } | |
1208 } else if (cmd.cmd3 == 0x3f1) { | |
1209 /* range Æâ¤Ë´Ý¤á¤ë */ | |
1210 int min = cmd.args[0].value; | |
1211 int val = cmd.args[1].value; | |
1212 int max = cmd.args[2].value; | |
1213 if (min > max) { | |
1214 int tmp = max; | |
1215 max = min; | |
1216 min = tmp; | |
1217 } | |
1218 if (val < min) val = min; | |
1219 if (val > max) val = max; | |
1220 cmd.SetSysvar(val); | |
1221 } else if (cmd.cmd3 == 0x16c && cmd.cmd4 == 0) { | |
1222 /* ¤Ê¤ó¤«¤è¤¯¤ï¤«¤é¤Ê¤¤¤±¤É¥«¡¼¥½¥ë·Á¾õÊѹ¹¤Ë¤·¤È¤¯ */ | |
1223 SetCursor(cmd.args[0].value); | |
1224 cmd.clear(); | |
1225 } else if (cmd.cmd3 == 0x0bc1) { // ¥á¥Ë¥å¡¼¤«¤é¤Î¥í¡¼¥É | |
1226 cmd.cmd_type = CMD_LOADREQ; | |
1227 } else if ( (cmd.cmd3 >= 0x8d4 && cmd.cmd3 <= 0x8d8) || cmd.cmd3 == 0x8db || cmd.cmd3 == 0x93f || cmd.cmd3 == 0xa39) { | |
1228 // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤Î¿§ÀßÄê | |
1229 int r, g, b, a, flag; | |
1230 if (cmd.cmd3 == 0xa39) { // ¸µÀßÄê¤ò¼è¤ê½Ð¤¹ | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1231 config->GetOriginalParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag); |
0 | 1232 } else { |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1233 config->GetParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag); |
0 | 1234 } |
1235 if (cmd.cmd3 == 0xa39 || cmd.cmd3 == 0x93f) { // ÀßÄê¤òÊÑ¿ô¤Ë¼è¤ê½Ð¤¹ | |
1236 if (cmd.args.size() != 5) { | |
1237 fprintf(stderr,"cmd 01-04:%4d : invalid arg size\n", cmd.cmd3); | |
1238 } else { | |
1239 vector<VarInfo> args(cmd.args); | |
1240 cmd.SetFlagvar(args[0], r); | |
1241 cmd.SetFlagvar(args[1], g); | |
1242 cmd.SetFlagvar(args[2], b); | |
1243 cmd.SetFlagvar(args[3], a); | |
1244 cmd.SetFlagvar(args[4], flag); | |
1245 } | |
1246 } else { | |
1247 switch(cmd.cmd3) { | |
1248 case 0x8d4: r = cmd.args[0].value; break; | |
1249 case 0x8d5: g = cmd.args[0].value; break; | |
1250 case 0x8d6: b = cmd.args[0].value; break; | |
1251 case 0x8d7: a = cmd.args[0].value; break; | |
1252 case 0x8d8: flag = cmd.args[0].value; break; | |
1253 case 0x8db: | |
1254 r = cmd.args[0].value; | |
1255 g = cmd.args[1].value; | |
1256 b = cmd.args[2].value; | |
1257 a = cmd.args[3].value; | |
1258 flag = cmd.args[4].value; | |
1259 break; | |
1260 } | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1261 config->SetParam("#WINDOW_ATTR", 5, r, g, b, a, flag); |
0 | 1262 SetWindowColor(r, g, b, a, flag); |
1263 cmd.clear(); | |
1264 } | |
1265 } else if (cmd.cmd3 == 0xa28 || cmd.cmd3 == 0xa29 || cmd.cmd3 == 0xa2c || cmd.cmd3 == 0xa2d || cmd.cmd3 == 0xa2e) { | |
1266 int v = 0; | |
1267 switch(cmd.cmd3) { | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1268 case 0xa28: case 0xa2d: config->GetOriginalParam("#INIT_MESSAGE_SPEED", 1, &v); break; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1269 case 0xa29: config->GetOriginalParam("#INIT_MESSAGE_SPEED_MOD", 1, &v); break; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1270 case 0xa2c: config->GetOriginalParam("#MESSAGE_KEY_WAIT_USE", 1, &v); break; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1271 case 0xa2e: config->GetOriginalParam("#MESSAGE_KEY_WAIT_TIME", 1, &v); break; |
0 | 1272 } |
1273 cmd.SetSysvar(v); | |
1274 } else if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x914 || cmd.cmd3 == 0x92f || cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8b0 || cmd.cmd3 == 0x8cb) { | |
1275 // ¥Æ¥¥¹¥Èɽ¼¨Â®ÅÙ´ØÏ¢ | |
1276 int m, speed; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1277 config->GetParam("#INIT_MESSAGE_SPEED", 1, &speed); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1278 config->GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &m); |
0 | 1279 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) fprintf(stderr,"TEXT speed %d\n",speed); |
1280 else if (cmd.cmd3 == 0x914) fprintf(stderr,"TEXT mode %d\n",m); | |
1281 else if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) fprintf(stderr,"TEXT %d, %d <- speed %d\n",m,speed,cmd.args[0].value); | |
1282 else fprintf(stderr,"TEXT %d, %d <- mode %d\n",m,speed,cmd.args[0].value); | |
1283 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) cmd.SetSysvar(speed); | |
1284 else if (cmd.cmd3 == 0x914) cmd.SetSysvar(m); | |
1285 else { | |
1286 if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) speed = cmd.args[0].value; | |
1287 else m = cmd.args[0].value; | |
1288 if (speed < 10) speed = 10; | |
1289 else if (speed > 1000) speed = 1000; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1290 config->SetParam("#INIT_MESSAGE_SPEED", 1, speed); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1291 config->SetParam("#INIT_MESSAGE_SPEED_MOD", 1, m); |
0 | 1292 if (m) speed = -1; |
1293 SetTextSpeed(speed); | |
1294 cmd.clear(); | |
1295 } | |
1296 } else if (cmd.cmd3 == 0x92e || cmd.cmd3 == 0x930 || cmd.cmd3 == 0x8ca || cmd.cmd3 == 0x8cc) { | |
1297 // ¥Æ¥¥¹¥È¥ª¡¼¥È¥â¡¼¥É´ØÏ¢ | |
1298 int m, wait; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1299 config->GetParam("#MESSAGE_KEY_WAIT_USE", 1, &m); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1300 config->GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait); |
0 | 1301 if (cmd.cmd3 == 0x92e) fprintf(stderr,"AUTO mode %d\n",m); |
1302 else if (cmd.cmd3 == 0x930) fprintf(stderr,"AUTO wait %d\n",wait); | |
1303 else if (cmd.cmd3 == 0x8ca) fprintf(stderr,"AUTO %d,%d <- mode %d\n",m,wait,cmd.args[0].value); | |
1304 else fprintf(stderr,"AUTO %d,%d <- wait %d\n",m,wait,cmd.args[0].value); | |
1305 | |
1306 if (cmd.cmd3 == 0x92e) cmd.SetSysvar(m); | |
1307 else if (cmd.cmd3 == 0x930) cmd.SetSysvar(wait); | |
1308 else { | |
1309 if (cmd.cmd3 == 0x8ca) m = cmd.args[0].value; | |
1310 else wait = cmd.args[1].value; | |
1311 if (wait < 0) wait = 0; | |
1312 else if (wait > 60000) wait = 60000; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1313 config->SetParam("#MESSAGE_KEY_WAIT_USE", 1, m); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1314 config->SetParam("#MESSAGE_KEY_WAIT_TIME", 1, wait); |
0 | 1315 if (m) SetTextWait(wait); |
1316 else SetTextWait(-1); | |
1317 cmd.clear(); | |
1318 } | |
1319 } else if (cmd.cmd3 == 0x51f && cmd.cmd4 == 0) { // replace_name2 ¤ÎÀßÄê | |
1320 int n = cmd.args[0].value; | |
1321 if (n>=0 && n<26) { | |
1322 replace_name2[n] = cmd.Str(cmd.args[1]); | |
1323 } | |
1324 cmd.clear(); | |
1325 } else if (cmd.cmd3 == 0x51e && cmd.cmd4 == 0) { // replace_name2 ¤òÆÀ¤ë | |
1326 int n = cmd.args[0].value; | |
1327 if (n >= 0 && n < 26) { | |
1328 cmd.SetStrvar(cmd.args[1], replace_name2[n]); | |
1329 } else { | |
1330 cmd.SetStrvar(cmd.args[1], ""); | |
1331 } | |
1332 } else if (cmd.cmd3 == 0x514 && cmd.cmd4 == 0) { // replace_name ¤òÆÀ¤ë | |
1333 int n = cmd.args[0].value; | |
1334 if (n >= 0 && n < 26) { | |
1335 cmd.SetStrvar(cmd.args[1], replace_name[n]); | |
1336 } else { | |
1337 cmd.SetStrvar(cmd.args[1], ""); | |
1338 } | |
1339 } | |
1340 } | |
52 | 1341 } |
0 | 1342 |
1343 extern int print_blit; | |
1344 bool TextImpl::Wait(unsigned int current_time, Cmd& cmd) { | |
52 | 1345 if (current_time != Event::Time::NEVER_WAKE) old_time = current_time; |
0 | 1346 /* |
1347 if (event.presscount(MOUSE_UP)) { | |
1348 if (text) text->Pic()->ReBlit(); | |
1349 } | |
1350 if (event.presscount(MOUSE_DOWN)) { | |
1351 print_blit^=1; | |
1352 } | |
1353 */ | |
1354 | |
1355 if (status == NORMAL && status_mask == NORMAL) return false; | |
52 | 1356 |
0 | 1357 if (status_mask & WAIT_EXTRN_MASK) return true; |
1358 if (status_mask & (BACKLOG_MASK|BACKLOG_MASK_FWD) ) { | |
1359 if (status_mask & BACKLOG_WAIT_MASK) ; | |
1360 else { | |
52 | 1361 if ( (status == WAIT_TEXT && text != NULL) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) { |
0 | 1362 if(text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) { |
1363 text->wid->Flush(); // ɽ¼¨¤òºÇ¸å¤Î¾õÂ֤ˤ¹¤ë | |
1364 } | |
52 | 1365 if (status == WAIT_TEXT && text != NULL && kcursor != NULL) kcursor->show(); |
0 | 1366 } |
1367 } | |
1368 if (status_mask & BACKLOG_MASK) { | |
1369 cmd.cmd_type = CMD_BACKLOGREQ; | |
1370 } else { | |
1371 cmd.cmd_type = CMD_BACKLOGREQ_FWD; | |
1372 } | |
1373 status_mask = Status(status_mask & ~(BACKLOG_MASK|BACKLOG_MASK_FWD)); | |
1374 return false; | |
1375 } | |
1376 if ( (status_mask & BACKLOG_WAIT_MASK) && (status_mask & BACKLOG_MASK_KOE)) { | |
1377 if (drawn_backlog_item.koe != -1) { | |
1378 cmd.cmd_type = CMD_OTHER; | |
1379 cmd.cmd1 = 1; | |
1380 cmd.cmd2 = 0x17; | |
1381 cmd.cmd3 = 0; | |
1382 cmd.cmd4 = 1; | |
1383 cmd.args.clear(); | |
1384 cmd.args.push_back(VarInfo(drawn_backlog_item.koe)); | |
1385 cmd.args.push_back(VarInfo(0)); | |
1386 } | |
1387 status_mask = Status(status_mask & ~BACKLOG_MASK_KOE); | |
1388 return false; | |
1389 } | |
1390 if (skip_mode & SKIP_IN_MENU) return false; | |
1391 if (status_mask & SAVEMASK) { | |
1392 cmd.cmd_type = CMD_SAVEREQ; | |
1393 status_mask = Status(status_mask & ~SAVEMASK); | |
1394 return false; | |
1395 } | |
1396 if (status_mask & LOADMASK) { | |
1397 cmd.cmd_type = CMD_LOADREQ; | |
1398 status_mask = Status(status_mask & ~LOADMASK); | |
1399 return false; | |
1400 } | |
1401 if (status_mask & SKIPEND_MASK) { | |
1402 if ( (skip_mode & SKIP_TEXT) && (skip_mode & SKIPEND_TEXT)) { | |
1403 if (skip_mode & SKIPEND_KEY) { // shift skip Ãæ | |
1404 SkipMode new_mode = SkipMode(skip_mode & (~SKIPEND_TEXT)); | |
1405 if (new_mode & (SKIP_GRP_NOEFFEC || SKIP_GRP_NODRAW)) | |
1406 new_mode = SkipMode(new_mode & (~SKIP_GRP_FAST)); | |
1407 cmd.SetSysvar(TYPE_SYS_SKIPMODE, new_mode); | |
1408 } else { | |
1409 cmd.SetSysvar(TYPE_SYS_SKIPMODE, SKIP_NO); | |
1410 } | |
1411 } | |
1412 status_mask = Status(status_mask & ~SKIPEND_MASK); | |
1413 } | |
1414 if (status_mask & SKIPMASK) { | |
1415 if (skip_mode != SKIP_NO) { | |
1416 cmd.SetSysvar(TYPE_SYS_SKIPMODE, skip_mode | SKIPEND_TEXT); | |
1417 } else { | |
1418 cmd.SetSysvar(TYPE_SYS_SKIPMODE, SKIP_TEXT | SKIP_GRP_FAST | SKIPEND_TEXT); | |
1419 } | |
1420 status_mask = Status(status_mask & ~SKIPMASK); | |
1421 return false; | |
1422 } | |
1423 if (event.presscount(MOUSE_RIGHT)) { | |
52 | 1424 if ( (status == WAIT_TEXT && text != NULL) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) { |
0 | 1425 if(text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) { |
1426 text->wid->Flush(); // ɽ¼¨¤òºÇ¸å¤Î¾õÂ֤ˤ¹¤ë | |
1427 } | |
1428 cmd.cmd_type = CMD_MENUREQ; | |
1429 if (!(status_mask & STATSAVE_MASK)) { | |
1430 status_saved = status; | |
1431 status_mask = Status(status_mask | STATSAVE_MASK); | |
1432 } | |
1433 return false; | |
1434 } else if (status == WAIT_CLICK_MOUSEPOS) { | |
1435 status = WAIT_CLICK_MOUSEPOSEND_R; | |
1436 } | |
1437 } | |
1438 if (event.presscount(MOUSE_UP)) { | |
52 | 1439 if ( (status == WAIT_TEXT && text != NULL) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) { |
0 | 1440 if(text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) { |
1441 text->wid->Flush(); // ɽ¼¨¤òºÇ¸å¤Î¾õÂ֤ˤ¹¤ë | |
1442 } | |
1443 cmd.cmd_type = CMD_BACKLOGREQ; | |
1444 if (!(status_mask & STATSAVE_MASK)) { | |
1445 status_saved = status; | |
1446 status_mask = Status(status_mask | STATSAVE_MASK); | |
1447 } | |
1448 return false; | |
1449 } | |
1450 } | |
1451 if (status_mask & CLEARSCR_MASK) { | |
52 | 1452 if ( (status == WAIT_TEXT && text != NULL ) || status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) { |
0 | 1453 if (skip_mode) skip_mode = SKIP_NO; |
1454 if (text && text->wid->status != WidText::PREPARE && text->wid->status != WidText::WAIT && text->wid->status != WidText::WAIT2) { | |
1455 text->wid->Flush(); // ɽ¼¨¤òºÇ¸å¤Î¾õÂ֤ˤ¹¤ë | |
1456 return true; | |
1457 } | |
1458 status_mask = Status(status_mask & (~CLEARSCR_MASK) | CLEARSCR_WAIT_MASK); | |
52 | 1459 if (text != NULL) text->hide(); |
1460 if (kcursor != NULL) kcursor->hide(); | |
1461 if (sel_widget != NULL) sel_widget->hide(); | |
1462 if (backlog_widget != NULL) backlog_widget->hide(); | |
0 | 1463 return true; |
1464 } | |
1465 status_mask = Status(status_mask & (~CLEARSCR_MASK)); | |
1466 return false; | |
1467 } | |
1468 if (status_mask & CLEARSCR_WAIT_MASK) { | |
1469 return true; | |
1470 } | |
1471 if (status == WAIT_TEXT) { | |
52 | 1472 if (text == NULL) { |
1473 status = NORMAL; | |
1474 return false; | |
1475 } | |
0 | 1476 if (skip_mode & SKIP_TEXT) { |
1477 } else if (text->wid->status != WidText::PREPARE) { | |
1478 return true; | |
1479 } | |
52 | 1480 if (kcursor != NULL) kcursor->hide(); |
0 | 1481 text_stream.Clear(); |
1482 status = NORMAL; | |
1483 cmd.cmd_type = CMD_TEXTEND; | |
1484 return false; | |
1485 } | |
1486 if (status == WAIT) { | |
1487 if (skip_mode & SKIP_TEXT) ; | |
1488 else if (wait_time > current_time) return true; | |
1489 status = NORMAL; | |
1490 } else if (status == WAIT_CLICK) { | |
1491 if (skip_mode & SKIP_TEXT) ; | |
1492 else if (wait_time > current_time) return true; | |
1493 status = NORMAL; | |
1494 cmd.SetSysvar(0); | |
1495 } else if (status == WAIT_ABORT) { | |
1496 cmd.SetSysvar(1); | |
1497 status = NORMAL; | |
1498 } else if (status == WAIT_CLICK_MOUSEPOS || status == WAIT_CLICK_MOUSEPOSEND_L || status == WAIT_CLICK_MOUSEPOSEND_R) { | |
1499 if (status == WAIT_CLICK_MOUSEPOS && (skip_mode & SKIP_TEXT) == 0) return true; // keep wait | |
1500 else { | |
1501 int x, y; | |
1502 event.MousePos(x,y); | |
1503 if (status == WAIT_CLICK_MOUSEPOS) x = y = 0; // skip mode | |
1504 cmd.clear(); | |
1505 cmd.SetFlagvar(wait_savedvar[0], x); | |
1506 cmd.SetFlagvar(wait_savedvar[1], y); | |
1507 if (status == WAIT_CLICK_MOUSEPOSEND_R) cmd.SetSysvar(-1); | |
1508 else cmd.SetSysvar(0); | |
1509 status = NORMAL; | |
1510 } | |
1511 } else if (status == WAIT_SELECT_INBOX || status == WAIT_SELECT_OUTBOX) { | |
1512 return true; | |
1513 } else if ( int(status) >= WAIT_SELECT_VALUE) { | |
1514 int sel_val = int(status) - WAIT_SELECT_VALUE; | |
1515 cmd.SetSysvar(sel_val); | |
1516 selects.clear(); | |
1517 delete sel_widget; | |
52 | 1518 sel_widget = NULL; |
0 | 1519 status = NORMAL; |
1520 // CreateSelect() ¤ÇºîÀ®¤µ¤ì¤¿ cur_backlog_item ¤ò backlog_item ¤ØÈ¿±Ç¤µ¤»¤ë | |
1521 cur_backlog_item.text.InsertColor(sel_backlog_pos[sel_val], sel_backlog_pos[sel_val+1], 0xff, 0, 0); | |
1522 backlog_item = cur_backlog_item; | |
1523 cur_backlog_item.Clear(); | |
1524 } | |
1525 return false; | |
1526 } | |
1527 | |
1528 void clearbtn_press(void* pointer, WidButton* button) { | |
52 | 1529 if (pointer == NULL) return; |
0 | 1530 TextImpl* t = (TextImpl*)pointer; |
1531 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::CLEARSCR_MASK); | |
1532 return; | |
1533 } | |
1534 void TextImpl::PressFuncSkip(void* pointer, WidButton* from) { | |
52 | 1535 if (pointer == NULL) return; |
0 | 1536 TextImpl* t = (TextImpl*)pointer; |
1537 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::SKIPMASK); | |
1538 return; | |
1539 } | |
1540 void TextImpl::PressFuncLoad(void* pointer, WidButton* from) { | |
52 | 1541 if (pointer == NULL) return; |
0 | 1542 TextImpl* t = (TextImpl*)pointer; |
1543 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::LOADMASK); | |
1544 return; | |
1545 } | |
1546 void TextImpl::PressFuncSave(void* pointer, WidButton* from) { | |
52 | 1547 if (pointer == NULL) return; |
0 | 1548 TextImpl* t = (TextImpl*)pointer; |
1549 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::SAVEMASK); | |
1550 return; | |
1551 } | |
1552 void TextImpl::PressFuncBacklog(void* pointer, WidButton* from) { | |
52 | 1553 if (pointer == NULL) return; |
0 | 1554 TextImpl* t = (TextImpl*)pointer; |
1555 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::BACKLOG_MASK); | |
1556 return; | |
1557 } | |
1558 void TextImpl::PressFuncBacklogFwd(void* pointer, WidButton* from) { | |
52 | 1559 if (pointer == NULL) return; |
0 | 1560 TextImpl* t = (TextImpl*)pointer; |
1561 t->status_mask = TextImpl::Status(t->status_mask | TextImpl::BACKLOG_MASK_FWD); | |
1562 return; | |
1563 } | |
1564 void movebtn_drag(int from_x, int from_y, int x, int y, void* pointer, WidButton* button) { | |
52 | 1565 if (pointer == NULL) return; |
0 | 1566 fprintf(stderr,"drag.\n"); |
1567 } | |
52 | 1568 |
0 | 1569 #define BTNCNT 10 |
47
5f548e5957a8
* get rid of the "deprecated conversion from string constant to ‘char*’" warnings
thib
parents:
43
diff
changeset
|
1570 static const char* btnname[BTNCNT] = { |
0 | 1571 "MOVE", |
1572 "CLEAR", | |
1573 "READJUMP", | |
1574 "AUTOMODE", | |
1575 "MSGBK", | |
1576 "MSGBKLEFT", | |
1577 "MSGBKRIGHT", | |
1578 "EXBTN_000", | |
1579 "EXBTN_001", | |
1580 "EXBTN_002" | |
1581 }; | |
52 | 1582 |
0 | 1583 static int btnpos[BTNCNT] = { // g00 ¥Õ¥¡¥¤¥ëÆâ¤Î¥Ü¥¿¥ó¾ðÊó¤Î°ÌÃÖ |
1584 // 0, 1, 13, 12, 2, 3, 4, 5, 6, 7 // princess bride? | |
1585 0, 1, 13, 14, 2, 3, 4, 5, 6, 7 // tomoyo after? | |
1586 }; | |
52 | 1587 |
0 | 1588 static WidButton::PressFunc btnpress[BTNCNT] = { |
1589 0, clearbtn_press, &TextImpl::PressFuncSkip,0,&TextImpl::PressFuncBacklogFwd,&TextImpl::PressFuncBacklog,&TextImpl::PressFuncBacklogFwd,&TextImpl::PressFuncSave,&TextImpl::PressFuncLoad,0 | |
1590 }; | |
52 | 1591 |
0 | 1592 static WidButton::DragFunc btndrag[BTNCNT] = { |
1593 movebtn_drag, 0,0,0,0, 0,0,0,0, 0 | |
1594 }; | |
1595 | |
1596 void TextImpl::SetTextSpeed(int speed) { | |
1597 // 100 : 10char / sec | |
1598 // 10 : 100char / sec | |
1599 // text widget: | |
1600 if (speed <= 0) speed = -1; | |
1601 else if (speed > 1000) speed = 1; | |
1602 else speed = 1000 / speed; | |
1603 int i; | |
1604 for (i=0; i<32; i++) | |
1605 if (widgets[i]) widgets[i]->wid->SetSpeed(speed); | |
1606 } | |
52 | 1607 |
0 | 1608 void TextImpl::SetTextWait(int wait) { |
1609 int i; | |
1610 for (i=0; i<32; i++) | |
1611 if (widgets[i]) widgets[i]->wid->SetWait(wait); | |
1612 } | |
1613 | |
1614 void TextImpl::SetWindowColor(int r, int g, int b, int a, bool is_transparent) { | |
1615 char key[1024]; | |
1616 int w; | |
1617 | |
1618 for (w=0; w<32; w++) { | |
52 | 1619 if (widgets[w] == NULL) continue; |
0 | 1620 sprintf(key, "#WAKU.%03d.000.BACK", w); |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1621 const char* back = config->GetParaStr(key); |
52 | 1622 if (back == NULL || back[0] == 0) continue; |
0 | 1623 sprintf(key, "%s.g00", back); |
1624 Surface* back_s = parent.Root().NewSurface(key); | |
52 | 1625 if (back_s == NULL) continue; |
0 | 1626 Rect rect(*back_s); |
1627 Surface* new_s = parent.Root().NewSurface(rect.width(), rect.height(), ALPHA_MASK); | |
1628 DSurfaceMove(back_s, rect, new_s, rect); | |
1629 DSurfaceFillA(new_s, rect, r, g, b, a); | |
1630 widgets[w]->wid->Pic()->SetSurface(new_s, 0, 0); | |
1631 widgets[w]->wid->Pic()->SetSurfaceFreeFlag(1); | |
1632 if (!is_transparent) | |
1633 widgets[w]->wid->Pic()->SetSurfaceAttribute(PicBase::BLIT_MULTIPLY); | |
1634 parent.Root().DeleteSurface(back_s); | |
1635 } | |
1636 } | |
1637 | |
1638 void TextImpl::SetCursor(int cursor_no) { | |
1639 char key[1024]; | |
1640 sprintf(key, "#CURSOR.%03d.NAME", cursor_no); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1641 string path = config->GetParaStr(key); |
0 | 1642 if (path.length() == 0) return; // ̾Á°¤Ê¤· |
1643 path += ".pdt"; | |
1644 int w,h,cont,speed; | |
1645 sprintf(key, "#CURSOR.%03d.SIZE", cursor_no); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1646 config->GetParam(key, 2, &w, &h); |
0 | 1647 sprintf(key, "#CURSOR.%03d.CONT", cursor_no); |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1648 config->GetParam(key, 1, &cont); |
0 | 1649 sprintf(key, "#CURSOR.%03d.SPEED", cursor_no); |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1650 config->GetParam(key, 1, &speed); |
0 | 1651 |
1652 // speed ¤Ç£±¼þ¡¢cont ²óÊѲ½ | |
52 | 1653 if (kcursor != NULL) delete kcursor; |
0 | 1654 |
1655 kcursor = new WidTimeCursor(event, speed/cont, &parent, path.c_str(), 0, 0, w, 0, cont, Rect(0,0,w,h)); | |
1656 int i; | |
1657 for (i=0; i<32; i++) { | |
1658 if (widgets[i]) widgets[i]->wid->SetCursor(kcursor); | |
1659 } | |
1660 } | |
1661 | |
52 | 1662 void kconv(const unsigned char* src, unsigned char* dest) { //FIXME: code duplication? |
0 | 1663 /* input : sjis output: euc */ |
1664 while(*src) { | |
1665 unsigned int high = *src++; | |
1666 if (high < 0x80) { | |
1667 /* ASCII */ | |
1668 *dest++ = high; continue; | |
1669 } else if (high < 0xa0) { | |
1670 /* SJIS */ | |
1671 high -= 0x71; | |
1672 } else if (high < 0xe0) { | |
1673 /* hankaku KANA */ | |
1674 *dest++ = 0x8e; *dest++ = high; | |
1675 continue; | |
1676 } else { /* high >= 0xe0 : SJIS */ | |
1677 high -= 0xb1; | |
1678 } | |
1679 /* SJIS convert */ | |
1680 high = (high<<1) + 1; | |
1681 | |
1682 unsigned int low = *src++; | |
1683 if (low == 0) break; /* incorrect code */ | |
1684 if (low > 0x7f) low--; | |
1685 if (low >= 0x9e) { | |
1686 low -= 0x7d; | |
1687 high++; | |
1688 } else { | |
1689 low -= 0x1f; | |
1690 } | |
1691 *dest++ = high | 0x80; *dest++ = low | 0x80; | |
1692 } | |
1693 *dest = 0; | |
1694 } | |
52 | 1695 |
1696 void kconv_rev(const unsigned char* src, unsigned char* dest) { //FIXME: code duplication? | |
0 | 1697 /* input : euc output: sjis */ |
1698 while(*src) { | |
1699 unsigned int high = *src++; | |
1700 if (high < 0x80) { | |
1701 /* ASCII */ | |
1702 *dest++ = high; continue; | |
1703 } else if (high == 0x8e) { /* hankaku KANA */ | |
1704 high = *src; | |
1705 if (high >= 0xa0 && high < 0xe0) | |
1706 *dest++ = *src++; | |
1707 continue; | |
1708 } else { | |
1709 unsigned int low = *src++; | |
1710 if (low == 0) break; /* incorrect code , EOS */ | |
1711 if (low < 0x80) continue; /* incorrect code */ | |
1712 /* convert */ | |
1713 low &= 0x7f; high &= 0x7f; | |
1714 low += (high & 1) ? 0x1f : 0x7d; | |
1715 high = (high-0x21)>>1; | |
1716 high += (high > 0x1e) ? 0xc1 : 0x81; | |
1717 *dest++ = high; | |
1718 if (low > 0x7f) low++; | |
1719 *dest++ = low; | |
1720 } | |
1721 } | |
1722 *dest = 0; | |
1723 } | |
52 | 1724 |
0 | 1725 string kconv(const string& s) { |
1726 char* out = new char[s.length()*2+100]; | |
1727 kconv((const unsigned char*)s.c_str(), (unsigned char*)out); | |
1728 string ret = out; | |
1729 delete[] out; | |
1730 return ret; | |
1731 } | |
52 | 1732 |
0 | 1733 string kconv_rev(const string& s) { |
1734 char* out = new char[s.length()*2+100]; | |
1735 kconv_rev((const unsigned char*)s.c_str(), (unsigned char*)out); | |
1736 string ret = out; | |
1737 delete[] out; | |
1738 return ret; | |
1739 } | |
1740 | |
1741 /**************************************************************:: | |
1742 ** | |
1743 ** Text | |
1744 */ | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1745 Text::Text(Event::Container& _event, PicContainer& _parent) { |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1746 pimpl = new TextImpl(_event, _parent, backlog, backlog_item); |
0 | 1747 } |
52 | 1748 |
0 | 1749 Text::~Text() { |
1750 delete pimpl; | |
52 | 1751 pimpl = NULL; |
0 | 1752 } |
52 | 1753 |
0 | 1754 void Text::InitWindow(void) { |
1755 pimpl->InitWindow(); | |
1756 } | |
52 | 1757 |
0 | 1758 void Text::Exec(Cmd& cmd) { |
1759 pimpl->Exec(cmd); | |
1760 } | |
52 | 1761 |
0 | 1762 bool Text::Wait(unsigned int current_time, Cmd& cmd) { |
1763 return pimpl->Wait(current_time, cmd); | |
1764 } | |
52 | 1765 |
0 | 1766 void Text::SetSkipMode(SkipMode mode) { |
1767 pimpl->SetSkipMode(mode); | |
1768 } | |
52 | 1769 |
0 | 1770 void Text::Save(std::string& str, bool select_save) { |
1771 pimpl->Save(str, select_save); | |
1772 } | |
52 | 1773 |
0 | 1774 void Text::Load(const char* str) { |
1775 pimpl->Load(str); | |
1776 } | |
1777 | |
1778 void Text::hide(void) { | |
1779 pimpl->hide(); | |
1780 } | |
52 | 1781 |
0 | 1782 void Text::show(void) { |
1783 pimpl->show(); | |
1784 } | |
52 | 1785 |
0 | 1786 void Text::show(int num) { |
1787 pimpl->show(num); | |
1788 } | |
52 | 1789 |
0 | 1790 void Text::DrawBacklog(BacklogItem& item, Cmd& cmd) { |
1791 pimpl->DrawBacklog(item, cmd); | |
1792 } | |
52 | 1793 |
0 | 1794 /**************************************************************:: |
1795 ** | |
1796 ** BacklogItem | |
1797 */ | |
1798 | |
1799 BacklogItem::BacklogItem(void) { | |
1800 scn = -1; | |
1801 pos = -1; | |
1802 koe = -1; | |
1803 face = ""; | |
1804 text.kanji_type = TextStream::sjis; | |
1805 } | |
52 | 1806 |
0 | 1807 void BacklogItem::Clear(void) { |
1808 scn = -1; | |
1809 pos = -1; | |
1810 koe = -1; | |
1811 text.Clear(); | |
1812 } | |
52 | 1813 |
0 | 1814 void BacklogItem::AddTextPos(Cmd& cmd) { |
1815 if (scn == -1 && pos == -1) { | |
1816 scn = cmd.scn; | |
1817 pos = cmd.pos; | |
1818 return; | |
1819 } | |
1820 DeleteTextPos(); | |
1821 } | |
52 | 1822 |
0 | 1823 void BacklogItem::DeleteTextPos(void) { |
1824 scn = 0; | |
1825 pos = -1; | |
1826 } | |
52 | 1827 |
0 | 1828 BacklogItem& BacklogItem::operator =(const BacklogItem& p) { |
1829 scn = p.scn; | |
1830 pos = p.pos; | |
1831 koe = p.koe; | |
1832 face = p.face; | |
1833 text = p.text; | |
1834 } | |
52 | 1835 |
0 | 1836 void BacklogItem::SetSavepos(int p) { |
1837 Clear(); | |
1838 scn = SaveSelect; | |
1839 pos = p; | |
1840 } | |
1841 | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1842 Rect TextWindow::WakuSize(PicContainer& pic, int waku_no) { |
0 | 1843 char key[1024]; |
1844 sprintf(key, "#WAKU.%03d.000.NAME", waku_no); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1845 const char* name = AyuSysConfig::GetInstance()->GetParaStr(key); |
52 | 1846 if (name == NULL) return Rect(0,0,0,0); |
0 | 1847 std::string str = name; str += ".g00"; |
1848 Surface* s = pic.Root().NewSurface(str.c_str()); | |
52 | 1849 if (s == NULL) return Rect(0,0,0,0); |
0 | 1850 Rect r(*s); |
1851 pic.Root().DeleteSurface(s); | |
1852 return r; | |
1853 } | |
52 | 1854 |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1855 void TextWindow::MakeWaku(PicContainer& pic, Event::Container& event, int waku_no, int window_no, bool* use_btn, void* callback) { |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1856 AyuSysConfig *config = AyuSysConfig::GetInstance(); |
0 | 1857 char key[1024]; |
1858 std::string str; | |
1859 /* ÏȤòºîÀ® */ | |
1860 sprintf(key, "#WAKU.%03d.000.NAME", waku_no); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1861 const char* name = config->GetParaStr(key); |
52 | 1862 if (name != NULL && name[0] == 0) name = NULL; |
0 | 1863 sprintf(key, "#WAKU.%03d.000.BACK", waku_no); |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1864 const char* back = config->GetParaStr(key); |
52 | 1865 if (back != NULL && back[0] == 0) back = NULL; |
0 | 1866 sprintf(key, "#WAKU.%03d.000.BTN", waku_no); |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1867 const char* btn = config->GetParaStr(key); |
52 | 1868 if (btn != NULL && btn[0] == 0) btn = NULL; |
0 | 1869 |
52 | 1870 if (name == NULL && back == NULL && btn == NULL) return; |
0 | 1871 |
1872 /* ¤Þ¤º¡¢¥Æ¥¥¹¥ÈÇطʤòÀßÄê */ | |
52 | 1873 if (back != NULL) { |
0 | 1874 str = back; str += ".g00"; |
52 | 1875 int rc, gc, bc, ac, flag; |
0 | 1876 char key[1024]; |
1877 sprintf(key, "#WINDOW.%03d.ATTR", window_no); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1878 if (config->GetParam(key, 5, &rc, &gc, &bc, &ac, &flag) == -1) { |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1879 config->GetParam("#WINDOW_ATTR", 5, &rc, &gc, &bc, &ac, &flag); |
0 | 1880 } |
1881 Surface* back_s = pic.Root().NewSurface(str.c_str()); | |
52 | 1882 if (back_s != NULL) { |
0 | 1883 Rect rect(*back_s); |
1884 Surface* s = pic.Root().NewSurface(rect.width(), rect.height(), ALPHA_MASK); | |
1885 DSurfaceMove(back_s, rect, s, rect); | |
1886 DSurfaceFillA(s, rect, rc, gc, bc, ac); // Æ©ÌÀÅÙÀßÄê | |
1887 pic.SetSurface(s, 0, 0); | |
1888 pic.SetSurfaceFreeFlag(1); | |
1889 if (flag == 0) wid->Pic()->SetSurfaceAttribute(PicBase::BLIT_MULTIPLY); | |
1890 pic.Root().DeleteSurface(back_s); | |
1891 } | |
1892 } | |
1893 /* ¤½¤ÎÁ°¤ËÏȾþ¤ê¤òÀßÄê */ | |
52 | 1894 if (name != NULL) { |
0 | 1895 str = name; str += ".g00"; |
1896 Surface* s = pic.Root().NewSurface(str.c_str()); | |
1897 if (s) { | |
1898 Rect rect(*s); | |
1899 pic.Root().DeleteSurface(s); | |
1900 PicBase* p = pic.create_leaf(Rect(0, 0, rect.width(), rect.height()),0); | |
1901 p->SetSurface(str.c_str(), 0, 0); | |
1902 p->ZMove(ZMOVE_BOTTOM); | |
1903 p->show(); | |
1904 } | |
1905 } | |
52 | 1906 if (btn == NULL) return; |
1907 if (use_btn == NULL) return; | |
0 | 1908 // ¥Ü¥¿¥ó¤ÎºîÀ® |
1909 // »ÈÍѤ¹¤ë¥Ü¥¿¥ó¤Ë¤Ä¤¤¤Æ¤Ï¡¢É¬Íפ˱þ¤¸¤Æ show() ¤¹¤ë¤³¤È | |
1910 | |
1911 /* ¥Ü¥¿¥ó¤Î°ÌÃÖ¾ðÊó¤òµá¤á¤ë */ | |
1912 str = btn; str += ".g00"; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1913 ARCINFO* info = FileSearcher::GetInstance()->Find(FileSearcher::PDT, str.c_str(), "g00"); |
52 | 1914 if (info == NULL) return; // cannot find file |
0 | 1915 const char* data = info->Read(); |
1916 /* g00 ¥Õ¥¡¥¤¥ë¤Î¥Ø¥Ã¥ÀÉôʬ¤Ë°ÌÃÖ¾ðÊó¤ÏÆþ¤Ã¤Æ¤¤¤ë */ | |
1917 /* ¸ºß¤·¤Ê¤±¤ì¤Ð¥Ü¥¿¥ó²èÁü¤Ç¤Ï¤Ê¤¤ */ | |
52 | 1918 if (data == NULL || *data != 2) { |
0 | 1919 delete info; |
1920 return; | |
1921 } | |
1922 int index_count = read_little_endian_int(data+5); // 0x70 == 112 ( 8 ¸Ä¤º¤Ä¥°¥ë¡¼¥×¤Ê¤Î¤Ç¡¢14¸Ä¤Î¥Ü¥¿¥ó ) ¤¬É¸½à | |
1923 int i; | |
1924 for (i=0; i<BTNCNT; i++) { | |
1925 if (!use_btn[i]) continue; | |
1926 if (btnpos[i]*8 >= index_count) { | |
1927 continue; // ¥Ü¥¿¥ó¤¬Â¸ºß¤·¤Ê¤¤ | |
1928 } | |
1929 int x, y, w, h; | |
1930 sprintf(key, "#WAKU.%03d.000.%s_BOX", waku_no, btnname[i]); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1931 if (config->GetParam(key, 5, 0, &x, &y, &w, &h) == -1) continue; |
0 | 1932 int sx, sy, sdx, sdy, cnt; |
1933 const char* d = data + 9 + btnpos[i]*24*8; | |
1934 sx = read_little_endian_int(d); | |
1935 sy = read_little_endian_int(d+4); | |
1936 sdx = read_little_endian_int(d+24) - sx; | |
1937 sdy = read_little_endian_int(d+24 + 4) - sy; | |
1938 cnt = 2; | |
1939 if (sx+sdx*2 == read_little_endian_int(d+2*24) && sy+sdy*2 == read_little_endian_int(d+2*24+4)) cnt = 3; | |
1940 WidButton* wid = new WidButton(event, &pic, str.c_str(), sx, sy, sdx, sdy, cnt, Rect(x, y, x+w, y+h), 1); | |
1941 if (btnpress[i]) { wid->press_func = btnpress[i]; wid->press_pointer = callback;} | |
1942 if (btndrag[i]) { wid->drag_func = btndrag[i]; wid->drag_pointer = callback;} | |
1943 } | |
1944 delete info; | |
1945 } | |
1946 | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1947 TextWindow::TextWindow(PicContainer& parent, Event::Container& event, int win_no, void* callback) : |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1948 wid(0), name_visible(true),name(0),name_container(0), face(0) |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1949 { |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1950 AyuSysConfig *config = AyuSysConfig::GetInstance(); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1951 int i; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1952 for (i=0; i<8; i++) |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1953 face_pics[i]=0; |
0 | 1954 char key[1024]; |
1955 bool use_btn[BTNCNT]; | |
1956 int size, rep1, rep2, cntw, cnth, mposx, mposy, posd, posx, posy, minx, miny, waku_no, ruby; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1957 sprintf(key, "#WINDOW.%03d.MOJI_SIZE", win_no); if (config->GetParam(key, 1, &size) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1958 sprintf(key, "#WINDOW.%03d.MOJI_REP", win_no); if (config->GetParam(key, 2, &rep1, &rep2) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1959 sprintf(key, "#WINDOW.%03d.MOJI_CNT", win_no); if (config->GetParam(key, 2, &cntw, &cnth) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1960 sprintf(key, "#WINDOW.%03d.POS", win_no); if (config->GetParam(key, 3, &posd, &posx, &posy) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1961 sprintf(key, "#WINDOW.%03d.MOJI_POS", win_no); if (config->GetParam(key, 4, &mposy, NULL, &mposx, NULL) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1962 sprintf(key, "#WINDOW.%03d.MOJI_MIN", win_no); if (config->GetParam(key, 2, &minx, &miny) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1963 sprintf(key, "#WINDOW.%03d.WAKU_SETNO", win_no);if (config->GetParam(key, 1, &waku_no) == -1) return; |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1964 sprintf(key, "#WINDOW.%03d.LUBY_SIZE", win_no); if (config->GetParam(key, 1, &ruby) == -1) return; |
0 | 1965 |
1966 /* ¥Æ¥¥¹¥È¥¦¥£¥¸¥Ã¥È¡§²èÌ̤ᦲ¼°ìÇդޤǻÈÍÑ */ | |
1967 /* posd == 2 ¤Ê¤é²èÌ̲¼¤Ë¤Ò¤Ã¤Ä¤¯¤è¤¦¤ËÇÛÃÖ */ | |
1968 Rect r(0,0); | |
1969 if (posd == 2) { | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1970 r = WakuSize(parent, waku_no); |
0 | 1971 r = Rect(0, parent.Height()-r.height(), r.width(), parent.Height()); |
1972 posx = 0; | |
1973 posy = parent.Height()-r.height(); | |
1974 } else /* posd == 0 ? */ | |
1975 r = Rect(posx, posy, parent.Width(), parent.Height()); | |
1976 | |
1977 /* ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦¤ÎºîÀ® */ | |
1978 int w = size*cntw; int h = (size+ruby+2)*cnth; | |
1979 wid = new WidText(event, &parent, r, Rect(mposx, mposy, mposx+w, mposy+h), size); | |
1980 wid->stream.kanji_type = TextStream::sjis; | |
1981 /* ´é¥¦¥£¥ó¥É¥¦¤ÎºîÀ® */ | |
1982 for (i=0; i<8; i++) { | |
1983 int x,y; | |
1984 sprintf(key, "#WINDOW.%03d.FACE.%03d", win_no, i); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1985 if (config->GetParam(key, 2, &x, &y) == -1) continue; |
0 | 1986 /* ´é¥¦¥£¥ó¥É¥¦¤òºîÀ®¤¹¤ë */ |
1987 if (x >= 0 && y >= 0) { | |
1988 face_pics[i] = wid->PicNode()->create_leaf(Rect(x,y), PicBase::FIT_SURFACE); | |
1989 } else { | |
1990 face_pics[i] = parent.create_leaf(Rect(x+posx,y+posy), PicBase::FIT_SURFACE); | |
1991 } | |
1992 face_pics[i]->show(); | |
1993 } | |
1994 face = face_pics[0]; | |
1995 // ¥Ü¥¿¥ó¤ÎÀßÄê | |
1996 for (i=0; i<BTNCNT; i++) { | |
1997 int num; | |
1998 sprintf(key, "#WINDOW.%03d.%s_USE", win_no, btnname[i]); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
1999 config->GetParam(key, 1, &num); |
0 | 2000 use_btn[i] = (num==0) ? false : true; |
2001 } | |
2002 // make name window | |
2003 int shadow, name_mod, name_size, name_min, name_center, name_posx, name_posy, name_mposx, name_mposy; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2004 sprintf(key, "#WINDOW.%03d.MOJI_SHADOW", win_no); config->GetParam(key, 1, &shadow); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2005 sprintf(key, "#WINDOW.%03d.NAME_MOD", win_no); config->GetParam(key, 1, &name_mod); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2006 sprintf(key, "#WINDOW.%03d.NAME_MOJI_SIZE", win_no); config->GetParam(key, 1, &name_size); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2007 sprintf(key, "#WINDOW.%03d.NAME_MOJI_MIN", win_no); config->GetParam(key, 1, &name_min); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2008 sprintf(key, "#WINDOW.%03d.NAME_MOJI_POS", win_no); config->GetParam(key, 2, &name_mposx, &name_mposy); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2009 sprintf(key, "#WINDOW.%03d.NAME_CENTERING", win_no); config->GetParam(key, 1, &name_center); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2010 sprintf(key, "#WINDOW.%03d.NAME_POS", win_no); config->GetParam(key, 2, &name_posx, &name_posy); |
0 | 2011 // if name_mode==0 name is in the text window |
2012 // if name_mode == 1 open name window | |
2013 // if name_mode == 2 name is not used | |
2014 if (name_mod) { | |
2015 if (name_mod == 1) { | |
2016 int w = name_size*name_min; int h = name_size; | |
2017 int name_waku; | |
2018 sprintf(key, "#WINDOW.%03d.NAME_WAKU_SETNO", win_no); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2019 if (config->GetParam(key, 1, &name_waku) != -1 && name_waku != -1) { |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2020 Rect waku_r = WakuSize(parent, name_waku); |
0 | 2021 waku_r.rmove(r.lx, r.ty); // ¥Æ¥¥¹¥È¥¦¥£¥ó¥É¥¦°ÌÃÖ¤ËÆ°¤«¤¹ |
2022 waku_r.rmove(name_posx, name_posy-waku_r.height()); // NAME_POS ¤Ø°ÌÃÖÊäÀµ | |
2023 name_container = parent.create_node(waku_r, 0); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2024 MakeWaku(*name_container, event, name_waku, win_no, 0, callback); |
0 | 2025 Rect name_r(0,0,w,h); |
2026 name_r.rmove(name_mposx, name_mposy); | |
2027 name = new WidLabel(name_container, name_r, true, 0, name_size); | |
2028 name->show(); | |
2029 } else { // ̾Á°ÀìÍÑÏȤʤ· | |
2030 Rect name_r(0, 0, w, h); | |
2031 name_r.rmove(r.lx, r.ty); | |
2032 name_r.rmove(name_posx, name_posy-name_size); | |
2033 name_container = parent.create_node(name_r, 0); | |
52 | 2034 name = new WidLabel(name_container, Rect(0, 0, w, h), true, 0, name_size); |
0 | 2035 name->show(); |
2036 name_container->show(); | |
2037 } | |
2038 } else { // name_mod == 2 or 3 | |
52 | 2039 name_container = parent.create_node( Rect(0, 0, 1, 1), 0); |
0 | 2040 } |
2041 } | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2042 MakeWaku(*wid->PicNode(), event,waku_no, win_no, use_btn, callback); |
0 | 2043 } |
52 | 2044 |
0 | 2045 void TextImpl::InitWindow(void) { |
43
01aa5ddf7dc8
A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents:
40
diff
changeset
|
2046 int i; |
0 | 2047 int w; |
2048 std::string str; | |
2049 | |
2050 for (w=0; w<32; w++) { | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2051 widgets[w] = new TextWindow(parent, event, w, (void*)this); |
0 | 2052 if (widgets[w]->wid == 0) { |
2053 delete widgets[w]; | |
52 | 2054 widgets[w] = NULL; |
0 | 2055 } |
2056 } | |
2057 SetCursor(0); | |
2058 for (i=0; i<26; i++) { | |
2059 char buf[1024]; | |
2060 sprintf(buf, "#NAME.%c", i+'A'); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2061 const char* s = config->GetParaStr(buf); |
52 | 2062 if (s != NULL) replace_name[i] = s; |
0 | 2063 } |
2064 // replace_name2 : ½é´üÀßÄê | |
2065 // ½í¡¢½©À¸¡¢½í (CLANNAD) | |
52 | 2066 char name_nagisa[3] = {'\x8f', '\x8d', '\0'}; |
2067 char name_akio[5] = {'\x8f', '\x48', '\x90', '\xb6', '\0'}; | |
0 | 2068 replace_name2[0] = name_nagisa; |
2069 replace_name2[1] = name_akio; | |
2070 replace_name2[2] = name_nagisa; | |
52 | 2071 text = NULL; |
0 | 2072 /* ¥Æ¥¥¹¥È®ÅÙ¤ÎÀßÄê */ |
2073 int speed, mod, wait, auto_mod; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2074 config->GetParam("#INIT_MESSAGE_SPEED", 1, &speed); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2075 config->GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &mod); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2076 config->GetParam("#MESSAGE_KEY_WAIT_USE", 1, &auto_mod); |
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
2077 config->GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait); |
0 | 2078 if (mod) speed = -1; |
2079 if (!auto_mod) wait = -1; | |
2080 SetTextSpeed(speed); | |
2081 SetTextWait(wait); | |
2082 return; | |
2083 } |