示例#1
0
//NewForm creates and initializes a form.
func NewForm(width int, height int, backgroundColor int) *Form {
	form := new(Form)
	form.Controls = make(map[string]Control)

	form.currentTabIndex = -1
	form.visual = rc.NewRogueConsole(width, height, width, height)
	form.visual.TransparencyColor = backgroundColor

	form.isVisualValid = false
	form.focusNextFlag = false
	form.focusSpecificFlag = false

	return form
}
示例#2
0
func setup() *rc.RogueConsole {
	con := rc.NewRogueConsole(25, 9, 25, 9)

	redArray := rc.FillArrayI(25, 9, console.ChFgRed)
	greenArray := rc.FillArrayI(25, 9, console.ChFgGreen)
	blueArray := rc.FillArrayI(25, 9, console.ChFgBlue)
	yellowArray := rc.FillArrayI(25, 9, console.ChFgYellow)

	bg1 := rc.StringToArray(25, 9,
		"┌───────────────────────┐"+
			"│                       │"+
			"│                       │"+
			"│                       │"+
			"│                       │"+
			"│                       │"+
			"│                       │"+
			"│                       │"+
			"└───────────────────────┘")

	bg2 := rc.StringToArray(25, 9,
		"                         "+
			"                         "+
			"  /─\\                    "+
			"  \\─/                    "+
			"                         "+
			"          1234           "+
			"                         "+
			"                         "+
			"                         ")

	fg1 := rc.StringToArray(25, 9,
		"                         "+
			"                         "+
			"  ab                     "+
			"                         "+
			"                         "+
			"                         "+
			"                         "+
			"                         "+
			"                         ")

	fg2 := rc.StringToArray(25, 9,
		"                         "+
			"                         "+
			"  c                      "+
			"  d                      "+
			"                         "+
			"                         "+
			"                         "+
			"                         "+
			"                         ")

	rc.Replace(&bg1, ' ', rc.TransparancyChar)
	rc.Replace(&bg2, ' ', rc.TransparancyChar)
	rc.Replace(&fg1, ' ', rc.TransparancyChar)
	rc.Replace(&fg2, ' ', rc.TransparancyChar)

	con.AddBackground(bg1, redArray)
	con.AddBackground(bg2, greenArray)
	con.AddForeground(fg1, blueArray)
	con.AddForeground(fg2, yellowArray)

	con.CameraX = 0
	con.CameraY = 0

	return con
}