예제 #1
0
 public void DrawBuffer(CommandBuffer buffer, Matrix4 world, Lighting lighting)
 {
     if (SideMaterials.Length < 6)
     {
         return;
     }
     if (ready)
     {
         for (int i = 0; i < 6; i++)
         {
             int     start, count;
             Vector3 pos;
             sphere.GetDrawParameters(faces[i], out start, out count, out pos);
             SideMaterials[i].Render.Camera = _camera;
             var transform = Matrix4.CreateScale(Radius) * world;
             buffer.AddCommand(
                 SideMaterials[i].Render,
                 null,
                 transform,
                 lighting,
                 sphere.VertexBuffer,
                 PrimitiveTypes.TriangleList,
                 0,
                 start,
                 count,
                 SortLayers.OBJECT
                 );
         }
         //Draw atmosphere
         if (SideMaterials.Length > 6)
         {
             var mat       = (AtmosphereMaterial)SideMaterials[6].Render;
             var transform = Matrix4.CreateScale(Radius * mat.Scale) * world;
             for (int i = 0; i < 6; i++)
             {
                 int     start, count;
                 Vector3 pos;
                 sphere.GetDrawParameters(faces[i], out start, out count, out pos);
                 SideMaterials[6].Render.Camera = _camera;
                 buffer.AddCommand(
                     SideMaterials[6].Render,
                     null,
                     transform,
                     lighting,
                     sphere.VertexBuffer,
                     PrimitiveTypes.TriangleList,
                     0,
                     start,
                     count,
                     SortLayers.OBJECT,
                     RenderHelpers.GetZ(transform, _camera.Position, pos)
                     );
             }
         }
     }
     else
     {
         throw new Exception();
     }
 }
        public void Draw(SpriteBatch spriteBatch)
        {
            RenderHelpers.DrawMenuBox(_researchArea.bounds.X, _researchArea.bounds.Y,
                                      _researchArea.bounds.Width, _researchArea.bounds.Height, out var areaInnerAnchors);

            var researchItemCellX = areaInnerAnchors.X + _researchArea.bounds.Width / 2f - Game1.tileSize / 2f;

            RenderHelpers.DrawItemBox((int)researchItemCellX, (int)areaInnerAnchors.Y + 10, Game1.tileSize,
                                      Game1.tileSize,
                                      out _);

            var researchProgressString = GetItemProgression();

            var progressFont      = Game1.smallFont;
            var progressPositionX = areaInnerAnchors.X + _researchArea.bounds.Width / 2f -
                                    progressFont.MeasureString(researchProgressString).X / 2f;

            spriteBatch.DrawString(progressFont, researchProgressString,
                                   new Vector2(progressPositionX, areaInnerAnchors.Y + Game1.tileSize + 10), Color.Black);

            var buttonTexture = ModManager.Instance.ModMode switch
            {
                ModMode.Buy => _sellTexture,
                _ => _researchTexture
            };

            spriteBatch.Draw(buttonTexture, _researchButton.bounds, _researchButton.sourceRect, Color.White);

            _researchItem?.drawInMenu(spriteBatch, new Vector2(researchItemCellX, areaInnerAnchors.Y + 10), 1f);
        }
예제 #3
0
        public void Draw(SpriteBatch spriteBatch, Item hoveredItem)
        {
            var cost = ModManager.Instance.GetItemPrice(hoveredItem);

            var costText = hoveredItem.Stack > 1 ? $"{cost * hoveredItem.Stack}({cost})" : $"{cost}";

            if (cost <= 0)
            {
                costText = "0";
            }

            var mousePos     = Game1.getMousePosition();
            var basePosition = new Vector2(mousePos.X, mousePos.Y) + new Vector2(-38, 0);

            var textOffsetX = _coinTexture.Width * Game1.pixelZoom + 5;
            var textWidth   = Game1.smallFont.MeasureString(costText).X;

            var boxWidth = textWidth + UIConstants.BorderWidth * 2 + _coinTexture.Width;

            RenderHelpers.DrawTextMenuBox((int)(basePosition.X - boxWidth), (int)(basePosition.Y - 40),
                                          Game1.smallFont, costText, textOffsetX);

            Utility.drawWithShadow(spriteBatch, _coinTexture, basePosition + new Vector2(-boxWidth + 16, -24),
                                   _coinTexture.Bounds, Color.White, 0f, Vector2.Zero, shadowIntensity: 0f);
        }
