Beispiel #1
0
        private void DrawScreen(int gameX, int gameY, int mapx, int mapY)
        {
            // Get currentLevelIndex and screen
            LevelIndex level        = levelMap.GetLevel(gameX, gameY);
            bool       invalidLevel = false;

            if (level == LevelIndex.None ||
                (levelFilter != LevelIndex.None && level != levelFilter))
            {
                return;
                ////if(!fillEmptySpots) return;

                ////if(levelFilter != LevelIndex.None)
                ////    level = levelFilter;
                ////else
                ////    level = GuessLevel(gameX, gameY);

                ////if(level == LevelIndex.Tourian)
                ////    level = LevelIndex.Kraid;

                ////invalidLevel = true;
            }

            Level levelData   = rom.GetLevel(level);
            int   screenIndex = rom.GetScreenIndex(gameX, gameY);

            if (screenIndex == 0xFF || invalidLevel)  // Blank screen
            {
                screenIndex = GetBlankScreenIndex(level);
            }



            Screen screen = levelData.Screens[screenIndex];

            // Load data into renderer
            renderer.Level         = levelData;
            renderer.SelectedEnemy = -1;

            // Apply paletteIndex
            //screen.ApplyLevelPalette(screenBitmap); // Sprites
            //renderer.ApplyPalette(screenBitmap, levelMap.GetAltPal(gameX, gameY)); // Backgrounds
            ScreenEditor.ApplyPalette(levelMap.GetAltPal(gameX, gameY), levelData, screenBitmap, HighlightEffect.Invert);

            // Render Screen
            renderer.DefaultPalette = screen.ColorAttributeTable;
            renderer.Clear();
            renderer.SelectedDoor = -1;
            renderer.DrawScreen(screenIndex);
            IList <EnemyInstance> enemies = hideEnemies ? null : screen.Enemies;

            renderer.Render(b, screenBitmap, enemies, screen.Doors, showPhysics);

            Rectangle source = new Rectangle(0, 0, ScreenWidth, ScreenHeight);
            Rectangle dest   = new Rectangle(
                mapx * ScreenWidth / scale, mapY * ScreenHeight / scale,
                ScreenWidth / scale, ScreenHeight / scale);

            gMap.DrawImage(screenBitmap, dest, source, GraphicsUnit.Pixel);
        }
        private void LoadItems(LevelIndex level)
        {
            TreeNode node = GetNode(level);
            Level    l    = rom.GetLevel(level);

            ////foreach (ItemRowEntry row in l.ItemTable_DEPRECATED) {
            ////    foreach (ScreenItems screen in row) {
            foreach (ItemScreenData screen in l.Items)
            {
                foreach (ItemData item in screen.Items)
                {
                    if (item.ItemType == ItemTypeIndex.PowerUp)
                    {
                        int x            = screen.MapX;
                        int y            = screen.MapY;
                        var powerUp      = ((ItemPowerupData)item).PowerUp;
                        int powerupIndex = (int)powerUp;

                        TreeNode n = new TreeNode("(" + x.ToString("x") + ", " + y.ToString("x") + ") " + powerUp.ToString().Replace('_', ' '), powerupIndex, powerupIndex);
                        n.Tag = new datTag(new Point(x, y), powerupIndex, level);
                        if (powerUp == PowerUpType.IceBeam ||
                            powerUp == PowerUpType.WaveBeam ||
                            powerUp == PowerUpType.LongBeam)
                        {
                            OmittedNode.Nodes.Add(n);
                        }
                        else
                        {
                            node.Nodes.Add(n);
                            checkedItemCount++;
                        }
                    }
                }
            }
            ////    }
            ////}
        }
Beispiel #3
0
        void OnLayoutRendered(object sender, EventArgs e)
        {
            if (!useScreenImages)
            {
                return;
            }

            Rectangle src = new Rectangle(0, 0, 256, 240);

            LayoutIndex index = renderer.RenderedLayout;

            for (int x = 0; x < 32; x++)
            {
                for (int y = 0; y < 32; y++)
                {
                    if (GetLevel(x, y) == index.Level && rom.GetScreenIndex(x, y) == index.ScreenIndex && GetAltPal(x, y) == index.AltPalette)
                    {
                        Rectangle dest = new Rectangle(x * mapTileWidth, y * mapTileHeight, mapTileWidth, mapTileHeight);
                        _gMapImage.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
                        _gMapImage.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.Half;

                        _gMapImage.DrawImage(renderer.RenderedImage, dest, src, GraphicsUnit.Pixel);
                        if (PerformingInitialRender)
                        {
                            if ((index.ScreenIndex % 5) == 0 || index.ScreenIndex == rom.GetLevel(index.Level).Screens.Count - 1)
                            {
                                Invalidate();
                            }
                        }
                        else
                        {
                            Invalidate();
                        }
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>Loads a structure.</summary>
        public void LoadStruct()
        {
            loadedData.StructIndex = data.StructIndex;


            loadedStructure             = rom.GetLevel(loadedData.Level).GetStruct(StructIndex);
            addTileIndicator.StructData = loadedStructure;
            addTileIndicator.FreeSpace  = loadedLevel.FreeStructureMemory;
            lblFreeMem.Text             = "$" + addTileIndicator.FreeSpace.ToString("x") + " free bytes";

            var       comboData = loadedStructure.Data;
            Rectangle source    = new Rectangle(0, 0, 16, 16);
            Rectangle dest      = source;

            gCurrentStruct.Clear(Color.Transparent);

            for (int y = 0; y < Structure.StructureData.height; y++)
            {
                for (int x = 0; x < Structure.StructureData.width; x++)
                {
                    byte tile = comboData[x, y];
                    if (tile != Struct.EmptyTile)
                    {
                        source.X = 16 * (tile % 16);
                        source.Y = 16 * (tile / 16);
                        dest.X   = x * 16;
                        dest.Y   = y * 16;

                        //gCurrentStruct.DrawImage(combos[levelIndex], dest, source, GraphicsUnit.Pixel);
                        gCurrentStruct.DrawImage(comboEditor.BackgroundImage, dest, source, GraphicsUnit.Pixel);
                    }
                }
            }
            picStruct.Invalidate();
            addTileIndicator.Hide();
        }
Beispiel #5
0
        IList <LineDisplayItem> IRomDataParentObject.GetListItems()
        {
            List <LineDisplayItem> items = new List <LineDisplayItem>();

            items.Add(new LineDisplayItem("Background 1", rom.GetLevel(level).BgPalette.Offset, 4, rom.data));
            items.Add(new LineDisplayItem("Background 2", rom.GetLevel(level).BgPalette.Offset + 4, 4, rom.data));
            items.Add(new LineDisplayItem("Background 3", rom.GetLevel(level).BgPalette.Offset + 8, 4, rom.data));
            items.Add(new LineDisplayItem("Background 4", rom.GetLevel(level).BgPalette.Offset + 12, 4, rom.data));

            if (HasSecondaryPalette)
            {
                items.Add(new LineDisplayItem("Background Alt 1", rom.GetLevel(level).BgAltPalette.Offset, 4, rom.data));
                items.Add(new LineDisplayItem("Background Alt 2", rom.GetLevel(level).BgAltPalette.Offset + 4, 4, rom.data));
                items.Add(new LineDisplayItem("Background Alt 3", rom.GetLevel(level).BgAltPalette.Offset + 8, 4, rom.data));
                items.Add(new LineDisplayItem("Background Alt 4", rom.GetLevel(level).BgAltPalette.Offset + 12, 4, rom.data));
            }

            items.Add(new LineDisplayItem("Sprite 1", rom.GetLevel(level).SpritePalette.Offset, 4, rom.data));
            items.Add(new LineDisplayItem("Sprite 2", rom.GetLevel(level).SpritePalette.Offset + 4, 4, rom.data));
            items.Add(new LineDisplayItem("Sprite 3", rom.GetLevel(level).SpritePalette.Offset + 8, 4, rom.data));
            items.Add(new LineDisplayItem("Sprite 4", rom.GetLevel(level).SpritePalette.Offset + 12, 4, rom.data));

            return(items);
        }