protected override void Draw(DrawingHandleBase handle)
            {
                var map = _owner.eyeManager.CurrentMap;

                var            worldHandle   = (DrawingHandleWorld)handle;
                ShaderInstance currentShader = null;

                foreach (var effect in _owner._Effects)
                {
                    if (_mapManager.GetGrid(effect.Coordinates.GridID).ParentMapId != map)
                    {
                        continue;
                    }

                    var newShader = effect.Shaded ? null : _unshadedShader;

                    if (newShader != currentShader)
                    {
                        worldHandle.UseShader(newShader);
                        currentShader = newShader;
                    }

                    worldHandle.SetTransform(
                        effect.Coordinates.ToWorld(_mapManager).Position,
                        new Angle(-effect.Rotation), effect.Size);
                    var effectSprite = effect.EffectSprite;
                    worldHandle.DrawTexture(effectSprite,
                                            -((Vector2)effectSprite.Size / EyeManager.PIXELSPERMETER) / 2, ToColor(effect.Color));
                }
            }
Example #2
0
        /// <inheritdoc />
        public override void Initialize()
        {
            base.Initialize();

            _selectionShaderInRangeInstance = _prototypeManager.Index <ShaderPrototype>(ShaderInRange).Instance();
            _selectionShaderInstance        = _prototypeManager.Index <ShaderPrototype>(ShaderOutOfRange).Instance();
        }
 public EffectOverlay(EffectSystem owner, IPrototypeManager protoMan, IMapManager mapMan) : base(
         "EffectSystem")
 {
     _owner          = owner;
     _unshadedShader = protoMan.Index <ShaderPrototype>("unshaded").Instance();
     _mapManager     = mapMan;
 }
Example #4
0
        public FireTileOverlay()
        {
            IoCManager.InjectDependencies(this);

            _gasTileOverlaySystem = EntitySystem.Get <GasTileOverlaySystem>();
            _shader = _prototypeManager.Index <ShaderPrototype>("unshaded").Instance().Duplicate();
            ZIndex  = GasTileOverlaySystem.GasOverlayZIndex + 1;
        }
 public DamageOverlay()
 {
     // TODO: Replace
     IoCManager.InjectDependencies(this);
     _oxygenShader = _prototypeManager.Index <ShaderPrototype>("GradientCircleMask").InstanceUnique();
     _critShader   = _prototypeManager.Index <ShaderPrototype>("GradientCircleMask").InstanceUnique();
     _bruteShader  = _prototypeManager.Index <ShaderPrototype>("GradientCircleMask").InstanceUnique();
 }
Example #6
0
        public override void Initialize()
        {
            base.Initialize();

            var shaderProto = _prototypeManager.Index <ShaderPrototype>(HairShaderName);

            _facialHairShader = shaderProto.InstanceUnique();
            _hairShader       = shaderProto.InstanceUnique();
        }
