Пример #1
0
 private void InstallSkin(AudiosurfSkin skin, bool forcedInstall = false)
 {
     if (SkySpheresCheck.Checked || forcedInstall)
     {
         skin.SkySpheres?.Apply(x => x?.Save(EnvironmentalVeriables.gamePath));
     }
     if (HitsCheck.Checked || forcedInstall)
     {
         skin.Hits?.Apply(x => x?.Save(EnvironmentalVeriables.gamePath));
     }
     if (TilesCheck.Checked || forcedInstall)
     {
         skin.Tiles?.Save(EnvironmentalVeriables.gamePath);
         skin.TilesFlyup?.Save(EnvironmentalVeriables.gamePath);
     }
     if (ParticlesCheck.Checked || forcedInstall)
     {
         skin.Particles?.Apply(x => x?.Save(EnvironmentalVeriables.gamePath));
     }
     if (RingsCheck.Checked || forcedInstall)
     {
         skin.Rings?.Apply(x => x?.Save(EnvironmentalVeriables.gamePath));
     }
     skin.Cliffs?.Apply(x => x?.Save(EnvironmentalVeriables.gamePath));
 }
        public SkinCreatorForm()
        {
            InitializeComponent();
            LoadIdleImages();
            InitializeAssociationTables();
            skin = new AudiosurfSkin();
            CreateSkinFieldsAssotiationTables();
            tilesGroup = new[] { tile1, tile2, tile3, tile4 };

            tilesetSizes.Items.AddRange(SizesStrings);
            hitsSizes.Items.AddRange(SizesStrings);
            particlesSizes.Items.AddRange(SizesStrings);
            ringsSizes.Items.AddRange(SizesStrings);

            tilesetSizes.SelectedIndex   = 0;
            hitsSizes.SelectedIndex      = 0;
            particlesSizes.SelectedIndex = 0;
            ringsSizes.SelectedIndex     = 0;

            skinPackager = new SkinPackager();
            isRescaleCheckButton.Checked = true;
            skinNameEntry.Text           = "Unnamed skin";
            Focus();
            AllPictureboxes = new[]
            {
                Sphere1, Sphere2, Sphere3, tile1, tile2, tile3, tile4, tileflyup, ring1, ring2, ring3, ring4, part1, part2, part3, hit1, hit2
            };
        }
