Esempio n. 1
0
        public void ReadBackgroundTextures()
        {
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var backgroundPath = Path.Combine(contentPath, @"Textures\BackgroundCube\Final\BackgroundCube.dds");

            Assert.IsTrue(File.Exists(backgroundPath), "Filepath should exist on developer machine");

            var backgroundBmp = TexUtil.CreateBitmap(backgroundPath, 0, -1, -1);

            ImageTextureUtil.WriteImage(backgroundBmp, @".\TestOutput\BackgroundCube0_Full.png");

            backgroundBmp = TexUtil.CreateBitmap(backgroundPath, 1, 1024, 1024);
            ImageTextureUtil.WriteImage(backgroundBmp, @".\TestOutput\BackgroundCube1_1024.png");

            backgroundBmp = TexUtil.CreateBitmap(backgroundPath, 2, 512, 512);
            ImageTextureUtil.WriteImage(backgroundBmp, @".\TestOutput\BackgroundCube2_512.png");

            backgroundBmp = TexUtil.CreateBitmap(backgroundPath, 3, 128, 128);
            ImageTextureUtil.WriteImage(backgroundBmp, @".\TestOutput\BackgroundCube3_128.png");

            backgroundBmp = TexUtil.CreateBitmap(backgroundPath, 4, 64, 64);
            ImageTextureUtil.WriteImage(backgroundBmp, @".\TestOutput\BackgroundCube4_64.png");

            backgroundBmp = TexUtil.CreateBitmap(backgroundPath, 5, 32, 32);
            ImageTextureUtil.WriteImage(backgroundBmp, @".\TestOutput\BackgroundCube5_32.png");
        }
Esempio n. 2
0
        public void LocateSpaceEngineersApplication()
        {
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "SpaceEgineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");
        }
Esempio n. 3
0
        public void CreateMenuTextures()
        {
            SpaceEngineersCore.LoadDefinitions();

            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var smallBlockLandingGear     = SpaceEngineersApi.GetDefinition(new MyObjectBuilderType(typeof(MyObjectBuilder_LandingGear)), "SmallBlockLandingGear");
            var smallBlockLandingGearPath = Path.Combine(contentPath, smallBlockLandingGear.Icons.First());

            Assert.IsTrue(File.Exists(smallBlockLandingGearPath), "Filepath should exist on developer machine");
            Assert.IsTrue(smallBlockLandingGear is MyObjectBuilder_CubeBlockDefinition, "Type should match");
            var smallBlockLandingGearBmp = TexUtil.CreateBitmap(smallBlockLandingGearPath);

            var gridItemPath = Path.Combine(contentPath, @"Textures\GUI\Controls\grid_item.dds");

            Assert.IsTrue(File.Exists(gridItemPath), "Filepath should exist on developer machine");
            var gridBmp = TexUtil.CreateBitmap(gridItemPath);

            var bmp = ImageTextureUtil.MergeImages(gridBmp, smallBlockLandingGearBmp, Brushes.Black);

            ImageTextureUtil.WriteImage(bmp, @".\TestOutput\Menu_SmallBlockLandingGear.png");
        }
Esempio n. 4
0
        public void BaseModel1LoadSave()
        {
            SpaceEngineersCore.LoadDefinitions();
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var largeThruster     = (MyObjectBuilder_CubeBlockDefinition)SpaceEngineersApi.GetDefinition(SpaceEngineersTypes.Thrust, "LargeBlockLargeThrust");
            var thrusterModelPath = Path.Combine(contentPath, largeThruster.Model);

            Assert.IsTrue(File.Exists(thrusterModelPath), "Filepath should exist on developer machine");

            var modelData = MyModel.LoadModelData(thrusterModelPath);
            //var modelData = MyModel.LoadCustomModelData(thrusterModelPath);

            var testFilePath = @".\TestOutput\Thruster.mwm";

            MyModel.SaveModelData(testFilePath, modelData);

            var originalBytes = File.ReadAllBytes(thrusterModelPath);
            var newBytes      = File.ReadAllBytes(testFilePath);

            Assert.AreEqual(originalBytes.Length, newBytes.Length, "Bytestream content must equal");
            Assert.IsTrue(originalBytes.SequenceEqual(newBytes), "Bytestream content must equal");
        }
Esempio n. 5
0
        public void CustomModel1LoadSave()
        {
            SpaceEngineersCore.LoadDefinitions();
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var cockpitModelPath = Path.Combine(contentPath, @"Models\Characters\Animations\cockpit1_large.mwm");

            Assert.IsTrue(File.Exists(cockpitModelPath), "Filepath should exist on developer machine");

            var modelData = MyModel.LoadCustomModelData(cockpitModelPath);

            var testFilePath = @".\TestOutput\cockpit_animation.mwm";

            MyModel.SaveModelData(testFilePath, modelData);

            var originalBytes = File.ReadAllBytes(cockpitModelPath);
            var newBytes      = File.ReadAllBytes(testFilePath);

            Assert.AreEqual(originalBytes.Length, newBytes.Length, "Bytestream content must equal");
            Assert.IsTrue(originalBytes.SequenceEqual(newBytes), "Bytestream content must equal");
        }
