package ui

import (
	"fmt"
)

func (d *Driver) Dialogues() []string {
	out := make([]string, len(d.dialogues))

	for i, dialogue := range d.dialogues {
		out[i] = dialogue.Locator
	}

	return out
}

func (d *Driver) IsInDialogue() bool {
	return d.activeDialogue != nil
}

func (d *Driver) ShowDialogue(locator string) error {
	for _, dialogue := range d.dialogues {
		if dialogue.Locator == locator {

			// FIXME: we should unhover and mouseup the non-dialogue elements
			dialogue.Active = true
			d.activeDialogue = dialogue

			return nil
		}
	}
	return fmt.Errorf("Couldn't find dialogue %v", locator)
}

func (d *Driver) HideDialogue() {
	if d.activeDialogue != nil {
		d.activeDialogue.Active = false
	}

	d.activeDialogue = nil
}
