// Create entry about effect.
        // return true if description is correct
        private bool startEffectDescription(string effectDescription, string effectTypeString, string effectName,
                                            Dictionary <string, string> attributes, int position)
        {
            TextEffectParams newParams = new TextEffectParams();

            if (!TextEffectTables.StringToEffectType.ContainsKey(effectTypeString))     //Non-existing type of editing
            {
                return(false);
            }
            newParams.EffectType = TextEffectTables.StringToEffectType[effectTypeString];
            newParams.Range      = new TextRange(position, position);// Пока заполняем так, затем изменим, когда найдётся закрывающий тег
            newParams.Attributes = attributes;

            // Create name for description in order to correctly find closing tag
            string key = effectName.Length == 0 ? effectDescription : "name=" + effectName;

            if (_formingEffects.ContainsKey(key))      // Have two tags with the same name before their closing tags. This leads to ambiguity.
            {
                return(false);
            }
            _formingEffects.Add(key, newParams);
            if (!_openedEffectsPerTypes.ContainsKey(effectTypeString))
            {
                _openedEffectsPerTypes.Add(effectTypeString, new Stack <string>());
            }
            _openedEffectsPerTypes[effectTypeString].Push(key);
            return(true);
        }
Пример #2
0
        // IDialogueEditing
        public void Initialize(TextEffectParams effectParams)
        {
            Assert.IsTrue(effectParams.EffectType == TextEffectType.Animation_Wobble);

            _range = effectParams.Range;
            Dictionary <string, string> attributes = effectParams.Attributes;

            if (attributes.ContainsKey(TextEffectsAttributes.Frequency1Attribute))
            {
                _frequency1 = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.Frequency1Attribute]);
            }
            Assert.IsTrue(_frequency1 >= 0);

            if (attributes.ContainsKey(TextEffectsAttributes.Frequency2Attribute))
            {
                _frequency2 = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.Frequency2Attribute]);
            }
            Assert.IsTrue(_frequency2 >= 0);

            if (attributes.ContainsKey(TextEffectsAttributes.AmplitudeAttribute))
            {
                _amplitude = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.AmplitudeAttribute]);
            }
            Assert.IsTrue(_amplitude >= 0);

            if (attributes.ContainsKey(TextEffectsAttributes.CoverageAttribute))
            {
                Assert.IsTrue(Tools.StringToEnum(attributes[TextEffectsAttributes.CoverageAttribute], ref _coverage));
            }
        }
        // IDialogueEditing
        public void Initialize(TextEffectParams effectParams)
        {
            Assert.IsTrue(effectParams.EffectType == TextEffectType.Animation_SizeTransition);

            _range = effectParams.Range;
            Dictionary <string, string> attributes = effectParams.Attributes;

            if (attributes.ContainsKey(TextEffectsAttributes.SpeedAttribute))
            {
                _speed = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.SpeedAttribute]);
            }
            Assert.IsTrue(_speed >= 0);

            if (attributes.ContainsKey(TextEffectsAttributes.SizeFromAttribute))
            {
                _sizeFrom = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.SizeFromAttribute]);
            }
            Assert.IsTrue(_sizeFrom >= 0);

            if (attributes.ContainsKey(TextEffectsAttributes.SizeToAttribute))
            {
                _sizeTo = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.SizeToAttribute]);
            }
            Assert.IsTrue(_sizeTo >= 0);
        }
        public ITextEffect CreateEffect(TextEffectParams effectParams)
        {
            switch (effectParams.EffectType)
            {
            case TextEffectType.Color_Blink:
                return(new ColorBlinkEffect());

            case TextEffectType.Color_Transition:
                return(new ColorTransitionEffect());

            case TextEffectType.Color_Rainbow:
                return(new ColorRainbowEffect());

            case TextEffectType.Animation_Wave:
                return(new WaveEffect());

            case TextEffectType.Animation_Wobble:
                return(new WobbleEffect());

            case TextEffectType.Animation_Shake:
                return(new ShakeEffect());

            case TextEffectType.Animation_SizeTransition:
                return(new SizeTransitionEffect());

            default:
                Assert.IsTrue(false);
                return(null);
            }
        }
        // Close effect entry: define right border of effect text range
        // return true if description is correct and opened entry was found with it
        private bool finishEffectDescription(string effectDescription, string effectTypeString, string effectName, int position)
        {
            // Find opened entry of effect appropriate to the description
            TextEffectParams closedParams    = null;
            string           closedParamsKey = "";

            if (effectName.Length != 0)
            {
                closedParamsKey = "name=" + effectName;
                if (!_formingEffects.ContainsKey(closedParamsKey))    // Closing tag has name, which does't fit to any opening tag
                {
                    return(false);
                }
                closedParams = _formingEffects[closedParamsKey];
            }
            else if (_formingEffects.ContainsKey(effectDescription))
            {
                closedParamsKey = effectDescription;
                closedParams    = _formingEffects[effectDescription];
            }
            else if (effectTypeString.Length != 0)
            {
                // Указали тип редактирования. Попробуем закрыть последнюю запись с соответствующим типом
                if (_openedEffectsPerTypes.ContainsKey(effectTypeString))
                {
                    while (_openedEffectsPerTypes[effectTypeString].Count > 0)
                    {
                        string formingParamKey = _openedEffectsPerTypes[effectTypeString].Pop();
                        // _formingEffects may not have a key, it's allowed:
                        // entry may be deleted from _formingEffects erlier
                        if (_formingEffects.ContainsKey(formingParamKey))
                        {
                            closedParamsKey = formingParamKey;
                            closedParams    = _formingEffects[formingParamKey];
                        }
                    }
                }
            }

            if (closedParams == null || closedParamsKey.Length == 0)   // Some closing effect tag doesn't have appropriate opening tag. Parser can't define, what to close.
            {
                return(false);
            }

            // Finish entry
            closedParams.Range = new TextRange(closedParams.Range.From, position);
            _foundEffects.Add(closedParams);
            _formingEffects.Remove(closedParamsKey);
            return(true);
        }
