Line data Source code
1 : package overlay
2 :
3 : import (
4 : "github.com/kijimaD/ruins/internal/widgets/entityspec"
5 : "github.com/kijimaD/ruins/internal/widgets/pagination"
6 : w "github.com/kijimaD/ruins/internal/world"
7 : "github.com/mlange-42/ark/ecs"
8 : )
9 :
10 : // detailRowsPerPage は詳細モーダル1ページに収める性能行の数。
11 : // 行数でページ分割することで、短い項目は1ページに収まり、行の多い項目だけがはみ出さないよう分割される
12 : const detailRowsPerPage = 12
13 :
14 : // DetailPageCount はエンティティの詳細モーダルのページ数を返す。
15 : // 呼び出し側が実体からページ数を確かめる公開の入口
16 : func DetailPageCount(world w.World, entity ecs.Entity) int {
17 1 : return detailPageCount(len(entityspec.SpecRows(world, entity)))
18 1 : }
19 :
20 : // detailPageCount は行数からページ数を返す。ページ計算は pagination に委ねる。
21 : // 行が無いか負数のときの1丸めも pagination.GetTotalPages が吸収する
22 : func detailPageCount(rowCount int) int {
23 1 : return pagination.New(0, rowCount, detailRowsPerPage).GetTotalPages()
24 1 : }
|