private void ImportAPButton_Click(object sender, EventArgs e)
        {
            string title  = R._("読込むファイル名を選択してください");
            string filter = R._("AP|*.romtcs.ap.bin|All files|*");

            OpenFileDialog open = new OpenFileDialog();

            open.Title  = title;
            open.Filter = filter;

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (open.FileNames.Length <= 0 || !U.CanReadFileRetry(open.FileNames[0]))
                {
                    return;
                }
                filename = open.FileNames[0];
                Program.LastSelectedFilename.Save(this, "", open);
            }

            using (InputFormRef.AutoPleaseWait wait = new InputFormRef.AutoPleaseWait(this))
            {
                byte[] ap         = File.ReadAllBytes(filename);
                uint   ap_address = U.toOffset((uint)P4.Value);

                string        undoname = this.Text + " AP:" + U.ToHexString(ap_address);
                Undo.UndoData undodata = Program.Undo.NewUndoData(undoname);

                uint newaddr = InputFormRef.WriteBinaryData(this
                                                            , ap_address
                                                            , ap
                                                            , InputFormRef.get_data_pos_callback_ap
                                                            , undodata
                                                            );
                if (newaddr == U.NOT_FOUND)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }
                Program.Undo.Push(undodata);

                this.P4.Value = U.toPointer(newaddr);
            }

            //ポインタの書き込み
            this.WriteButton.PerformClick();
        }
示例#2
0
        private void MapChipImportButton_Click(object sender, EventArgs e)
        {
            if (MapStyleEditorFormWarningVanillaTileOverraideForm.CheckWarningUI((uint)ChipsetConfigAddress.Value))
            {
                return;
            }

            string title  = R._("読み込むファイル名を選択してください");
            string filter = R._("mapchip_config|*.mapchip_config|All files|*");

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Title  = title;
                open.Filter = filter;
                Program.LastSelectedFilename.Load(this, "mapchip_config", open);
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                Program.LastSelectedFilename.Save(this, "mapchip_config", open);
                filename = open.FileNames[0];
            }

            byte[] map_config = File.ReadAllBytes(filename);
            if (map_config.Length < 9216)
            {
                R.ShowStopError("ファイルサイズが小さすぎます. 9216バイト必要です。");
                return;
            }

            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            bool          r        = OverraideMapConfig(map_config, undodata);

            if (!r)
            {
                return;
            }

            Program.Undo.Push(undodata);
        }
示例#3
0
        private void AnimeImportButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                string title  = R._("開くファイル名を選択してください");
                string filter = R._("アニメスクリプト|*.txt|All files|*");

                OpenFileDialog open = new OpenFileDialog();
                open.Title    = title;
                open.Filter   = filter;
                open.FileName = "romanime_" + this.AddressList.Text.Trim();
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                filename = open.FileNames[0];
                Program.LastSelectedFilename.Save(this, "", open);
            }

            string error = "";

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                error = Import(filename);
            }
            if (error != "")
            {
                R.ShowStopError(error);
                return;
            }

            U.ReSelectList(this.AddressList);
        }
        private void MapChipImportButton_Click(object sender, EventArgs e)
        {
            string title  = R._("読み込むファイル名を選択してください");
            string filter = R._("mapchip_config|*.mapchip_config|All files|*");

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Title  = title;
                open.Filter = filter;
                Program.LastSelectedFilename.Load(this, "mapchip_config", open);
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                Program.LastSelectedFilename.Save(this, "mapchip_config", open);
                filename = open.FileNames[0];
            }

            if (U.GetFileSize(filename) < 9216)
            {
                R.ShowStopError("ファイルサイズが小さすぎます. 9216バイト必要です。");
                return;
            }

            this.configUZ = File.ReadAllBytes(filename);

            //チップセットの更新.
            Chipset_Update();
            SelectedChipset_Update();

            //書き込み
            ConfigWriteButton.PerformClick();

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }
        private void MagicAnimeImportButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            string title  = R._("開くファイル名を選択してください");
            string filter = R._("TEXT|*.txt|All files|*");

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Title  = title;
                open.Filter = filter;
                Program.LastSelectedFilename.Load(this, "", open);
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                Program.LastSelectedFilename.Save(this, "", open);
                filename = open.FileName;
            }

            //インポート実行
            uint   id    = (uint)AddressList.SelectedIndex + 1;
            string error = MagicAnimeImportDirect(id, filename);

            if (error != "")
            {
                R.ShowStopError(error);
                return;
            }
        }
示例#6
0
        private void AnimationImportButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                string title  = R._("開くファイル名を選択してください");
                string filter = R._("スキルアニメスクリプト|*.txt|All files|*");

                OpenFileDialog open = new OpenFileDialog();
                open.Title    = title;
                open.Filter   = filter;
                open.FileName = "skill_" + this.AddressList.Text.Trim();
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                filename = open.FileNames[0];
                Program.LastSelectedFilename.Save(this, "", open);
            }

            uint   id    = (uint)this.AddressList.SelectedIndex;
            string error = SkillAnimeImportDirect(id, filename);

            if (error != "")
            {
                R.ShowStopError(error);
                return;
            }
        }
