Esempio n. 1
0
        /// <summary>
        /// creates a FreeTypeFont
        /// </summary>
        /// <param name="attributes"></param>
        private void CreateFreeTypeFont(XMLAttributes attributes)
        {
#if CEGUI_HAS_FREETYPE
            var name           = attributes.GetValueAsString(FontNameAttribute);
            var filename       = attributes.GetValueAsString(FontFilenameAttribute);
            var resource_group = attributes.GetValueAsString(FontResourceGroupAttribute);

            Logger.LogInsane("---- CEGUI font name: " + name);
            Logger.LogInsane("----       Font type: FreeType");
            Logger.LogInsane("----     Source file: " + filename + " in resource group: " +
                             (String.IsNullOrEmpty(resource_group)
                                          ? "(Default)"
                                          : resource_group));
            Logger.LogInsane("---- Real point size: " + attributes.GetValueAsString(FontSizeAttribute, "12"));

            _font = new FreeTypeFont(name,
                                     attributes.GetValueAsFloat(FontSizeAttribute, 12.0f),
                                     attributes.GetValueAsBool(FontAntiAliasedAttribute, true),
                                     filename, resource_group,
                                     PropertyHelper.FromString <AutoScaledMode>(attributes.GetValueAsString(FontAutoScaledAttribute)),
                                     new Sizef(attributes.GetValueAsFloat(FontNativeHorzResAttribute, 640.0f),
                                               attributes.GetValueAsFloat(FontNativeVertResAttribute, 480.0f)),
                                     attributes.GetValueAsFloat(FontLineSpacingAttribute, 0.0f));
#else
            throw new InvalidRequestException("CEGUI was compiled without freetype support.");
#endif
        }
Esempio n. 2
0
        // XML parsing helper functions.
        private void ElementImagesetStart(XMLAttributes attributes)
        {
            // get name of the imageset.
            string name = attributes.GetValueAsString(ImagesetNameAttribute);

            // get name of the imageset.
            s_imagesetType = attributes.GetValueAsString(ImagesetTypeAttribute, ImageTypeAttributeDefault);
            // get texture image filename
            string filename = attributes.GetValueAsString(ImagesetImageFileAttribute);
            // get resource group to use for image file.
            string resource_group = attributes.GetValueAsString(ImagesetResourceGroupAttribute);

            var logger = System.GetSingleton().Logger;

            logger.LogEvent("[ImageManager] Started creation of Imageset from XML specification:");
            logger.LogEvent("[ImageManager] ---- CEGUI Imageset name: " + name);
            logger.LogEvent("[ImageManager] ---- Source texture file: " + filename);
            logger.LogEvent("[ImageManager] ---- Source texture resource group: " +
                            (String.IsNullOrEmpty(resource_group) ? "(Default)" : resource_group));

            ValidateImagesetFileVersion(attributes);

            var renderer = System.GetSingleton().GetRenderer();

            // if the texture already exists,
            if (renderer.IsTextureDefined(name))
            {
                System.GetSingleton().Logger
                .LogEvent("[ImageManager] WARNING: Using existing texture: " + name);
                s_texture = renderer.GetTexture(name);
            }
            else
            {
                // create texture from image
                s_texture = renderer.CreateTexture(name, filename,
                                                   String.IsNullOrEmpty(resource_group)
                                                       ? d_imagesetDefaultResourceGroup
                                                       : resource_group);
            }

            // set native resolution for imageset
            s_nativeResolution = new Sizef(attributes.GetValueAsFloat(ImagesetNativeHorzResAttribute, 640),
                                           attributes.GetValueAsFloat(ImagesetNativeVertResAttribute, 480));

            // set auto-scaling as needed
            s_autoScaled =
                PropertyHelper.FromString <AutoScaledMode>(attributes.GetValueAsString(ImagesetAutoScaledAttribute,
                                                                                       "false"));
        }
