public AGSTextComponent(IRenderPipeline pipeline, IBoundingBoxBuilder boundingBoxBuilder,
                                IGLTextureRenderer textureRenderer, BitmapPool bitmapPool,
                                AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes,
                                IGLUtils glUtils, IGraphicsBackend graphics, IFontFactory fonts,
                                IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _pipeline = pipeline;
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();

            _instructionPool = new ObjectPool <Instruction>(pool => new Instruction(pool, glUtils, textureRenderer, _glTextHitTest), 0);

            TextVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged           += onPropertyChanged;
            _shouldUpdateBoundingBoxes = true;
        }
Exemple #2
0
 public GLUtils(IGraphicsBackend graphics, IRenderMessagePump messagePump)
 {
     _graphics               = graphics;
     _messagePump            = messagePump;
     _quad                   = new GLVertex[4];
     _line                   = new GLVertex[2];
     CurrentGlobalResolution = new SizeF();
 }
Exemple #3
0
 public GLUtils(IGraphicsBackend graphics, IRenderMessagePump messagePump, IGameState state)
 {
     _state            = state;
     _graphics         = graphics;
     _messagePump      = messagePump;
     _quad             = new GLVertex[4];
     _line             = new GLVertex[2];
     CurrentResolution = new SizeF();
 }
Exemple #4
0
        public GLFrameBuffer(Size size, IGraphicsBackend graphics, IRenderMessagePump messagePump)
        {
            _width    = size.Width;
            _height   = size.Height;
            Texture   = new GLTexture(null, graphics, messagePump);
            _graphics = graphics;
            _graphics.TexImage2D(_width, _height, IntPtr.Zero);

            _fbo = _graphics.GenFrameBuffer();
        }
Exemple #5
0
 public GLTexture(ITextureConfig config, IGraphicsBackend graphics, IRenderMessagePump messagePump)
 {
     _graphics    = graphics;
     _messagePump = messagePump;
     if (Environment.CurrentManagedThreadId != AGSGame.UIThreadID)
     {
         throw new InvalidOperationException("Must generate textures on the UI thread");
     }
     ID     = _graphics.GenTexture();
     Config = config ?? new AGSTextureConfig();
 }
Exemple #6
0
 public SpriteSheetLoader(IResourceLoader resources, IBitmapLoader bitmapLoader,
                          Action <IImage, AGSAnimation> addAnimationFrame,
                          Func <ITexture, IBitmap, string, ILoadImageConfig, ISpriteSheet, IImage> loadImage,
                          IGraphicsBackend graphics, IRenderMessagePump messagePump)
 {
     _graphics          = graphics;
     _messagePump       = messagePump;
     _resources         = resources;
     _bitmapLoader      = bitmapLoader;
     _addAnimationFrame = addAnimationFrame;
     _loadImage         = loadImage;
 }
Exemple #7
0
 public AGSRuntimeSettings(IGameSettings settings, IGameWindow gameWindow, IRenderMessagePump messagePump, IGLUtils glUtils)
 {
     _glUtils            = glUtils;
     _gameWindow         = gameWindow;
     _messagePump        = messagePump;
     Title               = settings.Title;
     VirtualResolution   = settings.VirtualResolution;
     Vsync               = settings.Vsync;
     PreserveAspectRatio = settings.PreserveAspectRatio;
     WindowState         = settings.WindowState;
     WindowBorder        = settings.WindowBorder;
 }
Exemple #8
0
 public AGSGame(IGameState state, IGameEvents gameEvents, IRenderMessagePump renderMessagePump, IUpdateMessagePump updateMessagePump,
                IGraphicsBackend graphics, IGLUtils glUtils)
 {
     _renderMessagePump = renderMessagePump;
     _renderMessagePump.SetSyncContext();
     _updateMessagePump = updateMessagePump;
     State          = state;
     Events         = gameEvents;
     _relativeSpeed = state.Speed;
     _graphics      = graphics;
     _glUtils       = glUtils;
     GLUtils        = _glUtils;
 }
