Beispiel #1
0
        public static void ExitToMenu(bool save = true)
        {
            IngameOptions.Close();
            Main.menuMode = 10;

            if (save)
            {
                WorldGen.SaveAndQuit((Action)null);
            }
            else
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state) {
                    Main.invasionProgress            = 0;
                    Main.invasionProgressDisplayLeft = 0;
                    Main.invasionProgressAlpha       = 0f;

                    Main.StopTrackedSounds();
                    CaptureInterface.ResetFocus();
                    Main.ActivePlayerFileData.StopPlayTimer();

                    Main.gameMenu = true;
                    if (Main.netMode != 0)
                    {
                        Netplay.disconnect = true;
                        Main.netMode       = 0;
                    }

                    Main.fastForwardTime = false;
                    Main.UpdateSundial();

                    Main.menuMode = 0;
                }), (Action)null);
            }
        }
        /// <summary>
        /// Loads the UI for mod configs.
        /// </summary>
        /// <param name="config"></param>
        public static void OpenModConfigUI(ModConfig config)
        {
            Type interfaceType = ReflectionHelpers.GetMainAssembly()
                                 .GetType("Terraria.ModLoader.UI.Interface");

            if (!Main.gameMenu)
            {
                IngameOptions.Close();
                IngameFancyUI.CoverNextFrame();
                Main.playerInventory = false;
                Main.editChest       = false;
                Main.npcChatText     = "";
                Main.inFancyUI       = true;
            }
            else
            {
                if (!ReflectionHelpers.Get(interfaceType, null, "modConfigID", out Main.menuMode))
                {
                    LogHelpers.Warn("Could not get Interface.modConfigID");
                    return;
                }
            }

            UIState modConfigInterfaceObj;

            if (!ReflectionHelpers.Get(interfaceType, null, "modConfig", out modConfigInterfaceObj) || modConfigInterfaceObj == null)
            {
                LogHelpers.Warn("Could not get Interface.modConfig");
                return;
            }

            object _;

            if (!ReflectionHelpers.RunMethod(modConfigInterfaceObj, "SetMod", new object[] { config.mod, config }, out _))
            {
                LogHelpers.Warn("Could not run Interface.modConfig.SetMod");
                return;
            }

            Main.InGameUI.SetState(modConfigInterfaceObj);

            Main.PlaySound(SoundID.MenuTick);
        }
Beispiel #3
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            Vector3 hSLVector = colorSet.GetHSLVector();
            DelegateMethods.v3_1 = hSLVector;

            Vector2 pos = GetDimensions().Position().Offset(texture.Width, texture.Height);
            IngameOptions.valuePosition = pos;
            IngameOptions.DrawValueBar(spriteBatch, 1f, hSLVector.X, 0, new Utils.ColorLerpMethod(DelegateMethods.ColorLerp_HSL_H));

            pos = pos.Offset(0, texture.Height * 2);
            IngameOptions.valuePosition = pos;
            IngameOptions.DrawValueBar(spriteBatch, 1f, hSLVector.Y, 0, new Utils.ColorLerpMethod(DelegateMethods.ColorLerp_HSL_S));

            pos = pos.Offset(0, texture.Height * 2);
            IngameOptions.valuePosition = pos;
            IngameOptions.DrawValueBar(spriteBatch, 1f, hSLVector.Z, 0, new Utils.ColorLerpMethod(DelegateMethods.ColorLerp_HSL_L));

            colorSet.SetHSL(hSLVector);
        }
