Exemplo n.º 1
0
        public AGSModelMatrixComponent(IRuntimeSettings settings)
        {
            _isDirty           = true;
            _matrices          = new ModelMatrices();
            _areaBindings      = new Dictionary <string, List <IComponentBinding> >();
            _virtualResolution = settings.VirtualResolution;
            OnMatrixChanged    = new AGSEvent();

            _onScaleChangedCallback               = onScaleChanged;
            _onTranslateChangedCallback           = onTranslateChanged;
            _onWorldPositionChangedCallback       = onWorldPositionChanged;
            _onJumpOffsetChangedCallback          = onJumpOffsetChanged;
            _onRotateChangedCallback              = onRotateChanged;
            _onImageChangedCallback               = onImageChanged;
            _onDrawbaleChangedCallback            = onDrawableChanged;
            _onSomethingChangedCallback           = onSomethingChanged;
            _onParentChangedCallback              = onParentChanged;
            _onTextChangedCallback                = onTextPropertyChanged;
            _onRoomChangedCallback                = onRoomPropertyChanged;
            _onSpriteChangeCallback               = onSpritePropertyChanged;
            _onAreasChangedCallback               = onAreasChanged;
            _onAreaPropertyChangedCallback        = onAreaPropertyChanged;
            _onScalingAreaChangedCallback         = onScalingAreaChanged;
            _onAreaRestrictionChangedCallback     = onAreaRestrictionChanged;
            _onAreaRestrictionListChangedCallback = onAreaRestrictListChanged;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 public AGSEntity(string id, Resolver resolver)
 {
     ID                      = id;
     _resolver               = resolver;
     _components             = new ConcurrentDictionary <Type, List <IComponent> >();
     OnComponentsInitialized = new AGSEvent <AGSEventArgs>();
 }
Exemplo n.º 4
0
 public HasRoomComponent(IGameState state)
 {
     _state        = state;
     OnRoomChanged = new AGSEvent();
     refreshRoom();
     state.Rooms?.OnListChanged?.Subscribe(onRoomsChanged);
 }
Exemplo n.º 5
0
 public GLImage()
 {
     Width           = 1f;
     Height          = 1f;
     ID              = "";
     OnImageDisposed = new AGSEvent();
 }
Exemplo n.º 6
0
 public AGSSliderComponent(IGameState state, IInput input, IGameEvents gameEvents)
 {
     _state         = state;
     _input         = input;
     _gameEvents    = gameEvents;
     OnValueChanged = new AGSEvent <SliderValueEventArgs> ();
 }
Exemplo n.º 7
0
 public AGSModelMatrixComponent(IRuntimeSettings settings)
 {
     _isDirty           = true;
     _matrices          = new ModelMatrices();
     _virtualResolution = settings.VirtualResolution;
     OnMatrixChanged    = new AGSEvent <AGSEventArgs>();
 }
Exemplo n.º 8
0
 public AGSBoundingBoxWithChildrenComponent(IGameState state, IGameEvents events)
 {
     _state         = state;
     EntitiesToSkip = new AGSConcurrentHashSet <string>();
     OnBoundingBoxWithChildrenChanged = new AGSEvent();
     events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
 }
Exemplo n.º 9
0
 public AGSModelMatrixComponent(IRuntimeSettings settings)
 {
     _isDirty           = true;
     _matrices          = new ModelMatrices();
     _areaBindings      = new Dictionary <string, List <IComponentBinding> >();
     _virtualResolution = settings.VirtualResolution;
     OnMatrixChanged    = new AGSEvent();
 }
Exemplo n.º 10
0
 public AGSConcurrentHashSet(int capacity = 5, bool fireListChangedEvent = true)
 {
     _map = new ConcurrentDictionary <TItem, byte> (2, capacity);
     if (fireListChangedEvent)
     {
         OnListChanged = new AGSEvent <AGSHashSetChangedEventArgs <TItem> >();
     }
 }
Exemplo n.º 11
0
 public AGSStackLayoutComponent()
 {
     _isPaused        = true;
     OnLayoutChanged  = new AGSEvent();
     EntitiesToIgnore = new AGSConcurrentHashSet <string>();
     _direction       = LayoutDirection.Vertical;
     _relativeSpacing = -1f; //a simple vertical layout top to bottom by default.
 }
Exemplo n.º 12
0
 public HasRoomComponent(IGameState state, IAGSRoomTransitions roomTransitions)
 {
     _state           = state;
     _roomTransitions = roomTransitions;
     OnRoomChanged    = new AGSEvent();
     refreshRoom();
     state.Rooms?.OnListChanged?.Subscribe(onRoomsChanged);
 }
Exemplo n.º 13
0
 public AGSEntity(string id, Resolver resolver)
 {
     ID                      = id;
     _resolver               = resolver;
     _components             = new ConcurrentDictionary <Type, Lazy <API.IComponent> >();
     _bindings               = new AGSConcurrentHashSet <API.IComponentBinding>();
     OnComponentsInitialized = new AGSEvent();
     OnComponentsChanged     = new AGSEvent <AGSListChangedEventArgs <API.IComponent> >();
 }
Exemplo n.º 14
0
        private int _inUpdate; //For preventing re-entrancy

        public TreeTableLayout(IGameEvents gameEvents)
        {
            ColumnSizes           = new AGSBindingList <float>(10);
            Rows                  = new AGSBindingList <ITreeTableRowLayoutComponent>(10);
            OnRefreshLayoutNeeded = new AGSEvent();
            OnQueryLayout         = new AGSEvent <QueryLayoutEventArgs>();
            Rows.OnListChanged.Subscribe(onRowsChanged);
            gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
        }
Exemplo n.º 15
0
 public AGSTreeNodeView(IUIControl treeItem, IButton expandButton, IPanel parentPanel, IPanel verticalPanel, IPanel horizontalPanel)
 {
     TreeItem               = treeItem;
     ExpandButton           = expandButton;
     ParentPanel            = parentPanel;
     VerticalPanel          = verticalPanel;
     HorizontalPanel        = horizontalPanel;
     OnRefreshDisplayNeeded = new AGSEvent();
 }
Exemplo n.º 16
0
 public AGSSoundEmitter(IGame game)
 {
     _game            = game;
     OnSoundStarted   = new AGSEvent <ISound>();
     OnSoundCompleted = new AGSEvent <ISound>();
     _playingSounds   = new ConcurrentDictionary <int, EmittedSound>();
     game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
     AutoPan          = true;
     AutoAdjustVolume = true;
 }
Exemplo n.º 17
0
        private int _inUpdate; //For preventing re-entrancy

        public AGSStackLayoutComponent(IGameEvents gameEvents)
        {
            _gameEvents      = gameEvents;
            _isPaused        = true;
            _isDirty         = true;
            OnLayoutChanged  = new AGSEvent();
            EntitiesToIgnore = new AGSConcurrentHashSet <string>();
            _direction       = LayoutDirection.Vertical;
            _relativeSpacing = -1f; //a simple vertical layout top to bottom by default.
            gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
        }
Exemplo n.º 18
0
 public GLImage(IBitmap bitmap, string id, ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig)
 {
     OnImageDisposed = new AGSEvent();
     OriginalBitmap  = bitmap;
     Width           = bitmap.Width;
     Height          = bitmap.Height;
     ID          = id;
     Texture     = texture;
     SpriteSheet = spriteSheet;
     LoadConfig  = loadConfig;
 }
Exemplo n.º 19
0
 public AGSSliderComponent(IGameState state, IInput input, IGameEvents gameEvents, IFocusedUI focus)
 {
     _focus               = focus;
     _state               = state;
     _input               = input;
     _gameEvents          = gameEvents;
     AllowKeyboardControl = true;
     OnValueChanged       = new AGSEvent <SliderValueEventArgs>();
     OnValueChanging      = new AGSEvent <SliderValueEventArgs>();
     input.KeyUp.Subscribe(onKeyUp);
 }
Exemplo n.º 20
0
 public AGSHasImage()
 {
     OnImageChanged  = new AGSEvent <AGSEventArgs>();
     OnAnchorChanged = new AGSEvent <AGSEventArgs>();
     OnTintChanged   = new AGSEvent <AGSEventArgs>();
     _imageArgs      = new AGSEventArgs();
     _anchorArgs     = new AGSEventArgs();
     _tintArgs       = new AGSEventArgs();
     Anchor          = new PointF(0.5f, 0f);
     Tint            = Colors.White;
 }
Exemplo n.º 21
0
 public AGSTreeViewComponent(ITreeNodeViewProvider provider, IGameState state)
 {
     HorizontalSpacing = 10f;
     VerticalSpacing   = 30f;
     OnNodeSelected    = new AGSEvent <NodeEventArgs>();
     OnNodeExpanded    = new AGSEvent <NodeEventArgs>();
     OnNodeCollapsed   = new AGSEvent <NodeEventArgs>();
     AllowSelection    = SelectionType.Single;
     _state            = state;
     NodeViewProvider  = provider;
 }
Exemplo n.º 22
0
        public AGSUIEvents(UIEventsAggregator aggregator)
        {
            _aggregator = aggregator;

            MouseEnter         = new AGSEvent <MousePositionEventArgs> ();
            MouseLeave         = new AGSEvent <MousePositionEventArgs> ();
            MouseMove          = new AGSEvent <MousePositionEventArgs> ();
            MouseClicked       = new AGSEvent <MouseClickEventArgs> ();
            MouseDoubleClicked = new AGSEvent <MouseClickEventArgs>();
            MouseDown          = new AGSEvent <MouseButtonEventArgs> ();
            MouseUp            = new AGSEvent <MouseButtonEventArgs> ();
            LostFocus          = new AGSEvent <MouseButtonEventArgs>();
        }
Exemplo n.º 23
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;
        }
