Inheritance: MonoBehaviour
Example #1
0
 // Use this for initialization
 public MenuMovie(SFCamera parent, SFManager sfmgr, SFMovieCreationParams cp) :
     base(sfmgr, cp)
 {
     this.parent = parent;
     SFMgr       = sfmgr;
     this.SetFocus(true);
 }
Example #2
0
    public ScaleformMovie(ScaleformLayer layer, SFCamera cam, SFMovieCreationParams creationParams) :
        base(cam.GetSFManager(), creationParams)
    {
        Layer  = layer;
        Camera = cam;

        SetFocus(true);
    }
    public ScaleformMovie(ScaleformLayer layer, SFCamera cam, SFMovieCreationParams creationParams) :
        base(cam.GetSFManager(), creationParams)
    {
        Layer = layer;
        Camera = cam;

        SetFocus(true);
    }
 protected override void Awake()
 {
     base.Awake();
     scaleformCamera = FindObjectOfType(typeof(SFCamera)) as SFCamera;
     if (scaleformCamera == null)
     {
         Debug.LogError("Scaleform Camera wasn't found! Scaleform layers will not work.");
     }
 }
Example #5
0
    public void Update()
    {
        RenderTexture rtt    = (GetComponent("Camera") as Camera).targetTexture;
        SFCamera      camera = Component.FindObjectOfType(typeof(SFCamera)) as SFCamera;

        if (camera)
        {
            SFManager sfManager = camera.GetSFManager();
            Movie     movie     = sfManager.GetTopMovie();
            if (movie != null)
            {
#if !(UNITY_3_5)
                Debug.Log("GetNativeTexturePtr: " + rtt.GetNativeTexturePtr());
                sfManager.ReplaceTexture(movie.GetID(), "texture1", rtt);
#endif
            }
        }
    }
    private void Update()
    {
        if (movie == null)
        {
            if (scaleformCamera == null)
            {
                return;
            }
            var manager = scaleformCamera.GetSFManager();
            if (manager == null || !manager.IsSFInitialized())
            {
                return;
            }

            SFMovieCreationParams creationParams = SFCamera.CreateMovieCreationParams(FlashMovieFile, MovieDepth, BackgroundColor, OverrideBackgroundColor);
            creationParams.IsInitFirstFrame = InitFirstFrame;
            creationParams.TheScaleModeType = ScaleMode;

            movie = createMovie(creationParams);
        }
    }
Example #7
0
    new public virtual void Update()
    {
        if (!bSucceeded)
        {
            // Try to get the SFManager from the Camera
            SFCamera camera = Component.FindObjectOfType(typeof(SFCamera)) as SFCamera;
            if (camera == null)
            {
                return;
            }

            if (MovieClassName != null)
            {
                // Is this a class?
                Type classType = Type.GetType(MovieClassName);
                // GetType with the type name only will look for the Type in the caller's assembly and then in the System assembly.
                // GetType with the assembly qualified type name will look for the Type in any assembly.

                // Also: GetType() is resolved at runtime and can be used to get the run time type of an object.
                // typeof is resolved at compile time.
                Type movieType = Type.GetType(typeof(Scaleform.GFx.Movie).AssemblyQualifiedName);
                if (classType != null && classType.IsSubclassOf(movieType))
                {
                    if (CreateRenderMovie(camera, classType))
                    {
                        bSucceeded = true;
                    }
                }
                else
                {
                    // If subclass is not specified, just create a default Movie.
                    if (CreateRenderMovie(camera, movieType))
                    {
                        bSucceeded = true;
                    }
                }
            }
        }
    }
Example #8
0
 private void Initialize()
 {
     SFCamera camera = Component.FindObjectOfType(typeof(SFCamera)) as SFCamera;
     if (camera == null) return;
     if (MovieClassName != null)
     {
         Type classType = Type.GetType(MovieClassName);
         Type movieType = Type.GetType(typeof(Scaleform.Movie).AssemblyQualifiedName);
     #if !NETFX_CORE
         if (classType != null && classType.IsSubclassOf(movieType))
     #else
         if (classType != null && classType.GetTypeInfo().IsSubclassOf(movieType))
     #endif
         {
             if (CreateRenderMovie(camera, classType)) isinited = true;
         }
         else
         {
             // If subclass is not specified, just create a default Movie.
             if (CreateRenderMovie(camera, movieType)) isinited = true;
         }
     }
 }