Beispiel #4
0
        public override void HandleMe(ref string label, bool clicked, ref int yPosition, int index)
        {
            int yPos = yPosition;

            base.HandleMe(ref label, clicked, ref yPosition, index);
            int xPos = 390 + Main.screenWidth / 2 - 400 - 100;

            // String 1
            Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontDeathText, this.label, (float)xPos, (float)yPos, Interface.color, Color.Black, Vector2.Zero, 0.5f);
            // String 2
            xPos += 270;            //180;
            if (secondStringOnly)
            {
                xPos -= 270;
            }
            Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontDeathText, estimationString(getter()), (float)xPos, (float)yPos, Interface.color, Color.Black, Vector2.Zero, 0.5f);
            // Slider
            if (!noSlider)
            {
                IngameOptions.valuePosition = new Vector2((float)(Main.screenWidth / 2 - 140), (float)(yPos + 12));                 // line up correctly
                float percent = IngameOptions.DrawValueBar(Main.spriteBatch, 1.3f, getter() / ratio);
                if (IngameOptions.inBar || IngameOptions.rightLock == index)
                {
                    IngameOptions.rightHover = index;
                    if (Main.mouseLeft && IngameOptions.rightLock == index)
                    {
                        setter(ratio * percent);
                    }
                }
                if (IngameOptions.inBar && Interface.keyboardSliderAdjustment != 0)
                {
                    float newPercent = (getter() / ratio + (.001f * Interface.keyboardSliderAdjustment));
                    newPercent = Math.Min(Math.Max(0f, newPercent), 1f);
                    setter(ratio * newPercent);
                }
            }
        }
        /// <summary>
        /// Switches to the list of mod configs menu.
        /// </summary>
        public static void OpenModConfigListUI()
        {
            Type interfaceType = ReflectionLibraries.GetMainAssembly()
                                 .GetType("Terraria.ModLoader.UI.Interface");

            if (!Main.gameMenu)
            {
                IngameOptions.Close();
                IngameFancyUI.CoverNextFrame();
                Main.playerInventory = false;
                Main.editChest       = false;
                Main.npcChatText     = "";
                Main.inFancyUI       = true;
            }
            else
            {
                if (!ReflectionLibraries.Get(interfaceType, null, "modConfigID", out Main.menuMode))
                {
                    LogLibraries.Warn("Could not get Interface.modConfigID");
                    return;
                }
            }

            UIState modConfigListInterfaceObj;

            if (!ReflectionLibraries.Get(interfaceType, null, "modConfigList", out modConfigListInterfaceObj) ||
                modConfigListInterfaceObj == null)
            {
                LogLibraries.Warn("Could not get Interface.modConfigList");
                return;
            }

            Main.InGameUI.SetState(modConfigListInterfaceObj);

            Main.PlaySound(SoundID.MenuTick);
        }
Beispiel #6
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            float num = 6f;

            base.DrawSelf(spriteBatch);
            int num2 = 0;

            IngameOptions.rightHover = -1;
            if (!Main.mouseLeft)
            {
                IngameOptions.rightLock = -1;
            }
            if (IngameOptions.rightLock == _sliderIDInPage)
            {
                num2 = 1;
            }
            else if (IngameOptions.rightLock != -1)
            {
                num2 = 2;
            }
            CalculatedStyle dimensions = GetDimensions();
            float           num3       = dimensions.Width + 1f;
            Vector2         vector     = new Vector2(dimensions.X, dimensions.Y);
            bool            flag       = base.IsMouseHovering;

            if (num2 == 1)
            {
                flag = true;
            }
            if (num2 == 2)
            {
                flag = false;
            }
            Vector2 baseScale = new Vector2(0.8f);
            Color   value     = (false ? Color.Gold : (flag ? Color.White : Color.Silver));

            value = Color.Lerp(value, Color.White, flag ? 0.5f : 0f);
            Color   color    = (flag ? _color : _color.MultiplyRGBA(new Color(180, 180, 180)));
            Vector2 position = vector;

            Utils.DrawSettingsPanel(spriteBatch, position, num3, color);
            position.X += 8f;
            position.Y += 2f + num;
            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, _TextDisplayFunction(), position, value, 0f, Vector2.Zero, baseScale, num3);
            position.X -= 17f;
            TextureAssets.ColorBar.Frame();
            position = (IngameOptions.valuePosition = new Vector2(dimensions.X + dimensions.Width - 10f, dimensions.Y + 10f + num));
            float obj = IngameOptions.DrawValueBar(spriteBatch, 1f, _GetStatusFunction(), num2);

            if (IngameOptions.inBar || IngameOptions.rightLock == _sliderIDInPage)
            {
                IngameOptions.rightHover = _sliderIDInPage;
                if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && !PlayerInput.UsingGamepad && IngameOptions.rightLock == _sliderIDInPage)
                {
                    _SlideKeyboardAction(obj);
                }
            }
            if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
            {
                IngameOptions.rightLock = IngameOptions.rightHover;
            }
            if (base.IsMouseHovering && PlayerInput.CurrentProfile.AllowEditting)
            {
                _SlideGamepadAction();
            }
        }
