comparison scn2k/scn2k_text.cc @ 53:ddbcbd000206

* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons * ParseMoji moved to TextStream * Some cleaning (0 -> NULL when needed, removal of useless returns, ...)
author thib
date Sun, 19 Apr 2009 11:44:05 +0000
parents 15a18fbe6f21
children f1a27ee7e03c
comparison
equal deleted inserted replaced
52:15a18fbe6f21 53:ddbcbd000206
91 bool name_visible; 91 bool name_visible;
92 WidLabel* name; 92 WidLabel* name;
93 PicContainer* name_container; 93 PicContainer* name_container;
94 PicBase* face; 94 PicBase* face;
95 PicBase* face_pics[8]; 95 PicBase* face_pics[8];
96 TextWindow(PicContainer& parent, Event::Container& event, int window_no, const AyuSysConfig& config, void* callback); 96 TextWindow(PicContainer& parent, Event::Container& event, int window_no, void* callback);
97 ~TextWindow() { 97 ~TextWindow() {
98 if (name_container != NULL) { 98 if (name_container != NULL) {
99 delete name_container; 99 delete name_container;
100 name_container = NULL; 100 name_container = NULL;
101 } 101 }
109 if (wid != NULL) { 109 if (wid != NULL) {
110 delete wid; 110 delete wid;
111 wid = NULL; 111 wid = NULL;
112 } 112 }
113 } 113 }
114 Rect WakuSize(PicContainer& pic, int waku_no, const AyuSysConfig& config); 114 Rect WakuSize(PicContainer& pic, int waku_no);
115 void MakeWaku(PicContainer& pic, Event::Container& event, int waku_no,int window_no, bool* use_btn, const AyuSysConfig& config, void* callback); 115 void MakeWaku(PicContainer& pic, Event::Container& event, int waku_no,int window_no, bool* use_btn, void* callback);
116 void show(void) { 116 void show(void) {
117 wid->show(); 117 wid->show();
118 if (name_container && name_visible) name_container->show(); 118 if (name_container && name_visible) name_container->show();
119 if (face) face->show(); 119 if (face) face->show();
120 } 120 }
203 BacklogItem drawn_backlog_item; 203 BacklogItem drawn_backlog_item;
204 204
205 public: 205 public:
206 PicContainer& parent; 206 PicContainer& parent;
207 Event::Container& event; 207 Event::Container& event;
208 AyuSysConfig& config; 208 AyuSysConfig *config;
209 private: 209 private:
210 TextWindow* widgets[32]; 210 TextWindow* widgets[32];
211 WidTimeCursor* kcursor; 211 WidTimeCursor* kcursor;
212 Surface* sel_bg1; 212 Surface* sel_bg1;
213 Surface* sel_bg2; 213 Surface* sel_bg2;
227 private: 227 private:
228 static void PressFuncButton(void* pointer, WidButton* from); 228 static void PressFuncButton(void* pointer, WidButton* from);
229 static bool PressFunc(int x, int y, void* pointer); 229 static bool PressFunc(int x, int y, void* pointer);
230 230
231 public: 231 public:
232 TextImpl(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item); 232 TextImpl(Event::Container& _event, PicContainer& _parent, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item);
233 ~TextImpl(); 233 ~TextImpl();
234 void InitWindow(void); 234 void InitWindow(void);
235 void SetWindowColor(int r, int g, int b, int a, bool is_transparent); 235 void SetWindowColor(int r, int g, int b, int a, bool is_transparent);
236 void SetTextSpeed(int new_speed); 236 void SetTextSpeed(int new_speed);
237 void SetTextWait(int new_wait); 237 void SetTextWait(int new_wait);
250 250
251 /**************************************************************:: 251 /**************************************************************::
252 ** 252 **
253 ** TextImpl(implementation) 253 ** TextImpl(implementation)
254 */ 254 */
255 TextImpl::TextImpl(Event::Container& _event, PicContainer& _parent, AyuSysConfig& _config, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item) : 255 TextImpl::TextImpl(Event::Container& _event, PicContainer& _parent, vector<BacklogItem>& parent_backlog, BacklogItem& parent_backlog_item) :
256 text(0),status(TextImpl::NORMAL), status_saved(TextImpl::NORMAL), status_mask(TextImpl::NORMAL), ruby_text_flag(false), 256 text(0),status(TextImpl::NORMAL), status_saved(TextImpl::NORMAL), status_mask(TextImpl::NORMAL), ruby_text_flag(false),
257 old_time(0), base_time(0), text_window_number(0), text_parsing(false), skip_mode(SKIP_NO), save_selectcount(0), sel_widget(0), 257 old_time(0), base_time(0), text_window_number(0), text_parsing(false), skip_mode(SKIP_NO), save_selectcount(0), sel_widget(0),
258 backlog_widget(0), backlog(parent_backlog), backlog_item(parent_backlog_item), parent(_parent), event(_event), config(_config), 258 backlog_widget(0), backlog(parent_backlog), backlog_item(parent_backlog_item), parent(_parent), event(_event),
259 kcursor(0), sel_bg1(0), sel_bg2(0), sel_bg_rect(0,0,0,0) { 259 kcursor(0), sel_bg1(0), sel_bg2(0), sel_bg_rect(0,0,0,0) {
260 config = AyuSysConfig::GetInstance();
260 int i; 261 int i;
261 for (i=0; i<32; i++) { 262 for (i=0; i<32; i++) {
262 widgets[i] = 0; 263 widgets[i] = 0;
263 } 264 }
264 text_stream.kanji_type = TextStream::sjis; 265 text_stream.kanji_type = TextStream::sjis;
621 text->show(); 622 text->show();
622 if (kcursor) { 623 if (kcursor) {
623 int kx, ky, d; 624 int kx, ky, d;
624 char key[1024]; 625 char key[1024];
625 sprintf(key, "#WINDOW.%03d.KEYCUR_MOD", text_window_number); 626 sprintf(key, "#WINDOW.%03d.KEYCUR_MOD", text_window_number);
626 config.GetParam(key, 3, &d, &kx, &ky); 627 config->GetParam(key, 3, &d, &kx, &ky);
627 // 正しくない気がする 628 // 正しくない気がする
628 kx += text->wid->Pic()->PosX(); 629 kx += text->wid->Pic()->PosX();
629 ky += text->wid->Pic()->PosY(); 630 ky += text->wid->Pic()->PosY();
630 // 微妙に下にする 631 // 微妙に下にする
631 ky += 8; 632 ky += 8;
655 } 656 }
656 657
657 void TextImpl::CreateSelBG(void) { 658 void TextImpl::CreateSelBG(void) {
658 if (sel_bg1 != NULL || sel_bg2 != NULL) return; 659 if (sel_bg1 != NULL || sel_bg2 != NULL) return;
659 660
660 const char* btnfile1 = config.GetParaStr("#SELBTN.000.NAME"); 661 const char* btnfile1 = config->GetParaStr("#SELBTN.000.NAME");
661 const char* btnfile2 = config.GetParaStr("#SELBTN.000.BACK"); 662 const char* btnfile2 = config->GetParaStr("#SELBTN.000.BACK");
662 char path[1024]; 663 char path[1024];
663 strcpy(path, btnfile1); 664 strcpy(path, btnfile1);
664 sel_bg1 = parent.Root().NewSurface(path); 665 sel_bg1 = parent.Root().NewSurface(path);
665 if (sel_bg1 == NULL) { 666 if (sel_bg1 == NULL) {
666 sprintf(path,"%s.g00",btnfile1); 667 sprintf(path,"%s.g00",btnfile1);
679 680
680 void TextImpl::CreateSelect(Cmd& cmd) { 681 void TextImpl::CreateSelect(Cmd& cmd) {
681 char key[1024]; 682 char key[1024];
682 sprintf(key, "#WINDOW.%03d.SELCOM_USE",text_window_number); 683 sprintf(key, "#WINDOW.%03d.SELCOM_USE",text_window_number);
683 int sel_type = 0; 684 int sel_type = 0;
684 if (cmd.cmd3 == 1) config.GetParam(key, 1, &sel_type); 685 if (cmd.cmd3 == 1) config->GetParam(key, 1, &sel_type);
685 else if (cmd.cmd3 == 3) sel_type = 0; 686 else if (cmd.cmd3 == 3) sel_type = 0;
686 687
687 int sel_size = cmd.args.size() / 2; 688 int sel_size = cmd.args.size() / 2;
688 int i; 689 int i;
689 // cur_backlog_item に次にbacklogに入るべき内容を作成 690 // cur_backlog_item に次にbacklogに入るべき内容を作成
706 External_select: 707 External_select:
707 CreateSelBG(); 708 CreateSelBG();
708 hide(); // なので、テキストウィンドウは消去 709 hide(); // なので、テキストウィンドウは消去
709 int baseposx, baseposy, repposx, repposy, centerx, centery; 710 int baseposx, baseposy, repposx, repposy, centerx, centery;
710 int mojisize, col1, col2; 711 int mojisize, col1, col2;
711 config.GetParam("#SELBTN.000.CENTERING", 2, &centerx, &centery); 712 config->GetParam("#SELBTN.000.CENTERING", 2, &centerx, &centery);
712 config.GetParam("#SELBTN.000.BASEPOS", 2, &baseposx, &baseposy); 713 config->GetParam("#SELBTN.000.BASEPOS", 2, &baseposx, &baseposy);
713 config.GetParam("#SELBTN.000.REPPOS", 2, &repposx, &repposy); 714 config->GetParam("#SELBTN.000.REPPOS", 2, &repposx, &repposy);
714 config.GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize); 715 config->GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize);
715 config.GetParam("#SELBTN.000.MOJIDEFAULTCOL", 1, &col1); 716 config->GetParam("#SELBTN.000.MOJIDEFAULTCOL", 1, &col1);
716 config.GetParam("#SELBTN.000.MOJISELECTCOL", 1, &col2); 717 config->GetParam("#SELBTN.000.MOJISELECTCOL", 1, &col2);
717 if (col1 == col2) col2 = 1; // CLANNAD でとりあえず。 718 if (col1 == col2) col2 = 1; // CLANNAD でとりあえず。
718 int r, g, b; 719 int r, g, b;
719 sprintf(key, "#COLOR_TABLE.%03d", col1); 720 sprintf(key, "#COLOR_TABLE.%03d", col1);
720 config.GetParam(key, 3, &r, &g, &b); 721 config->GetParam(key, 3, &r, &g, &b);
721 Color fore(r,g,b); 722 Color fore(r,g,b);
722 sprintf(key, "#COLOR_TABLE.%03d", col2); 723 sprintf(key, "#COLOR_TABLE.%03d", col2);
723 config.GetParam(key, 3, &r, &g, &b); 724 config->GetParam(key, 3, &r, &g, &b);
724 Color seled(r,g,b); 725 Color seled(r,g,b);
725 726
726 /* ウィジット作成 */ 727 /* ウィジット作成 */
727 /* ウィンドウ背景の大きさを求める */ 728 /* ウィンドウ背景の大きさを求める */
728 if (baseposx == 0 && sel_bg_rect.width() != 0) 729 if (baseposx == 0 && sel_bg_rect.width() != 0)
761 } 762 }
762 sel_widget->show_all(); 763 sel_widget->show_all();
763 status = WAIT_SELECT_OUTBOX; 764 status = WAIT_SELECT_OUTBOX;
764 } else { // CLANNAD: テキストウィンドウ内に選択肢表示 765 } else { // CLANNAD: テキストウィンドウ内に選択肢表示
765 int mojisize; 766 int mojisize;
766 config.GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize); 767 config->GetParam("#SELBTN.000.MOJISIZE", 1, &mojisize);
767 Color fore(0xff,0xff,0xff); 768 Color fore(0xff,0xff,0xff);
768 Color seled(0xff,0xff,0xff); 769 Color seled(0xff,0xff,0xff);
769 770
770 show(); 771 show();
771 if (text == NULL) goto External_select; // テキスト・ウィンドウを表示できなければ外部選択肢にする 772 if (text == NULL) goto External_select; // テキスト・ウィンドウを表示できなければ外部選択肢にする
1225 cmd.cmd_type = CMD_LOADREQ; 1226 cmd.cmd_type = CMD_LOADREQ;
1226 } else if ( (cmd.cmd3 >= 0x8d4 && cmd.cmd3 <= 0x8d8) || cmd.cmd3 == 0x8db || cmd.cmd3 == 0x93f || cmd.cmd3 == 0xa39) { 1227 } else if ( (cmd.cmd3 >= 0x8d4 && cmd.cmd3 <= 0x8d8) || cmd.cmd3 == 0x8db || cmd.cmd3 == 0x93f || cmd.cmd3 == 0xa39) {
1227 // テキストウィンドウの色設定 1228 // テキストウィンドウの色設定
1228 int r, g, b, a, flag; 1229 int r, g, b, a, flag;
1229 if (cmd.cmd3 == 0xa39) { // 元設定を取り出す 1230 if (cmd.cmd3 == 0xa39) { // 元設定を取り出す
1230 config.GetOriginalParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag); 1231 config->GetOriginalParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag);
1231 } else { 1232 } else {
1232 config.GetParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag); 1233 config->GetParam("#WINDOW_ATTR", 5, &r, &g, &b, &a, &flag);
1233 } 1234 }
1234 if (cmd.cmd3 == 0xa39 || cmd.cmd3 == 0x93f) { // 設定を変数に取り出す 1235 if (cmd.cmd3 == 0xa39 || cmd.cmd3 == 0x93f) { // 設定を変数に取り出す
1235 if (cmd.args.size() != 5) { 1236 if (cmd.args.size() != 5) {
1236 fprintf(stderr,"cmd 01-04:%4d : invalid arg size\n", cmd.cmd3); 1237 fprintf(stderr,"cmd 01-04:%4d : invalid arg size\n", cmd.cmd3);
1237 } else { 1238 } else {
1255 b = cmd.args[2].value; 1256 b = cmd.args[2].value;
1256 a = cmd.args[3].value; 1257 a = cmd.args[3].value;
1257 flag = cmd.args[4].value; 1258 flag = cmd.args[4].value;
1258 break; 1259 break;
1259 } 1260 }
1260 config.SetParam("#WINDOW_ATTR", 5, r, g, b, a, flag); 1261 config->SetParam("#WINDOW_ATTR", 5, r, g, b, a, flag);
1261 SetWindowColor(r, g, b, a, flag); 1262 SetWindowColor(r, g, b, a, flag);
1262 cmd.clear(); 1263 cmd.clear();
1263 } 1264 }
1264 } else if (cmd.cmd3 == 0xa28 || cmd.cmd3 == 0xa29 || cmd.cmd3 == 0xa2c || cmd.cmd3 == 0xa2d || cmd.cmd3 == 0xa2e) { 1265 } else if (cmd.cmd3 == 0xa28 || cmd.cmd3 == 0xa29 || cmd.cmd3 == 0xa2c || cmd.cmd3 == 0xa2d || cmd.cmd3 == 0xa2e) {
1265 int v = 0; 1266 int v = 0;
1266 switch(cmd.cmd3) { 1267 switch(cmd.cmd3) {
1267 case 0xa28: case 0xa2d: config.GetOriginalParam("#INIT_MESSAGE_SPEED", 1, &v); break; 1268 case 0xa28: case 0xa2d: config->GetOriginalParam("#INIT_MESSAGE_SPEED", 1, &v); break;
1268 case 0xa29: config.GetOriginalParam("#INIT_MESSAGE_SPEED_MOD", 1, &v); break; 1269 case 0xa29: config->GetOriginalParam("#INIT_MESSAGE_SPEED_MOD", 1, &v); break;
1269 case 0xa2c: config.GetOriginalParam("#MESSAGE_KEY_WAIT_USE", 1, &v); break; 1270 case 0xa2c: config->GetOriginalParam("#MESSAGE_KEY_WAIT_USE", 1, &v); break;
1270 case 0xa2e: config.GetOriginalParam("#MESSAGE_KEY_WAIT_TIME", 1, &v); break; 1271 case 0xa2e: config->GetOriginalParam("#MESSAGE_KEY_WAIT_TIME", 1, &v); break;
1271 } 1272 }
1272 cmd.SetSysvar(v); 1273 cmd.SetSysvar(v);
1273 } else if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x914 || cmd.cmd3 == 0x92f || cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8b0 || cmd.cmd3 == 0x8cb) { 1274 } else if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x914 || cmd.cmd3 == 0x92f || cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8b0 || cmd.cmd3 == 0x8cb) {
1274 // テキスト表示速度関連 1275 // テキスト表示速度関連
1275 int m, speed; 1276 int m, speed;
1276 config.GetParam("#INIT_MESSAGE_SPEED", 1, &speed); 1277 config->GetParam("#INIT_MESSAGE_SPEED", 1, &speed);
1277 config.GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &m); 1278 config->GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &m);
1278 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) fprintf(stderr,"TEXT speed %d\n",speed); 1279 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) fprintf(stderr,"TEXT speed %d\n",speed);
1279 else if (cmd.cmd3 == 0x914) fprintf(stderr,"TEXT mode %d\n",m); 1280 else if (cmd.cmd3 == 0x914) fprintf(stderr,"TEXT mode %d\n",m);
1280 else if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) fprintf(stderr,"TEXT %d, %d <- speed %d\n",m,speed,cmd.args[0].value); 1281 else if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) fprintf(stderr,"TEXT %d, %d <- speed %d\n",m,speed,cmd.args[0].value);
1281 else fprintf(stderr,"TEXT %d, %d <- mode %d\n",m,speed,cmd.args[0].value); 1282 else fprintf(stderr,"TEXT %d, %d <- mode %d\n",m,speed,cmd.args[0].value);
1282 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) cmd.SetSysvar(speed); 1283 if (cmd.cmd3 == 0x913 || cmd.cmd3 == 0x92f) cmd.SetSysvar(speed);
1284 else { 1285 else {
1285 if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) speed = cmd.args[0].value; 1286 if (cmd.cmd3 == 0x8af || cmd.cmd3 == 0x8cb) speed = cmd.args[0].value;
1286 else m = cmd.args[0].value; 1287 else m = cmd.args[0].value;
1287 if (speed < 10) speed = 10; 1288 if (speed < 10) speed = 10;
1288 else if (speed > 1000) speed = 1000; 1289 else if (speed > 1000) speed = 1000;
1289 config.SetParam("#INIT_MESSAGE_SPEED", 1, speed); 1290 config->SetParam("#INIT_MESSAGE_SPEED", 1, speed);
1290 config.SetParam("#INIT_MESSAGE_SPEED_MOD", 1, m); 1291 config->SetParam("#INIT_MESSAGE_SPEED_MOD", 1, m);
1291 if (m) speed = -1; 1292 if (m) speed = -1;
1292 SetTextSpeed(speed); 1293 SetTextSpeed(speed);
1293 cmd.clear(); 1294 cmd.clear();
1294 } 1295 }
1295 } else if (cmd.cmd3 == 0x92e || cmd.cmd3 == 0x930 || cmd.cmd3 == 0x8ca || cmd.cmd3 == 0x8cc) { 1296 } else if (cmd.cmd3 == 0x92e || cmd.cmd3 == 0x930 || cmd.cmd3 == 0x8ca || cmd.cmd3 == 0x8cc) {
1296 // テキストオートモード関連 1297 // テキストオートモード関連
1297 int m, wait; 1298 int m, wait;
1298 config.GetParam("#MESSAGE_KEY_WAIT_USE", 1, &m); 1299 config->GetParam("#MESSAGE_KEY_WAIT_USE", 1, &m);
1299 config.GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait); 1300 config->GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait);
1300 if (cmd.cmd3 == 0x92e) fprintf(stderr,"AUTO mode %d\n",m); 1301 if (cmd.cmd3 == 0x92e) fprintf(stderr,"AUTO mode %d\n",m);
1301 else if (cmd.cmd3 == 0x930) fprintf(stderr,"AUTO wait %d\n",wait); 1302 else if (cmd.cmd3 == 0x930) fprintf(stderr,"AUTO wait %d\n",wait);
1302 else if (cmd.cmd3 == 0x8ca) fprintf(stderr,"AUTO %d,%d <- mode %d\n",m,wait,cmd.args[0].value); 1303 else if (cmd.cmd3 == 0x8ca) fprintf(stderr,"AUTO %d,%d <- mode %d\n",m,wait,cmd.args[0].value);
1303 else fprintf(stderr,"AUTO %d,%d <- wait %d\n",m,wait,cmd.args[0].value); 1304 else fprintf(stderr,"AUTO %d,%d <- wait %d\n",m,wait,cmd.args[0].value);
1304 1305
1307 else { 1308 else {
1308 if (cmd.cmd3 == 0x8ca) m = cmd.args[0].value; 1309 if (cmd.cmd3 == 0x8ca) m = cmd.args[0].value;
1309 else wait = cmd.args[1].value; 1310 else wait = cmd.args[1].value;
1310 if (wait < 0) wait = 0; 1311 if (wait < 0) wait = 0;
1311 else if (wait > 60000) wait = 60000; 1312 else if (wait > 60000) wait = 60000;
1312 config.SetParam("#MESSAGE_KEY_WAIT_USE", 1, m); 1313 config->SetParam("#MESSAGE_KEY_WAIT_USE", 1, m);
1313 config.SetParam("#MESSAGE_KEY_WAIT_TIME", 1, wait); 1314 config->SetParam("#MESSAGE_KEY_WAIT_TIME", 1, wait);
1314 if (m) SetTextWait(wait); 1315 if (m) SetTextWait(wait);
1315 else SetTextWait(-1); 1316 else SetTextWait(-1);
1316 cmd.clear(); 1317 cmd.clear();
1317 } 1318 }
1318 } else if (cmd.cmd3 == 0x51f && cmd.cmd4 == 0) { // replace_name2 の設定 1319 } else if (cmd.cmd3 == 0x51f && cmd.cmd4 == 0) { // replace_name2 の設定
1615 int w; 1616 int w;
1616 1617
1617 for (w=0; w<32; w++) { 1618 for (w=0; w<32; w++) {
1618 if (widgets[w] == NULL) continue; 1619 if (widgets[w] == NULL) continue;
1619 sprintf(key, "#WAKU.%03d.000.BACK", w); 1620 sprintf(key, "#WAKU.%03d.000.BACK", w);
1620 const char* back = config.GetParaStr(key); 1621 const char* back = config->GetParaStr(key);
1621 if (back == NULL || back[0] == 0) continue; 1622 if (back == NULL || back[0] == 0) continue;
1622 sprintf(key, "%s.g00", back); 1623 sprintf(key, "%s.g00", back);
1623 Surface* back_s = parent.Root().NewSurface(key); 1624 Surface* back_s = parent.Root().NewSurface(key);
1624 if (back_s == NULL) continue; 1625 if (back_s == NULL) continue;
1625 Rect rect(*back_s); 1626 Rect rect(*back_s);
1635 } 1636 }
1636 1637
1637 void TextImpl::SetCursor(int cursor_no) { 1638 void TextImpl::SetCursor(int cursor_no) {
1638 char key[1024]; 1639 char key[1024];
1639 sprintf(key, "#CURSOR.%03d.NAME", cursor_no); 1640 sprintf(key, "#CURSOR.%03d.NAME", cursor_no);
1640 string path = config.GetParaStr(key); 1641 string path = config->GetParaStr(key);
1641 if (path.length() == 0) return; // 名前なし 1642 if (path.length() == 0) return; // 名前なし
1642 path += ".pdt"; 1643 path += ".pdt";
1643 int w,h,cont,speed; 1644 int w,h,cont,speed;
1644 sprintf(key, "#CURSOR.%03d.SIZE", cursor_no); 1645 sprintf(key, "#CURSOR.%03d.SIZE", cursor_no);
1645 config.GetParam(key, 2, &w, &h); 1646 config->GetParam(key, 2, &w, &h);
1646 sprintf(key, "#CURSOR.%03d.CONT", cursor_no); 1647 sprintf(key, "#CURSOR.%03d.CONT", cursor_no);
1647 config.GetParam(key, 1, &cont); 1648 config->GetParam(key, 1, &cont);
1648 sprintf(key, "#CURSOR.%03d.SPEED", cursor_no); 1649 sprintf(key, "#CURSOR.%03d.SPEED", cursor_no);
1649 config.GetParam(key, 1, &speed); 1650 config->GetParam(key, 1, &speed);
1650 1651
1651 // speed で1周、cont 回変化 1652 // speed で1周、cont 回変化
1652 if (kcursor != NULL) delete kcursor; 1653 if (kcursor != NULL) delete kcursor;
1653 1654
1654 kcursor = new WidTimeCursor(event, speed/cont, &parent, path.c_str(), 0, 0, w, 0, cont, Rect(0,0,w,h)); 1655 kcursor = new WidTimeCursor(event, speed/cont, &parent, path.c_str(), 0, 0, w, 0, cont, Rect(0,0,w,h));
1739 1740
1740 /**************************************************************:: 1741 /**************************************************************::
1741 ** 1742 **
1742 ** Text 1743 ** Text
1743 */ 1744 */
1744 Text::Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config) { 1745 Text::Text(Event::Container& _event, PicContainer& _parent) {
1745 pimpl = new TextImpl(_event, _parent, config, backlog, backlog_item); 1746 pimpl = new TextImpl(_event, _parent, backlog, backlog_item);
1746 } 1747 }
1747 1748
1748 Text::~Text() { 1749 Text::~Text() {
1749 delete pimpl; 1750 delete pimpl;
1750 pimpl = NULL; 1751 pimpl = NULL;
1836 Clear(); 1837 Clear();
1837 scn = SaveSelect; 1838 scn = SaveSelect;
1838 pos = p; 1839 pos = p;
1839 } 1840 }
1840 1841
1841 Rect TextWindow::WakuSize(PicContainer& pic, int waku_no, const AyuSysConfig& config) { 1842 Rect TextWindow::WakuSize(PicContainer& pic, int waku_no) {
1842 char key[1024]; 1843 char key[1024];
1843 sprintf(key, "#WAKU.%03d.000.NAME", waku_no); 1844 sprintf(key, "#WAKU.%03d.000.NAME", waku_no);
1844 const char* name = config.GetParaStr(key); 1845 const char* name = AyuSysConfig::GetInstance()->GetParaStr(key);
1845 if (name == NULL) return Rect(0,0,0,0); 1846 if (name == NULL) return Rect(0,0,0,0);
1846 std::string str = name; str += ".g00"; 1847 std::string str = name; str += ".g00";
1847 Surface* s = pic.Root().NewSurface(str.c_str()); 1848 Surface* s = pic.Root().NewSurface(str.c_str());
1848 if (s == NULL) return Rect(0,0,0,0); 1849 if (s == NULL) return Rect(0,0,0,0);
1849 Rect r(*s); 1850 Rect r(*s);
1850 pic.Root().DeleteSurface(s); 1851 pic.Root().DeleteSurface(s);
1851 return r; 1852 return r;
1852 } 1853 }
1853 1854
1854 void TextWindow::MakeWaku(PicContainer& pic, Event::Container& event, int waku_no, int window_no, bool* use_btn, const AyuSysConfig& config, void* callback) { 1855 void TextWindow::MakeWaku(PicContainer& pic, Event::Container& event, int waku_no, int window_no, bool* use_btn, void* callback) {
1856 AyuSysConfig *config = AyuSysConfig::GetInstance();
1855 char key[1024]; 1857 char key[1024];
1856 std::string str; 1858 std::string str;
1857 /* 枠を作成 */ 1859 /* 枠を作成 */
1858 sprintf(key, "#WAKU.%03d.000.NAME", waku_no); 1860 sprintf(key, "#WAKU.%03d.000.NAME", waku_no);
1859 const char* name = config.GetParaStr(key); 1861 const char* name = config->GetParaStr(key);
1860 if (name != NULL && name[0] == 0) name = NULL; 1862 if (name != NULL && name[0] == 0) name = NULL;
1861 sprintf(key, "#WAKU.%03d.000.BACK", waku_no); 1863 sprintf(key, "#WAKU.%03d.000.BACK", waku_no);
1862 const char* back = config.GetParaStr(key); 1864 const char* back = config->GetParaStr(key);
1863 if (back != NULL && back[0] == 0) back = NULL; 1865 if (back != NULL && back[0] == 0) back = NULL;
1864 sprintf(key, "#WAKU.%03d.000.BTN", waku_no); 1866 sprintf(key, "#WAKU.%03d.000.BTN", waku_no);
1865 const char* btn = config.GetParaStr(key); 1867 const char* btn = config->GetParaStr(key);
1866 if (btn != NULL && btn[0] == 0) btn = NULL; 1868 if (btn != NULL && btn[0] == 0) btn = NULL;
1867 1869
1868 if (name == NULL && back == NULL && btn == NULL) return; 1870 if (name == NULL && back == NULL && btn == NULL) return;
1869 1871
1870 /* まず、テキスト背景を設定 */ 1872 /* まず、テキスト背景を設定 */
1871 if (back != NULL) { 1873 if (back != NULL) {
1872 str = back; str += ".g00"; 1874 str = back; str += ".g00";
1873 int rc, gc, bc, ac, flag; 1875 int rc, gc, bc, ac, flag;
1874 char key[1024]; 1876 char key[1024];
1875 sprintf(key, "#WINDOW.%03d.ATTR", window_no); 1877 sprintf(key, "#WINDOW.%03d.ATTR", window_no);
1876 if (config.GetParam(key, 5, &rc, &gc, &bc, &ac, &flag) == -1) { 1878 if (config->GetParam(key, 5, &rc, &gc, &bc, &ac, &flag) == -1) {
1877 config.GetParam("#WINDOW_ATTR", 5, &rc, &gc, &bc, &ac, &flag); 1879 config->GetParam("#WINDOW_ATTR", 5, &rc, &gc, &bc, &ac, &flag);
1878 } 1880 }
1879 Surface* back_s = pic.Root().NewSurface(str.c_str()); 1881 Surface* back_s = pic.Root().NewSurface(str.c_str());
1880 if (back_s != NULL) { 1882 if (back_s != NULL) {
1881 Rect rect(*back_s); 1883 Rect rect(*back_s);
1882 Surface* s = pic.Root().NewSurface(rect.width(), rect.height(), ALPHA_MASK); 1884 Surface* s = pic.Root().NewSurface(rect.width(), rect.height(), ALPHA_MASK);
1906 // ボタンの作成 1908 // ボタンの作成
1907 // 使用するボタンについては、必要に応じて show() すること 1909 // 使用するボタンについては、必要に応じて show() すること
1908 1910
1909 /* ボタンの位置情報を求める */ 1911 /* ボタンの位置情報を求める */
1910 str = btn; str += ".g00"; 1912 str = btn; str += ".g00";
1911 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, str.c_str(), "g00"); 1913 ARCINFO* info = FileSearcher::GetInstance()->Find(FileSearcher::PDT, str.c_str(), "g00");
1912 if (info == NULL) return; // cannot find file 1914 if (info == NULL) return; // cannot find file
1913 const char* data = info->Read(); 1915 const char* data = info->Read();
1914 /* g00 ファイルのヘッダ部分に位置情報は入っている */ 1916 /* g00 ファイルのヘッダ部分に位置情報は入っている */
1915 /* 存在しなければボタン画像ではない */ 1917 /* 存在しなければボタン画像ではない */
1916 if (data == NULL || *data != 2) { 1918 if (data == NULL || *data != 2) {
1924 if (btnpos[i]*8 >= index_count) { 1926 if (btnpos[i]*8 >= index_count) {
1925 continue; // ボタンが存在しない 1927 continue; // ボタンが存在しない
1926 } 1928 }
1927 int x, y, w, h; 1929 int x, y, w, h;
1928 sprintf(key, "#WAKU.%03d.000.%s_BOX", waku_no, btnname[i]); 1930 sprintf(key, "#WAKU.%03d.000.%s_BOX", waku_no, btnname[i]);
1929 if (config.GetParam(key, 5, 0, &x, &y, &w, &h) == -1) continue; 1931 if (config->GetParam(key, 5, 0, &x, &y, &w, &h) == -1) continue;
1930 int sx, sy, sdx, sdy, cnt; 1932 int sx, sy, sdx, sdy, cnt;
1931 const char* d = data + 9 + btnpos[i]*24*8; 1933 const char* d = data + 9 + btnpos[i]*24*8;
1932 sx = read_little_endian_int(d); 1934 sx = read_little_endian_int(d);
1933 sy = read_little_endian_int(d+4); 1935 sy = read_little_endian_int(d+4);
1934 sdx = read_little_endian_int(d+24) - sx; 1936 sdx = read_little_endian_int(d+24) - sx;
1940 if (btndrag[i]) { wid->drag_func = btndrag[i]; wid->drag_pointer = callback;} 1942 if (btndrag[i]) { wid->drag_func = btndrag[i]; wid->drag_pointer = callback;}
1941 } 1943 }
1942 delete info; 1944 delete info;
1943 } 1945 }
1944 1946
1945 TextWindow::TextWindow(PicContainer& parent, Event::Container& event, int win_no, const AyuSysConfig& config, void* callback) : 1947 TextWindow::TextWindow(PicContainer& parent, Event::Container& event, int win_no, void* callback) :
1946 wid(0), name_visible(true),name(0),name_container(0), face(0) { 1948 wid(0), name_visible(true),name(0),name_container(0), face(0)
1947 int i; for (i=0; i<8; i++) face_pics[i]=0; 1949 {
1950 AyuSysConfig *config = AyuSysConfig::GetInstance();
1951 int i;
1952 for (i=0; i<8; i++)
1953 face_pics[i]=0;
1948 char key[1024]; 1954 char key[1024];
1949 bool use_btn[BTNCNT]; 1955 bool use_btn[BTNCNT];
1950 int size, rep1, rep2, cntw, cnth, mposx, mposy, posd, posx, posy, minx, miny, waku_no, ruby; 1956 int size, rep1, rep2, cntw, cnth, mposx, mposy, posd, posx, posy, minx, miny, waku_no, ruby;
1951 sprintf(key, "#WINDOW.%03d.MOJI_SIZE", win_no); if (config.GetParam(key, 1, &size) == -1) return; 1957 sprintf(key, "#WINDOW.%03d.MOJI_SIZE", win_no); if (config->GetParam(key, 1, &size) == -1) return;
1952 sprintf(key, "#WINDOW.%03d.MOJI_REP", win_no); if (config.GetParam(key, 2, &rep1, &rep2) == -1) return; 1958 sprintf(key, "#WINDOW.%03d.MOJI_REP", win_no); if (config->GetParam(key, 2, &rep1, &rep2) == -1) return;
1953 sprintf(key, "#WINDOW.%03d.MOJI_CNT", win_no); if (config.GetParam(key, 2, &cntw, &cnth) == -1) return; 1959 sprintf(key, "#WINDOW.%03d.MOJI_CNT", win_no); if (config->GetParam(key, 2, &cntw, &cnth) == -1) return;
1954 sprintf(key, "#WINDOW.%03d.POS", win_no); if (config.GetParam(key, 3, &posd, &posx, &posy) == -1) return; 1960 sprintf(key, "#WINDOW.%03d.POS", win_no); if (config->GetParam(key, 3, &posd, &posx, &posy) == -1) return;
1955 sprintf(key, "#WINDOW.%03d.MOJI_POS", win_no); if (config.GetParam(key, 4, &mposy, NULL, &mposx, NULL) == -1) return; 1961 sprintf(key, "#WINDOW.%03d.MOJI_POS", win_no); if (config->GetParam(key, 4, &mposy, NULL, &mposx, NULL) == -1) return;
1956 sprintf(key, "#WINDOW.%03d.MOJI_MIN", win_no); if (config.GetParam(key, 2, &minx, &miny) == -1) return; 1962 sprintf(key, "#WINDOW.%03d.MOJI_MIN", win_no); if (config->GetParam(key, 2, &minx, &miny) == -1) return;
1957 sprintf(key, "#WINDOW.%03d.WAKU_SETNO", win_no);if (config.GetParam(key, 1, &waku_no) == -1) return; 1963 sprintf(key, "#WINDOW.%03d.WAKU_SETNO", win_no);if (config->GetParam(key, 1, &waku_no) == -1) return;
1958 sprintf(key, "#WINDOW.%03d.LUBY_SIZE", win_no); if (config.GetParam(key, 1, &ruby) == -1) return; 1964 sprintf(key, "#WINDOW.%03d.LUBY_SIZE", win_no); if (config->GetParam(key, 1, &ruby) == -1) return;
1959 1965
1960 /* テキストウィジット:画面の右下一杯まで使用 */ 1966 /* テキストウィジット:画面の右下一杯まで使用 */
1961 /* posd == 2 なら画面下にひっつくように配置 */ 1967 /* posd == 2 なら画面下にひっつくように配置 */
1962 Rect r(0,0); 1968 Rect r(0,0);
1963 if (posd == 2) { 1969 if (posd == 2) {
1964 r = WakuSize(parent, waku_no, config); 1970 r = WakuSize(parent, waku_no);
1965 r = Rect(0, parent.Height()-r.height(), r.width(), parent.Height()); 1971 r = Rect(0, parent.Height()-r.height(), r.width(), parent.Height());
1966 posx = 0; 1972 posx = 0;
1967 posy = parent.Height()-r.height(); 1973 posy = parent.Height()-r.height();
1968 } else /* posd == 0 ? */ 1974 } else /* posd == 0 ? */
1969 r = Rect(posx, posy, parent.Width(), parent.Height()); 1975 r = Rect(posx, posy, parent.Width(), parent.Height());
1974 wid->stream.kanji_type = TextStream::sjis; 1980 wid->stream.kanji_type = TextStream::sjis;
1975 /* 顔ウィンドウの作成 */ 1981 /* 顔ウィンドウの作成 */
1976 for (i=0; i<8; i++) { 1982 for (i=0; i<8; i++) {
1977 int x,y; 1983 int x,y;
1978 sprintf(key, "#WINDOW.%03d.FACE.%03d", win_no, i); 1984 sprintf(key, "#WINDOW.%03d.FACE.%03d", win_no, i);
1979 if (config.GetParam(key, 2, &x, &y) == -1) continue; 1985 if (config->GetParam(key, 2, &x, &y) == -1) continue;
1980 /* 顔ウィンドウを作成する */ 1986 /* 顔ウィンドウを作成する */
1981 if (x >= 0 && y >= 0) { 1987 if (x >= 0 && y >= 0) {
1982 face_pics[i] = wid->PicNode()->create_leaf(Rect(x,y), PicBase::FIT_SURFACE); 1988 face_pics[i] = wid->PicNode()->create_leaf(Rect(x,y), PicBase::FIT_SURFACE);
1983 } else { 1989 } else {
1984 face_pics[i] = parent.create_leaf(Rect(x+posx,y+posy), PicBase::FIT_SURFACE); 1990 face_pics[i] = parent.create_leaf(Rect(x+posx,y+posy), PicBase::FIT_SURFACE);
1988 face = face_pics[0]; 1994 face = face_pics[0];
1989 // ボタンの設定 1995 // ボタンの設定
1990 for (i=0; i<BTNCNT; i++) { 1996 for (i=0; i<BTNCNT; i++) {
1991 int num; 1997 int num;
1992 sprintf(key, "#WINDOW.%03d.%s_USE", win_no, btnname[i]); 1998 sprintf(key, "#WINDOW.%03d.%s_USE", win_no, btnname[i]);
1993 config.GetParam(key, 1, &num); 1999 config->GetParam(key, 1, &num);
1994 use_btn[i] = (num==0) ? false : true; 2000 use_btn[i] = (num==0) ? false : true;
1995 } 2001 }
1996 // make name window 2002 // make name window
1997 int shadow, name_mod, name_size, name_min, name_center, name_posx, name_posy, name_mposx, name_mposy; 2003 int shadow, name_mod, name_size, name_min, name_center, name_posx, name_posy, name_mposx, name_mposy;
1998 sprintf(key, "#WINDOW.%03d.MOJI_SHADOW", win_no); config.GetParam(key, 1, &shadow); 2004 sprintf(key, "#WINDOW.%03d.MOJI_SHADOW", win_no); config->GetParam(key, 1, &shadow);
1999 sprintf(key, "#WINDOW.%03d.NAME_MOD", win_no); config.GetParam(key, 1, &name_mod); 2005 sprintf(key, "#WINDOW.%03d.NAME_MOD", win_no); config->GetParam(key, 1, &name_mod);
2000 sprintf(key, "#WINDOW.%03d.NAME_MOJI_SIZE", win_no); config.GetParam(key, 1, &name_size); 2006 sprintf(key, "#WINDOW.%03d.NAME_MOJI_SIZE", win_no); config->GetParam(key, 1, &name_size);
2001 sprintf(key, "#WINDOW.%03d.NAME_MOJI_MIN", win_no); config.GetParam(key, 1, &name_min); 2007 sprintf(key, "#WINDOW.%03d.NAME_MOJI_MIN", win_no); config->GetParam(key, 1, &name_min);
2002 sprintf(key, "#WINDOW.%03d.NAME_MOJI_POS", win_no); config.GetParam(key, 2, &name_mposx, &name_mposy); 2008 sprintf(key, "#WINDOW.%03d.NAME_MOJI_POS", win_no); config->GetParam(key, 2, &name_mposx, &name_mposy);
2003 sprintf(key, "#WINDOW.%03d.NAME_CENTERING", win_no); config.GetParam(key, 1, &name_center); 2009 sprintf(key, "#WINDOW.%03d.NAME_CENTERING", win_no); config->GetParam(key, 1, &name_center);
2004 sprintf(key, "#WINDOW.%03d.NAME_POS", win_no); config.GetParam(key, 2, &name_posx, &name_posy); 2010 sprintf(key, "#WINDOW.%03d.NAME_POS", win_no); config->GetParam(key, 2, &name_posx, &name_posy);
2005 // if name_mode==0 name is in the text window 2011 // if name_mode==0 name is in the text window
2006 // if name_mode == 1 open name window 2012 // if name_mode == 1 open name window
2007 // if name_mode == 2 name is not used 2013 // if name_mode == 2 name is not used
2008 if (name_mod) { 2014 if (name_mod) {
2009 if (name_mod == 1) { 2015 if (name_mod == 1) {
2010 int w = name_size*name_min; int h = name_size; 2016 int w = name_size*name_min; int h = name_size;
2011 int name_waku; 2017 int name_waku;
2012 sprintf(key, "#WINDOW.%03d.NAME_WAKU_SETNO", win_no); 2018 sprintf(key, "#WINDOW.%03d.NAME_WAKU_SETNO", win_no);
2013 if (config.GetParam(key, 1, &name_waku) != -1 && name_waku != -1) { 2019 if (config->GetParam(key, 1, &name_waku) != -1 && name_waku != -1) {
2014 Rect waku_r = WakuSize(parent, name_waku, config); 2020 Rect waku_r = WakuSize(parent, name_waku);
2015 waku_r.rmove(r.lx, r.ty); // テキストウィンドウ位置に動かす 2021 waku_r.rmove(r.lx, r.ty); // テキストウィンドウ位置に動かす
2016 waku_r.rmove(name_posx, name_posy-waku_r.height()); // NAME_POS へ位置補正 2022 waku_r.rmove(name_posx, name_posy-waku_r.height()); // NAME_POS へ位置補正
2017 name_container = parent.create_node(waku_r, 0); 2023 name_container = parent.create_node(waku_r, 0);
2018 MakeWaku(*name_container, event, name_waku, win_no, 0, config, callback); 2024 MakeWaku(*name_container, event, name_waku, win_no, 0, callback);
2019 Rect name_r(0,0,w,h); 2025 Rect name_r(0,0,w,h);
2020 name_r.rmove(name_mposx, name_mposy); 2026 name_r.rmove(name_mposx, name_mposy);
2021 name = new WidLabel(name_container, name_r, true, 0, name_size); 2027 name = new WidLabel(name_container, name_r, true, 0, name_size);
2022 name->show(); 2028 name->show();
2023 } else { // 名前専用枠なし 2029 } else { // 名前専用枠なし
2031 } 2037 }
2032 } else { // name_mod == 2 or 3 2038 } else { // name_mod == 2 or 3
2033 name_container = parent.create_node( Rect(0, 0, 1, 1), 0); 2039 name_container = parent.create_node( Rect(0, 0, 1, 1), 0);
2034 } 2040 }
2035 } 2041 }
2036 MakeWaku(*wid->PicNode(), event,waku_no, win_no, use_btn, config, callback); 2042 MakeWaku(*wid->PicNode(), event,waku_no, win_no, use_btn, callback);
2037 } 2043 }
2038 2044
2039 void TextImpl::InitWindow(void) { 2045 void TextImpl::InitWindow(void) {
2040 int i; 2046 int i;
2041 int w; 2047 int w;
2042 std::string str; 2048 std::string str;
2043 2049
2044 for (w=0; w<32; w++) { 2050 for (w=0; w<32; w++) {
2045 widgets[w] = new TextWindow(parent, event, w, config, (void*)this); 2051 widgets[w] = new TextWindow(parent, event, w, (void*)this);
2046 if (widgets[w]->wid == 0) { 2052 if (widgets[w]->wid == 0) {
2047 delete widgets[w]; 2053 delete widgets[w];
2048 widgets[w] = NULL; 2054 widgets[w] = NULL;
2049 } 2055 }
2050 } 2056 }
2051 SetCursor(0); 2057 SetCursor(0);
2052 for (i=0; i<26; i++) { 2058 for (i=0; i<26; i++) {
2053 char buf[1024]; 2059 char buf[1024];
2054 sprintf(buf, "#NAME.%c", i+'A'); 2060 sprintf(buf, "#NAME.%c", i+'A');
2055 const char* s = config.GetParaStr(buf); 2061 const char* s = config->GetParaStr(buf);
2056 if (s != NULL) replace_name[i] = s; 2062 if (s != NULL) replace_name[i] = s;
2057 } 2063 }
2058 // replace_name2 : 初期設定 2064 // replace_name2 : 初期設定
2059 // 渚、秋生、渚 (CLANNAD) 2065 // 渚、秋生、渚 (CLANNAD)
2060 char name_nagisa[3] = {'\x8f', '\x8d', '\0'}; 2066 char name_nagisa[3] = {'\x8f', '\x8d', '\0'};
2063 replace_name2[1] = name_akio; 2069 replace_name2[1] = name_akio;
2064 replace_name2[2] = name_nagisa; 2070 replace_name2[2] = name_nagisa;
2065 text = NULL; 2071 text = NULL;
2066 /* テキスト速度の設定 */ 2072 /* テキスト速度の設定 */
2067 int speed, mod, wait, auto_mod; 2073 int speed, mod, wait, auto_mod;
2068 config.GetParam("#INIT_MESSAGE_SPEED", 1, &speed); 2074 config->GetParam("#INIT_MESSAGE_SPEED", 1, &speed);
2069 config.GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &mod); 2075 config->GetParam("#INIT_MESSAGE_SPEED_MOD", 1, &mod);
2070 config.GetParam("#MESSAGE_KEY_WAIT_USE", 1, &auto_mod); 2076 config->GetParam("#MESSAGE_KEY_WAIT_USE", 1, &auto_mod);
2071 config.GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait); 2077 config->GetParam("#MESSAGE_KEY_WAIT_TIME", 1, &wait);
2072 if (mod) speed = -1; 2078 if (mod) speed = -1;
2073 if (!auto_mod) wait = -1; 2079 if (!auto_mod) wait = -1;
2074 SetTextSpeed(speed); 2080 SetTextSpeed(speed);
2075 SetTextWait(wait); 2081 SetTextWait(wait);
2076 return; 2082 return;