Exemple #1
0
 public override TaleWorlds.TwoDimension.Texture GetTexture(
     TwoDimensionContext twoDimensionContext,
     string name)
 {
     this.CheckTexture();
     return(this._providedTexture);
 }
        protected override void OnRender(TwoDimensionContext twoDimensionContext, TwoDimensionDrawContext drawContext)
        {
            base.OnRender(twoDimensionContext, drawContext);

            var size = _agentMarkerSize;

            UpdateDrawObject2D(size, size);
            var materials      = new SimpleMaterial[(int)AgentMarkerType.Count];
            var globalPosition = Widgets.Utility.GetGlobalPosition(this);

            for (int i = 0; i < AgentMakers.CountOfAgentMarkers; ++i)
            {
                var agentMaker = AgentMakers.AgentMarkers[i];
                var type       = agentMaker.AgentMarkerType;
                twoDimensionContext.Draw(globalPosition.x + agentMaker.PositionInWidget.x * ScaledSuggestedWidth / Math.Max(SuggestedWidth, 1) - size * 0.5f, globalPosition.y + agentMaker.PositionInWidget.y * ScaledSuggestedHeight / Math.Max(SuggestedHeight, 1) - size * 0.5f, materials[(int)type] ??= CreateMaterial(drawContext, type), _cachedMesh, type.GetLayer());
            }
        }
Exemple #3
0
        protected override void OnRender(TwoDimensionContext twoDimensionContext, TwoDimensionDrawContext drawContext)
        {
            base.OnRender(twoDimensionContext, drawContext);


            SimpleMaterial simpleMaterial = drawContext.CreateSimpleMaterial();
            Brush          brush          = Brush;
            StyleLayer     styleLayer;

            if (brush == null)
            {
                styleLayer = null;
            }
            else
            {
                Dictionary <string, StyleLayer> .ValueCollection layers = brush.GetStyleOrDefault(CurrentState).Layers;
                styleLayer = layers?.FirstOrDefault();
            }
            simpleMaterial.OverlayEnabled         = false;
            simpleMaterial.CircularMaskingEnabled = false;
            simpleMaterial.Texture          = Texture;
            simpleMaterial.AlphaFactor      = (styleLayer?.AlphaFactor ?? 1f) * Brush.GlobalAlphaFactor * Context.ContextAlpha;
            simpleMaterial.ColorFactor      = (styleLayer?.ColorFactor ?? 1f) * Brush.GlobalColorFactor;
            simpleMaterial.HueFactor        = styleLayer?.HueFactor ?? 0.0f;
            simpleMaterial.SaturationFactor = styleLayer?.SaturationFactor ?? 0.0f;
            simpleMaterial.ValueFactor      = styleLayer?.ValueFactor ?? 0.0f;
            simpleMaterial.Color            = (styleLayer?.Color ?? Color.White) * Brush.GlobalColor;
            if (CachedMesh == null || Math.Abs(CachedMesh.Width - Size.X) > 0.01f && Math.Abs(CachedMesh.Height - Size.Y) > 0.01f)
            {
                UpdateDrawObject2D();
            }
            if (drawContext.CircularMaskEnabled)
            {
                simpleMaterial.CircularMaskingEnabled         = true;
                simpleMaterial.CircularMaskingCenter          = drawContext.CircularMaskCenter;
                simpleMaterial.CircularMaskingRadius          = drawContext.CircularMaskRadius;
                simpleMaterial.CircularMaskingSmoothingRadius = drawContext.CircularMaskSmoothingRadius;
            }
            //drawContext.Draw(GlobalPosition.X, GlobalPosition.Y, simpleMaterial, CachedMesh, Size.X, Size.Y);
            twoDimensionContext.Draw(GlobalPosition.X, GlobalPosition.Y, simpleMaterial, CachedMesh, Layer);
        }
Exemple #4
0
 public abstract Texture GetTexture(TwoDimensionContext twoDimensionContext, string name);
 public override Texture GetTexture(TwoDimensionContext twoDimensionContext, string name)
 {
     //return SimpleMiniMap.Instance?.MapTexture ?? new ImageRGBA(100, 100).CreateTexture();
     return(MiniMap.Instance?.MapTexture ?? new ImageRGBA(100, 100).CreateTexture());
 }