Beispiel #7
0
 public override void OnClick()
 {
     IngameOptions.Close();
     IngameFancyUI.OpenAchievementsAndGoto(this._achievement);
 }
Beispiel #8
0
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            float num1 = 6f;

            base.DrawSelf(spriteBatch);
            int lockState = 0;

            IngameOptions.rightHover = -1;
            if (!Main.mouseLeft)
            {
                IngameOptions.rightLock = -1;
            }
            if (IngameOptions.rightLock == this._sliderIDInPage)
            {
                lockState = 1;
            }
            else if (IngameOptions.rightLock != -1)
            {
                lockState = 2;
            }
            CalculatedStyle dimensions = this.GetDimensions();
            float           num2       = dimensions.Width + 1f;
            Vector2         vector2    = new Vector2(dimensions.X, dimensions.Y);
            bool            flag1      = false;
            bool            flag2      = this.IsMouseHovering;

            if (lockState == 1)
            {
                flag2 = true;
            }
            if (lockState == 2)
            {
                flag2 = false;
            }
            Vector2 baseScale = new Vector2(0.8f);
            Color   baseColor = Color.Lerp(flag1 ? Color.Gold : (flag2 ? Color.White : Color.Silver), Color.White, flag2 ? 0.5f : 0.0f);
            Color   color     = flag2 ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
            Vector2 position  = vector2;

            Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
            position.X += 8f;
            position.Y += 2f + num1;
            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2, 2f);
            position.X -= 17f;
            Main.colorBarTexture.Frame(1, 1, 0, 0);
            position = new Vector2((float)((double)dimensions.X + (double)dimensions.Width - 10.0), dimensions.Y + 10f + num1);
            IngameOptions.valuePosition = position;
            float num3 = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction(), lockState, (Utils.ColorLerpMethod)null);

            if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
            {
                IngameOptions.rightHover = this._sliderIDInPage;
                if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && (!PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage))
                {
                    this._SlideKeyboardAction(num3);
                }
            }
            if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
            {
                IngameOptions.rightLock = IngameOptions.rightHover;
            }
            if (!this.IsMouseHovering || !PlayerInput.CurrentProfile.AllowEditting)
            {
                return;
            }
            this._SlideGamepadAction();
        }