예제 #4
0
        public void Draw(SpriteBatch spriteBatch)
        {
            var textOffsetX = _coinTexture.Width * Game1.pixelZoom + 5;

            RenderHelpers.DrawTextMenuBox(_balanceArea.bounds.X, _balanceArea.bounds.Y, _width, Game1.smallFont,
                                          RenderHelpers.FillString(Game1.player._money.ToString(), "0", Game1.smallFont, _width - textOffsetX - 5, "+"),
                                          textOffsetX);

            _coin.draw(spriteBatch);
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            GetCurrentQualityIcon(out var texture, out var sourceRect, out var color);

            RenderHelpers.DrawMenuBox(_qualityButton.bounds.X, _qualityButton.bounds.Y,
                                      _qualityButton.bounds.Width - UIConstants.BorderWidth,
                                      _qualityButton.bounds.Height - UIConstants.BorderWidth, out var qualityIconPos);

            spriteBatch.Draw(texture, new Vector2(qualityIconPos.X, qualityIconPos.Y), sourceRect, color, 0,
                             Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 1f);
        }
예제 #6
0
            public DropListOption(Rectangle bounds, int index, string label, TValue value, SpriteFont font)
                : base(bounds, index.ToString(), label)
            {
                Index = index;
                Value = value;

                var labelSize = font.MeasureString(label);

                LabelWidth  = RenderHelpers.GetLabelWidth(font) - 10;
                LabelHeight = (int)labelSize.Y;
            }
예제 #7
0
        public void Draw(SpriteBatch spriteBatch)
        {
            RenderHelpers.DrawMenuBox(_searchBoxArea.bounds.X, _searchBoxArea.bounds.Y,
                                      _searchBoxArea.bounds.Width - UIConstants.BorderWidth,
                                      _searchBoxArea.bounds.Height - UIConstants.BorderWidth, out _);

            _searchBox.Draw(spriteBatch);

            spriteBatch.Draw(_searchIcon.texture, _searchIcon.bounds, _searchIcon.sourceRect,
                             Color.White * _iconOpacity);
        }
예제 #8
0
        public void DrawBuffer(CommandBuffer buffer, VMeshData data, int vertexOffset, ushort startVertex, int startIndex, Matrix4 world, ref Lighting light, MaterialAnimCollection mc, Material overrideMat = null)
        {
            if (MaterialCrc == 0)
            {
                return;
            }

            var mat = Material;

            if (mat == null)
            {
                mat = defaultMaterial;
            }
            if (overrideMat != null)
            {
                mat = overrideMat;
            }
            if (lastmc != mc)
            {
                if (mc != null)
                {
                    mc.Anims.TryGetValue(mat.Name, out ma);
                    lastmc = mc;
                }
                else
                {
                    ma = null;
                }
            }
            float z = 0;

            if (mat.Render.IsTransparent)
            {
                z = RenderHelpers.GetZ(world, mat.Render.Camera.Position, CalculateAvg(data, startVertex));
            }

            buffer.AddCommand(
                mat.Render,
                ma,
                world,
                light,
                data.VertexBuffer,
                PrimitiveTypes.TriangleList,
                startVertex + vertexOffset + StartVertex,
                startIndex + TriangleStart,
                primitiveCount,
                SortLayers.OBJECT,
                z
                );
        }
