Skip to content

Instantly share code, notes, and snippets.

@lost-nd-xxx
Created April 3, 2024 21:09
Show Gist options
  • Save lost-nd-xxx/e360ed4b1106d8a2496e09f38378cff5 to your computer and use it in GitHub Desktop.
Save lost-nd-xxx/e360ed4b1106d8a2496e09f38378cff5 to your computer and use it in GitHub Desktop.
里々用縦書き変換関数
#里々用縦書き変換関数
#このテキストファイルはPublic Domainで公開します。ご自由にお使いください。
#◆使い方
#(call、縦書き変換、【スコープ】、【バルーン番号】、【文字列】、【(省略可能)表示後に飛ぶイベント名】)
#タブ文字を【タブ】と表記しています。
#都合上、入力文字列は全角に変換されます。
#そのため、さくらスクリプトが含まれていると不格好になります。
################
# テスト表示用
################
*縦書きテストメニュー
:\c\_q縦書きを試しますか?
_◆試してみる【タブ】縦書きテスト表示
_◆何もしない【タブ】script:\e
*縦書きテスト表示
:(call,縦書き変換,0,0,(テスト用文章),縦書きテスト表示後)
*縦書きテスト表示後
:\x
>縦書きテストメニュー
@テスト用文章
寿限無(ウェイト) 寿限無(ウェイト)(改行)五却のすりきれ(ウェイト)(改行)海砂利水魚の(ウェイト)(改行)水行末(ウェイト)(改行)雲来末(ウェイト)(改行)風来末(ウェイト)(改行)食う寝る処に住む処(ウェイト)(改行)藪ら柑子の藪柑子(ウェイト)(改行)パイポパイポ(ウェイト)(改行)パイポのシューリンガン(ウェイト)(改行)シューリンガンの(ウェイト)グーリンダイ(ウェイト)(改行)グーリンダイの(ウェイト)ポンポコピーの(ウェイト)ポンポコナーの(ウェイト)(改行)長久命の(ウェイト) 長助
@改行
(tate_改行記号)
#簡略表記用
@ウェイト
(tate_ウェイト記号)
#簡略表記用
################
# カスタム要素
################
@tate_改行記号
(バイト値,2)
#文章中で使われない1文字
#これを入力文字列へ入れると強制的に改行されます
@tate_ウェイト記号
(バイト値,3)
#文章中で使われない1文字
#これを入力文字列へ入れると下記のウェイトが入ります
@tate_ウェイト
\w5
#(tate_ウェイト記号)を入れた箇所がこれに置き換えられます
@tate_行間
0.5
#単位はemです(1em=全角での1文字)
@tate_字間
0.1
#単位はemです(1em=全角での1文字)
@tate_末尾省略記号
#文章がバルーン1画面に収まりきらなかったときに末尾を省略します
#その時に入れる記号や文字などを書いてください
#表示で全角一文字の大きさになっていれば、インライン画像やユニコード記号でもOKです
################
# ここから本体
################
@縦書き変換
(whenlist,(nop,),
(Aの数)<3,
[縦書き変換エラー]引数が足りません。,
(vncall,is_digit,A0,tate_いんてぐら)==0,
[縦書き変換エラー]引数1つめが整数ではありません。,
(vncall,is_digit,A1,tate_いんてぐら)==0,
[縦書き変換エラー]引数2つめが整数ではありません。,
(vncall,length,A2)<=0,
[縦書き変換エラー]引数3つめがおかしいです,
(tate_準備)
@tate_いんてぐら
integer
*tate_準備
$tate_文字列【タブ】(vncall,han2zen,A2)
$tate_出力前【タブ】(whenlist,(A0)==,0,\0,1,\1,\p[(A0)])\b[(A1)]
(tate_出力前)\_w[1]\![embed,On_tate_本体,(A0),(A3)]
*On_tate_本体
$tate_バルーン高さ【タブ】(get_property,currentghost.balloon.scope((R0)).validheight.initial)
$tate_バルーン横幅【タブ】(get_property,currentghost.balloon.scope((R0)).validwidth)
$tate_バルーン半角字幅【タブ】(get_property,currentghost.balloon.scope((R0)).char_width)
$tate_バルーン行数【タブ】(get_property,currentghost.balloon.scope((R0)).lines.initial)
$tate_バルーン字高【タブ】(calc,(tate_バルーン高さ)/(tate_バルーン行数))
$tate_バルーン行数【タブ】(sprintf,%d,(calc_float,((tate_バルーン高さ)-(tate_バルーン字高))/(tate_バルーン字高)*((tate_字間)+1)))
$tate_バルーン横幅【タブ】(when、(変数「tate_バルーン横幅」の存在)==0、312、(tate_バルーン横幅))
$tate_バルーン行数【タブ】(when、(変数「tate_バルーン行数」の存在)==0、10、(tate_バルーン行数))
$tate_バルーン半角字幅【タブ】(when、(変数「tate_バルーン半角字幅」の存在)==0、6、(tate_バルーン半角字幅))
$tate_バルーン列数【タブ】(sprintf,%d,(calc_float,(tate_バルーン横幅)/((tate_バルーン半角字幅)*2*((tate_行間)+1))))
$tate_バルーン最大字数【タブ】(sprintf,%d,(calc_float,(tate_バルーン列数)*(tate_バルーン行数)))
$tate_行カウント【タブ】0
$tate_列カウント【タブ】0
$tate_字カウント【タブ】0
$tate_改行フラグ【タブ】0
$tate_自動改行直後【タブ】0
$tate_出力【タブ】0
$tate_ループ継続【タブ】1
\![raise,On_tate_出力開始,(R1)]
*On_tate_出力開始
(tate_出力前)\c(while,(tate_ループ継続),(tate_ループ))
$tate_tmp【タブ】(nop,(tate_変数削除))
>(R0)【タブ】(変数「(R0)」の存在)==1
*tate_記号変換
$tate_出力【タブ】(replace、(tate_出力)、、、\_u[0xfe11])
$tate_出力【タブ】(replace、(tate_出力)、。、\_u[0xfe12])
$tate_出力【タブ】(replace、(tate_出力)、…、\_u[0xfe19])
$tate_出力【タブ】(replace、(tate_出力)、ー、\_u[0xfe31])
$tate_出力【タブ】(replace、(tate_出力)、{、\_u[0xfe37])
$tate_出力【タブ】(replace、(tate_出力)、}、\_u[0xfe38])
$tate_出力【タブ】(replace、(tate_出力)、〔、\_u[0xfe39])
$tate_出力【タブ】(replace、(tate_出力)、〕、\_u[0xfe3a])
$tate_出力【タブ】(replace、(tate_出力)、【、\_u[0xfe3b])
$tate_出力【タブ】(replace、(tate_出力)、】、\_u[0xfe3c])
$tate_出力【タブ】(replace、(tate_出力)、《、\_u[0xfe3d])
$tate_出力【タブ】(replace、(tate_出力)、》、\_u[0xfe3e])
$tate_出力【タブ】(replace、(tate_出力)、〈、\_u[0xfe3f])
$tate_出力【タブ】(replace、(tate_出力)、〉、\_u[0xfe40])
$tate_出力【タブ】(replace、(tate_出力)、「、\_u[0xfe41])
$tate_出力【タブ】(replace、(tate_出力)、」、\_u[0xfe42])
$tate_出力【タブ】(replace、(tate_出力)、『、\_u[0xfe43])
$tate_出力【タブ】(replace、(tate_出力)、』、\_u[0xfe44])
$tate_出力【タブ】(replace、(tate_出力)、[、\_u[0xfe47])
$tate_出力【タブ】(replace、(tate_出力)、]、\_u[0xfe48])
$tate_出力【タブ】(replace、(tate_出力)、ぁ、\_l[@0.1em,]ぁ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ぃ、\_l[@0.1em,]ぃ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ぅ、\_l[@0.1em,]ぅ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ぇ、\_l[@0.1em,]ぇ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ぉ、\_l[@0.1em,]ぉ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、っ、\_l[@0.1em,]っ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ゃ、\_l[@0.1em,]ゃ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ゅ、\_l[@0.1em,]ゅ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ょ、\_l[@0.1em,]ょ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ゎ、\_l[@0.1em,]ゎ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ァ、\_l[@0.1em,]ァ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ィ、\_l[@0.1em,]ィ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ゥ、\_l[@0.1em,]ゥ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ェ、\_l[@0.1em,]ェ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ォ、\_l[@0.1em,]ォ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ヵ、\_l[@0.1em,]ヵ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ヶ、\_l[@0.1em,]ヶ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ッ、\_l[@0.1em,]ッ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ャ、\_l[@0.1em,]ャ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ュ、\_l[@0.1em,]ュ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ョ、\_l[@0.1em,]ョ\_l[@-0.1em,])
$tate_出力【タブ】(replace、(tate_出力)、ヮ、\_l[@0.1em,]ヮ\_l[@-0.1em,])
#縦書き用記号へ変換したり、小さい文字を右に寄せたり
*tate_変数削除
$tate_バルーン列数【タブ】
$tate_バルーン半角字幅【タブ】
$tate_バルーン字高【タブ】
$tate_バルーン最大字数【タブ】
$tate_バルーン横幅【タブ】
$tate_バルーン行数【タブ】
$tate_バルーン高さ【タブ】
$tate_ループ継続【タブ】
$tate_出力【タブ】
$tate_出力前【タブ】
$tate_列カウント【タブ】
$tate_字カウント【タブ】
$tate_改行フラグ【タブ】
$tate_文字列【タブ】
$tate_自動改行直後【タブ】
$tate_行カウント【タブ】
@tate_位置指定
\_l[(calc_float,((tate_バルーン列数)-(tate_列カウント))*((tate_行間)+1))em,(calc_float,(tate_行カウント)*((tate_字間)+1))em]
@tate_ループ
(whenlist,(nop,),φ
(tate_列カウント)==(calc,(tate_バルーン列数))&&φ
(tate_行カウント)==(calc,(tate_バルーン行数)-1)&&φ
(tate_文字存在確認)==1,φ
(vncall,set,tate_結果変数名,tate_末尾省略)(tate_結果追記)φ
(set,tate_ループ継続,0),φ
(tate_列カウント)>(calc,(tate_バルーン列数))&&φ
(tate_文字存在確認)==1,φ
(vncall,set,tate_結果変数名,tate_末尾省略)(tate_結果追記)φ
(set,tate_ループ継続,0),φ
(tate_文字存在確認)==1,φ
(vncall,set,tate_結果変数名,tate_結果格納内容)(tate_結果追記),φ
(tate_文字存在確認)==0,φ
(set,tate_ループ継続,0)φ
)φ
(when,(tate_行カウント)>=(tate_バルーン行数),φ
(set,tate_自動改行直後,1)φ
(set,tate_行カウント,0)φ
(set,tate_列カウント,(calc,(tate_列カウント)+1))φ
)φ
@tate_文字存在確認
(vncall,length,tate_文字存在確認部品)
@tate_文字存在確認部品
(vncall,at,tate_文字列,tate_字カウント)
@tate_末尾省略
\_l[0,(calc_float,((tate_バルーン行数)-1)*((tate_字間)+1))em]φ
(tate_末尾省略記号)
@tate_結果変数名
tate_出力
@tate_結果格納内容
(whenlist、(nop,)、φ
(equal,(vncall,at,tate_文字列,tate_字カウント),(tate_改行記号))==1&&φ
(tate_自動改行直後)==1、φ
(set,tate_行カウント,0)φ
(set,tate_字カウント,(calc,(tate_字カウント)+1))φ
(set,tate_自動改行直後,0)、φ
(equal,(vncall,at,tate_文字列,tate_字カウント),(tate_改行記号))==1、φ
(set,tate_行カウント,0)φ
(set,tate_字カウント,(calc,(tate_字カウント)+1))φ
(set,tate_列カウント,(calc,(tate_列カウント)+1))φ
(set,tate_自動改行直後,0)、φ
(equal,(vncall,at,tate_文字列,tate_字カウント),(tate_ウェイト記号))==1、φ
(tate_ウェイト)φ
(set,tate_字カウント,(calc,(tate_字カウント)+1))、φ
(tate_位置指定)φ
(vncall,at,tate_文字列,tate_字カウント)φ
(set,tate_自動改行直後,0)φ
(set,tate_字カウント,(calc,(tate_字カウント)+1))φ
(set,tate_行カウント,(calc,(tate_行カウント)+1))φ
#(tate_位置指定)に半角カンマが含まれるため、whenlistの区切り字を「、」にしている
@tate_結果追記
(when、(vncall,length,(tate_結果変数名))>0、φ
(nop,(vncall,tate_記号変換,tate_結果変数名))φ
((tate_結果変数名))φ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment