123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- package main
- import (
- "fmt"
- "red-green/door"
- "time"
- )
- func pctUpdate(pct *int64) func() int64 {
- return func() int64 {
- return *pct
- }
- }
- func main() {
- fmt.Println("Starting testdoor.go")
- d := door.Door{}
- d.Init()
- reset := door.Reset
- bold := door.Color(1, 37, 40)
- bolder := door.ColorText("BLI BOLD YEL ON BLUE")
- d.Write("Welcome to " + bolder + "door32.sys" + reset + door.CRNL + "..." + door.CRNL)
- key := d.WaitKey(door.Inactivity, 0)
- message := fmt.Sprintf("Key %s%d / %x%s"+door.CRNL, bold, key, key, reset)
- d.Write(message)
- b := door.Box{20, 1}
- d.Write(b.Top() + door.CRNL)
- // or %-20s
- message = fmt.Sprintf("%20s", "SHAZAM!")
- d.Write(b.Row(message) + door.CRNL)
- d.Write(b.Middle() + door.CRNL)
- d.Write(b.Row(fmt.Sprintf("%-20s", "Meow?")) + door.CRNL)
- d.Write(b.Bottom() + door.CRNL)
- left := d.TimeLeft()
- message = fmt.Sprintf("You have %0.2f minutes / %0.2f seconds remaining..."+door.CRNL, left.Minutes(), left.Seconds())
- d.Write(message)
- inputColor := door.ColorText("BRI WHI ON BLUE")
- prompt := door.Line{Text: "What is YOUR Name: "}
- prompt.RenderF = door.RenderBlueYellow
- d.Write(prompt.Output() + inputColor)
- // d.Write("What is your name: " + inputColor)
- name := d.Input(25)
- d.Write(door.Reset + door.CRNL)
- bar := door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
- bar2 := door.BarLine{Width: 30, Style: door.PERCENT_SPACE}
- bar2.ColorRange = []door.BarRange{
- {2500, door.ColorText("RED")},
- {5000, door.ColorText("BROWN")},
- {7500, door.ColorText("BOLD YEL")},
- {9500, door.ColorText("GREEN")},
- {10100, door.ColorText("BRI GRE")}}
- bar3 := door.BarLine{Width: 15, Style: door.GRADIENT, Line: door.Line{DefaultColor: door.ColorText("CYAN")}}
- var percentage int64
- bar.UpdateP = pctUpdate(&percentage)
- bar2.UpdateP = pctUpdate(&percentage)
- bar3.UpdateP = pctUpdate(&percentage)
- bar_start := door.Goto(3, 15)
- for f := 0; f <= 100; f++ {
- percentage = int64(f * 100)
- d.Write(bar_start)
- bar.Update()
- d.Write(bar.Output())
- d.Write(" " + door.Reset)
- bar2.Update()
- d.Write(bar2.Output())
- d.Write(door.Reset + " ")
- bar3.Update()
- d.Write(bar3.Output())
- if d.Disconnected {
- break
- }
- time.Sleep(time.Millisecond * 100)
- // d.WaitKey(0, 55000)
- }
- d.Write(door.CRNL)
- message = fmt.Sprintf("Returning %s to the BBS..."+door.CRNL, name)
- d.Write(message)
- d.WaitKey(3, 0)
- left = d.TimeLeft()
- message = fmt.Sprintf("You had %0.2f minutes / %0.2f seconds remaining!"+door.CRNL, left.Minutes(), left.Seconds())
- d.Write(message)
- fmt.Println("Ending testdoor.go")
- }
|