コード例 #1
0
ファイル: LayerPropertiesWnd.cs プロジェクト: zeromus/maped3
 public void setvalues(MapLayer ml)
 {
     ml.name = t_layername.Text;
     ml.Translucency = (int)n_layerlucency.Value;
     ml.parallaxInfo.MultipleX = (double)n_px.Value;
     ml.parallaxInfo.MultipleY = (double)n_py.Value;
 }
コード例 #2
0
ファイル: mapView.cs プロジェクト: salviati/verge3
        private void renderEntities(pr2.IRenderImage backBuffer, MapLayer ml, int px, int py)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;
            int tw   = backBuffer.Width / 16 + 2;
            int th   = backBuffer.Height / 16 + 2;

            foreach (MapEntity me in ParentMap.Entities)
            {
                int tx = me.TileX;
                int ty = me.TileY;

                if (tx >= mtx && tx <= mtx + tw && ty >= mty && ty <= mty + th)
                {
                    int cx = -mtox + (tx - mtx) * 16;
                    int cy = -mtoy + (ty - mty) * 16;
                    Render.renderColoredTile_50Alpha(backBuffer, cx, cy, Preferences.Current.EntsColor);
                    Render.renderNumber(backBuffer, cx + 4, cy + 4, me.ID, unchecked ((int)0xFFFFFFFF));
                }
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="map"></param>
        public static Map ReadMap2(FileInfo fi)
        {
            FileStream   fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            byte[] Buffer = br.ReadBytes((int)fi.Length);

            br.Close();

            Map map = new Map();

            map.FileOnDisk = fi;

            MemoryStream ms = new MemoryStream(Buffer);

            br = new BinaryReader(ms);

            if (Buffer[0] != 77 || Buffer[1] != 65 || Buffer[2] != 80 || Buffer[3] != 249 || Buffer[4] != 53 || Buffer[5] != 0)
            {
                Errors.Error("InputOutput", "File is not a VERGE2 Map");
                return(null);
            }


            // 6 bytes signature
            // 4 bytes unknown??
            // ---
            // advance 10 bytes
            br.ReadBytes(10);


            // 60 bytes VSP FileName
            FileInfo vspfile = new FileInfo(Helper.BytesToString(br.ReadBytes(60)));

            if (!vspfile.Exists)
            {
                // TODO:  give the option to create a vsp in this case
                Errors.Error("InputOutput", "VSP was not found. New VSP created.");
                map.vsp = new Vsp24();
            }
            else
            {
                map.vsp = ReadVsp(vspfile.FullName);
            }

            // 60 bytes music filename
            map.MusicFileName = Helper.BytesToString(br.ReadBytes(60));

            // 20 bytes render string
            string dontcare = Helper.BytesToString(br.ReadBytes(20));


            // 4 bytes, start position
            map.PlayerStartX = (int)br.ReadInt16();
            map.PlayerStartY = (int)br.ReadInt16();

            // 51 bytes, unknown
            br.ReadBytes(51);

            // 1 byte, number of layers
            int layerCount = (int)br.ReadByte();


            for (int i = 0; i < layerCount; i++)
            {
                // 12 bytes per layer discriptor
                MapLayer ml = new MapLayer(map);
                ml.type = LayerType.Tile;
                ml.name = "Layer " + i.ToString();


                int mx, dx, my, dy;
                mx = (int)br.ReadByte();
                dx = (int)br.ReadByte();
                my = (int)br.ReadByte();
                dy = (int)br.ReadByte();

                double dmx, dmy;

                dmx = 1.0 * mx / dx;
                dmy = 1.0 * my / dy;
                ml.parallaxInfo.MultipleX = dmx;
                ml.parallaxInfo.MultipleY = dmy;

                /*
                 *                              ml.parallaxInfo.MultiplyX = (int)br.ReadByte();
                 *                              ml.parallaxInfo.DivideX = (int)br.ReadByte();
                 *                              ml.parallaxInfo.MultiplyY = (int)br.ReadByte();
                 *                              ml.parallaxInfo.DivideY = (int)br.ReadByte(); */

                int w = (int)br.ReadInt16();
                int h = (int)br.ReadInt16();
                ml.size(w, h);

                ml.Translucency = (int)br.ReadByte();
                ml.HLine        = (int)br.ReadByte();

                // padding
                br.ReadInt16();

                map.Layers.Add(ml);
            }

            for (int i = 0; i < layerCount; i++)
            {
                int rleLength = br.ReadInt32();

                ushort[] layerdata = InputOutput.DecompressData16(Helper.BytesToWords(br.ReadBytes(rleLength)));
                MapLayer ml        = (MapLayer)map.Layers[i];
                ml.Data = new short[ml.Width * ml.Height];
                for (int j = 0; j < ml.Width * ml.Height; j++)
                {
                    ml.Data[j] = (short)layerdata[j];
                }
            }

            int obsDataLength = br.ReadInt32();

            byte[] obsdata = InputOutput.DecompressData8(br.ReadBytes(obsDataLength));
            map.ObsLayer      = new MapLayer(map);
            map.ObsLayer.type = LayerType.Obs;
            map.ObsLayer.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            map.ObsLayer.name = "Obstructions";
            map.ObsLayer.Data = new short[map.ObsLayer.Width * map.ObsLayer.Height];
            for (int i = 0; i < map.ObsLayer.Width * map.ObsLayer.Height; i++)
            {
                map.ObsLayer.Data[i] = obsdata[i];
            }


            int zoneDataLength = br.ReadInt32();

            byte[] zonedata = InputOutput.DecompressData8(br.ReadBytes(zoneDataLength));
            map.ZoneLayer      = new MapLayer(map);
            map.ZoneLayer.type = LayerType.Zone;
            map.ZoneLayer.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            map.ZoneLayer.name = "Zones";
            map.ZoneLayer.Data = new short[map.ZoneLayer.Width * map.ZoneLayer.Height];
            for (int i = 0; i < map.ZoneLayer.Width * map.ZoneLayer.Height; i++)
                map.ZoneLayer.Data[i] = zonedata[i]; }
コード例 #4
0
ファイル: LayerResizerWnd.cs プロジェクト: salviati/verge3
 public void init(MapLayer ml)
 {
     n_w.Value   = ml.Width;
     n_h.Value   = ml.Height;
     l_dims.Text = "Original Size - " + ml.Width.ToString() + " x " + ml.Height.ToString();
 }
コード例 #5
0
ファイル: LPanel.cs プロジェクト: Bananattack/verge3
        public LPanel(Panel lTool, MapLayer ml, bool render, bool write, int layer)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint,true);
            SetStyle(ControlStyles.UserPaint,true);
            SetStyle(ControlStyles.DoubleBuffer,true);
            SetStyle(ControlStyles.Opaque,true);
            SetStyle(ControlStyles.UserMouse,true);

            LayerRef = layer;
            mLayerRef = ml;

            Cursor = Cursors.Hand;

            if(mLayerRef is MapLayerSpecial)
                Size = new Size(lTool.Width-4,16);
            else
                Size = new Size(lTool.Width-4, 25);

            Render=render;
            Write=write;
            if ( Write ) Global.lpSelection = this;
            if( ml.type != LayerType.Tile )
                return;

            cmenu = new ContextMenu();

            MenuItem m_properties = new MenuItem("Properties", new EventHandler(properties_menu));
            cmenu.MenuItems.Add(m_properties);
            cmenu.Popup += new EventHandler(cmenu_Popup);
            ContextMenu = cmenu;
        }
コード例 #6
0
ファイル: InputOutput.cs プロジェクト: zeromus/maped3
        public static Map ReadMap2(FileInfo fi)
        {
            FileStream fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            byte[] Buffer = br.ReadBytes((int)fi.Length);

            br.Close();

            Map map = new Map();

            map.FileOnDisk = fi;

            MemoryStream ms = new MemoryStream(Buffer);
            br = new BinaryReader(ms);

            if (Buffer[0] != 77 || Buffer[1] != 65 || Buffer[2] != 80 || Buffer[3] != 249 || Buffer[4] != 53 || Buffer[5] != 0)
            {
                Errors.Error("InputOutput", "File is not a VERGE2 Map");
                return null;
            }

            // 6 bytes signature
            // 4 bytes unknown??
            // ---
            // advance 10 bytes
            br.ReadBytes(10);

            // 60 bytes VSP FileName
            FileInfo vspfile = new FileInfo(Helper.BytesToString(br.ReadBytes(60)));
            if (!vspfile.Exists)
            {
                // TODO:  give the option to create a vsp in this case
                Errors.Error("InputOutput", "VSP was not found. New VSP created.");
                map.vsp = new Vsp24();
            }
            else
            {
                map.vsp = ReadVsp(vspfile.FullName);
            }

            // 60 bytes music filename
            map.MusicFileName = Helper.BytesToString(br.ReadBytes(60));

            // 20 bytes render string
            string dontcare = Helper.BytesToString(br.ReadBytes(20));

            // 4 bytes, start position
            map.PlayerStartX = (int)br.ReadInt16();
            map.PlayerStartY = (int)br.ReadInt16();

            // 51 bytes, unknown
            br.ReadBytes(51);

            // 1 byte, number of layers
            int layerCount = (int)br.ReadByte();

            for (int i = 0; i < layerCount; i++)
            {
                // 12 bytes per layer discriptor
                MapLayer ml = new MapLayer(map);
                ml.type = LayerType.Tile;
                ml.name = "Layer " + i.ToString();

                int mx, dx, my, dy;
                mx = (int)br.ReadByte();
                dx = (int)br.ReadByte();
                my = (int)br.ReadByte();
                dy = (int)br.ReadByte();

                double dmx, dmy;

                dmx = 1.0 * mx / dx;
                dmy = 1.0 * my / dy;
                ml.parallaxInfo.MultipleX = dmx;
                ml.parallaxInfo.MultipleY = dmy;
                /*
                                                                                ml.parallaxInfo.MultiplyX = (int)br.ReadByte();
                                                                                ml.parallaxInfo.DivideX = (int)br.ReadByte();
                                                                                ml.parallaxInfo.MultiplyY = (int)br.ReadByte();
                                                                                ml.parallaxInfo.DivideY = (int)br.ReadByte(); */

                int w = (int)br.ReadInt16();
                int h = (int)br.ReadInt16();
                ml.size(w, h);

                ml.Translucency = (int)br.ReadByte();
                ml.HLine = (int)br.ReadByte();

                // padding
                br.ReadInt16();

                map.Layers.Add(ml);
            }

            for (int i = 0; i < layerCount; i++)
            {
                int rleLength = br.ReadInt32();

                ushort[] layerdata = InputOutput.DecompressData16(Helper.BytesToWords(br.ReadBytes(rleLength)));
                MapLayer ml = (MapLayer)map.Layers[i];
                ml.Data = new short[ml.Width * ml.Height];
                for (int j = 0; j < ml.Width * ml.Height; j++)
                    ml.Data[j] = (short)layerdata[j];

            }

            int obsDataLength = br.ReadInt32();
            byte[] obsdata = InputOutput.DecompressData8(br.ReadBytes(obsDataLength));
            map.ObsLayer = new MapLayer(map);
            map.ObsLayer.type = LayerType.Obs;
            map.ObsLayer.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            map.ObsLayer.name = "Obstructions";
            map.ObsLayer.Data = new short[map.ObsLayer.Width * map.ObsLayer.Height];
            for (int i = 0; i < map.ObsLayer.Width * map.ObsLayer.Height; i++)
                map.ObsLayer.Data[i] = obsdata[i];

            int zoneDataLength = br.ReadInt32();
            byte[] zonedata = InputOutput.DecompressData8(br.ReadBytes(zoneDataLength));
            map.ZoneLayer = new MapLayer(map);
            map.ZoneLayer.type = LayerType.Zone;
            map.ZoneLayer.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            map.ZoneLayer.name = "Zones";
            map.ZoneLayer.Data = new short[map.ZoneLayer.Width * map.ZoneLayer.Height];
            for (int i = 0; i < map.ZoneLayer.Width * map.ZoneLayer.Height; i++)
                map.ZoneLayer.Data[i] = zonedata[i];

            MapLayer el = new MapLayer(map);
            el.type = LayerType.Entity;
            el.name = "Entities";
            map.Layers.Add(el);
            map.EntLayer = el;

            MapLayerSpecial rl = new MapLayerSpecial(map);
            rl.type = LayerType.Special_Retrace;

            map.Layers.Add(rl);
            map.Layers.Add(map.ObsLayer);
            map.Layers.Add(map.ZoneLayer);
            int zoneCount = br.ReadInt32();

            // 50 bytes per zone
            for (int i = 0; i < zoneCount; i++)
            {
                MapZone mz = new MapZone();

                mz.ID = i;

                mz.Name = Helper.CharsToString(br.ReadChars(40));
                //Errors.Error(mz.Name);

                mz.PlayerScript = "";
                br.ReadInt16();
                mz.Rate = (int)br.ReadInt16();
                mz.Delay = (int)br.ReadInt16();

                mz.Flags = (int)br.ReadInt16();
                mz.EntityScript = "";
                br.ReadInt16();

                map.Zones.Add(mz);
            }
            if (zoneCount == 0)
            {
                MapZone mz = new MapZone();
                mz.ID = 0;
                mz.Name = "NULL_ZONE";
                map.Zones.Add(mz);
            }

            int chrCount = (int)br.ReadByte();
            ArrayList al_chrs = new ArrayList();

            for (int i = 0; i < chrCount; i++)
            {
                MapChr mc = new MapChr();

                try
                {
                    mc.Name = Helper.BytesToFileString(br.ReadBytes(60));
                }
                catch (Exception e)
                {
                    mc.Name = "";

                    /// there's no error log in maped3 yet.  I'll discuss this with the boys.  For now, ANNOYING MESSAGE BOX!
                    /// -gru

                    Errors.Error("I/O", "Bad filename for MapChr(" + i + "): " + e.Message + "\nDefaulting to empty string for file name.");
                }

                mc.ID = i;

                if (mc.Name.Length > 0)
                {
                    FileInfo mcfi = new FileInfo(mc.Name);
                    if (ReadCHR(mcfi, mc) == 0) mc.bImageAvailable = true;
                }
                al_chrs.Add(mc);
            }

            int entCount = (int)br.ReadByte();
            //Errors.Error(entCount.ToString() + ", "+br.BaseStream.Position.ToString());

            for (int i = 0; i < entCount; i++)
            {
                MapEntity me = new MapEntity();

                me.TileX = (int)br.ReadInt32();
                me.TileY = (int)br.ReadInt32();

                int xx = (int)br.ReadInt16();
                int xy = (int)br.ReadInt16();

                //Errors.Error(""+ me.TileX+","+me.TileY+":"+xx+","+xy);
                // ignore
                //br.ReadBytes(4);

                me.Facing = (int)br.ReadByte();
                if (me.Facing == 0)
                    me.Facing = 2;
                me.Moving = (int)br.ReadByte();

                // ignore
                br.ReadByte();

                me.BottomLineFrame = (int)br.ReadByte();
                me.SpecialFrameSet = (int)br.ReadByte();
                int cidx = (int)br.ReadByte();
                // assign chr
                // dont do this
                //me.Chr = ((MapChr)al_chrs[cidx]).Clone();
                me.ChrName = string.Copy(((MapChr)al_chrs[cidx]).Name);

                me.Reset = (int)br.ReadByte();
                me.ObeyObstruction = (int)br.ReadByte();
                me.IsObstruction = (int)br.ReadByte();
                me.Speed = (int)br.ReadByte();
                switch (me.Speed)
                {
                    case 1: me.Speed = 25; break;
                    case 2: me.Speed = 33; break;
                    case 3: me.Speed = 50; break;
                    case 4: me.Speed = 100; break;
                    case 5: me.Speed = 200; break;
                    case 6: me.Speed = 300; break;
                    case 7: me.Speed = 400; break;
                }

                // ignore
                br.ReadBytes(10); // entspeedcnt(1), anim frame delay(1), anim script(4), move script(4)

                //32

                me.AutoFace = (int)br.ReadByte();
                me.ActivationMode = (int)br.ReadByte();
                me.MoveType = (int)br.ReadByte();
                if (me.MoveType > 1) me.MoveType--;
                me.__movescript = (int)br.ReadByte();

                // ignore
                br.ReadBytes(2); // subtile move ctr, mode flag

                me.WanderSteps = (int)br.ReadInt16();
                me.WanderDelay = (int)br.ReadInt16();

                // ignore
                br.ReadBytes(4); // step ctr, delay ctr

                me.ID = i;

                br.ReadBytes(2); // WTF IS THIS!!

                for (int j = 0; j < 6; j++)
                {
                    me.UserData[j] = br.ReadInt16();
                }

                me.WanderRectangle.x0 = me.UserData[1];
                me.WanderRectangle.y0 = me.UserData[2];
                me.WanderRectangle.x1 = me.UserData[4];
                me.WanderRectangle.y1 = me.UserData[5];

                // ignore
                br.ReadBytes(20); // a lot of shiznit

                me.Description = Helper.BytesToString(br.ReadBytes(20));

                //Errors.Error(me.Description);

                //br.ReadBytes(2); // WTF IS THIS!!

                me.ID = i;
                map.Entities.Add(me);
            }

            int movescriptCount = (int)br.ReadByte();
            int movescriptBuffersize = (int)br.ReadInt32();

            ArrayList al_scripts = new ArrayList();
            // ignore
            br.ReadBytes(4 * movescriptCount);

            string script = "";
            while (movescriptBuffersize > 0)
            {
                char c = br.ReadChar();

                if (c == (char)0)
                {
                    al_scripts.Add(string.Copy(script));
                    script = "";
                }
                else script += c;
                movescriptBuffersize--;
            }
            // add all the scripts to their respective entities and trash the movescript array

            foreach (MapEntity me in map.Entities)
            {
                me.MoveScript = (string)al_scripts[me.__movescript];
            }

            br.Close();

            string rs2 = "";
            foreach (char c in dontcare)
            {
                if (rs2.Length != 0)
                    rs2 += ",";
                rs2 += c;
            }
            map.RenderString = rs2;
            return map;
        }
