Esempio n. 1
0
        private void LoadTexturePacks()
        {
            // We load the default texture pack specially.
            _texturePacks.Add(TexturePack.Default);
            AddTexturePackRow(TexturePack.Default);

            // Make sure to create the texture pack directory if there is none.
            if (!Directory.Exists(TexturePack.TexturePackPath))
                Directory.CreateDirectory(TexturePack.TexturePackPath);

            var zips = Directory.EnumerateFiles(TexturePack.TexturePackPath);
            bool officialPresent = false;
            foreach (var zip in zips)
            {
                if (!zip.EndsWith(".zip"))
                    continue;
                if (Path.GetFileName(zip) == "Minecraft.zip")
                    officialPresent = true;

                var texturePack = TexturePack.FromArchive(zip);
                if (texturePack != null)
                {
                    _texturePacks.Add(texturePack);
                    AddTexturePackRow(texturePack);
                }
            }
            if (!officialPresent)
                OfficialAssetsButton.Visible = true;
        }
Esempio n. 2
0
        void OfficialAssetsButton_Clicked(object sender, EventArgs e)
        {
            var result = MessageDialog.AskQuestion("Download Mojang assets",
                                                   "This will download the official Minecraft assets from Mojang.\n\n" +
                                                   "By proceeding you agree to the Mojang asset guidelines:\n\n" +
                                                   "https://account.mojang.com/terms#brand\n\n" +
                                                   "Proceed?",
                                                   Command.Yes, Command.No);

            if (result == Command.Yes)
            {
                OfficialAssetsButton.Visible   = false;
                OfficialAssetsProgress.Visible = true;
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        var stream = new WebClient().OpenRead("http://s3.amazonaws.com/Minecraft.Download/versions/b1.7.3/b1.7.3.jar");
                        var ms     = new MemoryStream();
                        CopyStream(stream, ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        stream.Dispose();
                        var jar = ZipFile.Read(ms);
                        var zip = new ZipFile();
                        zip.AddEntry("pack.txt", "Minecraft textures");
                        CopyBetweenZips("pack.png", jar, zip);
                        CopyBetweenZips("terrain.png", jar, zip);
                        // TODO: Items, windows, etc
                        zip.Save(Path.Combine(TexturePack.TexturePackPath, "Minecraft.zip"));
                        Application.Invoke(() =>
                        {
                            OfficialAssetsProgress.Visible = false;
                            var texturePack = TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, "Minecraft.zip"));
                            _texturePacks.Add(texturePack);
                            AddTexturePackRow(texturePack);
                        });
                        ms.Dispose();
                    }
                    catch (Exception ex)
                    {
                        Application.Invoke(() =>
                        {
                            MessageDialog.ShowError("Error retrieving assets", ex.ToString());
                            OfficialAssetsProgress.Visible = false;
                            OfficialAssetsButton.Visible   = true;
                        });
                    }
                });
            }
        }
Esempio n. 3
0
        protected override void LoadContent()
        {
            // Ensure we have default textures loaded.
            TextureMapper.LoadDefaults(GraphicsDevice);

            // Load any custom textures if needed.
            TextureMapper = new TextureMapper(GraphicsDevice);
            if (UserSettings.Local.SelectedTexturePack != TexturePack.Default.Name)
            {
                TextureMapper.AddTexturePack(TexturePack.FromArchive(Path.Combine(TexturePack.TexturePackPath, UserSettings.Local.SelectedTexturePack)));
            }

            Pixel = new FontRenderer(
                new Font(Content, "Fonts/Pixel", FontStyle.Regular),
                new Font(Content, "Fonts/Pixel", FontStyle.Bold),
                null, // No support for underlined or strikethrough yet. The FontRenderer will revert to using the regular font style.
                null, // (I don't think BMFont has those options?)
                new Font(Content, "Fonts/Pixel", FontStyle.Italic));
            Interfaces.Add(ChatInterface  = new ChatInterface(Client, KeyboardComponent, Pixel));
            Interfaces.Add(DebugInterface = new DebugInterface(Client, Pixel));

            ChatInterface.IsVisible  = true;
            DebugInterface.IsVisible = true;

            OpaqueEffect = new BasicEffect(GraphicsDevice);
            OpaqueEffect.EnableDefaultLighting();
            OpaqueEffect.DirectionalLight0.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight1.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.DirectionalLight2.SpecularColor = Color.Black.ToVector3();
            OpaqueEffect.TextureEnabled     = true;
            OpaqueEffect.Texture            = TextureMapper.GetTexture("terrain.png");
            OpaqueEffect.FogEnabled         = true;
            OpaqueEffect.FogStart           = 512f;
            OpaqueEffect.FogEnd             = 1000f;
            OpaqueEffect.FogColor           = Color.CornflowerBlue.ToVector3();
            OpaqueEffect.VertexColorEnabled = true;

            TransparentEffect = new AlphaTestEffect(GraphicsDevice);
            TransparentEffect.AlphaFunction      = CompareFunction.Greater;
            TransparentEffect.ReferenceAlpha     = 127;
            TransparentEffect.Texture            = TextureMapper.GetTexture("terrain.png");
            TransparentEffect.VertexColorEnabled = true;

            base.LoadContent();
        }
Esempio n. 4
0
        protected override void LoadContent()
        {
            // Ensure we have default textures loaded.
            TextureMapper.LoadDefaults(GraphicsDevice);

            // Load any custom textures if needed.
            TextureMapper = new TextureMapper(GraphicsDevice);
            if (UserSettings.Local.SelectedTexturePack != TexturePack.Default.Name)
                TextureMapper.AddTexturePack(TexturePack.FromArchive(Path.Combine(Paths.TexturePacks,
                    UserSettings.Local.SelectedTexturePack)));

            Pixel = new FontRenderer(
                new Font(Content, "Fonts/Pixel"),
                new Font(Content, "Fonts/Pixel", FontStyle.Bold), null, null,
                new Font(Content, "Fonts/Pixel", FontStyle.Italic));

            base.LoadContent();
        }