Exemplo n.º 1
0
        bool WriteMapConfig(Undo.UndoData undodata)
        {
            if (this.MapStyle.SelectedIndex < 0)
            {
                return(false);
            }
            uint config_plist    = this.MapEditConf[this.MapStyle.SelectedIndex].config_plist;
            uint chipset_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CONFIG, config_plist);

            byte[] chipsetConfigZ = LZ77.compress(this.ConfigUZ);
            uint   newaddr        = InputFormRef.WriteBinaryData(this, (uint)ChipsetConfigAddress.Value, chipsetConfigZ, InputFormRef.get_data_pos_callback_lz77, undodata);

            if (newaddr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }
            ChipsetConfigAddress.Value = newaddr;

            //拡張領域に書き込んでいる可能性もあるので plstを更新する.
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.CONFIG, config_plist, newaddr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }

            //書き込んだ通知.
            InputFormRef.ShowWriteNotifyAnimation(this, newaddr);
            InputFormRef.WriteButtonToYellow(this.Config_WriteButton, false);
            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
            return(true);
        }
Exemplo n.º 2
0
        private void MapStyleEditorForm_Load(object sender, EventArgs e)
        {
            IsInit = true;

            //マップIDリストを作る.
            List <U.AddrResult> maplist = MapSettingForm.MakeMapIDList();

            //マップスタイルリストを作る
            this.MapEditConf = MapEditorForm.MakeMapStyleList(maplist);
            //マップスタイルリストを作る
            MakeMapStyleCombo();

            U.SelectedIndexSafety(this.MapStyle, 0);

            List <U.AddrResult> terrainList = MapTerrainNameForm.MakeList();

            U.ConvertComboBox(terrainList, ref this.ConfigTerrain);

            //マップオブジェクト
            this.MAP.SetChipSize(8);
            Bitmap black = ImageUtil.BlankDummy();

            U.MakeTransparent(black);
            this.MAP.SetDefaultIcon(black);

            //パレット
            this.PFR = new PaletteFormRef(this);
            PFR.MakePaletteUI(OnChangeColor, GetSampleBitmap);
            U.SelectedIndexSafety(this.PaletteCombo, 0);

            //TSA変更のイベント適応.
            List <Control> controls = InputFormRef.GetAllControls(this);

            InputFormRef.MakeLinkEvent("Config_", controls);


            //最大化禁止
            //C#のバグである Anchorを四隅にすると、スクロールバーが消えるというバグに対処するために、
            //フォームを固定化しないとおかしなことになる。
            //クレームは microsoft あたりまでどうぞ.
            this.MaximizeBox = false;
            IsInit           = false;

            U.AllowDropFilename(this, ImageFormRef.IMAGE_FILE_FILTER, (string filename) =>
            {
                using (ImageFormRef.AutoDrag ad = new ImageFormRef.AutoDrag(filename))
                {
                    ObjImportButton_Click(null, null);
                }
            });
            U.AllowDropFilename(this, new string[] { ".MAPCHIP_CONFIG" }, (string filename) =>
            {
                using (ImageFormRef.AutoDrag ad = new ImageFormRef.AutoDrag(filename))
                {
                    MapChipImportButton_Click(null, null);
                }
            });
        }
Exemplo n.º 3
0
        void ImportObj(Bitmap bitmap, bool importObjWithPalette)
        {
            const int palette_count = MAX_MAP_PALETTE_COUNT;
            int       width         = 32 * 8;
            int       height        = 32 * 8;

            if (bitmap.Width != width || bitmap.Height < 128)
            {
                R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height);
                return;
            }
            height = ImageUtil.CalcHeight(width, width * bitmap.Height / 2);

            if (importObjWithPalette)
            {//パレットもインポートする場合 パレット数のチェック.
                int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap);
                if (bitmap_palette_count > palette_count)
                {
                    R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count);
                    return;
                }

                bitmap = PaletteSwapper(bitmap);
            }

            //画像
            byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height);

            //画像等データの書き込み
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);

            bool r = WriteMapChipImage(image, undodata);

            if (!r)
            {
                return;
            }

            r = WriteMapChipPalette(bitmap, importObjWithPalette, palette_count, undodata);
            if (!r)
            {
                return;
            }

            Program.Undo.Push(undodata);

            //チップセットの更新.
            Chipset_Update();
            SelectedChipset_Update();
            MapStyle_SelectedIndexChanged(null, null);
            InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false);

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }
Exemplo n.º 4
0
        void NotifyMapEditor()
        {
            Form f = InputFormRef.GetForm <MapEditorForm>();

            if (f == null)
            {
                return;
            }
            uint mapid = (uint)AddressList.SelectedIndex;

            MapEditorForm mapeditor = (MapEditorForm)f;

            mapeditor.OnUpdateMapChangeForm(mapid);
        }
