Пример #1
0
        /// <summary>
        /// Edit and update a Limit Modifier.
        /// </summary>
        protected async ValueTask UpdateLimitModifier()
        {
            if (treLimit.SelectedNode.Level <= 0)
            {
                return;
            }
            TreeNode objSelectedNode = treLimit.SelectedNode;
            string   strGuid         = (objSelectedNode?.Tag as IHasInternalId)?.InternalId ?? string.Empty;

            if (string.IsNullOrEmpty(strGuid) || strGuid.IsEmptyGuid())
            {
                return;
            }
            LimitModifier objLimitModifier = _objCharacter.LimitModifiers.FindById(strGuid);

            //If the LimitModifier couldn't be found (Ie it comes from an Improvement or the user hasn't properly selected a treenode, fail out early.
            if (objLimitModifier == null)
            {
                Program.ShowMessageBox(await LanguageManager.GetStringAsync("Warning_NoLimitFound"));
                return;
            }

            using (SelectLimitModifier frmPickLimitModifier = new SelectLimitModifier(objLimitModifier, "Physical", "Mental", "Social"))
            {
                await frmPickLimitModifier.ShowDialogSafeAsync(this);

                if (frmPickLimitModifier.DialogResult == DialogResult.Cancel)
                {
                    return;
                }

                //Remove the old LimitModifier to ensure we don't double up.
                _objCharacter.LimitModifiers.Remove(objLimitModifier);
                // Create the new limit modifier.
                objLimitModifier = new LimitModifier(_objCharacter, strGuid);
                objLimitModifier.Create(frmPickLimitModifier.SelectedName, frmPickLimitModifier.SelectedBonus, frmPickLimitModifier.SelectedLimitType, frmPickLimitModifier.SelectedCondition, true);

                _objCharacter.LimitModifiers.Add(objLimitModifier);
            }

            MakeDirtyWithCharacterUpdate?.Invoke(this, EventArgs.Empty);
        }
Пример #2
0
        private async void cmdAddLimitModifier_Click(object sender, EventArgs e)
        {
            using (SelectLimitModifier frmPickLimitModifier = new SelectLimitModifier(null, "Physical", "Mental", "Social"))
            {
                await frmPickLimitModifier.ShowDialogSafeAsync(this);

                if (frmPickLimitModifier.DialogResult == DialogResult.Cancel)
                {
                    return;
                }

                // Create the new limit modifier.
                LimitModifier objLimitModifier = new LimitModifier(_objCharacter);
                objLimitModifier.Create(frmPickLimitModifier.SelectedName, frmPickLimitModifier.SelectedBonus, frmPickLimitModifier.SelectedLimitType, frmPickLimitModifier.SelectedCondition, true);
                if (objLimitModifier.InternalId.IsEmptyGuid())
                {
                    return;
                }

                _objCharacter.LimitModifiers.Add(objLimitModifier);
            }

            MakeDirtyWithCharacterUpdate?.Invoke(this, EventArgs.Empty);
        }