package main import ( "bytes" "fmt" "red-green/door" "strings" "github.com/mitchellh/go-wordwrap" ) func about_test_door(d *door.Door) { var W int = 58 // We're colliding with MemStats window. // (80 - 60) / 2 = 10 var center_x int = (door.Width - W) / 2 // MaxX = 80 - 20 = 60 if MaxX < center_x+W { // Problem. center_x = (MaxX - W) / 2 if center_x < 0 { //Problem #2 W = 48 center_x = (MaxX - W) / 2 } } var center_y int = (door.Height - 16) / 2 var about door.Panel = door.Panel{X: center_x, Y: center_y, Width: W, Style: door.SINGLE_DOUBLE, BorderColor: door.ColorText("BOLD YELLOW ON BLUE"), } about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(fmt.Sprintf("%*s", -W, "About This Door"))), DefaultColor: door.ColorText("BOLD CYAN ON BLUE")}) about.Lines = append(about.Lines, about.Spacer()) about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(fmt.Sprintf("%*s", -W, "Test Door written in go, using go door.")))}) var copyright string = "(C) 2022 Bugz, Red Green Software" if door.Unicode { copyright = strings.Replace(copyright, "(C)", "\u00a9", -1) } about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(copyright)), Width: W, DefaultColor: door.ColorText("BOLD WHITE ON BLUE")}) for _, text := range []string{"", "This door was written by Bugz.", ""} { about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(text)), Width: W}) } var mainText string = "It is written in Go, detects CP437/unicode, detects screen " + "size, supports door.sys & door32.sys, supports TheDraw Fonts " + "(the fonts are compiled into the door), has NoMoreSecrets " + "and SpinRite effects, and runs on Linux " + "and sometimes even Windows..." var wrapped string = wordwrap.WrapString(mainText, uint(W)) for _, text := range strings.Split(wrapped, "\n") { about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(text)), Width: W}) } var better door.NoMoreSecretsConfig = door.NoMoreSecretsDefault better.Jumble_Loop_Speed = 75 // 35 better.Reveal_Loop_Speed = 100 // 50 better.Color = door.ColorText("BRI CYAN ON BLUE") door.NoMoreSecrets(about.Output(), d, &better) }