Beispiel #9
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            PlayerInput.SetZoom_Unscaled();
            PlayerInput.SetZoom_MouseInWorld();
            Microsoft.Xna.Framework.Rectangle rectangle1 = new Microsoft.Xna.Framework.Rectangle((int)((double)Main.mouseX + (double)Main.screenPosition.X), (int)((double)Main.mouseY + (double)Main.screenPosition.Y), 1, 1);
            if ((double)Main.player[Main.myPlayer].gravDir == -1.0)
            {
                rectangle1.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY;
            }
            PlayerInput.SetZoom_UI();
            IngameOptions.MouseOver();
            IngameFancyUI.MouseOver();

            for (int index1 = 0; index1 < 200; ++index1)
            {
                if (Main.npc[index1].active)
                {
                    Rectangle rectangle2 = new Rectangle((int)Main.npc[index1].Bottom.X - Main.npc[index1].frame.Width / 2,
                                                         (int)Main.npc[index1].Bottom.Y - Main.npc[index1].frame.Height,
                                                         Main.npc[index1].frame.Width,
                                                         Main.npc[index1].frame.Height);
                    if (Main.npc[index1].type >= 87 && Main.npc[index1].type <= 92)
                    {
                        rectangle2 = new Rectangle((int)((double)Main.npc[index1].position.X + (double)Main.npc[index1].width * 0.5 - 32.0),
                                                   (int)((double)Main.npc[index1].position.Y + (double)Main.npc[index1].height * 0.5 - 32.0),
                                                   64,
                                                   64);
                    }
                    bool flag1 = rectangle1.Intersects(rectangle2);
                    bool flag2 = flag1 || Main.SmartInteractShowingGenuine && Main.SmartInteractNPC == index1;
                    if (flag2 && (
                            Main.npc[index1].type != 85 &&
                            Main.npc[index1].type != 341 &&
                            Main.npc[index1].aiStyle != 87 ||
                            Main.npc[index1].ai[0] != 0.0) &&
                        Main.npc[index1].type != 488)
                    {
                        if (flag1)
                        {
                            ElementHelper elementHelper = new ElementHelper();

                            float buffer = 4 * Main.UIScale;
                            float prev   = 0;

                            Element Primary    = elementHelper.Primary(Main.npc[index1]);
                            Element Secondary  = elementHelper.Secondary(Main.npc[index1]);
                            Element Tertiary   = elementHelper.Tertiary(Main.npc[index1]);
                            Element Quatrinary = elementHelper.Quatrinary(Main.npc[index1]);

                            var icon1 = GetTexture("Types/" + Formal.Name[Primary]);
                            var icon2 = GetTexture("Types/" + Formal.Name[Secondary]);
                            var icon3 = GetTexture("Types/" + Formal.Name[Tertiary]);
                            var icon4 = GetTexture("Types/" + Formal.Name[Quatrinary]);

                            int yOffset = 38;
                            int xOffset = 12;
                            Main.spriteBatch.Begin();
                            int x = (int)((Main.mouseX + xOffset) * Main.UIScale);
                            int y = (int)((Main.mouseY + yOffset) * Main.UIScale);
                            if (Primary != Element.none && Primary != Element.levitate)
                            {
                                Main.spriteBatch.Draw(icon1, new Vector2(x + prev, y), null, Color.White, 0, new Vector2(0, 0), Main.UIScale, SpriteEffects.None, 0);
                                prev += icon1.Width * Main.UIScale + buffer;
                            }
                            if (Secondary != Element.none && Secondary != Element.levitate)
                            {
                                Main.spriteBatch.Draw(icon2, new Vector2(x + prev, y), null, Color.White, 0, new Vector2(0, 0), Main.UIScale, SpriteEffects.None, 0);
                                prev += icon2.Width * Main.UIScale + buffer;
                            }
                            if (Tertiary != Element.none && Tertiary != Element.levitate)
                            {
                                Main.spriteBatch.Draw(icon3, new Vector2(Main.mouseX + prev, Main.mouseY), null, Color.White, 0, new Vector2(0, 0), Main.UIScale, SpriteEffects.None, 0);
                            }
                            if (Quatrinary != Element.none && Quatrinary != Element.levitate)
                            {
                                Main.spriteBatch.Draw(icon4, new Vector2(x, y + icon1.Width * Main.UIScale + buffer), null, Color.White, 0, new Vector2(0, 0), Main.UIScale, SpriteEffects.None, 0);
                            }
                            Main.spriteBatch.End();
                            break;
                        }
                        break;
                    }
                }
            }

            //PlayerInput.SetZoom_UI();
            base.ModifyInterfaceLayers(layers);
        }
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            float num1 = 6f;

            base.DrawSelf(spriteBatch);
            int lockState = 0;

            IngameOptions.rightHover = -1;
            if (!Main.mouseLeft)
            {
                IngameOptions.rightLock = -1;
            }
            if (IngameOptions.rightLock == this._sliderIDInPage)
            {
                lockState = 1;
            }
            else if (IngameOptions.rightLock != -1)
            {
                lockState = 2;
            }
            CalculatedStyle dimensions = this.GetDimensions();
            float           num2       = dimensions.Width + 1f;
            Vector2         vector2;

            // ISSUE: explicit reference operation
            ((Vector2)@vector2).\u002Ector(dimensions.X, dimensions.Y);
            bool flag1 = false;
            bool flag2 = this.IsMouseHovering;

            if (lockState == 1)
            {
                flag2 = true;
            }
            if (lockState == 2)
            {
                flag2 = false;
            }
            Vector2 baseScale;

            // ISSUE: explicit reference operation
            ((Vector2)@baseScale).\u002Ector(0.8f);
            Color   baseColor = Color.Lerp(flag1 ? Color.get_Gold() : (flag2 ? Color.get_White() : Color.get_Silver()), Color.get_White(), flag2 ? 0.5f : 0.0f);
            Color   color     = flag2 ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
            Vector2 position  = vector2;

            Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Vector2& local1 = @position;
            // ISSUE: explicit reference operation
            double num3 = (^ local1).X + 8.0;

            // ISSUE: explicit reference operation
            (^ local1).X = (__Null)num3;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Vector2& local2 = @position;
            // ISSUE: explicit reference operation
            double num4 = (^ local2).Y + (2.0 + (double)num1);

            // ISSUE: explicit reference operation
            (^ local2).Y = (__Null)num4;
            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction.Invoke(), position, baseColor, 0.0f, Vector2.get_Zero(), baseScale, num2, 2f);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Vector2& local3 = @position;
            // ISSUE: explicit reference operation
            double num5 = (^ local3).X - 17.0;

            // ISSUE: explicit reference operation
            (^ local3).X = (__Null)num5;
            Main.colorBarTexture.Frame(1, 1, 0, 0);
            // ISSUE: explicit reference operation
            ((Vector2)@position).\u002Ector((float)((double)dimensions.X + (double)dimensions.Width - 10.0), dimensions.Y + 10f + num1);
            IngameOptions.valuePosition = position;
            float num6 = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction.Invoke(), lockState, (Utils.ColorLerpMethod)null);

            if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
            {
                IngameOptions.rightHover = this._sliderIDInPage;
                if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && (!PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage))
                {
                    this._SlideKeyboardAction(num6);
                }
            }
            if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
            {
                IngameOptions.rightLock = IngameOptions.rightHover;
            }
            if (!this.IsMouseHovering || !PlayerInput.CurrentProfile.AllowEditting)
            {
                return;
            }
            this._SlideGamepadAction.Invoke();
        }