예제 #9
0
        public void Draw(SpriteBatch sprites, float opacity = 1)
        {
            foreach (var option in _options)
            {
                if (!option.visible)
                {
                    continue;
                }

                if (option.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
                {
                    sprites.Draw(CursorSprites.SpriteMap, option.bounds, CursorSprites.HoverBackground,
                                 Color.White * opacity);
                }
                else if (option.Index == _selectedOption.Index)
                {
                    sprites.Draw(CursorSprites.SpriteMap, option.bounds, CursorSprites.ActiveBackground,
                                 Color.White * opacity);
                }
                else
                {
                    sprites.Draw(CursorSprites.SpriteMap, option.bounds, CursorSprites.InactiveBackground,
                                 Color.White * opacity);
                }

                var position =
                    new Vector2(option.bounds.X + DropdownPadding, option.bounds.Y + Game1.tileSize / 16);

                sprites.DrawString(_font, RenderHelpers.TruncateString(option.label, _font, _labelWidth), position,
                                   Color.Black * opacity);
            }

            if (CanScrollUp)
            {
                _upArrow.draw(sprites, Color.White * opacity, 1);
            }

            if (CanScrollDown)
            {
                _downArrow.draw(sprites, Color.White * opacity, 1);
            }
        }
예제 #10
0
        public ItemResearchArea(IContentHelper content, IMonitor monitor, int x, int y)
        {
            // _researchTexture = content.Load<Texture2D>("assets/images/search-button.png");
            // _sellTexture = content.Load<Texture2D>("assets/images/sell-button.png");

            _researchTexture = content.Load <Texture2D>(Path.Combine("assets", "images", "search-button"));
            _sellTexture     = content.Load <Texture2D>(Path.Combine("assets", "images", "sell-button.png"));

            _researchArea = new ClickableComponent(new Rectangle(x, y, Game1.tileSize + 60, Game1.tileSize + 50), "");

            _researchButton = new ClickableTextureComponent(
                new Rectangle(
                    RenderHelpers.GetChildCenterPosition(x, _researchArea.bounds.Width + 2 * UIConstants.BorderWidth,
                                                         _researchTexture.Width),
                    _researchArea.bounds.Height + 38 + y, _researchTexture.Width,
                    _researchTexture.Height), _researchTexture,
                new Rectangle(0, 0, _researchTexture.Width, _researchTexture.Height), 1f);

            ProgressionManager.OnStackChanged += OnStackChanged;
        }
예제 #11
0
        public DropdownList(TValue selectedValue, TValue[] items, Func <TValue, string> getLabel, int x, int y,
                            SpriteFont font)
            : base(new Rectangle(), nameof(DropdownList <TValue>))
        {
            _options = items
                       .Select((i, index) => new DropListOption(Rectangle.Empty, index, getLabel(i), i, font))
                       .ToArray();

            _font       = font;
            _labelWidth = RenderHelpers.GetLabelWidth(_font);

            MaxLabelHeight = _options.Max(p => p.LabelHeight);

            var selectedIndex = Array.IndexOf(items, selectedValue);

            _selectedOption = selectedIndex >= 0 ? _options[selectedIndex] : _options.First();

            bounds.X = x;
            bounds.Y = y;

            ReinitializeComponents();
        }
예제 #12
0
        public void DrawBuffer(CommandBuffer buffer, VMeshData data, ushort startVertex, Matrix4 world, Lighting light, MaterialAnimCollection mc)
        {
            if (Material == null)
            {
                return;
            }
            if (lastmc != mc)
            {
                if (mc != null)
                {
                    mc.Anims.TryGetValue(Material.Name, out ma);
                    lastmc = mc;
                }
                else
                {
                    ma = null;
                }
            }
            float z = 0;

            if (Material.Render.IsTransparent)
            {
                z = RenderHelpers.GetZ(world, Material.Render.Camera.Position, CalculateAvg(data, startVertex));
            }

            buffer.AddCommand(
                Material.Render,
                ma,
                world,
                light,
                data.VertexBuffer,
                PrimitiveTypes.TriangleList,
                startVertex + StartVertex,
                TriangleStart,
                primitiveCount,
                SortLayers.OBJECT,
                z
                );
        }
예제 #13
0
 public void Draw(SpriteBatch spriteBatch)
 {
     RenderHelpers.DrawTextMenuBox(_sortButton.bounds.X, _sortButton.bounds.Y, Game1.smallFont,
                                   _sortButton.name, _sortTexture.Width * Game1.pixelZoom + 5);
     _sortIcon.draw(spriteBatch);
 }
 public static string RenderUserControl(ucajax.AjaxControlViewModel ajaxControlViewModel)
 {
     return(RenderHelpers.RenderUserControl(ajaxControlViewModel.ControlPath, ajaxControlViewModel.UseFormLess, ajaxControlViewModel.ControlParams, ajaxControlViewModel.ControlAssembly, ajaxControlViewModel.ControlName, HttpContext.Current));
 }
예제 #15
0
        public void DrawBeamApp(PolylineRender poly, float globalTime, NodeReference reference, ParticleEffectInstance instance, ref Matrix4x4 transform, float sparam)
        {
            //get particles!
            var beam = instance.Beams[reference.BeamIndex];
            if (beam.ParticleCount < 2) { beam.ParticleCount = 0;  return; }
            AgeComparer.Instance.Particles = instance.Pool.Particles;
            Array.Sort(beam.ParticleIndices, 0, beam.ParticleCount, AgeComparer.Instance);
            //draw
            var node_tr = GetAttachment(reference, transform);
            Texture2D tex;
            Vector2 tl, tr, bl, br;
            var res = instance.Resources;
            TextureHandler.Update(Texture, res);
            var frame = GetFrame(globalTime, sparam, ref instance.Pool.Particles[beam.ParticleIndices[0]]);
            int index = (int) Math.Floor((TextureHandler.FrameCount - 1) * frame) * 4;
            tl = TextureHandler.Coordinates[index];
            tr = TextureHandler.Coordinates[index + 1];
            bl = TextureHandler.Coordinates[index + 2];
            br = TextureHandler.Coordinates[index + 3];
            //Sorting hack kinda
            var z = RenderHelpers.GetZ(instance.Pool.Camera.Position, Vector3.Transform(Vector3.Zero, node_tr));
            for (int j = 0; j < 2; j++) //two planes
            {
                poly.StartLine(TextureHandler.Texture ?? res.WhiteTexture, BlendInfo);
                bool odd = true;
                Vector3 dir = Vector3.Zero;

                for (int i = 0; i < beam.ParticleCount; i++)
                {
                    var pos = Vector3.Transform(instance.Pool.Particles[beam.ParticleIndices[i]].Position, node_tr);
                    if (i + 1 < beam.ParticleCount) {
                        var pos2 = Vector3.Transform(instance.Pool.Particles[beam.ParticleIndices[i + 1]].Position, node_tr);
                        var forward = (pos2 - pos).Normalized();
                        var toCamera = (instance.Pool.Camera.Position - pos).Normalized();
                        var up = Vector3.Cross(toCamera, forward);
                        up.Normalize();
                        dir = up;
                        if (j == 1)
                        {
                            //Broken? Doesn't show up
                            var right = Vector3.Cross(up, forward).Normalized();
                            dir = right;
                        }
                    }
                    var time = instance.Pool.Particles[beam.ParticleIndices[i]].TimeAlive / instance.Pool.Particles[beam.ParticleIndices[i]].LifeSpan;
                    var w = Width.GetValue(sparam, time);
                    poly.AddPoint(
                        pos + (dir * w / 2),
                        pos - (dir * w / 2),
                        odd ? tl : bl,
                        odd ? tr : br,
                        new Color4(
                            Color.GetValue(sparam, time),
                            Alpha.GetValue(sparam, time)
                        )
                    );
                    odd = !odd;
                }
                poly.FinishLine(z);
            }
            beam.ParticleCount = 0;
        }
예제 #16
0
        public unsafe void DrawBeamApp(PolylineRender poly, LineBuffer points, float globalTime, NodeReference reference, ParticleEffectInstance instance, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam)
        {
            //TODO: Cross-plane not showing
            //TODO: In some cases particles are going backwards? (Broken emitter or LineBuffer)
            //TODO: See if z sorting can be better for Polyline
            //TODO: Implement FLBeamAppearance properties
            if (points.Count() < 2)
            {
                return;
            }
            //Get only active indices, alloc on stack for 0 GC pressure
            //int* indices = stackalloc int[512];
            var indices   = new int[512];
            var particles = new Particle[512];

            for (int i = 0; i < 512; i++)
            {
                indices[i] = -1;
            }
            int ptCount = 0;

            for (int i = 0; i < points.Count(); i++)
            {
                if (points[i].Active)
                {
                    indices[ptCount++] = points[i].ParticleIndex;
                }
            }
            if (ptCount < 2)
            {
                return;
            }
            for (int i = 0; i < ptCount; i++)
            {
                particles[i] = instance.Particles[indices[i]];
            }
            for (int i = 1; i < ptCount; i++)
            {
                if (particles[i - 1].TimeAlive > particles[i].TimeAlive)
                {
                    Console.WriteLine("bad order");
                }
            }
            var       node_tr = GetAttachment(reference, transform);
            Texture2D tex;
            Vector2   tl, tr, bl, br;

            HandleTexture(res, globalTime, sparam, ref instance.Particles[indices[0]], out tex, out tl, out tr, out bl, out br);
            //Sorting hack kinda
            var z = RenderHelpers.GetZ(billboards.Camera.Position, node_tr.Transform(Vector3.Zero));

            for (int j = 0; j < 2; j++)             //two planes
            {
                poly.StartLine(tex, BlendInfo);
                bool    odd = true;
                Vector3 dir = Vector3.Zero;

                for (int i = 0; i < ptCount; i++)
                {
                    var pos = node_tr.Transform(instance.Particles[indices[i]].Position);
                    if (i + 1 < ptCount)
                    {
                        var pos2     = node_tr.Transform(instance.Particles[indices[i + 1]].Position);
                        var forward  = (pos2 - pos).Normalized();
                        var toCamera = (billboards.Camera.Position - pos).Normalized();
                        var up       = Vector3.Cross(toCamera, forward);
                        up.Normalize();
                        dir = up;
                        if (j == 1)
                        {
                            //Broken? Doesn't show up
                            var right = Vector3.Cross(up, forward).Normalized();
                            dir = right;
                        }
                    }
                    var time = instance.Particles[indices[i]].TimeAlive / instance.Particles[indices[i]].LifeSpan;
                    var w    = Width.GetValue(sparam, time);
                    poly.AddPoint(
                        pos + (dir * w / 2),
                        pos - (dir * w / 2),
                        odd ? tl : bl,
                        odd ? tr : br,
                        new Color4(
                            Color.GetValue(sparam, time),
                            Alpha.GetValue(sparam, time)
                            )
                        );
                    odd = !odd;
                }
                poly.FinishLine(z);
            }
        }
예제 #17
0
 public void DrawBuffer(CommandBuffer buffer, Matrix4 world, ref Lighting lighting, Material overrideMat = null)
 {
     if (SideMaterials.Length < 6)
     {
         return;
     }
     if (ready)
     {
         for (int i = 0; i < SideMaterials.Length; i++)
         {
             if (SideMaterials[i] != null && !SideMaterials[i].Loaded)
             {
                 SideMaterials[i].Loaded = false;
             }
         }
         for (int i = 0; i < 6; i++)
         {
             int     start, count;
             Vector3 pos;
             sphere.GetDrawParameters(faces[i], out start, out count, out pos);
             if (SideMaterials[i] == null)
             {
                 SideMaterials[i] = library.FindMaterial(CrcTool.FLModelCrc(sideMaterialNames[i]));
             }
             var mat = SideMaterials[i] ?? defaultMaterial;
             mat = overrideMat ?? mat;
             mat.Render.Camera = _camera;
             var transform = Matrix4.CreateScale(Radius) * world;
             buffer.AddCommand(
                 mat.Render,
                 null,
                 transform,
                 lighting,
                 sphere.VertexBuffer,
                 PrimitiveTypes.TriangleList,
                 0,
                 start,
                 count,
                 SortLayers.OBJECT
                 );
         }
         //Draw atmosphere
         if (SideMaterials.Length > 6 && overrideMat == null)
         {
             if (SideMaterials[6] == null)
             {
                 SideMaterials[6] = library.FindMaterial(CrcTool.FLModelCrc(sideMaterialNames[6]));
                 if (SideMaterials[6] == null)
                 {
                     return;
                 }
             }
             var mat       = (AtmosphereMaterial)SideMaterials[6].Render;
             var transform = Matrix4.CreateScale(Radius * mat.Scale) * world;
             for (int i = 0; i < 6; i++)
             {
                 int     start, count;
                 Vector3 pos;
                 sphere.GetDrawParameters(faces[i], out start, out count, out pos);
                 SideMaterials[6].Render.Camera = _camera;
                 buffer.AddCommand(
                     SideMaterials[6].Render,
                     null,
                     transform,
                     lighting,
                     sphere.VertexBuffer,
                     PrimitiveTypes.TriangleList,
                     0,
                     start,
                     count,
                     SortLayers.OBJECT,
                     RenderHelpers.GetZ(transform, _camera.Position, pos)
                     );
             }
         }
     }
     else
     {
         throw new Exception();
     }
 }