Esempio n. 3
0
        private void CreateFntFont(XMLAttributes attributes)
        {
            var name          = attributes.GetValueAsString(FontNameAttribute);
            var filename      = attributes.GetValueAsString(FontFilenameAttribute);
            var resourceGroup = attributes.GetValueAsString(FontResourceGroupAttribute);

            Logger.LogInsane("---- CEGUI font name: " + name);
            Logger.LogInsane("----       Font type: Fnt");
            Logger.LogInsane("----     Source file: " + filename + " in resource group: " + (String.IsNullOrEmpty(resourceGroup) ? "(Default)" : resourceGroup));

            _font = new FntFont(
                name, filename, resourceGroup,
                PropertyHelper.FromString <AutoScaledMode>(attributes.GetValueAsString(FontAutoScaledAttribute)),
                new Sizef(attributes.GetValueAsFloat(FontNativeHorzResAttribute, 640.0f),
                          attributes.GetValueAsFloat(FontNativeVertResAttribute, 480.0f)));
        }
        public AnimationKeyFrameHandler(XMLAttributes attributes, Affector affector)
        {
            //throw new NotImplementedException();
            var progressionStr = attributes.GetValueAsString(ProgressionAttribute);

            var logEvent = new StringBuilder("\t\tAdding KeyFrame at position: " +
                                             attributes.GetValueAsString(PositionAttribute) +
                                             "  Value: " +
                                             attributes.GetValueAsString(ValueAttribute));

            if (!string.IsNullOrEmpty(progressionStr))
            {
                logEvent.Append("  Progression: " + attributes.GetValueAsString(ProgressionAttribute, ProgressionLinear));
            }

            Logger.LogInsane(logEvent.ToString());

            KeyFrame.Progression progression;
            if (progressionStr == ProgressionDiscrete)
            {
                progression = KeyFrame.Progression.Discrete;
            }
            else if (progressionStr == ProgressionQuadraticAccelerating)
            {
                progression = KeyFrame.Progression.QuadraticAccelerating;
            }
            else if (progressionStr == ProgressionQuadraticDecelerating)
            {
                progression = KeyFrame.Progression.QuadraticDecelerating;
            }
            else
            {
                progression = KeyFrame.Progression.Linear;
            }

            affector.CreateKeyFrame(
                attributes.GetValueAsFloat(PositionAttribute),
                attributes.GetValueAsString(ValueAttribute),
                progression,
                attributes.GetValueAsString(SourcePropertyAttribute));

            if (affector.GetNumKeyFrames() == 1 && !string.IsNullOrEmpty(progressionStr))
            {
                System.GetSingleton().Logger
                .LogEvent("WARNING: progression type specified for first keyframe in animation will be ignored.");
            }

            d_completed = true;
        }
Esempio n. 5
0
        /// <summary>
        /// handles the opening Mapping XML element.
        /// </summary>
        /// <param name="attributes"></param>
        private void ElementMappingStart(XMLAttributes attributes)
        {
            if (_font == null)
            {
                throw new InvalidRequestException("Attempt to access null object.");
            }

            // double-check font type just in case - report issues as 'soft' errors
            if (_font.GetTypeName() != FontTypePixmap)
            {
                System.GetSingleton().Logger.LogEvent(
                    "Imageset_xmlHandler::elementMappingStart: <Mapping> element is " +
                    "only valid for Pixmap type fonts.", LoggingLevel.Errors);
            }
            else
            {
                ((PixmapFont)_font).DefineMapping(
                    (char)attributes.GetValueAsInteger(MappingCodepointAttribute),
                    attributes.GetValueAsString(MappingImageAttribute),
                    attributes.GetValueAsFloat(MappingHorzAdvanceAttribute, -1.0f));
            }
        }
        public AnimationDefinitionHandler(XMLAttributes attributes, string namePrefix)
        {
            _anim = null;

            var animName = namePrefix + attributes.GetValueAsString(NameAttribute);

            Logger.LogInsane(
                "Defining animation named: " +
                animName +
                "  Duration: " +
                attributes.GetValueAsString(DurationAttribute) +
                "  Replay mode: " +
                attributes.GetValueAsString(ReplayModeAttribute) +
                "  Auto start: " +
                attributes.GetValueAsString(AutoStartAttribute, "false"));

            _anim = AnimationManager.GetSingleton().CreateAnimation(animName);

            _anim.SetDuration(attributes.GetValueAsFloat(DurationAttribute));

            var replayMode = attributes.GetValueAsString(ReplayModeAttribute, ReplayModeLoop);

            if (replayMode == ReplayModeOnce)
            {
                _anim.SetReplayMode(Animation.ReplayMode.Once);
            }
            else if (replayMode == ReplayModeBounce)
            {
                _anim.SetReplayMode(Animation.ReplayMode.Bounce);
            }
            else
            {
                _anim.SetReplayMode(Animation.ReplayMode.Loop);
            }

            _anim.SetAutoStart(attributes.GetValueAsBool(AutoStartAttribute));
        }