Exemplo n.º 24
0
 public AGSEntity(string id, Resolver resolver)
 {
     ID = id;
     if (!_ids.Add(id))
     {
         throw new ArgumentException($"Duplicate entity: {id}");
     }
     _resolver               = resolver;
     _components             = new ConcurrentDictionary <Type, Lazy <API.IComponent> >();
     _bindings               = new AGSConcurrentHashSet <API.IComponentBinding>(200, false);
     OnComponentsInitialized = new AGSEvent();
     OnComponentsChanged     = new AGSEvent <AGSListChangedEventArgs <API.IComponent> >();
     _onDisposed             = new AGSEvent();
 }
Exemplo n.º 25
0
 public AGSBoundingBoxComponent(IRuntimeSettings settings, IGLViewportMatrixFactory layerViewports,
                                IBoundingBoxBuilder boundingBoxBuilder, IGameState state, IGameEvents events)
 {
     _boundingBoxes = new ConcurrentDictionary <IViewport, ViewportBoundingBoxes>(new IdentityEqualityComparer <IViewport>());
     _boundingBoxes.TryAdd(state.Viewport, new ViewportBoundingBoxes(state.Viewport));
     _settings = settings;
     _state    = state;
     OnBoundingBoxesChanged = new AGSEvent();
     _layerViewports        = layerViewports;
     _boundingBoxBuilder    = boundingBoxBuilder;
     boundingBoxBuilder.OnNewBoxBuildRequired.Subscribe(onHitTextBoxShouldChange);
     events.OnRoomChanging.Subscribe(onHitTextBoxShouldChange);
     onHitTextBoxShouldChange();
 }
