private void btnAdd_Click(object sender, EventArgs e)
 {
     CustomAction entry = new CustomAction();
     entry.TriggerData = txtTriggerData.Text;
     entry.Trigger = (CustomAction.ActionTriggerType)cbTriggers.SelectedIndex;
     int value = 0;
     Int32.TryParse(txtPercent.Text, out value);
     entry.Chance = value;
     CustomAction.Action action = new CustomAction.Action();
     action.ActionData = txtActionData.Text;
     action.Type = (CustomAction.ActionType)cbActions.SelectedIndex;
     entry.Actions.Add(action);
     lstCustomActions.Items.Add(entry);
 }
Example #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(WhenString(Trigger));
            if (CustomAction.UsesTriggerData(Trigger))
            {
                sb.Append(" " + TriggerData);
            }
            sb.Append(", ");
            foreach (Action action in Actions)
            {
                sb.Append(ActionString(action.Type));
                if (CustomAction.UsesActionData(action.Type))
                {
                    sb.Append(" " + action.ActionData);
                }
                sb.Append(". ");
            }
            sb.Append("(" + this.Chance.ToString() + "%)");
            return(sb.ToString());
        }