101 lines
4.7 KiB
Lua
101 lines
4.7 KiB
Lua
-- YataiDONJuuyon mode-select board (juu-yon scenes/main_menu.tscn + scripts/scenes/main_menu.gd).
|
|
-- * boards are the main_menu PanelContainers rebuilt 1:1 (Graphics/entry/jy_entry/board_0..3,
|
|
-- 125 x 412): bar.png 9-slice modulated with the board colour + bar_highlight;
|
|
-- * juu-yon right-aligns the row (MenuItems HBox, margin_right 32, separation 4 -> right edge 928);
|
|
-- the engine centres it (box_manager.cpp), so the board is drawn shifted by 448 - total / 2;
|
|
-- * the selected board rises 48 px (main_menu.gd target_y -= 48; engine "box opening" animation 11
|
|
-- carries the 48 px), its label outline turns black and the white Highlight pulses at
|
|
-- alpha (sin(t*4 - 90deg) + 1) / 8;
|
|
-- * the selected board also shows the Description panel (VBoxContainer 400..928 x 512..592).
|
|
-- Colours follow the board's function: 演奏ゲーム orange, 私の部屋 (engine: costume) green,
|
|
-- ゲーム設定 (settings) cyan, and the 4th juu-yon colour (ゲーム終了 pink) for the engine's
|
|
-- practice / dan boards, which juu-yon does not have.
|
|
EntryBox = {}
|
|
EntryBox.__index = EntryBox
|
|
|
|
local SS = tex.get_screen_scale()
|
|
local SKIN = {
|
|
entry_box_text_offset = { y = 29 },
|
|
}
|
|
-- juu-yon's outline widths look too heavy at this skin's 960 px (user, 2026-09-27): every text
|
|
-- outline is drawn at OUTLINE_K of the juu-yon value.
|
|
local OUTLINE_K = 0.6
|
|
local BOARD_W, BOARD_Y, SEP = 125, 128, 4
|
|
local OUTLINES = { [0] = { 157, 37, 3 }, [1] = { 101, 115, 38 }, [2] = { 2, 140, 147 }, [3] = { 132, 51, 64 } }
|
|
local DESC_KEY = { [0] = "jy_desc_songselect", [1] = "jy_desc_myroom", [2] = "jy_desc_options" }
|
|
|
|
local count = 0
|
|
|
|
local function kind_of(text_str)
|
|
if text_str == tex.skin_text("entry_game") then return 0 end
|
|
if text_str == tex.skin_text("entry_costume") then return 1 end
|
|
if text_str == tex.skin_text("entry_settings") then return 2 end
|
|
return 3
|
|
end
|
|
|
|
function EntryBox.new(text_str, font_size)
|
|
local self = setmetatable({}, EntryBox)
|
|
if __hss_entry_reset then
|
|
count = 0
|
|
__hss_entry_reset = false
|
|
end
|
|
self.index = count
|
|
count = count + 1
|
|
|
|
self.kind = kind_of(text_str)
|
|
-- VerticalText2D font 32, outline_size 18 (radius 9), board outline colour / black when selected
|
|
self.text = text.create_raw_text(text_str, font_size, { 255, 255, 255, 255 },
|
|
{ OUTLINES[self.kind][1], OUTLINES[self.kind][2], OUTLINES[self.kind][3], 255 },
|
|
true, 9 * OUTLINE_K / SS)
|
|
self.text_sel = text.create_raw_text(text_str, font_size, { 255, 255, 255, 255 }, { 0, 0, 0, 255 }, true, 9 * OUTLINE_K / SS)
|
|
|
|
self.board = tex.get_texture("entry/jy_entry/board_" .. self.kind)
|
|
self.white = tex.get_texture("entry/jy_entry/white")
|
|
self.desc = tex.get_texture("entry/jy_entry/description")
|
|
local key = DESC_KEY[self.kind]
|
|
if key then
|
|
local s = tex.skin_text(key)
|
|
self.desc_lines = {}
|
|
for line in (s .. "\n"):gmatch("(.-)\n") do
|
|
if line ~= "" then
|
|
-- DescriptionLabel: ipag 20, black, outline 2 black
|
|
self.desc_lines[#self.desc_lines + 1] = text.create_raw_text(line, 20, { 0, 0, 0, 255 }, { 0, 0, 0, 255 }, false, 1 / SS)
|
|
end
|
|
end
|
|
end
|
|
local off = SKIN.entry_box_text_offset
|
|
self.text_y_offset = off and off.y or 29
|
|
self.start_ms = tex.get_current_ms()
|
|
return self
|
|
end
|
|
|
|
function EntryBox:draw(x, left_x, right_x, is_selected, move_finished, open_attr, fade, y_pos)
|
|
local total = count * BOARD_W + (count - 1) * SEP
|
|
local bx = x + (448 - total / 2)
|
|
local rise = is_selected and open_attr or 0
|
|
local by = BOARD_Y - rise
|
|
|
|
tex.draw_texture(self.board, { x = bx, y = by, fade = fade })
|
|
if is_selected then
|
|
local t = (tex.get_current_ms() - self.start_ms) / 1000.0
|
|
local a = (math.sin(t * 4 - math.rad(90)) + 1) / 8
|
|
-- Highlight: StyleBoxFlat white, expand margins 18/17/19/17 around the content rect -> (0,0)-(102,388)
|
|
tex.draw_texture(self.white, { x = bx, y = by, x2 = 102 - 1, y2 = 388 - 1, fade = a * fade })
|
|
else
|
|
self.start_ms = tex.get_current_ms()
|
|
end
|
|
|
|
local t = is_selected and self.text_sel or self.text
|
|
t:draw({ x = math.floor(bx + 50.5 - t.width / 2 + 0.5), y = by + self.text_y_offset, fade = fade })
|
|
|
|
if is_selected and self.desc and self.desc_lines then
|
|
tex.draw_texture(self.desc, { x = 400, y = 512, fade = fade })
|
|
local n = #self.desc_lines
|
|
local lh = n > 0 and self.desc_lines[1].height or 0
|
|
local y0 = 552 - n * lh / 2
|
|
for i, ln in ipairs(self.desc_lines) do
|
|
ln:draw({ x = math.floor(664 - ln.width / 2 + 0.5), y = math.floor(y0 + (i - 1) * lh + 0.5), fade = fade })
|
|
end
|
|
end
|
|
end
|