Пример #1
0
        public Bitmap makeObject(int index, ObjRec[] objects, Bitmap[][] objStrips, MapViewType drawType, int constantSubpal = -1)
        {
            var obj        = objects[index];
            int scaleInt16 = 16;
            var images     = new Image[obj.getSize()];

            for (int i = 0; i < obj.getSize(); i++)
            {
                int x        = i % obj.w;
                int y        = i / obj.w;
                int pali     = (y >> 1) * (obj.w >> 1) + (x >> 1);
                var objStrip = constantSubpal == -1 ? objStrips[obj.getSubpallete(pali)] : objStrips[constantSubpal];
                images[i] = objStrip[obj.indexes[i]];
            }

            var mblock = UtilsGDI.GlueImages(images, obj.w, obj.h);

            using (Graphics g2 = Graphics.FromImage(mblock))
            {
                if (drawType == MapViewType.ObjType)
                {
                    g2.FillRectangle(new SolidBrush(CadObjectTypeColors[obj.getType()]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                    g2.DrawString(String.Format("{0:X}", obj.getType()), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                }
                else if (drawType == MapViewType.ObjNumbers)
                {
                    g2.FillRectangle(new SolidBrush(Color.FromArgb(192, 255, 255, 255)), new Rectangle(0, 0, scaleInt16, scaleInt16));
                    g2.DrawString(String.Format("{0:X}", index), new Font("Arial", 6), Brushes.Red, new Point(0, 0));
                }
            }
            return(mblock);
        }
Пример #2
0
 private void changeLevelIndex(bool reloadBlocks = false)
 {
     curActiveVideoNo    = cbVideoNo.SelectedIndex;
     curActiveBigBlockNo = cbBigBlockNo.SelectedIndex;
     curActiveBlockNo    = cbBlockNo.SelectedIndex;
     curActivePalleteNo  = cbPaletteNo.SelectedIndex;
     curViewType         = (MapViewType)cbViewType.SelectedIndex;
     reloadLevel(true, reloadBlocks);
 }
Пример #3
0
        public Image[] makeBigBlocks(int videoNo, int bigBlockNo, BigBlock[] bigBlockIndexes, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
                                     MapViewType curViewType = MapViewType.Tiles, int hierarchyLevel = 0)
        {
            int blockCount = ConfigScript.getBigBlocksCount(hierarchyLevel);
            var bigBlocks  = new Image[blockCount];

            Image[] smallBlocksPack;
            if (hierarchyLevel == 0)
            {
                smallBlocksPack = makeObjects(videoNo, bigBlockNo, palleteNo, smallObjectsViewType);
            }
            else
            {
                var bigBlockIndexesPrev = ConfigScript.getBigBlocksRecursive(hierarchyLevel - 1, bigBlockNo);
                smallBlocksPack = makeBigBlocks(videoNo, bigBlockNo, bigBlockIndexesPrev, palleteNo, smallObjectsViewType, curViewType, hierarchyLevel - 1);
            }

            //tt version hardcode
            Image[][] smallBlocksAll = null;

            bool smallBlockHasSubpals = bigBlockIndexes == null ? true : bigBlockIndexes[0].smallBlocksWithPal();

            if (!smallBlockHasSubpals)
            {
                smallBlocksAll = new Image[4][];
                for (int i = 0; i < 4; i++)
                {
                    smallBlocksAll[i] = makeObjects(videoNo, bigBlockNo, palleteNo, smallObjectsViewType, i);
                }
            }
            else
            {
                smallBlocksAll = new Image[4][] { smallBlocksPack, smallBlocksPack, smallBlocksPack, smallBlocksPack };
            }

            for (int btileId = 0; btileId < blockCount; btileId++)
            {
                Image b;
                if (ConfigScript.isBuildScreenFromSmallBlocks())
                {
                    var sb = smallBlocksPack[btileId];
                    //scale for small blocks
                    b = UtilsGDI.ResizeBitmap(sb, (int)(sb.Width * 2), (int)(sb.Height * 2));
                }
                else
                {
                    b = bigBlockIndexes[btileId].makeBigBlock(smallBlocksAll);
                }
                if (curViewType == MapViewType.ObjNumbers)
                {
                    b = VideoHelper.addObjNumber(b, btileId);
                }
                bigBlocks[btileId] = b;
            }
            return(bigBlocks);
        }
Пример #4
0
        public Bitmap[] makeObjects(ObjRec[] objects, Bitmap[][] objStrips, MapViewType drawType, int constantSubpal = -1)
        {
            var ans = new Bitmap[objects.Length];

            for (int index = 0; index < objects.Length; index++)
            {
                ans[index] = makeObject(index, objects, objStrips, drawType, constantSubpal);
            }
            return(ans);
        }
Пример #5
0
        /// <summary>
        ///     Performs the search in apple maps application.
        /// </summary>
        /// <param name="query">
        ///     The query. This parameter is treated as if its value had been typed into the Maps search field by
        ///     the user.
        /// </param>
        /// <param name="viewType">Map view type.</param>
        public static void PerformSearch(string query, MapViewType viewType = MapViewType.Standard)
        {
            if (IGUtils.IsIosCheck())
            {
                return;
            }

            Check.Argument.IsStrNotNullOrEmpty(query, "query");

            var url = FormatMapsUrl("q={0}&t={1}", UnityWebRequest.EscapeURL(query), _mapViews[viewType]);

            IGUtils._openUrl(url);
        }
Пример #6
0
        private void cbLevelPair_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (
                cbTileset.SelectedIndex == -1 ||
                cbVideoNo.SelectedIndex == -1 ||
                cbPaletteNo.SelectedIndex == -1 ||
                cbPart.SelectedIndex == -1 ||
                cbViewType.SelectedIndex == -1 ||
                cbSmallBlock.SelectedIndex == -1 ||
                cbHierarchyLevel.SelectedIndex == -1
                )
            {
                return;
            }
            if (!readOnly && dirty && (sender == cbTileset || sender == cbHierarchyLevel))
            {
                DialogResult dr = MessageBox.Show("Tiles was changed. Do you want to save current tileset?", "Save", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Cancel)
                {
                    returnCbLevelIndexes();
                    return;
                }
                else if (dr == DialogResult.Yes)
                {
                    if (!saveToFile())
                    {
                        returnCbLevelIndexes();
                        return;
                    }
                }
                else
                {
                    dirty = false;
                    updateSaveVisibility();
                }
            }

            //generic version
            curHierarchyLevel = cbHierarchyLevel.SelectedIndex;
            curTileset        = cbTileset.SelectedIndex;
            curSmallBlockNo   = cbSmallBlock.SelectedIndex;
            curViewType       = (MapViewType)cbViewType.SelectedIndex;

            curVideo   = cbVideoNo.SelectedIndex;
            curPallete = cbPaletteNo.SelectedIndex;
            curPart    = cbPart.SelectedIndex;
            UtilsGui.setCbItemsCount(cbPart, Math.Max(ConfigScript.getBigBlocksCount(curHierarchyLevel) / 256, 1));
            UtilsGui.setCbIndexWithoutUpdateLevel(cbPart, cbLevelPair_SelectedIndexChanged, curPart);
            reloadLevel();
        }
Пример #7
0
        public static Image[] setBlocksForPictures(float curButtonScale = 2, int blockWidth = 32, int blockHeight = 32, MapViewType curDrawType = MapViewType.Tiles)
        {
            //only if using pictures
            if (!ConfigScript.usePicturesInstedBlocks || ConfigScript.getBlocksPicturesFilename() == "")
            {
                return(null);
            }
            MapViewType curViewType   = curDrawType;
            var         imSrc         = Image.FromFile(ConfigScript.getBlocksPicturesFilename());
            int         imBlockWidth  = blockWidth * 2; //default scale
            int         imBlockHeight = blockHeight * 2;
            int         imCountX      = imSrc.Width / imBlockWidth;
            int         imCountY      = imSrc.Height / imBlockHeight;

            var bigBlocks = new Image[imCountX * imCountY];

            for (int i = 0; i < bigBlocks.Length; i++)
            {
                bigBlocks[i] = new Bitmap((int)(curButtonScale * blockWidth), (int)(curButtonScale * blockHeight));
            }

            for (int y = 0; y < imCountY; y++)
            {
                for (int x = 0; x < imCountX; x++)
                {
                    var imBlock   = CropImage(imSrc, new Rectangle(x * imBlockWidth, y * imBlockHeight, imBlockWidth, imBlockHeight));
                    var imResized = ResizeBitmap(imBlock, (int)(curButtonScale * blockWidth), (int)(curButtonScale * blockHeight));
                    bigBlocks[y * imCountX + x] = imResized;
                }
            }

            if (curViewType == MapViewType.ObjNumbers)
            {
                int _bbRectPosX  = (int)((blockWidth / 2) * curButtonScale);
                int _bbRectSizeX = (int)((blockWidth / 2) * curButtonScale);
                int _bbRectPosY  = (int)((blockHeight / 2) * curButtonScale);
                int _bbRectSizeY = (int)((blockHeight / 2) * curButtonScale);
                for (int i = 0; i < 256; i++)
                {
                    var im1 = bigBlocks[i];
                    using (var g = Graphics.FromImage(im1))
                    {
                        g.FillRectangle(new SolidBrush(Color.FromArgb(192, 255, 255, 255)), new Rectangle(0, 0, _bbRectSizeX * 2, _bbRectSizeY * 2));
                        g.DrawString(String.Format("{0:X}", i), new Font("Arial", 16), Brushes.Red, new Point(0, 0));
                    }
                    bigBlocks[i] = im1;
                }
            }
            return(bigBlocks);
        }
Пример #8
0
        /// <summary>
        ///     Opens the apple maps location.
        /// </summary>
        /// <param name="location">Location to open.</param>
        /// <param name="label">Label of location.</param>
        /// <param name="viewType">Map view type.</param>
        public static void OpenMapLocation(Location location, string label = null, MapViewType viewType = MapViewType.Standard)
        {
            if (IGUtils.IsIosCheck())
            {
                return;
            }

            var url = FormatMapsUrl("ll={0}&t={1}", location.ToLinkStr(), _mapViews[viewType]);

            if (label != null)
            {
                // The q parameter can also be used as a label
                // if the location is explicitly defined in the ll or address parameters.
                url = url + "&q=" + label;
            }
            IGUtils._openUrl(url);
        }
Пример #9
0
        public Bitmap[] makeObjects(int videoPageId, int tilesId, int palId, MapViewType drawType, int constantSubpal = -1)
        {
            byte[]   videoChunk = ConfigScript.getVideoChunk(videoPageId);
            ObjRec[] objects    = ConfigScript.getBlocks(tilesId);

            byte[] palette   = ConfigScript.getPal(palId);
            var    range256  = Enumerable.Range(0, 256);
            var    objStrip1 = range256.Select(i => makeImage(i, videoChunk, palette, 0)).ToArray();
            var    objStrip2 = range256.Select(i => makeImage(i, videoChunk, palette, 1)).ToArray();
            var    objStrip3 = range256.Select(i => makeImage(i, videoChunk, palette, 2)).ToArray();
            var    objStrip4 = range256.Select(i => makeImage(i, videoChunk, palette, 3)).ToArray();
            var    objStrips = new[] { objStrip1, objStrip2, objStrip3, objStrip4 };

            var bitmaps = makeObjects(objects, objStrips, drawType, constantSubpal);

            return(bitmaps);
        }
Пример #10
0
        private void cbLevelPair_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (
                cbTileset.SelectedIndex == -1 ||
                cbVideoNo.SelectedIndex == -1 ||
                cbPaletteNo.SelectedIndex == -1 ||
                cbViewType.SelectedIndex == -1 ||
                cbBigBlock.SelectedIndex == -1 ||
                cbHierarchyLevel.SelectedIndex == -1
                )
            {
                return;
            }
            if (!readOnly && dirty && (sender == cbTileset || sender == cbHierarchyLevel))
            {
                DialogResult dr = MessageBox.Show("Tiles was changed. Do you want to save current tileset?", "Save", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Cancel)
                {
                    returnCbLevelIndexes();
                    return;
                }
                else if (dr == DialogResult.Yes)
                {
                    if (!saveToFile())
                    {
                        returnCbLevelIndexes();
                        return;
                    }
                }
                else
                {
                    dirty = false;
                    updateSaveVisibility();
                }
            }

            //generic version
            curHierarchyLevel = cbHierarchyLevel.SelectedIndex;
            curTileset        = cbTileset.SelectedIndex;
            curBigBlockNo     = cbBigBlock.SelectedIndex;
            curViewType       = (MapViewType)cbViewType.SelectedIndex;

            curVideo   = cbVideoNo.SelectedIndex;
            curPallete = cbPaletteNo.SelectedIndex;
            reloadLevel();
        }
Пример #11
0
        /// <summary>
        ///     Opens the map address.
        /// </summary>
        /// <param name="address">Address to open.</param>
        /// <param name="label">Label of location.</param>
        /// <param name="viewType">Map view type.</param>
        public static void OpenMapAddress(string address, string label = null, MapViewType viewType = MapViewType.Standard)
        {
            if (IGUtils.IsIosCheck())
            {
                return;
            }

            address = address.EscapeMapQuery();
            Check.Argument.IsStrNotNullOrEmpty(address, "address");

            var url = FormatMapsUrl("address={0}&t={1}", address, _mapViews[viewType]);

            if (label != null)
            {
                // The q parameter can also be used as a label
                // if the location is explicitly defined in the ll or address parameters.
                url = url + "&q=" + label;
            }
            IGUtils._openUrl(url);
        }
Пример #12
0
        /// <summary>
        ///     Performs the search with provided query near specified location.
        /// </summary>
        /// <param name="query">Query.</param>
        /// <param name="searchLocation">Search location.</param>
        /// <param name="zoom">Zoom level. Must be between 2 and 23</param>
        /// <param name="viewType">Map view type.</param>
        public static void PerformSearch(string query, Location searchLocation, int zoom = DefaultMapZoomLevel,
                                         MapViewType viewType = MapViewType.Standard)
        {
            if (IGUtils.IsIosCheck())
            {
                return;
            }

            Check.Argument.IsStrNotNullOrEmpty(query, "query");

            if (zoom < MinMapZoomLevel || zoom > MaxMapZoomLevel)
            {
                throw new ArgumentOutOfRangeException("zoom", "Zoom level must be between 2 and 23");
            }

            var url = FormatMapsUrl("q={0}&sll={1}&z={2}&t={3}",
                                    UnityWebRequest.EscapeURL(query), searchLocation.ToLinkStr(), zoom, _mapViews[viewType]);

            IGUtils._openUrl(url);
        }
Пример #13
0
        private void setBlocks(bool needRebuildBlocks)
        {
            //if using pictures
            if (ConfigScript.usePicturesInstedBlocks)
            {
                if (needRebuildBlocks)
                {
                    //get block size from image
                    layers[0].blockWidth  = ConfigScript.getBlocksPicturesWidth();
                    layers[0].blockHeight = 32;
                    layers[1].blockWidth  = ConfigScript.getBlocksPicturesWidth();
                    layers[1].blockHeight = 32;
                    bigBlocks             = UtilsGDI.setBlocksForPictures(curButtonScale, layers[0].blockWidth, layers[0].blockHeight, curViewType);
                }
                updateBlocksImages();
                return;
            }

            MapViewType smallObjectsType =
                curViewType == MapViewType.SmallObjNumbers ? MapViewType.ObjNumbers :
                curViewType == MapViewType.ObjType ? MapViewType.ObjType : MapViewType.Tiles;

            float smallBlockScaleFactor = curButtonScale;
            int   bigTileIndex          = curActiveBlockNo;

            if (needRebuildBlocks)
            {
                if (ConfigScript.isUseSegaGraphics())
                {
                    bigBlocks = makeSegaBigBlocks();
                }
                else
                {
                    bigBlocks = ConfigScript.videoNes.makeBigBlocks(curActiveVideoNo, curActiveBigBlockNo, bigTileIndex, curActivePalleteNo, smallObjectsType, curViewType, ConfigScript.getbigBlocksHierarchyCount() - 1);
                }
                changeBlocksSize(bigBlocks);
            }
            curActiveBlock = 0;
            updateBlocksImages();
        }
Пример #14
0
        private void setBlocks(bool needRebuildBlocks)
        {
            //if using pictures
            if (ConfigScript.usePicturesInstedBlocks)
            {
                if (needRebuildBlocks)
                {
                    //get block size from image
                    int w = ConfigScript.getBlocksPicturesWidth();
                    int h = 32;
                    bigBlocks = UtilsGDI.setBlocksForPictures(curScale, w, h, curActiveViewType);
                }
            }
            else
            {
                MapViewType smallObjectsType =
                    curActiveViewType == MapViewType.SmallObjNumbers ? MapViewType.ObjNumbers :
                    curActiveViewType == MapViewType.ObjType ? MapViewType.ObjType : MapViewType.Tiles;

                if (needRebuildBlocks)
                {
                    if (ConfigScript.isUseSegaGraphics())
                    {
                        bigBlocks = Globals.makeSegaBigBlocks(curActiveVideoNo, curActiveBigBlockNo, curActivePalleteNo, curActiveViewType);
                    }
                    else if (ConfigScript.isUseGbGraphics())
                    {
                        bigBlocks = Globals.makeGbBigBlocks(curActiveVideoNo, curActiveBigBlockNo, curActivePalleteNo, curActiveViewType);
                    }
                    else
                    {
                        bigBlocks = ConfigScript.videoNes.makeBigBlocks(curActiveVideoNo, curActiveBigBlockNo, curActiveBlockNo, curActivePalleteNo, smallObjectsType, curActiveViewType, ConfigScript.getbigBlocksHierarchyCount() - 1);
                    }
                }
            }

            curActiveBlock = 0;
            updateBlocksImages();
        }
Пример #15
0
        public Image[] makeBigBlocks(byte[] ppuData, byte[] tileData, byte[] pallette, int count,
                                     MapViewType curViewType = MapViewType.Tiles)
        {
            var result = new Image[count];

            Color[] pal = getPalette(pallette);

            var tiles = new Image[256];

            for (int i = 0; i < tiles.Length; i++)
            {
                tiles[i] = getTile(ppuData, pal, i);
            }

            /*var im = getTilesRectangle(ppuData, pal);
             * im.Save("chr.png");*/

            for (int i = 0; i < count; i++)
            {
                //linear 2x2 tiles only for now
                int startIndex = i * 4;
                var tileImages = new[]
                {
                    tiles[tileData[startIndex]],
                    tiles[tileData[startIndex + 1]],
                    tiles[tileData[startIndex + 2]],
                    tiles[tileData[startIndex + 3]],
                };
                var block = UtilsGDI.GlueImages(tileImages, 2, 2);
                result[i] = block;

                if (curViewType == MapViewType.ObjNumbers)
                {
                    result[i] = VideoHelper.addObjNumber(result[i], i);
                }
            }
            return(result);
        }
Пример #16
0
        /// <summary>
        ///     Opens apple maps maps application with direction to destination
        /// </summary>
        /// <param name="destinationAddress">Destination address.</param>
        /// <param name="sourceAddress">Source address.</param>
        /// <param name="transportType">Transport type.</param>
        /// <param name="viewType">Map view type.</param>
        public static void GetDirections(string destinationAddress, string sourceAddress = null,
                                         TransportType transportType = TransportType.ByCar,
                                         MapViewType viewType        = MapViewType.Standard)
        {
            if (IGUtils.IsIosCheck())
            {
                return;
            }

            if (string.IsNullOrEmpty(destinationAddress))
            {
                throw new ArgumentException("Destination address must not be null or empty", "destinationAddress");
            }

            var url = FormatMapsUrl("daddr={0}&dirflg={1}&t={2}",
                                    UnityWebRequest.EscapeURL(destinationAddress), _transportTypes[transportType], viewType);

            if (!string.IsNullOrEmpty(sourceAddress))
            {
                url = url + "&saddr=" + UnityWebRequest.EscapeURL(sourceAddress);
            }
            Debug.Log("XXX: " + url);
            IGUtils._openUrl(url);
        }
Пример #17
0
 /// <summary>
 /// Deserializes xml markup from file into an MapViewType object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output MapViewType object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out MapViewType obj, out System.Exception exception) {
     exception = null;
     obj = default(MapViewType);
     try {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
Пример #18
0
 //TODO: write universal "RectangulateStripImage function"
 //using makeObjectsStrip for now. Return rectangle small blocks objects
 public Bitmap makeObjectsRectangle(byte videoPageId, byte tilesId, byte palId, float scale, MapViewType drawType, int constantSubpal = -1)
 {
     Bitmap imageStrip = ConfigScript.videoNes.makeObjectsStrip(videoPageId, tilesId, palId, scale, drawType, constantSubpal);
     //print only first 256 blocks
     int BLOCKS_IN_ROW = 16;
     int BLOCKS_IN_COL = 16;
     Bitmap resultVideo = new Bitmap((int)(16*scale*BLOCKS_IN_ROW), (int)(16*scale*BLOCKS_IN_COL));
     using (Graphics g = Graphics.FromImage(resultVideo))
     {
         for (int i = 0; i < 256; i++)
         {
             int size = (int)(16 * scale);
             g.DrawImage(imageStrip, new Rectangle(i%16 * size, (i/16) *size, size, size), new Rectangle(i * size, 0, size, size) , GraphicsUnit.Pixel);
         }
     }
     return resultVideo;
 }
Пример #19
0
        public Image[] makeBigBlocks(int videoNo, int bigBlockNo, BigBlock[] bigBlockIndexes, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
            float smallBlockScaleFactor = 2.0f, float curButtonScale = 2, MapViewType curViewType = MapViewType.Tiles, bool showAxis = false)
        {
            int blockCount = ConfigScript.getBigBlocksCount();
            var bigBlocks = new Image[blockCount];

            byte blockId = (byte)bigBlockNo;
            byte backId = (byte)videoNo;
            byte palId = (byte)palleteNo;

            var im = makeObjectsStrip(backId, blockId, palId, smallBlockScaleFactor, smallObjectsViewType);
            var smallBlocks = new System.Windows.Forms.ImageList();
            smallBlocks.ImageSize = new Size((int)(16 * smallBlockScaleFactor), (int)(16 * smallBlockScaleFactor));
            smallBlocks.Images.AddStrip(im);
            Image[] smallBlocksPack = smallBlocks.Images.Cast<Image>().ToArray();

            //tt version hardcode
            Image[][] smallBlocksAll = null;
            if (GameType.TT == Globals.getGameType())
            {
                smallBlocksAll = new Image[4][];
                for (int i = 0; i < 4; i++)
                {
                    var il = new ImageList();
                    il.ImageSize = new System.Drawing.Size((int)(16 * smallBlockScaleFactor), (int)(16 * smallBlockScaleFactor));
                    il.Images.AddStrip(makeObjectsStrip((byte)backId, (byte)blockId, (byte)palId, smallBlockScaleFactor, smallObjectsViewType, i));
                    smallBlocksAll[i] = il.Images.Cast<Image>().ToArray();
                }
            }
            else
            {
                smallBlocksAll = new Image[1][];
                smallBlocksAll[0] = smallBlocksPack;
            }

            for (int btileId = 0; btileId < blockCount; btileId++)
            {
                Image b;
                if (ConfigScript.isBuildScreenFromSmallBlocks())
                {
                    var sb = smallBlocks.Images[btileId];
                    b = Utils.ResizeBitmap(sb, (int)(sb.Width * curButtonScale), (int)(sb.Height * curButtonScale));
                }
                else
                {
                    b = makeBigBlock(btileId, bigBlockIndexes, smallBlocksAll);
                }
                if (curViewType == MapViewType.ObjNumbers)
                    b = VideoHelper.addObjNumber(b, btileId);
                if (showAxis)
                    b = VideoHelper.addAxisRectangle(b);
                bigBlocks[btileId] = b;
            }
            return bigBlocks;
        }
Пример #20
0
        private void cbLevelPair_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (
                cbTileset.SelectedIndex == -1 ||
                cbVideoNo.SelectedIndex == -1 || 
                cbPaletteNo.SelectedIndex == -1 ||
                cbPart.SelectedIndex == -1 ||
                cbViewType.SelectedIndex == -1 || 
                cbSmallBlock.SelectedIndex == -1
                )
            {
                return;
            }
            if (!readOnly && dirty && sender == cbTileset)
            {
                DialogResult dr = MessageBox.Show("Tiles was changed. Do you want to save current tileset?", "Save", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Cancel)
                {
                    returnCbLevelIndexes();
                    return;
                }
                else if (dr == DialogResult.Yes)
                {
                    if (!saveToFile())
                    {
                        returnCbLevelIndexes();
                        return;
                    }
                }
                else
                {
                    dirty = false;
                    updateSaveVisibility();
                }
            }

            //generic version
            curTileset = cbTileset.SelectedIndex;
            curSmallBlockNo = cbSmallBlock.SelectedIndex;
            curViewType = (MapViewType)cbViewType.SelectedIndex;

            curVideo = cbVideoNo.SelectedIndex + 0x90;
            curPallete = cbPaletteNo.SelectedIndex;
            curPart = cbPart.SelectedIndex;
            Utils.setCbItemsCount(cbPart, Math.Max(ConfigScript.getBigBlocksCount() / 256, 1));
            Utils.setCbIndexWithoutUpdateLevel(cbPart, cbLevelPair_SelectedIndexChanged, curPart);
            reloadLevel();
        }
Пример #21
0
        public static void setBlocks(ImageList bigBlocks, float curButtonScale = 2, int blockWidth = 32, int blockHeight = 32, MapViewType curDrawType = MapViewType.Tiles, bool showAxis = true)
        {
            MapViewType curViewType = curDrawType;

            bigBlocks.Images.Clear();
            //smallBlocks.Images.Clear();
            bigBlocks.ImageSize = new Size((int)(curButtonScale * blockWidth), (int)(curButtonScale * blockHeight));

            //if using pictures
            if (ConfigScript.usePicturesInstedBlocks)
            {
                if (ConfigScript.blocksPicturesFilename != "")
                {
                    var imSrc = Image.FromFile(ConfigScript.blocksPicturesFilename);
                    int imBlockWidth = blockWidth * 2; //default scale
                    int imBlockHeight = blockHeight * 2;
                    int imCountX = imSrc.Width / imBlockWidth;
                    int imCountY = imSrc.Height / imBlockHeight;
                    for (int y = 0; y < imCountY; y++)
                    {
                        for (int x = 0; x < imCountX; x++)
                        {
                            var imBlock = CropImage(imSrc, new Rectangle(x * imBlockWidth, y * imBlockHeight, imBlockWidth, imBlockHeight));
                            var imResized = ResizeBitmap(imBlock, (int)(curButtonScale * blockWidth), (int)(curButtonScale * blockHeight));
                            bigBlocks.Images.Add(imResized);
                        }
                    }

                }
                for (int i = bigBlocks.Images.Count; i < 256; i++)
                    bigBlocks.Images.Add(VideoHelper.emptyScreen((int)(blockWidth * curButtonScale), (int)(blockHeight * curButtonScale)));
                if (showAxis)
                {
                    for (int i = 0; i < 256; i++)
                    {
                        var im1 = bigBlocks.Images[i];
                        using (var g = Graphics.FromImage(im1))
                            g.DrawRectangle(new Pen(Color.FromArgb(255, 255, 255, 255)), new Rectangle(0, 0, (int)(blockWidth * curButtonScale), (int)(blockHeight * curButtonScale)));
                        bigBlocks.Images[i] = im1;
                    }
                }

                if (curViewType == MapViewType.ObjNumbers)
                {
                    int _bbRectPosX = (int)((blockWidth / 2) * curButtonScale);
                    int _bbRectSizeX = (int)((blockWidth / 2) * curButtonScale);
                    int _bbRectPosY = (int)((blockHeight / 2) * curButtonScale);
                    int _bbRectSizeY = (int)((blockHeight / 2) * curButtonScale);
                    for (int i = 0; i < 256; i++)
                    {
                        var im1 = bigBlocks.Images[i];
                        using (var g = Graphics.FromImage(im1))
                        {
                            g.FillRectangle(new SolidBrush(Color.FromArgb(192, 255, 255, 255)), new Rectangle(0, 0, _bbRectSizeX * 2, _bbRectSizeY * 2));
                            g.DrawString(String.Format("{0:X}", i), new Font("Arial", 16), Brushes.Red, new Point(0, 0));
                        }
                        bigBlocks.Images[i] = im1;
                    }

                }
            }
        }
Пример #22
0
        public Bitmap makeObjectsStrip(int videoPageId, int tilesId, int palId, MapViewType drawType, int constantSubpal = -1)
        {
            var bitmaps = makeObjects(videoPageId, tilesId, palId, drawType, constantSubpal);

            return(UtilsGDI.GlueImages(bitmaps, bitmaps.Length, 1));
        }
Пример #23
0
 /// <summary>
 /// Constructs a minimap view with a specified view type.
 ///
 ///     <remarks>The view type will determine how the minimap will look.</remarks>
 /// </summary>
 /// <param name="viewType">The type of view to compose.</param>
 public MinimapViewPacketComposer(MapViewType viewType)
 {
     SetOpcode(226);
     AppendByte((byte)viewType);
 }
Пример #24
0
 public Image[] makeBigBlocks(byte[] mapping, byte[] tiles, byte[] palette, int count, float zoom, MapViewType curViewType = MapViewType.Tiles, bool showAxis = false)
 {
     var result = new Image[count];
     ushort[] m = Mapper.LoadMapping(mapping);
     Color[] cpal = GetPalette(palette);
     for (ushort i = 0; i < count; i++)
     {
         if (!ConfigScript.isBlockSize4x4())
             result[i] = GetZoomBlock(m, tiles, cpal, i, zoom * 2.0f);
         else
             result[i] = GetZoomBlock4x4(m, tiles, cpal, i, zoom);
         if (curViewType == MapViewType.ObjNumbers)
             result[i] = VideoHelper.addObjNumber(result[i], i);
         if (showAxis)
             result[i] = VideoHelper.addAxisRectangle(result[i]);
     }
     return result;
 }
Пример #25
0
        private void BigBlockEdit_Load(object sender, EventArgs e)
        {
            curTileset = 0;
            curVideo = 0x90;
            curPallete = 0;
            curPart = 0;
            dirty = false;
            updateSaveVisibility();
            curViewType = MapViewType.Tiles;

            initControls();

            blocksPanel.Controls.Clear();
            blocksPanel.SuspendLayout();
            for (int i = 0; i < SMALL_BLOCKS_COUNT; i++)
            {
                var but = new Button();
                but.Size = new Size(32, 32);
                but.ImageList = smallBlocks;
                but.ImageIndex = i;
                but.Margin = new Padding(0);
                but.Padding = new Padding(0);
                but.Click += new EventHandler(buttonObjClick);
                blocksPanel.Controls.Add(but);
            }
            blocksPanel.ResumeLayout();
            prepareAxisLabels();
            reloadLevel();

            readOnly = false; //must be read from config
            tbbSave.Enabled = !readOnly;
            tbbImport.Enabled = !readOnly;
        }
Пример #26
0
        public Image[] makeBigBlocks(byte[] mapping, byte[] tiles, byte[] palette, int count, MapViewType curViewType = MapViewType.Tiles)
        {
            var result = new Image[count];

            ushort[] m    = Mapper.loadMapping(mapping);
            Color[]  cpal = getPalette(palette);
            for (ushort i = 0; i < count; i++)
            {
                if (!ConfigScript.isBlockSize4x4())
                {
                    var b = getBlock(m, tiles, cpal, i);
                    result[i] = UtilsGDI.ResizeBitmap(b, 32, 32);
                }
                else
                {
                    var b = getBlock4X4(m, tiles, cpal, i);
                    result[i] = UtilsGDI.ResizeBitmap(b, 32, 32);
                }
                if (curViewType == MapViewType.ObjNumbers)
                {
                    result[i] = VideoHelper.addObjNumber(result[i], i);
                }
            }
            return(result);
        }
Пример #27
0
 public AppleMapOptions MapType(MapViewType mapViewType)
 {
     _mapViewType = mapViewType;
     return(this);
 }
Пример #28
0
 public static bool Deserialize(string xml, out MapViewType obj) {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
Пример #29
0
 /// <summary>
 /// Deserializes workflow markup into an MapViewType object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output MapViewType object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out MapViewType obj, out System.Exception exception) {
     exception = null;
     obj = default(MapViewType);
     try {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex) {
         exception = ex;
         return false;
     }
 }
Пример #30
0
        public Bitmap makeObjectsStrip(byte videoPageId, byte tilesId, byte palId, float scale, MapViewType drawType, int constantSubpal = -1)
        {
            byte[] videoChunk = ConfigScript.getVideoChunk(videoPageId);

            int blocksCount = ConfigScript.getBlocksCount();
            ObjRec[] objects = ConfigScript.getBlocks(tilesId);

            byte[] palette = ConfigScript.getPal(palId);
            var objStrip1 = makeImageStrip(videoChunk, palette, 0, scale);
            var objStrip2 = makeImageStrip(videoChunk, palette, 1, scale);
            var objStrip3 = makeImageStrip(videoChunk, palette, 2, scale);
            var objStrip4 = makeImageStrip(videoChunk, palette, 3, scale);
            var objStrips = new[] { objStrip1, objStrip2, objStrip3, objStrip4 };
            Bitmap res = new Bitmap((int)(16 * blocksCount * scale), (int)(16 * scale));
            using (Graphics g = Graphics.FromImage(res))
            {
                for (int i = 0; i < blocksCount; i++)
                {
                    var mblock = new Bitmap((int)(16 * scale), (int)(16 * scale));
                    var co = objects[i];
                    Bitmap curStrip;
                    if (constantSubpal == -1)
                    {
                        if (Globals.getGameType() == GameType.DT2)
                        {
                            var objectForColor = objects[i / 4];
                            curStrip = objStrips[objectForColor.getSubpalleteForDt2(i % 4)];
                        }
                        else
                        {
                            curStrip = objStrips[co.getSubpallete()];
                        }
                    }
                    else
                    {
                        curStrip = objStrips[constantSubpal];
                    }

                    int scaleInt8 = (int)(scale * 8);
                    int scaleInt16 = (int)(scale * 16);
                    using (Graphics g2 = Graphics.FromImage(mblock))
                    {
                        g2.DrawImage(curStrip, new Rectangle(0, 0, scaleInt8, scaleInt8), new Rectangle(co.c1 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                        g2.DrawImage(curStrip, new Rectangle(scaleInt8, 0, scaleInt8, scaleInt8), new Rectangle(co.c2 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                        g2.DrawImage(curStrip, new Rectangle(0, scaleInt8, scaleInt8, scaleInt8), new Rectangle(co.c3 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                        g2.DrawImage(curStrip, new Rectangle(scaleInt8, scaleInt8, scaleInt8, scaleInt8), new Rectangle(co.c4 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                        if (drawType == MapViewType.ObjType)
                        {
                            if (Globals.getGameType() == GameType.DT2)
                            {
                                g2.FillRectangle(new SolidBrush(CadObjectTypeColors[co.getTypeForDt2(i)]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                                g2.DrawString(String.Format("{0:X}", co.getTypeForDt2(i)), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                            }
                            else
                            {
                                g2.FillRectangle(new SolidBrush(CadObjectTypeColors[co.getType()]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                                g2.DrawString(String.Format("{0:X}", co.getType()), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                            }
                        }
                        else if (drawType == MapViewType.ObjNumbers)
                        {
                            g2.FillRectangle(new SolidBrush(Color.FromArgb(192, 255, 255, 255)), new Rectangle(0, 0, scaleInt16, scaleInt16));
                            g2.DrawString(String.Format("{0:X}", i), new Font("Arial", 6), Brushes.Red, new Point(0, 0));
                        }
                    }
                    g.DrawImage(mblock, new Rectangle(i * scaleInt16, 0, scaleInt16, scaleInt16));
                }
            }
            return res;
        }
Пример #31
0
 public Image[] makeBigBlocks(int videoNo, int bigBlockNo, int blockNo, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
                              MapViewType curViewType = MapViewType.Tiles, int hierarchyLevel = 0)
 {
     BigBlock[] bigBlockIndexes = ConfigScript.getBigBlocksRecursive(hierarchyLevel, blockNo);
     return(makeBigBlocks(videoNo, bigBlockNo, bigBlockIndexes, palleteNo, smallObjectsViewType, curViewType, hierarchyLevel));
 }
Пример #32
0
        public static Image[] makeSegaBigBlocks(int curActiveVideoNo, int curActiveBigBlockNo, int curActivePalleteNo, MapViewType curViewType)
        {
            byte[] mapping    = ConfigScript.getSegaMapping(curActiveBigBlockNo);
            byte[] videoTiles = ConfigScript.getVideoChunk(curActiveVideoNo);
            byte[] pal        = ConfigScript.getPal(curActivePalleteNo);
            int    count      = ConfigScript.getBigBlocksCount(ConfigScript.getbigBlocksHierarchyCount() - 1, curActiveBigBlockNo);

            return(ConfigScript.videoSega.makeBigBlocks(mapping, videoTiles, pal, count, curViewType));
        }
Пример #33
0
        public static Image[] makeGbBigBlocks(int curActiveVideoNo, int curActiveBigBlockNo, int curActivePalleteNo, MapViewType curViewType)
        {
            byte[]   videoTiles = ConfigScript.getVideoChunk(curActiveVideoNo);
            ObjRec[] blocks     = ConfigScript.getBlocksFunc(curActiveBigBlockNo);
            var      blocksData = new byte[blocks.Length * 4]; //hardcode small blocks sizes

            Utils.writeBlocksLinear(blocks, blocksData, 0, 256, false, false);
            byte[] pal   = ConfigScript.getPal(curActivePalleteNo);
            int    count = ConfigScript.getBigBlocksCount(ConfigScript.getbigBlocksHierarchyCount() - 1, curActiveBigBlockNo);

            return(ConfigScript.videoGb.makeBigBlocks(videoTiles, blocksData, pal, count, curViewType));
        }
Пример #34
0
        public Image[] makeBigBlocks(int videoNo, int levelNo, int bigBlockNo, int blockNo, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
            float smallBlockScaleFactor = 2.0f, int blockWidth = 32, int blockHeight = 32, float curButtonScale = 2, MapViewType curViewType = MapViewType.Tiles, bool showAxis = false)
        {
            int blockCount = ConfigScript.getBigBlocksCount();
            int SCREEN_SIZE = ConfigScript.getScreenWidth(levelNo) * ConfigScript.getScreenHeight(levelNo);
            var bigBlocks = new Image[blockCount];

            byte blockId = (byte)bigBlockNo;
            byte blockIndexId = (byte)blockNo;
            byte backId = (byte)videoNo;
            byte palId = (byte)palleteNo;
            byte[] bigBlockIndexes = ConfigScript.getBigBlocks(blockIndexId);

            var im = makeObjectsStrip(backId, blockId, palId, smallBlockScaleFactor, smallObjectsViewType);
            var smallBlocks = new System.Windows.Forms.ImageList();
            smallBlocks.ImageSize = new Size((int)(16 * smallBlockScaleFactor), (int)(16 * smallBlockScaleFactor));
            smallBlocks.Images.AddStrip(im);

            //tt version hardcode
            ImageList[] smallBlocksAll = null;
            byte[] smallBlocksColorBytes = null;
            if (GameType.TT == Globals.getGameType())
            {
                smallBlocksAll = new ImageList[4];
                for (int i = 0; i < 4; i++)
                {
                    smallBlocksAll[i] = new ImageList();
                    smallBlocksAll[i].ImageSize = new System.Drawing.Size((int)(16 * smallBlockScaleFactor), (int)(16 * smallBlockScaleFactor));
                    smallBlocksAll[i].Images.AddStrip(makeObjectsStrip((byte)backId, (byte)blockId, (byte)palId, smallBlockScaleFactor, smallObjectsViewType, i));
                }
                smallBlocksColorBytes = getTTSmallBlocksColorBytes(blockId);
            }

            for (int btileId = 0; btileId < blockCount; btileId++)
            {
                Image b;
                if (ConfigScript.isBuildScreenFromSmallBlocks())
                {
                    b = Utils.ResizeBitmap(smallBlocks.Images[btileId], (int)(blockWidth * curButtonScale), (int)(blockHeight * curButtonScale));
                }
                else
                {
                    switch (Globals.getGameType())
                    {
                        case GameType.TT:
                            b = makeBigBlockTT(btileId, (int)(blockWidth * curButtonScale), (int)(blockHeight * curButtonScale), bigBlockIndexes, smallBlocksAll, smallBlocksColorBytes);
                            break;
                        case GameType._3E:
                            b = makeBigBlock3E(btileId, (int)(blockWidth * curButtonScale), (int)(blockHeight * curButtonScale), bigBlockIndexes, smallBlocks);
                            break;
                        default:
                            b = makeBigBlock(btileId, (int)(blockWidth * curButtonScale), (int)(blockHeight * curButtonScale), bigBlockIndexes, smallBlocks);
                            break;
                    }
                }
                if (curViewType == MapViewType.ObjNumbers)
                    b = VideoHelper.addObjNumber(b, btileId);
                if (showAxis)
                    b = VideoHelper.addAxisRectangle(b);
                bigBlocks[btileId] = b;
            }
            return bigBlocks;
        }
Пример #35
0
 public Image[] makeBigBlocks(int videoNo, int bigBlockNo, int blockNo, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
     float smallBlockScaleFactor = 2.0f, float curButtonScale = 2, MapViewType curViewType = MapViewType.Tiles, bool showAxis = false)
 {
     byte blockIndexId = (byte)blockNo;
     BigBlock[] bigBlockIndexes = ConfigScript.getBigBlocks(blockIndexId);
     return makeBigBlocks(videoNo, bigBlockNo, bigBlockIndexes, palleteNo, smallObjectsViewType, smallBlockScaleFactor, curButtonScale, curViewType, showAxis);
 }
Пример #36
0
 public static bool LoadFromFile(string fileName, out MapViewType obj) {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
Пример #37
0
        public Bitmap makeObject(int index, ObjRec[] objects, Bitmap[] objStrips, float scale, MapViewType drawType, int constantSubpal = -1)
        {
            int i = index;
            var mblock = new Bitmap((int)(16 * scale), (int)(16 * scale));
            var co = objects[i];
            Bitmap curStrip;
            if (constantSubpal == -1)
            {
                if (Globals.getGameType() == GameType.DT2)
                {
                    var objectForColor = objects[i / 4];
                    curStrip = objStrips[objectForColor.getSubpalleteForDt2(i % 4)];
                }
                else
                {
                    curStrip = objStrips[co.getSubpallete()];
                }
            }
            else
            {
                curStrip = objStrips[constantSubpal];
            }

            int scaleInt8 = (int)(scale * 8);
            int scaleInt16 = (int)(scale * 16);
            using (Graphics g2 = Graphics.FromImage(mblock))
            {
                g2.DrawImage(curStrip, new Rectangle(0, 0, scaleInt8, scaleInt8), new Rectangle(co.c1 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                g2.DrawImage(curStrip, new Rectangle(scaleInt8, 0, scaleInt8, scaleInt8), new Rectangle(co.c2 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                g2.DrawImage(curStrip, new Rectangle(0, scaleInt8, scaleInt8, scaleInt8), new Rectangle(co.c3 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                g2.DrawImage(curStrip, new Rectangle(scaleInt8, scaleInt8, scaleInt8, scaleInt8), new Rectangle(co.c4 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                if (drawType == MapViewType.ObjType)
                {
                    if (Globals.getGameType() == GameType.DT2)
                    {
                        g2.FillRectangle(new SolidBrush(CadObjectTypeColors[co.getTypeForDt2(i)]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                        g2.DrawString(String.Format("{0:X}", co.getTypeForDt2(i)), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                    }
                    else
                    {
                        g2.FillRectangle(new SolidBrush(CadObjectTypeColors[co.getType()]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                        g2.DrawString(String.Format("{0:X}", co.getType()), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                    }
                }
                else if (drawType == MapViewType.ObjNumbers)
                {
                    g2.FillRectangle(new SolidBrush(Color.FromArgb(192, 255, 255, 255)), new Rectangle(0, 0, scaleInt16, scaleInt16));
                    g2.DrawString(String.Format("{0:X}", i), new Font("Arial", 6), Brushes.Red, new Point(0, 0));
                }
            }
            return mblock;
        }
Пример #38
0
 private void changeLevelIndex(bool reloadObjectsPanel = false)
 {
     curActiveVideoNo = cbVideoNo.SelectedIndex + 0x90;
     curActiveBigBlockNo = cbBigBlockNo.SelectedIndex;
     curActiveBlockNo = cbBlockNo.SelectedIndex;
     curActivePalleteNo = cbPaletteNo.SelectedIndex;
     curViewType = (MapViewType)cbViewType.SelectedIndex;
     reloadLevel(true, reloadObjectsPanel);
 }
Пример #39
0
        public Bitmap makeObjectsStrip(byte videoPageId, byte tilesId, byte palId, float scale, MapViewType drawType, int constantSubpal = -1)
        {
            byte[] videoChunk = ConfigScript.getVideoChunk(videoPageId);
            int blocksCount = ConfigScript.getBlocksCount();
            ObjRec[] objects = ConfigScript.getBlocks(tilesId);

            byte[] palette = ConfigScript.getPal(palId);
            var objStrip1 = makeImageStrip(videoChunk, palette, 0, scale);
            var objStrip2 = makeImageStrip(videoChunk, palette, 1, scale);
            var objStrip3 = makeImageStrip(videoChunk, palette, 2, scale);
            var objStrip4 = makeImageStrip(videoChunk, palette, 3, scale);
            var objStrips = new[] { objStrip1, objStrip2, objStrip3, objStrip4 };
            Bitmap res = new Bitmap((int)(16 * blocksCount * scale), (int)(16 * scale));
            using (Graphics g = Graphics.FromImage(res))
            {
                for (int i = 0; i < blocksCount; i++)
                {
                    var mblock = makeObject(i, objects, objStrips, scale, drawType, constantSubpal);
                    int scaleInt16 = (int)(scale * 16);
                    g.DrawImage(mblock, new Rectangle(i * scaleInt16, 0, scaleInt16, scaleInt16));
                }
            }
            return res;
        }
Пример #40
0
        private void BigBlockEdit_Load(object sender, EventArgs e)
        {
            curHierarchyLevel = 0;
            curTileset = 0;
            curVideo = 0x90;
            curPallete = 0;
            curPart = 0;
            dirty = false;
            updateSaveVisibility();
            curViewType = MapViewType.Tiles;

            initControls();
            reloadLevel();
            reloadBlocksPanel();

            readOnly = false; //must be read from config
            tbbSave.Enabled = !readOnly;
            tbbImport.Enabled = !readOnly;
        }