コード例 #1
0
ファイル: EllipseHelper.cs プロジェクト: fel88/GeomPad
        public override void Draw(IDrawingContext ctx)
        {
            if (!Visible)
            {
                return;
            }
            if (ShowLocation)
            {
                DrawHelpers.DrawCross(Location, DrawSize);
            }
            if (ShowAux)
            {
                DrawHelpers.DrawCross(AuxPoint, DrawSize);
            }

            GL.Color3(Color.Blue);
            if (Selected)
            {
                GL.Color3(Color.Red);
            }
            GL.Begin(PrimitiveType.Lines);
            var pnts = GetPointsD();

            for (int i = 1; i < pnts.Length; i++)
            {
                var pp0 = pnts[i - 1];
                var pp1 = pnts[i];
                GL.Vertex3(pp0);
                GL.Vertex3(pp1);
            }
            GL.End();
        }
コード例 #2
0
        public void DrawToolTips(SpriteBatch b)
        {
            if (IsEmptyMenu)
            {
                return;
            }

            if (HoveredSlot.HasValue)
            {
                Object HoveredItem = GetHoveredItem();
                if (HoveredItem != null)
                {
                    Rectangle Location;
                    if (IsNavigatingWithGamepad)
                    {
                        Location = HoveredSlot.Value; //new Rectangle(HoveredSlot.Value.Right, HoveredSlot.Value.Bottom, 1, 1);
                    }
                    else
                    {
                        Location = new Rectangle(Game1.getMouseX() - 8, Game1.getMouseY() + 36, 8 + 36, 1);
                    }
                    DrawHelpers.DrawToolTipInfo(b, Location, HoveredItem, true, true, true, true, true, true, Bag.MaxStackSize);
                }
            }
        }
コード例 #3
0
        public static void Postfix(SObject __instance, SpriteBatch spriteBatch, int x, int y, float alpha)
        {
            try
            {
                if (__instance.TryGetCombinedQuantity(out int CombinedQuantity) && CombinedQuantity > 1)
                {
                    float Transparency = alpha * ModEntry.UserConfig.NumberOpacity;
                    if (Transparency > 0f)
                    {
                        Color RenderColor = Color.White * Transparency;

                        float draw_layer      = GetTileDrawLayerDepth(x, y);
                        float DrawLayerOffset = 1E-05f; // The SpriteBatch LayerDepth needs to be slightly larger than the layer depth used for the bigCraftable texture to avoid z-fighting

                        Vector2 TopLeftTilePosition     = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * Game1.tileSize, y * Game1.tileSize));
                        Vector2 BottomRightTilePosition = Game1.GlobalToLocal(Game1.viewport, new Vector2((x + 1) * Game1.tileSize - 1, (y + 1) * Game1.tileSize - 1));

                        float   Scale                   = 3.0f;
                        float   QuantityWidth           = DrawHelpers.MeasureNumber(CombinedQuantity, Scale);
                        Vector2 QuantityTopLeftPosition = new Vector2(BottomRightTilePosition.X - QuantityWidth, BottomRightTilePosition.Y - DrawHelpers.TinyDigitBaseHeight - Game1.tileSize / 8);
                        Utility.drawTinyDigits(CombinedQuantity, spriteBatch, QuantityTopLeftPosition, Scale, draw_layer + DrawLayerOffset, RenderColor);
                    }
                }
            }
            catch (Exception ex)
            {
                ModEntry.Logger.Log(string.Format("Unhandled Error in {0}.{1}:\n{2}", nameof(DrawPatch), nameof(Postfix), ex), LogLevel.Error);
            }
        }
コード例 #4
0
        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            bool flip          = false;
            int  lineThickness = 2;

            // result point rows.
            for (int y = 0; y < _numOfCurvatureSegmentPoints - 1; y++)
            {
                for (int x = 0; x < _numOfCurvatureSegmentPoints - 1; x++)
                {
                    var index  = _numOfCurvatureSegmentPoints * y + x;
                    var index2 = _numOfCurvatureSegmentPoints * y + x + 1;
                    var index3 = _numOfCurvatureSegmentPoints * y + x + _numOfCurvatureSegmentPoints;
                    var col    = Color.Black;
                    if (flip)
                    {
                        col = Color.Green;
                    }
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[index]), ToVector2(curveLinePoints[index2]), lineThickness, col);
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[index]), ToVector2(curveLinePoints[index3]), lineThickness, col);
                    flip = !flip;
                }
            }

            for (int y = 0; y < cpHeight; y++)
            {
                for (int x = 0; x < cpWidth; x++)
                {
                    int index = y * cpWidth + x;
                    DrawHelpers.DrawBasicPoint(new Vector2(cps[index].X, cps[index].Y), 4, Color.Red);
                }
            }
        }