示例#7
0
        private void ImportButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }
            if (AddressList.SelectedIndex <= 0)
            {
                return;
            }
            if (!this.InputFormRef.CheckWriteProtectionID00())
            {
                return;
            }

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                string title  = R._("インポートする音楽ファイルを選択してください");
                string filter = R._("sound|*.s;*.wav;*.mid;*.midi;*.instrument|s|*.s|midi|*.mid;*.midi|wav|*.wav|MusicalInstrument|*.instrument|All files|*");

                OpenFileDialog open = new OpenFileDialog();
                open.Title  = title;
                open.Filter = filter;
                Program.LastSelectedFilename.Load(this, "", open);
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                Program.LastSelectedFilename.Save(this, "", open);
                filename = open.FileNames[0];
            }

            uint songtable_address = InputFormRef.BaseAddress + (InputFormRef.BlockSize * (uint)AddressList.SelectedIndex);

            string error = "";

            string ext = U.GetFilenameExt(filename);

            if (ext == ".WAV" || ext == ".WAVE")
            {
                SongTrackImportWaveForm f = (SongTrackImportWaveForm)InputFormRef.JumpFormLow <SongTrackImportWaveForm>();
                f.Init(filename);
                DialogResult dr = f.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                {
                    f.Dettach();
                    return;
                }
                error = SongUtil.ImportWave(f.GetFilename(), songtable_address, f.UseLoop());
                f.Dettach();
            }
            else if (ext == ".MID" || ext == ".MIDI")
            {
                //楽器セットとオプションを選択してもらう.
                SongTrackImportMidiForm f = (SongTrackImportMidiForm)InputFormRef.JumpFormLow <SongTrackImportMidiForm>();
                f.Init((uint)P4.Value);
                DialogResult dr = f.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                //少し時間がかかるので、しばらくお待ちください表示.
                using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
                {
                    if (f.GetUseMID2AGB() == SongTrackImportMidiForm.ImportMethod.FEBuilderGBA)
                    {//FEBuilderGBAでimport
                        error = SongUtil.ImportMidiFile(filename, songtable_address
                                                        , f.GetInstrumentAddr()
                                                        , f.GetIgnoreMOD()
                                                        , f.GetIgnoreBEND()
                                                        , f.GetIgnoreLFOS()
                                                        , f.GetIgnoreHEAD()
                                                        , f.GetIgnoreBACK()
                                                        );
                    }
                    else
                    {//mid2agbでimport
                        error = SongUtil.ImportMidiFileMID2AGB(filename, songtable_address
                                                               , f.GetInstrumentAddr()
                                                               , f.GetMID2AGB_V()
                                                               , f.GetMID2AGB_R()
                                                               , f.GetIgnoreMOD()
                                                               , f.GetIgnoreBEND()
                                                               , f.GetIgnoreLFOS()
                                                               );
                    }
                }
            }
            else if (ext == ".INSTRUMENT")
            {
                //少し時間がかかるので、しばらくお待ちください表示.
                using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
                {
                    error = SongUtil.ImportInstrument(filename, songtable_address);
                }
            }
            else
            {
                //楽器セットを選択してもらう.
                SongTrackImportSelectInstrumentForm f = (SongTrackImportSelectInstrumentForm)InputFormRef.JumpFormLow <SongTrackImportSelectInstrumentForm>();
                f.Init((uint)P4.Value);
                DialogResult dr = f.ShowDialog();
                if (dr != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                //少し時間がかかるので、しばらくお待ちください表示.
                using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
                {
                    error = SongUtil.ImportS(filename, songtable_address, f.GetInstrumentAddr());
                }
            }


            if (error != "")
            {
                R.ShowStopError(error);
                return;
            }

            int selectedIndex = AddressList.SelectedIndex;

            ReloadListButton.PerformClick();
            AddressList.SelectedIndex = selectedIndex;

            SongTableForm.ReloadList();
            InputFormRef.ShowWriteNotifyAnimation(this, 0);
        }
        private void ImportAllButton_Click(object sender, EventArgs e)
        {
            U.AddrResult ar = InputFormRef.SelectToAddrResult(FilterComboBox, FilterComboBox.SelectedIndex);
            if (ar.isNULL())
            {
                R.ShowStopError("タイルアニメーションのPLISTを特定できません");
                return;
            }
            uint pointer;
            uint tileanime_addr = MapPointerForm.PlistToOffsetAddrFast(MapPointerForm.PLIST_TYPE.ANIMATION, ar.tag, out pointer);

            if (tileanime_addr == U.NOT_FOUND)
            {
                R.ShowStopError("タイルアニメーションのPLISTからポインタを求められません。\r\nPLIST:{0}", ar.tag);
                return;
            }
            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                string title  = R._("読込むファイル名を選択してください");
                string filter = R._("マップアニメ2|*.mapanime2.txt|All files|*");

                OpenFileDialog open = new OpenFileDialog();
                open.Title  = title;
                open.Filter = filter;

                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (open.FileNames.Length <= 0 || !U.CanReadFileRetry(open.FileNames[0]))
                {
                    return;
                }
                filename = open.FileNames[0];
                Program.LastSelectedFilename.Save(this, "", open);
            }

            using (InputFormRef.AutoPleaseWait wait = new InputFormRef.AutoPleaseWait(this))
            {
                string errorMessage = ImportAll(filename, pointer, this.InputFormRef);
                if (errorMessage != "")
                {
                    R.ShowStopError(errorMessage);
                    return;
                }
            }

            //リストを読み直し.
            int selected = FilterComboBox.SelectedIndex;
            List <U.AddrResult> animeList = MakeTileAnimation2();

            U.ConvertComboBox(animeList, ref FilterComboBox);

            //現在地を再選択して、リストを描画する.
            U.ForceUpdate(FilterComboBox, selected);
        }