Ejemplo n.º 1
0
        public override void Load()
        {
            Instance = this;

            bagKey = RegisterHotKey("Open Bag", "B");

            TagSerializer.AddSerializer(new FreqSerializer());

            if (!Main.dedServ)
            {
                lootAll    = ModLoader.GetTexture(UITexturePath + "LootAll");
                depositAll = ModLoader.GetTexture(UITexturePath + "DepositAll");

                restack    = new Texture2D[2];
                restack[0] = ModLoader.GetTexture(UITexturePath + "Restack_0");
                restack[1] = ModLoader.GetTexture(UITexturePath + "Restack_1");

                restock = ModLoader.GetTexture(UITexturePath + "Restock");

                vacuumBagOn  = ModLoader.GetTexture(ItemTexturePath + "VacuumBagActive");
                vacuumBagOff = ModLoader.GetTexture(ItemTexturePath + "VacuumBagInactive");

                ringBig   = ModLoader.GetTexture(ItemTexturePath + "RingBig");
                ringSmall = ModLoader.GetTexture(ItemTexturePath + "RingSmall");

                gemsMiddle = new Texture2D[3];
                gemsSide   = new Texture2D[3];
                for (int i = 0; i < 3; i++)
                {
                    gemsMiddle[i] = ModLoader.GetTexture(TileTexturePath + "GemMiddle" + i);
                    gemsSide[i]   = ModLoader.GetTexture(TileTexturePath + "GemSide" + i);
                }
            }
        }
Ejemplo n.º 2
0
        public override void Load()
        {
            Instance = this;

            TagSerializer.AddSerializer(new EnergySerializer());
            TagSerializer.AddSerializer(new HeatSerializer());
            TagSerializer.AddSerializer(new FluidSerializer());

            FluidLoader.Autoload();
            FluidLoader.SetupContent();

            if (!Main.dedServ)
            {
                borderTexture     = TextureManager.Load("Images/UI/PanelBorder");
                backgroundTexture = TextureManager.Load("Images/UI/PanelBackground");

                corner = ModLoader.GetTexture(TexturePath + "BarCorner");
                side   = ModLoader.GetTexture(TexturePath + "BarSide");

                LayerDisplayUI = new LayerDisplayUI();
                LayerDisplayUI.Activate();
                ILayerDisplayUI = new UserInterface();
                ILayerDisplayUI.SetState(LayerDisplayUI);
            }
        }
Ejemplo n.º 3
0
        public override void OnInitialize()
        {
            TinkererShopsPanel = new UIPanel();
            TinkererShopsPanel.SetPadding(0);
            TinkererShopsPanel.Left.Set(575f, 0f);
            TinkererShopsPanel.Top.Set(275f, 0f);
            TinkererShopsPanel.Width.Set(200f, 0f);
            TinkererShopsPanel.Height.Set(75f, 0f);
            TinkererShopsPanel.BackgroundColor = new Color(73, 94, 171);

            TinkererShopsPanel.OnMouseDown += new UIElement.MouseEvent(DragStart);
            TinkererShopsPanel.OnMouseUp   += new UIElement.MouseEvent(DragEnd);

            UIText text = new UIText("Movement/Misc");

            text.Left.Set(35, 0f);
            text.Top.Set(10, 0f);
            text.Width.Set(90, 0f);
            text.Height.Set(22, 0f);
            text.OnClick += new MouseEvent(PlayButtonClicked1);
            TinkererShopsPanel.Append(text);

            UIText text2 = new UIText("Combat");

            text2.Left.Set(35, 0f);
            text2.Top.Set(40, 0f);
            text2.Width.Set(50, 0f);
            text2.Height.Set(22, 0f);
            text2.OnClick += new MouseEvent(PlayButtonClicked2);
            TinkererShopsPanel.Append(text2);

            Texture2D     buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/ButtonPlay");
            UIImageButton playButton        = new UIImageButton(buttonPlayTexture);

            playButton.Left.Set(10, 0f);
            playButton.Top.Set(10, 0f);
            playButton.Width.Set(22, 0f);
            playButton.Height.Set(22, 0f);
            playButton.OnClick += new MouseEvent(PlayButtonClicked1);
            TinkererShopsPanel.Append(playButton);
            UIImageButton playButton2 = new UIImageButton(buttonPlayTexture);

            playButton2.Left.Set(10, 0f);
            playButton2.Top.Set(40, 0f);
            playButton2.Width.Set(22, 0f);
            playButton2.Height.Set(22, 0f);
            playButton2.OnClick += new MouseEvent(PlayButtonClicked2);
            TinkererShopsPanel.Append(playButton2);

            Texture2D     buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            UIImageButton closeButton         = new UIImageButton(buttonDeleteTexture);

            closeButton.Left.Set(170, 0f);
            closeButton.Top.Set(10, 0f);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            TinkererShopsPanel.Append(closeButton);
            base.Append(TinkererShopsPanel);
        }