コード例 #5
0
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            _spriteBatch.Begin();

            bool flip = false;

            for (int i = 0; i < curveLinePoints.Length - 1; i++)
            {
                if (flip)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Green);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Black);
                }
                flip = !flip;
            }

            for (int i = 0; i < cp.Length; i++)
            {
                DrawHelpers.DrawBasicPoint(new Vector2(cp[i].X, cp[i].Y), Color.Red);
            }

            //_spriteBatch.DrawString(_font, " time " + t, new Vector2(10, 10), Color.Black);

            _spriteBatch.End();
        }
        protected override void Draw(GameTime gameTime)
        {
            this.GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();

            curve.DrawWithSpriteBatch(_spriteBatch, _font, gameTime);

            if (isMouseNearCp)
            {
                var col = Color.Blue;
                if (selectedCp == mouseNearCpNumber)
                {
                    col = Color.Red;
                }
                DrawHelpers.DrawCrossHair(new Vector2(_wayPoints[mouseNearCpNumber].X, _wayPoints[mouseNearCpNumber].Y), 15, col);
            }

            var p = new Vector2(positionWeightAtCycledTime.X, positionWeightAtCycledTime.Y);

            DrawHelpers.DrawCrossHair(p, 5, Color.White);
            _spriteBatch.DrawString(_font, $" pos X:{p.X.ToString("###0.00")}, Y:{p.Y.ToString("###0.00")}\n weight: {positionWeightAtCycledTime.W.ToString("####0.000")}", p + new Vector2(0, 20), Color.White);

            _spriteBatch.DrawString(_font, msg, new Vector2(10, 5), Color.White);

            _spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #7
0
        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            bool flip = false;

            for (int i = 0; i < curveLinePoints.Length - 1; i++)
            {
                if (flip)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Green);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Black);
                }

                if (i < 3)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), 1, Color.Yellow);
                }

                flip = !flip;
            }

            for (int i = 0; i < artificialCpLine.Count - 1; i += 2)
            {
                DrawHelpers.DrawBasicLine(new Vector2(artificialCpLine[i].X, artificialCpLine[i].Y), new Vector2(artificialCpLine[i + 1].X, artificialCpLine[i + 1].Y), 1, Color.Purple);
            }

            for (int i = 0; i < cp.Length; i++)
            {
                DrawHelpers.DrawBasicPoint(new Vector2(cp[i].X, cp[i].Y), Color.Red);
            }
        }
コード例 #8
0
 protected override void LoadContent()
 {
     _spriteBatch = new SpriteBatch(GraphicsDevice);
     _font        = Content.Load <SpriteFont>("MgGenFont");
     _dot         = CreateDotTexture(GraphicsDevice, Color.White);
     curve        = new Curve_BezierSplineWeighted(_wayPoints, 0.5f, isCurveClosed);
     DrawHelpers.Initialize(GraphicsDevice, _spriteBatch, null);
 }
コード例 #9
0
        public void Draw(SpriteBatch b)
        {
            if (IsEmptyMenu)
            {
                return;
            }

            //b.Draw(TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, Color.Cyan), Bounds, Color.White);

            //  Draw the backgrounds of each slot
            foreach (Rectangle LockedSlot in LockedSlotBounds)
            {
                b.Draw(Game1.menuTexture, LockedSlot, new Rectangle(64, 896, 64, 64), Color.White);
            }
            foreach (Rectangle UnlockedSlot in SlotBounds)
            {
                b.Draw(Game1.menuTexture, UnlockedSlot, new Rectangle(128, 128, 64, 64), Color.White);
            }

            //  Draw the items of each slot
            for (int i = 0; i < SlotBounds.Count; i++)
            {
                Rectangle Destination = SlotBounds[i];

                //  Draw a thin yellow border if mouse is hovering this slot
                bool IsHovered = Destination == HoveredSlot;
                if (IsHovered)
                {
                    Color     HighlightColor = Color.Yellow;
                    Texture2D Highlight      = TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, HighlightColor);
                    b.Draw(Highlight, Destination, Color.White * 0.25f);

                    int BorderThickness = Destination.Width / 16;
                    DrawHelpers.DrawBorder(b, Destination, BorderThickness, HighlightColor);
                }

                Object CurrentItem = PlaceholderItems[i];

                float IconScale = IsHovered ? 1.25f : 1.0f;
                Color Overlay   = CurrentItem.Stack == 0 ? Color.White * 0.30f : Color.White;
                DrawHelpers.DrawItem(b, Destination, CurrentItem, CurrentItem.Stack > 0, true, IconScale, 1.0f, Overlay, CurrentItem.Stack >= Bag.MaxStackSize ? Color.Red : Color.White);

                OnItemSlotRendered?.Invoke(this, new ItemSlotRenderedEventArgs(b, Destination, CurrentItem, IsHovered));
            }

            foreach (Rectangle LockedSlot in LockedSlotBounds)
            {
                if (HoveredSlot == LockedSlot)
                {
                    Color     HighlightColor = Color.Yellow;
                    Texture2D Highlight      = TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, HighlightColor);
                    b.Draw(Highlight, LockedSlot, Color.White * 0.25f);

                    int BorderThickness = LockedSlot.Width / 16;
                    DrawHelpers.DrawBorder(b, LockedSlot, BorderThickness, HighlightColor);
                }
            }
        }