Example #9
0
    public bool CreateRenderMovie(SFCamera camera, Type movieClassType)
    {
#if !(UNITY_4_0 || UNITY_4_1) && UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceVersion[0] == 'D')
        {
            return(false);
        }
#endif
        if (RenderTexture == null)
        {
            Debug.Log("RenderTexture is null, failure to create RenderMovie. Check if you specified all the parameters properly.");
            return(false);
        }
        if (RTTMovie == null || RTTMovie.MovieID == 0)
        {
            if (camera)
            {
                Debug.Log("Creating movie");
                SFMovieCreationParams creationParams = SFCamera.CreateRTTMovieCreationParams(SwfName, OriginX, OriginY, RenderTexture, ClearColor);
                creationParams.TheScaleModeType     = ScaleModeType.SM_ExactFit;
                creationParams.IsInitFirstFrame     = true;
                creationParams.IsAutoManageViewport = false;
                // Has the user specified a movie subclass?
                if (movieClassType != null)
                {
                    SFManager sfMgr = camera.GetSFManager();
                    RTTMovie = Activator.CreateInstance(movieClassType, sfMgr, creationParams) as Movie;
                    if (RTTMovie != null)
                    {
                        RTTMovie.SetRTT(this);
                    }
                    return(true);
                }
            }
        }
        return(false);
    }
Example #10
0
 public bool CreateRenderMovie(SFCamera camera, Type movieClassType)
 {
     #if !(UNITY_4_0 || UNITY_4_1) && UNITY_STANDALONE_WIN
     if (SystemInfo.graphicsDeviceVersion[0] == 'D')
     {
         return false;
     }
     #endif
     if (RenderTexture == null)
     {
         Debug.Log("RenderTexture is null, failure to create RenderMovie. Check if you specified all the parameters properly.");
         return false;
     }
     if (RTTMovie == null || RTTMovie.MovieID == 0)
     {
         if (camera)
         {
             Debug.Log("Creating movie");
             SFMovieCreationParams creationParams = SFCamera.CreateRTTMovieCreationParams(SwfName, OriginX, OriginY, RenderTexture, ClearColor);
             creationParams.TheScaleModeType      = ScaleModeType.SM_ExactFit;
             creationParams.IsInitFirstFrame      = true;
             creationParams.IsAutoManageViewport  = false;
             // Has the user specified a movie subclass?
             if (movieClassType != null)
             {
                 SFManager sfMgr = camera.GetSFManager();
                 RTTMovie = Activator.CreateInstance(movieClassType, sfMgr, creationParams) as Movie;
                 if (RTTMovie != null)
                 {
                     RTTMovie.SetRTT(this);
                 }
                 return true;
             }
         }
     }
     return false;
 }
Example #11
0
 protected override void Awake()
 {
     base.Awake();
     scaleformCamera = FindObjectOfType(typeof(SFCamera)) as SFCamera;
     if (scaleformCamera == null) Debug.LogError("Scaleform Camera wasn't found! Scaleform layers will not work.");
 }