Exemple #9
0
#pragma warning restore CS0067

        public GLLabelRenderer(Dictionary <string, ITexture> textures,
                               IBoundingBoxBuilder boundingBoxBuilder, IGLColorBuilder colorBuilder,
                               IGLTextureRenderer textureRenderer, BitmapPool bitmapPool, IGLViewportMatrixFactory viewportMatrix,
                               AGSBoundingBoxes labelBoundingBoxes, AGSBoundingBoxes textBoundingBoxes, IGraphicsFactory graphicsFactory,
                               IGLUtils glUtils, IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IFontLoader fonts,
                               IRuntimeSettings settings, IRenderMessagePump messagePump, IGameState state, IGameEvents events)
        {
            _bindings = new List <IComponentBinding>();
            _afterCropTextBoundingBoxes = new AGSBoundingBoxes();
            _state                       = state;
            _events                      = events;
            Width                        = 1f;
            Height                       = 1f;
            _matricesPool                = new GLMatrices[3];
            _messagePump                 = messagePump;
            OnLabelSizeChanged           = new AGSEvent();
            _glUtils                     = glUtils;
            _graphics                    = graphics;
            _fonts                       = fonts;
            _bitmapPool                  = bitmapPool;
            _viewport                    = viewportMatrix;
            _textureRenderer             = textureRenderer;
            _labelBoundingBoxes          = labelBoundingBoxes;
            _textBoundingBoxes           = textBoundingBoxes;
            _boundingBoxBuilder          = boundingBoxBuilder;
            _virtualResolution           = settings.VirtualResolution;
            _settings                    = settings;
            _labelBoundingBoxFakeBuilder = new BoundingBoxesEmptyBuilder();
            _bgRenderer                  = new GLImageRenderer(textures,
                                                               colorBuilder, _textureRenderer, graphicsFactory, glUtils, bitmapLoader);

            _colorBuilder = colorBuilder;

            TextVisible           = true;
            TextBackgroundVisible = true;

            subscribeTextConfigChanges();
            PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == nameof(TextBackgroundVisible))
                {
                    return;
                }
                onBoundingBoxShouldChange();
                if (e.PropertyName == nameof(Config))
                {
                    subscribeTextConfigChanges();
                }
            };
            _shouldUpdateBoundingBoxes = true;
        }
Exemple #10
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontLoader fonts, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            this._maxWidth     = maxWidth;
            this._text         = text;
            this._bitmapPool   = pool;
            _config            = new AGSTextConfig();

            prepareBitmapDraw();
        }
Exemple #11
0
        public GLText(IGraphicsBackend graphics, IRenderMessagePump messagePump, IFontFactory fonts, IFont defaultFont, BitmapPool pool,
                      bool alwaysMeasureOnly, string text = "", int maxWidth = int.MaxValue)
        {
            _messagePump       = messagePump;
            _fonts             = fonts;
            _graphics          = graphics;
            _alwaysMeasureOnly = alwaysMeasureOnly;
            _maxWidth          = maxWidth;
            _text       = text;
            _bitmapPool = pool;
            _config     = fonts.GetTextConfig(font: defaultFont);

            prepareBitmapDraw();
        }
Exemple #12
0
        public GLGraphicsFactory(ITextureCache textures, Resolver resolver,
                                 IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IRenderThread renderThread,
                                 IResourceLoader resources, IIconFactory icons, IBrushLoader brushes,
                                 IRenderMessagePump messagePump, IGameSettings settings, IBorderFactory borders)
        {
            Icons              = icons;
            Brushes            = brushes;
            Borders            = borders;
            _renderThread      = renderThread;
            _textures          = textures;
            _resolver          = resolver;
            _resources         = resources;
            _bitmapLoader      = bitmapLoader;
            _spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics, messagePump);

            settings.Defaults.Skin = new AGSBlueSkin(this).CreateSkin();
        }
#pragma warning restore CS0067

        public AGSRuntimeSettings(IGameSettings settings, IGameWindow gameWindow, IRenderMessagePump messagePump)
        {
            _gameWindow  = gameWindow;
            _messagePump = messagePump;
            LoadFrom(settings);
        }
Exemple #14
0
        public GLGraphicsFactory(Dictionary <string, ITexture> textures, Resolver resolver, IGLUtils glUtils,
                                 IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IRenderThread renderThread,
                                 IResourceLoader resources, IIconFactory icons, IBrushLoader brushes, IRenderMessagePump messagePump)
        {
            Icons              = icons;
            Brushes            = brushes;
            _renderThread      = renderThread;
            _textures          = textures;
            _resolver          = resolver;
            _resources         = resources;
            _bitmapLoader      = bitmapLoader;
            _spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics, messagePump);

            AGSGameSettings.CurrentSkin = new AGSBlueSkin(this, glUtils).CreateSkin();
        }
Exemple #15
0
 public static void Load(IRenderMessagePump messagePump, AGSProject agsProj, AGSEditor editor)
 {
     editor.Project = agsProj;
     messagePump.Post(async _ => await load(agsProj, editor), null);
 }
Exemple #16
0
 public static void Load(IRenderMessagePump messagePump, AGSProject agsProj)
 {
     messagePump.Post(async _ => load(agsProj), null);
 }