Exemple #1
0
        private void AddScriptLines(string[] ScriptData)
        {
            int         i = 0;
            ScriptLevel l = ScriptLevels[ScriptLevelIndex];

            for (var index = 0; index < ScriptData.Length; index++)
            {
                if (i == 0 && ScriptData[index].ToLower().StartsWith("version="))
                {
                    l.ScriptVersion = Convert.ToInt32(ScriptData[index].Remove(0, ("version=").Length));
                    l.CurrentLine  += 1;
                }
                else
                {
                    while (ScriptData[index].StartsWith(" ") | ScriptData[index].StartsWith("\t"))
                    {
                        ScriptData[index] = ScriptData[index].Remove(0, 1);
                    }
                    while (ScriptData[index].EndsWith(" ") | ScriptData[index].EndsWith("\t"))
                    {
                        ScriptData[index] = ScriptData[index].Remove(ScriptData[index].Length - 1, 1);
                    }
                    if (!string.IsNullOrEmpty(ScriptData[index]))
                    {
                        Scripts.Insert(i, new Script(ScriptData[index], ScriptLevelIndex));
                        i += 1;
                    }
                }
            }
        }
Exemple #2
0
        private void PushdownStyleScript()
        {
            if ((type_ != null))
            {
                bool overrodeParentDispStyle = false;
                bool overrodeScriptLevel     = false;
                bool overrodePlus            = false;
                bool overrodeMinus           = false;
                int  plusValue  = 0;
                int  minusValue = 0;

                if (type_.type == ElementType.Math)
                {
                    scriptLevel_ = 0;
                }
                else if (style_ != null)
                {
                    DisplayStyle ownDispStyle       = style_.displayStyle;
                    DisplayStyle parentDisplayStyle = DisplayStyle.AUTOMATIC;

                    if ((parent_ != null) && (parent_.style_ != null))
                    {
                        parentDisplayStyle = parent_.style_.displayStyle;
                    }

                    if ((ownDispStyle != DisplayStyle.AUTOMATIC) && (ownDispStyle != parentDisplayStyle))
                    {
                        if (style_.displayStyle == DisplayStyle.TRUE)
                        {
                            displayStyle            = true;
                            overrodeParentDispStyle = true;
                        }
                        else if (style_.displayStyle == DisplayStyle.FALSE)
                        {
                            displayStyle            = false;
                            overrodeParentDispStyle = true;
                        }
                    }
                    else
                    {
                        displayStyle = parent_.displayStyle;
                    }

                    ScriptLevel ownscriptLevel    = style_.scriptLevel;
                    ScriptLevel parentScriptLevel = ScriptLevel.NONE;

                    if ((parent_ != null) && (parent_.style_ != null))
                    {
                        parentScriptLevel = parent_.style_.scriptLevel;
                    }
                    if ((ownscriptLevel != ScriptLevel.NONE) && (ownscriptLevel != parentScriptLevel))
                    {
                        if (style_.scriptLevel == ScriptLevel.ZERO)
                        {
                            scriptLevel_        = 0;
                            overrodeScriptLevel = true;
                        }
                        else if (style_.scriptLevel == ScriptLevel.ONE)
                        {
                            scriptLevel_        = 1;
                            overrodeScriptLevel = true;
                        }
                        else if (style_.scriptLevel == ScriptLevel.TWO)
                        {
                            scriptLevel_        = 2;
                            overrodeScriptLevel = true;
                        }
                        else if (style_.scriptLevel == ScriptLevel.PLUS_ONE)
                        {
                            overrodePlus = true;
                            minusValue   = 1;
                        }
                        else if (style_.scriptLevel == ScriptLevel.PLUS_TWO)
                        {
                            overrodePlus = true;
                            minusValue   = 2;
                        }
                        else if (style_.scriptLevel == ScriptLevel.MINUS_ONE)
                        {
                            overrodeMinus = true;
                            plusValue     = 1;
                        }
                        else if (style_.scriptLevel == ScriptLevel.MINUS_TWO)
                        {
                            overrodeMinus = true;
                            plusValue     = 2;
                        }
                    }
                    else
                    {
                        scriptLevel_ = parent_.scriptLevel_;
                    }
                }

                if (((type_.type != ElementType.Math) && (parent_ != null)) && (parent_.type_ != null))
                {
                    if (!overrodeParentDispStyle)
                    {
                        displayStyle = parent_.displayStyle;
                    }
                    if (!overrodeScriptLevel)
                    {
                        scriptLevel_ = parent_.scriptLevel_;
                    }

                    if ((((parent_.type_.type == ElementType.Mover) ||
                          (parent_.type_.type == ElementType.Munder)) ||
                         ((parent_.type_.type == ElementType.Munderover) ||
                          (parent_.type_.type == ElementType.Msub))) ||
                        (((parent_.type_.type == ElementType.Msup) ||
                          (parent_.type_.type == ElementType.Mmultiscripts)) ||
                         (parent_.type_.type == ElementType.Msubsup)))
                    {
                        if (childIndex > 0)
                        {
                            if (!overrodeScriptLevel)
                            {
                                scriptLevel_ = parent_.scriptLevel_ + 1;
                            }
                            if (!overrodeParentDispStyle)
                            {
                                displayStyle = false;
                            }
                        }
                    }
                    else if (parent_.type_.type == ElementType.Mroot)
                    {
                        if ((childIndex > 0) && !overrodeScriptLevel)
                        {
                            scriptLevel_ = parent_.scriptLevel_ + 2;
                        }
                    }
                    else if (parent_.type_.type == ElementType.Mfrac)
                    {
                        if (parent_.displayStyle)
                        {
                            if (!overrodeScriptLevel)
                            {
                                scriptLevel_ = parent_.scriptLevel_;
                            }
                        }
                        else if (!overrodeScriptLevel)
                        {
                            scriptLevel_ = parent_.scriptLevel_ + 1;
                        }
                        if (!overrodeParentDispStyle)
                        {
                            displayStyle = false;
                        }
                    }
                }
                if (overrodePlus)
                {
                    scriptLevel_ += plusValue;
                    scriptLevel_  = Math.Min(scriptLevel_, 2);
                }
                if (overrodeMinus)
                {
                    scriptLevel_ -= minusValue;
                    scriptLevel_  = Math.Max(scriptLevel_, 0);
                }
            }

            NodesList list = GetChildrenNodes();

            for (Node child = list.Next(); child != null; child = list.Next())
            {
                child.PushdownStyleScript();
            }

            scriptLevel_ = Math.Min(scriptLevel_, 2);
            scriptLevel_ = Math.Max(scriptLevel_, 0);
        }
        public StylePropertiesDialog(StyleAttributes styleAttributes, Node parentNode)
        {
            this.container      = null;
            this.color          = Color.Black;
            this.background     = Color.White;
            this.isBold         = false;
            this.isItalic       = false;
            this.isFraktur      = false;
            this.isNormal       = false;
            this.isDoubleStruck = false;
            this.isScript       = false;
            this.isMonospace    = false;
            this.isSans         = false;
            this.isBig          = false;
            this.isNormalVar    = false;
            this.isSmall        = false;
            this.success        = false;
            this.hasScriptLevel = false;
            this.InitializeComponent();
            this.Style          = styleAttributes;
            this.color          = this.Style.color;
            this.background     = this.Style.background;
            this.isBold         = this.Style.isBold;
            this.isItalic       = this.Style.isItalic;
            this.isFraktur      = this.Style.isFractur;
            this.isNormal       = this.Style.isNormal;
            this.isDoubleStruck = this.Style.isDoubleStruck;
            this.isMonospace    = this.Style.isMonospace;
            this.isScript       = this.Style.isScript;
            this.isSans         = this.Style.isSans;
            this.sizeEdit.Text  = this.Style.FontSize();
            if (this.Style.scale == 1.25)
            {
                this.isBig = true;
            }
            else if (this.Style.scale == 0.8)
            {
                this.isSmall = true;
            }
            else if (this.Style.scale == 1)
            {
                this.isNormalVar = true;
            }
            DisplayStyle displayStyle = DisplayStyle.AUTOMATIC;
            ScriptLevel  scriptLevel  = ScriptLevel.NONE;

            if ((parentNode != null) && (parentNode.style_ != null))
            {
                displayStyle = parentNode.style_.displayStyle;
                scriptLevel  = parentNode.style_.scriptLevel;
            }
            if ((this.Style.displayStyle == DisplayStyle.TRUE) && (this.Style.displayStyle != displayStyle))
            {
                this.dispStyle.SelectedItem = this.dispStyle.Items[1];
            }
            else if ((this.Style.displayStyle == DisplayStyle.FALSE) && (this.Style.displayStyle != displayStyle))
            {
                this.dispStyle.SelectedItem = this.dispStyle.Items[2];
            }
            else
            {
                this.dispStyle.SelectedItem = this.dispStyle.Items[0];
            }
            try
            {
                this.scriptLevel.SelectedItem = this.scriptLevel.Items[0];
                if ((this.Style.scriptLevel != ScriptLevel.NONE) && (this.Style.scriptLevel != scriptLevel))
                {
                    switch (this.Style.scriptLevel)
                    {
                    case ScriptLevel.ZERO:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[1];
                        break;
                    }

                    case ScriptLevel.ONE:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[2];
                        break;
                    }

                    case ScriptLevel.TWO:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[3];
                        break;
                    }

                    case ScriptLevel.PLUS_ONE:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[4];
                        break;
                    }

                    case ScriptLevel.PLUS_TWO:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[5];
                        break;
                    }

                    case ScriptLevel.MINUS_ONE:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[6];
                        break;
                    }

                    case ScriptLevel.MINUS_TWO:
                    {
                        this.scriptLevel.SelectedItem = this.scriptLevel.Items[7];
                        break;
                    }
                    }
                }
            }
            catch
            {
            }

            this.smallVar.Checked         = this.isSmall;
            this.normalVar.Checked        = this.isNormalVar;
            this.bigVar.Checked           = this.isBig;
            this.foreColorPanel.BackColor = this.color;
            this.backColorPanel.BackColor = this.background;
            this.foreColorPanel.BackColor = this.color;
            this.backColorPanel.BackColor = this.background;
            this.bold.Checked             = this.isBold;
            this.italic.Checked           = this.isItalic;
            this.doubleStruck.Checked     = this.isDoubleStruck;
            this.fraktur.Checked          = this.isFraktur;
            this.monospace.Checked        = this.isMonospace;
            this.sansSerif.Checked        = this.isSans;
            this.script.Checked           = this.isScript;
            this.normal.Checked           = this.isNormal;
            if (((!this.isBold && !this.isItalic) && (!this.isDoubleStruck && !this.isFraktur)) && ((!this.isMonospace && !this.isSans) && (!this.isScript && !this.isNormal)))
            {
                this.notSet.Checked = true;
            }
            this.hasScriptLevel = true;
        }
