Beispiel #1
0
        public void LoadPalette(PaletteHandler allpalettes)
        {
            int paletteid = mapdata.palette;

            if (paletteid >= 0xA3)
            {
                paletteid = 0xA3;
            }

            byte pal0 = 0;
            byte pal1 = allpalettes.palettesGroups[paletteid];     //aux1
            byte pal2 = allpalettes.palettesGroups[paletteid + 1]; //aux2
            byte pal3 = allpalettes.palettesGroups[paletteid + 2]; //animated

            Color[] aux1, aux2, main, animated, hud;
            Color   bgr = allpalettes.bgrcolor[0];

            if (pal1 != 255)
            {
                aux1 = allpalettes.auxPalettes[pal1];
            }
            else
            {
                aux1 = allpalettes.auxPalettes[0];
            }
            if (pal2 != 255)
            {
                aux2 = allpalettes.auxPalettes[pal2];
            }
            else
            {
                aux2 = allpalettes.auxPalettes[0];
            }
            if (pal3 == 255)
            {
                pal3 = 0;
            }
            if (pal3 >= (allpalettes.animatedPalettes.Length / 7))
            {
                pal3 = 0;
            }



            if (mapdata.index < 0x40)
            {
                //default LW Palette
                pal0 = 0;
                bgr  = allpalettes.bgrcolor[0];
                //hardcoded LW DM palettes if we are on one of those maps (might change it to read game code)
                if ((mapdata.index >= 0x03 && mapdata.index <= 0x07))
                {
                    pal0 = 2;
                }
                else if (mapdata.index >= 0x0B && mapdata.index <= 0x0E)
                {
                    pal0 = 2;
                }
            }
            else if (mapdata.index >= 0x40 && mapdata.index < 0x80)
            {
                bgr = allpalettes.bgrcolor[1];
                //default DW Palette
                pal0 = 1;
                //hardcoded DW DM palettes if we are on one of those maps (might change it to read game code)
                if (mapdata.index >= 0x43 && mapdata.index <= 0x47)
                {
                    pal0 = 3;
                }
                else if (mapdata.index >= 0x4B && mapdata.index <= 0x4E)
                {
                    pal0 = 3;
                }
            }
            else if (mapdata.index >= 132) //special area like Zora's domain, etc...
            {
                bgr  = allpalettes.bgrcolor[2];
                pal0 = 4;
            }


            if (pal0 != 255)
            {
                main = allpalettes.mainPalettes[pal0];
            }
            else
            {
                main = allpalettes.mainPalettes[0];
            }

            animated = new Color[7];

            for (int i = 0; i < 7; i++)
            {
                animated[i] = allpalettes.animatedPalettes[(pal3 * 7) + i];
            }

            hud = allpalettes.hudPalettes[0];

            SetColorsPalette(main, animated, aux1, aux2, hud, bgr);
        }
