/// <summary>
 /// Creates a fully functional expression member.
 /// </summary>
 /// <param name="text">Default text (usually displayed when value is null)</param>
 /// <param name="valueDescription">Value description class</param>
 /// <param name="nameXml">Value's name as it appears in the element's attribute</param>
 /// <param name="mandatory">If this value will not be present, crashes or glitches can happen</param>
 public ExpressionMember(string text, ExpressionMemberValueDescription valueDescription, string nameXml = "", bool mandatory = false)
 {
     Text = text;
     _valueDescription = valueDescription;
     Name      = nameXml;
     Mandatory = mandatory;
 }
 /// <summary>
 /// Creates a fully functional expression member.
 /// </summary>
 /// <param name="text">Default text (usually displayed when value is null)</param>
 /// <param name="valueDescription">Value description class</param>
 /// <param name="nameXml">Value's name as it appears in the element's attribute</param>
 /// <param name="mandatory">If this value will not be present, crashes or glitches can happen</param>
 public ExpressionMember(string text, ExpressionMemberValueDescription valueDescription, string nameXml = "", bool mandatory = false)
 {
     Text = text;
     _valueDescription = valueDescription;
     Name = nameXml;
     Mandatory = mandatory;
 }
        protected ExpressionMemberCheck(string text, ExpressionMemberValueDescription valueDescription, string nameXml = "", bool mandatory = false)
            : base(text, valueDescription, nameXml, mandatory)
        {
            Separators = new List <int>();
            Choices    = new List <string>();

            PossibleExpressions = new Dictionary <string, List <ExpressionMember> >();
        }
        protected ExpressionMemberCheck(string text, ExpressionMemberValueDescription valueDescription, string nameXml = "", bool mandatory = false)
            : base(text, valueDescription, nameXml, mandatory)
        {
            Separators = new List<int>();
            Choices = new List<string>();

            PossibleExpressions = new Dictionary<string, List<ExpressionMember>>();
        }
示例#5
0
        /// <summary>
        /// Adds "
        /// </summary>
        ///
        /// <summary>
        /// Adds "for object [selected by gm or named]"
        /// </summary>
        private void ____Add_Name(List <ExpressionMember> eML, ExpressionMemberValueDescription name = null)
        {
            name = name ?? ExpressionMemberValueDescriptions.NameAll;

            eML.Add(new ExpressionMember("for "));
            eML.Add(new ExpressionMember("object "));
            eML.Add(new ExpressionMemberCheck_Name_GM_Slot(name));
        }
        /// <summary>
        /// Shows a GUI form to edit the container's expression member
        /// </summary>
        public override void ShowEditingDialog(ExpressionMemberContainer container, ExpressionMemberValueDescription description, string defaultValue)
        {
            KeyValuePair <bool, string> result = DialogRHKeys.Show(container.Member.Name, container.GetAttribute("raceKeys"), container.GetAttribute("hullKeys"), DialogRHKeysMode.RaceNamesKeys);

            if (result.Key)
            {
                ValueChosen(container, result.Value);
            }
        }
        /// <summary>
        /// Shows a GUI form to edit the container's expression member
        /// </summary>
        /// <param name="container"></param>
        public override void ShowEditingDialog(ExpressionMemberContainer container, ExpressionMemberValueDescription description, string defaultValue)
        {
            KeyValuePair <bool, string> result = DialogSimple.Show(container.Member.Name, description, container.GetValue(), container.Member.Mandatory, defaultValue, true);

            if (result.Key)
            {
                ValueChosen(container, result.Value);
            }
        }
        /// <summary>
        /// Shows a GUI form to edit the container's expression member
        /// </summary>
        /// <param name="container"></param>
        public override void ShowEditingDialog(ExpressionMemberContainer container, ExpressionMemberValueDescription description, string defaultValue)
        {
            KeyValuePair <bool, string> result = DialogConsoleList.Show(container.Member.Name, container.GetValue());

            if (result.Key)
            {
                ValueChosen(container, result.Value);
            }
        }
示例#9
0
        /// <summary>
        /// Adds "(type) "
        /// </summary>
        private void ____Add_Property_Name_Value(List <ExpressionMember> eML, ExpressionMemberValueDescription name = null, ExpressionMemberValueDescription value = null)
        {
            name  = name ?? ExpressionMemberValueDescriptions.NameAll;
            value = value ?? ExpressionMemberValueDescriptions.ValueF;

            eML.Add(new ExpressionMember("<property>", ExpressionMemberValueDescriptions.Property, "property"));
            eML.Add(new ExpressionMember("of "));
            eML.Add(new ExpressionMember("<>", name, "name", true));
            eML.Add(new ExpressionMember("<>", ExpressionMemberValueDescriptions.Comparator, "comparator"));
            eML.Add(new ExpressionMember("<>", value, "value", true));
        }
        /// <summary>
        /// Represents a single member in an expression, which provides branching via checking a condition.
        /// This check is for name vs gm selection in multiple statements that do something to/with an object.
        /// </summary>
        public ExpressionMemberCheck_Name_GM(ExpressionMemberValueDescription name = null)
            : base("", ExpressionMemberValueDescriptions.Check_Name_GMSelection)
        {
            name = name ?? ExpressionMemberValueDescriptions.Name;

            List<ExpressionMember> eML;

            eML = this.Add("with name"); //Choices[0]
            eML.Add(new ExpressionMember("<>", name	, "name"));

            eML = this.Add("selected by GM"); //Choices[1]
            eML.Add(new ExpressionMember("", ExpressionMemberValueDescriptions.UseGM, "use_gm_selection"));
        }