Пример #6
0
        // ITextEffect
        public void Initialize(TextEffectParams effectParams)
        {
            Assert.IsTrue(effectParams.EffectType == TextEffectType.Color_Rainbow);

            _range = effectParams.Range;

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.FrequencyAttribute))
            {
                _frequency = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.FrequencyAttribute]);
            }
            Assert.IsTrue(_frequency >= 0);

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.LengthAttribute))
            {
                _length = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.LengthAttribute]);
            }
            Assert.IsTrue(_length >= 0);
        }
        // ITextEffect
        public void Initialize(TextEffectParams effectParams)
        {
            Assert.IsTrue(effectParams.EffectType == TextEffectType.Color_Blink);

            _range = effectParams.Range;

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.FrequencyAttribute))
            {
                _frequency = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.FrequencyAttribute]);
            }
            Assert.IsTrue(_frequency >= 0);

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.ColorFromAttribute))
            {
                _colorFrom = Tools.WebColor(effectParams.Attributes[TextEffectsAttributes.ColorFromAttribute]);
            }

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.ColorToAttribute))
            {
                _colorTo = Tools.WebColor(effectParams.Attributes[TextEffectsAttributes.ColorToAttribute]);
            }
        }
        // ITextEffect
        public void Initialize(TextEffectParams effectParams)
        {
            Assert.IsTrue(effectParams.EffectType == TextEffectType.Color_Transition);

            _range = effectParams.Range;

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.SpeedAttribute))
            {
                _transitionSpeed = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.SpeedAttribute]);
            }
            Assert.IsTrue(_transitionSpeed >= 0);

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.ColorFromAttribute))
            {
                _colorFrom = Tools.WebColor(effectParams.Attributes[TextEffectsAttributes.ColorFromAttribute]);
            }

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.ColorToAttribute))
            {
                _colorTo = Tools.WebColor(effectParams.Attributes[TextEffectsAttributes.ColorToAttribute]);
            }
        }
Пример #9
0
        // IDialogueEditing
        public void Initialize(TextEffectParams effectParams)
        {
            Assert.IsTrue(effectParams.EffectType == TextEffectType.Animation_Wave);

            _range = effectParams.Range;

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.FrequencyAttribute))
            {
                _frequency = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.FrequencyAttribute]);
            }
            Assert.IsTrue(_frequency >= 0);

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.LengthAttribute))
            {
                _length = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.LengthAttribute]);
            }
            Assert.IsTrue(_length >= 0);

            if (effectParams.Attributes.ContainsKey(TextEffectsAttributes.AmplitudeAttribute))
            {
                _amplitude = Tools.StringToFloat(effectParams.Attributes[TextEffectsAttributes.AmplitudeAttribute]);
            }
            Assert.IsTrue(_amplitude >= 0);
        }