Exemplo n.º 5
0
        void N_PostWriteEvent(object sender, EventArgs arg)
        {
            Form f = InputFormRef.GetForm <MapEditorForm>();

            if (f == null)
            {
                return;
            }
            uint mapid = (uint)AddressList.SelectedIndex;

            MapEditorForm mapeditor = (MapEditorForm)f;

            mapeditor.OnUpdateMapChangeForm(mapid);
        }
Exemplo n.º 6
0
        private void X_JUMP_MAPEDITOR_Click(object sender, EventArgs e)
        {
            if (AddressList.SelectedIndex < 0)
            {
                return;
            }
            if (N_AddressList.SelectedIndex < 0)
            {
                return;
            }

            MapEditorForm f = (MapEditorForm)InputFormRef.JumpForm <MapEditorForm>(U.NOT_FOUND);

            f.JumpTo((uint)AddressList.SelectedIndex, (uint)N_B0.Value);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
        private void X_JUMP_MAPEDITOR_Click(object sender, EventArgs e)
        {
            if (AddressList.SelectedIndex < 0)
            {
                return;
            }
            if (N_AddressList.SelectedIndex < 0)
            {
                return;
            }
            U.AddrResult ar    = InputFormRef.SelectToAddrResult(this.AddressList);
            uint         mapid = ar.tag;

            MapEditorForm f = (MapEditorForm)InputFormRef.JumpForm <MapEditorForm>(U.NOT_FOUND);

            f.JumpTo(mapid, (uint)N_B0.Value);
        }
Exemplo n.º 9
0
        public const int MAX_MAP_PALETTE_COUNT   = PARTS_MAP_PALETTE_COUNT * 2; //通常と霧がある

        public MapStyleEditorForm()
        {
            InitializeComponent();

            //マップエディタのマップスタイル
            this.MapEditConf = MapEditorForm.PreLoadResource(U.ConfigDataFilename("mapstyle_"));

            this.ForeBrush = new SolidBrush(this.ForeColor);
            this.BackBrush = new SolidBrush(this.BackColor);
            PaletteTypeCombo.SelectedIndex = 0; //霧なし

            U.SetIcon(MapChipExportButton, Properties.Resources.icon_arrow);
            U.SetIcon(MapChipImportButton, Properties.Resources.icon_upload);
            U.SetIcon(ObjExportButton, Properties.Resources.icon_arrow);
            U.SetIcon(ObjImportButton, Properties.Resources.icon_upload);
            U.SetIcon(PaletteExportButton, Properties.Resources.icon_arrow);
            U.SetIcon(PaletteImportButton, Properties.Resources.icon_upload);
        }
Exemplo n.º 10
0
        private void PaletteImportButton_Click(object sender, EventArgs e)
        {
            if (this.MapStyle.SelectedIndex < 0)
            {
                return;
            }
            uint palette_plist = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist;
            uint obj_plist     = this.MapEditConf[this.MapStyle.SelectedIndex].obj_plist;

            Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this);

            if (bitmap == null)
            {
                return;
            }

            bool r = MapPaletteImport(bitmap, palette_plist);

            if (!r)
            {
                return;
            }

            //パレットの交換
            this.MapObjImage = ImageUtilMap.DrawMapChipOnly(obj_plist, palette_plist);
            if (this.MapObjImage == null)
            {
                this.MapObjImage = ImageUtil.BlankDummy();
            }
            U.ForceUpdate(this.PaletteCombo, 0);

            //チップセットの更新.
            Chipset_Update();
            SelectedChipset_Update();
            MapStyle_SelectedIndexChanged(sender, e);
            InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false);

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }
Exemplo n.º 11
0
        private void PaletteWriteButton_Click(object sender, EventArgs e)
        {
            if (this.MapStyle.SelectedIndex < 0)
            {
                return;
            }
            uint palette_plist = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist;
            int  palette_count = MAX_MAP_PALETTE_COUNT;

            Undo.UndoData undodata = Program.Undo.NewUndoData(this);

            //パレット情報の書き込み.
            uint palette_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist);

            if (palette_address == 0)
            {//未割り当てならば新規確保しようか
                palette_address = InputFormRef.AppendBinaryData(PaletteFormRef.NewNullPalette(palette_count), undodata);
            }

            PFR.MakePaletteColorPaletteToROM(this.MapObjImage.Palette, palette_address, palette_count, undodata);
            InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false);

            //拡張領域に書き込んでいる可能性もあるので plstを更新する.
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist, palette_address, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return;
            }

            Program.Undo.Push(undodata);

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }
Exemplo n.º 12
0
 void DrawMapChipInfo(int chipset_id, int x, int y, PaintEventArgs e)
 {
     MapEditorForm.DrawMapChipInfoLow(chipset_id, x, y, e, this.ConfigUZ, this.Font, this.ForeBrush, this.BackBrush);
 }