コード例 #7
0
        private unsafe void paint(Graphics g)
        {
            g.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            g.InterpolationMode  = InterpolationMode.NearestNeighbor;
            g.CompositingMode    = CompositingMode.SourceCopy;
            g.CompositingQuality = CompositingQuality.HighSpeed;

            Rectangle r = new Rectangle(0, 0, 100, 100);

            if (Global.ActiveMap != null && Controller != null)
            {
                // get map
                Map map = Global.ActiveMap;
                // get base layer
                MapLayer BaseLayer = (MapLayer)Global.ActiveMap.Layers[0];
                // get the vsp
                Vsp24 mapVsp = Global.ActiveVsp;

                int vw = 200, vh = 200;
                if (BaseLayer.Width > BaseLayer.Height)
                {
                    vh = (int)(vh * ((float)BaseLayer.Height / (float)BaseLayer.Width));
                }
                else
                {
                    vw = (int)(vw * ((float)BaseLayer.Width / (float)BaseLayer.Height));
                }


                float ratio_x = (float)BaseLayer.Width / vw;
                float ratio_y = (float)BaseLayer.Height / vh;

                float ratio_xn = (float)vw / (BaseLayer.Width * 16);
                float ratio_yn = (float)vh / (BaseLayer.Height * 16);

                mapView mv = Controller.MapView;

                int pw = BaseLayer.Width * 16;
                int ph = BaseLayer.Height * 16;

                //zero 1/18/03 - note the zoom alterations here
                int nw = mv.Width * vw / Controller.ZoomLevel / pw;
                int nh = mv.Height * vh / Controller.ZoomLevel / ph;

                r.Width  = nw;
                r.Height = nh;

                int ox = (int)(Controller.hScrollBar.Value * ratio_xn);
                int oy = (int)(Controller.vScrollBar.Value * ratio_yn);

                r.X = ox;
                r.Y = oy;



                if (bNeedsRedraw)
                {
                    BitmapData bmpd   = bmp.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
                    int *      imgptr = (int *)bmpd.Scan0.ToPointer();
                    if (mapVsp != null && mapVsp.tileCount > 0)
                    {
                        for (int l = 0; l < map.Layers.Count; l++)
                        {
                            MapLayer layer = (MapLayer)map.Layers[l];
                            if (layer.type != LayerType.Tile)
                            {
                                continue;
                            }

                            for (int i = 0; i < vh; i++)
                            {
                                for (int j = 0; j < vw; j++)
                                {
                                    int tx = (int)(ratio_x * j);
                                    int ty = (int)(ratio_y * i);
                                    if (tx >= layer.Width || tx < 0 || ty >= layer.Height || ty < 0)
                                    {
                                        continue;
                                    }
                                    int tidx = layer.Data[ty * layer.Width + tx];
                                    if ((l == 0 || tidx != 0) && 0 < tidx && tidx < mapVsp.Tiles.Count)
                                    {
                                        imgptr[i * 200 + j] = ((Vsp24Tile)mapVsp.Tiles[tidx]).ColorAverage;
                                    }
                                }
                            }
                        }
                    }
                    bmp.UnlockBits(bmpd);
                    bNeedsRedraw = false;
                }
                int xx = (200 - vw) / 2;
                int yy = (200 - vh) / 2;
                r.X += xx + 1;
                r.Y += yy + 1;



                // flicker reduce hack
                g.Clip = new Region(new Rectangle(xx, yy, vw + 1, vh + 1));
                g.DrawImageUnscaled(bmp, xx, yy, vw, vh);
                g.Clip = new Region(new Rectangle(0, 0, 200, 200));
                //


                g.DrawRectangle(rectPen, r);
                g.DrawRectangle(rectPenW, xx - 2, yy - 2, vw + 4, vh + 4);
            }
            else
            {
                g.FillRectangle(Brushes.Black, 0, 0, Width, Height);
            }
        }
コード例 #8
0
ファイル: mapView.cs プロジェクト: jder/verge3
        private void renderObstructionLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py)
        {
            int mtx = px / 16;
            int mty = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth = mapLayer.Width;
            int layerHeight = mapLayer.Height;
            int cpx = -mtox;
            int cpy = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = mapLayer.Data;
            if (Global.RenderOptions.bTranslucentEffects) {
                for (int ty = 0; ty < th; ty++, cpy += 16) {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16) {
                        tile = tileMap[tp++];
                        if (0 < tile && tile < ParentMap.vsp.ObstructionTiles.Count) {
                            Render.renderObsTile(backBuffer, cpx, cpy, ((VspObstructionTile)ParentMap.vsp.ObstructionTiles[tile]).Image, false, Preferences.Current.ObsColor);
                        }
                    }
                }
            } else {
                for (int ty = 0; ty < th; ty++, cpy += 16) {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16) {
                        tile = tileMap[tp++];
                        if (0 < tile && tile < ParentMap.vsp.ObstructionTiles.Count) {
                            Render.renderObsTileFast(backBuffer, cpx, cpy, ((VspObstructionTile)ParentMap.vsp.ObstructionTiles[tile]).Image, false);
                        }
                    }
                }
            }
        }
コード例 #9
0
ファイル: mainWindow.cs プロジェクト: mcgrue/maped3
        private void b_layeradd_Click(object sender, System.EventArgs e)
        {
            NewLayerWindow nlw = new NewLayerWindow();
            MapLayer bl = null;
            foreach (MapLayer ml in Global.ActiveMap.Layers)
                if (ml.type == LayerType.Tile)
                {
                    bl = ml;
                    break;
                }
            if (bl == null)
                nlw.init(100, 100);
            else nlw.init(bl.Width, bl.Height);
            if (nlw.ShowDialog() != DialogResult.OK) return;

            MapLayer mlz = new MapLayer(Global.ActiveMap);
            mlz.type = LayerType.Tile;
            mlz.size(nlw.SelectedSize.Width, nlw.SelectedSize.Height);
            mlz.name = "Layer " + (Global.ActiveMap.Layers.Count - 3);
            mlz.parallaxInfo = new ParallaxInfo();

            //			lpAddLayer(mlz, true,false, );
            Global.ActiveMap.AddLayer(mlz);
            lpUpdate(Global.ActiveMap, mlz);
        }
コード例 #10
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public void DeleteLayer(MapLayer ml)
 {
     if (ml.type != LayerType.Tile) return;
     UIState.RemoveLayer(ml);
     RenderManager.Layers.Remove(ml);
     Layers.Remove(ml);
 }
コード例 #11
0
ファイル: Map.cs プロジェクト: zeromus/maped3
        public int AddLayer(MapLayer ml)
        {
            if (this == Global.ActiveMap)
                UIState.AddLayer(ml);

            RenderManager.AddLayer(ml);
            Layers.Add(ml);
            return Layers.Count - 1;
        }
コード例 #12
0
ファイル: mapView.cs プロジェクト: salviati/verge3
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (!live || ParentMap.IsBrush)
            {
                return;
            }


            mdown = true;
            if (Global.editedLayer.type == LayerType.Entity)
            {
                if (Global.SelectedEntity != null)
                {
                    Global.SelectedEntity.TileX = Global.MapCursorLocation.X;
                    Global.SelectedEntity.TileY = Global.MapCursorLocation.Y;
                }
                return;
            }

            currMapPlugin = Global.toolPalette.currMapPlugin;
            if (currMapPlugin == null)
            {
                return;
            }


            //get the tool to be used
            currMapTool = currMapPlugin.getTool(
                e.Button == MouseButtons.Left,
                e.Button == MouseButtons.Right,
                ((Control.ModifierKeys & Keys.Shift) != 0),
                ((Control.ModifierKeys & Keys.Control) != 0),
                ((Control.ModifierKeys & Keys.Alt) != 0)
                );
            if (currMapTool == null)
            {
                return;
            }

            //ensure that the tool to be used works with the current edited layer
            MapLayer ml = null;

            foreach (LayerType t in currMapTool.layerTypes)
            {
                if (t == Global.editedLayer.type)
                {
                    ml = Global.editedLayer;
                }
            }

            if (ml == null)
            {
                currMapTool = null;
                return;
            }

            Capture             = true;
            bDragging           = true;
            ParentMap.bUpdating = true;


            //setup eventinfo
            currMapEventInfo = new Plugins.MapEventInfo();
            //currMapEventInfo.invalidateEvent += new EventHandler(invalidateEvent);

            currMapEventInfo.editedMap        = ParentMap;
            currMapEventInfo.editedLayer      = ml;
            currMapEventInfo.editedLayerIndex = ParentMap.Layers.IndexOf(ml);
            currMapEventInfo.lb        = ((e.Button & MouseButtons.Left) > 0);
            currMapEventInfo.rb        = ((e.Button & MouseButtons.Right) > 0);
            currMapEventInfo.opManager = Global.opManager;
            setupMapCursorLocation(ref currMapEventInfo.start, e.X, e.Y);
            setupMapCursorLocation(ref currMapEventInfo.current, e.X, e.Y);
            setupMapCursorLocation(ref currMapEventInfo.previous, e.X, e.Y);
            currMapEventInfo.bDirty = false;
            if (currMapTool is Plugins.IMapDragTool)
            {
                bDraggingTool   = true;
                currMapDragTool = (Plugins.IMapDragTool)currMapTool;
                currMapDragTool.MouseDown(currMapEventInfo);
                currMapDragTool.MouseMove(currMapEventInfo);
                if (currMapDragTool is Plugins.IMapDragTileTool)
                {
                    ((Plugins.IMapDragTileTool)currMapDragTool).MouseMoveTile(currMapEventInfo);
                }
            }
            if (currMapTool is Plugins.IMapClickTool)
            {
                ((Plugins.IMapClickTool)currMapTool).MouseClick(currMapEventInfo);
            }
            if (currMapEventInfo.bDirty)
            {
                Invalidate();
            }
            currMapEventInfo.bDirty = false;
        }
