protected sealed override void OnLoad(ConfigNode node)
        {
            try
            {
                title              = ConfigNodeUtil.ParseValue <string>(node, "title", "");
                notes              = ConfigNodeUtil.ParseValue <string>(node, "notes", "");
                hideChildren       = ConfigNodeUtil.ParseValue <bool?>(node, "hideChildren", (bool?)false).Value;
                completeInSequence = ConfigNodeUtil.ParseValue <bool?>(node, "completeInSequence", (bool?)false).Value;
                OnParameterLoad(node);

                if (hideChildren)
                {
                    foreach (ContractParameter p in this.GetChildren())
                    {
                        ContractConfiguratorParameter ccParam = p as ContractConfiguratorParameter;
                        if (ccParam != null)
                        {
                            ccParam.Hide();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string contractName = "unknown";
                try
                {
                    contractName = ConfigNodeUtil.ParseValue <string>(node, "ContractIdentifier");
                }
                catch { }
                LoggingUtil.LogException(e);
                ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_LOAD, e, contractName, ID);
            }
        }
Esempio n. 2
0
        protected override string GetTitle()
        {
            if (hidden)
            {
                return("");
            }

            if (Parent != null)
            {
                ContractConfiguratorParameter ccpParent = Parent as ContractConfiguratorParameter;
                if (ccpParent != null && ccpParent.hideChildren)
                {
                    return("");
                }
            }

            string output = (optional && !fakeOptional && string.IsNullOrEmpty(title) ? "(Optional) " : "") + GetParameterTitle();

            // Update the contract window title
            titleTracker.Add(output);
            if (lastTitle != output && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
            {
                titleTracker.UpdateContractWindow(output);
                lastTitle = output;
            }

            return(output);
        }
Esempio n. 3
0
        public new bool AnyChildParametersFailed()
        {
            for (int i = ParameterCount; i-- > 0;)
            {
                ContractParameter             param   = GetParameter(i);
                ContractConfiguratorParameter ccParam = param as ContractConfiguratorParameter;
                if (param.State == ParameterState.Failed && (ccParam == null || !ccParam.fakeFailures))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        void SetupChildParameters()
        {
            if (!hiddenParameters.Any())
            {
                return;
            }

            bool foundIncomplete = false;

            foreach (ContractParameter child in this.GetChildren())
            {
                ContractConfiguratorParameter param = child as ContractConfiguratorParameter;
                if (param != null)
                {
                    // Need to potentially hide
                    if (foundIncomplete)
                    {
                        if (hiddenParameters.Contains(param.ID) && !param.hidden)
                        {
                            param.hidden = true;
                            ContractConfigurator.OnParameterChange.Fire(Root, param);
                        }
                    }
                    // Need to potentially unhide
                    else
                    {
                        if (hiddenParameters.Contains(param.ID) && param.hidden)
                        {
                            param.hidden = false;
                            ContractConfigurator.OnParameterChange.Fire(Root, param);
                        }
                    }
                }

                // Check on the state
                if (child.State != ParameterState.Complete)
                {
                    foundIncomplete = true;
                }
            }
        }
        protected override string GetTitle()
        {
            string output = "";

            try
            {
                if (hidden)
                {
                    return("");
                }

                if (Parent != null)
                {
                    ContractConfiguratorParameter ccpParent = Parent as ContractConfiguratorParameter;
                    if (ccpParent != null && ccpParent.hideChildren)
                    {
                        return("");
                    }
                }

                // (Optional)
                output = (optional && !fakeOptional && string.IsNullOrEmpty(title) ?
                          StringBuilderCache.Format("{0} {1}", Localizer.GetStringByTag("#cc.param.optionalTag"), GetParameterTitle()) :
                          GetParameterTitle());

                // Update the contract window title
                titleTracker.Add(output);
                if (lastTitle != output && Root != null && (Root.ContractState == Contract.State.Active || Root.ContractState == Contract.State.Failed))
                {
                    titleTracker.UpdateContractWindow(output);
                    lastTitle = output;
                }
            }
            catch (Exception e)
            {
                // Don't let exceptions mess us up
                LoggingUtil.LogException(new ContractConfiguratorException(this, e));
            }

            return(output);
        }