An XML Serializable class representing the state of a Text.
상속: TextSaveBase
예제 #1
0
 public static TextSave ReadTextSave(ContentReader input)
 {
     FlatRedBall.Content.Saves.TextSave newObject = new FlatRedBall.Content.Saves.TextSave();
     if (input.ReadBoolean())
     {
         newObject.mFontTextureInstance = input.ReadExternalReference <Microsoft.Xna.Framework.Graphics.Texture2D>();
     }
     newObject.FontPatternText = input.ReadString();
     newObject.X                   = input.ReadSingle();
     newObject.Y                   = input.ReadSingle();
     newObject.Z                   = input.ReadSingle();
     newObject.RotationX           = input.ReadSingle();
     newObject.RotationY           = input.ReadSingle();
     newObject.RotationZ           = input.ReadSingle();
     newObject.DisplayText         = input.ReadString();
     newObject.Name                = input.ReadString();
     newObject.Parent              = input.ReadString();
     newObject.Scale               = input.ReadSingle();
     newObject.Spacing             = input.ReadSingle();
     newObject.NewLineDistance     = input.ReadSingle();
     newObject.MaxWidth            = input.ReadSingle();
     newObject.MaxWidthBehavior    = (FlatRedBall.Graphics.MaxWidthBehavior)Enum.ToObject(typeof(FlatRedBall.Graphics.MaxWidthBehavior), (int)input.ReadInt32());
     newObject.VerticalAlignment   = (FlatRedBall.Graphics.VerticalAlignment)Enum.ToObject(typeof(FlatRedBall.Graphics.VerticalAlignment), (int)input.ReadInt32());
     newObject.HorizontalAlignment = (FlatRedBall.Graphics.HorizontalAlignment)Enum.ToObject(typeof(FlatRedBall.Graphics.HorizontalAlignment), (int)input.ReadInt32());
     newObject.Visible             = input.ReadBoolean();
     newObject.CursorSelectable    = input.ReadBoolean();
     newObject.FontTexture         = input.ReadString();
     newObject.FontFile            = input.ReadString();
     newObject.Red                 = input.ReadSingle();
     newObject.Green               = input.ReadSingle();
     newObject.Blue                = input.ReadSingle();
     newObject.ColorOperation      = input.ReadString();
     newObject.RelativeX           = input.ReadSingle();
     newObject.RelativeY           = input.ReadSingle();
     newObject.RelativeZ           = input.ReadSingle();
     newObject.RelativeRotationX   = input.ReadSingle();
     newObject.RelativeRotationY   = input.ReadSingle();
     newObject.RelativeRotationZ   = input.ReadSingle();
     return(newObject);
 }
예제 #2
0
        public static TextSave FromText(Text text)
        {
            TextSave textSave = new TextSave();

            textSave.X = text.Position.X;
            textSave.Y = text.Position.Y;
            textSave.Z = text.Position.Z;

            textSave.RotationX = text.RotationX;
            textSave.RotationY = text.RotationY;
            textSave.RotationZ = text.RotationZ;

            textSave.RelativeX = text.RelativePosition.X;
            textSave.RelativeY = text.RelativePosition.Y;
            textSave.RelativeZ = text.RelativePosition.Z;

            textSave.RelativeRotationX = text.RelativeRotationX;
            textSave.RelativeRotationY = text.RelativeRotationY;
            textSave.RelativeRotationZ = text.RelativeRotationZ;

            textSave.DisplayText = text.DisplayText;
            textSave.Name        = text.Name;

            textSave.MaxWidth         = text.MaxWidth;
            textSave.MaxWidthBehavior = text.MaxWidthBehavior;

            textSave.Scale           = text.Scale;
            textSave.Spacing         = text.Spacing;
            textSave.NewLineDistance = text.NewLineDistance;

            textSave.VerticalAlignment   = text.VerticalAlignment;
            textSave.HorizontalAlignment = text.HorizontalAlignment;

            textSave.Visible = text.Visible;

            textSave.CursorSelectable = text.CursorSelectable;

            if (text.Parent != null)
            {
                textSave.Parent = text.Parent.Name;
            }

            if (text.Font != null && text.Font != TextManager.DefaultFont)
            {
                textSave.FontFile = text.Font.mFontFile;

                if (text.Font.mTextures.Length == 1)
                {
                    textSave.FontTexture = text.Font.Texture.Name;
                }
                else
                {
                    textSave.FontTexture = "";
                }
            }

#if FRB_MDX
            //spriteSave.Fade = 255 - spriteToCreateSaveFrom.Alpha;
            //spriteSave.FadeRate = -spriteToCreateSaveFrom.AlphaRate;

            textSave.Red   = text.Red;
            textSave.Green = text.Green;
            textSave.Blue  = text.Blue;



            //spriteSave.TintRedRate = spriteToCreateSaveFrom.RedRate;
            //spriteSave.TintGreenRate = spriteToCreateSaveFrom.GreenRate;
            //spriteSave.TintBlueRate = spriteToCreateSaveFrom.BlueRate;

            textSave.ColorOperation =
                GraphicalEnumerations.TranslateColorOperation(text.ColorOperation);
#elif FRB_XNA
            //spriteSave.Fade = (1 - spriteToCreateSaveFrom.Alpha) * 255.0f;
            //spriteSave.FadeRate = -spriteToCreateSaveFrom.AlphaRate * 255.0f;

            textSave.Red   = text.Red * 255.0f;
            textSave.Green = text.Green * 255.0f;
            textSave.Blue  = text.Blue * 255.0f;

            //spriteSave.TintRedRate = spriteToCreateSaveFrom.RedRate * 255.0f;
            //spriteSave.TintGreenRate = spriteToCreateSaveFrom.GreenRate * 255.0f;
            //spriteSave.TintBlueRate = spriteToCreateSaveFrom.BlueRate * 255.0f;

            textSave.ColorOperation =
                GraphicalEnumerations.ColorOperationToFlatRedBallMdxString(text.ColorOperation);
#endif



            return(textSave);
        }
