コード例 #1
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            if (DynamicInvasionsMod.Config == null || !DynamicInvasionsMod.Config.Enabled)
            {
                return;
            }
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Invasion Progress Bars"));

            if (idx != -1)
            {
                var func = new GameInterfaceDrawMethod(delegate() {
                    if (Main.netMode != 2)                                 // Not server
                    {
                        var modworld = ModContent.GetInstance <DynamicInvasionsWorld>();

                        if (modworld.Logic.RunProgressBarAnimation())
                        {
                            modworld.Logic.DrawProgressBar(Main.spriteBatch);
                        }
                    }
                    return(true);
                });
                var layer = new LegacyGameInterfaceLayer(
                    "DynamicInvasions: Progress",
                    func,
                    InterfaceScaleType.UI
                    );

                layers.Insert(idx, layer);
            }
        }
コード例 #2
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            //

            GameInterfaceDrawMethod cpDrawCallback = () => {
                this.DrawCP(Main.spriteBatch);
                return(true);
            };

            //

            if (LoadLibraries.IsCurrentPlayerInGame())
            {
                var cpLayer = new LegacyGameInterfaceLayer("ModControlPanel: Control Panel",
                                                           cpDrawCallback,
                                                           InterfaceScaleType.UI);
                layers.Insert(idx, cpLayer);
            }
        }
コード例 #3
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            //

            GameInterfaceDrawMethod debugDrawCallback = () => {
                try {
                    ModContent.GetInstance <PlayerMessages>().Draw(Main.spriteBatch);
                } catch (Exception e) {
                    LogLibraries.Warn(e.ToString());
                }
                return(true);
            };

            //

            if (LoadLibraries.IsCurrentPlayerInGame())
            {
                var debugLayer = new LegacyGameInterfaceLayer("ModLibsGeneral: Debug Display",
                                                              debugDrawCallback,
                                                              InterfaceScaleType.UI);
                layers.Insert(idx, debugLayer);
            }
        }
コード例 #4
0
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));

            if (idx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod func = delegate {
                Player player   = Main.LocalPlayer;
                Item   heldItem = player.HeldItem;

                if (heldItem == null || heldItem.IsAir || heldItem.type != ModContent.ItemType <PaintBlasterItem>())
                {
                    return(true);
                }

                var myitem = (PaintBlasterItem)heldItem.modItem;

                if (myitem.IsUsingUI)
                {
                    myitem.DrawPainterUI(Main.spriteBatch);
                }
                myitem.DrawScreen(Main.spriteBatch);
                myitem.DrawHUD(Main.spriteBatch);

                return(true);
            };

            var interfaceLayer = new LegacyGameInterfaceLayer("BetterPaint: Paint Blaster UI", func, InterfaceScaleType.UI);

            layers.Insert(idx, interfaceLayer);
        }
コード例 #5
0
 public LegacyGameInterfaceLayer(
     string name,
     GameInterfaceDrawMethod drawMethod,
     InterfaceScaleType scaleType = InterfaceScaleType.Game)
     : base(name, scaleType)
 {
     this._drawMethod = drawMethod;
 }
コード例 #6
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int layerIdx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));

            if (layerIdx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod invOver = delegate {
                if (!Main.playerInventory)
                {
                    return(true);
                }

                var mymod = EncumbranceMod.Instance;
                if (mymod.Config.BurdenedItemSlotOverlayOpacity == 0f)
                {
                    return(true);
                }

                var myplayer = (EncumbrancePlayer)TmlHelpers.SafelyGetModPlayer(Main.LocalPlayer, this, "EncumbrancePlayer");
                int capacity = myplayer.GetCurrentCapacity();

                float invScale = 0.85f;
                //if( (plr.chest != -1 || Main.npcShop > 0) && !Main.recBigList ) {
                //	inv_scale = 0.755f;
                //}

                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        int idx = i + j * 10;

                        if (idx < capacity)
                        {
                            continue;
                        }

                        Texture2D tex   = this.ShadowBox;
                        int       posX  = (int)(20f + ((float)i * 56f) * invScale);
                        int       posY  = (int)(20f + ((float)j * 56f) * invScale);
                        var       pos   = new Vector2(posX, posY);
                        Color     color = Color.White * mymod.Config.BurdenedItemSlotOverlayOpacity;

                        Main.spriteBatch.Draw(tex, pos, null, color, 0f, default(Vector2), invScale, SpriteEffects.None, 1f);
                    }
                }

                return(true);
            };

            var invOverLayer = new LegacyGameInterfaceLayer("Encumbrance: Inventory Overlay", invOver, InterfaceScaleType.UI);

            layers.Insert(layerIdx + 1, invOverLayer);
        }