Beispiel #2
0
        public JsonData(string projectLoaded)
        {
            this.projectLoaded = projectLoaded;
            allPalettes        = new PaletteHandler(projectLoaded);

            blocksetGroups  = JsonConvert.DeserializeObject <byte[]>(File.ReadAllText(projectLoaded + "//Overworld//BlocksetGroups.json"));
            blocksetGroups2 = JsonConvert.DeserializeObject <byte[]>(File.ReadAllText(projectLoaded + "//Overworld//BlocksetGroups2.json"));
            palettesGroups  = JsonConvert.DeserializeObject <byte[]>(File.ReadAllText(projectLoaded + "//Overworld//PalettesGroups.json"));
            spritesetGroups = JsonConvert.DeserializeObject <byte[]>(File.ReadAllText(projectLoaded + "//Overworld//SpritesetGroups.json"));

            itemsOW = JsonConvert.DeserializeObject <RoomPotSave[]>(File.ReadAllText(projectLoaded + "//Overworld//Items//Items.json"));
            createItems();

            spritesOW[0] = JsonConvert.DeserializeObject <List <Room_Sprite> >(File.ReadAllText(projectLoaded + "//Overworld//Sprites//Beginning Sprites.json"));
            spritesOW[1] = JsonConvert.DeserializeObject <List <Room_Sprite> >(File.ReadAllText(projectLoaded + "//Overworld//Sprites//ZeldaRescued Sprites.json"));
            spritesOW[2] = JsonConvert.DeserializeObject <List <Room_Sprite> >(File.ReadAllText(projectLoaded + "//Overworld//Sprites//AgahnimDefeated Sprites.json"));
            createSprites(0);
            createSprites(1);
            createSprites(2);


            for (int i = 0; i < 128; i++)
            {
                mapdata[i] = JsonConvert.DeserializeObject <MapSave>(File.ReadAllText(projectLoaded + "//Overworld//Maps//Map" + i.ToString("D3") + ".json"));
            }

            for (int i = 0; i < 223; i++)
            {
                tilesetBitmaps[i] = new Bitmap(projectLoaded + "//Graphics//" + i.ToString("D3") + ".png");
            }
            entranceOWs = JsonConvert.DeserializeObject <EntranceOW[]>(File.ReadAllText(projectLoaded + "//Overworld//Entrances//Entrances.json"));
            for (int i = 0; i < 128; i++)
            {
                byte  m = entranceOWs[i].entranceId;
                short s = (short)(entranceOWs[i].mapId);
                int   p = entranceOWs[i].mapPos >> 1;
                int   x = (p % 64);
                int   y = (p >> 6);
                entranceOWsEditor[i] = new EntranceOWEditor((x * 16) + (((s % 64) - (((s % 64) / 8) * 8)) * 512), (y * 16) + (((s % 64) / 8) * 512), m, s, entranceOWs[i].mapPos);
            }

            holes = JsonConvert.DeserializeObject <EntranceOW[]>(File.ReadAllText(projectLoaded + "//Overworld//Entrances//Holes.json"));
            for (int i = 0; i < 19; i++)
            {
                byte  m = holes[i].entranceId;
                short s = holes[i].mapId;
                int   p = (holes[i].mapPos + 0x400) >> 1;
                int   x = (p % 64);
                int   y = (p >> 6);
                holesOWsEditor[i] = new EntranceOWEditor((x * 16) + ((s - ((s / 8) * 8)) * 512), (y * 16) + ((s / 8) * 512), m, s, (short)(holes[i].mapPos + 0x400));
                //Handle hole to editorhole
            }
            entrances = JsonConvert.DeserializeObject <Entrance[]>(File.ReadAllText(projectLoaded + "//Dungeons//Entrances//Entrances.json"));

            exitsOWs = JsonConvert.DeserializeObject <ExitOW[]>(File.ReadAllText(projectLoaded + "//Overworld//Entrances//Exits.json"));

            tileTypeSet = JsonConvert.DeserializeObject <byte[][]>(File.ReadAllText(projectLoaded + "//Overworld//TilesTypes.json"));

            alltiles16 = JsonConvert.DeserializeObject <Tile16[]>(File.ReadAllText(projectLoaded + "//Overworld//Tiles16.json"));

            File.WriteAllText(projectLoaded + "//Overworld//Tiles16Backup.json", JsonConvert.SerializeObject(alltiles16));


            overlayDatas = JsonConvert.DeserializeObject <List <OverlayData>[]>(File.ReadAllText(projectLoaded + "//Overworld//Overlays.json"));

            gameTexts = JsonConvert.DeserializeObject <string[]>(File.ReadAllText(projectLoaded + "//Texts//AllTexts.json"));
            linkGfx   = new Bitmap(128, 448);
            using (Graphics g = Graphics.FromImage(linkGfx))
            {
                Bitmap templinkGfx = new Bitmap(projectLoaded + "//Graphics//Link.png");
                g.DrawImage(templinkGfx, 0, 0);
            }
            linkGfx.MakeTransparent(Color.Black);
        }