Пример #1
0
        public MainForm()
        {
            InitializeComponent();
            DialogCaption = "emutool v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Text          = DialogCaption + " - emuiibo's tool for virtual amiibo creation";
            Amiibos       = AmiiboAPI.GetAllAmiibos();

            if (HasAmiibos())
            {
                APIStatusLabel.Text = "AmiiboAPI was accessed - amiibo list was loaded.";
                AmiiboSeries        = Amiibos.GetAmiiboSeries();

                if (AmiiboSeries.Any())
                {
                    foreach (var series in AmiiboSeries)
                    {
                        SeriesComboBox.Items.Add(series);
                    }
                    SeriesComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                APIStatusLabel.Text     = "Unable to download amiibo list from AmiiboAPI.";
                APIStatusLabel.Image    = Properties.Resources.ErrorIcon;
                AmiiboSelectBox.Enabled = false;
                SettingsBox.Enabled     = false;
                GenerationBox.Enabled   = false;
            }
        }
Пример #2
0
        public MainForm()
        {
            InitializeComponent();
            DialogCaption = "emutool v" + Assembly.GetExecutingAssembly().GetName().Version;
            Text          = DialogCaption + " - emuiibo's tool for virtual amiibo creation";
            Amiibos       = AmiiboAPI.GetAllAmiibos();

            if (HasAmiibos())
            {
                toolStripStatusLabel1.Text = "AmiiboAPI was accessed - amiibo list was loaded.";
                AmiiboSeries = Amiibos.GetAmiiboSeries();

                if (AmiiboSeries.Any())
                {
                    foreach (var series in AmiiboSeries)
                    {
                        SeriesComboBox.Items.Add(series);
                    }
                }
            }
            else
            {
                toolStripStatusLabel1.Text  = "Unable to download amiibo list from AmiiboAPI.";
                toolStripStatusLabel1.Image = Properties.Resources.ErrorIcon;
                groupBox1.Enabled           = false;
                groupBox2.Enabled           = false;
                groupBox3.Enabled           = false;
            }
        }
Пример #3
0
        public MainForm()
        {
            InitializeComponent();
            Amiibos = AmiiboAPI.GetAllAmiibos();

            if (HasAmiibos())
            {
                toolStripStatusLabel1.Text = "AmiiboAPI was accessed - amiibo list was loaded.";
                AmiiboSeries = Amiibos.GetAmiiboSeries();

                if (AmiiboSeries.Any())
                {
                    foreach (var series in AmiiboSeries)
                    {
                        comboBox1.Items.Add(series);
                    }
                    comboBox1.SelectedIndex = 0;
                }
            }
            else
            {
                toolStripStatusLabel1.Text  = "Unable to download amiibo list from AmiiboAPI.";
                toolStripStatusLabel1.Image = Properties.Resources.ErrorIcon;
                groupBox1.Enabled           = false;
                groupBox2.Enabled           = false;
                groupBox3.Enabled           = false;
            }
        }
Пример #4
0
        public MainForm()
        {
            InitializeComponent();
            DialogCaption = "emutool v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Text          = DialogCaption + " - emuiibo的虚拟amiibo创建工具";
            Amiibos       = AmiiboAPI.GetAllAmiibos();

            if (HasAmiibos())
            {
                APIStatusLabel.Text = "Amiibo API已被访问 - amiibo列表已加载。";
                AmiiboSeries        = Amiibos.GetAmiiboSeries();

                if (AmiiboSeries.Any())
                {
                    foreach (var series in AmiiboSeries)
                    {
                        SeriesComboBox.Items.Add(series);
                    }
                    SeriesComboBox.SelectedIndex = 0;
                }
            }
            else
            {
                APIStatusLabel.Text     = "无法通过Amiibo API下载amiibo列表。";
                APIStatusLabel.Image    = Properties.Resources.ErrorIcon;
                AmiiboSelectBox.Enabled = false;
                SettingsBox.Enabled     = false;
                GenerationBox.Enabled   = false;
            }
        }
Пример #5
0
        private void CreateButton_Click(object sender, EventArgs e)
        {
            try
            {
                string base_dir = "";
                if (!FtpSaveCheck.Checked)
                {
                    // If we're saving normally and we're not using the last path, ask the user for the path
                    base_dir = SelectDirectory();
                    if (base_dir == null)
                    {
                        // User cancelled
                        return;
                    }
                }

                if (!CreateAllCheck.Checked)
                {
                    var cur_amiibo = CurrentSeriesAmiibos[AmiiboComboBox.SelectedIndex];
                    if (string.IsNullOrEmpty(AmiiboNameBox.Text))
                    {
                        ShowErrorBox("No amiibo name was specified.");
                        return;
                    }

                    bool use_name_as_dir = UseNameCheck.Checked;
                    if (!use_name_as_dir && string.IsNullOrEmpty(DirectoryNameBox.Text))
                    {
                        ShowErrorBox("No amiibo directory name was specified.");
                        return;
                    }

                    string name     = AmiiboNameBox.Text;
                    string dir_name = name;
                    if (!use_name_as_dir)
                    {
                        dir_name = DirectoryNameBox.Text;
                    }

                    CreateAmiibo(name, dir_name, base_dir, cur_amiibo);
                    MessageBox.Show("The virtual amiibo was successfully created.", DialogCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    var actual_base_dir = base_dir;
                    AmiiboSeries = Amiibos.GetAmiiboSeries();
                    if (AmiiboSeries.Any())
                    {
                        foreach (var series in AmiiboSeries)
                        {
                            base_dir = Path.Combine(actual_base_dir, series);
                            Utils.RecreateDirectory(base_dir);
                            CurrentSeriesAmiibos = Amiibos.GetAmiibosBySeries(series);
                            if (CurrentSeriesAmiibos.Any())
                            {
                                foreach (var amiibo in CurrentSeriesAmiibos)
                                {
                                    CreateAmiibo(amiibo.AmiiboName, amiibo.AmiiboName, base_dir, amiibo);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ey, no amiibos");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ey, no series");
                    }
                    MessageBox.Show("All virtual amiibos were successfully created.", DialogCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Utils.LogExceptionMessage(ex);
            }

            LastPathLabel.Visible = LastPathCheck.Visible = !string.IsNullOrEmpty(LastUsedPath);
            if (LastPathLabel.Visible)
            {
                LastPathLabel.Text = "Last path: " + LastUsedPath;
            }
        }
Пример #6
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                var cur_amiibo = CurrentSeriesAmiibos[AmiiboComboBox.SelectedIndex];
                if (string.IsNullOrEmpty(AmiiboNameBox.Text))
                {
                    ShowErrorBox("No amiibo name was specified.");
                    return;
                }


                bool use_name_as_dir = UseNameCheck.Checked;
                if (!use_name_as_dir && string.IsNullOrEmpty(DirectoryNameBox.Text))
                {
                    ShowErrorBox("No amiibo directory name was specified.");
                    return;
                }

                string name     = AmiiboNameBox.Text;
                string dir_name = name;
                if (!use_name_as_dir)
                {
                    dir_name = DirectoryNameBox.Text;
                }

                string out_path      = "";
                bool   use_last_path = LastPathCheck.Checked;
                if (use_last_path)
                {
                    if (string.IsNullOrEmpty(LastUsedPath))
                    {
                        use_last_path = false;
                    }
                }

                bool      save_to_ftp = FtpSaveCheck.Checked;
                IPAddress ftp_ip      = null;
                int       ftp_port    = 0;

                // For FTP, use a temp directory to save the resulting files from amiibo.Save() before transfer
                var ftp_tmp_path  = Path.Combine(Environment.CurrentDirectory, "temp_ftp");
                var ftp_sd_folder = $"/emuiibo/amiibo/{dir_name}/";
                var selected_path = "";

                if (save_to_ftp)
                {
                    // Prepare FTP path
                    out_path = Path.Combine(ftp_tmp_path, dir_name);

                    // Validate the FTP address
                    if (!IPAddress.TryParse(FtpAddressBox.Text, out ftp_ip))
                    {
                        ShowErrorBox("FTP address is invalid");
                        return;
                    }

                    if (!int.TryParse(FtpPortBox.Text, out ftp_port))
                    {
                        ShowErrorBox("FTP port is invalid");
                        return;
                    }

                    if (CancelAmiiboCreation($"'ftp://{ftp_ip.ToString()}:{ftp_port}{ftp_sd_folder}'"))
                    {
                        // User cancelled
                        return;
                    }
                }
                else
                {
                    if (use_last_path)
                    {
                        if (CancelAmiiboCreation("the last used path"))
                        {
                            // User cancelled
                            return;
                        }
                        out_path = Path.Combine(LastUsedPath, dir_name);
                    }
                    else
                    {
                        // If we're saving normally and we're not using the last path, ask the user for the path
                        selected_path = SelectDirectory();
                        if (selected_path == null)
                        {
                            // User cancelled
                            return;
                        }
                        out_path = Path.Combine(selected_path, dir_name);
                        if (CancelAmiiboCreation($"'{out_path}'"))
                        {
                            // User cancelled
                            return;
                        }
                    }
                }

                // Actually save the amiibo
                if (generateAllAmibosCheck.Checked)
                {
                    AmiiboSeries = Amiibos.GetAmiiboSeries();
                    if (AmiiboSeries.Any())
                    {
                        foreach (var series in AmiiboSeries)
                        {
                            CurrentSeriesAmiibos = Amiibos.GetAmiibosBySeries(series);
                            if (CurrentSeriesAmiibos.Any())
                            {
                                var index = 0;
                                foreach (var amiibo in CurrentSeriesAmiibos)
                                {
                                    var amiibo_build = AmiiboUtils.BuildAmiibo(CurrentSeriesAmiibos[index], amiibo.AmiiboName);
                                    amiibo_build.Save(out_path + "\\" + series + "\\" + amiibo.AmiiboName, RandomizeUuidCheck.Checked, SaveImageCheck.Checked);
                                    index++;
                                }
                            }
                        }
                    }
                }
                else
                {
                    var amiibo = AmiiboUtils.BuildAmiibo(cur_amiibo, name);
                    amiibo.Save(out_path, RandomizeUuidCheck.Checked, SaveImageCheck.Checked);
                }


                // Special handling for FTP
                if (save_to_ftp)
                {
                    var success = true;
                    using (var client = new FtpClient(ftp_ip.ToString(), ftp_port, new NetworkCredential("", "")))
                    {
                        client.ConnectTimeout = 1000;
                        client.Connect();
                        foreach (var file in Directory.GetFiles(out_path))
                        {
                            var file_name = Path.GetFileName(file);
                            // Upload each file created, creating directories along the way
                            var status = client.UploadFile(file, ftp_sd_folder + file_name, createRemoteDir: true);
                            if (status != FtpStatus.Success)
                            {
                                success = false;
                                break;
                            }
                        }
                        client.Disconnect();
                    }

                    ExceptionUtils.Unless(success, "Error during FTP upload, please try again");

                    // Clean the temp directory
                    Directory.Delete(ftp_tmp_path, true);
                }
                else
                {
                    if (!use_last_path)
                    {
                        // Update last used path
                        LastUsedPath = selected_path;
                    }
                }

                MessageBox.Show("The virtual amiibo was successfully created.", DialogCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                ExceptionUtils.LogExceptionMessage(ex);
            }
            LastPathLabel.Visible = LastPathCheck.Visible = !string.IsNullOrEmpty(LastUsedPath);
            if (LastPathLabel.Visible)
            {
                LastPathLabel.Text = "Last path: " + LastUsedPath;
            }
        }