コード例 #7
0
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int layerIdx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));

            if (layerIdx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod controlUi = delegate {
                if (!Main.playerInventory || Main.myPlayer < 0 || Main.LocalPlayer == null || !Main.LocalPlayer.active)
                {
                    if (Main.LocalPlayer != null && !Main.LocalPlayer.active)
                    {
                        TmlHelpers.SafelyGetModPlayer <ExtensibleInventoryPlayer>(Main.LocalPlayer);
                        if (!Main.LocalPlayer.active)
                        {
                            return(true);
                        }
                    }
                    //if( Main.playerInventory ) {
                    //	LogHelpers.LogOnce( ""+(Main.myPlayer<0)+","+(Main.LocalPlayer == null)+","+(!Main.LocalPlayer.active) );
                    //}
                    return(true);
                }

                var mymod = ExtensibleInventoryMod.Instance;

                try {
                    mymod.InvUIMngr?.Update(Main._drawInterfaceGameTime);
                    mymod.InvUI?.Draw(Main.spriteBatch);

                    if (!this.Config.HideScrollModeIcon)
                    {
                        var myplayer = TmlHelpers.SafelyGetModPlayer <ExtensibleInventoryPlayer>(Main.LocalPlayer);
                        if (myplayer.ScrollModeOn & this.ScrollIcon != null)
                        {
                            var   pos        = new Vector2(Main.mouseX - 24, Main.mouseY);
                            float colorScale = 0.35f * ((float)myplayer.ScrollModeDuration / (float)ExtensibleInventoryPlayer.ScrollModeMaxDuration);

                            Main.spriteBatch.Draw(this.ScrollIcon, pos, Color.White * colorScale);
                        }
                    }
                } catch (Exception e) {
                    throw new ModHelpersException("", e);
                }

                return(true);
            };

            var invOverLayer = new LegacyGameInterfaceLayer("Extensible Inventory: Page Controls", controlUi, InterfaceScaleType.UI);

            layers.Insert(layerIdx + 1, invOverLayer);
        }
コード例 #8
0
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            var loadLibs = ModContent.GetInstance <LoadLibraries>();

            if (loadLibs == null)
            {
                return;
            }

            //

            var layerDisable = LayerDisable.Instance;

            foreach (GameInterfaceLayer layer in layers)
            {
                if (layerDisable.DisabledLayers.Contains(layer.Name))
                {
                    layer.Active = false;
                }
            }

            //

            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            //

            GameInterfaceDrawMethod hudDrawCallback = () => {
                FreeHUD.Instance?.UIContext.Draw(Main.spriteBatch, Main._drawInterfaceGameTime);
                return(true);
            };

            //

            if (LoadLibraries.IsCurrentPlayerInGame())
            {
                var hudLayer = new LegacyGameInterfaceLayer("ModLibsUI: HUD UI",
                                                            hudDrawCallback,
                                                            InterfaceScaleType.UI);
                layers.Insert(idx, hudLayer);
            }
        }
コード例 #9
0
ファイル: InjuryMod.cs プロジェクト: hamstar0/tml-injury-mod
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Resource Bars"));                   //Vanilla: Inventory

            if (idx != -1)
            {
                GameInterfaceDrawMethod func = delegate {
                    this.HealthLoss.DrawSubHealth(this, Main.spriteBatch);
                    this.HealthLoss.DrawCurrentHeartDropAnimation(this, Main.spriteBatch);

                    return(true);
                };
                var interfaceLayer = new LegacyGameInterfaceLayer("Injury: Heart Overlay", func, InterfaceScaleType.UI);

                layers.Insert(idx + 1, interfaceLayer);
            }
        }