コード例 #13
0
ファイル: mapView.cs プロジェクト: salviati/verge3
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!live)
            {
                return;
            }

            int xScroll = hscrollbar.Value;
            int yScroll = vscrollbar.Value;

            Map currMap = ParentMap;

            pr2.IRenderImage img = pr2.RenderImage.LockBitmap(bmp);
            img.Clear(unchecked ((int)0xFF000000));

            Map      mOld  = null;
            MapLayer mlOld = null;

            if (currMapTool is Plugins.IMapTweaker)
            {
                mOld  = currMapEventInfo.editedMap;
                mlOld = currMapEventInfo.editedLayer;
                currMapEventInfo.editedMap   = mOld.tileCopy();
                currMapEventInfo.editedLayer = currMapEventInfo.editedMap.findLayer(mlOld.name);
                currMap = currMapEventInfo.editedMap;
                currMapEventInfo.bTweak = true;
                ((Plugins.IMapTweaker)currMapTool).tweakMap(currMapEventInfo);
                currMapEventInfo.bTweak = false;
            }

            bool bottomlayer = false;
            bool blayerfound = false;

            for (int c = 0; c < ParentMap.RenderManager.Layers.Count; c++)
            {
                MapLayer mlCurr = (MapLayer)ParentMap.RenderManager.Layers[c];

                if (!blayerfound && mlCurr.type == LayerType.Tile)
                {
                    bottomlayer = true;
                    blayerfound = true;
                }

                if (!ParentMap.IsBrush)
                {
                    if (!ParentMap.UIState[c].bRender)
                    {
                        continue;
                    }
                }

                if (mlCurr.type == LayerType.Entity)
                {
                    renderEntities(img, mlCurr, xScroll, yScroll);
                }

                if (mlCurr.type == LayerType.Tile || mlCurr.type == LayerType.Obs || mlCurr.type == LayerType.Zone)
                {
                    if (bDragging && currMapEventInfo.editedLayerIndex == c && currMapTool is Plugins.IMapPainter)
                    {
                        //if(Global.editedLayer == mlCurr && currMapTool is Plugins.IMapPainter) {
                        MapLayer mlOld2 = currMapEventInfo.editedLayer;
                        MapLayer mlTemp = mlOld2.copy();
                        currMapEventInfo.editedLayer = mlTemp;
                        currMapEventInfo.bTweak      = true;
                        ((Plugins.IMapPainter)currMapTool).tweakLayer(currMapEventInfo);
                        currMapEventInfo.editedLayer = mlOld2;
                        currMapEventInfo.bTweak      = false;
                        renderLayer(img, mlTemp, xScroll, yScroll, bottomlayer);

                        ((Plugins.IMapPainter)currMapTool).paintMap(currMapEventInfo, img);
                    }
                    else
                    {
                        renderLayer(img, mlCurr, xScroll, yScroll, bottomlayer);
                    }
                    if (bottomlayer)
                    {
                        bottomlayer = false;
                    }
                }
            }

            if (currMapTool is Plugins.IMapTweaker)
            {
                currMapEventInfo.editedMap   = mOld;
                currMapEventInfo.editedLayer = mlOld;
            }

            img.Dispose();
            e.Graphics.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            e.Graphics.InterpolationMode  = InterpolationMode.NearestNeighbor;
            e.Graphics.CompositingMode    = CompositingMode.SourceCopy;
            e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;


            e.Graphics.DrawImage(bmp, 0, 0, bmp.Width * ZoomLevel, bmp.Height * ZoomLevel);



            if (!bDragging && bMouseContained)
            {
                Pen p = new Pen(Color.White, 2.0f);

                Plugins.MapCursorLocation mcl = new winmaped2.Plugins.MapCursorLocation();
                setupMapCursorLocation(ref mcl, cursorX, cursorY);

                int dx = (mcl.tx * 16 - xScroll);
                int dy = (mcl.ty * 16 - yScroll);

                //				if(dx != last_cursorX || dy != last_cursorY)
                //if (cursorX > 0 && cursorX < Size.Width && cursorY>0 && cursorY<Size.Height)
                e.Graphics.DrawRectangle(p, dx * ZoomLevel, dy * ZoomLevel, 16 * ZoomLevel, 16 * ZoomLevel);

                //				last_cursorX = dx;
                //				last_cursorY = dy;
            }

            if (currMapTool is Plugins.IMapPainter)
            {
                ((Plugins.IMapPainter)currMapTool).paintWindow(currMapEventInfo, e.Graphics);
            }
        }
コード例 #14
0
ファイル: mapView.cs プロジェクト: salviati/verge3
        private void renderTileLayer(pr2.IRenderImage backBuffer, MapLayer layer, Vsp24 vsp, int px, int py, bool drawZero)
        {
            int mtx  = px / 16;
            int mty  = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth  = layer.Width;
            int layerHeight = layer.Height;
            int cpx         = -mtox;
            int cpy         = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = layer.Data;
            if (Global.RenderOptions.bTranslucentEffects)
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if ((drawZero || tile != 0) && tile < vsp.tileCount)
                        {
                            Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                        }
                    }
                }
            }
            else
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.render(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, false);
                        }
                    }
                }
            }
        }
コード例 #15
0
        private void MoveToCursor(MouseEventArgs e)
        {
            if (Global.ActiveMap != null && lDown == true && Controller != null)
            {
                // get map
                Map map = Global.ActiveMap;
                // get base layer
                MapLayer BaseLayer = (MapLayer)Global.ActiveMap.Layers[0];
                // get the vsp
                Vsp24 mapVsp = Global.ActiveVsp;
                // get the mapview
                mapView mv = Global.MainMapController.MapView;


                int vw = 200, vh = 200;
                if (BaseLayer.Width > BaseLayer.Height)
                {
                    vh = (int)(vh * ((float)BaseLayer.Height / (float)BaseLayer.Width));
                }
                else
                {
                    vw = (int)(vw * ((float)BaseLayer.Width / (float)BaseLayer.Height));
                }


                float ratio_x = (float)BaseLayer.Width / vw;
                float ratio_y = (float)BaseLayer.Height / vh;

                int x = (200 - vw) / 2;
                int y = (200 - vh) / 2;

                int nx = (int)(ratio_x * (e.X - x) * 16);
                int ny = (int)(ratio_y * (e.Y - y) * 16);

                nx -= (mv.Width / Controller.ZoomLevel / 2);
                ny -= (mv.Height / Controller.ZoomLevel / 2);


                nx += x;
                ny += y;

                if (nx < 0)
                {
                    nx = 0;
                }
                if (ny < 0)
                {
                    ny = 0;
                }
                if (nx > Controller.hScrollBar.Maximum - mv.Width / Controller.ZoomLevel)
                {
                    nx = Controller.hScrollBar.Maximum - mv.Width / Controller.ZoomLevel;
                }
                if (ny > Controller.vScrollBar.Maximum - mv.Height / Controller.ZoomLevel)
                {
                    ny = Controller.vScrollBar.Maximum - mv.Height / Controller.ZoomLevel;
                }

                if (nx >= Controller.hScrollBar.Minimum)
                {
                    Controller.hScrollBar.Value = nx;
                }
                //Controller.hScrollBar.Value = nx;
                if (ny >= Controller.vScrollBar.Minimum)
                {
                    Controller.vScrollBar.Value = ny;
                }
                //Controller.vScrollBar.Value = ny;
                repaint();
            }
        }
コード例 #16
0
ファイル: mainWindow.cs プロジェクト: mcgrue/maped3
        private void miNewLayer_Click(object sender, System.EventArgs e)
        {
            if (Global.ActiveMap != null)
            {
                NewLayerWindow nlw = new NewLayerWindow();

                DialogResult dr = nlw.ShowDialog();

                if (dr != DialogResult.OK)
                {
                    return;
                }

                // add the layer

                MapLayer ml = new MapLayer(Global.ActiveMap);

                int w = nlw.SelectedSize.Width;
                int h = nlw.SelectedSize.Height;

                //ml.Height = h;
                //ml.Width = w;
                ml.size(w, h);

                ml.parallaxInfo = new ParallaxInfo();

                ml.Translucency = 0;

                Global.ActiveMap.Layers.Add(ml);

                lpAddLayer(ml, true, false, (Global.ActiveMap.Layers.Count - 1));

                // create a render state for this layer
                Global.ActiveMap.UIState.AddLayer(ml);

                //				Global.ForceRedraws();
            }
            ui_update();
        }
コード例 #17
0
ファイル: mainWindow.cs プロジェクト: mcgrue/maped3
 public void lpSwapLayer(MapLayer oldLayer, MapLayer newLayer)
 {
     foreach (Control lp in lPanel.Controls)
     {
         if (lp is LPanel)
         {
             if (((LPanel)lp).LayerRef == oldLayer)
             {
                 ((LPanel)lp).LayerRef = newLayer;
             }
         }
     }
 }
コード例 #18
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public int findLayerIndex(MapLayer ml)
 {
     for (int i = 0; i < Layers.Count; i++)
         if (Layers[i] == ml)
             return i;
     return -1;
 }
コード例 #19
0
ファイル: mapView.cs プロジェクト: jder/verge3
        private void renderEntities(pr2.IRenderImage backBuffer, MapLayer ml, int px, int py)
        {
            int mtx = px / 16;
            int mty = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            foreach (MapEntity me in ParentMap.Entities) {
                int tx = me.TileX;
                int ty = me.TileY;

                if (tx >= mtx && tx <= mtx + tw && ty >= mty && ty <= mty + th) {
                    int cx = -mtox + (tx - mtx) * 16;
                    int cy = -mtoy + (ty - mty) * 16;
                    Render.renderColoredTile_50Alpha(backBuffer, cx, cy, Preferences.Current.EntsColor);
                    Render.renderNumber(backBuffer, cx + 4, cy + 4, me.ID, unchecked((int)0xFFFFFFFF));
                }
            }
        }
