public AudiosurfSkin CreateSkinFromFolder(string path) { var result = new AudiosurfSkin(); string[] AllPictures = Directory.GetFiles(path); if (!AllPictures.Any(fileName => texturesNames.Contains(Path.GetFileName(fileName)))) { return(null); } foreach (var mask in masks) { if (mask == EnvironmentalVeriables.CliffImagesMask) { result.Cliffs = GetAllImagesByNameMask("cliffs", mask, path); } if (mask == EnvironmentalVeriables.HitImageMask) { result.Hits = GetAllImagesByNameMask("hits", mask, path); } if (mask == EnvironmentalVeriables.ParticlesImageMask) { result.Particles = GetAllImagesByNameMask("particles", mask, path); } if (mask == EnvironmentalVeriables.RingsImageMask) { result.Rings = GetAllImagesByNameMask("rings", mask, path); } if (mask == EnvironmentalVeriables.SkysphereImagesMask) { result.SkySpheres = GetAllImagesByNameMask("skysphere", mask, path); } } ImageGroup tiles = GetAllImagesByNameMask("tiles", "tiles.png", path); ImageGroup tileflyup = GetAllImagesByNameMask("tiles flyup", "tileflyup.png", path); if (tiles.Group.Count > 1 || tileflyup.Group.Count > 1) { MessageBox.Show("Ooops! May be folder with your skin contain more that 1 texture with name 'tiles.png' or 'tileflyup.png' (or ***tiles.png / ***tileflyup.png).\nPlease, check folder with skin and correct names of textures", "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } result.Tiles = new NamedBitmap("tiles.png", (Bitmap)tiles); result.TilesFlyup = new NamedBitmap("tileflyup.png", (Bitmap)tileflyup); return(result); }
public bool RewriteCompile(AudiosurfSkin skin, string path) { try { IFormatter formatter = new BinaryFormatter(); using (Stream filestream = new FileStream(path, FileMode.Create)) { formatter.Serialize(filestream, skin); } return(true); } catch (Exception e) { MessageBox.Show($"Ooops! Something goes wrong! We cant save your skin {skin.Name}!\n Exception message: {e.Message}.\n Stack trace written in log file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.Log("ERROR", e.ToString()); return(false); } }
public bool Compile(AudiosurfSkin skin) { try { IFormatter formatter = new BinaryFormatter(); using (Stream filestream = new FileStream((EnvironmentalVeriables.skinsFolderPath ?? defaultOutput) + @"\\" + skin.Name + skinExtension, FileMode.OpenOrCreate)) { formatter.Serialize(filestream, skin); } return(true); } catch (Exception e) { MessageBox.Show($"Ooops! Something goes wrong! We cant save your skin {skin.Name}!\n Exception message: {e.Message}.\n Stack trace written in log file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); logger.Log("ERROR", e.ToString()); return(false); } }