Ejemplo n.º 4
0
        public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
        {
            int ID = mod.GetID <TEQETank>(i, j);

            if (ID == -1)
            {
                return(false);
            }

            Tile tile = Main.tile[i, j];

            if (tile.TopLeft())
            {
                Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange);
                if (Main.drawToScreen)
                {
                    zero = Vector2.Zero;
                }
                Vector2 position = new Vector2(i * 16 - (int)Main.screenPosition.X, j * 16 - (int)Main.screenPosition.Y) + zero;

                TEQETank qeTank = (TEQETank)TileEntity.ByID[ID];
                ModFluid fluid  = qeTank.GetFluid();

                if (fluid != null)
                {
                    spriteBatch.Draw(ModLoader.GetTexture(FluidLoader.GetFluid(fluid.Name).Texture), new Rectangle((int)position.X + 6, (int)(position.Y + 6 + (20 - 20 * (fluid.volume / (float)TEQETank.MaxVolume))), 20, (int)(20 * (fluid.volume / (float)TEQETank.MaxVolume))), null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
        public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
        {
            if (fluid != null)
            {
                spriteBatch.End();

                RasterizerState state = new RasterizerState {
                    ScissorTestEnable = true
                };

                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, state);

                Rectangle prevRect = spriteBatch.GraphicsDevice.ScissorRectangle;
                float     progress = fluid.volume / (float)MaxAmount;

                spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle((int)(position.X + 10 * scale), (int)(position.Y + 20 * scale - 10 * scale * progress), 4, (int)(10 * progress));

                spriteBatch.Draw(ModLoader.GetTexture(fluid.Texture), position + new Vector2(10, 10) * scale, new Rectangle(0, 0, 4, 10), Color.White, 0f, origin, scale, SpriteEffects.None, 0f);

                spriteBatch.GraphicsDevice.ScissorRectangle = prevRect;
                spriteBatch.End();
                spriteBatch.Begin();
            }

            item.SetNameOverride(fluid != null ? fluid.DisplayName.GetTranslation(Language.ActiveCulture) + " Bucket" : "Empty Bucket");
        }
Ejemplo n.º 6
0
        public override bool PreDraw(SpriteBatch sb, Color lc)
        {
            Projectile p       = projectile;
            Texture2D  tex     = Main.projectileTexture[p.type];
            Texture2D  Bolt2   = ModLoader.GetTexture("DarkSouls/Projectiles/FBolt3_2");
            Texture2D  Bolt3   = ModLoader.GetTexture("DarkSouls/Projectiles/FBolt3_3");
            Vector2    drawPos = p.Center + Vector2.UnitY * p.gfxOffY - Main.screenPosition;

            int     frameH = tex.Height / Main.projFrames[p.type];
            int     frameY = frameH * p.frame;
            Vector2 origin = tex.Size() / 2f;

            origin.Y /= Main.projFrames[p.type];
            SpriteEffects fx = (p.spriteDirection == 1) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

            if (projectile.ai[0] == 1)
            {
                sb.Draw(Bolt2, drawPos, new Rectangle(0, frameY, tex.Width, frameH), lc, p.rotation, origin, p.scale, fx, 0f);
                return(false);
            }
            if (projectile.ai[0] == 2)
            {
                sb.Draw(Bolt3, drawPos, new Rectangle(0, frameY, tex.Width, frameH), lc, p.rotation, origin, p.scale, fx, 0f);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        public static void Unload()
        {
            if (Main.glowMaskTexture.Length == AntiarisGlowMasks.End)
            {
                Array.Resize(ref Main.glowMaskTexture, Main.glowMaskTexture.Length - AntiarisGlowMasks.Count);
            }
            else if (Main.glowMaskTexture.Length > AntiarisGlowMasks.End && Main.glowMaskTexture.Length > AntiarisGlowMasks.Count)
            {
                for (int i = AntiarisGlowMasks.End - AntiarisGlowMasks.Count; i < AntiarisGlowMasks.End; i++)
                {
                    Main.glowMaskTexture[i] = ModLoader.GetTexture("Terraria/Item_0");
                }
            }

            AntiarisGlowMasks.Loaded = false;
            AntiarisGlowMasks.EnchantedBreastplate = 0;
            AntiarisGlowMasks.EnchantedHelmet      = 0;
            AntiarisGlowMasks.SorcererRobe         = 0;
            AntiarisGlowMasks.GooHelmet            = 0;
            AntiarisGlowMasks.GooGreaves           = 0;
            AntiarisGlowMasks.GooBreastplate       = 0;
            AntiarisGlowMasks.GooBreastplateF      = 0;
            AntiarisGlowMasks.GooSpear             = 0;
            AntiarisGlowMasks.GooYoyo          = 0;
            AntiarisGlowMasks.ShadowflameArrow = 0;
            AntiarisGlowMasks.End = 0;
        }
Ejemplo n.º 8
0
        public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture = ModLoader.GetTexture("Gyrolite/Projectiles/Summoner/AjiwrenchMinion" + (int)projectile.ai[0]);
            Vector2   origin  = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);

            spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, new Rectangle?(), Color.White * 0.75F, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0);
            return(false);
        }
Ejemplo n.º 9
0
        public UITextButton(string text, Color color)
        {
            this.textColor     = color;
            _backgroundTexture = ModLoader.GetTexture("Terraria/UI/PanelBackground");
            _borderTexture     = ModLoader.GetTexture("Terraria/UI/PanelBorder");

            UpdateText(text);
        }
Ejemplo n.º 10
0
        public float textScale = 1f;// чтобы изменять размер текста в будующем
        public override void OnInitialize()
        {
            #region UI panel
            QuestTrackerPanel = new UIPanel();
            QuestTrackerPanel.Top.Set(200f, 0f);                               //Позиция сверху на экране
            QuestTrackerPanel.Left.Set(Main.screenWidth / 2, 0f);              //Позиция слева на экране
            QuestTrackerPanel.Width.Set(250f, 0f);                             //размер по ширине в пикселях
            QuestTrackerPanel.Height.Set(102f, 0f);                            //размер по высоте в пикселях
            QuestTrackerPanel.SetPadding(0f);                                  //Честно, сам без понятия, но вроде надо :shrug:
            QuestTrackerPanel.BackgroundColor = new Color(255, 255, 255) * 0f; //чтобы прозрачно было
            QuestTrackerPanel.BorderColor     = new Color(255, 255, 255) * 0f; // ^

            QuestTrackerPanel.OnMouseDown += new UIElement.MouseEvent(DragStart);
            QuestTrackerPanel.OnMouseUp   += new UIElement.MouseEvent(DragEnd);
            // ^ вот это нужно, чтобы панельку можно было таскать
            #endregion
            //Вот дальше идёт хардкоре, ибо дальше идут текста
            #region tracker texts
            currentQuest = new UIText("", textScale); //Ставим пока так, дабы не крашнуло
            currentQuest.Top.Set(10, 0);
            currentQuest.Left.Set(10.2f, 0);
            currentQuest.Width.Set(250, 0);
            currentQuest.Height.Set(102, 0);
            currentQuest.SetPadding(0);
            currentQuest.TextColor = Color.DarkGray;

            currentQuestName = new UIText("", textScale); //Ставим пока так, дабы не крашнуло
            currentQuestName.Top.Set(48, 0);
            currentQuestName.Left.Set(10.2f, 0);
            currentQuestName.Width.Set(250, 0);
            currentQuestName.Height.Set(102, 0);
            currentQuestName.SetPadding(0);
            currentQuestName.TextColor = Color.DarkGray;

            currentQuestText = new UIText("", textScale); //Ставим пока так, дабы не крашнуло
            currentQuestText.Top.Set(73, 0);
            currentQuestText.Left.Set(5.2f, 0);
            currentQuestText.Width.Set(250, 0);
            currentQuestText.Height.Set(102, 0);
            currentQuestText.SetPadding(0);
            currentQuestText.TextColor = Color.DarkGray;
            #endregion
            description = new UISilentButton(ModLoader.GetTexture("Antiaris/Miscellaneous/QuestIconUI"));
            description.Top.Set(5f, 0f);
            description.Left.Set(222f, 0f);
            description.Height.Set(26, 0f);
            description.Width.Set(78, 0f);
            description.SetPadding(0f);
            description.OnClick += new MouseEvent(PrintInfo);
            QuestTrackerPanel.Append(description);

            QuestTrackerPanel.Append(currentQuest);
            QuestTrackerPanel.Append(currentQuestText);
            QuestTrackerPanel.Append(currentQuestName);
            base.Append(QuestTrackerPanel);
        }
Ejemplo n.º 11
0
 public UIProgressImage(float height, float width, string texLoc1, string texLoc2, int texOffsetX = 0, int texOffsetY = 0)
 {
     _backgroundTexture  = ModLoader.GetTexture(texLoc1);
     _backgroundTexture2 = ModLoader.GetTexture(texLoc2);
     this.height         = height;
     this.width          = width;
     offsetX             = texOffsetX;
     offsetY             = texOffsetY;
     defaultWidth        = width;
 }
Ejemplo n.º 12
0
        public static void RegisterLayer(ILayer layer)
        {
            string TypeName = layer.GetType().FullName;

            layers[TypeName] = layer;

            LayerInfo info = layer.GetInfo();

            names[TypeName] = info.Name;
            icons[TypeName] = ModLoader.GetTexture(info.Texture);
        }
Ejemplo n.º 13
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D centerTexture = ModLoader.GetTexture("Gyrolite/Projectiles/Summoner/HeavySlimeMinion2");
            Vector2   centerOrigin  = new Vector2((centerTexture.Width / 2), 16);
            Vector2   centerPos     = new Vector2(projectile.Center.X, projectile.Center.Y);

            Rectangle     sourceRectangle = new Rectangle(0, (int)(centerTexture.Height / 6) * projectile.frame, 44, (int)(centerTexture.Height / 6));
            SpriteEffects effects         = projectile.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            Main.spriteBatch.Draw(centerTexture, centerPos - Main.screenPosition, sourceRectangle, lightColor, projectile.rotation, centerOrigin, projectile.scale, effects, 0);

            return(base.PreDraw(spriteBatch, lightColor));
        }