コード例 #10
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _font        = Content.Load <SpriteFont>("MgGenFont");
            _dot         = CreateDotTexture(GraphicsDevice, Color.White);
            DrawHelpers.Initialize(GraphicsDevice, _spriteBatch, null);

            mesh = new Mesh_BwtPrimitive(meshPoints, cpWidth, cpHeight, numOfPoints, isCurveClosed, isUniformedUsed, numOfIntegrationSteps);
        }
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _font        = Content.Load <SpriteFont>("MgGenFont");
            _dot         = CreateDotTexture(GraphicsDevice, Color.White);
            DrawHelpers.Initialize(GraphicsDevice, _spriteBatch, null);

            curve = new Curve_BezierRecalculatingCps(_wayPoints, numOfPoints, isCurveClosed, isUniformedUsed);
            curve._showTangents = showGeneratedTangentsPositions;
        }
コード例 #12
0
		public void DrawToggler( SpriteBatch sb ) {
			Vector2 pos, size;
			Color bodyColor = HonorBoundUI.ButtonBodyColor;
			Color edgeColor = HonorBoundUI.ButtonEdgeColor;

			if( this.IsTogglerLit ) { bodyColor = HonorBoundUI.ButtonBodyLitColor; }
			this.GetTogglerDimensions( out pos, out size );
			
			DrawHelpers.DrawBorderedRect( sb, bodyColor, edgeColor, pos, size, 2 );
		}
コード例 #13
0
ファイル: Director.cs プロジェクト: weimingtom/Sakura
 private Director(uint sprites_capacity, uint draw_helpers_capacity, GraphicsContext context)
 {
     this.m_paused                = false;
     this.m_frame_timer           = new Timer();
     this.m_run_with_scene_called = false;
     this.m_elapsed               = 0.0;
     this.GL                       = new GraphicsContextAlpha(context);
     this.DrawHelpers              = new DrawHelpers(this.GL, draw_helpers_capacity);
     this.SpriteRenderer           = new SpriteRenderer(this.GL, 6u * sprites_capacity);
     this.m_canceled_replace_scene = new HashSet <Scene>();
 }
コード例 #14
0
        public void Draw(SpriteBatch b)
        {
            //b.Draw(TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, Color.Red), ContentsBounds, Color.White);

            if (HorizontalSeparatorPosition.HasValue)
            {
                DrawHelpers.DrawHorizontalSeparator(b, HorizontalSeparatorPosition.Value);
            }
            GroupedOptions.Draw(b);
            UngroupedOptions.Draw(b);
        }
コード例 #15
0
        protected override void Draw(GameTime gameTime)
        {
            this.GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();
            curve.DrawWithSpriteBatch(_spriteBatch, _font, gameTime);
            DrawHelpers.DrawCrossHair(positionAtCycledTime.ToVector2(), 5, Color.White);
            _spriteBatch.DrawString(_font, msg, new Vector2(10, 5), Color.White);
            _spriteBatch.End();

            base.Draw(gameTime);
        }
