123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package door
- // This was the way I did it in door++...
- // Don't
- /*
- type RenderOutput struct {
- Color string
- Pos int
- Len int
- }
- type Render struct {
- Text string
- Outputs []RenderOutput
- }
- */
- type Line struct {
- Text string
- DefaultColor string
- RenderF func(string) string
- UpdateF func() string
- }
- func (l *Line) Update() bool {
- if l.UpdateF == nil {
- return false
- }
- NewText := l.UpdateF()
- if NewText != l.Text {
- l.Text = NewText
- return true
- }
- return false
- }
- func (l *Line) Output(d *Door) {
- if l.RenderF == nil {
- output := l.DefaultColor + l.Text
- d.Write(output)
- } else {
- output := l.RenderF(l.Text)
- d.Write(output)
- }
- }
|