コード例 #1
0
        public ProfileEntry(PlayerProfile profile, Skin defaultSelection, Action <ProfileEntry> onDoubleClick)
        {
            Profile       = profile;
            OnDoubleClick = onDoubleClick;

            MinWidth  = 92;
            MaxWidth  = 92;
            MinHeight = 128;
            MaxHeight = 128;

            // AutoSizeMode = AutoSizeMode.GrowOnly;

            AddChild(new GuiTextElement()
            {
                Text   = profile.Username,
                Margin = Thickness.Zero,
                Anchor = Alignment.TopCenter,
                //Enabled = false
            });

            Margin = new Thickness(0, 8);
            Anchor = Alignment.FillY;
            // AutoSizeMode = AutoSizeMode.GrowAndShrink;
            // BackgroundOverlay = new GuiTexture2D(GuiTextures.OptionsBackground);

            ModelView = new GuiEntityModelView(new RemotePlayer(profile.Username, null, null, profile.Skin?.Texture ?? defaultSelection.Texture, (profile.Skin?.Slim ?? defaultSelection.Slim) ? "geometry.humanoid.customSlim" : "geometry.humanoid.custom")) /*"geometry.humanoid.customSlim"*/
            {
                BackgroundOverlay = new Color(Color.Black, 0.15f),
                Background        = null,
                //   Margin = new Thickness(15, 15, 5, 40),

                Width  = 92,
                Height = 128,

                Anchor = Alignment.Fill,
            };

            AddChild(ModelView);

            AddChild(new GuiTextElement()
            {
                Text   = profile.Username, //PROFILE TYPE!!!
                Margin = Thickness.Zero,
                Anchor = Alignment.BottomCenter,
                //Enabled = false,
                BackgroundOverlay = new Color(Color.Black, 0.5f),
                Background        = null
            });
        }
コード例 #2
0
ファイル: SkinEntry.cs プロジェクト: lvyitian/Alex
        public SkinEntry(LoadedSkin skin, PooledTexture2D texture2D, Action <SkinEntry> onDoubleClick)
        {
            Skin          = skin;
            OnDoubleClick = onDoubleClick;

            MinWidth  = 92;
            MaxWidth  = 92;
            MinHeight = 128;
            MaxHeight = 128;

            // AutoSizeMode = AutoSizeMode.GrowOnly;

            AddChild(
                new GuiTextElement()
            {
                Text = skin.Name, Margin = Thickness.Zero, Anchor = Alignment.TopCenter, Enabled = false
            });

            Margin = new Thickness(0, 8);
            Anchor = Alignment.FillY;
            // AutoSizeMode = AutoSizeMode.GrowAndShrink;
            // BackgroundOverlay = new GuiTexture2D(GuiTextures.OptionsBackground);

            var mob = new RemotePlayer(skin.Name, null, null, texture2D);

            mob.ModelRenderer = new EntityModelRenderer(skin.Model, texture2D);

            ModelView = new GuiEntityModelView(mob) /*"geometry.humanoid.customSlim"*/
            {
                BackgroundOverlay = new Color(Color.Black, 0.15f),
                Background        = null,
                //   Margin = new Thickness(15, 15, 5, 40),

                Width  = 92,
                Height = 128,
                Anchor = Alignment.Fill,
            };

            AddChild(ModelView);
        }
