Пример #1
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            if (!Visible)
            {
                return;
            }

            renderingContext.PushTransform(Transform);

            switch (Character)
            {
            case Shape s:
                var geometry = Context.GetGeometry(s.Geometry, Character);
                if (RenderCallback != null)
                {
                    RenderCallback(renderingContext, geometry, Texture);
                }
                else
                {
                    renderingContext.RenderGeometry(geometry, Texture);
                }

                if (Highlight)
                {
                    renderingContext.RenderOutline(geometry);
                }
                break;

            case Text t:
                renderingContext.RenderText(t, TextValue.Localized);
                break;
            }

            renderingContext.PopTransform();
        }
Пример #2
0
        public AptWindow(Game game, ContentManager contentManager, AptFile aptFile)
        {
            _game          = game;
            ContentManager = contentManager;
            AssetStore     = game.AssetStore;
            AptFile        = aptFile;

            //Create our context
            _context = new AptContext(this);

            //First thing to do here is to initialize the display list
            Root = AddDisposable(new SpriteItem
            {
                Transform          = ItemTransform.None,
                SetBackgroundColor = (c) => _backgroundColor = c
            });
            Root.Create(aptFile.Movie, _context);

            _context.Root = Root;
            _context.Avm.CommandHandler  = HandleCommand;
            _context.Avm.VariableHandler = HandleVariable;
            _context.Avm.MovieHandler    = HandleMovie;

            var m = Root.Character as Movie;

            _movieSize = new Vector2(m.ScreenWidth, m.ScreenHeight);

            _renderingContext = AddDisposable(new AptRenderingContext(this, contentManager, game.GraphicsLoadContext, _context));

            _resolver = new AptCallbackResolver(game);
        }
Пример #3
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            _curTransform = renderingContext.CurrentTransform * Transform;

            var windowScaling = renderingContext.Window.GetScaling();

            _curTransform.GeometryTranslation  *= windowScaling;
            _curTransform.GeometryRotation.M11 *= windowScaling.X;
            _curTransform.GeometryRotation.M22 *= windowScaling.Y;
        }
Пример #4
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            if (!Visible)
            {
                return;
            }

            renderingContext.PushTransform(Transform);

            switch (Character)
            {
            case Shape s:
                var geometry = Context.GetGeometry(s.Geometry, Character);
                if (RenderCallback != null)
                {
                    RenderCallback(renderingContext, geometry, Texture);
                }
                else
                {
                    renderingContext.RenderGeometry(geometry, Texture);
                }

                if (Highlight)
                {
                    renderingContext.RenderOutline(geometry);
                }
                break;

            case Text t:
                if (t.Value.Length > 0)
                {
                    var val = ScriptObject.ResolveValue(t.Value, ScriptObject);
                    if (val.Type != ValueType.Undefined)
                    {
                        t.Content = val.ToString();
                    }
                }

                //localize our content
                t.Content = t.Content.Replace("$", "APT:");     // All string values begin with $
                t.Content = t.Content.Split('&').First();       // Query strings after ampersand
                t.Content = t.Content.Translate();

                renderingContext.RenderText(t);
                break;
            }

            renderingContext.PopTransform();
        }
Пример #5
0
        protected override void RenderImpl(AptRenderingContext renderingContext)
        {
            if (!Visible)
            {
                return;
            }

            //calculate the transform for this element
            renderingContext.PushTransform(Transform);

            var clipMask  = (Texture)null;
            var clipDepth = 0;

            //render all subItems
            foreach (var(depth, item) in Content.Items)
            {
                item.Render(renderingContext);

                if (depth > clipDepth && clipMask != null)
                {
                    renderingContext.SetClipMask(null);
                    clipDepth = 0;
                }

                if (item.ClipDepth != null)
                {
                    renderingContext.SetClipMask(item.ClipMask);
                    clipDepth = item.ClipDepth.Value;
                }
            }

            // In case the clipMask wans't cleared inside the loop
            if (clipDepth > 0)
            {
                renderingContext.SetClipMask(null);
            }
            renderingContext.PopTransform();
        }