Ejemplo n.º 14
0
        // In OnInitialize, we place various UIElements onto our UIState (this class).
        // UIState classes have width and height equal to the full screen, because of this, usually we first define a UIElement that will act as the container for our UI.
        // We then place various other UIElement onto that container UIElement positioned relative to the container UIElement.
        public override void OnInitialize()
        {
            // Here we define our container UIElement. In DragableUIPanel.cs, you can see that DragableUIPanel is a UIPanel with a couple added features.
            coinCounterPanel = new DragableUIPanel();
            coinCounterPanel.SetPadding(0);
            // We need to place this UIElement in relation to its Parent. Later we will be calling `base.Append(coinCounterPanel);`.
            // This means that this class, ExampleUI, will be our Parent. Since ExampleUI is a UIState, the Left and Top are relative to the top left of the screen.
            coinCounterPanel.Left.Set(400f, 0f);
            coinCounterPanel.Top.Set(100f, 0f);
            coinCounterPanel.Width.Set(170f, 0f);
            coinCounterPanel.Height.Set(70f, 0f);
            coinCounterPanel.BackgroundColor = new Color(73, 94, 171);

            // Next, we create another UIElement that we will place. Since we will be calling `coinCounterPanel.Append(playButton);`, Left and Top are relative to the top left of the coinCounterPanel UIElement.
            // By properly nesting UIElements, we can position things relatively to each other easily.
            Texture2D          buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/ButtonPlay");
            UIHoverImageButton playButton        = new UIHoverImageButton(buttonPlayTexture, "Reset Coins Per Minute Counter");

            playButton.Left.Set(110, 0f);
            playButton.Top.Set(10, 0f);
            playButton.Width.Set(22, 0f);
            playButton.Height.Set(22, 0f);
            // UIHoverImageButton doesn't do anything when Clicked. Here we assign a method that we'd like to be called when the button is clicked.
            playButton.OnClick += new MouseEvent(PlayButtonClicked);
            coinCounterPanel.Append(playButton);

            Texture2D          buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            UIHoverImageButton closeButton         = new UIHoverImageButton(buttonDeleteTexture, Language.GetTextValue("LegacyInterface.52"));     // Localized text for "Close"

            closeButton.Left.Set(140, 0f);
            closeButton.Top.Set(10, 0f);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            coinCounterPanel.Append(closeButton);

            // UIMoneyDisplay is a fairly complicated custom UIElement. UIMoneyDisplay handles drawing some text and coin textures.
            // Organization is key to managing UI design. Making a contained UIElement like UIMoneyDisplay will make many things easier.
            moneyDiplay = new UIMoneyDisplay();
            moneyDiplay.Left.Set(15, 0f);
            moneyDiplay.Top.Set(20, 0f);
            moneyDiplay.Width.Set(100f, 0f);
            moneyDiplay.Height.Set(0, 1f);
            coinCounterPanel.Append(moneyDiplay);

            base.Append(coinCounterPanel);

            // As a recap, ExampleUI is a UIState, meaning it covers the whole screen. We attach coinCounterPanel to ExampleUI some distance from the top left corner.
            // We then place playButton, closeButton, and moneyDiplay onto coinCounterPanel so we can easily place these UIElements relative to coinCounterPanel.
            // Since coinCounterPanel will move, this proper organization will move playButton, closeButton, and moneyDiplay properly when coinCounterPanel moves.
        }
