コード例 #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;
        }
コード例 #2
0
 public AGSModelMatrixComponent(IRuntimeSettings settings)
 {
     _isDirty           = true;
     _matrices          = new ModelMatrices();
     _virtualResolution = settings.VirtualResolution;
     OnMatrixChanged    = new AGSEvent <AGSEventArgs>();
 }
コード例 #3
0
 public AGSModelMatrixComponent(IRuntimeSettings settings)
 {
     _isDirty           = true;
     _matrices          = new ModelMatrices();
     _areaBindings      = new Dictionary <string, List <IComponentBinding> >();
     _virtualResolution = settings.VirtualResolution;
     OnMatrixChanged    = new AGSEvent();
 }
コード例 #4
0
ファイル: GLLabelRenderer.cs プロジェクト: saizant/MonoAGS
        private void updateBoundingBoxes(IObject obj, IDrawableInfoComponent drawable, IViewport viewport)
        {
            var    noFactor = AGSModelMatrixComponent.NoScaling;
            bool   resolutionMatches;
            PointF hitTestResolutionFactor;
            Size   resolution;
            PointF textScaleFactor = new PointF(GLText.TextResolutionFactorX, GLText.TextResolutionFactorY);

            if (!textScaleFactor.Equals(_lastTextScaleFactor))
            {
                _lastTextScaleFactor = textScaleFactor;
                onBoundingBoxShouldChange();
            }
            resolutionMatches = AGSModelMatrixComponent.GetVirtualResolution(false, _virtualResolution, drawable,
                                                                             textScaleFactor, out hitTestResolutionFactor,
                                                                             out resolution);
            var scaleUpText   = hitTestResolutionFactor;
            var scaleDownText = noFactor;

            if (!textScaleFactor.Equals(hitTestResolutionFactor))
            {
                textScaleFactor = noFactor;
                scaleDownText   = hitTestResolutionFactor;
            }
            AutoFit autoFit = getAutoFit();
            float   height  = obj.Height;
            float   width   = obj.Width;

            bool shouldUpdateBoundingBoxes = _shouldUpdateBoundingBoxes;

            _shouldUpdateBoundingBoxes = false;
            if (autoFit == AutoFit.LabelShouldFitText)
            {
                updateText(_glTextHitTest, resolutionMatches, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue);
                if (!resolutionMatches)
                {
                    updateText(_glTextRender, true, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue);
                }
                CustomImageSize = new SizeF(_glTextHitTest.Width, _glTextHitTest.Height);
            }
            else if (autoFit == AutoFit.TextShouldWrapAndLabelShouldFitHeight)
            {
                updateText(_glTextHitTest, resolutionMatches, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width);
                if (!resolutionMatches)
                {
                    updateText(_glTextRender, true, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width);
                }
                CustomImageSize = new SizeF(BaseSize.Width, _glTextHitTest.Height);
            }
            else
            {
                CustomImageSize = BaseSize;
            }

            CustomImageResolutionFactor = hitTestResolutionFactor;
            var viewportMatrix = drawable.IgnoreViewport ? Matrix4.Identity : _viewport.GetViewport(drawable.RenderLayer.Z).GetMatrix(viewport, drawable.RenderLayer.ParallaxSpeed);

            if (!viewportMatrix.Equals(_lastViewportMatrix))
            {
                _lastViewportMatrix = viewportMatrix;
                onBoundingBoxShouldChange();
            }

            var modelMatrices = obj.GetModelMatrices();

            if (!modelMatrices.Equals(_lastMatrices))
            {
                _lastMatrices = modelMatrices;
                onBoundingBoxShouldChange();
            }
            if (!shouldUpdateBoundingBoxes)
            {
                return;
            }

            IGLMatrices textRenderMatrices   = acquireMatrix(0).SetMatrices(modelMatrices.InObjResolutionMatrix, viewportMatrix);
            IGLMatrices labelRenderMatrices  = obj.RenderLayer.IndependentResolution != null ? textRenderMatrices : acquireMatrix(1).SetMatrices(modelMatrices.InVirtualResolutionMatrix, viewportMatrix);
            IGLMatrices textHitTestMatrices  = resolutionMatches ? textRenderMatrices : obj.RenderLayer.IndependentResolution == null ? labelRenderMatrices : acquireMatrix(2).SetMatrices(modelMatrices.InVirtualResolutionMatrix, viewportMatrix);
            IGLMatrices labelHitTestMatrices = obj.RenderLayer.IndependentResolution == null ? labelRenderMatrices : textHitTestMatrices;

            if (textScaleFactor.Equals(hitTestResolutionFactor))
            {
                hitTestResolutionFactor = noFactor;
            }

            updateBoundingBoxes(_glTextHitTest, autoFit, textHitTestMatrices, labelHitTestMatrices, scaleUpText, noFactor, hitTestResolutionFactor, resolutionMatches, true);
            if (!resolutionMatches)
            {
                updateBoundingBoxes(_glTextRender, autoFit, textRenderMatrices, labelRenderMatrices, scaleUpText, scaleDownText, noFactor, true, false);
            }

            if (_lastWidth != Width || _lastHeight != Height)
            {
                OnLabelSizeChanged.Invoke();
            }
            _lastWidth  = Width;
            _lastHeight = Height;
        }
コード例 #5
0
 public bool Equals(ref ModelMatrices other)
 {
     return(InObjResolutionMatrix.Equals(other.InObjResolutionMatrix) &&
            InVirtualResolutionMatrix.Equals(other.InVirtualResolutionMatrix));
 }