Example #7
0
        public ItemSlotButton(Texture texture, Texture storageTexture)
        {
            _highlightShader  = IoCManager.Resolve <IPrototypeManager>().Index <ShaderPrototype>(HighlightShader).Instance();
            CustomMinimumSize = (64, 64);

            AddChild(Button = new TextureRect
            {
                Texture      = texture,
                TextureScale = (2, 2),
                MouseFilter  = MouseFilterMode.Stop
            });
Example #8
0
        public FlashOverlay() : base(nameof(SharedOverlayID.FlashOverlay))
        {
            IoCManager.InjectDependencies(this);
            _shader = _prototypeManager.Index <ShaderPrototype>("FlashedEffect").Instance().Duplicate();

            _startTime = _gameTiming.CurTime.TotalMilliseconds;
            _displayManager.Screenshot(ScreenshotType.BeforeUI, image =>
            {
                var rgba32Image    = image.CloneAs <Rgba32>(Configuration.Default);
                _screenshotTexture = _displayManager.LoadTextureFromImage(rgba32Image);
            });
        }
Example #9
0
        public override void Initialize()
        {
            _state = DragState.NotDragging;

            _dropTargetInRangeShader    = _prototypeManager.Index <ShaderPrototype>(ShaderDropTargetInRange).Instance();
            _dropTargetOutOfRangeShader = _prototypeManager.Index <ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
            _interactionSystem          = EntitySystem.Get <SharedInteractionSystem>();
            _inputSystem = EntitySystem.Get <InputSystem>();
            // needs to fire on mouseup and mousedown so we can detect a drag / drop
            CommandBinds.Builder
            .Bind(EngineKeyFunctions.Use, new PointerInputCmdHandler(OnUse, false))
            .Register <DragDropSystem>();
        }
Example #10
0
        public ParallaxOverlay()
        {
            IoCManager.InjectDependencies(this);
            _shader = _prototypeManager.Index <ShaderPrototype>("unshaded").Instance();

            if (_parallaxManager.ParallaxTexture == null)
            {
                _parallaxManager.OnTextureLoaded += texture => _parallaxTexture = texture;
            }
            else
            {
                _parallaxTexture = _parallaxManager.ParallaxTexture;
            }
        }
 public CooldownGraphic()
 {
     IoCManager.InjectDependencies(this);
     _shader = _protoMan.Index <ShaderPrototype>("CooldownAnimation").InstanceUnique();
 }
Example #12
0
 public ParallaxOverlay()
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("unshaded").Instance();
 }
Example #13
0
 public DrunkOverlay()
 {
     IoCManager.InjectDependencies(this);
     _drunkShader = _prototypeManager.Index <ShaderPrototype>("Drunk").InstanceUnique();
 }
Example #14
0
        /// <summary>
        /// Compilation function (must be overrided for a specific graphic library implementation).
        /// </summary>
        /// <param name="shader">Shader to compile.</param>
        /// <returns>Shader instance with compiled binary.</returns>
        protected override ShaderInstance CompileShader(ShaderInstance shader)
        {
            var outShader = new VKShaderInstance(base.CompileShader(shader));

            // - Gets all shader referenced assemblies
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
            var mathAsm    = typeof(System.Numerics.Vector4).Assembly.GetReferencedAssemblies();

            assemblies = assemblies.Concat(mathAsm.Select(x => Assembly.Load(x.FullName))).ToArray();
            var assemblyMeta = assemblies.Select(x => MetadataReference.CreateFromFile(x.Location));

            // - Compile the shader code obtaining an IL version
            CSharpCompilation compilation = CSharpCompilation.Create
                                            (
                "pEngine",
                syntaxTrees: new[] { CSharpSyntaxTree.ParseText(outShader.CSourceCode) },
                references: assemblyMeta,
                new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
                                            );

            // - Get the assembly class path
            string fullName = outShader.Type.FullName;

            // - We want to compile targetting GLSL450 compatible for Vulkan
            var backend = new Glsl450Backend(compilation);

            // - Prepare a GLSL compiler providing the C# IL binary
            var generator = new ShaderGenerator
                            (
                compilation, backend,
                outShader.HasVertexShader ? $"{fullName}.{shader.VertexFunctionName}" : null,
                outShader.HasFragmentShader ? $"{fullName}.{shader.FragmentFunctionName}" : null,
                outShader.HasComputeShader ? $"{fullName}.{shader.ComputeFunctionName}" : null
                            );

            // - Compile to the GLSL code
            var shaders = generator.GenerateShaders().GetOutput(backend);

            // - Stores all shader sources
            outShader.VertexSource   = outShader.HasVertexShader ? shaders.Where(x => x.VertexShaderCode != null).First().VertexShaderCode : "";
            outShader.FragmentSource = outShader.HasFragmentShader ? shaders.Where(x => x.FragmentShaderCode != null).First().FragmentShaderCode : "";
            outShader.ComputeSource  = outShader.HasComputeShader ? shaders.Where(x => x.ComputeShaderCode != null).First().ComputeShaderCode : "";

            // - This class will compile the GLSL code to the SPIR-V binary
            ShaderCompiler compiler = new ShaderCompiler();

            if (outShader.HasVertexShader)
            {
                var res = compiler.CompileToSpirV(outShader.VertexSource, ShaderCompiler.ShaderKind.VertexShader, "main");

                if (res.ErrorCount > 0)
                {
                    throw new InvalidProgramException(res.Errors);
                }

                outShader.VertexBinary = res.Binary;
            }

            if (outShader.HasFragmentShader)
            {
                var res = compiler.CompileToSpirV(outShader.FragmentSource, ShaderCompiler.ShaderKind.FragmentShader, "main");

                if (res.ErrorCount > 0)
                {
                    throw new InvalidProgramException(res.Errors);
                }

                outShader.FragmentBinary = res.Binary;
            }

            if (outShader.HasComputeShader)
            {
                var res = compiler.CompileToSpirV(outShader.ComputeSource, ShaderCompiler.ShaderKind.ComputeShader, "main");

                if (res.ErrorCount > 0)
                {
                    throw new InvalidProgramException(res.Errors);
                }

                outShader.ComputeBinary = res.Binary;
            }

            return(outShader);
        }
Example #15
0
 /// <summary>
 /// Copy constructor from base class.
 /// </summary>
 /// <param name="copy">Source class.</param>
 public VKShaderInstance(ShaderInstance copy) : base(copy)
 {
 }
Example #16
0
 public RainbowOverlay()
 {
     IoCManager.InjectDependencies(this);
     _rainbowShader = _prototypeManager.Index <ShaderPrototype>("Rainbow").InstanceUnique();
 }
 public GradientCircleMaskOverlay() : base(nameof(GradientCircleMaskOverlay))
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("GradientCircleMask").Instance();
 }
Example #18
0
 public CritOverlay()
 {
     IoCManager.InjectDependencies(this);
     _gradientCircleShader = _prototypeManager.Index <ShaderPrototype>("GradientCircleMask").Instance();
 }
 public CircleMaskOverlay() : base(nameof(SharedOverlayID.CircleMaskOverlay))
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("CircleMask").Instance();
 }
Example #20
0
 public CircleMaskOverlay()
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("CircleMask").Instance();
 }
Example #21
0
 public DebugPathfindingOverlay() : base(nameof(DebugPathfindingOverlay))
 {
     _shader        = IoCManager.Resolve <IPrototypeManager>().Index <ShaderPrototype>("unshaded").Instance();
     _eyeManager    = IoCManager.Resolve <IEyeManager>();
     _playerManager = IoCManager.Resolve <IPlayerManager>();
 }
Example #22
0
 public FlashOverlay()
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("FlashedEffect").Instance().Duplicate();
 }
 public ColoredScreenBorderOverlay()
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("ColoredScreenBorder").Instance();
 }
Example #24
0
 public BlindOverlay()
 {
     IoCManager.InjectDependencies(this);
     _greyscaleShader  = _prototypeManager.Index <ShaderPrototype>("GreyscaleFullscreen").InstanceUnique();
     _circleMaskShader = _prototypeManager.Index <ShaderPrototype>("CircleMask").InstanceUnique();
 }