Ejemplo n.º 15
0
        // chain voodoo
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            projectile.frameCounter++;         //increase the frameCounter by one
            if (projectile.frameCounter >= 10) //once the frameCounter has reached 10 - change the 10 to change how fast the projectile animates
            {
                projectile.frame++;            //go to the next frame
                projectile.frameCounter = 0;   //reset the counter
                if (projectile.frame > 7)
                {
                    projectile.frame = 0; //go back to the first frame
                }
            }

            Texture2D texture = ModLoader.GetTexture("AAMod/Projectiles/Yamata/Flairdra_Chain");

            Vector2   position        = projectile.Center;
            Vector2   mountedCenter   = Main.player[projectile.owner].MountedCenter;
            Rectangle?sourceRectangle = new Rectangle?();
            Vector2   origin          = new Vector2(texture.Width * 0.5f, texture.Height * 0.5f);
            float     num1            = texture.Height;
            Vector2   vector24        = mountedCenter - position;
            float     rotation        = (float)Math.Atan2(vector24.Y, vector24.X) - 1.57f;
            bool      flag            = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector24.X) && float.IsNaN(vector24.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if (vector24.Length() < num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector21 = vector24;
                    vector21.Normalize();
                    position += vector21 * num1;
                    vector24  = mountedCenter - position;
                    Color color2 = Lighting.GetColor((int)position.X / 16, (int)(position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1.35f, SpriteEffects.None, 0.0f);
                }
            }
            return(true);
        }
