Exemplo n.º 1
0
func setMenus(m mode) {
	menuBarWasPresent := len(menuBar) > 0
	switch m {
	case modeSplash, modeName, modeVanity:
		menuBar = []*menu.Menu{&fileMenu, &displayMenu, &ratingsMenu}
		fileMenu.Items = []menu.ItemInterface{
			beginGameItem,
			trainingItem,
			exitItem,
		}
		exitItem.Flags |= menu.Separator
		ratingsMenu.Items = []menu.ItemInterface{
			highScores,
			cpuSpeed,
		}
	case modeTraining:
		menuBar = []*menu.Menu{&fileMenu, &displayMenu, &invadersMenu, &colorMenu}
		// Make the "Invaders" menu
		list := []menu.ItemInterface{
			menu.MakeCheckItem("peek", false, universe.SetShowAlways),
			menu.MakeRadioItem("stationary", &letFrequonsMove, 0),
			menu.MakeRadioItem("moving", &letFrequonsMove, 1),
			rollPhase,
		}
		for k := 0; k <= 13; k++ {
			list = append(list, menu.MakeRadioItem(fmt.Sprintf("%v", k), &maxFrequon, k))
		}
		for _, k := range []int{0, 3, 4} {
			list[k].GetItem().Flags |= menu.Separator
		}
		invadersMenu.Items = list
		// Make the "Color" menu
		list = make([]menu.ItemInterface, len(colorSchemeInfo))
		for k, info := range colorSchemeInfo {
			list[k] = menu.MakeRadioItem(info.name, &colorSchemeSelect, k)
		}
		colorMenu.Items = list
	case modeGame:
		menuBar = menuBar[:0]
	}
	if (len(menuBar) != 0) != menuBarWasPresent {
		// Menu bar appeared or disappeared, so repartition
		partitionScreen(screenWidth, screenHeight)
	}
}
Exemplo n.º 2
0
	ratingsMenu  = menu.Menu{Label: "Ratings"}
	invadersMenu = menu.Menu{Label: "Invaders"}
	colorMenu    = menu.Menu{Label: "Color"}
)

// Items for "File" menu
var (
	beginGameItem, trainingItem *menu.SimpleItem

	exitItem = menu.MakeSimpleItem("Exit", func() {
		nimble.Quit()
	})
)

// Items for "Display" menu
var autoGain = menu.MakeCheckItem("Autogain", true, nil)

// Items for "Ratings" menu
var (
	highScores *menu.SimpleItem
	cpuSpeed   = menu.MakeSimpleItem("CPU Speed", func() {
		teletype.Reset()
		teletype.PrintUpper(fmt.Sprintf("HFT SPEED = %.1f GFlops\n", fourier.Benchmark()*1E-9))
	})
)

// State of stationary/moving radio buttons on the "Invaders" menu.
var letFrequonsMove = menu.RadioState{OnSelect: func(value int) {
	if value == 0 {
		universe.SetVelocityMax(0)
	} else {