Example #25
0
 public SingularityOverlay()
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("Singularity").Instance().Duplicate();
     _shader.SetParameter("maxDistance", MaxDistance * EyeManager.PixelsPerMeter);
 }
        public ParticleAcceleratorControlMenu(ParticleAcceleratorBoundUserInterface owner)
        {
            SetSize          = (400, 320);
            _greyScaleShader = IoCManager.Resolve <IPrototypeManager>().Index <ShaderPrototype>("Greyscale").Instance();

            Owner = owner;
            _drawNoiseGenerator = new NoiseGenerator(NoiseGenerator.NoiseType.Fbm);
            _drawNoiseGenerator.SetFrequency(0.5f);

            var resourceCache = IoCManager.Resolve <IResourceCache>();
            var font          = resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13);
            var panelTex      = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");

            MouseFilter = MouseFilterMode.Stop;

            _alarmControlAnimation = new Animation
            {
                Length          = TimeSpan.FromSeconds(1),
                AnimationTracks =
                {
                    new AnimationTrackControlProperty
                    {
                        Property  = nameof(Control.Visible),
                        KeyFrames =
                        {
                            new AnimationTrackProperty.KeyFrame(true,      0),
                            new AnimationTrackProperty.KeyFrame(false, 0.75f),
                        }
                    }
                }
            };

            var back = new StyleBoxTexture
            {
                Texture  = panelTex,
                Modulate = Color.FromHex("#25252A"),
            };

            back.SetPatchMargin(StyleBox.Margin.All, 10);

            var back2 = new StyleBoxTexture(back)
            {
                Modulate = Color.FromHex("#202023")
            };

            AddChild(new PanelContainer
            {
                PanelOverride = back,
                MouseFilter   = MouseFilterMode.Pass
            });

            _stateSpinBox = new SpinBox {
                Value = 0, IsValid = StrengthSpinBoxValid,
            };
            _stateSpinBox.InitDefaultButtons();
            _stateSpinBox.ValueChanged    += PowerStateChanged;
            _stateSpinBox.LineEditDisabled = true;

            _offButton = new Button
            {
                ToggleMode   = false,
                Text         = Loc.GetString("particle-accelerator-control-menu-off-button"),
                StyleClasses = { StyleBase.ButtonOpenRight },
            };
            _offButton.OnPressed += args => owner.SendEnableMessage(false);

            _onButton = new Button
            {
                ToggleMode   = false,
                Text         = Loc.GetString("particle-accelerator-control-menu-on-button"),
                StyleClasses = { StyleBase.ButtonOpenLeft },
            };
            _onButton.OnPressed += args => owner.SendEnableMessage(true);

            var closeButton = new TextureButton
            {
                StyleClasses        = { "windowCloseButton" },
                HorizontalAlignment = HAlignment.Right,
                Margin = new Thickness(0, 0, 8, 0)
            };

            closeButton.OnPressed += args => Close();

            var serviceManual = new Label
            {
                HorizontalAlignment = HAlignment.Center,
                StyleClasses        = { StyleBase.StyleClassLabelSubText },
                Text = Loc.GetString("particle-accelerator-control-menu-service-manual-reference")
            };

            _drawLabel = new Label();
            var imgSize = new Vector2(32, 32);

            AddChild(new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical,
                Children    =
                {
                    new Control
                    {
                        Margin   = new Thickness(2, 2, 0, 0),
                        Children =
                        {
                            new Label
                            {
                                Text              = Loc.GetString("particle-accelerator-control-menu-device-version-label"),
                                FontOverride      = font,
                                FontColorOverride = StyleNano.NanoGold,
                            },
                            closeButton
                        }
                    },
                    new PanelContainer
                    {
                        PanelOverride = new StyleBoxFlat        {
                            BackgroundColor = StyleNano.NanoGold
                        },
                        MinSize = (0, 2),
                    },
Example #27
0
 public NetInterpOverlay() : base(nameof(NetInterpOverlay))
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("unshaded").Instance();
 }
Example #28
0
 public SingularityOverlay()
 {
     IoCManager.InjectDependencies(this);
     _shader = _prototypeManager.Index <ShaderPrototype>("Singularity").Instance().Duplicate();
 }
 public ControlImpl(WebViewControl owner, ShaderInstance shaderInstance)
 {
     Owner           = owner;
     _shaderInstance = shaderInstance;
 }