Ejemplo n.º 16
0
        public override void PostDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color drawColor)
        {
            Texture2D eggTexture = ModLoader.GetTexture("Mharadium/NPCs/Boss/OrionSlime_Egg");

            Color color1 = Lighting.GetColor((int)eggPosition.X / 16, (int)((double)eggPosition.Y / 16.0));

            color1 = npc.GetAlpha(color1);

            Rectangle?sourceRectangle = new Rectangle?();

            Main.spriteBatch.Draw(eggTexture, eggPosition - Main.screenPosition, sourceRectangle, color1);

            base.PostDraw(spriteBatch, drawColor);
        }
Ejemplo n.º 17
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            int laserHeight = 2000;
            int laserWidth  = (projectile.ai[0] == 0 ? 20 : 44);

            float     angle    = projectile.velocity.ToRotation();
            Vector2   v        = new Vector2((float)(Math.Cos(angle) * laserHeight), (float)(Math.Sin(angle) * laserHeight));
            Texture2D texture  = projectile.ai[0] == 0 ? ModLoader.GetTexture("Decimation/Projectiles/RasGazeLaser") : ModLoader.GetTexture("Decimation/Projectiles/RasGazeBeam");
            Vector2   position = projectile.position - Main.screenPosition + v;

            spriteBatch.Draw(texture, position, new Rectangle(0, 0, laserWidth, laserHeight), Color.White, (float)(angle + (Math.PI * 1 / 2)), new Vector2(0, 0), 1, SpriteEffects.None, 0);

            return(false);
        }
Ejemplo n.º 18
0
        public UIVapeProgressBar(float value, float minValue, float maxValue, Color backgroundColor, Color foregroundColor)
        {
            this.value    = value;
            this.minValue = minValue;
            this.maxValue = maxValue;

            this.backgroundColor = backgroundColor;
            this.foregroundColor = foregroundColor;

            this.strokeThickness = 0;
            this.strokeColor     = Color.Black;

            this.backgroundTexture = ModLoader.GetTexture("VapeRPG/Textures/UI/Blank");
        }
Ejemplo n.º 19
0
        private static Texture2D GetSkillFrame(string name)
        {
            Texture2D frame;

            try
            {
                frame = ModLoader.GetTexture("VapeRPG/Textures/UI/Skills/" + name);
            }
            catch (Exception)
            {
                frame = ModLoader.GetTexture("VapeRPG/Textures/UI/SkillFrame");
            }

            return(frame);
        }
Ejemplo n.º 20
0
        public override void OnInitialize()
        {
            searchBarPanel = new UIPanel();
            searchBarPanel.SetPadding(0);
            //searchBarPanel.Left.Set(0, .5f);
            //searchBarPanel.Top.Set(0, .5f);
            searchBarPanel.Top.Set(50, 0f);
            searchBarPanel.HAlign = 0.5f;
            searchBarPanel.VAlign = 0.5f;
            searchBarPanel.Width.Set(170f, 0f);
            searchBarPanel.Height.Set(30f, 0f);
            searchBarPanel.BackgroundColor = new Color(73, 94, 171);
            searchBarPanel.OnMouseDown    += DragStart;
            searchBarPanel.OnMouseUp      += DragEnd;

            Texture2D          buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/Cursor_2");
            UIHoverImageButton playButton        = new UIHoverImageButton(buttonPlayTexture, "Click to switch peek modes: Show All");

            playButton.Left.Set(5, 0f);
            playButton.Top.Set(5, 0f);
            playButton.OnClick += TogHover;
            searchBarPanel.Append(playButton);

            box = new NewUITextBox("Type here to search", 0.78f);
            box.OnTabPressed += () =>
            {
                if (!string.IsNullOrEmpty(history))
                {
                    box.SetText(history);
                }
            };
            box.BackgroundColor = Color.Transparent;
            box.BorderColor     = Color.Transparent;
            box.Left.Pixels     = 15;
            box.Top.Pixels      = -5;
            box.MinWidth.Pixels = 120;
            box.OnUnfocus      += () =>
            {
                if (!string.IsNullOrEmpty(box.Text))
                {
                    history = box.Text;
                }
                visible = false;
            };
            searchBarPanel.Append(box);

            Append(searchBarPanel);
        }