コード例 #10
0
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            if (this.HUDData == null)
            {
                return;
            }

            int cursorIdx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Cursor"));

            if (cursorIdx == -1)
            {
                return;
            }

            var crosshairHUD = ModContent.GetInstance <CrosshairHUD>();

            //

            GameInterfaceDrawMethod draw = () => {
                crosshairHUD.DrawIf(Main.spriteBatch, this.HUDData);

                if (TMRConfig.Instance.DebugModeInfo)
                {
                    this.DrawDebugLine();
                }
                return(true);
            };

            var interfaceLayer = new LegacyGameInterfaceLayer(
                "TheMadRanger: Crosshair",
                draw,
                InterfaceScaleType.UI
                );

            //

            if (crosshairHUD.ConsumesCursor(this.HUDData))
            {
                layers.RemoveAt(cursorIdx);
            }

            layers.Insert(cursorIdx, interfaceLayer);
        }
コード例 #11
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Inventory"));

            if (idx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod locksUI = () => {
                if (Main.playerInventory && Main.EquipPage == 0)                    //== 2 is misc page
                {
                    this.DrawDisabledAccessorySlotOverlays(Main.spriteBatch);
                }
                return(true);
            };

            var tradeLayer = new LegacyGameInterfaceLayer("LockedAbilities: Accessory Locks", locksUI, InterfaceScaleType.UI);

            layers.Insert(idx + 1, tradeLayer);
        }
コード例 #12
0
        ////

        private void AddTitleDisplayLayer(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod ui = () => {
                Cutscene cutscene = CutsceneManager.Instance.GetCurrentCutscene_Player(Main.LocalPlayer);
                if (cutscene != null)
                {
                    cutscene.DrawInterface();
                }
                return(true);
            };

            ////

            var tradeLayer = new LegacyGameInterfaceLayer("Cutscene Lib: Titles", ui, InterfaceScaleType.UI);

            layers.Insert(idx, tradeLayer);
        }
コード例 #13
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx != -1)
            {
                GameInterfaceDrawMethod drawMethod = delegate {
                    if (!LoadHelpers.IsWorldSafelyBeingPlayed())
                    {
                        return(true);
                    }

                    try {
                        var      myworld = ModContent.GetInstance <RewardsWorld>();
                        KillData data    = myworld.Logic.GetPlayerData(Main.LocalPlayer);

                        if (data == null)
                        {
                            throw new ModHelpersException("No player data for " + Main.LocalPlayer.name);
                        }

                        if (data.CanDrawPoints())
                        {
                            data.DrawPointScore(Main.spriteBatch);
                        }
                    } catch (Exception) { }

                    return(true);
                };

                var interfaceLayer = new LegacyGameInterfaceLayer("Rewards: Points", drawMethod,
                                                                  InterfaceScaleType.UI);

                layers.Insert(idx, interfaceLayer);
            }
        }
