home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 September / VPR9809A.ISO / FFILLY / Chat091 / chat.tfy < prev    next >
Text File  |  1998-04-21  |  54KB  |  1,429 lines

  1. //chat.tfy
  2. #info INAM "Filly de Chat Ver.0.91"
  3. #info ISBJ "Fillyで動くチャットソフト"
  4. #info IART "Koji TAKAHASHI/POCOPEN,poco@yun.co.jp,GGB02243@niftyserve.or.jp"
  5. #info ICOP "Koji TAKAHASHI/POCOPEN,poco@yun.co.jp,GGB02243@niftyserve.or.jp"
  6. #info IENG "Koji TAKAHASHI/POCOPEN,poco@yun.co.jp,GGB02243@niftyserve.or.jp"
  7. #info IGNR "utility"
  8. #info IKEY "chat"
  9. #info GENR "utility"
  10. #info MDFY "Ask me"
  11. #info TRNS "Ask me"
  12. #info JINT "Ask me"
  13. #info VIDO "800x600,65536"
  14. #info PROD "Koji TAKAHASHI/POCOPEN,poco@yun.co.jp,GGB02243@niftyserve.or.jp"
  15. #info THKS "Yun,tomo@yun.co.jp;Yu-chan,yuji@yun.co.jp;Kage-chan,kage@yun.co.jp;Moriq,moriq@ma2.seikyou.ne.jp"
  16. #info CONT "Koji TAKAHASHI/POCOPEN,poco@yun.co.jp,GGB02243@niftyserve.or.jp"
  17.  
  18. #include rgb2bgr.h
  19. #include draw3D.h
  20.  
  21. #define WAIT 1
  22.  
  23. str recordTime();
  24. str lastStr();
  25.  
  26. str LF,CR,CD,start,record[],fileName,font,name,link[],oldJob,bName[],Handle;
  27. int pic,rCol[],ID,eCol[],help,width,height,fSize,lSize,bHeight,lines;
  28. int user[],userMax,count,top,mode,y,scLine,no,lHandle,cFlag,oldHeight,oldLines;
  29. int sl[],el[],sx[],ex[],sp[],ep[],key[],mWin,res[],res2[],wid[],fmode;
  30. int cWinx,cWiny,mWinx,mWiny;
  31.  
  32. main(){
  33. Debug(1);
  34.     int i,pic0;
  35.     int length;
  36.     str VER;
  37.     VER="2.31";
  38.     LF=StrCode(0x0a);
  39.     CR=StrCode(0x0d);
  40.     CD=GetCWD();
  41.     length=StrLen(CD);
  42.     if(SubStr(CD,length-1,1)!="\")CD=CD+"\";
  43.     if(GetVer()<VER)exit(VER);
  44.     loadIni();
  45.     BackMode(1);
  46.     bgCol(eCol[0]);
  47.     makeBmp("chat.bmp");
  48.     pic0=LoadPic("chat.bmp");
  49.     bHeight=24;
  50.     pic=CreatePic(pic0,width,height+bHeight);
  51.     DelPic(pic0);
  52.     fmode=0;
  53.     makeWindow();
  54.     textCol(eCol[2]);
  55.     SetFont(fSize,font,128,0,0,0,500);
  56.     if(help)showHelp(1);
  57.     ready0();
  58. }
  59.  
  60. int ready0(){
  61.     int i;
  62.     mes(KEY_DOWN){
  63.         if(StrCode(MesP2)=="A"){
  64.             del_us;
  65.             init();
  66.             del_me;
  67.         }
  68.         else if(StrCode(MesP2)=="C"){
  69.             del_us;
  70.             custom();
  71.             del_me;
  72.         }
  73.         else if(StrCode(MesP2)=="H"||MesP2==113){
  74.             SetLineSize(4);
  75.             SetPaintColor(eCol[0]);
  76.             DrawRect(pic,0,0,width,height-1);
  77.             textCol(eCol[2]);
  78.             SetFont(fSize,font,128,0,0,0,500);
  79.             showHelp(1);
  80.         }
  81.         else if(StrCode(MesP2)=="E"||MesP2==27){
  82.             del_us;
  83.             end(0,2);
  84.             del_me;
  85.         }
  86.     }
  87.     mes(LBDOWN){
  88.         if(MesP2>=0&&MesP2<80&&MesP3>=height&&MesP3<height+bHeight){
  89.             mes(TIME){step(WAIT){del_us;buttonAction(0);
  90.             ,,,,,,init();del_me}}
  91.         }
  92.         else if(MesP2>=80&&MesP2<160&&MesP3>=height&&MesP3<height+bHeight){
  93.             del_us;
  94.             buttonAction(1);
  95.             custom();
  96.             del_me;
  97.         }
  98.         else if(MesP2>=160&&MesP2<240&&MesP3>=height&&MesP3<height+bHeight){
  99.             buttonAction(2);
  100.             SetLineSize(4);
  101.             SetPaintColor(eCol[0]);
  102.             DrawRect(pic,0,0,width,height-1);
  103.             textCol(eCol[2]);
  104.             SetFont(fSize,font,128,0,0,0,500);
  105.             showHelp(1);
  106.         }
  107.         else if(MesP2>=240&&MesP2<320&&MesP3>=height&&MesP3<height+bHeight){
  108.             mes(TIME){step(WAIT){del_us;buttonAction(3);
  109.             ,,,,,,end(0,2);del_me}}
  110.         }
  111.     }
  112.     mes(RBDOWN){
  113.         del_us;
  114.         end(0,2);
  115.         del_me;
  116.     }
  117. }
  118.  
  119. int buttonAction(int i){
  120.     mes(TIME){
  121.         step(WAIT){
  122.             SetFont(16,"MS ゴシック",128,0,0,0,500);
  123.             SetLineSize(1);
  124.             draw3D(pic,i*80,height,i*80+79,height+bHeight-1,eCol[0],2,20,1);
  125.             textCol(0x0);
  126.             TextWrite(bName[i],pic,i*80+10,height+(bHeight-16)/2+3);
  127.             textCol(eCol[2]);
  128.             TextWrite(bName[i],pic,i*80+9,height+(bHeight-16)/2+2);
  129.             ,,,draw3D(pic,i*80,height,i*80+79,height+bHeight-1,eCol[0],2,20,0);
  130.             textCol(0x0);
  131.             TextWrite(bName[i],pic,i*80+8,height+(bHeight-16)/2+1);
  132.             textCol(eCol[2]);
  133.             TextWrite(bName[i],pic,i*80+7,height+(bHeight-16)/2);
  134.             del_me;
  135.            }
  136.      }
  137. }
  138.  
  139. int ready(){
  140.     int i,j;
  141.     int x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
  142.     mes(DP_RECEIVE){
  143.         getMes(DPGetMessage(),MesP1,MesP2);
  144.     }
  145.  
  146.     mes(KEY_DOWN){
  147.         getKey(MesP1,MesP2);
  148.     }
  149.     mes(RBDOWN){
  150.         end(count);
  151.     }
  152.  
  153.     mes(LBDOWN){
  154.         for(i=0;i<7;i=i+1){
  155.             if(MesP2>=i*80&&MesP2<i*80+80&&MesP3>=height&&MesP3<height+bHeight){
  156.                 mes(TIME){
  157.                     step(WAIT){
  158.                         SetFont(16,"MS ゴシック",128,0,0,0,500);
  159.                         SetLineSize(1);
  160.                         draw3D(pic,i*80,height,i*80+79,height+bHeight-1,eCol[0],2,20,1);
  161.                         textCol(0x0);
  162.                         TextWrite(bName[i],pic,i*80+10,height+(bHeight-16)/2+3);
  163.                         textCol(eCol[2]);
  164.                         TextWrite(bName[i],pic,i*80+9,height+(bHeight-16)/2+2);
  165.                         ,,,draw3D(pic,i*80,height,i*80+79,height+bHeight-1,eCol[0],2,20,0);
  166.                         textCol(0x0);
  167.                         TextWrite(bName[i],pic,i*80+8,height+(bHeight-16)/2+1);
  168.                         textCol(eCol[2]);
  169.                         TextWrite(bName[i],pic,i*80+7,height+(bHeight-16)/2);
  170.                         PostMes(KEY_DOWN,0,key[i]);
  171.                         SetFont(fSize,font,128,0,0,0,500);
  172.                         del_me;
  173.                     }
  174.                 }
  175.                 break;
  176.             }
  177.         }
  178.         for(j=0;j<no;j=j+1){
  179.             if(sl[j]==el[j]){
  180.                 x1=sx[j]+10;
  181.                 x2=ex[j]+10;
  182.                 y1=(sl[j]-top)*lSize;
  183.                 y2=(sl[j]-top+1)*lSize;
  184.                 if(MesP2>=x1&&MesP2<x2&&MesP3>=y1&&MesP3<y2){
  185.                     if(GetColor(pic,MesP2,(MesP3/lSize)*lSize+fSize)==eCol[1])
  186.                     Shell(link[j]);
  187.                 }
  188.                 if(mode==1||mode==2){
  189.                     y1=(lines-(count-sl[j]))*lSize;
  190.                     y2=(lines-(count-sl[j])+1)*lSize;
  191.                     if(MesP2>=x1&&MesP2<x2&&MesP3>=y1&&MesP3<y2){
  192.                     if(GetColor(pic,MesP2,(MesP3/lSize)*lSize+fSize)==eCol[1])
  193.                         Shell(link[j]);
  194.                     }
  195.                 }
  196.             }
  197.             else if(el[j]-sl[j]==1){
  198.                 x1=sx[j]+10;
  199.                 x2=wid[sl[j]]+10;
  200.                 y1=(sl[j]-top)*lSize;
  201.                 y2=(sl[j]-top+1)*lSize;
  202.                 x3=10;
  203.                 x4=ex[j]+10;
  204.                 y3=(el[j]-top)*lSize;
  205.                 y4=(el[j]-top+1)*lSize;
  206.                 if((MesP2>=x1&&MesP2<x2&&MesP3>=y1&&MesP3<y2)||(MesP2>=x3&&MesP2<x4&&MesP3>=y3&&MesP3<y4)){
  207.                     if(GetColor(pic,MesP2,(MesP3/lSize)*lSize+fSize)==eCol[1])
  208.                     Shell(link[j]);
  209.                 }
  210.                 if(mode==1||mode==2){
  211.                     y1=(lines-(count-sl[j]))*lSize;
  212.                     y2=(lines-(count-sl[j])+1)*lSize;
  213.                     y3=(lines-(count-el[j]))*lSize;
  214.                     y4=(lines-(count-el[j])+1)*lSize;
  215.                 if((MesP2>=x1&&MesP2<x2&&MesP3>=y1&&MesP3<y2)||(MesP2>=x3&&MesP2<x4&&MesP3>=y3&&MesP3<y4)){
  216.                     if(GetColor(pic,MesP2,(MesP3/lSize)*lSize+fSize)==eCol[1])
  217.                         Shell(link[j]);
  218.                     }
  219.                 }
  220.             }
  221.             else if(el[j]-sl[j]==2){
  222.                 x1=sx[j]+10;
  223.                 x2=wid[sl[j]]+10;
  224.                 y1=(sl[j]-top)*lSize;
  225.                 y2=(sl[j]-top+1)*lSize;
  226.                 x3=10;
  227.                 x4=wid[sl[j]+1]+10;
  228.                 x5=10;
  229.                 x6=ex[j]+10;
  230.                 y3=(el[j]-top-1)*lSize;
  231.                 y4=(el[j]-top)*lSize;
  232.                 y5=(el[j]-top)*lSize;
  233.                 y6=(el[j]-top+1)*lSize;
  234.                 if((MesP2>=x1&&MesP2<x2&&MesP3>=y1&&MesP3<y2)||(MesP2>=x3&&MesP2<x4&&MesP3>=y3&&MesP3<y4)||(MesP2>=x5&&MesP2<x6&&MesP3>=y5&&MesP3<y6)){
  235.                     if(GetColor(pic,MesP2,(MesP3/lSize)*lSize+fSize)==eCol[1])
  236.                     Shell(link[j]);
  237.                 }
  238.                 if(mode==1||mode==2){
  239.                     y1=(lines-(count-sl[j]))*lSize;
  240.                     y2=(lines-(count-sl[j])+1)*lSize;
  241.                     y3=(lines-(count-sl[j])-1)*lSize;
  242.                     y4=(lines-(count-sl[j]))*lSize;
  243.                     y5=(lines-(count-el[j]))*lSize;
  244.                     y6=(lines-(count-el[j])+1)*lSize;
  245.                 if((MesP2>=x1&&MesP2<x2&&MesP3>=y1&&MesP3<y2)||(MesP2>=x3&&MesP2<x4&&MesP3>=y3&&MesP3<y4)||(MesP2>=x5&&MesP2<x6&&MesP3>=y5&&MesP3<y6)){
  246.                     if(GetColor(pic,MesP2,(MesP3/lSize)*lSize+fSize)==eCol[1])
  247.                         Shell(link[j]);
  248.                     }
  249.                 }
  250.             }
  251.         }
  252.     }
  253. }
  254.  
  255. //画面スクロール関数
  256. int scroll(int s,int h){
  257.     MovePic(pic,0,s,width,h-lSize,pic,0,s-lSize);
  258.     SetLineSize(4);
  259.     SetPaintColor(eCol[0]);
  260.     DrawRect(pic,0,height-lSize,width,height);
  261. }
  262.  
  263. //バージョン違い
  264. int exit(int VER){
  265.     MsgBox(StrPrint("Filly.exe Ver.%s 以上が必要です","2.31"));
  266.     del_all;
  267.     del_me;
  268. }
  269.  
  270. //全角半角混在文の切り分け関数
  271. int splitStr1(str s,int l){//文字列、欲しい文字数-1
  272.     int i,c;
  273.     i=0;
  274.     for(;;){
  275.         c=CharCode(SubStr(s,i,1));
  276.         if((c>=0x81&&c<=0x9f)||(c>=0xe0&&c<=0xfc)){
  277.             c=CharCode(SubStr(s,i+1,1));
  278.             if((c>=0x40&&c<=0x7e)||(c>=0x80&&c<=0xfc)){
  279.                 i=i+2;
  280.             }
  281.             else i=i+1;
  282.         }
  283.         else i=i+1;
  284.         if(i>=l)break;
  285.     }
  286.     return(i);//分割位置
  287. }
  288.  
  289. //ログ記録&終了
  290. int end(int count,int s=0){
  291.     if(s==0){
  292.         if(MsgBox("チャットから抜けますか?",0x24)==6){
  293.             int file,i;
  294.             str logFile;
  295.             mes(TIME){
  296.                 step(5){
  297.                     DPSendMessage(DPGetName(ID),2);
  298.                     ,,,,DPEnd();
  299.                     del_all;
  300.                     record[count+1]=recordTime(1);
  301.                     logFile=CD+StrPrint("ch%ld.log",WhatDay());
  302.                     if(IsExist(logFile))file=OpenF(logFile,0x1);
  303.                     else file=OpenF(logFile,0x1001);
  304.                     SeekF(file,0,2);
  305.                     StrWriteF(file,start+LF);
  306.                     for(i=0;i<=count+1;i=i+1){
  307.                         StrWriteF(file,record[i]+LF);
  308.                     }
  309.                     CloseF(file);
  310.                     fmode=0;
  311.                     makeButton();
  312.                     ready0();
  313.                     del_me;
  314.                 }
  315.             }
  316.         }
  317.     }
  318.     else if(s==1){
  319.         if(MsgBox("チャットから抜けますか?",0x24)==6){
  320.             mes(TIME){
  321.                 step(5){
  322.                     DPSendMessage(DPGetName(ID),2);
  323.                     ,,,DPEnd();
  324.                     del_all;
  325.                     fmode=0;
  326.                     makeButton();
  327.                     ready0();
  328.                     del_me;
  329.                 }
  330.             }
  331.         }
  332.     }
  333.     else if(s==2){
  334.         if(MsgBox("終了しますか?",0x24)==6){
  335.             del_all;
  336.             mWinx=GetLowWord(GetWinPos(mWin));
  337.             mWiny=GetHiWord(GetWinPos(mWin));
  338.             saveIni();
  339.             CloseWinAll();
  340.             del_me;
  341.         }
  342.         else ready0();
  343.     }
  344. }
  345.  
  346. //1x1ドットのBMPファイルを新たに作る関数
  347. int makeBmp(str bmpFile){
  348.     if(IsExist(bmpFile)==0){
  349.         int code[],i,file;
  350.         code[0]=0x4d42; code[1]=0x0044; code[2]=0x0000; code[3]=0x0000;
  351.         code[4]=0x0000; code[5]=0x003e; code[6]=0x0000; code[7]=0x0028;
  352.         code[8]=0x0000; code[9]=0x0001; code[10]=0x0000;code[11]=0x0001;
  353.         code[12]=0x0000;code[13]=0x0001;code[14]=0x0004;code[15]=0x0000;
  354.         code[16]=0x0000;code[17]=0x0000;code[18]=0x0000;code[19]=0x0b12;
  355.         code[20]=0x0000;code[21]=0x0b12;code[22]=0x0000;code[23]=0x0002;
  356.         code[24}=0x0000;code[25]=0x0002;code[26]=0x0000;code[27]=0xffff;
  357.         code[28]=0x00ff;code[29]=0x0000;code[30]=0x0000;code[31]=0x0000;
  358.         code[32]=0x0000;code[33]=0x0000;
  359.         file=OpenF(bmpFile,0x9001);
  360.         for(i=0;i<34;i=i+1){
  361.             WriteF(file,code[i],2);
  362.         }
  363.         CloseF(file);
  364.     }
  365. }
  366.  
  367. //発言の表示
  368. int writeRec(int repaint=0){
  369.     int bottom;
  370.     if(mode==1||mode==2){
  371.         SetLineSize(4);
  372.         SetPaintColor(eCol[0]);
  373.         DrawRect(pic,0,0,width,height-scLine*lSize);
  374.         bottom=top+lines-scLine;
  375.         writeLine(0,top,bottom);
  376.         if(repaint){
  377.             DrawRect(pic,0,height-scLine*lSize,width,height);
  378.             SetLineSize(1);
  379.             SetPaintColor(eCol[6]);
  380.             DrawRect(pic,0,height-scLine*lSize-2,width,height-scLine*lSize-1);
  381.             bottom=count;
  382.             writeLine(height-scLine*lSize,bottom-scLine,bottom);
  383.         }
  384.     }
  385.     else{
  386.         if(repaint){
  387.             writeLine(0,top,count);
  388.         }
  389.         else{
  390.             SetPaintColor(eCol[0]);
  391.             SetLineSize(4);
  392.             DrawRect(pic,0,0,width,height-scLine*lSize);
  393.             writeLine(0,top,count-scLine);
  394.         }
  395.     }
  396. }
  397.  
  398. //行を表示
  399. int writeLine(int y0,int lTop,int lBottom){
  400.     int i,j,yy;
  401.     yy=y0;
  402.     for(i=lTop;i<lBottom;i=i+1){
  403.         SetPaintColor(eCol[rCol[i]]);
  404.         SetLineSize(1);
  405.         textCol(eCol[rCol[i]]);
  406.         TextWrite(record[i],pic,10,yy+1);
  407.         for(j=0;j<no;j=j+1){
  408.             if(i==sl[j]&&i==el[j]){
  409.                 DrawRect(pic,sx[j]+10,yy+fSize,ex[j]+10,yy+fSize+1);
  410.             }
  411.             else if(i==sl[j]&&i!=el[j]){
  412.                 DrawRect(pic,sx[j]+10,yy+fSize,wid[i]+10,yy+fSize+1);
  413.             }
  414.             else if(i!=sl[j]&&i==el[j]){
  415.                 DrawRect(pic,10,yy+fSize,ex[j]+10,yy+fSize+1);
  416.             }
  417.             if(i>sl[j]&&i<el[j]){
  418.                 DrawRect(pic,10,yy+fSize,wid[i]+10,yy+fSize+1);
  419.             }
  420.         }
  421.         yy=yy+lSize;
  422.     }
  423.     SetPaintColor(eCol[0]);
  424.     SetLineSize(4);
  425. }
  426.  
  427. //メッセージの表示
  428. int getMes(str Mes,int mesp1,int mesp2){
  429.     int col,i,j,point,length,lLength,oldPoint,cCount,ePoint,sPoint;
  430.     int uPoint,mPoint,devide,ce[],cs[],oldno,oldep;
  431.     str Speaker,Mes2,Mes3;
  432.     col=5;
  433.     textCol(eCol[col]);
  434.     Speaker=DPGetName(mesp1);
  435.     if(mesp1!=0){
  436.         if(mesp2==0&&mesp1!=ID){
  437.             if(DPIsHost()){
  438.                 user[userMax]=StrtoInt(Mes);
  439.                 userMax=userMax+1;
  440.                 for(i=0;i<userMax;i=i+1){
  441.                     DPSendMessage(StrPrint("%ld",user[i]),4);
  442.                 }
  443.             }
  444.             else{
  445.                 userMax=0;
  446.             }
  447.             Mes=StrPrint("system:%s がチャットに参加しました",DPGetName(StrtoInt(Mes)));
  448.         }
  449.         else if(mesp2==0&&mesp1==ID){
  450.             Mes="system:チャットに参加しました";
  451.         }
  452.         else if(mesp2==7){
  453.             Mes=StrPrint("system:ハンドル変更( %s )",Mes);
  454.         }
  455.         else if(mesp2==2){
  456.             if(mesp1==ID)Mes="system:チャットを終了しました";
  457.             else Mes=StrPrint("system:%s がチャットを終了しました",Mes);
  458.             for(i=0;i<userMax;i=i+1){
  459.                 if(user[i]==mesp1)user[i]=0;
  460.             }
  461.         }
  462.         else if(mesp2==1||mesp2==10||mesp2==11||mesp2==ID+1000){
  463.             if(mesp2==1){
  464.                 Mes=StrPrint("(%s)%s",Speaker,Mes);
  465.                 col=1;
  466.             }
  467.             else if(mesp2==10&&mesp1==ID){
  468.                 col=4;
  469.             }
  470.             else if(mesp2==11&&mesp1==ID){
  471.                 col=2;
  472.             }
  473.             else if(mesp2==ID+1000){
  474.                 if(mesp1!=ID){
  475.                     for(i=0;i<userMax;i=i+1){
  476.                         if(user[i]==mesp1)oldJob=StrPrint("%ld",i+1);
  477.                     }
  478.                 }
  479.                 col=3;
  480.             }
  481.             textCol(eCol[col]);
  482.         }
  483.         if(mesp2==4){
  484.             if(DPIsHost()==0){
  485.                 user[userMax]=StrtoInt(Mes);
  486.                 userMax=userMax+1;
  487.             }
  488.         }
  489.         else if(mesp2==0||mesp2==1||mesp2==2||mesp2==7||(mesp2==10&&mesp1==ID)||(mesp2==11&&mesp1==ID)||mesp2==ID+1000){
  490.             if(StrFind(Mes,StrPrint(">%s",DPGetName(ID)))!=-1){
  491.                 col=7;
  492.                 textCol(eCol[col]);
  493.             }
  494.             oldno=no;
  495.             Mes2=Mes;
  496.             oldep=0;
  497.             while(StrFind(Mes2,"http://")!=-1){
  498.                 length=StrLen(Mes2);
  499.                 sPoint=StrFind(Mes2,"http://");//リンク開始位置の、先頭からの文字数
  500.                 Mes3=SubStr(Mes2,0,sPoint);
  501.                 sp[no]=getStrWidth(Mes3,font,fSize)+oldep;//リンク開始位置のx座標
  502.                 Mes3=SubStr(Mes2,sPoint,length-sPoint);
  503.                 ePoint=StrFind(Mes3," ");
  504.                 if(ePoint!=-1)ePoint=ePoint+sPoint;
  505.                 else ePoint=StrLen(Mes3)+sPoint;//リンク終了位置の、先頭からの文字数
  506.                 Mes3=SubStr(Mes2,0,ePoint);
  507.                 ep[no]=getStrWidth(Mes3,font,fSize)+oldep;//リンク終了位置のx座標
  508.                 link[no]=SubStr(Mes2,sPoint,ePoint-sPoint);
  509.                 Mes2=SubStr(Mes2,ePoint,length-ePoint);
  510.                 oldep=ep[no];
  511.                 ce[no]=0;
  512.                 cs[no]=0;
  513.                 no=no+1;
  514.             }
  515.             Mes2=Mes;
  516.             oldep=0;
  517.             while(StrFind(Mes2,"mailto:")!=-1){
  518.                 length=StrLen(Mes2);
  519.                 sPoint=StrFind(Mes2,"mailto:");//リンク開始位置の、先頭からの文字数
  520.                 Mes3=SubStr(Mes2,0,sPoint);
  521.                 sp[no]=getStrWidth(Mes3,font,fSize)+oldep;//リンク開始位置のx座標
  522.                 Mes3=SubStr(Mes2,sPoint,length-sPoint);
  523.                 ePoint=StrFind(Mes3," ");
  524.                 if(ePoint!=-1)ePoint=ePoint+sPoint;
  525.                 else ePoint=StrLen(Mes3)+sPoint;//リンク終了位置の、先頭からの文字数
  526.                 Mes3=SubStr(Mes2,0,ePoint);
  527.                 ep[no]=getStrWidth(Mes3,font,fSize)+oldep;//リンク終了位置のx座標
  528.                 link[no]=SubStr(Mes2,sPoint,ePoint-sPoint);
  529.                 Mes2=SubStr(Mes2,ePoint,length-ePoint);
  530.                 oldep=ep[no];
  531.                 ce[no]=0;
  532.                 cs[no]=0;
  533.                 no=no+1;
  534.             }
  535.             devide=splitStr(Mes,width-10-fSize,font,fSize);
  536.             res[0]=0;
  537.             res2[0]=0;
  538.             textCol(eCol[col]);
  539.             SetFont(fSize,font,128,0,0,0,500,0,0);
  540.             for(i=1;i<=devide;i=i+1){
  541.                 wid[count]=res2[i]-res2[i-1];
  542.                 rCol[count]=col;
  543.                 record[count]=SubStr(Mes,res[i-1],res[i]-res[i-1]);
  544.                 if(y==height){
  545.                     if(mode==0)scroll(lSize,height);
  546.                     else scroll(height-(scLine-1)*lSize,scLine*lSize);
  547.                     TextWrite(record[count],pic,10,height-lSize+1);
  548.                     SetPaintColor(eCol[col]);
  549.                     SetLineSize(1);
  550.                     for(j=oldno;j<no;j=j+1){
  551.                         if(cs[j]!=1&&ce[j]!=1&&sp[j]>=res2[i-1]&&sp[j]<res2[i]&&ep[j]<=res2[i]){
  552.                             sx[j]=sp[j]-res2[i-1];
  553.                             ex[j]=ep[j]-res2[i-1];
  554.                             cs[j]=1;
  555.                             ce[j]=1;
  556.                             sl[j]=count;
  557.                             el[j]=count;
  558.                             DrawRect(pic,sx[j]+10,y-lSize+fSize,ex[j]+10,y-lSize+fSize+1);
  559.                         }
  560.                         else if(cs[j]!=1&&ce[j]!=1&&sp[j]>=res2[i-1]&&sp[j]<res2[i]&&ep[j]>res2[i]){
  561.                             sx[j]=sp[j]-res2[i-1];
  562.                             cs[j]=1;
  563.                             sl[j]=count;
  564.                             DrawRect(pic,sx[j]+10,y-lSize+fSize,res2[i]+10,y-lSize+fSize+1);
  565.                         }
  566.                         else if(cs[j]==1&&ce[j]!=1&&sp[j]<=res2[i-1]&&ep[j]>res2[i]){
  567.                             DrawRect(pic,10,y-lSize+fSize,res2[i]+10,y-lSize+fSize+1);
  568.                         }
  569.                         else if(cs[j]==1&&ce[j]!=1&&sp[j]<=res2[i-1]&&ep[j]>res2[i-1]&&ep[j]<=res2[i]){
  570.                             ex[j]=ep[j]-res2[i-1];
  571.                             ce[j]=1;
  572.                             el[j]=count;
  573.                             DrawRect(pic,10,y-lSize+fSize,ex[j]+10,y-lSize+fSize+1);
  574.                         }
  575.                     }
  576.                     if(mode==0)top=top+1;
  577.                 }
  578.                 else{
  579.                     TextWrite(record[count],pic,10,y+1);
  580.                     SetPaintColor(eCol[col]);
  581.                     SetLineSize(1);
  582.                     for(j=oldno;j<no;j=j+1){
  583.                         if(cs[j]!=1&&ce[j]!=1&&sp[j]>=res2[i-1]&&sp[j]<res2[i]&&ep[j]>res2[i-1]&&ep[j]<=res2[i]){
  584.                             sx[j]=sp[j]-res2[i-1];
  585.                             ex[j]=ep[j]-res2[i-1];
  586.                             cs[j]=1;
  587.                             ce[j]=1;
  588.                             sl[j]=count;
  589.                             el[j]=count;
  590.                             DrawRect(pic,sx[j]+10,y+fSize,ex[j]+10,y+fSize+1);
  591.                         }
  592.                         if(cs[j]!=1&&ce[j]!=1&&sp[j]>=res2[i-1]&&sp[j]<res2[i]&&ep[j]>res2[i]){
  593.                             sx[j]=sp[j]-res2[i-1];
  594.                             cs[j]=1;
  595.                             sl[j]=count;
  596.                             DrawRect(pic,sx[j]+10,y+fSize,res2[i]+10,y+fSize+1);
  597.                         }
  598.                         if(cs[j]==1&&ce[j]!=1&&sp[j]<=res2[i-1]&&ep[j]>res2[i]){
  599.                             DrawRect(pic,10,y+fSize,res2[i]+10,y+fSize+1);
  600.                         }
  601.                         if(cs[j]==1&&ce[j]!=1&&sp[j]<=res2[i-1]&&ep[j]>res2[i-1]&&ep[j]<=res2[i]){
  602.                             ex[j]=ep[j]-res2[i-1];
  603.                             ce[j]=1;
  604.                             el[j]=count;
  605.                             DrawRect(pic,10,y+fSize,ex[j]+10,y+fSize+1);
  606.                         }
  607.                     }
  608.                     y=y+lSize;
  609.                 }
  610.                 count=count+1;
  611.             }
  612.         }
  613.     }
  614. }
  615.  
  616. //キーボード操作
  617. int getKey(int mesP1,int mesP2){
  618.     str Mesk,line[],job,oldHandle;
  619.     int length,i,sjob,rjob,max,fileNo;
  620.     if((mesP2==36||mesP2==38||mesP2==33)&&(y==height||mode!=0)&&top>0){
  621.         mode=1;
  622.         if(mesP2==38)top=top-1;
  623.         else if(mesP2==36)top=0;
  624.         else if(mesP2==33)top=top-height/(lSize*2);
  625.         if(top<0)top=0;
  626.         writeRec();
  627.         SetLineSize(1);
  628.         SetPaintColor(eCol[6]);
  629.         DrawRect(pic,0,height-scLine*lSize-2,width,height-scLine*lSize-1);
  630.         SetLineSize(4);
  631.         SetPaintColor(eCol[0]);
  632.     }
  633.     else if(mesP2==35&&mode!=0){
  634.         mode=0;
  635.         top=count-lines;
  636.         writeRec();
  637.     }
  638.     else if((mesP2==40||mesP2==34)&&mode!=0&&top<count-lines+1){
  639.         if((mesP2==40&&top==count-lines-1)||(mesP2==34&&top>=count-lines-height/(lSize*2))){
  640.             mode=0;
  641.             top=count-lines;
  642.             writeRec();
  643.         }
  644.         else{
  645.             mode=2;
  646.             if(mesP2==40)top=top+1;
  647.             if(mesP2==34)top=top+height/(lSize*2);
  648.             if(top>count-lines)top=count-lines;
  649.             writeRec();
  650.             SetLineSize(1);
  651.             SetPaintColor(eCol[6]);
  652.             DrawRect(pic,0,height-scLine*lSize-2,width,height-scLine*lSize-1);
  653.             SetLineSize(4);
  654.             SetPaintColor(eCol[0]);
  655.         }
  656.     }
  657.     else if(mesP2==13){
  658.         Mesk=StrInput("メッセージを入力してください","");
  659.         if(Mesk=="/U"||Mesk=="/u")PostMes(KEY_DOWN,0,119);
  660.         else if(Mesk=="/F"||Mesk=="/f")PostMes(KEY_DOWN,0,118);
  661.         else if(Mesk=="/N"||Mesk=="/n")PostMes(KEY_DOWN,0,115);
  662.         else if(SubStr(Mesk,0,3)=="/F "||SubStr(Mesk,0,3)=="/f ")PostMes(KEY_DOWN,1,118);
  663.         else if(SubStr(Mesk,0,3)=="/N "||SubStr(Mesk,0,3)=="/n ")PostMes(KEY_DOWN,1,115);
  664.         else if(Mesk=="/E"||Mesk=="/e")PostMes(KEY_DOWN,0,27);
  665.         else if(Mesk=="/Q"||Mesk=="/q")PostMes(KEY_DOWN,0,19);
  666.         else if(Mesk=="/H"||Mesk=="/h")PostMes(KEY_DOWN,0,113);
  667.         else if(SubStr(Mesk,0,3)=="/S "||SubStr(Mesk,0,3)=="/s ")PostMes(KEY_DOWN,1,114);
  668.         else{
  669.             if(Mesk!=StrCode(0x00)){
  670.                 if(Mesk==LF)Mesk="";
  671.                 mes(TIME){
  672.                     step(WAIT){
  673.                         ,DPSendMessage(Mesk,1);
  674.                         del_me;
  675.                     }
  676.                 }
  677.             }
  678.         }
  679.     }
  680.     else if(StrCode(mesP2)=="U"||mesP2==119){
  681.         Mesk="JOB        USER NAME";
  682.         DPSendMessage(Mesk,10);
  683.         for(i=0;i<userMax;i=i+1){
  684.             if(user[i]!=0&&DPGetName(user[i])!=""){
  685.                 Mesk=StrPrint("%3ld        %s",i+1,DPGetName(user[i]));
  686.                 DPSendMessage(Mesk,10);
  687.             }
  688.         }
  689.     }
  690.     else if(StrCode(mesP2)=="H"||mesP2==113)showHelp();
  691.     else if(StrCode(mesP2)=="E"||mesP2==27){
  692.         if(fmode)end(count);
  693.         else end(count,2);
  694.     }
  695.     else if(StrCode(mesP2)=="Q"||mesP2==19)end(count,1);
  696.     else if(StrCode(mesP2)=="F"||mesP2==118){
  697.         if(mesP1){
  698.             length=StrLen(Mesk);
  699.             fileName=SubStr(Mesk,3,length-3);
  700.         }
  701.         else fileName=StrInput("txt","テキスト文書|*.txt||",1,0x1800,fileName,1);
  702.         if(IsExist(fileName)){
  703.             fileNo=OpenF(fileName,0x0);
  704.             i=0;
  705.             while((Mesk=StrReadF(fileNo))!=""){
  706.                 length=StrLen(Mesk);
  707.                 line[i]=SubStr(Mesk,0,length-1);
  708.                 i=i+1;
  709.             }
  710.             max=i;
  711.             i=0;
  712.             mes(IDLE){
  713.                 step(1){
  714.                     DPSendMessage(line[i],1);
  715.                     i=i+1;
  716.                     if(i==max)del_me;
  717.                     DPSendMessage(line[i],1);
  718.                     i=i+1;
  719.                     if(i==max)del_me;
  720.                     DPSendMessage(line[i],1);
  721.                     i=i+1;
  722.                     if(i==max)del_me;
  723.                 }
  724.             }
  725.             CloseF(fileNo);
  726.         }
  727.         else fileName="";
  728.     }
  729.     else if(StrCode(mesP2)=="N"||mesP2==115){
  730.         oldHandle=DPGetName(ID);
  731.         Handle=LF;
  732.         if(mesP1)Handle=SubStr(Mesk,3,20);
  733.         else{
  734.             while(Handle==LF){
  735.                 Handle=StrInput("名前を入力してください(全角8文字分まで)","");
  736.             }
  737.         }
  738.         if(CharCode(Handle)==0x00)return;
  739.         Handle=SubStr(Handle,0,splitStr1(Handle,15));
  740.         mes(TIME){
  741.             step(WAIT){
  742.                 ,DPSendMessage(StrPrint("%s → %s",oldHandle,Handle),7);
  743.                 DPSetName(Handle);
  744.                 del_me;
  745.             }
  746.         }
  747.     }
  748.     else if(StrCode(mesP2)=="S"||mesP2==114){
  749.         if(mesP1)rjob=StrtoInt(SubStr(Mesk,3,20));
  750.         else{
  751.             job=LF;
  752.             while(job==LF){
  753.                 job=StrInput("相手のJOB番号を半角で入力してください",oldJob);
  754.             }
  755.             if(CharCode(job)==0x00)return;
  756.             oldJob=job;
  757.             rjob=StrtoInt(job);
  758.         }
  759.         for(i=0;i<userMax;i=i+1){
  760.             if(user[i]==ID){
  761.                 sjob=i+1;
  762.                 break;
  763.             }
  764.         }
  765.         if(rjob==sjob){
  766.             mes(TIME){
  767.                 step(WAIT){
  768.                     ,DPSendMessage("send:自分には送れません",ID+1000);
  769.                     del_me;
  770.                 }
  771.             }
  772.         }
  773.         else if(rjob<=userMax&&rjob!=0){
  774.             if(user[rjob-1]!=0&&DPGetName(user[rjob-1])!=""){
  775.                 Mesk=StrInput("メッセージを入力してください","");
  776.                 if(CharCode(Mesk)==0x00)return;
  777.                 else if(Mesk==LF)Mesk="";
  778.                 Mesk=StrPrint("send:JOB %ld=>JOB %ld %s",sjob,rjob,Mesk);
  779.                 mes(TIME){
  780.                     step(WAIT){
  781.                         ,DPSendMessage(Mesk,user[rjob-1]+1000);
  782.                         DPSendMessage(Mesk,ID+1000);
  783.                         del_me;
  784.                     }
  785.                 }
  786.             }
  787.             else{
  788.                 mes(TIME){
  789.                     step(WAIT){
  790.                         ,DPSendMessage("send:指定したJOB番号は現在いません",ID+1000);                        del_me;
  791.                     }
  792.                 }
  793.             }
  794.         }
  795.         else{
  796.             mes(TIME){
  797.                 step(WAIT){
  798.                     ,DPSendMessage("send:無効なJOB番号です",ID+1000);
  799.                     del_me;
  800.                 }
  801.             }
  802.         }
  803.     }
  804. }
  805.  
  806. //データロード
  807. int loadIni(){
  808.     str iniFile,lastName;
  809.     iniFile="chat.ini";
  810.     font=GetIniStr("Setting","font","MS ゴシック",iniFile);
  811.     name=GetIniStr("Setting","defaultName","",iniFile);
  812.     lastName=GetIniStr("Setting","lastName","",iniFile);
  813.     if(name=="")name=lastName;
  814.     help=GetIniInt("Setting","help",1,iniFile);
  815.     width=GetIniInt("Setting","width",640,iniFile);
  816.     height=GetIniInt("Setting","height",400,iniFile);
  817.     fSize=GetIniInt("Setting","fontSize",16,iniFile);
  818.     scLine=GetIniInt("Setting","scrollLine",1,iniFile);
  819.     mWinx=GetIniInt("Setting","mainWindow_x",0,iniFile);
  820.     mWiny=GetIniInt("Setting","mainWindow_y",0,iniFile);
  821.     cWinx=GetIniInt("Setting","custWindow_x",0,iniFile);
  822.     cWiny=GetIniInt("Setting","custWindow_y",0,iniFile);
  823.     eCol[0]=StrtoInt(GetIniStr("Setting","backColor","0x000000",iniFile),1);//バック
  824.     eCol[1]=StrtoInt(GetIniStr("Setting","textColor","0xffffff",iniFile),1);//テキスト
  825.     eCol[2]=StrtoInt(GetIniStr("Setting","helpColor","0x00ff00",iniFile),1);//ヘルプ
  826.     eCol[3]=StrtoInt(GetIniStr("Setting","sendColor","0x00ffff",iniFile),1);//センド
  827.     eCol[4]=StrtoInt(GetIniStr("Setting","listColor","0xffff00",iniFile),1);//一覧
  828.     eCol[5]=StrtoInt(GetIniStr("Setting","systemColor","0x0000ff",iniFile),1);//システム
  829.     eCol[6]=StrtoInt(GetIniStr("Setting","lineColor","0xffffff",iniFile),1);//ライン
  830.     eCol[7]=StrtoInt(GetIniStr("Setting","tomeColor","0xff00ff",iniFile),1);//ネームマッチ
  831.     if(width<640)width=640;
  832.     else if(width>WinInfo(0))width=WinInfo(0);
  833.     if(height<400)height=400;
  834.     else if(height>WinInfo(1)-bHeight)height=WinInfo(1)-bHeight;
  835.     if(fSize<8)fSize=8;
  836.     else if(fSize>30)fSize=30;
  837.     lSize=fSize*5/4;
  838.     oldHeight=height;
  839.     if(height%lSize!=0)height=height+lSize-height%lSize;
  840.     if(scLine<1)scLine=1;
  841.     lines=height/lSize;
  842.     if(scLine*lSize>=height/2)scLine=lines/2;
  843. }
  844.  
  845. //データセーブ
  846. int saveIni(){
  847.     str iniFile;
  848.     CopyFile(CD+"chat.ini",CD+"chat.bak.ini");
  849.     iniFile="chat.ini";
  850.     WriteIniStr("Setting","lastName",Handle,iniFile);
  851.     WriteIniStr("Setting","font",font,iniFile);
  852. //    WriteIniStr("Setting","name",name,iniFile);
  853. //    WriteIniInt("Setting","help",help,iniFile);
  854.     WriteIniInt("Setting","width",width,iniFile);
  855.     WriteIniInt("Setting","height",height,iniFile);
  856.     WriteIniInt("Setting","fontSize",fSize,iniFile);
  857.     WriteIniInt("Setting","scrollLine",scLine,iniFile);
  858.     WriteIniInt("Setting","mainWindow_x",mWinx,iniFile);
  859.     WriteIniInt("Setting","mainWindow_y",mWiny,iniFile);
  860.     WriteIniInt("Setting","custWindow_x",cWinx,iniFile);
  861.     WriteIniInt("Setting","custWindow_y",cWiny,iniFile);
  862.     WriteIniStr("Setting","backColor",StrPrint("0x%06lx",eCol[0]),iniFile);//バック
  863.     WriteIniStr("Setting","textColor",StrPrint("0x%06lx",eCol[1]),iniFile);//テキスト
  864.     WriteIniStr("Setting","helpColor",StrPrint("0x%06lx",eCol[2]),iniFile);//ヘルプ
  865.     WriteIniStr("Setting","sendColor",StrPrint("0x%06lx",eCol[3]),iniFile);//センド
  866.     WriteIniStr("Setting","listColor",StrPrint("0x%06lx",eCol[4]),iniFile);//一覧
  867.     WriteIniStr("Setting","systemColor",StrPrint("0x%06lx",eCol[5]),iniFile);//システム
  868.     WriteIniStr("Setting","lineColor",StrPrint("0x%06lx",eCol[6]),iniFile);//ライン
  869.     WriteIniStr("Setting","tomeColor",StrPrint("0x%06lx",eCol[7]),iniFile);//ネームマッチ
  870. }
  871.  
  872. //ヘルプの表示
  873. int showHelp(int pat=0){
  874.     str Mes[];
  875.     int i;
  876.     Mes[0]="help:                   キーの使い方";
  877.     Mes[1]="help:----------------------------------------------------------";
  878.     Mes[2]="help:チャット開始:[A]             画面カスタマイズ:[C]";
  879.     Mes[3]="help:Filly de Chatの終了:右クリック or [Esc] 、[E]";
  880.     Mes[4]="help:----------------------------------------------------------";
  881.     Mes[5]="help:メッセージ入力:[Enter]       ユーザー一覧:[U] or [F8]";
  882.     Mes[6]="help:センド:[S] or [F3]           名前変更:[N] or [F4]";
  883.     Mes[7]="help:ファイルアップロード:[F] or [F5]  ヘルプ表示:[H] or [F2]";
  884.     Mes[8]="help:ログを保存してチャットを終了:右クリック or [Esc] 、[E]";
  885.     Mes[9]="help:ログを保存しないでチャットを終了:[Q] or [Pause]";
  886.     Mes[10]="help:スクロールアップ:[↑]        スクロールダウン:[↓]";
  887.     Mes[11]="help:1/2ページアップ:[Page Up]    1/2ページダウン:[Page Down]";
  888.     Mes[12]="help:先頭行へジャンプ:[Home]      最新行へジャンプ:[End]";
  889.     Mes[13]="help:----------------------------------------------------------";
  890.     for(i=0;i<14;i=i+1){
  891.         if(pat==0)DPSendMessage(Mes[i],11);
  892.         else TextWrite(Mes[i],pic,10,i*lSize+1);
  893.     }
  894. }
  895.  
  896. //記録時間
  897. str recordTime(int se=0){
  898.     int wd,wt;
  899.     str a,time;
  900.     wd=WhatDay();
  901.     wt=WhatTime();
  902.     a=SubStr("開始終了",se*4,4);
  903.     time=StrPrint("----%s時刻:%ld年%ld月%ld日%ld時%ld分%ld秒----",a,wd/10000,(wd/100)%100,wd%100,wt/10000,(wt/100)%100,wt%100);
  904.     return time;
  905. }
  906.  
  907. //画面カスタマイズ
  908. int custom(){
  909.     int i,old,new,select,point,pic0,cWin,cPic;
  910.     str bName2[],lName[],lName2[];
  911.     int bx,by,bWidth,wHeight,wWidth,yPitch,oldc2;
  912.     mes(RBDOWN){}
  913.     oldc2=eCol[2];
  914.     bName2[0]="  OK";
  915.     bName2[1]="reset";
  916.     wHeight=350;
  917.     wWidth=160;
  918.     yPitch=20;
  919.     bWidth=60;
  920.     bx=20+(wWidth-160)/2;
  921.     by=wHeight-30;
  922.     cPic=CreatePic(pic,wWidth,wHeight);
  923.     SetPaintColor(eCol[0]);
  924.     DrawRect(cPic,0,0,wWidth,wHeight);
  925.     lName[1]="|メッセージの色|";
  926.     lName[2]="|  ヘルプの色  |";
  927.     lName[3]="|  センドの色  |";
  928.     lName[4]="ユーザー一覧の色";
  929.     lName[5]="| システムの色 |";
  930.     lName[6]="|  境界線の色  |";
  931.     lName[7]="自分あて発言の色";
  932.     lName2[0]=" フォントの変更 ";
  933.     lName2[1]="ウィンドウサイズの変更";
  934.     lName2[2]=" スクロール時行数変更";
  935.     SetFont(16,"MS ゴシック",128,0,0,0,500);
  936. //    SetFont(16,font,128,0,0,0,500);
  937.     for(i=1;i<8;i=i+1){
  938.         textCol(eCol[i]);
  939.         TextWrite(lName[i],cPic,(wWidth-16*8)/2,i*yPitch);
  940.     }
  941.     for(i=0;i<3;i=i+1){
  942.         textCol(eCol[1]);
  943.         TextWrite(lName2[i],cPic,(wWidth-128)/2,i*50+wHeight-180);
  944.     }
  945.     draw3D(cPic,5,yPitch*8,wWidth-6,yPitch*8+2,eCol[0],1,20,1);
  946.     draw3D(cPic,(wWidth-160)/2+20,wHeight-160,(wWidth-160)/2+109,wHeight-141,0xffffff,2,20,1);
  947.     draw3D(cPic,(wWidth-160)/2+115,wHeight-160,(wWidth-160)/2+139,wHeight-141,0xffffff,2,20,1);
  948.     draw3D(cPic,(wWidth-160)/2+30,wHeight-110,(wWidth-160)/2+69,wHeight-91,0xffffff,2,20,1);
  949.     draw3D(cPic,(wWidth-160)/2+90,wHeight-110,(wWidth-160)/2+129,wHeight-91,0xffffff,2,20,1);
  950.     draw3D(cPic,(wWidth-160)/2+70,wHeight-60,(wWidth-160)/2+89,wHeight-41,0xffffff,2,20,1);
  951.     textCol(0xffffff);
  952.     TextWrite("x",cPic,(wWidth-160)/2+76,wHeight-107);
  953.     textCol(0x0);
  954.     point=splitStr1(font,11);
  955.     SetFont(14,"MS ゴシック",128,0,0,0,500);
  956.     TextWrite(StrPrint("%s",SubStr(font,0,point)),cPic,(wWidth-160)/2+22,wHeight-157);
  957.     TextWrite(StrPrint("%2ldp",fSize),cPic,(wWidth-160)/2+117,wHeight-157);
  958.     TextWrite(StrPrint("%4ld",width),cPic,(wWidth-160)/2+36,wHeight-107);
  959.     TextWrite(StrPrint("%4ld",height),cPic,(wWidth-160)/2+96,wHeight-107);
  960.     TextWrite(StrPrint("%2ld",scLine),cPic,(wWidth-160)/2+76,wHeight-57);
  961.     SetFont(16,"MS ゴシック",128,0,0,0,500);
  962.     for(i=0;i<2;i=i+1){
  963.         draw3D(cPic,i*bWidth+bx,by,(i+1)*bWidth+bx-1,by+bHeight-1,eCol[0],2,20,0);
  964.         textCol(0x0);
  965.         TextWrite(bName2[i],cPic,i*bWidth+bx+7,by+5);
  966.         textCol(eCol[2]);
  967.         TextWrite(bName2[i],cPic,i*bWidth+bx+6,by+4);
  968.     }
  969.     oldLines=lines;
  970.     CapTitle(" Customize");
  971.     cWin=OpenWin(cPic,cWinx,cWiny);
  972.     cFlag=1;
  973.     mes(LBDOWN){
  974.         if(MesP1==cWin&&MesP2>=bx+bWidth&&MesP2<bx+bWidth*2&&MesP3>=by&&MesP3<by+bHeight){
  975.             mes(TIME){
  976.                 step(WAIT){
  977.                     del_us;
  978.                     draw3D(cPic,bx+bWidth,by,bx+bWidth*2-1,by+bHeight-1,eCol[0],2,20,1);
  979.                     SetFont(16,"MS ゴシック",128,0,0,0,500);
  980.                     textCol(0x0);
  981.                     TextWrite(bName2[1],cPic,bx+bWidth+9,by+7);
  982.                     textCol(oldc2);
  983.                     TextWrite(bName2[1],cPic,bx+bWidth+8,by+6);
  984.                     ,,,draw3D(cPic,bx+bWidth,by,bx+bWidth*2-1,by+bHeight-1,eCol[0],2,20,0);
  985.                     textCol(0x0);
  986.                     TextWrite(bName2[1],cPic,bx+bWidth+7,by+5);
  987.                     textCol(oldc2);
  988.                     TextWrite(bName2[1],cPic,bx+bWidth+6,by+4);
  989.                     SetFont(fSize,font,128,0,0,0,500);
  990.                     loadIni();
  991.                     ,,,CloseWin(cWin);
  992.                     DelPic(cPic);
  993.                     custom();
  994.                     del_me;
  995.                 }
  996.             }
  997.         }
  998.         else if(MesP1==cWin&&MesP2>=bx&&MesP2<bx+bWidth&&MesP3>=by&&MesP3<by+bHeight){
  999.             mes(TIME){
  1000.                 step(WAIT){
  1001.                     del_us;
  1002.                     draw3D(cPic,bx,by,bx+bWidth-1,by+bHeight-1,eCol[0],2,20,1);
  1003.                     SetFont(16,"MS ゴシック",128,0,0,0,500);
  1004.                     textCol(0x0);
  1005.                     TextWrite(bName2[0],cPic,bx+9,by+7);
  1006.                     textCol(oldc2);
  1007.                     TextWrite(bName2[0],cPic,bx+8,by+6);
  1008.                     ,,,draw3D(cPic,bx,by,bx+bWidth-1,by+bHeight-1,eCol[0],2,20,0);
  1009.                     textCol(0x0);
  1010.                     TextWrite(bName2[0],cPic,bx+7,by+5);
  1011.                     textCol(oldc2);
  1012.                     TextWrite(bName2[0],cPic,bx+6,by+4);
  1013.                     SetFont(fSize,font,128,0,0,0,500);
  1014.                     ,,,CloseWin(cWin);
  1015.                     DelPic(cPic);
  1016.                     cWinx=GetLowWord(GetWinPos(cWin));
  1017.                     cWiny=GetHiWord(GetWinPos(cWin));
  1018.                     mWinx=GetLowWord(GetWinPos(mWin));
  1019.                     mWiny=GetHiWord(GetWinPos(mWin));
  1020.                     CloseWin(mWin);
  1021.                     pic0=CreatePic(pic,1,1);
  1022.                     DelPic(pic);
  1023.                     pic=CreatePic(pic0,width,height+bHeight);
  1024.                     DelPic(pic0);
  1025.                     makeWindow();
  1026.                     if(mode==0){
  1027.                         if(lines>oldLines){
  1028.                             top=top+oldLines-lines;
  1029.                             if(top<0)top=0;
  1030.                             if(count<=lines)top=0;
  1031.                             y=(count-top)*lSize;
  1032.                         }
  1033.                         else if(lines<oldLines){
  1034.                             if(count<=lines){
  1035.                                 top=0;
  1036.                                 y=count*lSize;
  1037.                             }
  1038.                             else{
  1039.                                 top=count-lines;
  1040.                                 y=(count-top)*lSize;
  1041.                             }
  1042.                         }
  1043.                         else y=(count-top)*lSize;
  1044.                     }
  1045.                     else if(mode!=0){
  1046.                         if(lines>oldLines){
  1047.                             if(lines>=count){
  1048.                                 mode=0;
  1049.                                 top=0;
  1050.                                 y=(count-top)*lSize;
  1051.                             }
  1052.                             else if(lines+top>=count){
  1053.                                 mode=0;
  1054.                                 if(top>=count-lines)top=count-lines;
  1055.                                 y=(count-top)*lSize;
  1056.                             }
  1057.                             else{
  1058.                                 y=height;
  1059.                             }
  1060.                         }
  1061.                         else if(lines<oldLines){
  1062.                             y=height;
  1063.                         }
  1064.                     }
  1065.                     SetFont(fSize,font,128,0,0,0,500);
  1066.                     cFlag=0;
  1067.                     ready0();
  1068.                     del_me;
  1069.                 }
  1070.             }
  1071.         }
  1072.         else if(MesP1==cWin){
  1073.             if(MesP2>=(wWidth-160)/2+20&&MesP2<(wWidth-160)/2+110&&MesP3>=wHeight-160&&MesP3<wHeight-140){
  1074.                 int ret[];
  1075.                 str newFont;
  1076.                 newFont=StrInput(ret[],"",3);
  1077.                 if(newFont!="")font=newFont;
  1078.                 point=splitStr1(font,11);
  1079.                 draw3D(cPic,(wWidth-160)/2+20,wHeight-160,(wWidth-160)/2+109,wHeight-141,0xffffff,2,20,1);
  1080.                 textCol(0x0);
  1081.                 SetFont(14,"MS ゴシック",128,0,0,0,500);
  1082.                 TextWrite(StrPrint("%s",SubStr(font,0,point)),cPic,(wWidth-160)/2+22,wHeight-157);
  1083.                 SetPaintColor(eCol[0]);
  1084.                 DrawRect(cPic,0,0,wWidth,yPitch*8);
  1085.                 SetFont(16,"MS ゴシック",128,0,0,0,500);
  1086. //                SetFont(16,font,128,0,0,0,500);
  1087.                 for(i=1;i<8;i=i+1){
  1088.                     textCol(eCol[i]);
  1089.                     TextWrite(lName[i],cPic,(wWidth-16*8)/2,i*yPitch);
  1090.                 }
  1091.             }
  1092.             else if(MesP2>=(wWidth-160)/2+115&&MesP2<(wWidth-160)/2+140&&MesP3>=wHeight-160&&MesP3<wHeight-140){
  1093.                 fSize=StrtoInt(StrInput("フォントのサイズは?(8~30)",StrPrint("%ld",fSize)));
  1094.                 if(fSize<8)fSize=8;
  1095.                 else if(fSize>30)fSize=30;
  1096.                 draw3D(cPic,(wWidth-160)/2+115,wHeight-160,(wWidth-160)/2+139,wHeight-141,0xffffff,2,20,1);
  1097.                 textCol(0x0);
  1098.                 SetFont(14,"MS ゴシック",128,0,0,0,500);
  1099.                 TextWrite(StrPrint("%2ldp",fSize),cPic,(wWidth-160)/2+117,wHeight-157);
  1100. //                oldLines=height/lSize;
  1101.                 lSize=fSize*5/4;
  1102.                 height=oldHeight+lSize-oldHeight%lSize;
  1103.                 lines=height/lSize;
  1104.             }
  1105.             else if(MesP2>=(wWidth-160)/2+30&&MesP2<(wWidth-160)/2+70&&MesP3>=wHeight-110&&MesP3<wHeight-90){
  1106.                 width=StrtoInt(StrInput("ウィンドウの幅は?",StrPrint("%ld",width)));
  1107.                 if(width<640)width=640;
  1108.                 else if(width>WinInfo(0))width=WinInfo(0);
  1109.                 draw3D(cPic,(wWidth-160)/2+30,wHeight-110,(wWidth-160)/2+69,wHeight-91,0xffffff,2,20,1);
  1110.                 textCol(0x0);
  1111.                 SetFont(14,"MS ゴシック",128,0,0,0,500);
  1112.                 TextWrite(StrPrint("%4ld",width),cPic,(wWidth-160)/2+36,wHeight-107);
  1113.             }
  1114.             else if(MesP2>=(wWidth-160)/2+90&&MesP2<(wWidth-160)/2+130&&MesP3>=wHeight-110&&MesP3<wHeight-90){
  1115.                 oldLines=height/lSize;
  1116.                 height=StrtoInt(StrInput("ウィンドウの高さは?",StrPrint("%ld",height)));
  1117.                 if(height<400)height=400;
  1118.                 else if(height>WinInfo(1))height=WinInfo(1);
  1119.                 if(height%lSize!=0)height=height+lSize-height%lSize;
  1120.                 lines=height/lSize;
  1121.                 draw3D(cPic,(wWidth-160)/2+90,wHeight-110,(wWidth-160)/2+129,wHeight-91,0xffffff,2,20,1);
  1122.                 textCol(0x0);
  1123.                 SetFont(14,"MS ゴシック",128,0,0,0,500);
  1124.                 TextWrite(StrPrint("%4ld",height),cPic,(wWidth-160)/2+96,wHeight-107);
  1125.             }
  1126.             else if(MesP2>=(wWidth-160)/2+70&&MesP2<(wWidth-160)/2+90&&MesP3>=wHeight-60&&MesP3<wHeight-40){
  1127.                 scLine=StrtoInt(StrInput("スクロール時の表示行数は?",StrPrint("%ld",scLine)));
  1128.                 if(scLine<1)scLine=1;
  1129.                 if(scLine*lSize>=height/2)scLine=lines/2;
  1130.                 draw3D(cPic,(wWidth-160)/2+70,wHeight-60,(wWidth-160)/2+89,wHeight-41,0xffffff,2,20,1);
  1131.                 textCol(0x0);
  1132.                 SetFont(14,"MS ゴシック",128,0,0,0,500);
  1133.                 TextWrite(StrPrint("%2ld",scLine),cPic,(wWidth-160)/2+76,wHeight-57);
  1134.             }
  1135.             else{
  1136.                 select=0;
  1137.                 for(i=0;i<8;i=i+1){
  1138.                     if(MesP2>=(wWidth-fSize*8)/2&&MesP2<wWidth-(wWidth-fSize*8)/2&&MesP3>=i*yPitch&&MesP3<i*yPitch+fSize)select=i;
  1139.                 }
  1140.                 old=eCol[select];
  1141.                 new=ColorInput();
  1142.                 if(new==-1)new=old;
  1143.                 eCol[select]=new;
  1144.                 if(select==0){
  1145.                     SetPaintColor(eCol[0]);
  1146.                     DrawRect(cPic,0,0,wWidth,wHeight);
  1147.                     SetFont(16,"MS ゴシック",128,0,0,0,500);
  1148. //                    SetFont(16,font,128,0,0,0,500);
  1149.                     for(i=1;i<8;i=i+1){
  1150.                         textCol(eCol[i]);
  1151.                         TextWrite(lName[i],cPic,(wWidth-16*8)/2,i*yPitch);
  1152.                     }
  1153.                     for(i=0;i<3;i=i+1){
  1154.                         textCol(eCol[1]);
  1155.                         TextWrite(lName2[i],cPic,(wWidth-128)/2,i*50+wHeight-180);
  1156.                     }
  1157.                     draw3D(cPic,(wWidth-160)/2+20,wHeight-160,(wWidth-160)/2+109,wHeight-141,0xffffff,2,20,1);
  1158.                     draw3D(cPic,(wWidth-160)/2+115,wHeight-160,(wWidth-160)/2+139,wHeight-141,0xffffff,2,20,1);
  1159.                     draw3D(cPic,(wWidth-160)/2+30,wHeight-110,(wWidth-160)/2+69,wHeight-91,0xffffff,2,20,1);
  1160.                     draw3D(cPic,(wWidth-160)/2+90,wHeight-110,(wWidth-160)/2+129,wHeight-91,0xffffff,2,20,1);
  1161.                     draw3D(cPic,(wWidth-160)/2+70,wHeight-60,(wWidth-160)/2+89,wHeight-41,0xffffff,2,20,1);
  1162.                     textCol(0xffffff);
  1163.                     TextWrite("x",cPic,(wWidth-160)/2+76,wHeight-57);
  1164.                     textCol(0x0);
  1165.                     SetFont(14,"MS ゴシック",128,0,0,0,500);
  1166.                     point=splitStr1(font,11);
  1167.                     TextWrite(StrPrint("%s",SubStr(font,0,point)),cPic,(wWidth-160)/2+22,wHeight-157);
  1168.                     TextWrite(StrPrint("%2ldp",fSize),cPic,(wWidth-160)/2+117,wHeight-157);
  1169.                     TextWrite(StrPrint("%4ld",width),cPic,(wWidth-160)/2+36,wHeight-107);
  1170.                     TextWrite(StrPrint("%4ld",height),cPic,(wWidth-160)/2+96,wHeight-107);
  1171.                     TextWrite(StrPrint("%2ld",scLine),cPic,(wWidth-160)/2+76,wHeight-57);
  1172.                     draw3D(cPic,5,yPitch*8,wWidth-6,yPitch*8+2,eCol[0],1,20,1);
  1173.                     SetFont(16,"MS ゴシック",128,0,0,0,500);
  1174.                     for(i=0;i<2;i=i+1){
  1175.                         draw3D(cPic,i*bWidth+bx,by,(i+1)*bWidth+bx-1,by+bHeight-1,eCol[0],2,20,0);
  1176.                         textCol(0x0);
  1177.                         TextWrite(bName2[i],cPic,i*bWidth+bx+7,by+5);
  1178.                         textCol(eCol[2]);
  1179.                         TextWrite(bName2[i],cPic,i*bWidth+bx+6,by+4);
  1180.                     }
  1181.                 }
  1182.                 else{
  1183.                     SetFont(16,"MS ゴシック",128,0,0,0,500);
  1184. //                    SetFont(16,font,128,0,0,0,500);
  1185.                     SetPaintColor(eCol[0]);
  1186.                     DrawRect(cPic,(wWidth-16*8)/2,select*yPitch,(wWidth+16*8)/2,select*20+20);
  1187.                     textCol(eCol[select]);
  1188.                     TextWrite(lName[select],cPic,(wWidth-16*8)/2,select*yPitch);
  1189.                 }
  1190.             }
  1191.         }
  1192.     }
  1193. }
  1194.  
  1195. //チャットウインドウを作る
  1196. int makeWindow(){
  1197.     SetLineSize(4);
  1198.     SetPaintColor(eCol[0]);
  1199.     DrawRect(pic,0,0,width,height+bHeight);
  1200.     makeButton();
  1201.     CapTitle(" Filly de Chat Ver.0.91");
  1202.     mWin=OpenWin(pic,mWinx,mWiny);
  1203. }
  1204.  
  1205. //チャットウインドウのボタンを作る
  1206. int makeButton(){
  1207.     int i,bmax;
  1208.     if(fmode){
  1209.     bName[0]="[Enter]";    bName[1]=" [U]ser";
  1210.     bName[2]=" [S]end";    bName[3]=" [N]ame";
  1211.     bName[4]=" [F]ile";    bName[5]=" [H]elp";
  1212.     bName[6]=" [E]xit";
  1213.     key[0]=13;             key[1]=85;
  1214.     key[2]=83;             key[3]=78;
  1215.     key[4]=70;             key[5]=72;
  1216.     key[6]=69;
  1217.     bmax=7;
  1218.     }
  1219.     if(fmode==0){
  1220.     bName[0]="[A]ccess";    bName[1]="[C]ustom";
  1221.     bName[2]=" [H]elp";     bName[3]=" [E]xit";
  1222.     key[0]=65;             key[1]=67;
  1223.     key[2]=72;             key[3]=69;
  1224.     bmax=4;
  1225.     }
  1226.     SetLineSize(4);
  1227.     SetPaintColor(eCol[0]);
  1228.     DrawRect(pic,0,height,width,height+bHeight);
  1229.     SetFont(16,"MS ゴシック",128,0,0,0,500);
  1230.     SetLineSize(1);
  1231.     for(i=0;i<bmax;i=i+1){
  1232.         draw3D(pic,i*80,height,i*80+79,height+bHeight-1,eCol[0],2,20,0);
  1233.         textCol(0x0);
  1234.         TextWrite(bName[i],pic,i*80+8,height+(bHeight-16)/2+1);
  1235.         textCol(eCol[2]);
  1236.         TextWrite(bName[i],pic,i*80+7,height+(bHeight-16)/2);
  1237.     }
  1238.     if(fmode){
  1239.         draw3D(pic,560,height,width-1,height+bHeight-1,eCol[0],2,20,1);
  1240.     }
  1241.     else if(fmode==0){
  1242.         draw3D(pic,320,height,width-1,height+bHeight-1,eCol[0],2,20,1);
  1243.     }
  1244.     if(width>=720){
  1245.         textCol(0x0);
  1246.         TextWrite("Filly de Chat 0.91",pic,574,height+(bHeight-16)/2+1);
  1247.         textCol(eCol[2]);
  1248.         TextWrite("Filly de Chat 0.91",pic,573,height+(bHeight-16)/2);
  1249.     }
  1250. }
  1251.  
  1252. str lastStr(str strings){
  1253.     int length;
  1254.     length=StrLen(strings);
  1255.     return SubStr(strings,length-1,1);
  1256. }
  1257.  
  1258. int splitStr(str ss,int w,str font,int size){
  1259.     str s;
  1260.     int x,oldx,c,i,j,lenss,len,z,oldres,oldres2;
  1261.     j=0;
  1262.     res[0]=0;
  1263.     res2[0]=0;
  1264.     oldres=0;
  1265.     oldres2=0;
  1266.     lenss=StrLen(ss);
  1267.     s=ss;
  1268.     SetFont(size,font,128,0,0,0,500);
  1269.     while(s!=""){
  1270.         z=1;
  1271.         oldx=0;
  1272.         len=StrLen(s);
  1273.         for(i=0;i<len;i=i+z){
  1274.             c=CharCode(SubStr(s,i,1));
  1275.             if((c>=0x81&&c<=0x9f)||(c>=0xe0&&c<=0xfc)){
  1276.                 c=CharCode(SubStr(s,i+1,1));
  1277.                 if((c>=0x40&&c<=0x7e)||(c>=0x80&&c<=0xfc)){
  1278.                     z=2;
  1279.                 }
  1280.                 else z=1;
  1281.             }
  1282.             else z=1;
  1283.             x=GetLowWord(GetTextSize(SubStr(s,0,i+z)));
  1284.             if(x>=w)break;
  1285.             oldx=x;
  1286.         }
  1287.         j=j+1;
  1288.         res[j]=oldres+i;
  1289.         res2[j]=oldres2+oldx;
  1290.         oldres=res[j];
  1291.         oldres2=res2[j];
  1292.         s=SubStr(ss,res[j],lenss-res[j]);
  1293.     }
  1294.     return j;
  1295. }
  1296.  
  1297. /*int splitStr(str ss,int w,str font,int size){
  1298.     int x[],sPic,i,j,len,lenss,c,z,oldres,oldres2,oldz;
  1299.     str s;
  1300.     j=0;
  1301.     res[0]=0;
  1302.     res2[0]=0;
  1303.     oldres=0;
  1304.     oldres2=0;
  1305.     lenss=StrLen(ss);
  1306.     s=ss;
  1307.     sPic=CreatePic(pic,lenss*size/2+10,1);
  1308.     while(s!=""){
  1309.         TextColor(0,0,0);
  1310.         BgColor(0,0,0);
  1311.         BackMode(0);
  1312.         len=StrLen(s);
  1313.         SetFont(size,font,128,0,0,0,500);
  1314.         SetPaintColor(0xffffff);
  1315.         DrawLine(sPic,0,0,len*size/2+10,0);
  1316.         x[0]=0;
  1317.         oldz=1;
  1318.         z=1;
  1319.         for(i=0;i<len;i=i+z){
  1320.             c=CharCode(SubStr(s,i,1));
  1321.             if((c>=0x81&&c<=0x9f)||(c>=0xe0&&c<=0xfc)){
  1322.                 c=CharCode(SubStr(s,i+1,1));
  1323.                 if((c>=0x40&&c<=0x7e)||(c>=0x80&&c<=0xfc)){
  1324.                     z=2;
  1325.                 }
  1326.                 else z=1;
  1327.             }
  1328.             else z=1;
  1329.             TextWrite(SubStr(s,0,i+z),sPic,0,0);
  1330.             if(i==0)x[i]=0;
  1331.             else x[i]=x[i-oldz];
  1332.             while(GetColor(sPic,x[i],0)!=0xffffff){
  1333.                 x[i]=x[i]+1;
  1334.             }
  1335.             if(x[i]>=w){
  1336.                 break;
  1337.             }
  1338.             oldz=z;
  1339.         }
  1340.         j=j+1;
  1341.         res[j]=oldres+i;
  1342.         res2[j]=x[i-z]+oldres2;
  1343.         oldres=res[j];
  1344.         oldres2=res2[j];
  1345.         s=SubStr(ss,res[j],lenss-res[j]);
  1346.     }
  1347.     DelPic(sPic);
  1348.     BackMode(1);
  1349.     return j;
  1350. }*/
  1351.  
  1352. int getStrWidth(str l,str f,int s){
  1353.     int y;
  1354.     SetFont(s,f,128,0,0,0,500);
  1355.     y=GetLowWord(GetTextSize(l));
  1356. }
  1357.  
  1358. /*int getStrWidth(str l,str f,int s){
  1359.     int picg,x,len;
  1360.     len=StrLen(l);
  1361.     picg=CreatePic(pic,len*s,1);
  1362.     SetPaintColor(0xffffff);
  1363.     DrawLine(picg,0,0,len*s,0);
  1364.     SetFont(s,f,128,0,0,0,500);
  1365.     TextColor(0,0,0);
  1366.     BgColor(0,0,0);
  1367.     BackMode(0);
  1368.     x=0;
  1369.     TextWrite(l,picg,0,0);
  1370.     while(GetColor(picg,x,0)!=0xffffff){
  1371.         x=x+1;
  1372.     }
  1373.     BackMode(1);
  1374.     DelPic(picg);
  1375. MsgBox(StrPrint("%ld %ld",y,x));
  1376.     return x;
  1377. }*/
  1378.  
  1379. int init(){
  1380.     Handle=LF;
  1381.     SetPaintColor(eCol[0]);
  1382.     SetLineSize(4);
  1383. //    mWinx=GetLowWord(GetWinPos(mWin));
  1384. //    mWiny=GetHiWord(GetWinPos(mWin));
  1385. //    dPic=CreatePic(pic,647,29);
  1386. //    DrawRect(dPic,0,0,647,29);
  1387. //    TextWrite("名前を入力してください(全角8文字分まで有効)",dPic,6,height-46);
  1388. //    CapTitle("名前を入力してください(全角8文字分まで有効)");
  1389. //    dWin=OpenWin(dPic,mWinx+10,mWiny+height-60);
  1390.     while(Handle==LF){
  1391.         Handle=StrInput("名前を入力してください(全角8文字分まで)",name);
  1392. //        Handle=StrInput("",name,4,mWinx+18,mWiny+height-34);
  1393.     }
  1394. //    CloseWin(dWin);
  1395. //    DelPic(dPic);
  1396.     if(CharCode(Handle)==0x00){
  1397.         ready0();
  1398.     }
  1399.     else{
  1400.         ID=DPInit(0x39ca8000);
  1401.         if(ID!=-1){
  1402.             DrawRect(pic,0,0,width,height);
  1403.             fmode=1;
  1404.             makeButton();
  1405.             Handle=SubStr(Handle,0,splitStr1(Handle,15));
  1406.             DPSetName(Handle);
  1407.             userMax=0;
  1408.             if(DPIsHost()){
  1409.                 user[0]=ID;
  1410.                 userMax=1;
  1411.             }
  1412.             y=0;
  1413.             cFlag=0;
  1414.             top=0;
  1415.             mode=0;
  1416.             count=0;
  1417.             no=0;
  1418.             fileName="";
  1419.             oldJob="";
  1420.             start=recordTime();
  1421.             DPSendMessage(StrPrint("%ld",ID),0);
  1422.             ready();
  1423.         }
  1424.         else{
  1425.             ready0();
  1426.         }
  1427.     }
  1428. }
  1429.