Пример #1
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int deathText = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Death Text"));

            if (deathText != -1)
            {
                layers.Insert(deathText, new LegacyGameInterfaceLayer("Desiccation: Respawn Timer", delegate
                {
                    if (MyPlayer.dead && ModContent.GetInstance <DesiccationClientsideConfig>().RespawnTimer)
                    {
                        DynamicSpriteFontExtensionMethods.DrawString(Main.spriteBatch, Main.fontDeathText, string.Format("{0:f" + ModContent.GetInstance <DesiccationClientsideConfig>().RespawnTimerDecimal + "}", MyPlayer.respawnTimer / 60f), new Vector2((Main.screenWidth / 2) - Main.fontDeathText.MeasureString(string.Format("{0:f" + ModContent.GetInstance <DesiccationClientsideConfig>().RespawnTimerDecimal + "}", MyPlayer.respawnTimer / 60f)).X / 2f, Main.screenHeight / 2 - 70), MyPlayer.GetDeathAlpha(Color.Transparent));
                    }
                    return(true);
                },
                                                                      InterfaceScaleType.UI)
                              );
            }
            int mouseText = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (mouseText != -1)
            {
                layers.Insert(mouseText, new LegacyGameInterfaceLayer("Desiccation: Player Name", delegate
                {
                    if (!Main.gameMenu && ModContent.GetInstance <DesiccationClientsideConfig>().NameInfo&& !DUtils.IsInventoryOpen)
                    {
                        string text         = $"{MyName} in {Main.worldName}";
                        Vector2 size        = Utils.DrawBorderString(Main.spriteBatch, text, new Vector2(DrawData.CenterStringXOnScreen(text, Main.fontMouseText), 2f), Color.WhiteSmoke);
                        Rectangle rectangle = new Rectangle((int)DrawData.CenterStringXOnScreen(text, Main.fontMouseText), 2, (int)size.X + 2, (int)size.Y - 10);
                        if (rectangle.ContainsCursor())
                        {
                            Main.hoverItemName = "Type in chat to change names. '/playername NEW NAME' to change player name, '/worldname NEW NAME' to change world name.";
                        }
                    }
                    return(true);
                },
                                                                      InterfaceScaleType.UI)
                              );
            }
        }