コード例 #16
0
        public void Draw(SpriteBatch b)
        {
            //b.Draw(TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, Color.Cyan), Bounds, Color.White);

            //  Draw the backgrounds of each slot
            for (int i = 0; i < SlotBounds.Count; i++)
            {
                if (i < Placeholders.Count)
                {
                    b.Draw(Game1.menuTexture, SlotBounds[i], new Rectangle(128, 128, 64, 64), Color.White);
                }
                else if (ShowLockedSlots)
                {
                    b.Draw(Game1.menuTexture, SlotBounds[i], new Rectangle(64, 896, 64, 64), Color.White);
                }
            }

            //  Draw the items of each slot
            for (int i = 0; i < SlotBounds.Count; i++)
            {
                if (i < Placeholders.Count)
                {
                    Rectangle Destination = SlotBounds[i];

                    //  Draw a thin yellow border if mouse is hovering this slot
                    bool IsHovered = Destination == HoveredSlot;
                    if (IsHovered)
                    {
                        Color     HighlightColor = Color.Yellow;
                        Texture2D Highlight      = TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, HighlightColor);
                        b.Draw(Highlight, Destination, Color.White * 0.25f);

                        int BorderThickness = Destination.Width / 16;
                        DrawHelpers.DrawBorder(b, Destination, BorderThickness, HighlightColor);
                    }

                    float IconScale = IsHovered ? 1.25f : 1.0f;
                    if (ActualContents[i] != null)
                    {
                        ItemBag CurrentItem = ActualContents[i];
                        DrawHelpers.DrawItem(b, Destination, CurrentItem, CurrentItem.Stack > 0, true, IconScale, 1f, Color.White, CurrentItem.Stack >= Bag.MaxStackSize ? Color.Red : Color.White);
                    }
                    else
                    {
                        ItemBag CurrentItem = Placeholders[i];
                        DrawHelpers.DrawItem(b, Destination, CurrentItem, CurrentItem.Stack > 0, true, IconScale, 0.35f, Color.White * 0.3f, CurrentItem.Stack >= Bag.MaxStackSize ? Color.Red : Color.White);
                    }
                }
            }
        }
コード例 #17
0
        public void DrawToolTips(SpriteBatch b)
        {
            //  Draw tooltips on the hovered item inside the bag
            if (HoveredSlot.HasValue)
            {
                Object HoveredItem = GetHoveredItem();
                if (HoveredItem != null)
                {
                    Rectangle Location;
                    if (IsNavigatingWithGamepad)
                    {
                        Location = HoveredSlot.Value; //new Rectangle(HoveredSlot.Value.Right, HoveredSlot.Value.Bottom, 1, 1);
                    }
                    else
                    {
                        Location = new Rectangle(Game1.getMouseX() - 8, Game1.getMouseY() + 36, 8 + 36, 1);
                    }
                    DrawHelpers.DrawToolTipInfo(b, Location, HoveredItem, true, true, true, true, true, true, Bag.MaxStackSize);
                }
            }

            //  Draw tooltips on the sidebar buttons
            if (IsRightSidebarVisible && HoveredContentsButton.HasValue)
            {
                string ButtonToolTip = "";
                if (HoveredContentsButton.Value == ContentsSidebarButton.SortingProperty)
                {
                    ButtonToolTip = ItemBagsMod.Translate(string.Format("RucksackSortProperty{0}ToolTip", Rucksack.SortProperty.ToString()));
                }
                else if (HoveredContentsButton.Value == ContentsSidebarButton.SortingOrder)
                {
                    if (Rucksack.SortOrder == SortingOrder.Ascending)
                    {
                        ButtonToolTip = ItemBagsMod.Translate("RucksackSortOrderAscendingToolTip");
                    }
                    else if (Rucksack.SortOrder == SortingOrder.Descending)
                    {
                        ButtonToolTip = ItemBagsMod.Translate("RucksackSortOrderDescendingToolTip");
                    }
                }

                if (!string.IsNullOrEmpty(ButtonToolTip))
                {
                    int     Margin      = 16;
                    Vector2 ToolTipSize = Game1.smallFont.MeasureString(ButtonToolTip);
                    DrawHelpers.DrawBox(b, HoveredContentsButtonBounds.Value.Left - (int)(ToolTipSize.X + Margin * 2), HoveredContentsButtonBounds.Value.Top, (int)(ToolTipSize.X + Margin * 2), (int)(ToolTipSize.Y + Margin * 2));
                    b.DrawString(Game1.smallFont, ButtonToolTip, new Vector2(HoveredContentsButtonBounds.Value.Left - Margin - ToolTipSize.X, HoveredContentsButtonBounds.Value.Top + Margin), Color.Black);
                }
            }
        }