Ejemplo n.º 21
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            Texture2D texture1 = (Texture2D)null;
            Color     color1   = Color.White;
            Texture2D texture2 = ModLoader.GetTexture("Negadium/Projectiles/Summoner/HydraHeadMinion_Neck");

            Vector2 position      = projectile.Center;
            Vector2 mountedCenter = new Vector2(player.Center.X, player.Center.Y);

            Microsoft.Xna.Framework.Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
            Vector2 origin    = new Vector2((float)texture2.Width * 0.5f, (float)texture2.Height * 0.5f);
            float   num1      = (float)texture2.Height;
            Vector2 vector2_4 = mountedCenter - position;
            float   rotation  = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
            bool    flag      = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2_4.Length() < (double)num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector2_1 = vector2_4;
                    vector2_1.Normalize();
                    position += vector2_1 * num1;
                    vector2_4 = mountedCenter - position;
                    Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture2, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0.0f);
                    if (texture1 != null)
                    {
                        Main.spriteBatch.Draw(texture1, position - Main.screenPosition, sourceRectangle, color1, rotation, origin, 1f, SpriteEffects.None, 0.0f);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 22
0
        public override void OnInitialize()
        {
            furnaceUI = new UIPanel();
            furnaceUI.SetPadding(0);
            furnaceUI.Width.Set(400, 0f);
            furnaceUI.Height.Set(200, 0f);
            furnaceUI.Top.Set(Main.screenHeight / 2, 0f);
            furnaceUI.Left.Set(Main.screenWidth / 2, 0f);

            furnaceUI.BackgroundColor = new Color(73, 94, 171);

            input.Width.Set(64, 0f);
            input.Height.Set(64, 0f);
            input.Top.Set(30, 0f);
            input.Left.Set(300, 0f);
            input.OnClick += inputSlotItem;
            furnaceUI.Append(input);

            output.Width.Set(64, 0f);
            output.Height.Set(64, 0f);
            output.Top.Set(120, 0f);
            output.Left.Set(300, 0f);
            output.OnClick += withdrawItem;
            furnaceUI.Append(output);

            Texture2D     buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            UIImageButton closeButton         = new UIImageButton(buttonDeleteTexture);

            closeButton.Left.Set(400 - 35, 0f);
            closeButton.Top.Set(10, 0f);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            furnaceUI.Append(closeButton);

            energyCounter = new UIText("");
            energyCounter.Left.Set(10, 0f);
            energyCounter.Top.Set(5, 0f);
            energyCounter.Width.Set(100, 0f);
            furnaceUI.Append(energyCounter);

            input.initComponent();
            output.initComponent();

            Append(furnaceUI);
        }
Ejemplo n.º 23
0
        public override void PostDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D texture1 = (Texture2D)null;
            Color     color1   = Color.White;
            Texture2D texture2 = ModLoader.GetTexture("Gyrolite/Projectiles/Magic/LifeDrain_Chain");

            Vector2 position      = projectile.Center;
            Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;

            Microsoft.Xna.Framework.Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
            Vector2 origin    = new Vector2((float)texture2.Width * 0.5f, (float)texture2.Height * 0.5f);
            float   num1      = (float)texture2.Height;
            Vector2 vector2_4 = mountedCenter - position;
            float   rotation  = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
            bool    flag      = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2_4.Length() < (double)num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector2_1 = vector2_4;
                    vector2_1.Normalize();
                    position += vector2_1 * num1;
                    vector2_4 = mountedCenter - position;
                    Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture2, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0.0f);
                    if (texture1 != null)
                    {
                        Main.spriteBatch.Draw(texture1, position - Main.screenPosition, sourceRectangle, color1, rotation, origin, 1f, SpriteEffects.None, 0.0f);
                    }
                }
            }
        }
        public override void Load()
        {
            try
            {
                Instance = this;

                TagSerializer.AddSerializer(new WireSerializer());
                TagSerializer.AddSerializer(new HeatPipeSerializer());

                //Main.OnPreDraw += PreDraw;
                //Main.OnPostDraw += PostDraw;

                if (!Main.dedServ)
                {
                    wireTexture     = ModLoader.GetTexture("DawnOfIndustryCore/Textures/Tiles/BasicWire");
                    heatPipeTexture = ModLoader.GetTexture("DawnOfIndustryCore/Textures/Tiles/HeatPipe");

                    inTexture      = ModLoader.GetTexture("DawnOfIndustryCore/Textures/Tiles/ConnectionIn");
                    outTexture     = ModLoader.GetTexture("DawnOfIndustryCore/Textures/Tiles/ConnectionOut");
                    bothTexture    = ModLoader.GetTexture("DawnOfIndustryCore/Textures/Tiles/ConnectionBoth");
                    blockedTexture = ModLoader.GetTexture("DawnOfIndustryCore/Textures/Tiles/ConnectionBlocked");

                    textureBlueprint = ModLoader.GetTexture(UIPath + "Blueprint");
                    lightningCap     = ModLoader.GetTexture(TexturePath + "LightningCap");
                    lightningSegment = ModLoader.GetTexture(TexturePath + "LightningSegment");

                    ResearchUI = new ResearchUI();
                    ResearchUI.Activate();
                    IResearchUI = new UserInterface();
                    IResearchUI.SetState(ResearchUI);

                    try
                    {
                        Platform.Current.SetWindowUnicodeTitle(Main.instance.Window, "Terraria: Dawn of Industry");
                    }
                    catch (Exception ex)
                    {
                        this.Log($"Failed to change title:\n{ex}");
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
            }
        }
Ejemplo n.º 25
0
        public override void Load()
        {
            Instance = this;

            OpenBrowser = this.Register("Open Browser", Keys.OemCloseBrackets);
            ShowRecipe  = this.Register("Show Recipe", Keys.R);
            ShowUsage   = this.Register("Show Usage", Keys.U);
            FindItem    = this.Register("Find Item in containers", Keys.F);
            PrevRecipe  = this.Register("Previous recipe", Keys.Back);

            if (!Main.dedServ)
            {
                for (int i = 0; i < 4; i++)
                {
                    textureSortMode.Add(ModLoader.GetTexture(TexturePath + "SortMode_" + i));
                }
                texturePause    = ModLoader.GetTexture(TexturePath + "Pause");
                texturePlay     = ModLoader.GetTexture(TexturePath + "Play");
                textureEntity   = ModLoader.GetTexture(TexturePath + "Entity");
                textureWorld    = ModLoader.GetTexture(TexturePath + "World");
                textureMagnet   = ModLoader.GetTexture(TexturePath + "Magnet");
                textureMapDeath = TextureManager.Load("Images" + Path.DirectorySeparatorChar + "MapDeath");

                IBrowserUI = new UserInterface();
                BrowserUI  = new BrowserUI();
                BrowserUI.Activate();
                IBrowserUI.SetState(BrowserUI);

                IRecipeUI = new UserInterface();
                RecipeUI  = new RecipeUI();
                RecipeUI.Activate();
                IRecipeUI.SetState(RecipeUI);

                ICheatUI = new UserInterface();
                CheatUI  = new CheatUI();
                CheatUI.Activate();
                ICheatUI.SetState(CheatUI);

                IMobUI = new UserInterface();
                MobUI  = new MobUI();
                MobUI.Activate();
                IMobUI.SetState(MobUI);
                MobUI.visible = true;
            }
        }
Ejemplo n.º 26
0
        public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
        {
            spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), new Color(70, 0, 0) * 0.9f);

            for (int i = 0; i < 50; i++)
            {
                spriteBatch.Draw(ModLoader.GetTexture("Terraria/npc_517"),
                                 new Vector2(Main.screenPosition.X / 2f - xPos[i], (yPos[i] + pillarVelocity / 5)),
                                 ModLoader.GetTexture("Terraria/npc_517").Bounds,
                                 Color.White * zDistance[i],
                                 0,
                                 new Vector2(0, 0),
                                 zDistance[i],
                                 SpriteEffects.None,
                                 0f
                                 );
            }
        }
