about.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package main
  2. import (
  3. "bytes"
  4. "fmt"
  5. "red-green/door"
  6. "strings"
  7. "github.com/mitchellh/go-wordwrap"
  8. )
  9. func about_test_door(d *door.Door) {
  10. var W int = 58
  11. // We're colliding with MemStats window.
  12. // (80 - 60) / 2 = 10
  13. var center_x int = (door.Width - W) / 2
  14. // MaxX = 80 - 20 = 60
  15. if MaxX < center_x+W {
  16. // Problem.
  17. center_x = (MaxX - W) / 2
  18. if center_x < 0 {
  19. //Problem #2
  20. W = 48
  21. center_x = (MaxX - W) / 2
  22. }
  23. }
  24. var center_y int = (door.Height - 16) / 2
  25. var about door.Panel = door.Panel{X: center_x,
  26. Y: center_y,
  27. Width: W,
  28. Style: door.SINGLE_DOUBLE,
  29. BorderColor: door.ColorText("BOLD YELLOW ON BLUE"),
  30. }
  31. about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(fmt.Sprintf("%*s", -W, "About This Door"))),
  32. DefaultColor: door.ColorText("BOLD CYAN ON BLUE")})
  33. about.Lines = append(about.Lines, about.Spacer())
  34. about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(fmt.Sprintf("%*s", -W, "Test Door written in go, using go door.")))})
  35. var copyright string = "(C) 2022 Bugz, Red Green Software"
  36. if door.Unicode {
  37. copyright = strings.Replace(copyright, "(C)", "\u00a9", -1)
  38. }
  39. about.Lines = append(about.Lines,
  40. &door.Line{Text: bytes.NewBuffer([]byte(copyright)), Width: W,
  41. DefaultColor: door.ColorText("BOLD WHITE ON BLUE")})
  42. for _, text := range []string{"",
  43. "This door was written by Bugz.",
  44. ""} {
  45. about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(text)), Width: W})
  46. }
  47. var mainText string = "It is written in Go, detects CP437/unicode, detects screen " +
  48. "size, supports door.sys & door32.sys, supports TheDraw Fonts " +
  49. "(the fonts are compiled into the door), has NoMoreSecrets " +
  50. "and SpinRite effects, and runs on Linux " +
  51. "and sometimes even Windows..."
  52. var wrapped string = wordwrap.WrapString(mainText, uint(W))
  53. for _, text := range strings.Split(wrapped, "\n") {
  54. about.Lines = append(about.Lines, &door.Line{Text: bytes.NewBuffer([]byte(text)), Width: W})
  55. }
  56. var better door.NoMoreSecretsConfig = door.NoMoreSecretsDefault
  57. better.Jumble_Loop_Speed = 75 // 35
  58. better.Reveal_Loop_Speed = 100 // 50
  59. better.Color = door.ColorText("BRI CYAN ON BLUE")
  60. door.NoMoreSecrets(about.Output(), d, &better)
  61. }