コード例 #20
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public void ModifyTile(MapLayer ml, int x, int y, int newtile)
 {
     ml.setTile(x, y, newtile);
 }
コード例 #21
0
ファイル: mapView.cs プロジェクト: jder/verge3
        private void renderZoneLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py)
        {
            int mtx = px / 16;
            int mty = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth = mapLayer.Width;
            int layerHeight = mapLayer.Height;
            int cpx = -mtox;
            int cpy = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            const int WHITE = unchecked((int)0xFFFFFFFF);

            short[] tileMap = mapLayer.Data;
            for (int ty = 0; ty < th; ty++, cpy += 16) {
                tp = (ty + mty) * layerWidth + mtx;
                if (Global.RenderOptions.bTranslucentEffects) {
                    for (cpx = xmin; cpx < xmax; cpx += 16) {
                        if ((tile = tileMap[tp++]) != 0) {
                            Render.renderColoredTile_50Alpha(backBuffer, cpx, cpy, Preferences.Current.ZonesColor);
                            Render.renderNumber(backBuffer, cpx, cpy, tile, WHITE);
                        }
                    }
                } else {
                    for (cpx = xmin; cpx < xmax; cpx += 16) {
                        if ((tile = tileMap[tp++]) != 0) {
                            Render.renderColoredTile(backBuffer, cpx, cpy, Preferences.Current.ZonesColor);
                            Render.renderNumber(backBuffer, cpx, cpy, tile, WHITE);
                        }
                    }
                }
            }
        }
コード例 #22
0
ファイル: Map.cs プロジェクト: zeromus/maped3
        public MapLayer copy()
        {
            MapLayer ml = new MapLayer(parentmap);
            ml.type = type;
            ml._Width = Width;
            ml._Height = Height;
            ml.parallaxInfo = parallaxInfo;
            ml.HLine = HLine;
            ml.name = name;
            ml.Translucency = Translucency;

            if (Data != null)
                ml.Data = (short[])Data.Clone();
            return ml;
        }
コード例 #23
0
ファイル: LayerResizerWnd.cs プロジェクト: Bananattack/verge3
 public void init(MapLayer ml)
 {
     n_w.Value = ml.Width;
     n_h.Value = ml.Height;
     l_dims.Text = "Original Size - " + ml.Width.ToString() + " x " + ml.Height.ToString();
 }
コード例 #24
0
ファイル: Map.cs プロジェクト: zeromus/maped3
        public MapLayer copyRange(int x0, int y0, int w, int h)
        {
            MapLayer ml = new MapLayer(parentmap);
            ml.type = type;
            ml.parallaxInfo = parallaxInfo;
            ml.HLine = HLine;
            ml.name = name;
            ml.Translucency = Translucency;
            ml._Width = 0;
            ml._Height = 0;

            if (Data != null)
            {
                ml._Width = w;
                ml._Height = h;
                ml.Data = new short[w * h];
                for (int y = 0; y < h; y++)
                    for (int x = 0; x < w; x++)
                        if (x + x0 < Width && y + y0 < Height && x + x0 >= 0 && y + y0 >= 0)
                            ml.Data[w * y + x] = Data[Width * (y + y0) + x + x0];
                        else
                            ml.Data[w * y + x] = 0;
            }

            return ml;
        }
コード例 #25
0
ファイル: InputOutput.cs プロジェクト: zeromus/maped3
        public static unsafe Map ReadMap3(FileInfo fi)
        {
            byte[] m3s = new byte[] { (byte)'V', (byte)'3', (byte)'M', (byte)'A', (byte)'P', (byte)0 };

            FileStream fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            Map map = new Map();

            map.FileOnDisk = fi;

            //			Directory.SetCurrentDirectory(map.FileOnDisk.Directory.FullName);

            byte[] sig = br.ReadBytes(m3s.Length);
            for (int i = 0; i < m3s.Length; i++)
                if (sig[i] != m3s[i]) return null;

            int version = br.ReadInt32();

            int vcofs = br.ReadInt32();

            if (version >= 3)
            {
                int numNotes = br.ReadInt32();
                for (int i = 0; i < numNotes; i++)
                {
                    Map.Note note = new Map.Note();
                    note.x = br.ReadInt32();
                    note.y = br.ReadInt32();
                    int strlen = br.ReadInt32();
                    byte[] bytes = br.ReadBytes(strlen);
                    note.note = System.Text.Encoding.ASCII.GetString(bytes);
                    map.Notes.Add(note);
                }
            }

            byte[] formal = br.ReadBytes(256);
            byte[] vspname = br.ReadBytes(256);
            byte[] musicname = br.ReadBytes(256);
            byte[] renderstring = br.ReadBytes(256);
            byte[] aexec = br.ReadBytes(256);

            string vspf = Helper.BytesToString(vspname);
            FileInfo vspfile;
            try
            {

                vspfile = new FileInfo(vspf);
            }
            catch (ArgumentException)
            {
                throw new Exception("VSP file is inaccessible. Requested file was '" + vspf + "'");
            }
            if (!vspfile.Exists)
            {
                System.Windows.Forms.DialogResult dr = System.Windows.Forms.MessageBox.Show("Unable to load requested VSP file.  Create a blank vsp?", "Load Error", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Information);
                if (dr == System.Windows.Forms.DialogResult.OK)
                    map.vsp = new Vsp24();
                else if (dr == System.Windows.Forms.DialogResult.Cancel)
                    return null;
                else return null;
            }
            else
            {
                map.vsp = ReadVsp(vspfile.FullName);
            }

            map.FormalName = Helper.BytesToString(formal);
            map.MusicFileName = Helper.BytesToString(musicname);
            //map.RenderString = Helper.BytesToString(renderstring);
            string rs = Helper.BytesToString(renderstring);
            map.AutoExecEvent = Helper.BytesToString(aexec);

            map.PlayerStartX = br.ReadInt16();
            map.PlayerStartY = br.ReadInt16();

            int layercount = br.ReadInt32();

            for (int i = 0; i < layercount; i++)
            {
                MapLayer ml = new MapLayer(map);
                ml.name = Helper.BytesToString(br.ReadBytes(256));
                ml.type = LayerType.Tile;
                ml.parallaxInfo = new ParallaxInfo();
                ml.parallaxInfo.MultipleX = br.ReadDouble();
                ml.parallaxInfo.MultipleY = br.ReadDouble();
                int w = br.ReadInt16();
                int h = br.ReadInt16();
                ml.size(w, h);
                ml.Translucency = br.ReadByte();
                int len = br.ReadInt32();
                int zlen = br.ReadInt32();
                ml.Data = ZLIB.DecodeShorts(br.ReadBytes(zlen), len);

                map.Layers.Add(ml);
            }

            MapLayer ol = new MapLayer(map);
            ol.type = LayerType.Obs;
            ol.name = "Obstructions";
            ol.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            int ol_lenn = br.ReadInt32();
            int ol_len = br.ReadInt32();
            byte[] obsdata = ZLIB.Decode(br.ReadBytes(ol_len), ol_lenn);
            //patch up total garbage obstruction data
            for (int i = 0; i < obsdata.Length; i++)
            {
                ol.Data[i] = obsdata[i];
            #if ASTRAL
                if (ol.Data[i] >= 16) //NUM_OBS
                    ol.Data[i] = 15;
            #endif
            }
            map.ObsLayer = ol;

            int zl_lenn = br.ReadInt32();
            int zl_len = br.ReadInt32();
            MapLayer zl = new MapLayer(map);
            zl.type = LayerType.Zone;
            zl.name = "Zones";
            zl.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            zl.Data = ZLIB.DecodeShorts(br.ReadBytes(zl_len), zl_lenn);
            map.ZoneLayer = zl;

            MapLayer el = new MapLayer(map);
            el.type = LayerType.Entity;
            el.name = "Entities";
            map.EntLayer = el;
            map.Layers.Add(el);

            MapLayerSpecial rl = new MapLayerSpecial(map);
            rl.type = LayerType.Special_Retrace;

            map.Layers.Add(rl);
            map.Layers.Add(ol);
            map.Layers.Add(zl);

            int zonecount = br.ReadInt32();
            for (int i = 0; i < zonecount; i++)
            {
                MapZone mz = new MapZone();
                byte[] zname = br.ReadBytes(256);
                byte[] pscript = br.ReadBytes(256);
                //				byte[] escript = br.ReadBytes(256);
                mz.Name = Helper.BytesToString(zname);
                mz.PlayerScript = Helper.BytesToString(pscript);
                //				mz.EntityScript = Helper.BytesToString(escript);
                mz.Rate = br.ReadByte();
                mz.Delay = br.ReadByte();
                mz.Flags = br.ReadByte();
                mz.ID = i;
                map.Zones.Add(mz);
            }
            if (zonecount == 0)
            {
                MapZone mz = new MapZone();
                mz.ID = 0;
                mz.Name = "NULL_ZONE";
                map.Zones.Add(mz);
            }

            int entcount = br.ReadInt32();
            for (int i = 0; i < entcount; i++)
            {
                MapEntity me = new MapEntity();
                me.TileX = br.ReadInt16();
                me.TileY = br.ReadInt16();
                me.Facing = br.ReadByte();

                me.ObeyObstruction = br.ReadByte();
                me.IsObstruction = br.ReadByte();
                me.AutoFace = br.ReadByte();
                me.Speed = br.ReadInt16();
                me.ActivationMode = br.ReadByte();

                me.MoveType = br.ReadByte();
                me.WanderRectangle.x0 = br.ReadInt16();
                me.WanderRectangle.y0 = br.ReadInt16();
                me.WanderRectangle.x1 = br.ReadInt16();
                me.WanderRectangle.y1 = br.ReadInt16();
                me.WanderDelay = br.ReadInt16();

                int expand = br.ReadInt32();

                me.MoveScript = Helper.BytesToString(br.ReadBytes(256));
                me.ChrName = Helper.BytesToString(br.ReadBytes(256));
                me.Description = Helper.BytesToString(br.ReadBytes(256));
                me.onActivate = Helper.BytesToString(br.ReadBytes(256));
                map.Entities.Add(me);
                me.ID = map.Entities.Count-1;
            }
            br.Close();
            string rs2 = "";
            if (version == 1)
            {
                foreach (char c in rs)
                {
                    if (rs2.Length != 0)
                        rs2 += ",";
                    rs2 += c;
                }
                map.RenderString = rs2;
            }
            else
                map.RenderString = rs;
            return map;
        }
