Пример #1
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);
            }
        }
Пример #2
0
 private Task DrawPreviewOfSkin(SkinLink link)
 {
     return(Task.Run(() =>
     {
         lock (skinPackager)
         {
             var skin = link.Load();
             pictureBoxes.ForEach(x => x.ClearAll());
             tileFlyup.Image = ((Bitmap)skin.TilesFlyup)?.Rescale(stdTextureSize);
             FillPictureBoxGruopFromImageGroup(skySpherePreview, skin.SkySpheres, stdSkysphereSize);
             FillPictureBoxGruopFromImageGroup(tilesTexturesImageGroup, ((Bitmap)skin.Tiles)?.Squarify(), stdTextureSize);
             FillPictureBoxGruopFromImageGroup(particlesTexturesImageGroup, skin.Particles, stdTextureSize);
             FillPictureBoxGruopFromImageGroup(ringsTexturesImageGroup, skin.Rings, stdTextureSize);
             FillPictureBoxGruopFromImageGroup(hitsImageGroup, skin.Hits, stdTextureSize);
         }
     }));
 }
Пример #3
0
 private bool RemoveSelectedSkin(SkinLink skin)
 {
     try
     {
         File.Delete(skin.Path);
         SkinsListBox.Items.RemoveAt(SkinsListBox.SelectedIndex);
         SkinsListBox.SelectedIndex = 0;
         SkinsListBox.Invalidate();
         EnvironmentalVeriables.Skins.Remove(skin);
         return(true);
     }
     catch (Exception e)
     {
         MessageBox.Show("Can not remove selected skin!", "File error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         logger.Log("Error", e.ToString());
         return(false);
     }
 }
Пример #4
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;
         }
     }));
 }
Пример #5
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"));
        }