Beispiel #11
0
 public override void PostUpdate()
 {
     if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F11))
     {
         hideMode = Main.hideUI;
     }
     if (Main.hideUI)
     {
         if (PlayerInput.Triggers.JustPressed.Inventory)
         {
             IngameOptions.Open();
             Main.hideUI = false;
         }
         #region talkNPC
         Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1);
         if (Main.player[Main.myPlayer].gravDir == -1f)
         {
             rectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY;
         }
         for (int k = 0; k < 200; k++)
         {
             if (Main.npc[k].active)
             {
                 int type = Main.npc[k].type;
                 Main.instance.LoadNPC(type);
                 Microsoft.Xna.Framework.Rectangle value3 = new Microsoft.Xna.Framework.Rectangle((int)Main.npc[k].Bottom.X - Main.npc[k].frame.Width / 2, (int)Main.npc[k].Bottom.Y - Main.npc[k].frame.Height, Main.npc[k].frame.Width, Main.npc[k].frame.Height);
                 if (Main.npc[k].type >= 87 && Main.npc[k].type <= 92)
                 {
                     value3 = new Microsoft.Xna.Framework.Rectangle((int)((double)Main.npc[k].position.X + (double)Main.npc[k].width * 0.5 - 32.0), (int)((double)Main.npc[k].position.Y + (double)Main.npc[k].height * 0.5 - 32.0), 64, 64);
                 }
                 bool flag = rectangle.Intersects(value3);
                 if (flag && ((Main.npc[k].type != 85 && Main.npc[k].type != 341 && Main.npc[k].aiStyle != 87) || Main.npc[k].ai[0] != 0f) && Main.npc[k].type != 488)
                 {
                     bool flag3 = Main.SmartInteractShowingGenuine && Main.SmartInteractNPC == k;
                     if (Main.npc[k].townNPC || Main.npc[k].type == 105 || Main.npc[k].type == 106 || Main.npc[k].type == 123 || Main.npc[k].type == 354 || Main.npc[k].type == 376 || Main.npc[k].type == 579 || Main.npc[k].type == 453)
                     {
                         Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle((int)(Main.player[Main.myPlayer].position.X + (float)(Main.player[Main.myPlayer].width / 2) - (float)(Player.tileRangeX * 16)), (int)(Main.player[Main.myPlayer].position.Y + (float)(Main.player[Main.myPlayer].height / 2) - (float)(Player.tileRangeY * 16)), Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2);
                         Microsoft.Xna.Framework.Rectangle value4     = new Microsoft.Xna.Framework.Rectangle((int)Main.npc[k].position.X, (int)Main.npc[k].position.Y, Main.npc[k].width, Main.npc[k].height);
                         if (rectangle2.Intersects(value4))
                         {
                             flag3 = true;
                         }
                     }
                     if (Main.player[Main.myPlayer].ownedProjectileCounts[651] > 0)
                     {
                         flag3 = false;
                     }
                     if (flag3 && !Main.player[Main.myPlayer].dead)
                     {
                         PlayerInput.SetZoom_MouseInWorld();
                         Main.HoveringOverAnNPC = true;
                         Main.instance.currentNPCShowingChatBubble = k;
                         if (Main.mouseRight && Main.mouseRightRelease)
                         {
                             Main.npcChatRelease = false;
                             if (PlayerInput.UsingGamepad)
                             {
                                 Main.player[Main.myPlayer].releaseInventory = false;
                             }
                             if (Main.player[Main.myPlayer].talkNPC != k)
                             {
                                 Main.CancelHairWindow();
                                 Main.npcShop          = 0;
                                 Main.InGuideCraftMenu = false;
                                 Main.player[Main.myPlayer].dropItemCheck();
                                 Main.npcChatCornerItem          = 0;
                                 Main.player[Main.myPlayer].sign = -1;
                                 Main.editSign = false;
                                 Main.player[Main.myPlayer].talkNPC = k;
                                 Main.playerInventory             = false;
                                 Main.player[Main.myPlayer].chest = -1;
                                 Recipe.FindRecipes();
                                 Main.npcChatText = Main.npc[k].GetChat();
                                 break;
                                 //Main.PlaySound(24, -1, -1, 1, 1f, 0f);
                             }
                         }
                     }
                 }
             }
         }
         #endregion
     }
     if (Main.playerInventory && hideMode)
     {
         Main.playerInventory = false;
         Main.hideUI          = true;
     }
     //random buy item
     if (player.talkNPC >= 0)
     {
         setNPCShop();
         if (Main.npcShop > 0)
         {
             Chest.SetupTravelShop();
             Main.instance.shop[Main.npcShop].SetupShop(Main.npcShop);
             List <int> tryBuyIndex = new List <int>();
             Item[]     shopItem    = Main.instance.shop[Main.npcShop].item;
             int        length      = shopItem.Length;
             for (int i = 0; i < length; i++)
             {
                 if (shopItem[i].type != 0 && shopItem[i].stack != 0)
                 {
                     tryBuyIndex.Add(i);
                 }
             }
             int n = tryBuyIndex.Count;
             while (n > 1)
             {
                 n--;
                 int k     = Main.rand.Next(n + 1);
                 int value = tryBuyIndex[k];
                 tryBuyIndex[k] = tryBuyIndex[n];
                 tryBuyIndex[n] = value;
             }
             for (int i = 0; i < n; i++)
             {
                 if (player.BuyItem(shopItem[tryBuyIndex[i]].GetStoreValue(), shopItem[tryBuyIndex[i]].shopSpecialCurrency))
                 {
                     Item.NewItem(player.position + player.Size / 2, shopItem[tryBuyIndex[i]].type, shopItem[tryBuyIndex[i]].stack, false, shopItem[tryBuyIndex[i]].prefix, true);
                     player.talkNPC = -1;
                     Main.npcShop   = 0;
                     Main.PlaySound(18);
                     break;
                 }
             }
         }
     }
 }
