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