コード例 #26
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public void AddLayer(MapLayer ml)
 {
     if (ml.type != LayerType.Tile) return;
     for (int i = Layers.Count - 1; i > 0; i--)
     {
         MapLayer mld = (MapLayer)Layers[i - 1];
         if (mld.type == LayerType.Tile || i == 1)
         {
             Layers.Insert(i, ml);
             return;
         }
     }
     //Layers.Insert(0,ml);
 }
コード例 #27
0
ファイル: Global.cs プロジェクト: Bananattack/verge3
 public static bool IsBaseLayer(MapLayer ml)
 {
     return (Global.ActiveMap.Layers.IndexOf(ml) == 0);
 }
コード例 #28
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public void MoveDown(MapLayer ml)
 {
     if (ml.type == LayerType.Obs || ml.type == LayerType.Zone)
         return;
     int idx = Layers.IndexOf(ml);
     MapLayer mlb = (MapLayer)Layers[idx + 1];
     if (mlb.type == LayerType.Obs || mlb.type == LayerType.Zone)
         return;
     Layers[idx] = mlb;
     Layers[idx + 1] = ml;
 }
コード例 #29
0
        public unsafe static int WriteMap(FileInfo fi, Map map)
        {
            byte[] map3_signature = new byte[] { (byte)'V', (byte)'3', (byte)'M', (byte)'A', (byte)'P', (byte)0 };
            if (map == null)
            {
                return(-1);
            }

            string vspname = Helper.GetRelativePath(map.FileOnDisk.Directory.FullName, map.vsp.FileOnDisk.FullName);

            if (vspname == null)
            {
                throw new Exception("Unable to resolve VSP path.");
            }

            fi = new FileInfo(fi.Name);
            if (fi.Exists)
            {
                fi.Delete();
            }
            FileStream   fs        = fi.OpenWrite();
            MemoryStream ms_outbuf = new MemoryStream();
            BinaryWriter bw_o      = new BinaryWriter(ms_outbuf);

            MemoryStream ms_outbuf2 = new MemoryStream();
            BinaryWriter bw         = new BinaryWriter(ms_outbuf2);

            bw_o.Write(map3_signature);
            bw_o.Write(Global.VERSIONINFO.MAPVERSION);



            bw.Write(Helper.StringToPaddedByteArray(map.FormalName, 256));
            bw.Write(Helper.StringToPaddedByteArray(vspname, 256));
            bw.Write(Helper.StringToPaddedByteArray(map.MusicFileName, 256));
            bw.Write(Helper.StringToPaddedByteArray(map.RenderString, 256));
            bw.Write(Helper.StringToPaddedByteArray(map.AutoExecEvent, 256));


            bw.Write((short)map.PlayerStartX);
            bw.Write((short)map.PlayerStartY);


            int special_count = 0;

            foreach (MapLayer ml in map.Layers)
            {
                if (ml.type != LayerType.Tile)
                {
                    special_count++;
                }
            }
            bw.Write(map.Layers.Count - special_count);

            foreach (MapLayer ml in map.Layers)
            {
                if (ml.type != LayerType.Tile)
                {
                    continue;
                }
                bw.Write(Helper.StringToPaddedByteArray(ml.name, 256));
                bw.Write(ml.parallaxInfo.MultipleX);
                bw.Write(ml.parallaxInfo.MultipleY);
                bw.Write((short)ml.Width);
                bw.Write((short)ml.Height);
                bw.Write((byte)ml.Translucency);

                fixed(short *ptr = ml.Data)
                {
                    byte[] zdata = ZLIB.Encode((byte *)ptr, ml.Data.Length * 2);
                    bw.Write(ml.Data.Length * 2);
                    bw.Write(zdata.Length);
                    bw.Write(zdata);
                }
            }

            MapLayer zl = map.ZoneLayer, ol = map.ObsLayer;

            byte[] obsdata = new byte[ol.Data.Length];
            for (int j = 0; j < ol.Data.Length; j++)
            {
                obsdata[j] = (byte)ol.Data[j];


                fixed(byte *ptr = obsdata)
                {
                    byte[] zdata = ZLIB.Encode(ptr, obsdata.Length);
                    bw.Write(obsdata.Length);
                    bw.Write(zdata.Length);
                    bw.Write(zdata);
                }

                fixed(short *ptr = zl.Data)
                {
                    byte[] zdata = ZLIB.Encode((byte *)ptr, zl.Data.Length * 2);
                    bw.Write(zl.Data.Length * 2);
                    bw.Write(zdata.Length);
                    bw.Write(zdata);
                }

                bw.Write(map.Zones.Count);
                foreach (MapZone mz in map.Zones)
                {
                    bw.Write(Helper.StringToPaddedByteArray(mz.Name, 256));
                    bw.Write(Helper.StringToPaddedByteArray(mz.PlayerScript, 256));
                    //				bw.Write(Helper.StringToPaddedByteArray(mz.EntityScript,256));
                    bw.Write((byte)mz.Rate);
                    bw.Write((byte)mz.Delay);
                    bw.Write((byte)mz.AdjAct);
                }


                bw.Write(map.Entities.Count);
                foreach (MapEntity me in map.Entities)
                {
                    bw.Write((short)me.TileX);
                    bw.Write((short)me.TileY);
                    bw.Write((byte)me.Facing);
                    bw.Write((byte)me.ObeyObstruction);
                    bw.Write((byte)me.IsObstruction);
                    bw.Write((byte)me.AutoFace);
                    bw.Write((short)me.Speed);
                    bw.Write((byte)me.ActivationMode);
                    bw.Write((byte)me.MoveType);
                    bw.Write((short)me.WanderRectangle.x0);
                    bw.Write((short)me.WanderRectangle.y0);
                    bw.Write((short)me.WanderRectangle.x1);
                    bw.Write((short)me.WanderRectangle.y1);
                    bw.Write((short)me.WanderDelay);
                    bw.Write((int)0);//expand
                    bw.Write(Helper.StringToPaddedByteArray(me.MoveScript, 256));
                    bw.Write(Helper.StringToPaddedByteArray(me.ChrName, 256));
                    bw.Write(Helper.StringToPaddedByteArray(me.Description, 256));
                    bw.Write(Helper.StringToPaddedByteArray(me.onActivate, 256));
                }


                bw_o.Write((int)14 + (int)ms_outbuf2.Length);
                bw.Close();
                bw_o.Close();
                bw = new BinaryWriter(fs);
                bw.Write(ms_outbuf.ToArray());
                bw.Write(ms_outbuf2.ToArray());

                //write number of compiled vc functions
                bw.Write((int)0);

                bw.Close();
                return(0);
        }
コード例 #30
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public void MoveUp(MapLayer ml)
 {
     if (ml.type == LayerType.Obs || ml.type == LayerType.Zone)
         return;
     int idx = Layers.IndexOf(ml);
     if (idx == 0)
         return;
     Layers[idx] = Layers[idx - 1];
     Layers[idx - 1] = ml;
 }
コード例 #31
0
        public unsafe static Map ReadMap3(FileInfo fi)
        {
            byte[] m3s = new byte[] { (byte)'V', (byte)'3', (byte)'M', (byte)'A', (byte)'P', (byte)0 };

            FileStream   fs = fi.OpenRead();
            BinaryReader br = new BinaryReader(fs);

            Map map = new Map();

            map.FileOnDisk = fi;

            //			Directory.SetCurrentDirectory(map.FileOnDisk.Directory.FullName);


            byte[] sig = br.ReadBytes(m3s.Length);
            for (int i = 0; i < m3s.Length; i++)
            {
                if (sig[i] != m3s[i])
                {
                    return(null);
                }
            }

            int version = br.ReadInt32();
            int vcofs   = br.ReadInt32();

            byte[] formal       = br.ReadBytes(256);
            byte[] vspname      = br.ReadBytes(256);
            byte[] musicname    = br.ReadBytes(256);
            byte[] renderstring = br.ReadBytes(256);
            byte[] aexec        = br.ReadBytes(256);

            string   vspf = Helper.BytesToString(vspname);
            FileInfo vspfile;

            try {
                vspfile = new FileInfo(vspf);
            } catch (ArgumentException) {
                throw new Exception("VSP file is inaccessible. Requested file was '" + vspf + "'");
            }
            if (!vspfile.Exists)
            {
                System.Windows.Forms.DialogResult dr = System.Windows.Forms.MessageBox.Show("Unable to load requested VSP file.  Create a blank vsp?", "Load Error", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Information);
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    map.vsp = new Vsp24();
                }
                else if (dr == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(null);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                map.vsp = ReadVsp(vspfile.FullName);
            }

            map.FormalName    = Helper.BytesToString(formal);
            map.MusicFileName = Helper.BytesToString(musicname);
            //map.RenderString = Helper.BytesToString(renderstring);
            string rs = Helper.BytesToString(renderstring);

            map.AutoExecEvent = Helper.BytesToString(aexec);

            map.PlayerStartX = br.ReadInt16();
            map.PlayerStartY = br.ReadInt16();

            int layercount = br.ReadInt32();

            for (int i = 0; i < layercount; i++)
            {
                MapLayer ml = new MapLayer(map);
                ml.name                   = Helper.BytesToString(br.ReadBytes(256));
                ml.type                   = LayerType.Tile;
                ml.parallaxInfo           = new ParallaxInfo();
                ml.parallaxInfo.MultipleX = br.ReadDouble();
                ml.parallaxInfo.MultipleY = br.ReadDouble();
                int w = br.ReadInt16();
                int h = br.ReadInt16();
                ml.size(w, h);
                ml.Translucency = br.ReadByte();
                int len  = br.ReadInt32();
                int zlen = br.ReadInt32();
                ml.Data = ZLIB.DecodeShorts(br.ReadBytes(zlen), len);

                map.Layers.Add(ml);
            }

            MapLayer ol = new MapLayer(map);

            ol.type = LayerType.Obs;
            ol.name = "Obstructions";
            ol.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            int ol_lenn = br.ReadInt32();
            int ol_len  = br.ReadInt32();

            byte[] obsdata = ZLIB.Decode(br.ReadBytes(ol_len), ol_lenn);
            for (int i = 0; i < obsdata.Length; i++)
            {
                ol.Data[i] = obsdata[i];
            }
            map.ObsLayer = ol;


            int      zl_lenn = br.ReadInt32();
            int      zl_len  = br.ReadInt32();
            MapLayer zl      = new MapLayer(map);

            zl.type = LayerType.Zone;
            zl.name = "Zones";
            zl.size(((MapLayer)map.Layers[0]).Width, ((MapLayer)map.Layers[0]).Height);
            zl.Data       = ZLIB.DecodeShorts(br.ReadBytes(zl_len), zl_lenn);
            map.ZoneLayer = zl;


            MapLayer el = new MapLayer(map);

            el.type      = LayerType.Entity;
            el.name      = "Entities";
            map.EntLayer = el;
            map.Layers.Add(el);

            MapLayerSpecial rl = new MapLayerSpecial(map);

            rl.type = LayerType.Special_Retrace;


            map.Layers.Add(rl);
            map.Layers.Add(ol);
            map.Layers.Add(zl);


            int zonecount = br.ReadInt32();

            for (int i = 0; i < zonecount; i++)
            {
                MapZone mz      = new MapZone();
                byte[]  zname   = br.ReadBytes(256);
                byte[]  pscript = br.ReadBytes(256);
                //				byte[] escript = br.ReadBytes(256);
                mz.Name         = Helper.BytesToString(zname);
                mz.PlayerScript = Helper.BytesToString(pscript);
                //				mz.EntityScript = Helper.BytesToString(escript);
                mz.Rate   = br.ReadByte();
                mz.Delay  = br.ReadByte();
                mz.AdjAct = br.ReadByte();
                mz.ID     = i;
                map.Zones.Add(mz);
            }
            if (zonecount == 0)
            {
                MapZone mz = new MapZone();
                mz.ID   = 0;
                mz.Name = "NULL_ZONE";
                map.Zones.Add(mz);
            }

            int entcount = br.ReadInt32();

            for (int i = 0; i < entcount; i++)
            {
                MapEntity me = new MapEntity();
                me.TileX  = br.ReadInt16();
                me.TileY  = br.ReadInt16();
                me.Facing = br.ReadByte();

                me.ObeyObstruction = br.ReadByte();
                me.IsObstruction   = br.ReadByte();
                me.AutoFace        = br.ReadByte();
                me.Speed           = br.ReadInt16();
                me.ActivationMode  = br.ReadByte();

                me.MoveType           = br.ReadByte();
                me.WanderRectangle.x0 = br.ReadInt16();
                me.WanderRectangle.y0 = br.ReadInt16();
                me.WanderRectangle.x1 = br.ReadInt16();
                me.WanderRectangle.y1 = br.ReadInt16();
                me.WanderDelay        = br.ReadInt16();

                int expand = br.ReadInt32();

                me.MoveScript  = Helper.BytesToString(br.ReadBytes(256));
                me.ChrName     = Helper.BytesToString(br.ReadBytes(256));
                me.Description = Helper.BytesToString(br.ReadBytes(256));
                me.onActivate  = Helper.BytesToString(br.ReadBytes(256));
                me.ID          = map.Entities.Add(me);
            }
            br.Close();
            string rs2 = "";

            if (version == 1)
            {
                foreach (char c in rs)
                {
                    if (rs2.Length != 0)
                    {
                        rs2 += ",";
                    }
                    rs2 += c;
                }
                map.RenderString = rs2;
            }
            else
            {
                map.RenderString = rs;
            }
            return(map);
        }
コード例 #32
0
ファイル: Map.cs プロジェクト: zeromus/maped3
        public void AddLayer(MapLayer ml)
        {
            LayerState ls = new LayerState();

            if (ml.HLine != 0) ls.drawMode = LayerState.DrawMode.Hline;
            else ls.drawMode = LayerState.DrawMode.None;
            ls.bRender = true;
            Layers.Add(ls);
        }
コード例 #33
0
ファイル: mainWindow.cs プロジェクト: mcgrue/maped3
 public void lpAddLayer(MapLayer ml, bool IsRendered, bool IsWrite, int layer)
 {
     LPanel lw = new LPanel(lPanel, ml, IsRendered, IsWrite, layer);
     lwLayers.Add(lw);
     lPanel.Controls.Add(lw);
     lPanel.SetControlLayouts();
 }
コード例 #34
0
ファイル: Map.cs プロジェクト: zeromus/maped3
 public void RemoveLayer(MapLayer ml)
 {
     LayerState lsr = null;
     foreach (LayerState ls in Layers)
     {
         if (ls.mlayer == ml)
             lsr = ls;
     }
     if (lsr != null)
         Layers.Remove(lsr);
 }
コード例 #35
0
ファイル: mainWindow.cs プロジェクト: mcgrue/maped3
 public void lpUpdate(Map map, MapLayer select)
 {
     foreach (LPanel lw in lwLayers)
     {
         lw.Dispose();
     }
     lwLayers.Clear();
     for (int i = 0; i < map.RenderManager.Layers.Count; i++)
     {
         MapLayer ml = (MapLayer)map.RenderManager.Layers[i];
         lpAddLayer(ml, true, (ml == select), i);
     }
     l_rstring.Text = Global.ActiveMap.RenderManager.ToRenderString();
     ui_update();
 }
コード例 #36
0
ファイル: LayerPropertiesWnd.cs プロジェクト: salviati/verge3
 public void init(MapLayer ml)
 {
     mlayer = ml;
     updateui();
 }
コード例 #37
0
ファイル: mainWindow.cs プロジェクト: mcgrue/maped3
        private unsafe void ImportTiles(bool repeat)
        {
            Vsp24 v = Global.ActiveMap.vsp;
            Vsp24 vsp = null;
            Bitmap bmp = null;

            int ic = 0;
            if (id.ISource == ImportSource.VSP)
            {
                if (!repeat)
                    if (openVspDialog.ShowDialog() != DialogResult.OK) return;
                vsp = InputOutput.ReadVsp(openVspDialog.FileName);
                if (vsp == null)
                {
                    Errors.Error("unable to load vsp");
                    return;
                }
            }
            else if (id.ISource == ImportSource.Image)
            {
                if (!repeat)
                    if (openImageDialog.ShowDialog() != DialogResult.OK) return;
                using (var tempbmp = new Bitmap(openImageDialog.FileName))
                    bmp = (Bitmap)tempbmp.Clone();
            }
            else if (id.ISource == ImportSource.Clipboard)
            {
                if (!WindowsClipboard.IsImage)
                {
                    Errors.Error("There is no image in the clipboard.");
                    return;
                }
                bmp = WindowsClipboard.getBitmap();
            }

            ArrayList tiles = new ArrayList();
            if (id.IDest == ImportDest.Tiles)
            {
                int tstart = 0;
                if (id.ISource == ImportSource.Image || id.ISource == ImportSource.Clipboard)
                {
                    tiles = v.ImportTiles(bmp, id.bPadding ? 1 : 0);
                }
                else
                {
                    tiles = v.GetTiles(vsp);
                }
                if (id.IMethod == ImportMethod.Append)
                {
                    tstart = v.Tiles.Count;
                    v.Tiles.AddRange(tiles);
                }
                else if (id.IMethod == ImportMethod.Insert)
                {
                    tstart = id.InsertAt >= tiles.Count ? tiles.Count - 1 : id.InsertAt;
                    v.Tiles.InsertRange(tstart, tiles);
                }
                else if (id.IMethod == ImportMethod.Replace)
                {
                    if (MessageBox.Show("Warning, the current tiles will be wiped and replaced with imported tiles!", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
                            == DialogResult.Cancel) goto ABORT;
                    v.Tiles.Clear();
                    v.Tiles.AddRange(tiles);
                    vspController.ResetView();
                    tstart = 0;
                }
                if (id.bAddLayer && (id.ISource == ImportSource.Image || id.ISource == ImportSource.Clipboard))
                {
                    int tw = bmp.Width / Global.TILE_SIZE;
                    int th = bmp.Height / Global.TILE_SIZE;

                    MapLayer mlz = new MapLayer(Global.ActiveMap);
                    mlz.type = LayerType.Tile;
                    mlz.size(tw, th);
                    mlz.name = "Imported Layer "; //"Layer " + (Global.ActiveMap.Layers.Count - 3);
                    mlz.parallaxInfo = new ParallaxInfo();
                    for (int ty = 0; ty < th; ty++)
                    {
                        for (int tx = 0; tx < tw; tx++)
                        {
                            mlz.Data[ty * tw + tx] = (short)(tstart + ((ty * tw) + tx));
                        }
                    }
                    Global.ActiveMap.AddLayer(mlz);
                    lpUpdate(Global.ActiveMap, mlz);
                }
            }
            else if (id.IDest == ImportDest.Obs)
            {
                if (id.ISource == ImportSource.Image || id.ISource == ImportSource.Clipboard)
                    tiles = v.ImportObstructionTiles(bmp, id.bPadding ? 1 : 0);
                else
                    tiles = v.ImportObstructionTiles(vsp);
                if (id.IMethod == ImportMethod.Append)
                    v.ObstructionTiles.AddRange(tiles);
                else if (id.IMethod == ImportMethod.Insert)
                {
                    v.ObstructionTiles.InsertRange(id.InsertAt >= tiles.Count ? tiles.Count - 1 : id.InsertAt, tiles);
                }
                else if (id.IMethod == ImportMethod.Replace)
                {
                    if (MessageBox.Show("Warning, the current obstruction tiles will be wiped and replaced with imported tiles!", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
                            == DialogResult.Cancel) goto ABORT;
                    v.ObstructionTiles.Clear();
                    v.ObstructionTiles.AddRange(tiles);
                    vspc_obs.ResetView();
                }
            }

            ic = tiles.Count;

            statusBar.Panels[0].Text = ic.ToString() + " tiles imported to VSP";

            miImportAgain.Enabled = true;

            ui_update();

               ABORT:
            if(bmp != null)
                bmp.Dispose();
        }
コード例 #38
0
ファイル: Global.cs プロジェクト: salviati/verge3
 public static bool IsBaseLayer(MapLayer ml)
 {
     return(Global.ActiveMap.Layers.IndexOf(ml) == 0);
 }
コード例 #39
0
ファイル: mapView.cs プロジェクト: jder/verge3
 void renderLayer(pr2.IRenderImage backBuffer, MapLayer mapLayer, int px, int py, bool drawZero)
 {
     switch (mapLayer.type) {
         case LayerType.Tile:
             renderTileLayer(backBuffer, mapLayer, ParentMap.vsp, px, py, drawZero);
             break;
         case LayerType.Zone:
             renderZoneLayer(backBuffer, mapLayer, px, py);
             break;
         case LayerType.Obs:
             renderObstructionLayer(backBuffer, mapLayer, px, py);
             break;
         default:
             break;
     }
 }
コード例 #40
0
ファイル: LayerPropertiesWnd.cs プロジェクト: zeromus/maped3
 public void init(MapLayer ml)
 {
     mlayer = ml;
     updateui();
 }
コード例 #41
0
ファイル: mapView.cs プロジェクト: jder/verge3
        private void renderTileLayer(pr2.IRenderImage backBuffer, MapLayer layer, Vsp24 vsp, int px, int py, bool drawZero)
        {
            int mtx = px / 16;
            int mty = py / 16;
            int mtox = px & 15;
            int mtoy = py & 15;

            //we add 2; one for the case where we are scrolled a little bit
            //(and so parts of two tiles are drawn instead of one complete)
            //and one for the case where the screen is a funny size and a remainder bit is shown
            int tw = backBuffer.Width / 16 + 2;
            int th = backBuffer.Height / 16 + 2;

            int layerWidth = layer.Width;
            int layerHeight = layer.Height;
            int cpx = -mtox;
            int cpy = -mtoy;

            tw = System.Math.Min(tw, layerWidth - mtx);
            th = System.Math.Min(th, layerHeight - mty);

            int tp;
            int tile;
            int xmin = -mtox;
            int xmax = xmin + tw * 16;

            short[] tileMap = layer.Data;
            if (Global.RenderOptions.bTranslucentEffects)
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.renderAlpha(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, 100 - layer.Translucency, false);
                        }
                    }
                }
            }
            else
            {
                for (int ty = 0; ty < th; ty++, cpy += 16)
                {
                    tp = (ty + mty) * layerWidth + mtx;
                    for (cpx = xmin; cpx < xmax; cpx += 16)
                    {
                        tile = tileMap[tp++];
                        if (Global.RenderOptions.bAnimate)
                        {
                            tile = Global.FrameCalc.getframe(tile);
                        }

                        if (drawZero || tile != 0 && tile < vsp.tileCount)
                        {
                            Render.render(backBuffer, cpx, cpy, vsp.GetTile(tile).Image, false);
                        }
                    }
                }
            }
        }
