-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal.go
78 lines (65 loc) · 1.92 KB
/
modal.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package gox
import (
rl "github.com/gen2brain/raylib-go/raylib"
)
type Modal struct {
X, Y, Width, Hight int32
Font rl.Font
app *App
Iteams []InterfaceDraw
Rounde float32
BackgroundColor rl.Color
close bool
shadowColor rl.Color
}
func (mo *Modal) Draw(x, y, width, hight int32) {
mo.X = x
mo.Y = y
mo.Width = width
mo.Hight = hight
if !mo.close {
mo.body(x, y, width, hight)
}
}
func (mo *Modal) body(x, y, width, hight int32) {
mo.shadowColor.A = 30
rl.DrawRectangleRounded(rl.Rectangle{X: float32(x - 5), Y: float32(y - 2), Width: float32(width + 10), Height: float32(hight + 4)}, mo.Rounde, 0, mo.shadowColor)
rl.DrawRectangleRounded(rl.Rectangle{X: float32(x), Y: float32(y), Width: float32(width), Height: float32(hight)}, mo.Rounde, 0, mo.BackgroundColor)
for _, iteam := range mo.Iteams {
rl.BeginScissorMode(x, y, width, hight)
iteam.EnableMemberModal()
iteam.DrawInterface(x+int32(iteam.Coord().X), (int32(iteam.Coord().Y) + y), int32(iteam.Coord().Width), int32(iteam.Coord().Height))
rl.EndScissorMode()
}
mo.event()
}
func (mo *Modal) event() {
check := rl.CheckCollisionRecs(rl.Rectangle{float32(mo.X), float32(mo.Y), float32(mo.Width), float32(mo.Hight)}, rl.Rectangle{float32(rl.GetMouseX()), float32(rl.GetMouseY()), 0, 0})
if check {
mo.app.Lock = true
} else {
mo.app.Lock = false
}
}
func (mo *Modal) SetPosition(x, y int32) {
mo.X = x
mo.Y = y
}
func (mo *Modal) Coord() rl.Rectangle {
return rl.NewRectangle(float32(mo.X), float32(mo.Y), float32(mo.Width), float32(mo.Hight))
}
func (mo *Modal) DrawInterface(x, y, width, hight int32) {
if !mo.close {
mo.body(x, y, width, hight)
}
}
func (mo *Modal) Close() {
mo.close = true
}
func (mo *Modal) Open() {
mo.close = false
}
func (mo *Modal) EnableMemberModal() {}
func (mo *Modal) AddChild(iteam ...InterfaceDraw) {
mo.Iteams = append(mo.Iteams, iteam...)
}