示例#11
0
        /// <summary>
        /// Represents a single member in an expression, which provides branching via checking a condition.
        /// This check is for name vs gm selection in multiple statements that do something to/with an object.
        /// </summary>
        public ExpressionMemberCheck_Name_GM(ExpressionMemberValueDescription name = null)
            : base("", ExpressionMemberValueDescriptions.Check_Name_GMSelection)
        {
            name = name ?? ExpressionMemberValueDescriptions.Name;

            List <ExpressionMember> eML;

            eML = this.Add("with name"); //Choices[0]
            eML.Add(new ExpressionMember("<>", name, "name"));

            eML = this.Add("selected by GM"); //Choices[1]
            eML.Add(new ExpressionMember("", ExpressionMemberValueDescriptions.UseGM, "use_gm_selection"));
        }
        public ExpressionMemberValueEditor(bool isDisplayed = true, bool isInteractive = true, bool forceRecreateMenu = false)
        {
            ForceRecreateMenu = forceRecreateMenu;
            _isDisplayed      = isDisplayed;
            _isInteractive    = isInteractive;

            XmlValueToDisplay = new Dictionary <string, string>();
            DisplayValueToXml = new Dictionary <string, string>();
            XmlValueToMenu    = new Dictionary <string, string>();
            MenuValueToXml    = new Dictionary <string, string>();
            MenuGroups        = new Dictionary <int, string>();
            MenuItems         = new List <string>();

            PrepareContextMenuStripMethod = (ExpressionMemberContainer i, ExpressionMemberValueEditor j, ExpressionMemberValueEditorActivationMode mode) => null;
            ValueSelectorContextMenuStrip = null;
            LastUser = null;
        }
