testdoor.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package main
  2. import (
  3. "fmt"
  4. "red-green/door"
  5. )
  6. func pctUpdate(pct *int64) func() int64 {
  7. return func() int64 {
  8. return *pct
  9. }
  10. }
  11. func main() {
  12. fmt.Println("Starting testdoor.go")
  13. d := door.Door{}
  14. d.Init()
  15. reset := door.Reset
  16. bold := door.Color(1, 37, 40)
  17. bolder := door.ColorText("BLI BOLD YEL ON BLUE")
  18. d.Write("Welcome to " + bolder + "door32.sys" + reset + door.CRNL + "..." + door.CRNL)
  19. key := d.WaitKey(door.Inactivity, 0)
  20. message := fmt.Sprintf("Key %s%d / %x%s"+door.CRNL, bold, key, key, reset)
  21. d.Write(message)
  22. b := door.Box{20, 1}
  23. d.Write(b.Top() + door.CRNL)
  24. // or %-20s
  25. message = fmt.Sprintf("%20s", "SHAZAM!")
  26. d.Write(b.Row(message) + door.CRNL)
  27. d.Write(b.Middle() + door.CRNL)
  28. d.Write(b.Row(fmt.Sprintf("%-20s", "Meow?")) + door.CRNL)
  29. d.Write(b.Bottom() + door.CRNL)
  30. left := d.TimeLeft()
  31. message = fmt.Sprintf("You have %0.2f minutes / %0.2f seconds remaining..."+door.CRNL, left.Minutes(), left.Seconds())
  32. d.Write(message)
  33. inputColor := door.ColorText("BRI WHI ON BLUE")
  34. prompt := door.Line{Text: "What is YOUR Name: "}
  35. prompt.RenderF = door.RenderBlueYellow
  36. d.Write(prompt.Output() + inputColor)
  37. // d.Write("What is your name: " + inputColor)
  38. name := d.Input(25)
  39. d.Write(door.Reset + door.CRNL)
  40. bar := door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
  41. bar2 := door.BarLine{Width: 30, Style: door.PERCENT_SPACE}
  42. bar2.ColorRange = []door.BarRange{
  43. {2500, door.ColorText("RED")},
  44. {5000, door.ColorText("BROWN")},
  45. {7500, door.ColorText("BOLD YEL")},
  46. {9500, door.ColorText("GREEN")},
  47. {10100, door.ColorText("BRI GRE")}}
  48. bar3 := door.BarLine{Width: 15, Style: door.GRADIENT, Line: door.Line{DefaultColor: door.ColorText("CYAN")}}
  49. var percentage int64
  50. bar.UpdateP = pctUpdate(&percentage)
  51. bar2.UpdateP = pctUpdate(&percentage)
  52. bar3.UpdateP = pctUpdate(&percentage)
  53. bar_start := door.Goto(3, 15)
  54. for f := 0; f <= 100; f++ {
  55. percentage = int64(f * 100)
  56. d.Write(bar_start)
  57. bar.Update()
  58. d.Write(bar.Output())
  59. d.Write(" " + door.Reset)
  60. bar2.Update()
  61. d.Write(bar2.Output())
  62. d.Write(door.Reset + " ")
  63. bar3.Update()
  64. d.Write(bar3.Output())
  65. d.WaitKey(0, 55000)
  66. }
  67. d.Write(door.CRNL)
  68. message = fmt.Sprintf("Returning %s to the BBS..."+door.CRNL, name)
  69. d.Write(message)
  70. d.WaitKey(3, 0)
  71. left = d.TimeLeft()
  72. message = fmt.Sprintf("You had %0.2f minutes / %0.2f seconds remaining!"+door.CRNL, left.Minutes(), left.Seconds())
  73. d.Write(message)
  74. fmt.Println("Ending testdoor.go")
  75. }