Exemple #4
0
        public void ChooseIf(GameTime gameTime, bool T)
        {
            ScriptLevel l       = ScriptLevels[ScriptLevelIndex];
            bool        proceed = false;

            while (!proceed)
            {
                if (Scripts.Count == 0)
                {
                    Logger.Log(Logger.LogTypes.Warning, "ActionScript.vb: Illegal \":if\" construct. Terminating execution.");
                    break; // TODO: might not be correct. Was : Exit While
                }
                Script s = Scripts[0];

                switch (s.ScriptType)
                {
                case BaseScript.ScriptTypes.@if:
                    l.IfIndex += 1;
                    if (l.WaitingEndIf[l.IfIndex - 1])
                    {
                        l.WaitingEndIf[l.IfIndex]   = true;
                        l.CanTriggerElse[l.IfIndex] = false;
                    }
                    else
                    {
                        if (T)
                        {
                            proceed = true;
                            l.WaitingEndIf[l.IfIndex]   = false;
                            l.CanTriggerElse[l.IfIndex] = false;
                        }
                        else
                        {
                            l.WaitingEndIf[l.IfIndex]   = true;
                            l.CanTriggerElse[l.IfIndex] = true;
                        }
                    }
                    break;

                case BaseScript.ScriptTypes.@else:
                    if (l.CanTriggerElse[l.IfIndex])
                    {
                        l.WaitingEndIf[l.IfIndex] = false;
                        proceed = true;
                    }
                    else
                    {
                        l.WaitingEndIf[l.IfIndex] = true;
                    }
                    break;

                case BaseScript.ScriptTypes.endif:
                    l.IfIndex -= 1;
                    if (!l.WaitingEndIf[l.IfIndex])
                    {
                        proceed = true;
                    }
                    break;
                }

                this.AddToWhileQuery(Scripts[0]);
                Scripts.RemoveAt(0);
                l.CurrentLine += 1;
            }

            if (Scripts.Count > 0)
            {
                Scripts[0].Update(gameTime);
            }
        }