コード例 #42
0
ファイル: NewMapWnd.cs プロジェクト: salviati/verge3
        public Map CreateMap()
        {
            Map  m       = new Map();
            int  l_count = (int)n_layers.Value;
            int  l_w     = (int)n_w.Value;
            int  l_h     = (int)n_h.Value;
            bool bNewvsp = rb_new.Checked;

            for (int i = 0; i < l_count; i++)
            {
                MapLayer ml = new MapLayer(m);
                ml.size(l_w, l_h);
                ml.name         = "Layer " + i;
                ml.type         = LayerType.Tile;
                ml.parallaxInfo = new ParallaxInfo();
                m.Layers.Add(ml);
            }
            MapLayer zl = new MapLayer(m);

            zl.type = LayerType.Zone;
            zl.name = "Zones";
            zl.size(l_w, l_h);

            m.ZoneLayer = zl;

            MapLayer ol = new MapLayer(m);

            ol.type = LayerType.Obs;
            ol.name = "Obstructions";
            ol.size(l_w, l_h);
            m.ObsLayer = ol;



            MapLayer el = new MapLayer(m);

            el.type = LayerType.Entity;
            el.name = "Entities";
            MapLayerSpecial rl = new MapLayerSpecial(m);

            rl.type = LayerType.Special_Retrace;


            m.Layers.Add(rl);
            m.Layers.Add(el);
            m.Layers.Add(ol);
            m.Layers.Add(zl);

            m.EntLayer = el;
            if (bNewvsp)
            {
                Vsp24 v = new Vsp24();

                //v.AddTiles(100);
                v.Tiles.AddRange(v.GetTiles(100));
                m.vsp = v;
            }
            else
            {
                Vsp24 v = InputOutput.ReadVsp(t_vspfile.Text);
                if (v == null)
                {
                    Errors.Error("Warning", "An error occured when attempting to load the vsp file.  A blank VSP has been created.");
                    v = new Vsp24();

                    v.Tiles.Add(v.GetTiles(100));
                    m.vsp = v;
                }
                else
                {
                    m.vsp = v;
                }
            }

            MapZone mz = new MapZone();

            mz.ID   = 0;
            mz.Name = "NULL_ZONE";
            m.Zones.Add(mz);


            m.Init();
            m.RenderString = "";
            return(m);
        }