コード例 #18
0
        public static void Postfix(InventoryMenu __instance, SpriteBatch b, int red, int green, int blue)
        {
            try
            {
                //  Draw a yellow border around other items in your inventory that the current CursorSlotItem can be combined with
                if (Game1.activeClickableMenu is GameMenu GM && GM.currentTab == GameMenu.inventoryTab)
                {
                    if (ModEntry.IsCombineKeyHeld(ModEntry.ModInstance.Helper.Input) && Game1.player.CursorSlotItem is SObject SourceObject)
                    {
                        InventoryPage InvPage = GM.pages.First(x => x is InventoryPage) as InventoryPage;
                        InventoryMenu InvMenu = InvPage.inventory;
                        if (InvMenu == __instance)
                        {
                            for (int i = 0; i < InvMenu.capacity; i++)
                            {
                                if (InvMenu.actualInventory.Count > i && InvMenu.inventory.Count > i &&
                                    InvMenu.actualInventory[i] is SObject TargetObject && ModEntry.CanCombine(SourceObject, TargetObject))
                                {
                                    Rectangle InventorySlotBounds = InvMenu.inventory[i].bounds;

                                    DrawHelpers.DrawBorder(b, InventorySlotBounds, 4, Color.Yellow);

                                    //  Since our border is now drawn on top of everything else that was already drawn by this InventoryMenu, re-draw the stack size to appear overtop of the border
                                    Vector2 Location  = new Vector2(InventorySlotBounds.X, InventorySlotBounds.Y);
                                    float   ScaleSize = 1.0f;
                                    if (TargetObject.IsCombinedMachine())
                                    {
                                        DrawInMenuPatch.DrawCombinedStack(TargetObject, b, Location, ScaleSize, 1.0f, Color.White);
                                    }
                                    else if (TargetObject.Stack > 1)
                                    {
                                        //  Code mostly taken from decompiled code: StardewValley.Object.drawInMenu
                                        Vector2 StackPosition = Location + new Vector2((float)(64 - Utility.getWidthOfTinyDigitString(TargetObject.stack, 3f * ScaleSize)) + 3f * ScaleSize, 64f - 18f * ScaleSize + 1f);
                                        Utility.drawTinyDigits(TargetObject.stack, b, StackPosition, 3f * ScaleSize, 1f, Color.White);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ModEntry.Logger.Log(string.Format("Unhandled Error in {0}.{1}:\n{2}", nameof(InventoryMenuDrawPatch), nameof(Postfix), ex), LogLevel.Error);
            }
        }
コード例 #19
0
        public void DrawSelf(SpriteBatch spriteBatch)
        {
            if (Killer == null || Victim == null)
            {
                return;
            }

            Vector2 position = Position;

            Texture2D tex = Textures.KillFeedEntry;

            Texture2D texScar = Textures.SCAREntryIcon;

            float offX = Killer.Length * 10;

            float offsetX = 94;

            Color borderColor = Main.LocalPlayer.name == Killer ? Color.Red * 0.9f : Color.Black * 0.9f;

            DrawHelpers.DrawBorderedRectangle(position, (int)Width, (int)Height, Color.Black * 0.8f * Opacity, borderColor * Opacity, spriteBatch);

            spriteBatch.Draw(texScar, position + new Vector2(20 + offX + 10, 5), null, Color.White * Opacity, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);

            if (NoScope)
            {
                spriteBatch.Draw(tex, position + new Vector2(20 + offX + offsetX, 5), new Rectangle(0, 80, 40, 40), Color.White * Opacity, 0f, Vector2.Zero, 0.75f, SpriteEffects.None, 1f);
                offsetX += 34;
            }

            if (WallBang)
            {
                spriteBatch.Draw(tex, position + new Vector2(20 + offX + offsetX, 6), new Rectangle(0, 40, 40, 40), Color.White * Opacity, 0f, Vector2.Zero, 0.75f, SpriteEffects.None, 1f);
                offsetX += 32;
            }

            if (Headshot)
            {
                spriteBatch.Draw(tex, position + new Vector2(20 + offX + offsetX, 6), new Rectangle(0, 0, 40, 40), Color.White * Opacity, 0f, Vector2.Zero, 0.75f, SpriteEffects.None, 1f);
                offsetX += 44;
            }

            spriteBatch.DrawString(Main.fontMouseText, Killer, position + new Vector2(10, 10), Color.White * Opacity);

            spriteBatch.DrawString(Main.fontMouseText, Victim, position + new Vector2(offX + 20 + offsetX, 10), Color.White * Opacity);
        }
コード例 #20
0
        public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, StackDrawType drawStackNumber, Color color, bool drawShadow)
        {
            spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(32f, 32f), GetPrimaryIconSourceRect(2), GetPrimaryIconColor() * transparency, 0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth);

            if (drawStackNumber != StackDrawType.Hide)
            {
                float   QuantityScale       = 2.7f * scaleSize;
                int     NumDigits           = DrawHelpers.GetNumDigits(Stack);
                Vector2 BottomRightPosition = new Vector2(location.X + 64f - DrawHelpers.MeasureNumber(Stack, QuantityScale),
                                                          location.Y + 64f - DrawHelpers.TinyDigitBaseHeight * QuantityScale);
                Utility.drawTinyDigits(Stack, spriteBatch, BottomRightPosition, QuantityScale, 0f, Color.White);
            }

            float   Offset             = (64f - 64f * scaleSize) / 2f;
            Vector2 BottomLeftPosition = new Vector2(location.X + Offset, location.Y + 64f + Offset);

            DrawIcon(spriteBatch, AugmentorType, BottomLeftPosition, scaleSize, transparency, 1f);
        }
コード例 #21
0
        private Rectangle[] DrawPageTicks(SpriteBatch sb)
        {
            Player plr = Main.LocalPlayer;

            if (plr == null || !plr.active)
            {
                return(new Rectangle[0]);                   //?
            }

            var mymod    = ExtensibleInventoryMod.Instance;
            var myplayer = TmlHelpers.SafelyGetModPlayer <ExtensibleInventoryPlayer>(plr);

            var pos      = new Vector2(mymod.Config.PageTicksPositionXCoord, mymod.Config.PageTicksPositionYCoord);
            int pages    = myplayer.Library.CurrentBook.CountPages();
            int maxPages = pages > 29 ? 28 : pages;
            var rects    = new Rectangle[pages];

            var unsharedColor = new Color(192, 192, 192);
            var sharedColor   = new Color(128, 255, 32);

            for (int i = 0; i < maxPages; i++)
            {
                bool isCurrPage = i == myplayer.Library.CurrentBook.CurrentPageIdx;
                bool isShared   = myplayer.Library.CurrentBook.IsPageSharing(i);

                var  rect       = new Rectangle((int)(pos.X + (i * 16)), (int)pos.Y, 13, 4);
                bool isHovering = rect.Contains(Main.mouseX, Main.mouseY);

                Color fillColor = new Color(128, 128, 256) * myplayer.Library.CurrentBook.GaugePageFullness(i);
                Color bordColor = (isShared ? sharedColor : unsharedColor) * (isHovering ? 1f : 0.65f);
                int   thickness = isCurrPage ? 2 : 1;

                DrawHelpers.DrawBorderedRect(sb, fillColor, bordColor, rect, thickness);

                rects[i] = rect;
            }

            if (pages != maxPages)
            {
                sb.DrawString(Main.fontMouseText, "...", new Vector2(pos.X + (28 * 16), pos.Y - 12f), Color.White);
            }

            return(rects);
        }
コード例 #22
0
        public void Update()
        {
            var center   = Center.transform.position.TakeXZ();
            var dir      = (End.position - Center.position).normalized.TakeXZ();
            var dist     = (End.position - Center.position).magnitude;
            var obstacle = new Rect(ObstacleStart.position.TakeXZ(), (ObstacleEnd.position - ObstacleStart.position).TakeXZ());

            var rect = new OrientedRect(center, dir, dist, Width);


            var hit = Collision2DHelper.Intersects(obstacle, rect);



            DrawHelpers.DrawRect(rect, hit ? Color.red : Color.green);

            DrawHelpers.DrawRect(obstacle, Color.blue);
            DrawHelpers.DrawRect(rect.GetAABB(), Color.black);
        }
コード例 #23
0
        public void DrawWithSpriteBatch(SpriteBatch _spriteBatch, GameTime gameTime)
        {
            bool flip          = false;
            int  lineThickness = 2;

            //if (_showTangents)
            //{
            //    for (int i = 0; i < artificialCpLine.Count - 1; i += 2)
            //    {
            //        DrawHelpers.DrawBasicLine(new Vector2(artificialCpLine[i].X, artificialCpLine[i].Y), new Vector2(artificialCpLine[i + 1].X, artificialCpLine[i + 1].Y), 1, Color.Purple);
            //    }

            //    for (int i = 0; i < artificialCpLine.Count - 1; i += 2)
            //    {
            //        DrawHelpers.DrawBasicLine(new Vector2(artificialTangentLine[i].X, artificialTangentLine[i].Y), new Vector2(artificialTangentLine[i + 1].X, artificialTangentLine[i + 1].Y), 1, Color.Pink);
            //    }
            //}

            for (int i = 0; i < cps.Length; i++)
            {
                DrawHelpers.DrawBasicPoint(new Vector2(cps[i].position.X, cps[i].position.Y), 4, Color.Red);
            }

            for (int i = 0; i < curveLinePoints.Length - 1; i++)
            {
                if (flip)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), lineThickness, Color.Green);
                }
                else
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), lineThickness, Color.Black);
                }

                if (i < 1)
                {
                    DrawHelpers.DrawBasicLine(ToVector2(curveLinePoints[i]), ToVector2(curveLinePoints[i + 1]), lineThickness, Color.Yellow);
                }

                flip = !flip;
            }
        }