Пример #3
0
        private void OpenSkinBtnClick(object sender, EventArgs e)
        {
            if (openSkinDialog.ShowDialog() == DialogResult.OK)
            {
                var fileName = Path.GetFileName(openSkinDialog.FileName);
                Extensions.MoveFile(openSkinDialog.FileName, "Skins" + $@"\{fileName}");
                AudiosurfSkin openedSkin = skinPackager.Decompile($@"Skins\{fileName}");
                if (openedSkin == null)
                {
                    MessageBox.Show("Cant open empty .askin file", "Empty Skin!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (EnvironmentalVeriables.Skins.Select(x => x.Name).Contains(openedSkin.Name))
                {
                    MessageBox.Show("Skin already opened!", "Skin Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var tempLink = new SkinLink("Skins" + $@"\{fileName}", openedSkin.Name);

                if (!SkinsListBox.Items.Contains(openedSkin))
                {
                    EnvironmentalVeriables.Skins.Add(tempLink);
                    SkinsListBox.Items.Add(tempLink);
                }
                SkinsListBox.SelectedItem = tempLink;
                currentSkin = openedSkin;
                DrawPreviewOfSkin(tempLink);
            }
        }
        private void OpenSkin(object sender, EventArgs e)
        {
            //TODO: Catched exceptions show message box with info about exception
            openFileDialog.Filter           = "Audiosurf Skins (.askin)|*.askin";
            openFileDialog.InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Skins";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                skin             = skinPackager.Decompile(openFileDialog.FileName);
                pathToOpenedSkin = openFileDialog.FileName;
                try
                {
                    Sphere1.Image = ((Bitmap)skin.SkySpheres.Group[0]).Rescale(picBoxSizes["SkySphere"]);
                    Sphere2.Image = ((Bitmap)skin.SkySpheres.Group[1]).Rescale(picBoxSizes["SkySphere"]);
                    Sphere3.Image = ((Bitmap)skin.SkySpheres.Group[2]).Rescale(picBoxSizes["SkySphere"]);
                }
                catch { }

                try
                {
                    var tilesheet = ((Bitmap)skin.Tiles).Squarify();
                    tile1.Image = tilesheet[0].Rescale(picBoxSizes["Texture"]);
                    tile2.Image = tilesheet[1].Rescale(picBoxSizes["Texture"]);
                    tile3.Image = tilesheet[2].Rescale(picBoxSizes["Texture"]);
                    tile4.Image = tilesheet[3].Rescale(picBoxSizes["Texture"]);
                }
                catch { }
                try
                {
                    tileflyup.Image = ((Bitmap)skin.TilesFlyup).Rescale(picBoxSizes["Texture"]);
                }
                catch { }

                try
                {
                    ring1.Image = ((Bitmap)skin.Rings.Group[0]).Rescale(picBoxSizes["Texture"]);
                    ring2.Image = ((Bitmap)skin.Rings.Group[1]).Rescale(picBoxSizes["Texture"]);
                    ring3.Image = ((Bitmap)skin.Rings.Group[2]).Rescale(picBoxSizes["Texture"]);
                    ring4.Image = ((Bitmap)skin.Rings.Group[3]).Rescale(picBoxSizes["Texture"]);
                }
                catch { }

                try
                {
                    part1.Image = ((Bitmap)skin.Particles.Group[0]).Rescale(picBoxSizes["Texture"]);
                    part2.Image = ((Bitmap)skin.Particles.Group[1]).Rescale(picBoxSizes["Texture"]);
                    part3.Image = ((Bitmap)skin.Particles.Group[2]).Rescale(picBoxSizes["Texture"]);
                    hit1.Image  = ((Bitmap)skin.Hits.Group[0]).Rescale(picBoxSizes["Texture"]);
                    hit2.Image  = ((Bitmap)skin.Hits.Group[1]).Rescale(picBoxSizes["Texture"]);
                }
                catch { }
                CreateSkinFieldsAssotiationTables();
                AllPictureboxes.ForEach(x => RemoveMouseActions(x));
                openFileDialog.Filter   = "Supported Images(*.PNG; *.JPG)| *.PNG; *.JPG| All files(*.*) | *.*";
                openFileDialog.FileName = "";
                button1.Text            = "Rewrite current";
                button1.Click          -= ExportSkin;
                button1.Click          += RewriteSkin;
            }
        }
 private void Reset(object sender, EventArgs e)
 {
     skin = new AudiosurfSkin();
     LoadIdleImages();
     AllPictureboxes.ForEach(x => SetMouseActions(x));
     button1.Text   = "Export";
     button1.Click += ExportSkin;
     button1.Click -= RewriteSkin;
 }
Пример #6
0
        private bool ExportSkin(AudiosurfSkin skin, string path = null)
        {
            if (skin == null)
            {
                return(false);
            }

            return(path != null?skinPackager.CompileTo(skin, path) : skinPackager.Compile(skin));
        }
Пример #7
0
        private async void SkinsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                var selectedSkin = (SkinLink)SkinsListBox.SelectedItem;
                if (selectedSkin == null)
                {
                    return;
                }

                await DrawPreviewOfSkin(selectedSkin);

                currentSkin = selectedSkin.Load();
                SetSkinPartChecked();
            }
            catch (Exception exc)
            {
                MessageBox.Show($"Ooops! May be you select empty skin or something else goes wrong! We cant load selected skin!\n Error message{exc.Message}", "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
 private Task PackFolderIntoSkin(string directory)
 {
     return(Task.Run(() =>
     {
         lock (skinPackager)
         {
             AudiosurfSkin skin = skinPackager.CreateSkinFromFolder(directory);
             if (skin == null)
             {
                 MessageBox.Show($"Error during packaging {directory} into audiosurf skin. Please, Check selected folder", "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             if (MessageBox.Show("Do you want to name new skin?", "new skin", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 new OpenNewSkinForm().ShowDialog();
                 skin.Name = EnvironmentalVeriables.TempSkinName;
             }
             else
             {
                 string name = new DirectoryInfo(directory).Name;
                 foreach (var skinName in EnvironmentalVeriables.Skins.Select(x => x.Name))
                 {
                     if (name == skinName)
                     {
                         MessageBox.Show("Skin with same name already exist! Enter new name for this skin", "Naming Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         new OpenNewSkinForm().ShowDialog();
                         name = EnvironmentalVeriables.TempSkinName;
                         break;
                     }
                 }
                 skin.Name = name;
             }
             skinPackager.CompileTo(skin, "Skins");
             var link = new SkinLink(@"Skins\" + skin.Name + SkinPackager.skinExtension, skin.Name);
             EnvironmentalVeriables.Skins.Add(link);
             SkinsListBox.Invoke(new Action(() => SkinsListBox.Items.Add(link)));
             DrawPreviewOfSkin(link);
             currentSkin = skin;
         }
     }));
 }
Пример #9
0
        private void LoadSkins(string[] files, bool reload = false)
        {
            progressBar1.Invoke(new Action(() => progressBar1.Value = progressBar1.Minimum));
            if (reload)
            {
                EnvironmentalVeriables.Skins.Clear();
                SkinsListBox.Invoke(new Action(() => SkinsListBox.Items.Clear()));
            }
            var progBarPart = progressBar1.Maximum / files.Length;

            foreach (var path in files)
            {
                if (new FileInfo(path).Extension != ".askin")
                {
                    continue;
                }

                AudiosurfSkin skin = skinPackager.Decompile(path);
                if (skin == null)
                {
                    return;
                }

                var tempLink = new SkinLink(path, skin.Name);
                loadingSkinNameLabel.Invoke(new Action(() => loadingSkinNameLabel.Text = tempLink.Name));
                progressBar1.Invoke(new Action(() => progressBar1.Value += progBarPart));
                EnvironmentalVeriables.Skins.Add(tempLink);
                SkinsListBox.Invoke(new Action(() => SkinsListBox.Items.Add(tempLink)));
            }

            if (SkinsListBox.Items.Count == 0)
            {
                return;
            }

            progressBar1.Invoke(new Action(() => progressBar1.Value = progressBar1.Maximum));
            SkinsListBox.SetProperty(() => SkinsListBox.SelectedIndex, 0);
            SkinsListBox.Invoke(new Action(() => SkinsListBox.Invalidate()));
            loadingSkinNameLabel.Invoke(new Action(() => loadingSkinNameLabel.Text = "Complete"));
        }