Esempio n. 1
0
        static SwfSymbolData LoadSymbol(
            string swf_path, string symbol_name, SwfLibrary library, List <SwfTagBase> tags)
        {
            var warnings = new HashSet <string>();
            var disp_lst = new SwfDisplayList();
            var executer = new SwfContextExecuter(library, 0, warning_msg => {
                warnings.Add(warning_msg);
            });
            var symbol_frames = new List <SwfFrameData>();

            while (executer.NextFrame(tags, disp_lst))
            {
                _progressBar.UpdateProgress(
                    string.Format("swf symbols loading ({0})", symbol_name),
                    (float)(executer.CurrentTag + 1) / tags.Count);
                symbol_frames.Add(LoadSymbolFrameData(library, disp_lst, warning_msg => {
                    warnings.Add(warning_msg);
                }));
            }
            foreach (var warning in warnings)
            {
                Debug.LogWarningFormat(
                    AssetDatabase.LoadMainAssetAtPath(swf_path),
                    "<b>[FlashTools]</b> {0}\nSwf path: {1}",
                    warning, swf_path);
            }
            return(new SwfSymbolData {
                Name = symbol_name,
                Frames = symbol_frames
            });
        }
        static SwfFrameData LoadSymbolFrameData(
            SwfLibrary library, SwfDisplayList display_list)
        {
            var frame = new SwfFrameData {
                Anchor = display_list.FrameAnchors.Count > 0
                                        ? display_list.FrameAnchors[0]
                                        : string.Empty,
                Labels = new List <string>(display_list.FrameLabels)
            };

            return(AddDisplayListToFrame(
                       library,
                       display_list,
                       Matrix4x4.identity,
                       SwfBlendModeData.identity,
                       SwfColorTransData.identity,
                       0,
                       0,
                       null,
                       frame));
        }
        static SwfSymbolData LoadSymbol(
            string symbol_name, SwfLibrary library, List <SwfTagBase> tags)
        {
            var disp_lst = new SwfDisplayList();
            var executer = new SwfContextExecuter(library, 0, warning_msg => {
                Debug.LogWarningFormat("<b>[FlashTools]</b> {0}", warning_msg);
            });
            var symbol_frames = new List <SwfFrameData>();

            while (executer.NextFrame(tags, disp_lst))
            {
                _progressBar.UpdateProgress(
                    string.Format("swf symbols loading ({0})", symbol_name),
                    (float)(executer.CurrentTag + 1) / tags.Count);
                symbol_frames.Add(LoadSymbolFrameData(library, disp_lst));
            }
            return(new SwfSymbolData {
                Name = symbol_name,
                Frames = symbol_frames
            });
        }
Esempio n. 4
0
        static SwfFrameData AddDisplayListToFrame(
            SwfLibrary library,
            SwfDisplayList display_list,
            Matrix4x4 parent_matrix,
            SwfBlendModeData parent_blend_mode,
            SwfColorTransData parent_color_transform,
            ushort parent_masked,
            ushort parent_mask,
            List <SwfInstanceData> parent_masks,
            SwfFrameData frame,
            System.Action <string> warning_log)
        {
            if (warning_log != null)
            {
                var inst_filter_types = display_list.Instances.Values
                                        .Where(p => p.Visible && p.FilterList.Filters.Count > 0)
                                        .SelectMany(p => p.FilterList.Filters)
                                        .Select(p => p.Type)
                                        .Distinct();
                foreach (var filter_type in inst_filter_types)
                {
                    warning_log(string.Format(
                                    "Unsupported filter type '{0}'",
                                    filter_type));
                }
            }
            var self_masks = new List <SwfInstanceData>();

            foreach (var inst in display_list.Instances.Values.Where(p => p.Visible))
            {
                CheckSelfMasks(self_masks, inst.Depth, frame);
                var child_matrix          = parent_matrix * inst.Matrix.ToUMatrix();
                var child_blend_mode      = parent_blend_mode * inst.BlendMode.ToBlendModeData(warning_log);
                var child_color_transform = parent_color_transform * inst.ColorTransform.ToColorTransData();
                switch (inst.Type)
                {
                case SwfDisplayInstanceType.Shape:
                    AddShapeInstanceToFrame(
                        library,
                        inst as SwfDisplayShapeInstance,
                        child_matrix,
                        child_blend_mode,
                        child_color_transform,
                        parent_masked,
                        parent_mask,
                        parent_masks,
                        self_masks,
                        frame);
                    break;

                case SwfDisplayInstanceType.Bitmap:
                    AddBitmapInstanceToFrame(
                        library,
                        inst as SwfDisplayBitmapInstance,
                        child_matrix,
                        child_blend_mode,
                        child_color_transform,
                        parent_masked,
                        parent_mask,
                        parent_masks,
                        self_masks,
                        frame);
                    break;

                case SwfDisplayInstanceType.Sprite:
                    AddSpriteInstanceToFrame(
                        library,
                        inst as SwfDisplaySpriteInstance,
                        child_matrix,
                        child_blend_mode,
                        child_color_transform,
                        parent_masked,
                        parent_mask,
                        parent_masks,
                        self_masks,
                        frame,
                        warning_log);
                    break;

                default:
                    throw new UnityException(string.Format(
                                                 "unsupported SwfDisplayInstanceType: {0}", inst.Type));
                }
            }
            CheckSelfMasks(self_masks, ushort.MaxValue, frame);
            return(frame);
        }