コード例 #3
0
        public GuiPlayerInventoryDialog(Player player, Inventory inventory)
        {
            Player    = player;
            Inventory = inventory;

            // Subscribe to events

            _guiHotBarInventoryItems = new InventoryContainerItem[inventory?.SlotCount ?? 0];

            if (_guiHotBarInventoryItems.Length != 46)
            {
                throw new ArgumentOutOfRangeException(nameof(inventory), inventory?.SlotCount ?? 0, "Expected player inventory containing 46 slots.");
            }

            ContentContainer.Background        = GuiTextures.InventoryPlayerBackground;
            ContentContainer.BackgroundOverlay = null;

            ContentContainer.Width  = ContentContainer.MinWidth = ContentContainer.MaxWidth = 176;
            ContentContainer.Height = ContentContainer.MinHeight = ContentContainer.MaxHeight = 166;

            SetFixedSize(176, 166);

            ContentContainer.AutoSizeMode = AutoSizeMode.None;

            var modelRenderer = player.ModelRenderer;
            var mob           = new PlayerMob(player.Name, player.Level, player.Network,
                                              player.ModelRenderer.Texture)
            {
                ModelRenderer = modelRenderer,
            };

            ContentContainer.AddChild(_playerEntityModelView =
                                          new GuiEntityModelView(mob)
            {
                Margin            = new Thickness(7, 25),
                Width             = 49,
                Height            = 70,
                Anchor            = Alignment.TopLeft,
                AutoSizeMode      = AutoSizeMode.None,
                Background        = null,
                BackgroundOverlay = null
            });

            Color color = Color.Blue;

            foreach (var slot in AddSlots(8, 84, 9, 27, 9, 0x00))
            {
                //   slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(color, 0.5f);
                slot.Item = Inventory[slot.InventoryIndex];
            }

            color = Color.Aqua;
            foreach (var slot in AddSlots(8, 142, 9, 9, 0, 0))
            {
                // slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(color, 0.5f);
                slot.Item = Inventory[slot.InventoryIndex];
            }

            foreach (var slot in AddSlots(8, 8, 1, 4, 0, 120))
            {
                var  inventoryIndex = slot.InventoryIndex;
                Item item           = new ItemAir();

                switch (slot.InventoryIndex)
                {
                case 0:
                    item           = Inventory.Helmet;
                    inventoryIndex = Inventory.HelmetSlot;
                    break;

                case 1:
                    item           = Inventory.Chestplate;
                    inventoryIndex = Inventory.ChestSlot;
                    break;

                case 2:
                    item           = Inventory.Leggings;
                    inventoryIndex = Inventory.LeggingsSlot;
                    break;

                case 3:
                    item           = Inventory.Boots;
                    inventoryIndex = Inventory.BootsSlot;
                    break;
                }

                //  slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Red, 0.5f);
                slot.Item           = item;
                slot.InventoryIndex = inventoryIndex;
            }

            foreach (var slot in AddSlots(98, 18, 2, 4, 41, 0))
            {
                slot.Item = Inventory[slot.InventoryIndex];
                //  slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Purple, 0.5f);
            }

            CraftingOutput = AddSlot(154, 28, 45, 0);
            //  CraftingOutput.HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Purple, 0.5f);

            /*var shieldSlot = new InventoryContainerItem()
             * {
             *  HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Orange, 0.5f),
             *  Anchor = Alignment.TopLeft,
             *  Margin =  new Thickness(61, 76),
             *  AutoSizeMode = AutoSizeMode.None,
             *  Item = Inventory[40],
             *  InventoryIndex = 40
             * };
             *
             * ContentContainer.AddChild(shieldSlot);*/
        }
