public DialogButton(string text, string keyword = null, string onFrame = null)
{
this.Text = text;
this.OnFrame = onFrame;
if (keyword != null)
this.Keyword = keyword;
else
{
// Take text, prepend @, replace all non-numerics with _ and
// make the string lower case, if no keyword was given.
// Yea... hey, this is 10 times faster than Regex + ToLower!
var sb = new StringBuilder();
sb.Append('@');
foreach (var c in text)
{
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))
sb.Append(c);
else if (c >= 'A' && c <= 'Z')
sb.Append((char)(c + 32));
else
sb.Append('_');
}
this.Keyword = sb.ToString();
}
}