Ejemplo n.º 27
0
        public override void PostDraw(SpriteBatch spriteBatch, Color drawColor)
        {
            npc.spriteDirection = 1;
            Texture2D centerTexture = ModLoader.GetTexture("Gyrolite/NPCs/Bosses/WispQueen/WispQueen_Center");
            Vector2   centerOrigin  = new Vector2((centerTexture.Width / 2), (centerTexture.Height / 2));

            centerPos = new Vector2(npc.Center.X, npc.Center.Y + 4 - (30 * (npc.scale - 1)));

            Color color1 = Lighting.GetColor((int)centerPos.X / 16, (int)((double)centerPos.Y / 16.0));

            color1 = npc.GetAlpha(color1);

            Rectangle?sourceRectangle = new Rectangle?();

            Main.spriteBatch.Draw(centerTexture, centerPos - Main.screenPosition, sourceRectangle, color1, centerRot, centerOrigin, npc.scale, SpriteEffects.None, 0);

            base.PostDraw(spriteBatch, drawColor);
        }
Ejemplo n.º 28
0
        // Now this is where the chain magic happens. You don't have to try to figure this whole thing out.
        // Just make sure that you edit the first line (which starts with 'Texture2D texture') correctly.
        public override bool PreDraw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, Color lightColor)
        {
            // So set the correct path here to load the chain texture. 'YourModName' is of course the name of your mod.
            // Then into the Projectiles folder and take the texture that is called 'CustomFlailBall_Chain'.
            Texture2D texture = ModLoader.GetTexture("EnduriumMod/Projectiles/BloodSpikelashChain");

            Vector2 position      = projectile.Center;
            Vector2 mountedCenter = Main.player[projectile.owner].MountedCenter;

            Microsoft.Xna.Framework.Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?();
            Vector2 origin    = new Vector2((float)texture.Width * 0.5f, (float)texture.Height * 0.5f);
            float   num1      = (float)texture.Height;
            Vector2 vector2_4 = mountedCenter - position;
            float   rotation  = (float)Math.Atan2((double)vector2_4.Y, (double)vector2_4.X) - 1.57f;
            bool    flag      = true;

            if (float.IsNaN(position.X) && float.IsNaN(position.Y))
            {
                flag = false;
            }
            if (float.IsNaN(vector2_4.X) && float.IsNaN(vector2_4.Y))
            {
                flag = false;
            }
            while (flag)
            {
                if ((double)vector2_4.Length() < (double)num1 + 1.0)
                {
                    flag = false;
                }
                else
                {
                    Vector2 vector2_1 = vector2_4;
                    vector2_1.Normalize();
                    position += vector2_1 * num1;
                    vector2_4 = mountedCenter - position;
                    Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)position.X / 16, (int)((double)position.Y / 16.0));
                    color2 = projectile.GetAlpha(color2);
                    Main.spriteBatch.Draw(texture, position - Main.screenPosition, sourceRectangle, color2, rotation, origin, 1f, SpriteEffects.None, 0.0f);
                }
            }

            return(true);
        }