コード例 #4
0
        public GuiPlayerInventoryDialog(Player player, Inventory inventory) : base(inventory, GuiTextures.InventoryPlayerBackground, 176, 166)
        {
            Player = player;

            // Subscribe to events

            if (player != null)
            {
                var modelRenderer = player.ModelRenderer;

                var mob = new PlayerMob(player.Name, player.Level, player.Network, player.ModelRenderer.Texture)
                {
                    ModelRenderer = modelRenderer,
                };

                ContentContainer.AddChild(
                    _playerEntityModelView = new GuiEntityModelView(mob)
                {
                    Margin            = new Thickness(7, 25),
                    Width             = 49,
                    Height            = 70,
                    Anchor            = Alignment.TopLeft,
                    AutoSizeMode      = AutoSizeMode.None,
                    Background        = null,
                    BackgroundOverlay = null
                });
            }

            Color color = Color.Blue;

            foreach (var slot in AddSlots(8, 84, 9, 27, 9, 0x00))
            {
                //   slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(color, 0.5f);
                slot.Item = Inventory[slot.InventoryIndex];
            }

            color = Color.Aqua;
            foreach (var slot in AddSlots(8, 142, 9, 9, 0, 0))
            {
                // slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(color, 0.5f);
                slot.Item = Inventory[slot.InventoryIndex];
            }

            foreach (var slot in AddSlots(8, 8, 1, 4, 0, 120))
            {
                var  inventoryIndex = slot.InventoryIndex;
                Item item           = new ItemAir();

                switch (slot.InventoryIndex)
                {
                case 0:
                    item           = inventory.Helmet;
                    inventoryIndex = inventory.HelmetSlot;
                    break;

                case 1:
                    item           = inventory.Chestplate;
                    inventoryIndex = inventory.ChestSlot;
                    break;

                case 2:
                    item           = inventory.Leggings;
                    inventoryIndex = inventory.LeggingsSlot;
                    break;

                case 3:
                    item           = inventory.Boots;
                    inventoryIndex = inventory.BootsSlot;
                    break;
                }

                //  slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Red, 0.5f);
                slot.Item           = item;
                slot.InventoryIndex = inventoryIndex;
            }

            foreach (var slot in AddSlots(98, 18, 2, 4, 41, 0))
            {
                slot.Item = Inventory[slot.InventoryIndex];
                //  slot.HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Purple, 0.5f);
            }

            CraftingOutput = AddSlot(154, 28, 45, 0);
            //  CraftingOutput.HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Purple, 0.5f);

            /*var shieldSlot = new InventoryContainerItem()
             * {
             *  HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Orange, 0.5f),
             *  Anchor = Alignment.TopLeft,
             *  Margin =  new Thickness(61, 76),
             *  AutoSizeMode = AutoSizeMode.None,
             *  Item = Inventory[40],
             *  InventoryIndex = 40
             * };
             *
             * ContentContainer.AddChild(shieldSlot);*/
        }
コード例 #5
0
        protected override void OnLoad(IRenderArgs args)
        {
            Skin skin = _playerProfileService?.CurrentProfile?.Skin;

            if (skin == null)
            {
                Alex.Resources.ResourcePack.TryGetBitmap("entity/alex", out var rawTexture);
                skin = new Skin()
                {
                    Slim    = true,
                    Texture = TextureUtils.BitmapToTexture2D(Alex.GraphicsDevice, rawTexture)
                };
            }

            var entity = new RemotePlayer("", null, null, skin.Texture);

            AddChild(_playerView =
                         new GuiEntityModelView(
                             entity /*new PlayerMob("", null, null, skin.Texture, skin.Slim)*/)                    /*"geometry.humanoid.customSlim"*/
            {
                BackgroundOverlay = new Color(Color.Black, 0.15f),

                Margin = new Thickness(15, 15, 5, 40),

                Width  = 92,
                Height = 128,

                Anchor = Alignment.BottomRight,
            });

            AddChild(new GuiButton("Change Skin", ChangeSKinBtnPressed)
            {
                Anchor         = Alignment.BottomRight,
                Modern         = false,
                TranslationKey = "",
                Margin         = new Thickness(15, 15, 6, 15),
                Width          = 90,
                //Enabled = false
            });

            AutoResetEvent reset = new AutoResetEvent(false);

            Alex.UIThreadQueue.Enqueue(() =>
            {
                using (MemoryStream ms =
                           new MemoryStream(ResourceManager.ReadResource("Alex.Resources.GradientBlur.png")))
                {
                    BackgroundOverlay = (TextureSlice2D)GpuResourceManager.GetTexture2D(this, args.GraphicsDevice, ms);
                }

                BackgroundOverlay.RepeatMode = TextureRepeatMode.Stretch;
                reset.Set();
            });
            reset.WaitOne();
            reset.Dispose();

            BackgroundOverlay.Mask = new Color(Color.White, 0.5f);

            _splashText.Text    = SplashTexts.GetSplashText();
            Alex.IsMouseVisible = true;

            Alex.GameStateManager.AddState("serverlist", new MultiplayerServerSelectionState(_backgroundSkyBox));
            //Alex.GameStateManager.AddState("profileSelection", new ProfileSelectionState(_backgroundSkyBox));
        }