Esempio n. 6
0
        /// <summary>
        /// Updates the base library files from the Space Engineers application path.
        /// </summary>
        /// <param name="appFilePath"></param>
        /// <returns>True if it succeeded, False if there was an issue that blocked it.</returns>
        private static bool UpdateBaseFiles(string appFilePath)
        {
            var counter = 0;

            // Wait until SEToolbox is shut down.
            while (Process.GetProcessesByName("SEToolbox").Length > 0)
            {
                System.Threading.Thread.Sleep(100);

                counter++;
                if (counter > 100)
                {
                    // 10 seconds is too long. Abort.
                    return(false);
                }
            }

            var baseFilePath = ToolboxUpdater.GetApplicationFilePath();

            foreach (var filename in ToolboxUpdater.CoreSpaceEngineersFiles)
            {
                var sourceFile = Path.Combine(baseFilePath, filename);

                try
                {
                    if (File.Exists(sourceFile))
                    {
                        File.Copy(sourceFile, Path.Combine(appFilePath, filename), true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch
                {
                    return(false);
                }
            }

            foreach (var filename in ToolboxUpdater.OptionalSpaceEngineersFiles)
            {
                var sourceFile = Path.Combine(baseFilePath, filename);

                try
                {
                    if (File.Exists(sourceFile))
                    {
                        File.Copy(sourceFile, Path.Combine(appFilePath, filename), true);
                    }
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 7
0
        //[TestMethod]
        public void LoadModelFailures()
        {
            SpaceEngineersCore.LoadDefinitions();
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var files          = Directory.GetFiles(Path.Combine(contentPath, "Models"), "*.mwm", SearchOption.AllDirectories);
            var badList        = new List <string>();
            var convertDiffers = new List <string>();

            foreach (var file in files)
            {
                Dictionary <string, object> data = null;
                try
                {
                    data = MyModel.LoadModelData(file);
                    //data = MyModel.LoadCustomModelData(file);
                }
                catch (Exception)
                {
                    badList.Add(file);
                    continue;
                }

                if (data != null)
                {
                    var testFilePath = @".\TestOutput\TempModelTest.mwm";

                    MyModel.SaveModelData(testFilePath, data);

                    var originalBytes = File.ReadAllBytes(file);
                    var newBytes      = File.ReadAllBytes(testFilePath);

                    if (!originalBytes.SequenceEqual(newBytes))
                    {
                        convertDiffers.Add(file);
                    }

                    //Assert.AreEqual(originalBytes.Length, newBytes.Length, "File {0} Bytestream content must equal", file);
                    //Assert.IsTrue(originalBytes.SequenceEqual(newBytes), "File {0} Bytestream content must equal", file);
                }
            }

            Assert.IsTrue(convertDiffers.Count > 0, "");
            Assert.IsTrue(badList.Count > 0, "");
        }
Esempio n. 8
0
        public void LoadComponentTexturesDx10PremultipliedAlpha()
        {
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\GUI\Icons\Cubes\AdvancedMotor.dds"));

            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\GUI\Icons\component\ExplosivesComponent.dds"));
        }
Esempio n. 9
0
        public void LoadComponentTexturesDx11()
        {
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Cubes\large_medical_room_cm.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Cubes\large_medical_room_cm.dds"), true);
        }
Esempio n. 10
0
        public void CreateBackgroundPreview()
        {
            const int  size        = 128;
            const bool ignoreAlpha = true;

            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var backgroundPath = Path.Combine(contentPath, @"Textures\BackgroundCube\Final\BackgroundCube.dds");

            Assert.IsTrue(File.Exists(backgroundPath), "Filepath should exist on developer machine");

            var result = new Bitmap(size * 4, size * 3);

            using (var graphics = Graphics.FromImage(result))
            {
                //set the resize quality modes to high quality
                graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                graphics.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                if (ignoreAlpha)
                {
                    graphics.FillRectangle(Brushes.Black, size * 2, size * 1, size, size);
                    graphics.FillRectangle(Brushes.Black, size * 0, size * 1, size, size);
                    graphics.FillRectangle(Brushes.Black, size * 1, size * 0, size, size);
                    graphics.FillRectangle(Brushes.Black, size * 1, size * 2, size, size);
                    graphics.FillRectangle(Brushes.Black, size * 1, size * 1, size, size);
                    graphics.FillRectangle(Brushes.Black, size * 3, size * 1, size, size);
                }

                graphics.DrawImage(TexUtil.CreateBitmap(backgroundPath, 0, size, size, ignoreAlpha), size * 2, size * 1, size, size);
                graphics.DrawImage(TexUtil.CreateBitmap(backgroundPath, 1, size, size, ignoreAlpha), size * 0, size * 1, size, size);
                graphics.DrawImage(TexUtil.CreateBitmap(backgroundPath, 2, size, size, ignoreAlpha), size * 1, size * 0, size, size);
                graphics.DrawImage(TexUtil.CreateBitmap(backgroundPath, 3, size, size, ignoreAlpha), size * 1, size * 2, size, size);
                graphics.DrawImage(TexUtil.CreateBitmap(backgroundPath, 4, size, size, ignoreAlpha), size * 1, size * 1, size, size);
                graphics.DrawImage(TexUtil.CreateBitmap(backgroundPath, 5, size, size, ignoreAlpha), size * 3, size * 1, size, size);

                // Approximate position of local Sun and light source.
                graphics.FillEllipse(Brushes.White, size * 1 + (int)(size * 0.7), size * 2 + (int)(size * 0.93), (int)(size * 0.06), (int)(size * 0.06));
            }

            ImageTextureUtil.WriteImage(result, string.Format(@".\TestOutput\BackgroundCube_{0}.png", size));
        }
Esempio n. 11
0
        public void LoadComponentTextures()
        {
            SpaceEngineersCore.LoadDefinitions();
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            var magnesiumOre     = SpaceEngineersApi.GetDefinition(SpaceEngineersTypes.Ore, "Magnesium");
            var magnesiumOrePath = Path.Combine(contentPath, magnesiumOre.Icons.First());

            Assert.IsTrue(File.Exists(magnesiumOrePath), "Filepath should exist on developer machine");
            Assert.IsTrue(magnesiumOre is MyObjectBuilder_PhysicalItemDefinition, "Type should match");
            var magnesiumOreBmp = TexUtil.CreateBitmap(magnesiumOrePath);

            ImageTextureUtil.WriteImage(magnesiumOreBmp, @".\TestOutput\Magnesium_Ore.png");

            var goldIngot     = SpaceEngineersApi.GetDefinition(SpaceEngineersTypes.Ingot, "Gold");
            var goldIngotPath = Path.Combine(contentPath, goldIngot.Icons.First());

            Assert.IsTrue(File.Exists(goldIngotPath), "Filepath should exist on developer machine");
            Assert.IsTrue(goldIngot is MyObjectBuilder_PhysicalItemDefinition, "Type should match");
            var goldIngotBmp = TexUtil.CreateBitmap(goldIngotPath);

            ImageTextureUtil.WriteImage(goldIngotBmp, @".\TestOutput\Gold_Ingot.png");

            var ammoMagazine     = SpaceEngineersApi.GetDefinition(SpaceEngineersTypes.AmmoMagazine, "NATO_5p56x45mm");
            var ammoMagazinePath = Path.Combine(contentPath, ammoMagazine.Icons.First());

            Assert.IsTrue(File.Exists(ammoMagazinePath), "Filepath should exist on developer machine");
            Assert.IsTrue(ammoMagazine is MyObjectBuilder_AmmoMagazineDefinition, "Type should match");
            var ammoMagazineBmp = TexUtil.CreateBitmap(ammoMagazinePath);

            ImageTextureUtil.WriteImage(ammoMagazineBmp, @".\TestOutput\NATO_5p56x45mm.png");

            var steelPlate     = SpaceEngineersApi.GetDefinition(SpaceEngineersTypes.Component, "SteelPlate");
            var steelPlatePath = Path.Combine(contentPath, steelPlate.Icons.First());

            Assert.IsTrue(File.Exists(steelPlatePath), "Filepath should exist on developer machine");
            Assert.IsTrue(steelPlate is MyObjectBuilder_ComponentDefinition, "Type should match");
            var steelPlateBmp = TexUtil.CreateBitmap(steelPlatePath);

            ImageTextureUtil.WriteImage(steelPlateBmp, @".\TestOutput\SteelPlate.png");

            var smallBlockLandingGear     = SpaceEngineersApi.GetDefinition(new MyObjectBuilderType(typeof(MyObjectBuilder_LandingGear)), "SmallBlockLandingGear");
            var smallBlockLandingGearPath = Path.Combine(contentPath, smallBlockLandingGear.Icons.First());

            Assert.IsTrue(File.Exists(smallBlockLandingGearPath), "Filepath should exist on developer machine");
            Assert.IsTrue(smallBlockLandingGear is MyObjectBuilder_CubeBlockDefinition, "Type should match");
            var smallBlockLandingGearBmp = TexUtil.CreateBitmap(smallBlockLandingGearPath);

            ImageTextureUtil.WriteImage(smallBlockLandingGearBmp, @".\TestOutput\SmallBlockLandingGear.png");

            var gridItemPath = Path.Combine(contentPath, @"Textures\GUI\Controls\grid_item.dds");

            Assert.IsTrue(File.Exists(gridItemPath), "Filepath should exist on developer machine");
            var gridBmp = TexUtil.CreateBitmap(gridItemPath);

            ImageTextureUtil.WriteImage(gridBmp, @".\TestOutput\grid_item.png");

            var sunPath = Path.Combine(contentPath, @"Textures\BackgroundCube\Prerender\Sun.dds");

            Assert.IsTrue(File.Exists(sunPath), "Filepath should exist on developer machine");
            var sunBmp = TexUtil.CreateBitmap(sunPath);

            ImageTextureUtil.WriteImage(sunBmp, @".\TestOutput\sun.png");

            var goldPath = Path.Combine(contentPath, @"Textures\Voxels\Gold_01_ForAxisXZ_de.dds");

            Assert.IsTrue(File.Exists(goldPath), "Filepath should exist on developer machine");
            var goldBmp = TexUtil.CreateBitmap(goldPath);

            ImageTextureUtil.WriteImage(goldBmp, @".\TestOutput\gold.png");

            var siliconPath = Path.Combine(contentPath, @"Textures\Voxels\Silicon_01_ForAxisXZ_de.dds");

            Assert.IsTrue(File.Exists(siliconPath), "Filepath should exist on developer machine");
            var siliconBmp = TexUtil.CreateBitmap(siliconPath);

            ImageTextureUtil.WriteImage(siliconBmp, @".\TestOutput\silicon.png");

            var platinumPath = Path.Combine(contentPath, @"Textures\Voxels\Platinum_01_ForAxisXZ_de.dds");

            Assert.IsTrue(File.Exists(platinumPath), "Filepath should exist on developer machine");
            var platinumBmp = TexUtil.CreateBitmap(platinumPath);

            ImageTextureUtil.WriteImage(platinumBmp, @".\TestOutput\platinum.png");

            var medicalDiffuseEmissivePath = Path.Combine(contentPath, @"Textures\Models\Cubes\large_medical_room_de.dds");

            Assert.IsTrue(File.Exists(medicalDiffuseEmissivePath), "Filepath should exist on developer machine");
            var medicalDiffuseEmissiveBmp = TexUtil.CreateBitmap(medicalDiffuseEmissivePath);

            ImageTextureUtil.WriteImage(medicalDiffuseEmissiveBmp, @".\TestOutput\large_medical_room_de.png");

            medicalDiffuseEmissiveBmp = TexUtil.CreateBitmap(medicalDiffuseEmissivePath, true);
            ImageTextureUtil.WriteImage(medicalDiffuseEmissiveBmp, @".\TestOutput\large_medical_room.png");

            var astronautMaskEmissivePath = Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_me.dds");

            Assert.IsTrue(File.Exists(astronautMaskEmissivePath), "Filepath should exist on developer machine");
            var astronautMaskEmissiveBmp = TexUtil.CreateBitmap(astronautMaskEmissivePath);

            ImageTextureUtil.WriteImage(astronautMaskEmissiveBmp, @".\TestOutput\Astronaut_me.png");

            astronautMaskEmissiveBmp = TexUtil.CreateBitmap(astronautMaskEmissivePath, true);
            ImageTextureUtil.WriteImage(astronautMaskEmissiveBmp, @".\TestOutput\Astronaut_me2.png");

            var astronautNormalSpecularPath = Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_ns.dds");

            Assert.IsTrue(File.Exists(astronautNormalSpecularPath), "Filepath should exist on developer machine");
            var astronautNormalSpecularBmp = TexUtil.CreateBitmap(astronautNormalSpecularPath);

            ImageTextureUtil.WriteImage(astronautNormalSpecularBmp, @".\TestOutput\Astronaut_ns.png");

            astronautNormalSpecularBmp = TexUtil.CreateBitmap(astronautNormalSpecularPath, true);
            ImageTextureUtil.WriteImage(astronautNormalSpecularBmp, @".\TestOutput\Astronaut_ns2.png");
        }
Esempio n. 12
0
        public void PixelEffectTextures()
        {
            SpaceEngineersCore.LoadDefinitions();
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            // ----

            var medicalDiffuseEmissivePath = Path.Combine(contentPath, @"Textures\Models\Cubes\large_medical_room_de.dds");

            Assert.IsTrue(File.Exists(medicalDiffuseEmissivePath), "Filepath should exist on developer machine");
            var medicalDiffuseEmissiveBmp = TexUtil.CreateBitmap(medicalDiffuseEmissivePath);

            ImageTextureUtil.WriteImage(medicalDiffuseEmissiveBmp, @".\TestOutput\large_medical_room_de.png");

            var medicalDiffuseEmissiveBmp2 = TexUtil.CreateBitmap(medicalDiffuseEmissivePath, true);

            ImageTextureUtil.WriteImage(medicalDiffuseEmissiveBmp2, @".\TestOutput\large_medical_room_de_full.png");

            IPixelEffect effect = new AlphaPixelEffect();
            var          medicalDiffuseEmissiveAlphaBmp = effect.Quantize(medicalDiffuseEmissiveBmp);

            ImageTextureUtil.WriteImage(medicalDiffuseEmissiveAlphaBmp, @".\TestOutput\large_medical_room_de_alpha.png");

            effect = new EmissivePixelEffect(0);
            var medicalNormalSpecularEmissiveBmp = effect.Quantize(medicalDiffuseEmissiveBmp);

            ImageTextureUtil.WriteImage(medicalNormalSpecularEmissiveBmp, @".\TestOutput\large_medical_room_emissive.png");

            var defaultImage = SEToolbox.ImageLibrary.ImageTextureUtil.CreateImage(medicalDiffuseEmissivePath, false, new EmissivePixelEffect(0));

            // ----

            var largeThrustDiffuseEmissivePath = Path.Combine(contentPath, @"Textures\Models\Cubes\large_thrust_large_me.dds");

            Assert.IsTrue(File.Exists(largeThrustDiffuseEmissivePath), "Filepath should exist on developer machine");
            var largeThrustDiffuseEmissiveBmp = TexUtil.CreateBitmap(largeThrustDiffuseEmissivePath);

            ImageTextureUtil.WriteImage(largeThrustDiffuseEmissiveBmp, @".\TestOutput\large_thrust_large_me.png");

            var largeThrustDiffuseEmissiveBmp2 = TexUtil.CreateBitmap(largeThrustDiffuseEmissivePath, true);

            ImageTextureUtil.WriteImage(largeThrustDiffuseEmissiveBmp2, @".\TestOutput\large_thrust_large_me_full.png");

            effect = new AlphaPixelEffect();
            var largeThrustDiffuseEmissiveAlphaBmp = effect.Quantize(largeThrustDiffuseEmissiveBmp);

            ImageTextureUtil.WriteImage(largeThrustDiffuseEmissiveAlphaBmp, @".\TestOutput\large_thrust_large_me_alpha.png");

            effect = new EmissivePixelEffect(0);
            var largeThrustNormalSpecularEmissiveBmp = effect.Quantize(largeThrustDiffuseEmissiveBmp);

            ImageTextureUtil.WriteImage(largeThrustNormalSpecularEmissiveBmp, @".\TestOutput\large_thrust_large_me_emissive.png");

            // ----

            var astronautMaskEmissivePath = Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_me.dds");

            Assert.IsTrue(File.Exists(astronautMaskEmissivePath), "Filepath should exist on developer machine");
            var astronautMaskEmissiveBmp = TexUtil.CreateBitmap(astronautMaskEmissivePath);

            ImageTextureUtil.WriteImage(astronautMaskEmissiveBmp, @".\TestOutput\Astronaut_me.png");

            effect = new AlphaPixelEffect();
            var astronautMaskEmissiveAlphaBmp = effect.Quantize(astronautMaskEmissiveBmp);

            ImageTextureUtil.WriteImage(astronautMaskEmissiveAlphaBmp, @".\TestOutput\Astronaut_me_alpha.png");

            var astronautMaskEmissiveBmp2 = TexUtil.CreateBitmap(astronautMaskEmissivePath, true);

            ImageTextureUtil.WriteImage(astronautMaskEmissiveBmp2, @".\TestOutput\Astronaut_me_full.png");

            effect = new EmissivePixelEffect(255);
            var astronautNormalSpecularEmissiveBmp = effect.Quantize(astronautMaskEmissiveBmp);

            ImageTextureUtil.WriteImage(astronautNormalSpecularEmissiveBmp, @".\TestOutput\Astronaut_me_emissive.png");

            // ----

            var astronautNormalSpecularPath = Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_ns.dds");

            Assert.IsTrue(File.Exists(astronautNormalSpecularPath), "Filepath should exist on developer machine");
            var astronautNormalSpecularBmp = TexUtil.CreateBitmap(astronautNormalSpecularPath);

            ImageTextureUtil.WriteImage(astronautNormalSpecularBmp, @".\TestOutput\Astronaut_ns.png");
        }
Esempio n. 13
0
        //private string _tempBinPath;

        #region methods

        public bool Init(string[] args)
        {
            // Detection and correction of local settings of SE install location.
            var filePath = ToolboxUpdater.GetApplicationFilePath();

            var validApps = new string[] {
                "SpaceEngineers.exe",
                "SpaceEngineersDedicated.exe",
                //"MedievalEngineers.exe",
                //"MedievalEngineersDedicated.exe"
            };

            if (GlobalSettings.Default.PromptUser || !ToolboxUpdater.ValidateSpaceEngineersInstall(filePath))
            {
                if (Directory.Exists(filePath))
                {
                    foreach (var validApp in validApps)
                    {
                        var testPath = Path.Combine(filePath, validApp);
                        if (File.Exists(testPath))
                        {
                            filePath = testPath;
                            break;
                        }
                    }
                }

                var faModel = new FindApplicationModel()
                {
                    GameApplicationPath = filePath
                };
                var faViewModel = new FindApplicationViewModel(faModel);
                var faWindow    = new WindowFindApplication(faViewModel);

                if (faWindow.ShowDialog() == true)
                {
                    filePath = faModel.GameBinPath;
                }
                else
                {
                    return(false);
                }
            }

            // Update and save user path.
            GlobalSettings.Default.SEBinPath = filePath;
            GlobalSettings.Default.Save();

            var ignoreUpdates = args.Any(a => a.ToUpper() == "/X" || a.ToUpper() == "-X");
            var oldDlls       = true; // args.Any(a => a.ToUpper() == "/OLDDLL" || a.ToUpper() == "-OLDDLL");
            var altDlls       = !oldDlls;

            // Go looking for any changes in the Dependant Space Engineers assemblies and immediately attempt to update.
            if (!ignoreUpdates && !altDlls && ToolboxUpdater.IsBaseAssembliesChanged() && !Debugger.IsAttached)
            {
                ToolboxUpdater.RunElevated(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SEToolboxUpdate"), "/B " + String.Join(" ", args), false, false);
                return(false);
            }

            var proc = Process.GetCurrentProcess();

            if (Process.GetProcessesByName(proc.ProcessName).Length == 1)
            {
                // Clean up Temp files if this is the only instance running.
                TempfileUtil.DestroyTempFiles();
            }

            // Dot not load any of the Space Engineers assemblies or dependant classes before this point.
            // ============================================

            // Alternate experimental method for loading the Space Engineers API assemblies.
            // Copy them to temporary path, then load with reflection on demand through the AppDomain.
            //if (altDlls)
            //{
            //    _tempBinPath = ToolboxUpdater.GetBinCachePath();
            //    var searchPath = GlobalSettings.Default.SEBinPath;

            //    DirectoryInfo checkDir = null;
            //    var counter = 0;

            //    while (checkDir == null && counter < 10)
            //    {
            //        if (Directory.Exists(_tempBinPath))
            //            break;

            //        checkDir = Directory.CreateDirectory(_tempBinPath);

            //        if (checkDir == null)
            //        {
            //            // wait a while, as the drive may be processing Windows Explorer which had a lock on the Directory after prior cleanup.
            //            System.Threading.Thread.Sleep(100);
            //        }

            //        counter++;
            //    }

            //    foreach (var file in ToolboxUpdater.CoreSpaceEngineersFiles)
            //    {
            //        var filename = Path.Combine(searchPath, file);
            //        var destFilename = Path.Combine(_tempBinPath, file);

            //        if (ToolboxUpdater.DoFilesDiffer(searchPath, _tempBinPath, file))
            //        {
            //            try
            //            {
            //                File.Copy(filename, destFilename, true);
            //            }
            //            catch { }
            //        }
            //    }

            //    // Copy directories which contain Space Engineers language resources.
            //    var dirs = Directory.GetDirectories(searchPath);

            //    foreach (var sourceDir in dirs)
            //    {
            //        var dirName = Path.GetFileName(sourceDir);
            //        var destDir = Path.Combine(_tempBinPath, dirName);
            //        Directory.CreateDirectory(destDir);

            //        foreach (string oldFile in Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories))
            //        {
            //            try
            //            {
            //                File.Copy(oldFile, Path.Combine(destDir, Path.GetFileName(oldFile)), true);
            //            }
            //            catch { }
            //        }
            //    }

            //    AppDomain currentDomain = AppDomain.CurrentDomain;
            //    currentDomain.AssemblyResolve += currentDomain_AssemblyResolve;
            //}

#if DEBUG
            // This will make it hairy for testing the AppDomain stuff.
            #warning Force the local debugger to load the Types allowing inspection.
            var settings0 = new VRage.Game.MyObjectBuilder_SessionSettings();
            var settings1 = new Sandbox.Common.ObjectBuilders.MyObjectBuilder_InteriorLight();
#endif

            return(true);
        }
Esempio n. 14
0
        public void LoadComponentTextures()
        {
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();


            //var ExplosivesComponentPath = Path.GetFullPath(@".\TestAssets\ExplosivesComponent.dds");
            //var ExplosivesComponentBmp = TexUtil.CreateBitmap(ExplosivesComponentPath);
            //File.Copy(ExplosivesComponentPath, Path.Combine(_path, "ExplosivesComponent.dds"), true);
            //ImageTextureUtil.WriteImage(ExplosivesComponentBmp, Path.Combine(_path, @"ExplosivesComponent.png"));

            LoadTextureAndExport(@"C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Content\Textures\Models\Cubes\DoorBlock_cm.dds");
            LoadTextureAndExport(Path.GetFullPath(@".\TestAssets\ExplosivesComponent.dds"));

            var magnesiumOre     = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.Ore, "Magnesium");
            var magnesiumOrePath = Path.Combine(contentPath, magnesiumOre.Icons.First());

            Assert.IsTrue(File.Exists(magnesiumOrePath), "Filepath should exist on developer machine");
            Assert.IsTrue(magnesiumOre is MyPhysicalItemDefinition, "Type should match");
            var magnesiumOreBmp = TexUtil.CreateBitmap(magnesiumOrePath);

            var str = Path.GetFullPath(Path.Combine(_path, "Magnesium_Ore.dds"));

            File.Copy(magnesiumOrePath, Path.Combine(_path, "Magnesium_Ore.dds"), true);
            ImageTextureUtil.WriteImage(magnesiumOreBmp, Path.Combine(_path, @"Magnesium_Ore.png"));



            return;

            var goldIngot     = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.Ingot, "Gold");
            var goldIngotPath = Path.Combine(contentPath, goldIngot.Icons.First());

            Assert.IsTrue(File.Exists(goldIngotPath), "Filepath should exist on developer machine");
            Assert.IsTrue(goldIngot is MyPhysicalItemDefinition, "Type should match");
            var goldIngotBmp = TexUtil.CreateBitmap(goldIngotPath);

            ImageTextureUtil.WriteImage(goldIngotBmp, @".\TestOutput\Gold_Ingot.png");

            var ammoMagazine     = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.AmmoMagazine, "NATO_5p56x45mm");
            var ammoMagazinePath = Path.Combine(contentPath, ammoMagazine.Icons.First());

            Assert.IsTrue(File.Exists(ammoMagazinePath), "Filepath should exist on developer machine");
            Assert.IsTrue(ammoMagazine is MyAmmoMagazineDefinition, "Type should match");
            var ammoMagazineBmp = TexUtil.CreateBitmap(ammoMagazinePath);

            ImageTextureUtil.WriteImage(ammoMagazineBmp, @".\TestOutput\NATO_5p56x45mm.png");

            var steelPlate     = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.Component, "SteelPlate");
            var steelPlatePath = Path.Combine(contentPath, steelPlate.Icons.First());

            Assert.IsTrue(File.Exists(steelPlatePath), "Filepath should exist on developer machine");
            Assert.IsTrue(steelPlate is MyComponentDefinition, "Type should match");
            var steelPlateBmp = TexUtil.CreateBitmap(steelPlatePath);

            ImageTextureUtil.WriteImage(steelPlateBmp, @".\TestOutput\SteelPlate.png");

            var smallBlockLandingGear     = MyDefinitionManager.Static.GetDefinition(new MyObjectBuilderType(typeof(MyObjectBuilder_LandingGear)), "SmallBlockLandingGear");
            var smallBlockLandingGearPath = Path.Combine(contentPath, smallBlockLandingGear.Icons.First());

            Assert.IsTrue(File.Exists(smallBlockLandingGearPath), "Filepath should exist on developer machine");
            Assert.IsTrue(smallBlockLandingGear is MyCubeBlockDefinition, "Type should match");
            var smallBlockLandingGearBmp = TexUtil.CreateBitmap(smallBlockLandingGearPath);

            ImageTextureUtil.WriteImage(smallBlockLandingGearBmp, @".\TestOutput\SmallBlockLandingGear.png");

            var gridItemPath = Path.Combine(contentPath, @"Textures\GUI\Controls\grid_item.dds");

            Assert.IsTrue(File.Exists(gridItemPath), "Filepath should exist on developer machine");
            var gridBmp = TexUtil.CreateBitmap(gridItemPath);

            ImageTextureUtil.WriteImage(gridBmp, @".\TestOutput\grid_item.png");

            var sunPath = Path.Combine(contentPath, @"Textures\BackgroundCube\Prerender\Sun.dds");

            Assert.IsTrue(File.Exists(sunPath), "Filepath should exist on developer machine");
            var sunBmp = TexUtil.CreateBitmap(sunPath);

            ImageTextureUtil.WriteImage(sunBmp, @".\TestOutput\sun.png");

            var goldPath = Path.Combine(contentPath, @"Textures\Voxels\Gold_01_ForAxisXZ_cm.dds");

            Assert.IsTrue(File.Exists(goldPath), "Filepath should exist on developer machine");
            var goldBmp = TexUtil.CreateBitmap(goldPath);

            ImageTextureUtil.WriteImage(goldBmp, @".\TestOutput\gold.png");

            var siliconPath = Path.Combine(contentPath, @"Textures\Voxels\Silicon_01_ForAxisXZ_cm.dds");

            Assert.IsTrue(File.Exists(siliconPath), "Filepath should exist on developer machine");
            var siliconBmp = TexUtil.CreateBitmap(siliconPath);

            ImageTextureUtil.WriteImage(siliconBmp, @".\TestOutput\silicon.png");

            var platinumPath = Path.Combine(contentPath, @"Textures\Voxels\Platinum_01_ForAxisXZ_cm.dds");

            Assert.IsTrue(File.Exists(platinumPath), "Filepath should exist on developer machine");
            var platinumBmp = TexUtil.CreateBitmap(platinumPath);

            ImageTextureUtil.WriteImage(platinumBmp, @".\TestOutput\platinum.png");

            var medicalMetallicPath = Path.Combine(contentPath, @"Textures\Models\Cubes\large_medical_room_cm.dds");

            Assert.IsTrue(File.Exists(medicalMetallicPath), "Filepath should exist on developer machine");
            var medicalMetallicBmp = TexUtil.CreateBitmap(medicalMetallicPath);

            ImageTextureUtil.WriteImage(medicalMetallicBmp, @".\TestOutput\large_medical_room_cm.png");

            medicalMetallicBmp = TexUtil.CreateBitmap(medicalMetallicPath, true);
            ImageTextureUtil.WriteImage(medicalMetallicBmp, @".\TestOutput\large_medical_room.png");

            var astronautMetallicPath = Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_cm.dds");

            Assert.IsTrue(File.Exists(astronautMetallicPath), "Filepath should exist on developer machine");
            var astronautMetallicBmp = TexUtil.CreateBitmap(astronautMetallicPath);

            ImageTextureUtil.WriteImage(astronautMetallicBmp, @".\TestOutput\Astronaut_cm.png");

            astronautMetallicBmp = TexUtil.CreateBitmap(astronautMetallicPath, true);
            ImageTextureUtil.WriteImage(astronautMetallicBmp, @".\TestOutput\Astronaut_me2.png");

            var astronautNormalGlossPath = Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_ng.dds");

            Assert.IsTrue(File.Exists(astronautNormalGlossPath), "Filepath should exist on developer machine");
            var astronautNormalGlossBmp = TexUtil.CreateBitmap(astronautNormalGlossPath);

            ImageTextureUtil.WriteImage(astronautNormalGlossBmp, @".\TestOutput\Astronaut_ng.png");

            astronautNormalGlossBmp = TexUtil.CreateBitmap(astronautNormalGlossPath, true);
            ImageTextureUtil.WriteImage(astronautNormalGlossBmp, @".\TestOutput\Astronaut_ng2.png");
        }
Esempio n. 15
0
        public void LoadComponentTextures()
        {
            var location = ToolboxUpdater.GetApplicationFilePath();

            Assert.IsNotNull(location, "Space Engineers should be installed on developer machine");
            Assert.IsTrue(Directory.Exists(location), "Filepath should exist on developer machine");

            var contentPath = ToolboxUpdater.GetApplicationContentPath();


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Cubes\DoorBlock_cm.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\GUI\Icons\Cubes\ExplosivesComponent.dds"));


            var magnesiumOre = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.Ore, "Magnesium");

            Assert.IsTrue(magnesiumOre is MyPhysicalItemDefinition, "Type should match");
            TestLoadTextureAndExport(Path.Combine(contentPath, magnesiumOre.Icons.First()));


            var goldIngot = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.Ingot, "Gold");

            Assert.IsTrue(goldIngot is MyPhysicalItemDefinition, "Type should match");
            TestLoadTextureAndExport(Path.Combine(contentPath, goldIngot.Icons.First()));


            var ammoMagazine = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.AmmoMagazine, "NATO_5p56x45mm");

            Assert.IsTrue(ammoMagazine is MyAmmoMagazineDefinition, "Type should match");
            TestLoadTextureAndExport(Path.Combine(contentPath, ammoMagazine.Icons.First()));


            var steelPlate = MyDefinitionManager.Static.GetDefinition(SpaceEngineersTypes.Component, "SteelPlate");

            Assert.IsTrue(steelPlate is MyComponentDefinition, "Type should match");
            TestLoadTextureAndExport(Path.Combine(contentPath, steelPlate.Icons.First()));


            var smallBlockLandingGear = MyDefinitionManager.Static.GetDefinition(new MyObjectBuilderType(typeof(MyObjectBuilder_LandingGear)), "SmallBlockLandingGear");

            Assert.IsTrue(smallBlockLandingGear is MyCubeBlockDefinition, "Type should match");
            TestLoadTextureAndExport(Path.Combine(contentPath, smallBlockLandingGear.Icons.First()));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\GUI\Controls\grid_item.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\BackgroundCube\Prerender\Sun.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Voxels\Gold_01_ForAxisXZ_cm.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Voxels\Silicon_01_ForAxisXZ_cm.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Voxels\Platinum_01_ForAxisXZ_cm.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_cm.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_cm.dds"), true);


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_ng.dds"));


            TestLoadTextureAndExport(Path.Combine(contentPath, @"Textures\Models\Characters\Astronaut\Astronaut_ng.dds"), true);
        }