示例#13
0
        /// <summary>
        /// Adds "with name (name) "
        /// </summary>
        private void ____Add_Name(List <ExpressionMember> eML, bool nameMandatory = false, ExpressionMemberValueDescription name = null)
        {
            name = name ?? ExpressionMemberValueDescriptions.Name;

            eML.Add(new ExpressionMember("with "));
            eML.Add(new ExpressionMember("name "));
            eML.Add(new ExpressionMember("<>", name, "name", nameMandatory));
        }
 /// <summary>
 /// Shows a gui form to edit the container's expression member
 /// </summary>
 /// <param name="container"></param>
 public override void ShowEditingDialog(ExpressionMemberContainer container, ExpressionMemberValueDescription description, string defaultValue)
 {
     KeyValuePair<bool, string> result = DialogConsoleList.Show(container.Member.Name, container.GetValue());
     if (result.Key)
         ValueChosen(container, result.Value);
 }
 /// <summary>
 /// Shows a gui form to edit the container's expression member
 /// </summary>
 /// <param name="container"></param>
 public override void ShowEditingDialog(ExpressionMemberContainer container, ExpressionMemberValueDescription description, string defaultValue)
 {
     KeyValuePair<bool, string> result = DialogSimple.Show(container.Member.Name, description, container.GetValue(), container.Member.Mandatory, defaultValue, true);
     if (result.Key)
         ValueChosen(container, result.Value);
 }
 /// <summary>
 /// Shows a gui form to edit the container's expression member
 /// </summary>
 public override void ShowEditingDialog(ExpressionMemberContainer container, ExpressionMemberValueDescription description, string defaultValue)
 {
     KeyValuePair<bool, string> result = DialogRHKeys.Show(container.Member.Name, container.GetAttribute("raceKeys"), container.GetAttribute("hullKeys"), DialogRHKeysMode.RaceNamesKeys);
     if (result.Key)
         ValueChosen(container, result.Value);
 }
        public ExpressionMemberValueEditor(bool isDisplayed = true, bool isInteractive = true, bool forceRecreateMenu = false)
        {
            ForceRecreateMenu = forceRecreateMenu;
            _isDisplayed = isDisplayed;
            _isInteractive = isInteractive;

            XmlValueToDisplay = new Dictionary<string, string>();
            DisplayValueToXml = new Dictionary<string, string>();
            XmlValueToMenu = new Dictionary<string, string>();
            MenuValueToXml = new Dictionary<string, string>();
            MenuGroups = new Dictionary<int, string>();
            MenuItems = new List<string>();

            PrepareContextMenuStripMethod = (ExpressionMemberContainer i, ExpressionMemberValueEditor j, ExpressionMemberValueEditorActivationMode mode) => null;
            ValueSelectorContextMenuStrip = null;
            LastUser = null;
        }
        /// <summary>
        /// Adds "with name (name) "
        /// </summary>
        private void ____Add_Name(List<ExpressionMember> eML, bool nameMandatory = false, ExpressionMemberValueDescription name = null)
        {
            name = name ?? ExpressionMemberValueDescriptions.Name;

            eML.Add(new ExpressionMember("with "));
            eML.Add(new ExpressionMember("name "));
            eML.Add(new ExpressionMember("<>", name, "name", nameMandatory));
        }
        /// <summary>
        /// Adds "for object [selected by gm or named]"
        /// </summary>
        private void ____Add_Name(List<ExpressionMember> eML, ExpressionMemberValueDescription name = null)
        {
            name = name ?? ExpressionMemberValueDescriptions.NameAll;

            eML.Add(new ExpressionMember("for "));
            eML.Add(new ExpressionMember("object "));
            eML.Add(new ExpressionMemberCheck_Name_GM(name));
        }
        /// <summary>
        /// Adds "(type) "
        /// </summary>
        private void ____Add_Property_Name_Value(List<ExpressionMember> eML, ExpressionMemberValueDescription name = null, ExpressionMemberValueDescription value = null)
        {
            name = name ?? ExpressionMemberValueDescriptions.NameAll;
            value = value ?? ExpressionMemberValueDescriptions.ValueF;

            eML.Add(new ExpressionMember("<property>", ExpressionMemberValueDescriptions.Property, "property"));
            eML.Add(new ExpressionMember("of "));
            eML.Add(new ExpressionMember("<>", name, "name", true));
            eML.Add(new ExpressionMember("<>", ExpressionMemberValueDescriptions.Comparator, "comparator"));
            eML.Add(new ExpressionMember("<>", value, "value", true));
        }
        public static KeyValuePair<bool, string> Show(string name, ExpressionMemberValueDescription description, string initialValue, bool mandatory, string defaultValue, bool pathEditor = false)
        {
            using (DialogSimple form = new DialogSimple())
            {
                string caption = "";
                caption += description.Type == ExpressionMemberValueType.VarDouble ? "[float] " : "";
                caption += description.Type == ExpressionMemberValueType.VarString ? "[string] " : "";
                caption += description.Type == ExpressionMemberValueType.Body ? "Element contents" : "";
                caption += description.Type == ExpressionMemberValueType.VarInteger ? "[integer] " : "";
                caption += description.Type == ExpressionMemberValueType.VarBool ? "[boolean] " : "";
                caption += name;
                if (description.Min != null || description.Max != null)
                {
                    if (description.Type == ExpressionMemberValueType.VarBool)
                    {

                    }
                    else if (description.Type == ExpressionMemberValueType.VarString)
                    {

                    }
                    else
                    {
                        caption += " [";
                        caption += description.Min == null ? "-INF" : description.Min.ToString();
                        caption += " ... ";
                        caption += description.Max == null ? "+INF" : description.Max.ToString();
                        caption += "]";
                    }
                }

                if (pathEditor)
                {
                    string info = (string)description.Min;
                    if (info.IndexOf(';') == -1)
                        throw new ArgumentException("description", "Semicolon not found! Min value for PathEditor typed ValueDescription should contain file extensions and header separated by semicolon.");
                    form.OpenFileExtensions = info.Substring(0, info.IndexOf(';'));
                    form.OpenFileHeader = info.Substring(info.IndexOf(';') + 1);
                    form.PathRelativity = (PathRelativityMode)description.Max;
                    form.openFileButton.Visible = true;
                }
                else
                {
                    form.OpenFileExtensions = "";
                    form.OpenFileHeader = "";
                    form.PathRelativity = (PathRelativityMode)0;
                    form.openFileButton.Visible = false;
                }

                form.Text = caption;
                form.Description = description;
                form.input.Text = initialValue;
                form.DefaultValue = defaultValue;
                form.NullMode = initialValue == null;
                form.nullButton.Text = defaultValue == null ? "Null" : "Default";

                if (description.Type == ExpressionMemberValueType.Body)
                {
                    form.Height = 300;
                    form.Width = 900;
                    form.input.Multiline = true;
                }
                form.warningLabel.Width = (pathEditor ? form.openFileButton.Left : form.button1.Left) - form.warningLabel.Left - 2;

                if (form.ShowDialog() == DialogResult.Cancel)
                    return new KeyValuePair<bool, string>(false, null);

                string result = form.NullMode ? defaultValue : form.input.Text;
                //R. Judge: Changes Jan 16, 2013, to band-aid up to 1.7
                if (result != null && description.Type == ExpressionMemberValueType.VarDouble)
                {
                    double resd = 0;

                    if (double.TryParse(result, NumberStyles.Float, NumberFormatInfo.CurrentInfo, out resd))
                    {
                        result = Helper.DoubleToString(resd);
                    }
                }
                if (result != null && description.Type == ExpressionMemberValueType.VarInteger)
                {
                    int resi = 0;
                    if (int.TryParse(result, NumberStyles.Float, NumberFormatInfo.CurrentInfo, out resi))
                    {
                        result = resi.ToString();
                    }
                }
                //R. Judge: End changes Jan 16, 2013.
                return new KeyValuePair<bool, string>(true, result);
            }
        }