コード例 #6
0
        public GuiPlayerInventoryDialog(Player player, Inventory inventory)
        {
            Player    = player;
            Inventory = inventory;

            // Subscribe to events

            _guiHotBarInventoryItems = new InventoryContainerItem[inventory?.SlotCount ?? 0];

            if (_guiHotBarInventoryItems.Length != 46)
            {
                throw new ArgumentOutOfRangeException(nameof(inventory), inventory?.SlotCount ?? 0, "Expected player inventory containing 46 slots.");
            }

            ContentContainer.Background = GuiTextures.InventoryPlayerBackground;
            ContentContainer.Width      = ContentContainer.MinWidth = ContentContainer.MaxWidth = 176;
            ContentContainer.Height     = ContentContainer.MinHeight = ContentContainer.MaxHeight = 166;

            SetFixedSize(176, 166);

            ContentContainer.AutoSizeMode = AutoSizeMode.None;

            AddChild(_debug = new GuiAutoUpdatingTextElement(() =>
            {
                if (base.GuiRenderer == null)
                {
                    return("");
                }

                var position = Mouse.GetState().Position;

                return($"Cursor: {position}");
            }, true)
            {
                Background = new Color(Color.Black, 0.35f),
                Anchor     = Alignment.TopCenter,
                Margin     = new Thickness(0, 0, 0, 200)
            });

            var texture = player.ModelRenderer.Texture;

            if (texture == null)
            {
            }

            var modelRenderer = player.ModelRenderer;
            var mob           = new PlayerMob(player.Name, player.Level, player.Network,
                                              player.ModelRenderer.Texture, true)
            {
                ModelRenderer = modelRenderer,
            };

            ContentContainer.AddChild(_playerEntityModelView =
                                          new GuiEntityModelView(mob)
            {
                Margin            = new Thickness(7, 25),
                Width             = 49,
                Height            = 70,
                Anchor            = Alignment.TopLeft,
                AutoSizeMode      = AutoSizeMode.None,
                Background        = null,
                BackgroundOverlay = null
            });

            int lx = 7, ly = 83;

            int   idx   = 9;
            Color color = Color.Blue;

            for (int y = 0; y < 4; y++)
            {
                for (int x = 0; x < 9; x++)
                {
                    var item = new InventoryContainerItem()
                    {
                        Item = Inventory[idx],
                        HighlightedBackground = new Microsoft.Xna.Framework.Color(color, 0.5f),
                        Anchor       = Alignment.TopLeft,
                        AutoSizeMode = AutoSizeMode.None,
                        //  Name = idx.ToString(),
                        Margin = new Thickness(lx, ly, 0, 0)
                    };

                    _guiHotBarInventoryItems[idx] = item;

                    ContentContainer.AddChild(item);
                    idx++;

                    lx += item.Width;
                }

                lx = 7;

                if (idx == 36)
                {
                    idx   = 0;
                    ly    = 141;
                    color = Color.GreenYellow;
                }
                else
                {
                    ly += _guiHotBarInventoryItems[idx - 1].Height;
                }
            }

            lx = 7;
            ly = 7;
            for (int i = 0; i < 4; i++)
            {
                var element = new InventoryContainerItem()
                {
                    HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Red, 0.5f),
                    Anchor       = Alignment.TopLeft,
                    Margin       = new Thickness(ly, lx),
                    AutoSizeMode = AutoSizeMode.None,
                    //Item = Inventory[]
                };

                ContentContainer.AddChild(element);

                ly += element.Height;
            }

            var shieldSlot = new InventoryContainerItem()
            {
                HighlightedBackground = new Microsoft.Xna.Framework.Color(Color.Orange, 0.5f),
                Anchor       = Alignment.TopLeft,
                Margin       = new Thickness(61, 76),
                AutoSizeMode = AutoSizeMode.None
            };

            ContentContainer.AddChild(shieldSlot);

            AddChild(TextOverlay = new GuiTextElement(true)
            {
                HasShadow    = true,
                Background   = new Color(Color.Black, 0.35f),
                Enabled      = false,
                FontStyle    = FontStyle.DropShadow,
                TextColor    = TextColor.Yellow,
                ClipToBounds = false,
                //BackgroundOverlay = new Color(Color.Black, 0.35f),
            });

            foreach (var child in ContentContainer.ChildElements.Where(x => x is InventoryContainerItem).Cast <InventoryContainerItem>())
            {
                child.CursorPressed += InventoryItemPressed;
                child.CursorEnter   += ChildOnCursorEnter;
                child.CursorLeave   += ChildOnCursorLeave;
            }
        }
