Exemplo n.º 1
0
 /// <summary>
 /// 今開いているROMを閉じる
 /// </summary>
 /// <returns>実際に閉じたならfalse, 閉じなかったならtrue</returns>
 public bool closeRomFile()
 {
     try
     {
         rom.Dispose();
         rom = null;
         mainView.Dispose();
         objectPlaceList.mainView = mainView = null;
         setInfoStatusText("ROM closed");
         return false;
     }
     catch (ROM.UserCancel)
     {
         return true;
     }
 }
Exemplo n.º 2
0
Arquivo: Map.cs Projeto: anta-/YSedit
        /// <summary>
        /// Mapに関してデータを読み、初期化をする
        /// </summary>
        /// <exception cref="ArgumentException">mapNumberが大きすぎた場合</exception>
        /// <exception cref="DataException">mapNumberが無効なマップを指している、またはROMが壊れている場合</exception>
        public Map(ROM rom_, byte mapNumber, MainView mainView)
        {
            rom = rom_;
            romIF = rom.romIF;
            this.mainView = mainView;
            mainView.onChanged += () => { rom.newChange(true); };

            if (romIF.mapNumbers <= mapNumber)
                throw new ArgumentException("map number is too big");

            currentMapNumber = mapNumber;
            ustruct5 = rom.readData(romIF.ustruct5Table + mapNumber * romIF.ustruct5_size, romIF.ustruct5_size);
            var iUStruct3 = ustruct5.getDataID(romIF.uttruct5_iUStruct3);
            ustruct3 = rom.readData(iUStruct3, romIF.ustruct3_size);
            var iiPlaceVector = ustruct3.getDataID(romIF.ustruct3_iiPlaceVector);
            var iPlaceVector = rom.readData(iiPlaceVector, 4).getDataID(0);
            placeVector = rom.readData(iPlaceVector, romIF.placeVector_size);
            var iObjPlaces = placeVector.getDataID(romIF.placeVector_iObjPlaces);
            var objPlaces = rom.readData(iObjPlaces,
                placeVector.getHalf(romIF.placeVector_numberOfObjPlaces) * romIF.objPlaceC_size);

            mainView.setObjPlaces(objPlaces);   //objPlacesはmainViewが持つ
            mainView.size = new System.Drawing.Size(0x2000, 0x200); //TODO: データから読み込む
        }
Exemplo n.º 3
0
        /// <summary>
        /// pathのROMファイルを開く。既に開いていたら閉じる
        /// </summary>
        /// <returns>成功したかどうか</returns>
        public bool openRomFile(string path)
        {
            Action<string> err = s =>
            {
                MessageBox.Show(s, "Error");
            };

            if (rom != null)
                closeRomFile();

            bool proceeded = false;
            try
            {
                rom = new ROM(path);
                rom.changedChanged += romChangedChanged;

                objectPlaceList.mainView = rom.mainView = mainView =
                     new MainView(mainViewPanel, rom.romIF,
                         objectPlaceList, objectSelector);

                rom.openPracticeMap();
                setInfoStatusText("ROM \"" + path + "\", practice map opened");
                proceeded = true;
            }
            catch (System.IO.IOException)
            {
                err("Can't open ROM file");
            }
            catch (UnauthorizedAccessException)
            {
                err("Can't open ROM file");
            }
            catch (ROM.UnknownROMException)
            {
                err("Unknown ROM file");
            }
            catch (DataException e)
            {
                err("ROM is broken (" + e.Message + ")");
            }
            finally
            {
                if (!proceeded)
                {
                    if (rom != null)
                        rom.Dispose();
                    rom = null;
                    if (mainView != null)
                        mainView.Dispose();
                    mainView = null;
                }
            }
            return proceeded;
        }