コード例 #43
0
ファイル: NewMapWnd.cs プロジェクト: zeromus/maped3
        public Map CreateMap()
        {
            Map m = new Map();
            int l_count = (int)n_layers.Value;
            int l_w = (int)n_w.Value;
            int l_h = (int)n_h.Value;
            bool bNewvsp = rb_new.Checked;
            for(int i=0;i<l_count;i++)
            {
                MapLayer ml = new MapLayer(m);
                ml.size(l_w,l_h);
                ml.name = "Layer " + i;
                ml.type = LayerType.Tile;
                ml.parallaxInfo = new ParallaxInfo();
                m.Layers.Add(ml);
            }
            MapLayer zl = new MapLayer(m);
            zl.type = LayerType.Zone;
            zl.name = "Zones";
            zl.size(l_w,l_h);

            m.ZoneLayer=zl;

            MapLayer ol = new MapLayer(m);
            ol.type = LayerType.Obs;
            ol.name = "Obstructions";
            ol.size(l_w,l_h);
            m.ObsLayer = ol;

            MapLayer el = new MapLayer(m);
            el.type = LayerType.Entity;
            el.name = "Entities";
            MapLayerSpecial rl = new MapLayerSpecial(m);
            rl.type=LayerType.Special_Retrace;

            m.Layers.Add(rl);
            m.Layers.Add(el);
            m.Layers.Add(ol);
            m.Layers.Add(zl);

            m.EntLayer = el;
            if(bNewvsp)
            {
                Vsp24 v = new Vsp24();

                //v.AddTiles(100);
                v.Tiles.AddRange(v.GetTiles(100));
                m.vsp = v;

            }
            else
            {
                Vsp24 v = InputOutput.ReadVsp(t_vspfile.Text);
                if(v==null)
                {
                    Errors.Error("Warning", "An error occured when attempting to load the vsp file.  A blank VSP has been created.");
                    v = new Vsp24();

                    v.Tiles.Add(v.GetTiles(100));
                    m.vsp = v;
                }
                else
                    m.vsp = v;
            }

            MapZone mz = new MapZone();
            mz.ID = 0;
            mz.Name = "NULL_ZONE";
            m.Zones.Add(mz);

            m.Init();
            m.RenderString = "";
            return m;
        }
コード例 #44
0
 public void ModifyTile(MapLayer ml, int x, int y, int newtile)
 {
     ml.setTile(x, y, newtile);
 }