123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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)
- if false {
- 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.Reset + door.CRNL + "Press a key to continue...")
- d.WaitKey(120, 0)
- m := door.Menu{Panel: door.Panel{Width: 25,
- X: 5,
- Y: 5,
- Style: door.DOUBLE,
- Title: "Please Select:",
- TitleOffset: 3,
- BorderColor: door.ColorText("BRI CYAN ON BLA")}}
- m.SelectedR = door.MakeMenuRender(door.ColorText("BOLD CYAN"),
- door.ColorText("BOLD BLUE"),
- door.ColorText("BOLD CYAN"),
- door.ColorText("BOLD BLUE"))
- m.UnselectedR = door.MakeMenuRender(door.ColorText("BOLD YEL ON BLUE"),
- door.ColorText("BOLD WHI ON BLUE"),
- door.ColorText("BOLD YEL ON BLUE"),
- door.ColorText("BOLD CYAN ON BLUE"))
- m.MenuOptions = []door.MenuOption{{rune('1'), "Play A Game"},
- {rune('A'), "Ask BUGZ for Help"},
- {rune('D'), "Drop to DOS"},
- {rune('Q'), "Quit"}}
- m.Build()
- test := door.Line{Text: "[T] Testing Render...", RenderF: m.SelectedR}
- d.Write(test.Output() + door.Reset + door.CRNL)
- test.RenderF = m.UnselectedR
- d.Write(test.Output() + door.Reset + door.CRNL)
- d.Write(door.Reset + door.CRNL + "Press a key to continue...")
- d.WaitKey(120, 0)
- d.Write(door.Clrscr)
- _ = m.Choose(&d)
- // d.Write(m.Output())
- // d.WaitKey(120, 0)
- d.Write(door.Reset + door.CRNL + 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")
- }
|