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