Beispiel #1
0
// updateKeys needs to be called on startup and whenever the displayed key
// mappings are changed.
func (xp *xpbar) updateKeys(teleportKey, cloakKey int) {
	if xp.tk != nil && xp.ck != nil {
		if tsym := vu.Keysym(teleportKey); tsym > 0 {
			xp.tk.Model().SetPhrase(string(tsym))
		}
		if csym := vu.Keysym(cloakKey); csym > 0 {
			xp.ck.Model().SetPhrase(string(csym))
		}
	}
}
Beispiel #2
0
Datei: kc.go Projekt: toophy/vu
// Create is the startup asset creation.
func (kc *kctag) Create(eng vu.Eng, s *vu.State) {
	top := eng.Root().NewPov()
	view := top.NewView()
	view.SetUI()
	kc.ui = view.Cam()
	kc.positions = kc.keyPositions()

	// Create the keyboard image.
	kc.kb = top.NewPov().SetScale(900, 255, 0).SetLocation(450, 100+85, 0)
	kc.kb.NewModel("uv").LoadMesh("icon").AddTex("keyboard")

	// Pressed key focus
	kc.focus = top.NewPov().SetScale(50, 50, 0)
	kc.focus.NewModel("uv").LoadMesh("icon").AddTex("particle")

	// Place the key symbols over the keys.
	font := "lucidiaSu18"
	fontColour := "lucidiaSu18Black"
	for code, key := range kc.positions { // map key is key code, map value is key struct
		if char := vu.Keysym(code); char > 0 {
			cx, cy := key.location()
			letter := top.NewPov().SetLocation(cx, cy, 0)
			model := letter.NewModel("uv")
			model.AddTex(fontColour).LoadFont(font).SetPhrase(string(char))
		}
	}

	// Have a lighter default background.
	eng.SetColor(0.45, 0.45, 0.45, 1)
	kc.resize(s.W, s.H)
}
Beispiel #3
0
// label adds a banner to a button or updates the banner if there is
// an existing banner.
func (b *button) label(part vu.Pov, keyCode int) {
	if keysym := vu.Keysym(keyCode); keysym > 0 {
		texture := "lucidiaSu22Black"
		if b.banner == nil {
			b.banner = part.NewPov().SetLocation(float64(b.x), float64(b.y), 0)
			b.banner.NewModel("uv").AddTex(texture).LoadFont("lucidiaSu22")
		}
		if keyCode == 0 {
			keyCode = vu.K_Space
		}
		b.banner.Model().SetPhrase(string(keysym))
	}
}