Exemple #5
0
        public void Switch(object Answer)
        {
            ScriptLevel l       = ScriptLevels[ScriptLevelIndex];
            bool        proceed = false;
            bool        first   = true;

            while (!proceed)
            {
                if (Scripts.Count == 0)
                {
                    Logger.Log(Logger.LogTypes.Warning, "ActionScript.vb: Illegal \":when\" construct. Terminating execution.");
                    break; // TODO: might not be correct. Was : Exit While
                }

                Script s = Scripts[0];

                switch (s.ScriptType)
                {
                case BaseScript.ScriptTypes.@select:
                    if (!first)
                    {
                        l.WhenIndex += 1;
                        l.WaitingEndWhen[l.WhenIndex] = true;
                        l.Switched[l.WhenIndex]       = true;
                    }
                    break;

                case BaseScript.ScriptTypes.Command:
                    if (s.ScriptV2.Value.ToLower().StartsWith("options.show(") == true && first == false)
                    {
                        l.WhenIndex += 1;
                        l.WaitingEndWhen[l.WhenIndex] = true;
                        l.Switched[l.WhenIndex]       = true;
                    }
                    break;

                case BaseScript.ScriptTypes.when:
                    if (l.Switched[l.WhenIndex] == false)
                    {
                        bool     equal = false;
                        string[] args  = Scripts[0].Value.Split(Convert.ToChar(";"));

                        foreach (string arg in args)
                        {
                            if (Script.EvaluateConstruct(arg).Equals(Script.EvaluateConstruct(Answer)))
                            {
                                equal = true;
                                break;     // TODO: might not be correct. Was : Exit For
                            }
                        }

                        if (equal)
                        {
                            l.WaitingEndWhen[l.WhenIndex] = false;
                            proceed = true;
                        }
                        else
                        {
                            l.WaitingEndWhen[l.WhenIndex] = true;
                        }
                    }
                    break;

                case BaseScript.ScriptTypes.endwhen:
                    l.WaitingEndWhen[l.WhenIndex] = false;
                    l.Switched[l.WhenIndex]       = false;
                    l.WhenIndex -= 1;
                    if (!l.WaitingEndWhen[l.WhenIndex])
                    {
                        proceed = true;
                    }
                    break;
                }

                this.AddToWhileQuery(Scripts[0]);
                Scripts.RemoveAt(0);
                l.CurrentLine += 1;
                first          = false;
            }
        }
