| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 | 
							- package main
 
- import (
 
- 	"fmt"
 
- 	"red-green/door"
 
- 	"strconv"
 
- 	"strings"
 
- 	"time"
 
- )
 
- func display_information(d *door.Door) {
 
- 	d.Write(door.Clrscr)
 
- 	var headerColor string = door.ColorText("BRI CYAN")
 
- 	var keyColor string = door.ColorText("BRI GREEN")
 
- 	var sepColor string = door.ColorText("BRI YEL")
 
- 	var valColor string = door.ColorText("CYAN")
 
- 	var nice_format func(string, string) string = func(key string, value string) string {
 
- 		return fmt.Sprintf("%s%-20s %s: %s%s", keyColor, key, sepColor, valColor, value) + door.CRNL
 
- 	}
 
- 	var offset string
 
- 	var header string = "DropFile: "
 
- 	offset = strings.Repeat(" ", len(header))
 
- 	d.Write(headerColor + header)
 
- 	d.Write(nice_format("Comm Type", strconv.Itoa(d.Config.Comm_type)))
 
- 	if d.Config.BBSID != "" {
 
- 		d.Write(offset + nice_format("BBS Software", d.Config.BBSID))
 
- 	}
 
- 	d.Write(offset + nice_format("Time Left", strconv.Itoa(d.Config.Time_left)))
 
- 	d.Write(offset + nice_format("Real Name", d.Config.Real_name))
 
- 	// d.Write(nice_format("Comm Handle", strconv.Itoa(d.Config.Comm_handle)))
 
- 	d.Write(offset + nice_format("Handle", d.Config.Handle))
 
- 	d.Write(offset + nice_format("User #", strconv.Itoa(d.Config.User_number)))
 
- 	d.Write(offset + nice_format("Security Level", strconv.Itoa(d.Config.Security_level)))
 
- 	d.Write(offset + nice_format("Node #", strconv.Itoa(d.Config.Node)))
 
- 	header = "Detected: "
 
- 	offset = strings.Repeat(" ", len(header))
 
- 	d.Write(door.CRNL + headerColor + header)
 
- 	d.Write(nice_format("Unicode", strconv.FormatBool(door.Unicode)))
 
- 	d.Write(offset + nice_format("CP437", strconv.FormatBool(door.CP437)))
 
- 	d.Write(offset + nice_format("Full CP437", strconv.FormatBool(door.Full_CP437)))
 
- 	d.Write(offset + nice_format("Screen Size", fmt.Sprintf("%d X %d", door.Width, door.Height)))
 
- 	var time time.Duration = d.TimeLeft()
 
- 	d.Write(offset + nice_format("Door Time Left", fmt.Sprintf("%d Hours, %d Minutes, %d Seconds", int(time.Hours()), int(time.Minutes())%60, int(time.Seconds())%60)))
 
- 	time = d.TimeUsed()
 
- 	d.Write(offset + nice_format("Door Time Used", fmt.Sprintf("%d Minutes, %d Seconds", int(time.Minutes()), int(time.Seconds())%60)))
 
- 	press_a_key(d)
 
- 	d.Write(door.Clrscr + door.CRNL + door.CRNL + door.CRNL)
 
- 	modules := GetModules()
 
- 	header = "Build:    "
 
- 	offset = strings.Repeat(" ", len(header))
 
- 	d.Write(headerColor + header)
 
- 	gover, gitver, goarch, goos := GetVersion()
 
- 	d.Write(nice_format("go version", gover))
 
- 	d.Write(offset + nice_format("git commit", gitver))
 
- 	d.Write(offset + nice_format("Arch", goarch))
 
- 	d.Write(offset + nice_format("OS", goos))
 
- 	for mod, version := range modules {
 
- 		d.Write(offset + nice_format(mod, version))
 
- 	}
 
- }
 
- func display_ansi(d *door.Door) {
 
- 	var art []string = ANSIGrowl()
 
- 	d.Write(door.Clrscr)
 
- 	for _, line := range art {
 
- 		d.Write(line + door.CRNL)
 
- 	}
 
- }
 
- func input_demo(d *door.Door) {
 
- 	var ticker *time.Ticker = time.NewTicker(time.Second)
 
- 	var StopIt = make(chan bool)
 
- 	go func() {
 
- 		for {
 
- 			select {
 
- 			case <-StopIt:
 
- 				return
 
- 			case t := <-ticker.C:
 
- 				const tf = "January 2, 2006 03:04:05 PM MST"
 
- 				output := door.SavePos + door.Goto(5, 2) + door.ColorText("BRI WHI ON CYAN") + t.Format(tf) + door.RestorePos
 
- 				d.Write(output)
 
- 			}
 
- 		}
 
- 	}()
 
- 	var inputColor string = door.ColorText("BRI WHI ON BLUE")
 
- 	var inputColor2 string = door.ColorText("BRI WHI ON GREEN")
 
- 	var prompt door.Line = door.Line{Text: "What is YOUR Name: "}
 
- 	prompt.RenderF = door.RenderBlueYellow
 
- 	d.Write(prompt.Output() + inputColor)
 
- 	var name string = d.Input(25)
 
- 	d.Write(door.Reset + door.CRNL)
 
- 	prompt.Text = "What is Your Quest: "
 
- 	d.Write(prompt.Output() + inputColor2)
 
- 	var quest string = d.Input(35)
 
- 	d.Write(door.Reset + door.CRNL)
 
- 	prompt.Text = "What is your Favorite CoLoR: "
 
- 	d.Write(prompt.Output() + inputColor)
 
- 	var color string = d.Input(15)
 
- 	d.Write(door.Reset + door.CRNL)
 
- 	ticker.Stop()
 
- 	StopIt <- true
 
- 	d.Write(fmt.Sprintf("You're %s on the %s quest, and fond of %s."+door.CRNL, name, quest, color))
 
- }
 
