Verified Commit fb5e8105 authored by Arisaka Mayuki's avatar Arisaka Mayuki
Browse files

Support align/valign

parent fca66eeb
......@@ -22,10 +22,10 @@ __meta__ = {
}
[node name="LabelContainer" type="Control" parent="VBoxContainer"]
margin_top = 120.0
margin_top = 40.0
margin_right = 1024.0
margin_bottom = 480.0
rect_min_size = Vector2( 1024, 360 )
margin_bottom = 560.0
rect_min_size = Vector2( 1024, 520 )
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
......@@ -33,8 +33,10 @@ __meta__ = {
[node name="Message" type="Label" parent="VBoxContainer/LabelContainer"]
margin_right = 1024.0
margin_bottom = 360.0
margin_bottom = 520.0
custom_fonts/font = SubResource( 1 )
align = 1
valign = 3
autowrap = true
__meta__ = {
"_edit_use_anchors_": false
......
......@@ -55,13 +55,25 @@ func apply():
# メッセージ
var m_text: String = m_label.text
var m_size: Vector2 = m_font.get_string_size(m_text)
var m_text_lines: Array = m_text.split("\n")
m_size.y += m_size.y * (m_text_lines.size() - 1)
var _li = 0
# ルビの存在する行
var m_text_line: String = m_text_lines[_li]
var _lidx: int = m_text_line.length()
while _lidx < ruby.t_idx:
_li += 1
m_text_line = m_text_lines[_li]
_lidx += m_text_line.length() + 1
var m_text_line_size: Vector2 = m_font.get_string_size(m_text_line)
# メッセージのうち、テキスト直前までのもの
var m_pre_text: String = m_text.substr(0, ruby.t_idx)
var m_pre_size: Vector2 = m_font.get_string_size(m_pre_text)
# メッセージのテキスト直前までのもののうち、改行を含むもの
var m_pre_nl_count: int = m_pre_text.count("\n")
m_pre_size.y += m_pre_size.y * m_pre_nl_count
# メッセージのテキスト直前までのもののうち、改行以降のもの
var m_pre_after_nl_idx: int = m_pre_text.find_last("\n")
var m_pre_after_nl_size: Vector2 = m_font.get_string_size(m_pre_text.substr(m_pre_after_nl_idx)) if m_pre_after_nl_idx >= 0 else m_pre_size
var m_pre_after_nl_size: Vector2 = m_font.get_string_size(m_pre_text.substr(m_pre_after_nl_idx + 1)) if m_pre_after_nl_idx >= 0 else m_pre_size
# ルビ長が対象より短い場合、スペースを入れて埋める
if r_size.x < t_size.x:
......@@ -70,7 +82,23 @@ func apply():
# いい感じにルビ位置を設定する
# SPACING/SPACING_EXTRAでルビ位置を微調整している
var r_pos: Vector2 = Vector2(int(m_pre_after_nl_size.x) % int(m_label.rect_size.x), m_size.y * m_pre_nl_count + SPACING - r_size.y + SPACING_EXTRA * m_pre_nl_count)
var x_spacing: float = 0
match (m_label.align):
Label.ALIGN_CENTER:
x_spacing = (m_label.rect_size.x - m_text_line_size.x) / 2
Label.ALIGN_RIGHT:
x_spacing = (m_label.rect_size.x - m_text_line_size.x)
var y_spacing: float = 0
match (m_label.valign):
Label.VALIGN_CENTER:
y_spacing = (m_label.rect_size.y - m_size.y) / 2
Label.VALIGN_BOTTOM:
y_spacing = (m_label.rect_size.y - m_size.y)
Label.VALIGN_FILL:
y_spacing += ((m_label.rect_size.y - m_size.y) / (m_text_lines.size() - 1)) * m_pre_nl_count
var r_pos_x: float = x_spacing + (int(m_pre_after_nl_size.x) % int(m_label.rect_size.x))
var r_pos_y: float = y_spacing + (m_text_line_size.y * m_pre_nl_count + SPACING - r_size.y + SPACING_EXTRA * m_pre_nl_count)
var r_pos: Vector2 = Vector2(r_pos_x, r_pos_y)
r_pos.x += (t_size.x - r_size.x) / 2
r_label.rect_position = r_pos
r_label.visible = true
......
......@@ -2,15 +2,15 @@
importer="texture"
type="StreamTexture"
path="res://.import/screenshot.png-024a21af5d37bf0f0dd0e2bccdd149d0.stex"
path="res://.import/screenshot_cc.png-700ce88655c8adc3f946720ef1d3c54d.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://screenshot.png"
dest_files=[ "res://.import/screenshot.png-024a21af5d37bf0f0dd0e2bccdd149d0.stex" ]
source_file="res://screenshot_cc.png"
dest_files=[ "res://.import/screenshot_cc.png-700ce88655c8adc3f946720ef1d3c54d.stex" ]
[params]
......
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/screenshot_cf.png-dc6a389144fb7a4fb79d8a703a3027da.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://screenshot_cf.png"
dest_files=[ "res://.import/screenshot_cf.png-dc6a389144fb7a4fb79d8a703a3027da.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/screenshot_lt.png-c3054e506376a8d7172f16749886e9c6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://screenshot_lt.png"
dest_files=[ "res://.import/screenshot_lt.png-c3054e506376a8d7172f16749886e9c6.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/screenshot_rb.png-cceeb86d37f4688ecbc33a8249fde3e0.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://screenshot_rb.png"
dest_files=[ "res://.import/screenshot_rb.png-cceeb86d37f4688ecbc33a8249fde3e0.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment