-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
133 lines (119 loc) · 3.81 KB
/
main.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
package main
import (
"fmt"
"runtime"
rl "github.com/gen2brain/raylib-go/raylib"
"github.com/luminoso-256/pipan/libmcpi"
)
const (
VERSION = "21MMDD"
)
var (
tabs = []string{"Play", "Profiles", "About"}
currTab = 0
font rl.Font
profiles []PipanProfile
cSelProfile = 0
)
func main() {
rl.SetConfigFlags(rl.FlagWindowResizable)
rl.InitWindow(800, 450, "Pipan")
rl.SetTargetFPS(60)
font = rl.LoadFont("data/font.ttf")
profiles = append(profiles, PipanProfile{
"A Test Profile", true, "Tiny", "AUsername", make(map[string]bool),
})
profiles = append(profiles, PipanProfile{
"Test 2: Electric Boogalo", false, "Tiny", "AUsername", make(map[string]bool),
})
profiles = append(profiles, PipanProfile{
"Three's a crowd", true, "Tiny", "AUsername", make(map[string]bool),
})
for !rl.WindowShouldClose() {
//= Core Input
if rl.IsKeyDown(rl.KeyLeftControl) && rl.IsKeyDown(rl.KeyOne) {
currTab = 0
}
if rl.IsKeyDown(rl.KeyLeftControl) && rl.IsKeyDown(rl.KeyTwo) {
currTab = 1
}
if rl.IsKeyDown(rl.KeyLeftControl) && rl.IsKeyDown(rl.KeyThree) {
currTab = 2
}
if currTab == 0 {
if rl.IsKeyDown(rl.KeyUp) && cSelProfile > 0 {
cSelProfile -= 1
}
if rl.IsKeyDown(rl.KeyDown) && cSelProfile < len(profiles)-1 {
cSelProfile += 1
}
if rl.IsKeyDown(rl.KeyEnter) {
var ff []string
for f, b := range profiles[cSelProfile].Features {
if b {
ff = append(ff, f)
}
}
lp := libmcpi.LaunchProfile{
ff,
profiles[cSelProfile].Username,
profiles[cSelProfile].RendDist,
"minecraft-pi-reborn-client",
}
var wg = lp.Launch()
defer wg.Wait()
break
}
}
//= Draw
rl.BeginDrawing()
rl.ClearBackground(rl.RayWhite)
/* The three core pages of UI */
switch currTab {
case 0:
pfX := float32(5)
for i, profile := range profiles {
name := ""
if profile.Modded {
name = fmt.Sprintf("[%d] %s (modded)", i, profile.Name)
} else {
name = fmt.Sprintf("[%d] %s (vanilla)", i, profile.Name)
}
if i == cSelProfile {
rl.DrawTextEx(font, name, rl.Vector2{5, pfX}, 16, 3, rl.Orange)
} else {
rl.DrawTextEx(font, name, rl.Vector2{5, pfX}, 16, 3, rl.Red)
}
pfX += 18
}
rl.DrawTextEx(font, "Arrows to Sel | Enter to Launch", rl.Vector2{5, float32(rl.GetScreenHeight()) - 36}, 14, 3, rl.LightGray)
break
case 1:
break
case 2:
if runtime.GOOS == "windows" {
//if you're building on windows this isnt going to work. Such a build should appropriately be identified as a UI dummy
rl.DrawTextEx(font, "Pipan ~ "+VERSION+" ("+runtime.GOOS+"-"+runtime.GOARCH+") [UIDummy]", rl.Vector2{5, 5}, 21, 3, rl.Black)
} else {
rl.DrawTextEx(font, "Pipan ~ "+VERSION+" ("+runtime.GOOS+"-"+runtime.GOARCH+")", rl.Vector2{5, 5}, 21, 3, rl.Black)
}
rl.DrawTextEx(font, "-----------------------------\nhttps://github.com/randomsoup/pipan", rl.Vector2{5, 30}, 15, 3, rl.Black)
rl.DrawTextEx(font, "Pipan is (C) Luminoso 2021 / MIT \nHave suggestions? Open a Github Issue", rl.Vector2{5, 85}, 15, 3, rl.Black)
break
}
/* Tab Bar */
rl.DrawLine(0, int32(rl.GetScreenHeight()-20), int32(rl.GetScreenWidth()), int32(rl.GetScreenHeight()-20), rl.LightGray)
tbX := float32(0)
for i, tab := range tabs {
if i == currTab {
rl.DrawRectangleRounded(rl.Rectangle{tbX + 5, float32(rl.GetScreenHeight() - 18), 20, 16}, 1, 12, rl.Red)
} else {
rl.DrawRectangleRounded(rl.Rectangle{tbX + 5, float32(rl.GetScreenHeight() - 18), 20, 16}, 1, 12, rl.Maroon)
}
rl.DrawTextEx(font, fmt.Sprintf("^%d", i+1), rl.Vector2{tbX + 6, float32(rl.GetScreenHeight() - 16)}, 14, 3, rl.Black)
rl.DrawTextEx(font, tab, rl.Vector2{tbX + 30, float32(rl.GetScreenHeight() - 16)}, 14, 3, rl.Black)
tbX += rl.MeasureTextEx(font, tab, 14, 3).X + 32
}
rl.EndDrawing()
}
}