Example #12
0
        //private bool CheckAddressValidity(byte bankNo, uint offset)
        //{
        //    if (offset == 0) return false;

        //    if (!MemoryManager.Instance.HasBank(bankNo))
        //    {
        //        ErrorLog.Add(string.Format("- Warning: Segment 0x{0:X2} was not initialized, cannot access offset 0x{0:X6}!\n", bankNo, offset));
        //        return false;
        //    }
        //    else if (!MemoryManager.Instance.LocateBank(bankNo, offset).IsValid())
        //    {
        //        ErrorLog.Add(string.Format("- Warning: Offset 0x{0:X6} is out of bounds for segment 0x{0:X2}!\n", offset, bankNo));
        //        return false;
        //    }

        //    return true;
        //}

        public void StartReadingLevelDataAt(byte bankNo, uint index)
        {
            //This will need to parse the commands from the level data and pick off the F3DEX
            SFGfx.sv_ClearStructures(false);
            SFGfx.gl_ClearRenderer(true);
            SFGfx.GameObjects.Clear();
            SFGfx.GameObjCount = 0;

            byte limbCount = MemoryManager.Instance.ReadByte(bankNo, index + 3); //This should be the number of limbs

            //First 4 bytes are things I don't know (+ the limb count), next 8 bytes are header pointers, then it starts the data
            index += 0xC;

            List <stuffToAdd> hierarchyTesting = new List <stuffToAdd>();
            stuffToAdd        topStuff         = new stuffToAdd();

            for (int i = 0; i < limbCount; i++)
            {
                if (!CheckAddressValidity(bankNo, index))
                {
                    break;
                }

                SFGfx.GameObject newObj = new SFGfx.GameObject();


                newObj.LvlPos = 0;
                newObj.Z      = (short)MemoryManager.Instance.ReadFloat(bankNo, index + 0x4);
                newObj.Y      = (short)MemoryManager.Instance.ReadFloat(bankNo, index + 0x8);
                newObj.X      = (short)MemoryManager.Instance.ReadFloat(bankNo, index + 0xC);
                newObj.XRot   = (short)((double)MemoryManager.Instance.ReadUShort(bankNo, index + 0x10) / 182.0444444);
                newObj.YRot   = (short)((double)MemoryManager.Instance.ReadUShort(bankNo, index + 0x12) / 182.0444444);
                newObj.ZRot   = (short)((double)MemoryManager.Instance.ReadUShort(bankNo, index + 0x14) / 182.0444444);
                newObj.ID     = 0;
                newObj.Unk    = 0;

                // default dlist offset to 0
                newObj.DListOffset = MemoryManager.Instance.ReadUInt(bankNo, index);

                //// if object id == 0xffff, break out because this marks end of data!
                //if (newObj.ID == 0xFFFF) break;

                //// if object id < 0x190, get offset like this
                //if (newObj.ID < 0x190)
                //{
                //    //NOTE: SET -2 TO DMA 1
                //    newObj.DListOffset = MemoryManager.Instance.ReadUInt((byte)0xFF, (0xC72E4 + ((uint)newObj.ID * 0x24)));
                //}

                // dlist offset sanity checks
                if (((newObj.DListOffset & 3) != 0x0) ||                // dlist offset not 4 byte aligned
                    ((newObj.DListOffset & 0xFF000000) == 0x80000000))  // dlist offset lies in ram
                {
                    newObj.DListOffset = 0x00;
                }


                stuffToAdd newHier = new stuffToAdd();
                newHier.id        = index + 0x04000000;
                newHier.siblingID = MemoryManager.Instance.ReadUInt(bankNo, index + 0x18);
                newHier.childID   = MemoryManager.Instance.ReadUInt(bankNo, index + 0x1C);

                index += 0x20;

                //if (newObj.DListOffset != 0x00)
                //{
                SFGfx.GameObjects.Add(newObj);

                newHier.gameObjectCount = SFGfx.GameObjCount;

                SFGfx.GameObjCount++;
                //}
                //else
                //   newHier.gameObjectCount = -1;

                hierarchyTesting.Add(newHier);
            }

            //Apply hierarchy stuff. For now, assume that there is only 1 at the top which is not a child
            stuffToAdd         topLevel     = hierarchyTesting.SingleOrDefault(x => hierarchyTesting.Count(y => y.childID == x.id || y.siblingID == x.id) == 0);
            Queue <stuffToAdd> nextTopLevel = new Queue <stuffToAdd>();

            while (topLevel.id != 0)
            {
                //Apply transformations each step down
                if (topLevel.childID != 0)
                {
                    SFGfx.GameObject parentObject = SFGfx.GameObjects[topLevel.gameObjectCount];

                    stuffToAdd childNode = hierarchyTesting.SingleOrDefault(x => topLevel.childID == x.id);
                    while (childNode.id != 0)
                    {
                        //Do the adding here
                        SFGfx.GameObject gameObject = SFGfx.GameObjects[childNode.gameObjectCount];

                        gameObject.X    += parentObject.X;
                        gameObject.Y    += parentObject.Y;
                        gameObject.Z    += parentObject.Z;
                        gameObject.XRot += parentObject.XRot;
                        gameObject.YRot += parentObject.YRot;
                        gameObject.ZRot += parentObject.ZRot;

                        SFGfx.GameObjects[childNode.gameObjectCount] = gameObject;

                        if (childNode.siblingID != 0)
                        {
                            childNode = hierarchyTesting.SingleOrDefault(x => childNode.siblingID == x.id);
                        }
                        else
                        {
                            childNode.id = 0;
                        }
                    }
                }

                if (topLevel.siblingID != 0)
                {
                    nextTopLevel.Enqueue(hierarchyTesting.SingleOrDefault(x => topLevel.siblingID == x.id));
                }
                if (topLevel.childID != 0)
                {
                    nextTopLevel.Enqueue(hierarchyTesting.SingleOrDefault(x => topLevel.childID == x.id));
                }

                if (nextTopLevel.Count > 0)
                {
                    topLevel = nextTopLevel.Dequeue();
                }
                else
                {
                    topLevel.id = 0;
                }
            }

            for (int j = hierarchyTesting.Count - 1; j >= 0; j--)
            {
                if (SFGfx.GameObjects[hierarchyTesting[j].gameObjectCount].DListOffset == 0x0)
                {
                    SFGfx.GameObjects.RemoveAt(hierarchyTesting[j].gameObjectCount);
                    SFGfx.GameObjCount--;
                }
            }

            ExecuteDisplayLists();

            SFCamera.Reset();
        }