コード例 #24
0
        public void DrawToolTips(SpriteBatch b)
        {
            //  Draw tooltips on the hovered item inside the bag
            if (HoveredSlot.HasValue)
            {
                ItemBag HoveredBag = GetHoveredBag();
                if (HoveredBag == null)
                {
                    int Index = SlotBounds.IndexOf(HoveredSlot.Value);
                    if (Index >= 0 && Index < Placeholders.Count)
                    {
                        HoveredBag = Placeholders[Index];
                    }
                }

                if (HoveredBag != null)
                {
                    Rectangle Location;
                    if (IsNavigatingWithGamepad)
                    {
                        Location = HoveredSlot.Value; //new Rectangle(HoveredSlot.Value.Right, HoveredSlot.Value.Bottom, 1, 1);
                    }
                    else
                    {
                        Location = new Rectangle(Game1.getMouseX() - 8, Game1.getMouseY() + 36, 8 + 36, 1);
                    }

                    //if (HoveredBag is Rucksack RS)
                    //{
                    //    int XPos = Location.Right;
                    //    int YPos = Location.Bottom;
                    //    RS.drawTooltip(b, ref XPos, ref YPos, Game1.smallFont, 1f, RS.Description);
                    //}
                    //else
                    //{
                    //    DrawHelpers.DrawToolTipInfo(b, Location, HoveredBag, true, true, true, true, true, Bag.MaxStackSize);
                    //}

                    DrawHelpers.DrawToolTipInfo(b, Location, HoveredBag, true, true, true, true, true, true, Bag.MaxStackSize);
                }
            }
        }
