示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Turns the selected image int a representation of the palette
            int x = 0; int y = 0;

            tex.Modified = true;
            for (int counter = 0; counter < 256; counter++)
            {
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 1, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 2, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 3, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 4, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 5, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 6, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 7, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 8, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 9, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 10, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 11, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 12, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 13, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 14, counter, counter);
                ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y + 15, counter, counter);

                x++;
                if (x >= 64)
                {
                    x = 0;
                    y = y + 16;
                }
            }
        }
示例#2
0
        private void BtnImport_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                Bitmap  jr       = (Bitmap)Bitmap.FromFile(openFileDialog1.FileName);
                Palette FinalPal = CurrentImage.GetFinalPallette();
                if ((jr.Width != CurrentImage.image.Width) || (jr.Height != CurrentImage.image.Height))
                {
                    jr = ArtLoader.Resize(jr, CurrentImage.image.Width, CurrentImage.image.Height);
                }

                for (int x = 0; x < jr.Width; x++)
                {
                    for (int y = 0; y < jr.Height; y++)
                    {
                        int nearest = PaletteLoader.GetNearestColour(jr.GetPixel(x, y), FinalPal);
                        //Get nearest palette to color
                        ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y, nearest, nearest);
                    }
                }
                ImgOut.Image = CurrentImage.image;
            }
        }
示例#3
0
        public static void LoadTileMap(int blockno, main MAIN)
        {
            //MAIN.TreeTiles.Nodes.Clear();
            MAIN.tilemap = new TileMap();
            if (MAIN.uwblocks[blockno].DataLen < 0x7c06)
            {
                return;
            }
            MAIN.tilemap.InitTileMap(MAIN.uwblocks[blockno].Data, 0, blockno, MAIN.uwblocks[blockno].Address);
            if (main.curgame == 1)
            {
                MAIN.tilemap.BuildTextureMap(MAIN.uwblocks[blockno + 18].Data, ref MAIN.tilemap.ceilingtexture);
            }
            else
            {
                MAIN.tilemap.BuildTextureMap(MAIN.uwblocks[blockno + 80].Data, ref MAIN.tilemap.ceilingtexture);
            }
            //Temporarily output to treeview for testing.
            // MAIN.txtMap.Text = "";
            //for (int x = 0; x <= 63; x++)
            //{

            //   TreeNode xnode = MAIN.TreeTiles.Nodes.Add("X=" + x);
            //    for (int y = 0; y <= 63; y++)
            //    {
            //        TreeNode ynode = xnode.Nodes.Add("Y=" + y);
            //        ynode.Tag = x + "," + y;
            //        //MAIN.txtMap.Text += MAIN.tilemap.Tiles[x, y].tileType;
            //    }
            //    //MAIN.txtMap.Text += "\n";
            //}

            MAIN.worldObjects = new objects();
            MAIN.worldObjects.InitWorldObjectList(MAIN.uwblocks[blockno].Data, 64 * 64 * 4, MAIN.uwblocks[blockno].Address);
            MAIN.TreeWorldObjects.Nodes.Clear();
            for (int i = 0; i <= MAIN.worldObjects.objList.GetUpperBound(0); i++)
            {
                TreeNode newnode = MAIN.TreeWorldObjects.Nodes.Add(i + ". " + objects.ObjectName(MAIN.worldObjects.objList[i].item_id, main.curgame));
                newnode.Tag = i;
            }

            MAIN.TreeWorldByTile.Nodes.Clear();
            for (int x = 0; x <= 63; x++)
            {
                for (int y = 0; y <= 63; y++)
                {
                    if (MAIN.tilemap.Tiles[x, y].indexObjectList != 0)
                    {
                        TreeNode xynode = MAIN.TreeWorldByTile.Nodes.Add(x + "," + y);
                        TileMapUI.PopulateWorldNode(xynode, MAIN.tilemap.Tiles[x, y].indexObjectList, MAIN.worldObjects.objList);
                    }
                }
            }

            MAIN.PicMap.Image  = ArtUI.UWMap(MAIN.tilemap, MAIN.tex);
            MAIN.PicMap.Height = 64 * (int)MAIN.numMapZoom.Value;
            MAIN.PicMap.Width  = 64 * (int)MAIN.numMapZoom.Value;
        }