Ejemplo n.º 29
0
        public static void Load()
        {
            Array.Resize(ref Main.glowMaskTexture, Main.glowMaskTexture.Length + Count);

            short i = (short)(Main.glowMaskTexture.Length - Count);

            Main.glowMaskTexture[i] = ModLoader.GetTexture("GoldensMisc/Items/Weapons/UndyingSpear_Glow");
            UndyingSpear            = i;
            i++;
            Main.glowMaskTexture[i] = ModLoader.GetTexture("GoldensMisc/Projectiles/UndyingSpear_Glow");
            UndyingSpearProjectile  = i;
            i++;
            Main.glowMaskTexture[i] = ModLoader.GetTexture("GoldensMisc/Items/Tools/RodofWarping_Glow");
            RodofWarping            = i;
            i++;
            End = i;

            Loaded = true;
        }
Ejemplo n.º 30
0
        public override void OnInitialize()
        {
            coinCounterPanel = new UIPanel();
            coinCounterPanel.SetPadding(0);
            coinCounterPanel.Left.Set(400f, 0f);
            coinCounterPanel.Top.Set(100f, 0f);
            coinCounterPanel.Width.Set(170f, 0f);
            coinCounterPanel.Height.Set(70f, 0f);
            coinCounterPanel.BackgroundColor = new Color(73, 94, 171);

            coinCounterPanel.OnMouseDown += new UIElement.MouseEvent(DragStart);
            coinCounterPanel.OnMouseUp   += new UIElement.MouseEvent(DragEnd);

            Texture2D     buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/ButtonPlay");
            UIImageButton playButton        = new UIImageButton(buttonPlayTexture);

            playButton.Left.Set(110, 0f);
            playButton.Top.Set(10, 0f);
            playButton.Width.Set(22, 0f);
            playButton.Height.Set(22, 0f);
            playButton.OnClick += new MouseEvent(PlayButtonClicked);
            coinCounterPanel.Append(playButton);

            Texture2D     buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            UIImageButton closeButton         = new UIImageButton(buttonDeleteTexture);

            closeButton.Left.Set(140, 0f);
            closeButton.Top.Set(10, 0f);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            coinCounterPanel.Append(closeButton);

            moneyDiplay = new UIMoneyDisplay();
            moneyDiplay.Left.Set(15, 0f);
            moneyDiplay.Top.Set(20, 0f);
            moneyDiplay.Width.Set(100f, 0f);
            moneyDiplay.Height.Set(0, 1f);
            coinCounterPanel.Append(moneyDiplay);

            base.Append(coinCounterPanel);
        }