Example #1
0
 private void createmap(int mapid, int itemid, int maplenth, int mapwidth)
 {
     singleMap map = new singleMap();
     int selectedIndex = this.listBox1.SelectedIndex;
     map = new singleMap
     {
         map_addr = this.allmapdata[mapid].map_addr,
         map_store_data = (byte[])this.allmapdata[selectedIndex].map_store_data.Clone(),
         MapWidth = mapwidth,
         MapHeight = maplenth,
         maptitles = new byte[map.MapHeight * map.MapWidth]
     };
     for (int i = 0; i < map.maptitles.Length; i++)
     {
         map.maptitles[i] = (byte)itemid;
     }
     map.nametable = new byte[(map.MapHeight * map.MapWidth) * 4];
     map.uper2 = new byte[map.MapHeight * map.MapWidth];
     map.PattenTable = this.allmapdata[mapid].PattenTable;
     map.PattenTable1 = this.allmapdata[this.listBox1.SelectedIndex].PattenTable1;
     map.palleteaddr = this.allmapdata[mapid].palleteaddr;
     map.maptitles_1 = (byte[])this.allmapdata[mapid].maptitles_1.Clone();
     map.map_store_data[9] = this.allmapdata[mapid].map_store_data[9];
     map.map_store_data[10] = this.allmapdata[mapid].map_store_data[10];
     map.pallete = (byte[])this.allmapdata[mapid].pallete.Clone();
     int mapWidth = map.MapWidth;
     int mapHeight = map.MapHeight;
     byte[] nametable = map.nametable;
     for (int j = 0; j < mapWidth; j++)
     {
         for (int num6 = 0; num6 < mapHeight; num6++)
         {
             nametable[((num6 * mapWidth) * 4) + (j * 2)] = map.maptitles_1[map.maptitles[(num6 * mapWidth) + j] * 4];
             nametable[(((num6 * mapWidth) * 4) + (j * 2)) + 1] = map.maptitles_1[(map.maptitles[(num6 * mapWidth) + j] * 4) + 1];
             nametable[((num6 * mapWidth) * 4) + ((mapWidth + j) * 2)] = map.maptitles_1[(map.maptitles[(num6 * mapWidth) + j] * 4) + 2];
             nametable[(((num6 * mapWidth) * 4) + ((mapWidth + j) * 2)) + 1] = map.maptitles_1[(map.maptitles[(num6 * mapWidth) + j] * 4) + 3];
             map.uper2[(num6 * mapWidth) + j] = (byte)(map.maptitles_1[0x200 + map.maptitles[(num6 * mapWidth) + j]] & 3);
         }
     }
     byte[] originalImageData = new byte[(((map.MapHeight * map.MapWidth) * 4) * 8) * 8];
     byte[] array = new byte[0x4000];
     this._commdata.chrimagedata[map.PattenTable[0]].CopyTo(array, 0);
     this._commdata.chrimagedata[map.PattenTable[1]].CopyTo(array, 0x1000);
     this._commdata.chrimagedata[map.PattenTable[2]].CopyTo(array, 0x2000);
     this._commdata.chrimagedata[map.PattenTable[3]].CopyTo(array, 0x3000);
     for (int k = 0; k < (map.MapWidth * 2); k++)
     {
         for (int num8 = 0; num8 < (map.MapHeight * 2); num8++)
         {
             int num9 = nametable[k + ((num8 * map.MapWidth) * 2)];
             int num10 = map.uper2[((num8 / 2) * map.MapWidth) + (k / 2)] * 4;
             for (int num11 = 0; num11 < 8; num11++)
             {
                 for (int num12 = 0; num12 < 8; num12++)
                 {
                     originalImageData[(((((num8 * 0x40) * map.MapWidth) * 2) + (((num11 * 8) * map.MapWidth) * 2)) + (k * 8)) + num12] = (byte)(array[((((num9 / 0x10) * 0x400) + (0x80 * num11)) + ((num9 % 0x10) * 8)) + num12] + num10);
                 }
             }
         }
     }
     for (int m = 0; m < originalImageData.Length; m++)
     {
         originalImageData[m] = map.pallete[originalImageData[m]];
     }
     Bitmap original = bmp.CreateBitmap(originalImageData, (map.MapWidth * 8) * 2, (map.MapHeight * 8) * 2);
     original.Palette = cp;
     Bitmap bitmap2 = new Bitmap(original);
     original.Dispose();
     original = null;
     map.cityBmp = bitmap2.Clone(new Rectangle(0, 0, map.MapWidth * 0x10, map.MapHeight * 0x10), PixelFormat.Format24bppRgb);
     for (int n = 0; n < 0x80; n++)
     {
         byte[] buffer4 = new byte[0x100];
         for (int num15 = 0; num15 < 2; num15++)
         {
             for (int num16 = 0; num16 < 2; num16++)
             {
                 int num17 = map.maptitles_1[((n * 4) + (num15 * 2)) + num16];
                 for (int num18 = 0; num18 < 8; num18++)
                 {
                     for (int num19 = 0; num19 < 8; num19++)
                     {
                         buffer4[(((((num15 * 8) * 8) * 2) + ((num18 * 8) * 2)) + (num16 * 8)) + num19] = (byte)(array[((((num17 / 0x10) * 0x400) + (0x80 * num18)) + ((num17 % 0x10) * 8)) + num19] + ((map.maptitles_1[0x200 + n] & 3) * 4));
                     }
                 }
             }
         }
         for (int num20 = 0; num20 < buffer4.Length; num20++)
         {
             buffer4[num20] = map.pallete[buffer4[num20]];
         }
         Bitmap bitmap3 = bmp.CreateBitmap(buffer4, 0x10, 0x10);
         bitmap3.Palette = cp;
         map.map_item_image[n] = new Bitmap(bitmap3);
     }
     map.enterdata = this.allmapdata[selectedIndex].enterdata;
     map.enters = this.allmapdata[selectedIndex].enters;
     map.npc_datas = this.allmapdata[selectedIndex].npc_datas;
     map.hideItem = this.allmapdata[selectedIndex].hideItem;
     map.specP = this.allmapdata[selectedIndex].specP;
     new editform { editmapid = selectedIndex, map = map }.Show(this);
     this.froms = new 小地图元件();
     this.froms.Show(this);
 }
Example #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.listBox1.SelectedIndex >= 0)
     {
         if (this.allmapdata[this.listBox1.SelectedIndex].mapstoreshare != 0)
         {
             MessageBox.Show("该地图图形是公用的,不能修改,请先更改!");
         }
         else
         {
             new editform { editmapid = this.listBox1.SelectedIndex, map = this.allmapdata[this.listBox1.SelectedIndex] }.Show(this);
             this.froms = new 小地图元件();
             this.froms.Show(this);
         }
     }
 }