Line data Source code
1 : package menuframe
2 :
3 : import (
4 : "image"
5 :
6 : "github.com/kijimaD/ruins/internal/widgets/hud"
7 : "github.com/kijimaD/ruins/internal/widgets/theme"
8 : w "github.com/kijimaD/ruins/internal/world"
9 : )
10 :
11 : // logTopY はゲームログ領域の上端Yを返す。モーダルやパネルをログに被らせないための基準にする
12 : func logTopY(screenHeight int) int {
13 1 : return screenHeight - hud.DefaultMessageAreaConfig.Height() - theme.Space3
14 1 : }
15 :
16 : // ModalRect は大きめモーダル、タブ画面など、の矩形を返す。画面をひと回り小さくし、ログ領域の
17 : // 手前で止める。上端は他のウィンドウと同じ MenuWindowTop で揃え、下はログ予約ぶんを空ける。
18 : func ModalRect(world w.World) image.Rectangle {
19 1 : sw := world.Resources.ScreenDimensions.Width
20 1 : sh := world.Resources.ScreenDimensions.Height
21 1 : logReserve := sh - logTopY(sh) + theme.Space3
22 1 : return image.Rect(theme.MenuModalMarginX, theme.MenuWindowTop, sw-theme.MenuModalMarginX, sh-logReserve)
23 1 : }
24 :
25 : // WindowRect は小さめウィンドウの標準矩形を返す。詳細モーダルやパネルを置く共通の位置で、
26 : // 画面ごとに位置合わせをしなくてよいようにする。横は画面中央、上端は他のウィンドウと同じ
27 : // MenuWindowTop で揃える
28 : func WindowRect(world w.World) image.Rectangle {
29 1 : windowWidth, windowHeight := 400, 400
30 1 : screenWidth := world.Resources.ScreenDimensions.Width
31 1 : x := screenWidth/2 - windowWidth/2
32 1 : y := theme.MenuWindowTop
33 1 : return image.Rect(x, y, x+windowWidth, y+windowHeight)
34 1 : }
|