;このスクリプトの動作には拡張ランタイム"hsp2max.hrt"か拡張DLL"hspext.dll"が必要になります。 #include"LoadPicture2.as" ;Thanks blueleafさん→http://hp.vector.co.jp/authors/VA034288/ ;一部改変(65行目のbgscr/67行目のscreen ともにp4を0→12) #include"hspda.as" #include"llmod.as" #include"obj.as" #include"hspext.as" s_dir_path=exedir ;スクリプトのテスト用 if cmdline!"" : s_dir_path=cmdline : chdir s_dir_path : else : s_dir_path=exedir ;ルート対策 strmid tmp,s_dir_path,-1,1 : if tmp=":" : s_dir_path+="\\" ;ベースウェアチェック exist"materia.exe" : a.0=strsize : exist"crow.exe" : a.1=strsize : exist"ssp.exe" : a.2=strsize if(a.0=-1)&&(a.1=-1)&&(a.2=-1){ dialog"materia.exe\ncrow.exe\nssp.exe\n\nいずれのベースウェアも見つかりません\nベースウェアの実行ファイルと同じディレクトリに置いて起動して下さい",1,"ベースウェアがありません" end } ;システムカラーを取得(設定画面でも使うので先に取得しておく) c_prm=15 : dllproc"GetSysColor",c_prm,1,1 peek br,dllret,0 : peek bg,dllret,1 : peek bb,dllret,2 dirlist tmp,"ghost",5 : exist"gs.cnf" if (stat=0)&(strsize=-1){ dialog"フォルダ\".\\ghost\\\"がありません\n設定を行いますか?",2,"ゴーストフォルダが見つかりません" if stat=7 : dialog"プログラムを実行できません\nGhost Selectorを終了します",1 : end g_dir="" : screen 2,,,6 : fst_b=1 : goto *config }else{ if strsize>=0{ gosub *load_cnf_file notesel g_dir notemax g_dn ;g_dnはゴーストフォルダ数 }else{ g_dn=1 : g_dir="ghost\n" } } sdim d_l,51200,g_dn ;ゴーストのフォルダの一覧用(note形式) notesel g_dir : sdim tmp,5120 : max=0 ;各ゴーストフォルダからゴーストのフォルダ一覧を取得 repeat g_dn if cnt>=g_dn : break noteget tmp,cnt ;パス末尾チェック。\が付いてる場合は除去。 strlen a,tmp : strmid tmp2,tmp,a-1,1 if tmp2="\\"{ strmid tmp,tmp,0,a-1 noteadd tmp,cnt,1 } dirlist tmp2,tmp,5 if stat=0{ dialog"ゴーストフォルダ"+tmp+"が見つかりません\n"+tmp+"の読み込みをキャンセルします",1,"Folder not Found" g_dn- : notedel cnt await 1 : continue cnt } chdir tmp dirlist d_l.cnt,"*",5 if stat>max : max=stat chdir s_dir_path loop sdim g_name,256,g_dn,max ;ゴースト名一覧が格納される二次元配列 sdim d_ln,256,g_dn,max ;ゴーストのフォルダの一覧を格納する二次元配列 sdim gn_list,256*max,g_dn ;listbox用 ;ゴースト名一覧を配列変数に取得 repeat g_dn notesel g_dir : noteget d_a,cnt : r=cnt ;d_aは処理対象ゴーストフォルダ名 notesel d_l.cnt : notemax max_n : sdim tmp_s,256,max_n repeat max_n noteget d_b,cnt ;d_bは処理対象のゴーストのフォルダ名 ;descript.txtからゴースト名を取得 exist""+d_a+"\\"+d_b+"\\ghost\\master\\descript.txt" if strsize=-1 : tmp_s.cnt=d_b : continue sdim tmp,strsize bload""+d_a+"\\"+d_b+"\\ghost\\master\\descript.txt",tmp,strsize instr a,tmp,"\nname," if a=-1{ instr a,tmp,"\rname," if a=-1{ instr a,tmp,"name," if a!0{ tmp_s.cnt=d_b a=-1 } } } if a!-1{ instr b,tmp,",",a : b+=a+1 instr c,tmp,"\n",b : instr a,tmp,"\r",b : if a=0{ if a=0{ ;最初にヒットした時点で作業用(参照用兼用)の初期化を行う sdim srch_list,128*max : sdim s_fld_list,128,max : dim srch_folder,max } srch_list+=""+g_name.now.cnt+"\n" s_fld_list.a=d_ln.now.cnt srch_folder.a=cnt : a+ } loop if a=0{ dialog"該当するゴーストはインストールされていません",1,"not found" objsel 7 : tmp2=-1 : objsend 7,$b1,0,tmp2,1 goto *main } sr_sw=1 objprm 2,srch_list : n=0 : n_sel=0 : objprm 2,0 if pre=1 : gosub *pre_sfc pos 170,260 : button "一覧",*ret objsel 7 : tmp2=-1 : objsend 7,$b1,0,tmp2,1 goto *main *ret ;検索クリア。ゴーストフォルダチェンジと兼用。 objprm 2,gn_list.now if sr_sw=1{ clrobj 12 : sr_sw=0 objprm 7,"" } n=0 : n_sel=0 : objprm 2,0 if pre=1 : gosub *pre_sfc goto *main *load_cnf_file ;設定ファイルの読込 exist"gs.cnf" : size=strsize sdim g_dir,size+100 bload"gs.cnf",g_dir,size ;g_dirはnote形式でゴーストフォルダ一覧が入る return *config ;設定画面 gsel 0,-1 : gsel 3,-1 : gsel 2 x=dispx/2-215 : y=dispy/2-85 width 430,170,x,y : cls color br,bg,bb : boxf 0,0,winx,winy : title"ゴーストフォルダの設定" strlen a,g_dir : sdim g_dir2,a+1 : g_dir2=g_dir : m=0 font"",12 : objmode 2,1 : objsize 300 : pos 5,5 : listbox m,150,g_dir2 notesel g_dir2 : notemax max objsize 80,24 : pos 340,10 : button"追加",*dir_ad pos 340,40 : button"削除",*dir_del pos 340,110 : button"OK",*config_save pos 340,140 : button"キャンセル",*cnf_cancel objsize 20,50 : pos 310,30 : button"↑",*dir_up pos 310,90 : button"↓",*dir_down onkey *push_key2 : gsel 2,1 stop *dir_ad selfolder tmp,"ゴーストフォルダの追加" if stat=1 : stop chdir tmp : dirlist tmp2,"*",5 if stat=0 : dialog""+tmp+"にはフォルダがありません",1,"error" : chdir s_dir_path : stop chdir s_dir_path noteadd tmp,max objprm 0,g_dir2 : objprm 0,max : max+ stop *dir_del if max=0 : stop notedel m : max- : if m>=max : m- objprm 0,g_dir2 : if m<=0 : objprm 0,0 stop *dir_up a=m-1 : b=1 if a<0 : stop : else : goto *up_down *dir_down a=m+1 : b=0 if a>=max : stop *up_down noteget tmp,m notedel m : noteadd tmp,a,0 objprm 0,g_dir2 : objprm 0,a if b=1 : objsel 5 : else : objsel 6 stop *config_save ;設定ファイルの書き込み gsel 2,-1 : wait 1 ;設定ファイルが無くてもいい時は設定ファイルを削除してしまう。 exist"gs.cnf" : if (max=0)&(strsize>=0) : delete"gs.cnf" : exec"gs.exe" : end if max>=1{ strlen a,g_dir2 bsave"gs.cnf",g_dir2,a } exec"gs.exe" : end *cnf_cancel ;設定キャンセル ;初回設定から設定画面を開いた場合は終了 if fst_b=1 : end gsel 2,-1 : gsel 0,1 if pre=1 : gsel 3,1 onkey *push_key goto *main *push_key ;キー入力処理 ;エンターキーで検索したりボタン押せたりするようにもする。 if iparam=27 : end ginfo 1 : if prmx!0 : stop objsel -1 if iparam=13{ if stat=1 { goto *config } if stat=3 { goto *materia } if stat=4 { goto *crow } if stat=5 { goto *ssp } if stat=6 { end } if (stat=7)|(stat=8) { goto *search } if stat=12 { goto *ret } } goto *main *push_key2 ;同じく設定画面用 if iparam=27 : goto *cnf_cancel ginfo 1 : if prmx!2 : stop objsel -1 if iparam=13{ if stat=1 { goto *dir_ad } if stat=2 { goto *dir_del } if stat=3 { goto *config_save } if stat=4 { goto *cnf_cancel } if stat=5 { goto *dir_up } if stat=6 { goto *dir_down } } stop