コード例 #7
0
ファイル: TitleState.cs プロジェクト: wqd1019dqw/Alex
        protected override void OnLoad(IRenderArgs args)
        {
            Skin skin = _playerProfileService?.CurrentProfile?.Skin;

            if (skin == null)
            {
                Alex.Resources.ResourcePack.TryGetBitmap("entity/alex", out Bitmap rawTexture);
                skin = new Skin()
                {
                    Slim    = true,
                    Texture = TextureUtils.BitmapToTexture2D(Alex.GraphicsDevice, rawTexture)
                };
            }

            var entity = new PlayerMob("", null, null, skin.Texture, skin.Slim);

            entity.Inventory.IsPeInventory = true;

            //entity.Inventory[entity.Inventory.SelectedSlot] =

            /*	if (ItemFactory.TryGetItem("minecraft:diamond_sword", out var sword))
             *      {
             *              entity.Inventory[entity.Inventory.SelectedSlot] = sword;
             *              entity.Inventory.MainHand = sword;
             *      }
             *      else
             *      {
             *              Log.Warn($"Could not get diamond sword!");
             *      }*/

            AddChild(_playerView = new GuiEntityModelView(entity /*new PlayerMob("", null, null, skin.Texture, skin.Slim)*/)                     /*"geometry.humanoid.customSlim"*/
            {
                BackgroundOverlay = new Color(Color.Black, 0.15f),

                Margin = new Thickness(15, 15, 5, 40),

                Width  = 92,
                Height = 128,

                Anchor = Alignment.BottomRight,
            });

            AddChild(_loginButton = new GuiButton("Switch user", LoginBtnPressed)
            {
                Anchor         = Alignment.BottomRight,
                Modern         = false,
                TranslationKey = "",
                Margin         = new Thickness(15, 15, 6, 15),
                Width          = 90
            });

            AutoResetEvent reset = new AutoResetEvent(false);

            Alex.UIThreadQueue.Enqueue(() =>
            {
                using (MemoryStream ms = new MemoryStream(ResourceManager.ReadResource("Alex.Resources.GradientBlur.png")))
                {
                    BackgroundOverlay = (TextureSlice2D)GpuResourceManager.GetTexture2D(this, args.GraphicsDevice, ms);
                }

                reset.Set();
            });
            reset.WaitOne();
            reset.Dispose();

            BackgroundOverlay.Mask = new Color(Color.White, 0.5f);

            _splashText.Text    = SplashTexts.GetSplashText();
            Alex.IsMouseVisible = true;

            Alex.GameStateManager.AddState("serverlist", new MultiplayerServerSelectionState(_backgroundSkyBox));
            //Alex.GameStateManager.AddState("profileSelection", new ProfileSelectionState(_backgroundSkyBox));
        }