コード例 #14
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            if (this.LoadHelpers != null && !TmlHelpers.LoadHelpers.IsWorldBeingPlayed())
            {
                return;
            }

            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod debug_layer_draw = delegate {
                var sb = Main.spriteBatch;

                this.PlayerMessages.Draw(sb);
                SimpleMessage.DrawMessage(sb);

                DebugHelpers.DebugHelpers.PrintToBatch(sb);
                DebugHelpers.DebugHelpers.Once = false;
                DebugHelpers.DebugHelpers.OnceInAWhile--;
                return(true);
            };

            GameInterfaceDrawMethod cp_layer_draw = delegate {
                var sb = Main.spriteBatch;

                if (!this.Config.DisableControlPanel)
                {
                    this.ControlPanel.UpdateToggler();
                    this.ControlPanel.DrawToggler(sb);
                }
                if (this.LastSeenCPScreenWidth != Main.screenWidth || this.LastSeenCPScreenHeight != Main.screenHeight)
                {
                    this.LastSeenCPScreenWidth  = Main.screenWidth;
                    this.LastSeenCPScreenHeight = Main.screenHeight;
                    this.ControlPanel.RecalculateMe();
                }

                this.Inbox.Draw(sb);

//sb.DrawString( Main.fontDeathText, "ALERT", new Vector2(128, 128), this.AnimatedColors.Alert.CurrentColor );
//sb.DrawString( Main.fontDeathText, "STROBE", new Vector2(128, 256), this.AnimatedColors.Strobe.CurrentColor );
//sb.DrawString( Main.fontDeathText, "FIRE", new Vector2(128, 320), this.AnimatedColors.Fire.CurrentColor );
//sb.DrawString( Main.fontDeathText, "WATER", new Vector2(128, 384), this.AnimatedColors.Water.CurrentColor );
//sb.DrawString( Main.fontDeathText, "AIR", new Vector2(128, 448), this.AnimatedColors.Air.CurrentColor );
                return(true);
            };

            GameInterfaceDrawMethod modlock_layer_draw = delegate {
                this.ModLockHelpers.DrawWarning(Main.spriteBatch);
                return(true);
            };


            var debug_layer = new LegacyGameInterfaceLayer("HamstarHelpers: Debug Display",
                                                           debug_layer_draw, InterfaceScaleType.UI);

            layers.Insert(idx, debug_layer);

            var modlock_layer = new LegacyGameInterfaceLayer("HamstarHelpers: Mod Lock",
                                                             modlock_layer_draw, InterfaceScaleType.UI);

            layers.Insert(idx, modlock_layer);

            if (!this.Config.DisableControlPanel)
            {
                var cp_layer = new LegacyGameInterfaceLayer("HamstarHelpers: Control Panel",
                                                            cp_layer_draw, InterfaceScaleType.UI);
                layers.Insert(idx, cp_layer);
            }
        }
コード例 #15
0
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_A", 1 );
            if (this.LoadHelpers != null && !LoadHelpers.IsWorldBeingPlayed())
            {
                return;
            }

            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod debugDrawCallback = () => {
                var sb = Main.spriteBatch;

                try {
                    this.PlayerMessages.Draw(sb);

                    DebugHelpers.PrintAll(sb);
                } catch (Exception e) {
                    LogHelpers.Warn("debugLayerDraw - " + e.ToString());
                }
                return(true);
            };

            GameInterfaceDrawMethod cpDrawCallback = () => {
                var sb = Main.spriteBatch;

                try {
                    if (!ModHelpersMod.Config.DisableControlPanel)
                    {
                        this.ControlPanel.UpdateToggler();
                        this.ControlPanel.DrawToggler(sb);
                    }
                    if (this.LastSeenCPScreenWidth != Main.screenWidth || this.LastSeenCPScreenHeight != Main.screenHeight)
                    {
                        this.LastSeenCPScreenWidth  = Main.screenWidth;
                        this.LastSeenCPScreenHeight = Main.screenHeight;
                        this.ControlPanel.RecalculateMe();
                    }

                    this.Inbox.Draw(sb);
                } catch (Exception e) {
                    LogHelpers.Warn("cpLayerDraw - " + e.ToString());
                }

                return(true);
            };

            GameInterfaceDrawMethod modlockDrawCallback = delegate {
                try {
                    this.ModLock.DrawWarning(Main.spriteBatch);
                } catch (Exception e) {
                    LogHelpers.Warn("modlockLayerDraw - " + e.ToString());
                }
                return(true);
            };

            ////

            var debugLayer = new LegacyGameInterfaceLayer("ModHelpers: Debug Display",
                                                          debugDrawCallback,
                                                          InterfaceScaleType.UI);

            layers.Insert(idx, debugLayer);

            var modlockLayer = new LegacyGameInterfaceLayer("ModHelpers: Mod Lock",
                                                            modlockDrawCallback,
                                                            InterfaceScaleType.UI);

            layers.Insert(idx, modlockLayer);

            var cpLayer = new LegacyGameInterfaceLayer("ModHelpers: Control Panel",
                                                       cpDrawCallback,
                                                       InterfaceScaleType.UI);

            layers.Insert(idx, cpLayer);
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_B", 1 );
        }
コード例 #16
0
        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            //

            GameInterfaceDrawMethod haggleUI = () => {
                this.UIContext?.Update(Main._drawInterfaceGameTime);
                this.UIContext?.Draw(Main.spriteBatch, Main._drawInterfaceGameTime);
                return(true);
            };

            GameInterfaceDrawMethod raidUI = () => {
                var logic = PirateLogic.Instance;
                if (Main.playerInventory || !logic.IsRaidingForMe(Main.LocalPlayer))
                {
                    return(true);
                }

                var  config           = PDYBConfig.Instance;
                long remainingSeconds = config.RaidDurationTicks - logic.RaidElapsedTicks;
                remainingSeconds /= 60;
                long remainingMinutes = remainingSeconds / 60;
                remainingSeconds %= 60;
                string msg = "Pirate raid time left: " + remainingMinutes.ToString("00") + ":" + remainingSeconds.ToString("00");

                string  msgAlt = "Pirate raid time left: 00:00";
                Vector2 strDim = Main.fontMouseText.MeasureString(msgAlt);
                float   scale  = 1f;

                Utils.DrawBorderStringFourWay(
                    sb: Main.spriteBatch,
                    font: Main.fontMouseText,
                    text: msg,
                    x: config.RaidTimerPositionX >= 0
                                                ? config.RaidTimerPositionX
                                                : (Main.screenWidth - (int)(strDim.X * scale)) + config.RaidTimerPositionX,
                    y: config.RaidTimerPositionY >= 0
                                                ? config.RaidTimerPositionY
                                                : Main.screenHeight + config.RaidTimerPositionY,
                    textColor: Color.Yellow,
                    borderColor: Color.Black,
                    origin: default(Vector2),
                    scale: scale
                    );

                return(true);
            };

            //

            var tradeLayer = new LegacyGameInterfaceLayer("PDYB: Haggle UI", haggleUI, InterfaceScaleType.UI);

            layers.Insert(idx, tradeLayer);
            var raidLayer = new LegacyGameInterfaceLayer("PDYB: Raid UI", raidUI, InterfaceScaleType.UI);

            layers.Insert(idx, raidLayer);
        }
コード例 #17
0
        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_A", 1 );
            if (this.LoadHelpers != null && !LoadHelpers.IsWorldBeingPlayed())
            {
                return;
            }

            int idx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (idx == -1)
            {
                return;
            }

            GameInterfaceDrawMethod debugDrawCallback = () => {
                var sb = Main.spriteBatch;

                try {
                    this.PlayerMessages.Draw(sb);
                    SimpleMessage.DrawMessage(sb);

                    DebugHelpers.PrintAll(sb);
                    DebugHelpers.Once = false;
                    DebugHelpers.OnceInAWhile--;
                } catch (Exception e) {
                    LogHelpers.Warn("debugLayerDraw - " + e.ToString());
                }
                return(true);
            };

            GameInterfaceDrawMethod cpDrawCallback = () => {
                var sb = Main.spriteBatch;

                try {
                    if (!this.Config.DisableControlPanel)
                    {
                        this.ControlPanel.UpdateToggler();
                        this.ControlPanel.DrawToggler(sb);
                    }
                    if (this.LastSeenCPScreenWidth != Main.screenWidth || this.LastSeenCPScreenHeight != Main.screenHeight)
                    {
                        this.LastSeenCPScreenWidth  = Main.screenWidth;
                        this.LastSeenCPScreenHeight = Main.screenHeight;
                        this.ControlPanel.RecalculateMe();
                    }

                    this.Inbox.Draw(sb);
                } catch (Exception e) {
                    LogHelpers.Warn("cpLayerDraw - " + e.ToString());
                }

//sb.DrawString( Main.fontDeathText, "ALERT", new Vector2(128, 128), this.AnimatedColors.Alert.CurrentColor );
//sb.DrawString( Main.fontDeathText, "STROBE", new Vector2(128, 256), this.AnimatedColors.Strobe.CurrentColor );
//sb.DrawString( Main.fontDeathText, "FIRE", new Vector2(128, 320), this.AnimatedColors.Fire.CurrentColor );
//sb.DrawString( Main.fontDeathText, "WATER", new Vector2(128, 384), this.AnimatedColors.Water.CurrentColor );
//sb.DrawString( Main.fontDeathText, "AIR", new Vector2(128, 448), this.AnimatedColors.Air.CurrentColor );
                return(true);
            };

            GameInterfaceDrawMethod modlockDrawCallback = delegate {
                try {
                    this.ModLock.DrawWarning(Main.spriteBatch);
                } catch (Exception e) {
                    LogHelpers.Warn("modlockLayerDraw - " + e.ToString());
                }
                return(true);
            };

            ////

            var debugLayer = new LegacyGameInterfaceLayer("ModHelpers: Debug Display",
                                                          debugDrawCallback, InterfaceScaleType.UI);

            layers.Insert(idx, debugLayer);

            var modlockLayer = new LegacyGameInterfaceLayer("ModHelpers: Mod Lock",
                                                            modlockDrawCallback, InterfaceScaleType.UI);

            layers.Insert(idx, modlockLayer);

            if (!this.Config.DisableControlPanel)
            {
                var cpLayer = new LegacyGameInterfaceLayer("ModHelpers: Control Panel",
                                                           cpDrawCallback, InterfaceScaleType.UI);
                layers.Insert(idx, cpLayer);
            }
