;******************************************************** ;@EXT_DESC 概要:立ち絵の扱いが簡単な[fg] ;@VER 2024.04.30.007 最後に変化した立ち絵を目立たせる機能追加 ; フィルター機能など[lay]の機能追加に対応 ;@VER 2024.04.18.006 引数説明記述を拡張機能v4.16.0準拠に ;@VER 2023.06.19.005 sn更新で不要になった sn.skip.enabled の扱いを削除 ;@VER 2022.11.02.004 [fg2]に snippet_ext 追加 ;@VER 2022.10.18.003 [fg2]@face説明追加 ;@VER 2022.01.10.002 出現時[tsy]にrender=true 追加 ;@VER 2021.12.17.001 nowarn_unused=true 追加 ; save:sn.fg2.max_lay はクリアされるので sys:に ;@VER 2019.7.22.000 ;******************************************************** ;******************************************************** ; 定数 ; 立ち絵表示範囲の右端と左端 [macro name=fg2_ini_save_const] [return cond=save:sn.fg2.max_lay] &save:sn.fg2.xb = 0 &save:sn.fg2.xe = const.sn.config.window.width-1 &save:sn.fg2.max_lay = 3 ; 最大レイヤ数(以下で自動調査) &save:sn.fg2.lays = '' ;-- &sn.fg2.attention_filter = 'brightness' ; これを本文中に書くと最後に変化した立ち絵を目立たせる(それ以外暗くする) [endmacro] ;******************************************************** ; 以降はノータッチで [fg2_ini_save_const] [add_lay layer=0 class=grp cond=!const.sn.lay.0] [add_lay layer=1 class=grp cond=!const.sn.lay.1] [add_lay layer=2 class=grp cond=!const.sn.lay.2] *max_lay_lp [if exp='const.sn.lay[save:sn.fg2.max_lay]'] &save:sn.fg2.max_lay = save:sn.fg2.max_lay + 1 [jump label=*max_lay_lp] [endif] [for_call name=l from=0 to=&save:sn.fg2.max_lay-1 label=*fg2_init] ;******************************************************** ; 立ち絵の扱いが簡単な[fg] [macro name=fg2 nowarn_unused=true nowarn_unused=true sum='レイヤ画像を変更・立ち絵の扱いが簡単な[fg]' snippet_ext=SP_GSM %fn?='差分名称(カンマ区切りで複数可)||【名前_表情やポーズ】形式の画像ファイル名' %face?='差分名称(カンマ区切りで複数可)|何もしない|差分名称または画像ファイル名を指定する。[fg fn="a" face="b,c,d"]なら「基本a」の上に「差分b」を重ね、「差分c」を重ね、「差分d」を重ねる' %add?='l、cl、c、cr、r|自動で追加位置を決定|追加位置ヒント。左、中左,中央,中右,右への追加をうながす' %del?='追加時の【名前】|なにもしない|立ち絵を削除する。追加時の【名前】を指定する' %swap?='追加時の【名前】|なにもしない|fnと同時に指定すると、swapを退場・fnを入場と入れ替わりに出現させる' ] [fg2_ini_save_const] ; ここまでで[clear_lay]などされてるレイヤ情報を削除 ;[trace text="&'max_lay='+ save:sn.fg2.max_lay +' lays:'+ save:sn.fg2.lays@str +':'"] [for_call name=l from=0 to=&save:sn.fg2.max_lay-1 label=*fg2_gc] ;[trace text="&'lays:'+ save:sn.fg2.lays@str +':'"] [if exp='mp:del'] &lay = save:sn.fg2.hu[mp:del] &&'save:sn.fg2.hu.'+ mp:del = null &&'save:sn.fg2.hu.'+ lay +'.pos' = null &&'save:sn.fg2.l2hu.'+ lay = null [let_replace name=save:sn.fg2.lays text=&save:sn.fg2.lays@str val='' reg=&lay cast=str] ;[trace text="&'== del lays:'+ save:sn.fg2.lays@str +': lay:'+ lay"] [fg * layer=&lay] [return] [endif] [let_replace name=h text=%fn val='' reg='_.+' cast=str] [if exp='mp:swap'] &lay = save:sn.fg2.hu[mp:swap] ;[trace text='&"sw 0 lay:"+ lay +" h:"+ h +" swap:"+ mp:swap'] [if exp='lay == null'] ; エラーとすべきなのか迷う。黙って通常処理でもいいのかも [trace text="&'swap属性に指定した人物キー【'+ lay +'】は存在しません。属性swap不要かも'"] [return] [endif] &old_h = save:sn.fg2.l2hu[lay] &&'save:sn.fg2.hu.'+ old_h = null &&'save:sn.fg2.hu.'+ h = lay &&'save:sn.fg2.l2hu.'+ lay = h ; &save:sn.fg2.hu[lay].pos = 00 ; 同じレイヤを使うので触らず ;[trace text='&"sw 1 l2hu:"+ save:sn.fg2.l2hu[lay] +" hu:"+ save:sn.fg2.hu[h] +" pos:"+ save:sn.fg2.hu[lay].pos'] [endif] &mylay = save:sn.fg2.hu[h] ;[trace text="&'== chg hu:'+ h +' lay:'+ mylay +' v:'+ const.sn.lay[mylay].fore.visible +' w:'+ const.sn.lay[mylay].fore.width"] [if exp='mylay != null && const.sn.lay[mylay].fore.visible && const.sn.lay[mylay].fore.width > 0'] [fg2_attention layer=&mylay] [fg * layer=&mylay pos='&save:sn.fg2.hu[mylay].pos'] [return] [endif] [let name=alpha text=%alpha|1] [let name=time text=%time|500] [let name=ease text=%ease|Cubic.Out] [let name=add text=%add|'cr'] &use_lay = null [for_call name=l from=0 to=&save:sn.fg2.max_lay-1 label=*fg2_add] ;[trace text="&'lays:'+ save:sn.fg2.lays@str +': use_lay:'+ use_lay +' add:'+ add"] [if exp='use_lay == null'] [trace text="&'最大レイヤ数'+ save:sn.fg2.max_lay +'を越えました。これ以上同時に立ち絵を表示したい場合、レイヤを増やして下さい'"] [return] [endif] &&'save:sn.fg2.hu.'+ h = use_lay ; name→lay &&'save:sn.fg2.l2hu.'+ use_lay = h ; lay→name ;[trace text="&'-- hu:'+ h +' lay:'+ save:sn.fg2.hu[h] +' use_lay:'+ use_lay +' hlh:'+ save:sn.fg2.l2hu[use_lay]"] [fg2_attention layer=&use_lay] ; 移動&フェードイン [let_length name=cnt text=&save:sn.fg2.lays@str] &wh = (save:sn.fg2.xe - save:sn.fg2.xb)/cnt/2 ;[trace text="&'== mov&fi cnt:'+ cnt +' wh:'+ wh +' lays:'+ save:sn.fg2.lays@str +':'"] [for_call * name=l from=0 to=&cnt-1 fn=ext_fg2 label=*fg2_dsp lay_fn=%fn lay_face=%face] [for_call name=l from=0 to=&cnt-1 label=*fg2_dspw] [endmacro] ;**************************** [macro name=fg2_attention] [return cond=!sn.fg2.attention_filter] [let_length name=cnt text=&save:sn.fg2.lays@str] [for_call * name=l from=0 to=&cnt-1 fn=ext_fg2 label=*fg2_attention] [endmacro] ;**************************** [macro name=clear_fg2_attention nowarn_unused=true] [return cond=!sn.fg2.attention_filter] [let_length name=cnt text=&save:sn.fg2.lays@str] [for_call * name=l from=0 to=&cnt-1 fn=ext_fg2 label=*clear_fg2_attention] [endmacro] ;******************************************************** ; 立ち絵を屈伸させる [macro name=fg2_squat nowarn_unused=true sum='立ち絵を屈伸させる' %name='追加時の【名前】||対象の立ち絵。追加時の【名前】を指定する' %time?='0〜;ミリ秒|250|変化にかける時間' %y?='ドット数|50|下へ沈ませる移動量' %ease?='イージング名|Circular.easeOut|揺れのイージング(値の変化の仕方)を指定する' %repeats?='0〜(整数)|1|繰返し回数。0は無限ループ' %no_wait?='true、false|false|trueを指定すると、終了を待たない' %ease?='イージング名|Linear.None|揺れのイージング(値の変化の仕方)を指定する' ] [fg2_ini_save_const] [let_replace name=h text=%name val='' reg='_.+' cast=str] &lay=save:sn.fg2.hu[h] [fg_squat * layer=&lay cond='lay != null'] [endmacro] ;******************************************************** ; 立ち絵を震わせる [macro name=fg2_shake nowarn_unused=true sum='立ち絵を震わせる' %name='追加時の【名前】||対象の立ち絵。追加時の【名前】を指定する' %time?='0〜;ミリ秒|250|ひと揺れにかける時間(実際に掛かる時間 = time * repeats *5【マクロ内の[push_tsy_seq]の数】)' %x?='ドット数|5|左右へ揺らす最大移動量' %repeats?='0〜(整数)|5|繰返し回数。0は無限ループ' %no_wait?='true、false|false|trueを指定すると、終了を待たない' ] [fg2_ini_save_const] [let_replace name=h text=%name val='' reg='_.+' cast=str] &lay=save:sn.fg2.hu[h] [fg_shake * layer=&lay cond='lay != null'] [endmacro] ;******************************************************** ; 立ち絵を反復横跳びさせる(楽しそう) [macro name=fg2_sidestep nowarn_unused=true sum='レイヤを反復横跳びさせる' %name='追加時の【名前】||対象の立ち絵。追加時の【名前】を指定する' %time?='0〜;ミリ秒|250|一動作にかける時間(実際に掛かる時間 = time * 4)' %x?='ドット数|25|左右へ揺らす移動量' %y?='ドット数|25|下へ沈ませる移動量' %repeats?='0〜(整数)|1|繰返し回数。0は無限ループ' %no_wait?='true、false|false|trueを指定すると、終了を待たない' ] [fg2_ini_save_const] [let_replace name=h text=%name val='' reg='_.+' cast=str] &lay=save:sn.fg2.hu[h] [fg_sidestep * layer=&lay cond='lay != null'] [endmacro] [return] ;******************************************************** *clear_fg2_attention [let_index_of name=i text=&save:sn.fg2.lays@str val=&for_call_idx.l] [return cond='i == -1'] ; 未使用なら対象外 &lay = for_call_idx.l [clear_filter layer=&lay page=both] [return] ;******************************************************** *fg2_attention [let_index_of name=i text=&save:sn.fg2.lays@str val=&for_call_idx.l] [return cond='i == -1'] ; 未使用なら対象外 &lay = for_call_idx.l [clear_filter layer=&lay page=both] [if exp='lay != mp:layer'] [add_filter layer=&lay page=both filter=&sn.fg2.attention_filter] [endif] [return] ;********************************************************* *fg2_gc [let_index_of name=i text=&save:sn.fg2.lays@str val=&for_call_idx.l] [return cond='i == -1'] ; 未使用なら対象外 &lay = for_call_idx.l &hu = save:sn.fg2.l2hu[lay] ;[trace text="&' ***fg2_gc lay='+ lay +' hu:'+ hu +' v:'+ const.sn.lay[lay].fore.visible +' a:'+ const.sn.lay[lay].fore.alpha +' w:'+ const.sn.lay[lay].fore.width"] [return cond='const.sn.lay[lay].fore.visible && const.sn.lay[lay].fore.alpha > 0 && const.sn.lay[lay].fore.width > 0'] ; 正常 ;[trace text="&' *fg2_gc lay='+ lay +' hu:'+ hu +' w:'+ const.sn.lay[lay].fore.width"] ; 辞書から削除。レイヤは触らない方針 &save:sn.fg2.l2hu[lay] = null &&'save:sn.fg2.hu.'+ hu = null &&'save:sn.fg2.hu.'+ hu +'.pos' = null [let_replace name=save:sn.fg2.lays text=&save:sn.fg2.lays@str val='' reg=&lay cast=str] ;[trace text="&' **exit** save:sn.fg2.lays:'+ save:sn.fg2.lays +':'"] [return] ;******************************************************** *fg2_add [let_index_of name=i text=&save:sn.fg2.lays@str val=&for_call_idx.l] [return cond='i != -1'] &use_lay = for_call_idx.l ; セットするのもここの役目 [if exp="add == 'l'"] &save:sn.fg2.lays = use_lay@str + save:sn.fg2.lays@str = str [elsif exp="add == 'r'"] &save:sn.fg2.lays = save:sn.fg2.lays@str + use_lay@str = str [else] [let_length name=len text=&save:sn.fg2.lays@str] [if exp="len % 2 == 0"] &bl = len/2 = uint [elsif exp="add == 'cl'"] &bl = (len-1)/2 = uint [else] &bl = (len-1)/2+1 = uint [endif] [let_substr name=b text=&save:sn.fg2.lays@str pos=0 len=&bl cast=str] [let_substr name=i text=&save:sn.fg2.lays@str pos=&bl len=all cast=str] &save:sn.fg2.lays = b@str + use_lay@str + i@str = str [endif] [for_call_break] [return] ;******************************************************** *fg2_dsp &l = for_call_idx.l [let_char_at name=lay text=&save:sn.fg2.lays@str pos=&l] ;[trace text="&'---- lay:'+ lay +' lays:'+ save:sn.fg2.lays@str + ' fn:'+ mp:lay_fn + ': l:'+ l +' v:'+ const.sn.lay[lay].fore.visible +' a:'+ const.sn.lay[lay].fore.alpha +' w:'+ const.sn.lay[lay].fore.width"] &x = save:sn.fg2.xb +wh +wh*2*l = int &&'save:sn.fg2.hu.'+ lay +'.pos' = x [if exp='const.sn.lay[lay].fore.visible && const.sn.lay[lay].fore.alpha > 0 && const.sn.lay[lay].fore.width > 0'] ;[trace text="&'== v:t lay:'+ lay +' tsy:'"] [tsy name=&lay layer=&lay time=&time x='&x -const.sn.lay[lay].fore.width/2' ease=&ease] ; tw_nm = name??layer なので ; * 厳禁、移動のみ指定する [else] ;[trace text="&'== v:f lay:'+ lay +' fg:'"] [lay * layer=&lay pos=&x fn=&mp:lay_fn face=&mp:lay_face alpha=0 visible=true] [tsy name=&lay layer=&lay time=&time alpha=&alpha render=true] ; tw_nm = name??layer なので [endif] [return] ;******************************************************** *fg2_dspw [let_char_at name=lay text=&save:sn.fg2.lays@str pos=&for_call_idx.l] [wait_tsy layer=&lay] ; [wait_tsy layer=&lay chk_exist_tw=true] ;4tst [return] ;******************************************************** *fg2_init [lay layer=&for_call_idx.l visible=false] [return]