|
@@ -8,6 +8,8 @@ import (
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/mitchellh/go-wordwrap"
|
|
|
)
|
|
|
|
|
|
func pctUpdate(pct *int64) func() int64 {
|
|
@@ -62,12 +64,15 @@ func about_test_door(d *door.Door) {
|
|
|
"This door was written by Bugz.",
|
|
|
"",
|
|
|
"It is written in Go, understands CP437 and unicode, adapts",
|
|
|
- "to screen sizes, uses door32.sys, supports TheDraw Fonts,",
|
|
|
- "has NoMoreSecrets effect, and runs on Linux and Windows."} {
|
|
|
+ "to screen sizes, uses door32.sys, supports TheDraw Fonts",
|
|
|
+ "(the fonts are compiled into the door), has NoMoreSecrets",
|
|
|
+ "effect, and runs on Linux and Windows."} {
|
|
|
about.Lines = append(about.Lines, door.Line{Text: fmt.Sprintf("%*s", -W, text)})
|
|
|
}
|
|
|
|
|
|
var better door.NoMoreSecretsConfig = door.NoMoreSecretsDefault
|
|
|
+ better.Jumble_Loop_Speed = 75 // 35
|
|
|
+ better.Reveal_Loop_Speed = 100 // 50
|
|
|
better.Color = door.ColorText("BRI CYAN ON BLUE")
|
|
|
|
|
|
door.NoMoreSecrets(about.Output(), d, &better)
|
|
@@ -76,7 +81,7 @@ func about_test_door(d *door.Door) {
|
|
|
func MainMenu() door.Menu {
|
|
|
// Make the main menu
|
|
|
var m door.Menu = door.Menu{Panel: door.Panel{Width: 45,
|
|
|
- X: 5,
|
|
|
+ X: 2,
|
|
|
Y: 5,
|
|
|
Style: door.DOUBLE,
|
|
|
Title: "[ Main Menu: ]",
|
|
@@ -92,7 +97,7 @@ func MainMenu() door.Menu {
|
|
|
door.ColorText("BOLD CYAN ON BLUE"))
|
|
|
|
|
|
m.AddSelection("A", "ANSI Display")
|
|
|
- m.AddSelection("C", "Crash")
|
|
|
+ // m.AddSelection("C", "Crash")
|
|
|
m.AddSelection("D", "Display Information (dropfile, screen)")
|
|
|
m.AddSelection("F", "Font Demo")
|
|
|
m.AddSelection("I", "Input Prompt Demo")
|
|
@@ -103,6 +108,60 @@ func MainMenu() door.Menu {
|
|
|
m.AddSelection("W", "Screen Width")
|
|
|
|
|
|
m.AddSelection("Q", "Quit")
|
|
|
+
|
|
|
+ var descriptions []string = []string{
|
|
|
+ // 12345678901234567890123456789012345678901234567890
|
|
|
+ "Display an ANSI file. It is compiled into the door itself.",
|
|
|
+ // "Crash go, see a handled error.", // The error shows up in the logs.
|
|
|
+ "Display dropfile information.",
|
|
|
+ "Display TheDraw Fonts. Font information is compiled into the door.",
|
|
|
+ "Input some values, while updating the time.",
|
|
|
+ "Isn't this is a menu?",
|
|
|
+ "Display various progress bar styles. Half step, display percentage, and gradient.",
|
|
|
+ "Show multiple panels.",
|
|
|
+ "Show more information about the door, using NoMoreSecrets effect.",
|
|
|
+ "Examples using the full width of the screen.",
|
|
|
+ "Exit this door.",
|
|
|
+ }
|
|
|
+
|
|
|
+ var widthLeft int = door.Width - (m.Width + m.X + 2)
|
|
|
+ var panelWidth int = widthLeft - (2 + 2)
|
|
|
+ var maxLines int = 1
|
|
|
+ var maxLineLength int
|
|
|
+ // Calculate the max lines needed for each line.
|
|
|
+ for _, line := range descriptions {
|
|
|
+ var wrapped string = wordwrap.WrapString(line, uint(panelWidth))
|
|
|
+ var lines int = len(strings.Split(wrapped, "\n"))
|
|
|
+ if lines > maxLines {
|
|
|
+ maxLines = lines
|
|
|
+ }
|
|
|
+ if len(line) > maxLineLength {
|
|
|
+ maxLineLength = len(line)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if maxLines == 1 {
|
|
|
+ // Ok! Everything fits into one line, SO use max line length as width of panel.
|
|
|
+ panelWidth = maxLineLength
|
|
|
+ }
|
|
|
+ var p door.Panel = door.Panel{X: m.Width + m.X + 2 + 1, Y: m.Y, Width: panelWidth, Style: door.SINGLE, BorderColor: door.ColorText("WHI ON BLU")}
|
|
|
+ for x := 0; x < maxLines; x++ {
|
|
|
+ p.Lines = append(p.Lines, door.Line{Text: ""})
|
|
|
+ }
|
|
|
+
|
|
|
+ // Target: 5, 20
|
|
|
+ m.Activated = func(item int, d *door.Door) {
|
|
|
+ var line string = descriptions[item]
|
|
|
+ var lines []string = strings.Split(wordwrap.WrapString(line, uint(panelWidth)), "\n")
|
|
|
+ for idx, _ := range p.Lines {
|
|
|
+ if idx >= len(lines) {
|
|
|
+ p.Lines[idx].Text = strings.Repeat(" ", panelWidth)
|
|
|
+ } else {
|
|
|
+ p.Lines[idx].Text = fmt.Sprintf("%-*s", panelWidth, lines[idx])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ d.Write(door.SavePos + p.Output() + door.RestorePos)
|
|
|
+ }
|
|
|
return m
|
|
|
}
|
|
|
|
|
@@ -334,7 +393,7 @@ func input_demo(d *door.Door) {
|
|
|
go func() {
|
|
|
for t := range ticker.C {
|
|
|
const tf = "January 2, 2006 03:04:05 PM MST"
|
|
|
- output := door.SavePos + door.Goto(5, 2) + door.ColorText("BRI WHI ON GREEN") + t.Format(tf) + door.RestorePos
|
|
|
+ output := door.SavePos + door.Goto(5, 2) + door.ColorText("BRI WHI ON CYAN") + t.Format(tf) + door.RestorePos
|
|
|
d.Write(output)
|
|
|
}
|
|
|
}()
|
|
@@ -351,7 +410,7 @@ func input_demo(d *door.Door) {
|
|
|
var quest string = d.Input(35)
|
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
prompt.Text = "What is your Favorite CoLoR: "
|
|
|
- d.Write(prompt.Output() + inputColor2)
|
|
|
+ d.Write(prompt.Output() + inputColor)
|
|
|
var color string = d.Input(15)
|
|
|
d.Write(door.Reset + door.CRNL)
|
|
|
ticker.Stop()
|
|
@@ -618,7 +677,7 @@ func main() {
|
|
|
width_demo(&d)
|
|
|
case 'Q':
|
|
|
choice = -1
|
|
|
- case 'C':
|
|
|
+ case 'C': // Disabled
|
|
|
var a, z int
|
|
|
z = 0
|
|
|
a = 10 / z
|