Ejemplo n.º 1
0
    // Coerce the name to prevent validation errors
    public void UpdateName()
    {
        int    column = nameBox.CursorGetColumn();
        string name   = nameBox.GetText();

        string[] forebidden = new string[] {
            " ", "\\", "/", "?", "@", "#", "$", "%", "^", "&", "*", "(", ")",
            "-", "=", "+", "{", "}", "\'", "\"", "~", "`", "!", "|", "[", "]"
        };

        for (int i = 0; i < forebidden.Length; i++)
        {
            name = name.Replace(forebidden[i], "_");
        }

        if (name.Length > MaxNameLength)
        {
            name = name.Substring(0, MaxNameLength);
        }

        nameBox.SetText(name);
        nameBox.CursorSetColumn(column);
        config.fileName = name + ".adventure";

        if (SettingsDb.SaveExists(config.fileName))
        {
            nameLabel.SetText(NameLabelWarning);
        }
        else
        {
            nameLabel.SetText(NameLabelText);
        }
    }