public override void Create(Character character, AptContext context, SpriteItem parent = null) { _sprite = (Playable)character; _currentFrame = 0; _actionList = new List <Action>(); FrameLabels = new Dictionary <string, uint>(); State = PlayState.PLAYING; Name = ""; Visible = true; Character = _sprite; Context = context; Content = new DisplayList(); Parent = parent; ScriptObject = new ObjectContext(this); // Fill the frameLabels in advance foreach (var frame in _sprite.Frames) { foreach (var item in frame.FrameItems) { switch (item) { case FrameLabel fl: FrameLabels[fl.Name] = fl.FrameId; break; } } } }
public AptWindow(Game game, ContentManager contentManager, AptFile aptFile) { _contentManager = contentManager; //Create our context _context = new AptContext(aptFile, contentManager); //First thing to do here is to initialize the display list Root = new SpriteItem { Transform = ItemTransform.None }; Root.SetBackgroundColor = (c) => _backgroundColor = c; Root.Create(aptFile.Movie, _context); _context.Root = Root; _context.Avm.CommandHandler = HandleCommand; AptFile = aptFile; Renderer = new AptRenderer(contentManager); ImageLoader = new MappedImageLoader(contentManager); _resolver = new AptCallbackResolver(game); }
internal 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 = new SpriteItem { Transform = ItemTransform.None, SetBackgroundColor = (c) => _backgroundColor = c }; Root.Create(aptFile.Movie, _context); _context.Root = Root; _context.Avm.CommandHandler = HandleCommand; var m = Root.Character as Movie; _movieSize = new Vector2(m.ScreenWidth, m.ScreenHeight); Renderer = new AptRenderer(this, contentManager); _resolver = new AptCallbackResolver(game); }
public void Create(Character chararacter, AptContext context, SpriteItem parent = null) { _character = chararacter; _context = context; _parent = parent; _scriptObject = new ObjectContext(this); Name = ""; Visible = true; }
public override void Create(Character character, AptContext context, SpriteItem parent = null) { Character = character; Context = context; Parent = parent; ScriptObject = new ObjectContext(this); Name = ""; Visible = true; IsHovered = false; }
private void CalculateTransform(ref ItemTransform transform, AptContext context) { var movie = (Movie)context.Root.Character; var movieSize = new Vector2(movie.ScreenWidth, movie.ScreenHeight); var scaling = _outputSize / movieSize; transform.GeometryRotation.M11 *= scaling.X; transform.GeometryRotation.M22 *= scaling.Y; transform.GeometryRotation.Translation = transform.GeometryTranslation * scaling; }
public override void Create(Character chararacter, AptContext context, SpriteItem parent = null) { Character = chararacter; Context = context; Parent = parent; Name = ""; Visible = true; var button = Character as Button; _actionList = new List <InstructionCollection>(); }
public override void Create(Character character, AptContext context, SpriteItem parent = null) { Character = character; Context = context; Parent = parent; ScriptObject = new ObjectContext(this); Name = ""; Visible = true; TextValue = character is Text text?LocalizedString.CreateApt(text.Content) : null; IsHovered = false; }
private void CalculateTransform(ref ItemTransform transform, AptContext context) { if (Window == null) { return; } var scaling = Window.GetScaling(); transform.GeometryRotation.M11 *= scaling.X; transform.GeometryRotation.M22 *= scaling.Y; transform.GeometryRotation.Translation = transform.GeometryTranslation * scaling; }
public void RenderText(DrawingContext2D drawingContext, AptContext context, Text text, ItemTransform transform) { var font = _contentManager.FontManager.GetOrCreateFont("Arial", text.FontHeight, FontWeight.Normal); CalculateTransform(ref transform, context); drawingContext.DrawText( text.Content, font, TextAlignment.Center, text.Color.ToColorRgbaF() * transform.ColorTransform, RectangleF.Transform(text.Bounds, transform.GeometryRotation)); }
public AptWindow(ContentManager contentManager, AptFile aptFile) { _contentManager = contentManager; //Create our context _context = new AptContext(aptFile, contentManager); //First thing to do here is to initialize the display list Root = new SpriteItem { Transform = ItemTransform.None }; Root.Create(aptFile.Movie, _context); _context.Root = Root; }
public static void RenderText(DrawingContext2D drawingContext, AptContext context, Text text, ItemTransform transform) { var content = context.ContentManager; var font = context.ContentManager.GetOrCreateFont("Arial", text.FontHeight, FontWeight.Normal); var matrix = transform.GeometryRotation; matrix.Translation = transform.GeometryTranslation; drawingContext.DrawText( text.Content, font, TextAlignment.Center, text.Color.ToColorRgbaF() * transform.ColorTransform, RectangleF.Transform(text.Bounds, matrix)); }
internal AptRenderingContext( AptWindow window, ContentManager contentManager, GraphicsLoadContext graphicsLoadContext, AptContext aptContext) { _contentManager = contentManager; _aptContext = aptContext; _graphicsLoadContext = graphicsLoadContext; Window = window; _transformStack = new Stack <ItemTransform>(); _clipMaskDrawingContext = AddDisposable( new DrawingContext2D( contentManager, graphicsLoadContext, BlendStateDescription.SingleAlphaBlend, RenderTarget.OutputDescription)); _commandList = AddDisposable(contentManager.GraphicsDevice.ResourceFactory.CreateCommandList()); }
public static void RenderGeometry(DrawingContext2D drawingContext, AptContext context, Geometry shape, ItemTransform transform) { var matrix = transform.GeometryRotation; matrix.Translation = transform.GeometryTranslation; foreach (var e in shape.Entries) { switch (e) { case GeometryLines l: { var color = l.Color.ToColorRgbaF() * transform.ColorTransform; foreach (var line in l.Lines) { drawingContext.DrawLine( Line2D.Transform(line, matrix), l.Thickness, color); } break; } case GeometrySolidTriangles st: { var color = st.Color.ToColorRgbaF() * transform.ColorTransform; foreach (var tri in st.Triangles) { drawingContext.FillTriangle( Triangle2D.Transform(tri, matrix), color); } break; } case GeometryTexturedTriangles tt: { var coordinatesTransform = new Matrix3x2 { M11 = tt.RotScale.M11, M12 = tt.RotScale.M12, M21 = tt.RotScale.M21, M22 = tt.RotScale.M22, M31 = tt.Translation.X, M32 = tt.Translation.Y }; foreach (var tri in tt.Triangles) { //if (assignment is RectangleAssignment) // throw new NotImplementedException(); var tex = context.GetTexture(tt.Image, shape); drawingContext.FillTriangle( tex, Triangle2D.Transform(tri, coordinatesTransform), Triangle2D.Transform(tri, matrix), transform.ColorTransform); } break; } } } }
public void RenderGeometry(DrawingContext2D drawingContext, AptContext context, Geometry shape, ItemTransform transform, Texture solidTexture) { CalculateTransform(ref transform, context); var matrix = transform.GeometryRotation; foreach (var e in shape.Entries) { switch (e) { case GeometryLines l: { var color = l.Color.ToColorRgbaF() * transform.ColorTransform; foreach (var line in l.Lines) { drawingContext.DrawLine( Line2D.Transform(line, matrix), l.Thickness, color); } break; } case GeometrySolidTriangles st: { var color = st.Color.ToColorRgbaF() * transform.ColorTransform; foreach (var tri in st.Triangles) { if (solidTexture == null) { drawingContext.FillTriangle( Triangle2D.Transform(tri, matrix), color); } else { var destTri = Triangle2D.Transform(tri, matrix); var coordTri = new Triangle2D(new Vector2(tri.V0.X / 100.0f * solidTexture.Width, tri.V0.Y / 100.0f * solidTexture.Height), new Vector2(tri.V1.X / 100.0f * solidTexture.Width, tri.V1.Y / 100.0f * solidTexture.Height), new Vector2(tri.V2.X / 100.0f * solidTexture.Width, tri.V2.Y / 100.0f * solidTexture.Height)); drawingContext.FillTriangle( solidTexture, coordTri, destTri, new ColorRgbaF(1.0f, 1.0f, 1.0f, color.A)); } } break; } case GeometryTexturedTriangles tt: { var coordinatesTransform = new Matrix3x2 { M11 = tt.RotScale.M11, M12 = tt.RotScale.M12, M21 = tt.RotScale.M21, M22 = tt.RotScale.M22, M31 = tt.Translation.X, M32 = tt.Translation.Y }; foreach (var tri in tt.Triangles) { //if (assignment is RectangleAssignment) // throw new NotImplementedException(); var tex = context.GetTexture(tt.Image, shape); drawingContext.FillTriangle( tex, Triangle2D.Transform(tri, coordinatesTransform), Triangle2D.Transform(tri, matrix), transform.ColorTransform); } break; } } } }