예제 #3
0
        public static TextSave FromText(Text text)
        {
            TextSave textSave = new TextSave();
            textSave.X = text.Position.X;
            textSave.Y = text.Position.Y;
            textSave.Z = text.Position.Z;

            textSave.RotationX = text.RotationX;
            textSave.RotationY = text.RotationY;
            textSave.RotationZ = text.RotationZ;

            textSave.RelativeX = text.RelativePosition.X;
            textSave.RelativeY = text.RelativePosition.Y;
            textSave.RelativeZ = text.RelativePosition.Z;

            textSave.RelativeRotationX = text.RelativeRotationX;
            textSave.RelativeRotationY = text.RelativeRotationY;
            textSave.RelativeRotationZ = text.RelativeRotationZ;

            textSave.DisplayText = text.DisplayText;
            textSave.Name = text.Name;

            textSave.MaxWidth = text.MaxWidth;
            textSave.MaxWidthBehavior = text.MaxWidthBehavior;

            textSave.Scale = text.Scale;
            textSave.Spacing = text.Spacing;
            textSave.NewLineDistance = text.NewLineDistance;

            textSave.VerticalAlignment = text.VerticalAlignment;
            textSave.HorizontalAlignment = text.HorizontalAlignment;

            textSave.Visible = text.Visible;

            textSave.CursorSelectable = text.CursorSelectable;

            if (text.Parent != null)
            {
                textSave.Parent = text.Parent.Name;
            }

            if (text.Font != null && text.Font != TextManager.DefaultFont)
            {
                textSave.FontFile = text.Font.mFontFile;

                if (text.Font.mTextures.Length == 1)
                {

                    textSave.FontTexture = text.Font.Texture.Name;
                }
                else
                {
                    textSave.FontTexture = "";
                }
            }

#if FRB_MDX
            //spriteSave.Fade = 255 - spriteToCreateSaveFrom.Alpha;
            //spriteSave.FadeRate = -spriteToCreateSaveFrom.AlphaRate;

            textSave.Red = text.Red;
            textSave.Green = text.Green;
            textSave.Blue = text.Blue;



            //spriteSave.TintRedRate = spriteToCreateSaveFrom.RedRate;
            //spriteSave.TintGreenRate = spriteToCreateSaveFrom.GreenRate;
            //spriteSave.TintBlueRate = spriteToCreateSaveFrom.BlueRate;

            textSave.ColorOperation =
                GraphicalEnumerations.TranslateColorOperation(text.ColorOperation);
#elif FRB_XNA
            //spriteSave.Fade = (1 - spriteToCreateSaveFrom.Alpha) * 255.0f;
            //spriteSave.FadeRate = -spriteToCreateSaveFrom.AlphaRate * 255.0f;

            textSave.Red = text.Red * 255.0f;
            textSave.Green = text.Green * 255.0f;
            textSave.Blue = text.Blue * 255.0f;

            //spriteSave.TintRedRate = spriteToCreateSaveFrom.RedRate * 255.0f;
            //spriteSave.TintGreenRate = spriteToCreateSaveFrom.GreenRate * 255.0f;
            //spriteSave.TintBlueRate = spriteToCreateSaveFrom.BlueRate * 255.0f;

            textSave.ColorOperation =
                GraphicalEnumerations.ColorOperationToFlatRedBallMdxString(text.ColorOperation);
            
#endif



            return textSave;
        }