-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.go
172 lines (144 loc) · 3.48 KB
/
ui.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package main
import (
// "fmt"
"image"
"image/color"
"strings"
"time"
// "strconv"
g "github.com/AllenDang/giu"
"github.com/AllenDang/imgui-go"
)
var (
selectedLevel string
)
func initUI() {
InitAddressesManager()
}
var LevelsMaps = map[string]string {
"Freddy": "maps/freddy",
"Bonnie": "maps/bonnie",
"Chica": "maps/chica",
"Foxy": "maps/foxy",
}
var pixelsIn1080Square int32 = 55
var unitsInSquare int32 = 320
var xoffset int32 = 0
var yoffset int32 = 0
func loop() {
imgui.PushStyleVarFloat(imgui.StyleVarWindowBorderSize, 0)
g.PushColorFrameBg(color.RGBA{10, 10, 10, 0})
// if focused {
// g.PushColorWindowBg(color.RGBA{50, 50, 50, 128})
// } else {
g.PushColorWindowBg(color.RGBA{10, 10, 10, 0})
// }
// var pixelsInUnitX, pixelsInUnitZ, xOffset, yOffset = getUnits(selectedLevel)
var pixelsInRadarSquare = int(pixelsIn1080Square)*radarSize/1080
var xUnitsInSquare = unitsInSquare
var zUnitsInSquare = unitsInSquare
var pixelsInUnitX float32 = float32(pixelsInRadarSquare)/float32(xUnitsInSquare)
var pixelsInUnitZ float32 = float32(pixelsInRadarSquare)/float32(zUnitsInSquare)
g.SingleWindow().Layout(
g.InputInt(&pixelsIn1080Square),
g.InputInt(&unitsInSquare),
g.InputInt(&xoffset),
g.InputInt(&yoffset),
g.Custom(func() {
canvas := g.GetCanvas()
if(!RunChecks(canvas)) {
return
}
X, Z, _ := GetUserPosition()
playerX := int(X*pixelsInUnitX)
playerZ := int(Z*pixelsInUnitZ)
playerSpriteSize := 20
renderImage(
canvas,
textures["player"],
image.Pt(windowSize/2 - playerSpriteSize/2, windowSize/2 - playerSpriteSize/2),
image.Pt(playerSpriteSize, playerSpriteSize),
)
renderImage(
canvas,
textures[LevelsMaps[selectedLevel]],
image.Pt(-playerZ+int(xoffset), playerX+int(yoffset)),
image.Pt(radarSize, radarSize),
)
}),
)
g.PopStyleColor()
g.PopStyleColor()
imgui.PopStyleVar()
}
func RunChecks(canvas *g.Canvas) bool {
drawText := func(text string) {
text = "tJocer:\n" + text
canvas.AddRectFilled(
image.Pt(0, 0),
image.Pt(
windowSize,
len(strings.Split(text, "\n"))*18+10,
),
color.RGBA{0, 0, 0, 180},
1,
g.DrawFlagsRoundCornersAll,
)
canvas.AddText(image.Pt(10, 10), color.White, text)
}
// if(baseAddress == 0) {
// drawText(t("GAME_IS_CLOSED"))
// return false
// }
pid, success := bindDefaultProcess()
if(!success) {
drawText(t("GAME_IS_CLOSED"))
baseAddress = 0
return false
}
baseAddress_, err := memoryReadInit(pid)
if(err == "NO_HANDLE") {
drawText(t("COULDNT_GET_HANDLE"))
return false
} else if (err == "BASE_ADDRESS_NOT_FOUND") {
drawText(t("COULDNT_READ_BASE_ADDRESS"))
return false
} else if (err == "" && baseAddress == 0) {
baseAddress = baseAddress_
initUI()
}
val, errReading := readMemoryAtByte8(baseAddress)
if(errReading || val == 0) {
drawText(t("GAME_IS_CLOSED"))
return false
}
selectedLevel = GetSelectedLevel()
switch selectedLevel {
case "":
drawText(t("UNKNOWN_LEVEL"))
return false
case "Loading level":
drawText(t("LEVEL_LOADING"))
return false
case "Menu":
drawText(t("SELECT_LEVEL"))
return false
}
if(LevelsMaps[selectedLevel] == "") {
drawText(t("NO_MAP"))
return false
}
return true
}
func renderImage(canvas *g.Canvas, texture *g.Texture, pos1 image.Point, pos2 image.Point) {
if(texture != nil) {
canvas.AddImage(texture, pos1, pos1.Add(pos2))
}
}
func refresh() {
ticker := time.NewTicker(time.Millisecond * 50)
for {
g.Update()
<-ticker.C
}
}