Exemplo n.º 1
0
        protected override void OnClick(EventArgs e)
        {
            try
            {
                MMDForm.instance.Controls.Clear();

                DirectoryInfo path = new DirectoryInfo(MMDForm.modPath + "\\.osml");
                if (!path.Exists)
                {
                    path.Create();               // TODO: mark this as hidden
                }
                LoadingBar loadingBar = new LoadingBar(MMDForm.instance);
                loadingBar.SetLoadingStatus("working, please wait...");
                Audio.PlaySound(loadingBar.GetLoadingBGM(), false);

                // values
                string displayName = MMDForm.displayNameInstance.Text;
                string author      = MMDForm.authorInstance.Text;
                string version     = MMDForm.versionInstance.Text;
                string description = MMDForm.descriptionInstance.Text;

                // parse the ini file
                loadingBar.SetLoadingStatus("writing ini data to metadata.ini");

                INIManage.Parse(MMDForm.modPath + "\\.osml\\metadata.ini",
                                new string[4]
                {
                    "displayName",
                    "author",
                    "version",
                    "description"
                },
                                new string[4]
                {
                    displayName,
                    author,
                    version,
                    description
                }
                                );

                loadingBar.SetLoadingStatus("saving icon");

                // save the icon to the icon path
                MMDForm.icon.Image.Save(MMDForm.modPath + "\\.osml\\icon.png");

                loadingBar.SetLoadingStatus("almost done!");

                Console.Beep();
                MessageBox.Show("All done!");

                // close MMDForm and tidy up
                loadingBar.Dispose();
                MMDForm.instance.Close();
                Audio.Stop();
                Audio.PlaySound("sfx_back", false);
            }

            catch (Exception ex)
            {
                string message = "An exception was encountered:\n" + ex.Message +
                                 "\n------------------\n" + ex.ToString();
                Logger.WriteLine(message);
                MessageBox.Show(message);
            }
        }