Example #13
0
    /// <summary>
    /// Create and return a new movie instance with the given swfName.
    /// </summary>
    /// <returns>
    /// An instance of class T.
    /// </returns>
    /// <param name='camera'>
    /// 创建的Swf属于哪个SFCamera
    /// </param>
    /// <param name='swfName'>
    /// A path to the SWF or GFX file relative to the StreamingAssets folder.
    /// </param>
    /// <param name='fromByteStream'>
    /// If true, an attempt will be made to load this file into memory. On some platforms, this is useful when there isn't a real file path.
    /// </param>
    /// <param name='backgroundColor'>
    /// The background clear color for this movie.
    /// </param>
    /// <param name='renderTarget'>
    /// The RenderTarget to use when rendering this movie. A null value just renders to the screen.
    /// </param>
    /// <param name='scaleModeType'>
    /// Override the default ScaleModeType for this movie. Default is SM_ShowAll.
    /// </param>
    /// <typeparam name='T'>
    /// The class type that will be instanced for this movie.
    /// </typeparam>
    public static T CreateSwf <T>(SFCamera camera, string swfName, bool fromByteStream, Color32 backgroundColor, RenderTexture renderTarget = null, ScaleModeType scaleModeType = ScaleModeType.SM_ShowAll, string movieName = null) where T : Movie
    {
        if (camera == null)
        {
            return(default(T));
        }

        int    depth = 1;
        bool   initFirstFrame = false;
        bool   useBackgroundColor = false;
        bool   autoManageViewport = true;
        int    ox = 0, oy = 0, width = 0, height = 0;
        Int32  length        = 0;
        IntPtr unmanagedData = IntPtr.Zero;

        Byte[] swfBytes = null;

        // load the swf either from a byte array or via path
        SFMovieCreationParams creationParams;


        if (renderTarget != null)
        {
            ox     = 0;
            oy     = 0;
            width  = renderTarget.width;
            height = renderTarget.height;

            useBackgroundColor = true;
            autoManageViewport = false;
        }
        else
        {
            SFCamera.GetViewport(ref ox, ref oy, ref width, ref height);
        }


        bool loadSucceeded = false;

        if (fromByteStream)
        {
            swfBytes = LoadFileToMemory(swfName);
            if (swfBytes != null && swfBytes.Length > 0)
            {
                loadSucceeded = true;

                length        = swfBytes.Length;
                unmanagedData = new IntPtr();
                unmanagedData = Marshal.AllocCoTaskMem((int)length);
                Marshal.Copy(swfBytes, 0, unmanagedData, (int)length);
            }
            else
            {
                Debug.Log("Unable to load swf from memory!");
            }
        }
        else
        {
            // no more to do here -- pass it on to the runtime.
            loadSucceeded = true;
        }


        string fullSwfPath = SFManager.GetScaleformContentPath() + swfName;

        creationParams = new SFMovieCreationParams(fullSwfPath, depth, ox, oy, width, height,
                                                   unmanagedData, length, initFirstFrame, renderTarget, backgroundColor, useBackgroundColor, scaleModeType,
                                                   autoManageViewport);


        if (movieName != null)
        {
            creationParams.MovieName = movieName;
        }

        if (loadSucceeded)
        {
            // create and return the instance
            GameObject uigo = new GameObject(Path.GetFileName(creationParams.MovieName));
            uigo.transform.parent = SFGFxMovieManager.Instance.uigroup.transform;
            T instance = uigo.AddComponent <T>();
            instance.Init(SFGFxMovieManager.Instance, camera.GetSFManager(), creationParams);
            //T instance = (T)Activator.CreateInstance(typeof(T), camera, camera.GetSFManager(), creationParams);

            return(instance);
        }
        else
        {
            Debug.Log(String.Format("Unable to load swf named: {0}", swfName));
            return(default(T));
        }
    }