コード例 #25
0
        public void PostSCARDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
        {
            if (Main.LocalPlayer.whoAmI == Main.myPlayer)
            {
                TBAPlayer standUser = TBAPlayer.Get(Main.LocalPlayer);


                if (standUser.Stand is SREKTStand && standUser.StandActive)
                {
                    int maxHeight = (npc.life * npc.height) / npc.lifeMax;


                    if (standUser.ActiveStandProjectile is SREKTStand stand && stand.Wallhack)
                    {
                        DrawHelpers.DrawBorderedRectangle(npc.position - Main.screenPosition - new Vector2(12, maxHeight - npc.height), 10, maxHeight, Color.Lime, Color.Green, spriteBatch);
                        DrawHelpers.DrawBorderedRectangle(npc.position - Main.screenPosition, npc.width, npc.height, Color.Black * 0f, Color.Green, spriteBatch);
                    }
                }
            }
        }
コード例 #26
0
        public void Draw(SpriteBatch b)
        {
            Color     HighlightColor = Color.Yellow;
            Texture2D Highlight      = TextureHelpers.GetSolidColorTexture(Game1.graphics.GraphicsDevice, HighlightColor);

            DrawHelpers.DrawBox(b, Bounds);

            //  Draw preview image
            b.Draw(Game1.menuTexture, PreviewDestination, new Rectangle(128, 128, 64, 64), Color.White);
            ItemBag CurrentBag = HoveredSprite.HasValue ? PreviewBag : Bag;

            DrawHelpers.DrawItem(b, PreviewDestination, CurrentBag, false, false, 1f, 1f, Color.White, Color.White);

            //  Draw instructional text
            b.DrawString(InstructionFont, InstructionText, InstructionDestination, Color.Black, 0f, Vector2.Zero, InstructionScale, SpriteEffects.None, 1f);

            //  Draw spritesheet with all icons to choose from
            DrawHelpers.DrawBorder(b, new Rectangle(TextureDestination.Left - 2, TextureDestination.Top - 2, TextureDestination.Width + 4, TextureDestination.Height + 4), 2, Color.Black);
            b.Draw(Texture, TextureDestination, new Rectangle(0, 0, TextureWidth, TextureHeight), Color.White);
            if (HoveredSprite.HasValue)
            {
                Rectangle Destination = HoveredSprite.Value.GetOffseted(new Point(TextureDestination.X, TextureDestination.Y));
                b.Draw(Highlight, Destination, Color.White * 0.25f);
                int BorderThickness = Math.Max(2, HoveredSprite.Value.Width / SpriteSize);
                DrawHelpers.DrawBorder(b, Destination, BorderThickness, HighlightColor);
            }

            //  Draw buttons
            b.Draw(Game1.menuTexture, DefaultButtonDestination, new Rectangle(128, 128, 64, 64), Color.White);
            b.DrawString(ButtonFont, DefaultButtonText, DefaultButtonTextDestination, Color.Black, 0f, Vector2.Zero, ButtonFontScale, SpriteEffects.None, 1f);
            b.Draw(Game1.menuTexture, CloseButtonDestination, new Rectangle(128, 128, 64, 64), Color.White);
            b.DrawString(ButtonFont, CloseButtonText, CloseButtonTextDestination, Color.Black, 0f, Vector2.Zero, ButtonFontScale, SpriteEffects.None, 1f);
            if (HoveredButton.HasValue)
            {
                Rectangle Destination = HoveredButton.Value;
                b.Draw(Highlight, Destination, Color.White * 0.25f);
                int BorderThickness = Math.Max(2, HoveredButton.Value.Width / 16);
                DrawHelpers.DrawBorder(b, Destination, BorderThickness, HighlightColor);
            }
        }
