LCOV - code coverage report
Current view: top level - widgets/menuframe - titlescreen.go Coverage Total Hit
Test: coverage.lcov Lines: 100.0 % 21 21
Test Date: 2026-11-19 00:25:22 Functions: - 0 0

            Line data    Source code
       1              : package menuframe
       2              : 
       3              : import (
       4              :         "image"
       5              : 
       6              :         "github.com/kijimaD/ruins/internal/resources"
       7              :         "github.com/kijimaD/ruins/internal/widgets/styled"
       8              :         "github.com/kijimaD/ruins/internal/widgets/theme"
       9              :         "github.com/kijimaD/ruins/internal/widgets/uicore"
      10              :         w "github.com/kijimaD/ruins/internal/world"
      11              : )
      12              : 
      13              : // 背景を透かすタイトル画面の寸法。画面はこれらを知らない
      14              : const (
      15              :         titleMenuLeft   = 64  // メニューの左端
      16              :         titleMenuBottom = 72  // メニュー下端から画面下端までの高さ
      17              :         titleNoteW      = 232 // 右下の注記の幅
      18              :         titleNoteMargin = 8   // 注記と画面端の余白
      19              : )
      20              : 
      21              : // TitleScreen は背景を透かすタイトル画面を組む。メニューを左下へ左寄せで置き、
      22              : // 版などの注記を右下へ右寄せで積む。パネル背景は付けない。
      23              : // 寸法と余白は部品が持ち、画面は項目と注記の文言だけを渡す。
      24              : func TitleScreen(world w.World, res resources.UIResources, itemIndex int, rows []Row, notes []string) uicore.Widget {
      25            1 :         sd := world.Resources.ScreenDimensions
      26            1 : 
      27              :         // タイトル画面は単一ページ。ページ表示は使わないので捨てる
      28            1 :         listRows, _ := RenderList(itemIndex, rows, styled.Cols(styled.Name()), ListOpts{}, res)
      29            1 :         menu := uicore.VBox(theme.MenuPanelRowH, uicore.Placeable(listRows)...)
      30            1 :         menuH := len(listRows) * theme.MenuPanelRowH
      31            1 :         menuTop := sd.Height - titleMenuBottom - menuH
      32            1 :         menu.Layout(image.Rect(titleMenuLeft, menuTop, titleMenuLeft+theme.MenuRowWidth, menuTop+menuH))
      33            1 : 
      34            1 :         children := make([]uicore.Widget, 0, 1+len(notes))
      35            1 :         children = append(children, menu)
      36            1 :         // 注記は下端から上へ積む。行数が変わっても最終行の位置は動かない
      37            1 :         for i, line := range notes {
      38            1 :                 t := uicore.NewText(line, res.Text.SmallFace, theme.TextAccent)
      39            1 :                 t.Align = uicore.AlignRight
      40            1 :                 y := sd.Height - noteRowH*(len(notes)-i) - titleNoteMargin
      41            1 :                 t.Layout(image.Rect(sd.Width-titleNoteW-titleNoteMargin, y, sd.Width-titleNoteMargin, y+noteRowH))
      42            1 :                 children = append(children, t)
      43            1 :         }
      44              : 
      45            1 :         root := uicore.NewGroup(children...)
      46            1 :         root.Layout(image.Rect(0, 0, sd.Width, sd.Height))
      47            1 :         return root
      48              : }
        

Generated by: LCOV version 2.0-1