-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_mode_update.go
68 lines (65 loc) · 1.67 KB
/
edit_mode_update.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
package main
import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
"golang.design/x/clipboard"
)
func (g *Game) EditModeUpdate() {
if editSelected == "" {
if inpututil.IsKeyJustPressed(ebiten.KeyN) {
editSelected = "name"
g.EditText = UInfo.Name
} else if inpututil.IsKeyJustPressed(ebiten.KeyU) {
editSelected = "ld_url"
g.EditText = UInfo.LD_URL
} else if inpututil.IsKeyJustPressed(ebiten.KeyP) {
editSelected = "ld_pass"
g.EditText = UInfo.LD_Pass
}
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
editSelected = ""
g.Mode = "title"
UpdateUserInfo()
LDConnection = "waiting..."
go CheckLDConnection()
return
}
} else {
if inpututil.IsKeyJustPressed(ebiten.KeyEnter) {
switch editSelected {
case "name":
if g.EditText != UInfo.Name {
UInfo.Highscore = 0
}
UInfo.Name = g.EditText
case "ld_url":
UInfo.LD_URL = g.EditText
case "ld_pass":
UInfo.LD_Pass = g.EditText
}
editSelected = ""
g.EditText = ""
g.EditRunes = make([]rune, 0)
}
if inpututil.IsKeyJustPressed(ebiten.KeyEscape) {
editSelected = ""
g.EditText = ""
g.EditRunes = make([]rune, 0)
}
if ebiten.IsKeyPressed(ebiten.KeyControl) && inpututil.IsKeyJustPressed(ebiten.KeyV) && canUseClipboard {
g.EditText += string(clipboard.Read(clipboard.FmtText))
} else {
g.EditRunes = ebiten.AppendInputChars(g.EditRunes[:0])
g.EditText += string(g.EditRunes)
}
if inpututil.IsKeyJustPressed(ebiten.KeyBackspace) {
if len(g.EditText) > 0 {
g.EditText = g.EditText[:len(g.EditText)-1]
}
}
EditTextBlink += 1
if EditTextBlink > 180 {
EditTextBlink = 0
}
}
}