示例#4
0
        public static void ApplyTileChanges(int x, int y, main MAIN)
        {
            MAIN.tilemap.Tiles[x, y].tileType        = (short)TileMap.GetTileTypeInt(MAIN.CmbTileType.Text);
            MAIN.tilemap.Tiles[x, y].floorHeight     = (short)MAIN.NumFloorHeight.Value;
            MAIN.tilemap.Tiles[x, y].flags           = (short)MAIN.NumTileFlags.Value;
            MAIN.tilemap.Tiles[x, y].floorTexture    = (short)MAIN.NumFloorTexture.Value;
            MAIN.tilemap.Tiles[x, y].noMagic         = (short)MAIN.NumNoMagic.Value;
            MAIN.tilemap.Tiles[x, y].doorBit         = (short)MAIN.NumDoorBit.Value;
            MAIN.tilemap.Tiles[x, y].indexObjectList = (short)MAIN.NumIndexObjectList.Value;
            MAIN.tilemap.Tiles[x, y].wallTexture     = (short)MAIN.NumWallTexture.Value;

            int actualtexture = MAIN.tilemap.GetMappedFloorTexture(TileMap.fSELF, MAIN.tilemap.Tiles[x, y]);

            MAIN.LblMappedFloorTexture.Text = actualtexture.ToString()
                                              + " " + MAIN.UWGameStrings.GetTextureName(actualtexture, main.curgame);


            TileMap.TileInfo t = MAIN.tilemap.Tiles[x, y];

            //Shift the bits to construct my data
            int tileType    = t.tileType;
            int floorHeight = (t.floorHeight / 2) << 4;

            int ByteToWrite = tileType | floorHeight;//| floorTexture | noMagic;//This will be set in the original data

            MAIN.levarkbuffer[t.FileAddress] = (char)(ByteToWrite);
            int flags        = t.flags & 0x3;
            int floorTexture = t.floorTexture << 2;
            int noMagic      = t.noMagic << 6;
            int DoorBit      = t.doorBit << 7;

            ByteToWrite = floorTexture | noMagic | DoorBit | flags;
            MAIN.levarkbuffer[t.FileAddress + 1] = (char)(ByteToWrite);

            ByteToWrite = ((t.indexObjectList & 0x3FF) << 6) | (t.wallTexture & 0x3F);
            MAIN.levarkbuffer[t.FileAddress + 2] = (char)(ByteToWrite & 0xFF);
            MAIN.levarkbuffer[t.FileAddress + 3] = (char)((ByteToWrite >> 8) & 0xFF);

            MAIN.tilemap.Cleanup();
            MAIN.PicMap.Image  = ArtUI.UWMap(MAIN.tilemap, MAIN.tex);
            MAIN.PicMap.Height = 64 * (int)MAIN.numMapZoom.Value;
            MAIN.PicMap.Width  = 64 * (int)MAIN.numMapZoom.Value;
        }
示例#5
0
        /// <summary>
        /// Handles the clicking of a pixel on the image display
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ImgOut_MouseClick(object sender, MouseEventArgs e)
        {
            if (CurrentImage == null)
            {
                return;
            }
            //if (main.curgame==GAME_UW1)
            //{
            //    if (CurrentImageNo>=210)
            //    {//Editing a 32x32 floor texture
            //        factor = 8;
            //    }
            //}
            // MessageBox.Show(e.Location.X / 4 +","+ (ImgOut.Height-e.Location.Y) / 4);
            int x = (int)(e.Location.X / NumZoom.Value);
            int y = (int)((e.Location.Y) / NumZoom.Value);

            ArtUI.setPixelAtLocation(CurrentImage, ImgOut, x, y, CurrentPalettePixel, CurrentRefPixel);
        }
示例#6
0
        /// <summary>
        /// Handles saving of changes of the image data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnImgSave_Click(object sender, EventArgs e)
        {
            //if (CurrentImage.ImageType != BitmapUW.ImageTypes.Texture) { return; }
            //Loop through all art loaders and see if they need modifiying.

            if (tex != null)
            {
                if (tex.Modified)
                {
                    switch (main.curgame)
                    {
                    case GAME_UW1:
                        if (tex.texturebufferW != null)
                        {
                            ArtUI.SaveTextureData(tex.texturebufferW, true);
                        }
                        if (tex.texturebufferF != null)
                        {
                            ArtUI.SaveTextureData(tex.texturebufferF, false);
                        }
                        break;

                    case GAME_UW2:
                        ArtUI.SaveTextureData(tex.texturebufferT, false);
                        break;
                    }
                }
            }
            for (int i = 0; i <= grfile.GetUpperBound(0); i++)
            {
                if (grfile[i] != null)
                {
                    if (grfile[i].Modified)
                    {
                        //do saving of a .gr file
                        switch (grfile[i].ImageType)
                        {
                        case BitmapUW.ImageTypes.EightBitUncompressed:
                            ArtUI.SaveBytDataUW1(grfile[i].ImageFileData, grfile[i].FileName.Replace(main.basepath, ""));
                            break;

                        case BitmapUW.ImageTypes.FourBitUncompress:
                            ArtUI.SaveBytDataUW1(grfile[i].ImageFileData, grfile[i].FileName.Replace(main.basepath, ""));
                            break;

                        default:    //4 bit formats (convert to 8 bits?)
                            grfile[i].Save4Bit();
                            break;
                        }
                    }
                }
            }

            if (bytfile != null)
            {
                if (curgame == GAME_UW1)
                {
                    for (int i = 0; i <= bytfile.GetUpperBound(0); i++)
                    {
                        if (bytfile[i] != null)
                        {
                            if (bytfile[i].ImageCache != null)
                            {
                                if (bytfile[i].ImageCache[0].Modified)
                                {
                                    //Save this .byt file
                                    ArtUI.SaveBytDataUW1(bytfile[i].ImageFileData, "\\Data\\" + BytLoader.FilePaths[i]);
                                }
                            }
                        }
                    }
                }
            }
        }