コード例 #27
0
ファイル: LineHelper.cs プロジェクト: fel88/GeomPad
        public override void Draw(IDrawingContext ctx)
        {
            if (!Visible)
            {
                return;
            }
            GL.Color3(Color.Blue);
            if (Selected)
            {
                GL.Color3(Color.Red);
            }
            GL.Begin(PrimitiveType.Lines);
            GL.Vertex3(Start);
            GL.Vertex3(End);
            GL.End();

            if (ShowCrosses)
            {
                DrawHelpers.DrawCross(Start, DrawSize);
                DrawHelpers.DrawCross(End, DrawSize);
            }
        }
コード例 #28
0
        public override void Draw(IDrawingContext ctx)
        {
            if (!Visible)
            {
                return;
            }
            GL.Color3(Color.Blue);

            GL.Begin(PrimitiveType.LineStrip);
            var res = GetPoints();

            foreach (var item in res)
            {
                GL.Color3(Color.Blue);
                GL.Vertex3(item);
            }

            GL.End();

            if (ShowIntermediateCrosses)
            {
                GL.Color3(Color.Yellow);
                foreach (var item in res)
                {
                    DrawHelpers.DrawCross(item.ToVector3d(), DrawSize / 2);
                }
            }
            GL.Color3(Color.Blue);

            GL.Begin(PrimitiveType.Lines);
            GL.Vertex3(Center);
            GL.Vertex3(Center + Axis * 5);
            GL.End();

            DrawHelpers.DrawCross(Start, DrawSize);
            DrawHelpers.DrawCross(End, DrawSize);
            DrawHelpers.DrawCross(Center, DrawSize);
            DrawHelpers.DrawCross(Value, DrawSize);
        }
コード例 #29
0
        public override void Draw(IDrawingContext gr)
        {
            if (!Visible)
            {
                return;
            }
            if (DrawPoles)
            {
                foreach (var item in Poles)
                {
                    DrawHelpers.DrawCross(item, DrawSize);
                }
            }
            var p = GetPoints();

            GL.Begin(PrimitiveType.LineStrip);
            foreach (var item in p)
            {
                GL.Vertex3(item);
            }
            GL.End();
        }
コード例 #30
0
        public override bool PreKill(int timeLeft)
        {
            /// For now, copy pasted VFX for road roller. Will make it prettier in the next build
            DrawHelpers.CircleDust(projectile.Center, Vector2.Zero, DustID.Fire, 90, 90, 2.5f, 60);

            Main.PlaySound(SoundID.Item14, projectile.position);
            for (int i = 0; i < 60; i++)
            {
                int dust = Dust.NewDust(projectile.Center, 0, 0, DustID.Fire, 0, 0);
                Main.dust[dust].velocity *= 16.5f;
                Main.dust[dust].noGravity = true;
                Main.dust[dust].scale     = 3.5f;
            }
            // Large Smoke Gore spawn
            for (int g = 0; g < 2; g++)
            {
                int goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), Vector2.Zero, Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 1.5f;

                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), Vector2.Zero, Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 3.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y + 3.5f;

                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), Vector2.Zero, Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X + 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;

                goreIndex = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), Vector2.Zero, Main.rand.Next(61, 64), 1f);
                Main.gore[goreIndex].scale      = 1.5f;
                Main.gore[goreIndex].velocity.X = Main.gore[goreIndex].velocity.X - 1.5f;
                Main.gore[goreIndex].velocity.Y = Main.gore[goreIndex].velocity.Y - 1.5f;
            }

            return(true);
        }