- func pctUpdate(pct *int64) func() int64 {
 
- 	return func() int64 {
 
- 		return *pct
 
- 	}
 
- }
 
- func progress_bars(d *door.Door) {
 
- 	d.Write(door.Clrscr)
 
- 	var barHalf door.BarLine = door.BarLine{Line: door.Line{DefaultColor: door.ColorText("BOLD YELLOW")}, Width: 20, Style: door.HALF_STEP}
 
- 	var barPercent door.BarLine = door.BarLine{Width: 30, Style: door.SOLID, PercentStyle: door.PERCENT_SPACE}
 
- 	barPercent.ColorRange = []door.BarRange{
 
- 		{Percent: 2500, Color: door.ColorText("RED")},
 
- 		{Percent: 5000, Color: door.ColorText("BROWN")},
 
- 		{Percent: 7500, Color: door.ColorText("BOLD YEL")},
 
- 		{Percent: 9500, Color: door.ColorText("GREEN")},
 
- 		{Percent: 10100, Color: door.ColorText("BRI GRE")}}
 
- 	var barGradient door.BarLine = door.BarLine{Width: 15, Style: door.GRADIENT, Line: door.Line{DefaultColor: door.ColorText("CYAN")}}
 
- 	var percentage int64
 
- 	barHalf.UpdateP = pctUpdate(&percentage)
 
- 	barPercent.UpdateP = pctUpdate(&percentage)
 
- 	barGradient.UpdateP = pctUpdate(&percentage)
 
- 	update_bars := func() {
 
- 		barHalf.Update()
 
- 		barPercent.Update()
 
- 		barGradient.Update()
 
- 	}
 
- 	d.Write(door.Goto(3, 12) + "Half-Step")
 
- 	d.Write(door.Goto(25, 12) + "% with space and Color Range")
 
- 	d.Write(door.Goto(57, 12) + "Gradient")
 
- 	d.Write(door.HideCursor)
 
- 	bar_start := door.Goto(3, 15)
 
- 	for f := 0; f <= 100; f++ {
 
- 		d.Write(door.Goto(3, 10) + door.Reset + fmt.Sprintf("Value: %d", f))
 
- 		percentage = int64(f * 100)
 
- 		update_bars()
 
- 		d.Write(bar_start + barHalf.Output() + "  " + door.Reset + barPercent.Output() + door.Reset + "  " + barGradient.Output())
 
- 		if d.Disconnect() {
 
- 			// don't continue to sleep if we're disconnected
 
- 			break
 
- 		}
 
- 		time.Sleep(time.Millisecond * 100)
 
- 	}
 
- 	d.Write(door.ShowCursor)
 
- }
 
- func width_demo(d *door.Door) {
 
- 	var w int = door.Width
 
- 	var panel door.Panel = door.Panel{X: 1, Y: 1, Width: w}
 
- 	var lineColor string = door.ColorText("WHI")
 
- 	var line string
 
- 	for y := 1; y <= door.Height; y++ {
 
- 		if y%10 == 0 {
 
- 			line = strings.Repeat("1234567890", w/10)
 
- 			for x := len(line); x < w; x++ {
 
- 				line += strconv.Itoa((x + 1) % 10)
 
- 			}
 
- 		} else {
 
- 			line = ""
 
- 			for x := 1; x < w; x++ {
 
- 				if x%10 == 0 {
 
- 					line += strconv.Itoa(y % 10)
 
- 				} else {
 
- 					line += " "
 
- 				}
 
- 			}
 
- 		}
 
- 		var l door.Line = door.Line{Text: line, DefaultColor: lineColor}
 
- 		panel.Lines = append(panel.Lines, l)
 
- 	}
 
- 	var message string = fmt.Sprintf("Screen Size: %d X %d", door.Width, door.Height)
 
- 	d.Write(panel.Output())
 
- 	// Output alert on top of panel
 
- 	var cx, cy int
 
- 	cx = (door.Width - len(message) + 2) / 2
 
- 	cy = (door.Height - 3) / 2
 
- 	var alert []string = door.AlertBox(message, 1)
 
- 	d.Write(door.ColorText("BRI YEL ON BLUE"))
 
- 	for idx, ab := range alert {
 
- 		d.Write(door.Goto(cx, cy+idx) + ab)
 
- 	}
 
- 	d.Write(door.Reset + panel.GotoEnd())
 
- 	// Pause for key
 
- 	d.WaitKey(door.Inactivity)
 
- 	panel.Lines = make([]door.Line, 0)
 
- 	var background string = "BUGZ Test Door in GO "
 
- 	var bl int = len(background)
 
- 	for y := 1; y <= door.Height; y++ {
 
- 		offset := (y - 1) % bl
 
- 		line = background[offset:]
 
- 		for len(line) < w {
 
- 			if len(line)+bl <= w {
 
- 				line += background
 
- 			} else {
 
- 				line += background[0 : w-len(line)]
 
- 			}
 
- 		}
 
- 		var l door.Line = door.Line{Text: line, RenderF: door.RenderBlueYellow}
 
- 		panel.Lines = append(panel.Lines, l)
 
- 	}
 
- 	d.Write(panel.Output())
 
- 	d.WaitKey(door.Inactivity)
 
- }
 
 
  |