Exemple #6
0
        /// <summary>
        /// Starts a script
        /// </summary>
        /// <param name="Input">The input string</param>
        /// <param name="InputType">Type of information; 0: Script path, 1: Text, 2: Direct input</param>
        public void StartScript(string Input, int InputType, bool CheckDelay = true, bool ResetInsight = true)
        {
            ScriptLevelIndex += 1;

            TempSpin = false;

            bool[] arr = new bool[100];
            ScriptLevels[ScriptLevelIndex] = new ScriptLevel
            {
                IfIndex        = 0,
                WhenIndex      = 0,
                ScriptVersion  = 1,
                WaitingEndIf   = arr.ToList(),
                WaitingEndWhen = arr.ToList(),
                CurrentLine    = 0,
                ScriptName     = "No script running",
                CanTriggerElse = arr.ToList(),
                Switched       = arr.ToList()
            };

            ScriptLevel l = ScriptLevels[ScriptLevelIndex];

            if (ResetInsight)
            {
                IsInsightScript = false;
            }

            if (reDelay == 0f | !CheckDelay)
            {
                switch (InputType)
                {
                case 0:
                {
                    //Start script from file
                    Logger.Debug("Start script (ID: " + Input + ")");
                    l.ScriptName = "Type: Script; Input: " + Input;

                    var file = GameModeManager.GetScriptFile(Input + ".dat");
                    Security.FileValidation.CheckFileValid(file, false, "ActionScript.vb");


                    // TODO:
                    //if (System.IO.File.Exists(path) == true)
                    //{
                    string Data = file.ReadAllText();

                    Data = Data.Replace(Environment.NewLine, "^");
                    string[] ScriptData = Data.Split(Convert.ToChar("^"));

                    AddScriptLines(ScriptData);
                    //}
                    //else
                    //{
                    //    Logger.Log(Logger.LogTypes.ErrorMessage, "ActionScript.vb: The script file \"" + path + "\" doesn't exist!");
                    //}
                }
                break;

                case 1:
                {
                    //Display text
                    Logger.Debug("Start Script (Text: " + Input + ")");
                    l.ScriptName = "Type: Text; Input: " + Input;

                    string Data = "version=2^@text.show(" + Input + ")^" + ":end";

                    string[] ScriptData = Data.Split(Convert.ToChar("^"));

                    AddScriptLines(ScriptData);
                }
                break;

                case 2:
                {
                    //Start script from direct input
                    string activator = Environment.StackTrace.Split(new [] { Environment.NewLine }, StringSplitOptions.None)[3];
                    activator = activator.Remove(activator.IndexOf("(", StringComparison.Ordinal));

                    Logger.Debug("Start Script (DirectInput; " + activator + ")");
                    l.ScriptName = "Type: Direct; Input: " + Input;

                    string Data = Input.Replace(Environment.NewLine, "^");

                    string[] ScriptData = Data.Split(Convert.ToChar("^"));

                    AddScriptLines(ScriptData);
                }
                break;
                }
            }
        }