Exemplo n.º 26
0
        public AGSSprite(Resolver resolver, IMaskLoader maskLoader)
        {
            _maskLoader    = maskLoader;
            _resolver      = resolver;
            OnScaleChanged = new AGSEvent <AGSEventArgs>();

            //todo: abstract it to the constructor
            _translate       = new AGSTranslate();
            _hasImage        = new AGSHasImage();
            _hasImage.Anchor = new PointF();
            _rotate          = new AGSRotate();

            ScaleX = 1;
            ScaleY = 1;
            _hasImage.OnImageChanged.Subscribe((sender, args) => ScaleBy(ScaleX, ScaleY));
        }
Exemplo n.º 27
0
        private int _inUpdate; //For preventing re-entrancy

        public AGSStackLayoutComponent(IGameEvents gameEvents)
        {
            _gameEvents      = gameEvents;
            _isPaused        = true;
            _isDirty         = true;
            OnLayoutChanged  = new AGSEvent();
            EntitiesToIgnore = new AGSConcurrentHashSet <string>();
            _direction       = LayoutDirection.Vertical;
            _relativeSpacing = -1f; //a simple vertical layout top to bottom by default.

            //Using low callback priority to make sure we only adjust the layout after all bounding box calculations has already happened.
            //Otherwise, this scenario can happen: the entity with the stack layout can subscribe to the bounding box with children event,
            //and adjust the starting point of the layout to start from the new top of the bounding box whenever the size changes.
            //If the stack layout updates in the middle of all the child bounding box calculations, it can trigger an endless loop:
            //layout update -> bounding box with children update -> layout update -> etc,
            //because the box in the bottom of the layout might remain below the bottom of the parent box border and increase the size of the parent each time.
            gameEvents.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute, CallbackPriority.Low);
        }
Exemplo n.º 28
0
        public AGSUIEvents(IInput input, IGameState state, IGameEvents gameEvents)
        {
            _input      = input;
            _state      = state;
            _gameEvents = gameEvents;

            MouseEnter         = new AGSEvent <MousePositionEventArgs> ();
            MouseLeave         = new AGSEvent <MousePositionEventArgs> ();
            MouseMove          = new AGSEvent <MousePositionEventArgs> ();
            MouseClicked       = new AGSEvent <MouseButtonEventArgs> ();
            MouseDoubleClicked = new AGSEvent <MouseButtonEventArgs>();
            MouseDown          = new AGSEvent <MouseButtonEventArgs> ();
            MouseUp            = new AGSEvent <MouseButtonEventArgs> ();
            LostFocus          = new AGSEvent <MouseButtonEventArgs>();

            _leftMouseClickTimer        = new Stopwatch();
            _rightMouseClickTimer       = new Stopwatch();
            _leftMouseDoubleClickTimer  = new Stopwatch();
            _rightMouseDoubleClickTimer = new Stopwatch();
        }
Exemplo n.º 29
0
        private AGSScale(IHasImage image, bool shouldSubscribeToImageChange)
        {
            _image         = image;
            OnScaleChanged = new AGSEvent <AGSEventArgs>();

            ScaleX = 1;
            ScaleY = 1;

            if (!shouldSubscribeToImageChange)
            {
                return;
            }
            image.OnImageChanged.Subscribe((sender, args) =>
            {
                if (_initialWidth == 0f)
                {
                    ResetBaseSize(_image.Image.Width, _image.Image.Height);
                }
            });
        }
Exemplo n.º 30
0
 public AGSAnimationComponent()
 {
     OnAnimationStarted = new AGSEvent();
 }