Exemplo n.º 13
0
        private void ObjImportButton_Click(object sender, EventArgs e)
        {
            if (this.MapStyle.SelectedIndex < 0)
            {
                return;
            }
            uint obj_plist  = this.MapEditConf[this.MapStyle.SelectedIndex].obj_plist;
            uint obj2_plist = (obj_plist >> 8) & 0xFF; //FE8にはないが FE7は、 plistを2つ設定できることがある.

            Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this);

            if (bitmap == null)
            {
                return;
            }
            int width         = 32 * 8;
            int height        = 32 * 8;
            int palette_count = MAX_MAP_PALETTE_COUNT;

            if (bitmap.Width != width || bitmap.Height < 128)
            {
                R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height);
                return;
            }
            height = ImageUtil.CalcHeight(width, width * bitmap.Height / 2);

            if (ObjImportOption.SelectedIndex == 1)
            {//パレットもインポートする場合 パレット数のチェック.
                int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap);
                if (bitmap_palette_count > palette_count)
                {
                    R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count);
                    return;
                }
                bitmap = PaletteSwapper(bitmap);
            }

            //画像
            byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height);

            //画像等データの書き込み
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            if (obj2_plist > 0)
            {//FE7とかあるフィールド画像分割
                byte[] image1  = U.subrange(image, 0, (uint)(image.Length / 2));
                byte[] image2  = U.subrange(image, (uint)(image.Length / 2), (uint)image.Length);
                byte[] image1Z = LZ77.compress(image1);
                byte[] image2Z = LZ77.compress(image2);
                uint   newaddr = InputFormRef.WriteBinaryData(this, (uint)ObjAddress.Value, image1Z, InputFormRef.get_data_pos_callback_lz77, undodata);
                if (newaddr == U.NOT_FOUND)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }

                ObjAddress.Value = newaddr;
                //拡張領域に書き込んでいる可能性もあるので plstを更新する.
                MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, obj_plist, newaddr, undodata);

                //分割されたデータを書き込み
                newaddr = InputFormRef.WriteBinaryData(this, (uint)ObjAddress2.Value, image2Z, InputFormRef.get_data_pos_callback_lz77, undodata);
                if (newaddr == U.NOT_FOUND)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }
                ObjAddress2.Value = newaddr;

                //拡張領域に書き込んでいる可能性もあるので plstを更新する.
                bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, obj2_plist, newaddr, undodata);
                if (!r)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }

                //書き込んだ通知.
                InputFormRef.ShowWriteNotifyAnimation(this, newaddr);
            }
            else
            {
                byte[] imageZ  = LZ77.compress(image);
                uint   newaddr = InputFormRef.WriteBinaryData(this, (uint)ObjAddress.Value, imageZ, InputFormRef.get_data_pos_callback_lz77, undodata);
                if (newaddr == U.NOT_FOUND)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }
                ObjAddress.Value = newaddr;

                //拡張領域に書き込んでいる可能性もあるので plstを更新する.
                bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, obj_plist, newaddr, undodata);
                if (!r)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }
                //書き込んだ通知.
                InputFormRef.ShowWriteNotifyAnimation(this, newaddr);
            }


            if (ObjImportOption.SelectedIndex == 1)
            {//パレットもインポートする場合
                //パレットの交換
                MapObjImage = bitmap;
                U.ForceUpdate(this.PaletteTypeCombo, 0);
                U.ForceUpdate(this.PaletteCombo, 0);

                //パレット情報の書き込み.
                uint palette_plist   = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist;
                uint palette_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist);
                if (palette_address == 0)
                {//未割り当てならば新規確保しようか
                    palette_address = InputFormRef.AppendBinaryData(PaletteFormRef.NewNullPalette(palette_count), undodata);
                }
                PaletteFormRef.MakePaletteBitmapToROM(this, bitmap, palette_address, palette_count, undodata);

                //拡張領域に書き込んでいる可能性もあるので plstを更新する.
                bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist, palette_address, undodata);
                if (!r)
                {
                    Program.Undo.Rollback(undodata);
                    return;
                }

                PaletteAddress.Value = palette_address;
            }
            else
            {//パレットはインポートしない場合
                //パレット情報の継承.
                bitmap.Palette = this.MapObjImage.Palette;
                //obj Bitmap交換
                this.MapObjImage = bitmap;
            }

            Program.Undo.Push(undodata);

            //チップセットの更新.
            Chipset_Update();
            SelectedChipset_Update();
            MapStyle_SelectedIndexChanged(sender, e);
            InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false);

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }