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