Beispiel #12
0
 protected override void DrawSelf(SpriteBatch spriteBatch)
 {
     IngameOptions.valuePosition = GetDimensions().Position().Offset(Main.colorBarTexture.Width, Main.colorBarTexture.Height);
     IngameOptions.DrawValueBar(spriteBatch, 1f, Value);
 }
Beispiel #13
0
 public override void OnClick()
 {
     IngameOptions.Close();
     AchievementsUI.OpenAndGoto(_achievement);
 }
Beispiel #14
0
        public void GetDetails()
        {
            PlayerInput.SetZoom_Unscaled();
            PlayerInput.SetZoom_MouseInWorld();
            Rectangle mouseRectangle = new Rectangle((int)((float)Main.mouseX + Main.screenPosition.X), (int)((float)Main.mouseY + Main.screenPosition.Y), 1, 1);

            if (Main.player[Main.myPlayer].gravDir == -1f)
            {
                mouseRectangle.Y = (int)Main.screenPosition.Y + Main.screenHeight - Main.mouseY;
            }
            Rectangle screenRectangle = new Rectangle((int)(Main.screenPosition.X), (int)(Main.screenPosition.Y), Main.screenWidth, Main.screenHeight);

            PlayerInput.SetZoom_UI();
            IngameOptions.MouseOver();
            IngameFancyUI.MouseOver();

            Main.HoveringOverAnNPC = false;
            NPC    ActualNPC;
            string TempText = "";
            UIText panel;

            for (int k = 0; k < 200; k++)
            {
                ActualNPC = Main.npc[k];
                if (ActualNPC.active && !ActualNPC.dontCountMe)
                {
                    int       type   = Main.npc[k].type;
                    Rectangle NPCPos = new Rectangle((int)ActualNPC.Bottom.X - ActualNPC.frame.Width / 2, (int)ActualNPC.Bottom.Y - ActualNPC.frame.Height, ActualNPC.frame.Width, ActualNPC.frame.Height);
                    if (ActualNPC.type >= 87 && ActualNPC.type <= 92)
                    {
                        NPCPos = new Rectangle((int)(ActualNPC.position.X + ActualNPC.width * 0.5 - 32.0), (int)(ActualNPC.position.Y + ActualNPC.height * 0.5 - 32.0), 64, 64);
                    }
                    bool IsMouseOver = mouseRectangle.Intersects(NPCPos);
                    bool IsOnScreen  = screenRectangle.Intersects(NPCPos);
                    if (IsMouseOver)
                    {
                        Main.player[Main.myPlayer].showItemIcon = false;

                        ARPGGlobalNPC Rnpc   = ActualNPC.GetGlobalNPC <ARPGGlobalNPC>();
                        string        preFix = "";
                        if (Rnpc.getLevel >= 0 && ActualNPC.damage > 0)
                        {
                            preFix = "Level : " + (Rnpc.getLevel + Rnpc.getTier) + "\n";

                            //  if (NPCUtils.GetWorldTier(ActualNPC, Rnpc.getLevel) > 0)
                            //      preFix += "World bonus level : +" + NPCUtils.GetWorldTier(ActualNPC, Rnpc.getLevel) + "\n";
                        }
                        TempText = "";

                        if (Main.npc[k].lifeMax > 1 && !Main.npc[k].dontTakeDamage)
                        {
                            TempText = string.Concat(new object[]
                            {
                                preFix,
                                "Rank : ",
                                (NPCRank)Rnpc.getRank,
                                "\nDamage : ",
                                Main.npc[k].damage,
                                "\nDef : ",
                                Main.npc[k].defense
                            });
                        }
                        panel = new UIText(TempText);


                        NPCDetails = new NPCInfoUI(TempText, Color.White, new Vector2(Main.mouseX, Main.mouseY));
                    }
                    else if (IsOnScreen && ((Config.vConfig.DisplayNpcName && !ActualNPC.townNPC) || (Config.vConfig.DisplayTownName && ActualNPC.townNPC)))
                    {
                        Main.player[Main.myPlayer].showItemIcon = false;
                        TempText = ActualNPC.GivenOrTypeName;
                        RPGModule.Entities.ARPGGlobalNPC Rnpc = ActualNPC.GetGlobalNPC <RPGModule.Entities.ARPGGlobalNPC>();
                        string preFix = "";
                        if (Rnpc.getLevel >= 0 && ActualNPC.damage > 0)
                        {
                            preFix = "Lvl." + (Rnpc.getLevel + Rnpc.getTier);

                            /*
                             * if (NPCUtils.GetWorldTier(ActualNPC, Rnpc.getLevel) > 0)
                             *  preFix += "( + " + RPGModule.Entities.NPCUtils.GetWorldTier(ActualNPC, Rnpc.getLevel) + " )";
                             */
                        }

                        TempText = "";

                        if (Main.npc[k].lifeMax > 1 && !Main.npc[k].dontTakeDamage)
                        {
                            TempText = string.Concat(new object[]
                            {
                                preFix,
                                " | ",
                                //ActualNPC.GivenOrTypeName,
                                //": ",
                                Main.npc[k].life,
                                "/",
                                Main.npc[k].lifeMax
                            });
                        }
                        int NpcColor    = 0;
                        int LevelOffSet = (ActualNPC.GetGlobalNPC <ARPGGlobalNPC>().getLevel + ActualNPC.GetGlobalNPC <RPGModule.Entities.ARPGGlobalNPC>().getTier) - Main.LocalPlayer.GetModPlayer <RPGModule.Entities.RPGPlayer>().GetLevel();
                        if (LevelOffSet < -100)
                        {
                            NpcColor = 0;
                        }
                        else if (LevelOffSet < -50)
                        {
                            NpcColor = 1;
                        }
                        else if (LevelOffSet < -15)
                        {
                            NpcColor = 2;
                        }
                        else if (LevelOffSet < -5)
                        {
                            NpcColor = 3;
                        }
                        else if (LevelOffSet < 5)
                        {
                            NpcColor = 4;
                        }
                        else if (LevelOffSet < 20)
                        {
                            NpcColor = 5;
                        }
                        else if (LevelOffSet < 40)
                        {
                            NpcColor = 6;
                        }
                        else if (LevelOffSet < 75)
                        {
                            NpcColor = 7;
                        }
                        else if (LevelOffSet < 100)
                        {
                            NpcColor = 8;
                        }
                        else
                        {
                            NpcColor = 9;
                        }

                        switch (ActualNPC.GetGlobalNPC <ARPGGlobalNPC>().getRank)
                        {
                        case 0:
                            NpcColor--;
                            break;

                        case 2:
                        case 3:
                            NpcColor++;
                            break;

                        case 4:
                        case 5:
                            NpcColor += 2;
                            break;

                        case 6:
                        case 7:
                            NpcColor += 3;
                            break;
                        }

                        if (ActualNPC.townNPC)
                        {
                            NpcColor = 0;
                        }
                        NPCName.Add(new NPCInfoUI(TempText, ColorDic[NpcColor], new Vector2(ActualNPC.Bottom.X - Main.screenPosition.X, ActualNPC.Bottom.Y - Main.screenPosition.Y)));
                    }
                }
            }
        }
        // Token: 0x060010E7 RID: 4327 RVA: 0x00407DF4 File Offset: 0x00405FF4
        protected override void DrawSelf(SpriteBatch spriteBatch)
        {
            float num = 6f;

            base.DrawSelf(spriteBatch);
            int num2 = 0;

            IngameOptions.rightHover = -1;
            if (!Main.mouseLeft)
            {
                IngameOptions.rightLock = -1;
            }
            if (IngameOptions.rightLock == this._sliderIDInPage)
            {
                num2 = 1;
            }
            else if (IngameOptions.rightLock != -1)
            {
                num2 = 2;
            }
            CalculatedStyle dimensions = base.GetDimensions();
            float           num3       = dimensions.Width + 1f;
            Vector2         arg_EB_0   = new Vector2(dimensions.X, dimensions.Y);
            bool            arg_85_0   = false;
            bool            flag       = base.IsMouseHovering;

            if (num2 == 1)
            {
                flag = true;
            }
            if (num2 == 2)
            {
                flag = false;
            }
            Vector2 baseScale = new Vector2(0.8f);
            Color   color     = arg_85_0 ? Color.Gold : (flag ? Color.White : Color.Silver);

            color = Color.Lerp(color, Color.White, flag ? 0.5f : 0f);
            Color   color2 = flag ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
            Vector2 vector = arg_EB_0;

            Utils.DrawSettingsPanel(spriteBatch, vector, num3, color2);
            vector.X += 8f;
            vector.Y += 2f + num;
            ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction(), vector, color, 0f, Vector2.Zero, baseScale, num3, 2f);
            vector.X -= 17f;
            Main.colorBarTexture.Frame(1, 1, 0, 0);
            vector = new Vector2(dimensions.X + dimensions.Width - 10f, dimensions.Y + 10f + num);
            IngameOptions.valuePosition = vector;
            float obj = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction(), num2, null);

            if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
            {
                IngameOptions.rightHover = this._sliderIDInPage;
                if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && !PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage)
                {
                    this._SlideKeyboardAction(obj);
                }
            }
            if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
            {
                IngameOptions.rightLock = IngameOptions.rightHover;
            }
            if (base.IsMouseHovering && PlayerInput.CurrentProfile.AllowEditting)
            {
                this._SlideGamepadAction();
            }
        }