//Services.DataStore.DataStore.Add( DebugHelpers.GetCurrentContext()+"_B", 1 );
        }
コード例 #18
0
        ////////////////

        /*public override void UpdateUI( GameTime gameTime ) {
         *      //bool mouseLeft = PlayerInput.Triggers.Current.MouseLeft;
         *      //bool isAlt = Main.keyState.IsKeyDown( Keys.LeftAlt ) || Main.keyState.IsKeyDown( Keys.RightAlt );
         *      //this.Logger.Info( "lclick:"+mouseLeft+" ("+Main.mouseLeft+"), alt:"+isAlt+", gameTime:"+gameTime.ElapsedGameTime.Ticks );
         *      //this.MyUI?.Update( gameTime );
         *
         *      foreach( HUDElement elem in this.HUDManager.Elements.Values ) {
         *              if( elem.IsDragging ) {
         * //this.Logger.Info( "drag " + gameTime.ElapsedGameTime.Ticks+", thread: "+Thread.CurrentThread.ManagedThreadId);
         *                      Main.LocalPlayer.mouseInterface = true;		<- This fails because UpdateUI runs before inputs are processed
         *                      break;
         *              }
         *      }
         * }*/


        ////////////////

        public override void ModifyInterfaceLayers(List <GameInterfaceLayer> layers)
        {
            if (Main.gameMenu)
            {
                return;
            }

            //

            GameInterfaceDrawMethod widgetsUI = delegate {
                if (Main.gameMenu)
                {
                    return(true);
                }

/*if( this.MyUI != null ) {
 * List<UIElement> elems;
 * ModLibsCore.Libraries.DotNET.Reflection.ReflectionLibraries.Get(
 *      this.MyUI,
 *      "Elements",
 *      out elems
 * );
 * ModLibsCore.Libraries.Debug.DebugLibraries.Print(
 *      "interface",
 *      string.Join(", ", elems
 *              .Where( e=>e.GetType()!=typeof(VanillaHUDElement) )
 *              .Select( e=>((HUDElement)e).Name )
 *      )
 * );
 * }*/
                this.MyUI?.Update(Main._drawInterfaceGameTime);                    //:blobshrug:
                this.MyUI?.Draw(Main.spriteBatch);

                return(true);
            };

            int mouseTextIdx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Mouse Text"));

            if (mouseTextIdx >= 0)
            {
                var invOverLayer = new LegacyGameInterfaceLayer(
                    name: "HUDElementsLib: Widgets",
                    drawMethod: widgetsUI,
                    scaleType: InterfaceScaleType.UI
                    );
                layers.Insert(mouseTextIdx, invOverLayer);
            }

            //

            int cursorIdx = layers.FindIndex(layer => layer.Name.Equals("Vanilla: Cursor"));

            if (cursorIdx >= 0)
            {
                foreach (HUDElement elem in this.HUDManager.Elements.Values)
                {
                    if (elem.ConsumesCursor())
                    {
                        layers.RemoveAt(cursorIdx);

                        break;
                    }
                }
            }

            //

            if (HUDElementsLibAPI.IsEditModeActive())
            {
                this.DisableHUDInterfaceLayersForEditMode(layers);
            }
        }