예제 #1
0
            public static CharInfo Parse(string html)
            {
                CharInfo i = new CharInfo();
                try
                {
                    i.Name = Match(html, @"Name:</td><td>([^<]*)\s");
                    i.Sex = Match(html, @"Sex:</td><td>([^<]*)</td>");
                    i.Profession = Match(html, @"Profession:</td><td>([^<]*)</td>");
                    i.Level = int.Parse(Match(html, @"Level:</td><td>([^<]*)</td>"));
                    i.World = Match(html, @"World:</td><td>([^<]*)<\/td>");
                    i.Residence = Match(html, @"Residence:</td><td>([^<]*)</td>");
                    string guildDetails = Match(html, @"membership:</td><td>(.*?)</td>");
                    i.GuildTitle = Match(guildDetails, @"(.*) of the <a href");
                    i.GuildName = Match(guildDetails, @">([^<]*)</a>");

                    // Requires more complex parsing
                    //i.LastLogin = DateTime.Parse(HttpUtility.HtmlDecode(Regex.Match(html, @"Last Login:<\/TD><TD>([^<]*)<\/TD>").Groups[1].Value));
                    i.Comment = Match(html, @"Comment:</td><td>(.*?)</td>").Replace("<br />", string.Empty);
                    i.AccountStatus = Match(html, @"Account&#160;Status:</td><td>([^<]*)</td>");


                    i.RealName = Match(html, @"Real name:</td><td>([^<]*)</td>");
                    i.Location = Match(html, @"Location:</td><td>([^<]*)</td>");
                    // Requires more complex parsing
                    //i.Created = DateTime.Parse(HttpUtility.HtmlDecode(Regex.Match(html, @"Created:<\/TD><TD>([^<]*)<\/TD>").Groups[1].Value));
                    MatchCollection deaths = Regex.Matches(html, @"<tr bgcolor=(?:#D4C0A1|#F1E0C6)><td width=25%>(.*?)?</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*)", RegexOptions.Singleline);
                    // TODO finish this!
                }
                catch
                {
                    return i;
                }
                return i;
            }
예제 #2
0
 // Methods
 internal TextUndoOperation(TextAction action, int index, CharInfo[] infos, ItopVector.DrawArea.TextOperation textoperation)
 {
     this.Action = action;
     this.CharIndex = index;
     this.CharInfos = infos;
     this.TextOperation = textoperation;
 }
예제 #3
0
        internal void OnCreateChar(CMSG_CREATECHARACTER cpkt)
        {
            //HELPER VARIABLES
            CharInfo info = new CharInfo();
            ServerInfo2 info2;
            LoginSession session;

            //START CREATING THE CHARACTER ON OUR SERVER
            if (LoginSessionHandler.sessions.TryGetValue(cpkt.SessionId, out session))
                if (ServerManager2.Instance.server.TryGetValue(session.World, out info2))
                {
                    SMSG_INTERNAL_CHARACTERCREATE cpkt2 = new SMSG_INTERNAL_CHARACTERCREATE();
                    cpkt2.CharacterId = session.playerid;
                    cpkt2.Name = cpkt.Name;
                    cpkt2.Eye = cpkt.Eye;
                    cpkt2.EyeBrowse = cpkt.EyeBrowse;
                    cpkt2.EyeColor = cpkt.EyeColor;
                    cpkt2.Hair = cpkt.Hair;
                    cpkt2.HairColor = cpkt.HairColor;
                    cpkt2.WeaponAffix = cpkt.WeaponAffix;
                    cpkt2.WeaponName = cpkt.WeaponName;
                    cpkt2.SessionId = cpkt.SessionId;

                    info.cexp = 0;
                    info.charId = 0;
                    info.gender = (byte)session.Gender;
                    info.name = cpkt.Name;
                    info.job = 1;
                    session.PendingCharInfo = info;
                    info2.client.SM_CHARACTER_CREATE(cpkt2);
                }
        }
예제 #4
0
 public void GetCharInfo(out CharInfo info)
 {
     info = new CharInfo();
     info.charId = BitConverter.ToUInt32(this.data, offset);
     info.name = UnicodeEncoding.Unicode.GetString(this.data, offset + 4, 32).TrimEnd('\0');
     info.cexp = BitConverter.ToUInt32(this.data, offset + 39);
     info.job = this.data[offset + 43];
     offset += 46;
 }
		public Console2(short width, short height, ConsoleColor backgroundColor)
		{
			_width = width;
			_height = height;
			_buffer = new CharInfo[width * height];

			for (int i = 0; i < _buffer.Length; i++)
			{
				_buffer[i] = new CharInfo((byte)' ', ConsoleColor.Black, backgroundColor);
			}

			InitConsole(width, height);
			_handle = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
			Clear();
		}
예제 #6
0
        public List<CharInfo> GetDbObjectList()
        {
            List<CharInfo> list = new List<CharInfo>();
            foreach(var pair in dictionary)
                {
                   foreach(Character c in pair.Value){
                       CharInfo ci = new CharInfo();
                       ci.name = c.name;
                       ci.guild = c.guild;
                       ci.realm = c.realm;
                       ci.role = c.role;
                       ci.itemLevel = c.itemLevel;
                        list.Add(ci);
                   }

                }

            return list;
        }
예제 #7
0
        public FastConsole(short width, short height)
        {
            Console.SetWindowSize(width, height);
            Console.SetBufferSize(width, height);

            width_ = width;
            height_ = height;
            buffer_ = new CharInfo[width*height];
            invert_ = new bool[width*height];
            for (int i = 0; i < width * height; i++)
            {
                buffer_[i] = new CharInfo() {Attributes = 7};
                invert_[i] = false;
            }

            handle_ = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
             if (handle_.IsInvalid)
                 throw new Exception("Error opening console.");

            Thread th = new Thread(Refresh);
            th.Start();
        }
예제 #8
0
        public void Update(CharInfo pck)
        {
            this.X = pck.X;
            this.Y = pck.Y;
            this.Z = pck.Z;
            this.ObjectID = pck.ObjectID;
            this.Name = pck.VisibleName;
            this.Title = pck.VisibleTitle;
            this.ClassID = pck.ClassID;
            //if (!this.LevelStrict)
                ;//this.Level = Info

            this.CurHP = pck.CurHP;
            this.MaxHP = pck.MaxHP;
            this.CurMP = pck.CurMP;
            this.MaxMP = pck.MaxMP;
            this.Speed = (int)Math.Round((pck.IsRun == 1 ? pck.RunSpeed : pck.WalkSpeed) * pck.MoveMult);
            this.CastSpeed = pck.CastSpeed;
            this.AtkSpeed = pck.AtkSpeed;
            this.Karma = pck.Karma;
            this.Noble = pck.IsNoble == 1;
            this.Hero = pck.IsHero == 1;
            this.CurCP = pck.CurCP;
        }
예제 #9
0
            public char addCharacter(int index, Image image)
            {
                Bitmap bm = (Bitmap)image;
                BitmapData bd = bm.LockBits(
                    new Rectangle(new Point(0, 0), bm.Size),
                    System.Drawing.Imaging.ImageLockMode.ReadOnly,
                    bm.PixelFormat);
                int bytes  = Math.Abs(bd.Stride) * bm.Height;
                byte[] bmBytes = new byte[bytes];
                System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, bmBytes, 0, bytes);
                bm.UnlockBits(bd);

                if (image.PixelFormat != PixelFormat.Format32bppArgb)
                {
                    int sBpp = (Image.GetPixelFormatSize(bm.PixelFormat) / 8);
                    int stride = Math.Abs(bd.Stride);
                    byte[] bmBytes2 = new byte[bytes * 4 / sBpp];
                    for (int i = 0; i < bd.Height; i++)
                        for (int ii = 0; ii < bd.Width; ii++)
                        {
                            switch (image.PixelFormat)
                            {
                                case PixelFormat.Format8bppIndexed:
                                    int colorIndex = bmBytes[i * stride + ii * sBpp];
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 0] = bm.Palette.Entries[colorIndex].B;  // b
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 1] = bm.Palette.Entries[colorIndex].G;  // g
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 2] = bm.Palette.Entries[colorIndex].R;  // r
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 3] = bm.Palette.Entries[colorIndex].A;  // a
                                    break;
                                case PixelFormat.Format24bppRgb:
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 0] = bmBytes[i * stride + ii * sBpp + 0];  // b
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 1] = bmBytes[i * stride + ii * sBpp + 1];  // g
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 2] = bmBytes[i * stride + ii * sBpp + 2];  // r
                                    bmBytes2[(i * bm.Width * 4) + ii * 4 + 3] = 0xff;  // a
                                    break;
                                default:
                                    MessageBox.Show(image.PixelFormat.ToString() + " format not supported!");
                                    return '\u0000';

                            }
                        }
                    bmBytes = bmBytes2;
                    bytes = bm.Width * 4 * bm.Height;
                }

                #region Create a compressed image from image data
                List<byte> data = new List<byte>();
                // Not the same as Color.White due to Color.Name being different
                Color color = Color.FromArgb( 0xff, 0xff, 0xff, 0xff );

                for (int i = 0; i < bytes / 4; i++)
                {
                    byte run = 1;
                    byte blue = bmBytes[i * 4 + 0];
                    byte green = bmBytes[i * 4 + 1];
                    byte red = bmBytes[i * 4 + 2];
                    byte alpha = bmBytes[i * 4 + 3];
                    if (alpha == 0)
                    {
                        while ( (i + run) < bytes / 4 && bmBytes[(i + run) * 4 + 3] == 0 && run < 0x3F)
                            run++;
                        data.Add(run);
                    }
                    else
                    {
                        Color temp = Color.FromArgb(alpha, red, green, blue);
                        if (temp != color)
                        {
                            // Add color change (Remember this auto-draws one pixel as well
                            data.Add((byte)0x00);
                            data.Add((byte)(((alpha * 15 / 255) << 4) + (red * 15 / 255)));
                            data.Add((byte)(((green * 15 / 255) << 4) + (blue * 15 / 255)));
                            color = temp;
                        }
                        else
                        {
                            while ((i + run) < bytes / 4
                                && (Math.Abs(bmBytes[i * 4 + 0] - bmBytes[(i + run) * 4 + 0]) < 5)
                                && (Math.Abs(bmBytes[i * 4 + 1] - bmBytes[(i + run) * 4 + 1]) < 5)
                                && (Math.Abs(bmBytes[i * 4 + 2] - bmBytes[(i + run) * 4 + 2]) < 5)
                                && (Math.Abs(bmBytes[i * 4 + 3] - bmBytes[(i + run) * 4 + 3]) < 5)
                                && run < 0x3F)
                                run++;
                            data.Add((byte)(0x40 + run));
                        }
                    }
                    i += run - 1;
                }
                #endregion

                // Check if compressed size is too large to be imported
                if (data.Count > short.MaxValue)
                {
                    MessageBox.Show("Compressed image size must not be larger than " + short.MaxValue.ToString("n0") + " bytes\nCurrent image compresses to " + data.Count.ToString("n0") + " bytes");
                    return '\u0000';
                }

                // For Index Placements
                CharInfo ci;
                try
                {
                    ci = charInfos[index];
                    if (ci.Index != index)
                    {
                        ci = new CharInfo(index);
                        charInfos.Add(ci);
                    }
                }
                catch
                {
                    ci = new CharInfo(index);
                    charInfos.Add(ci);
                }
                ci.Width = (short)image.Width;
                ci.Height = (short)image.Height;
                ci.DisplayWidth = (short)(ci.Width - 2);
                ci.Unk1 = charInfos[0].Unk1;           // Seems to be same throughout file
                ci.Offset = (int)ms.Length + 0x10;     // New data will be at end of file + one charInfo entry
                ids[ci.Index].cInfo = ci;
                ci.IdClasses.Add(ids[ci.Index]);
                ci.CompressedImageData = data.ToArray();
                ci.Size = (short)ci.CompressedImageData.Length;
                return (char)ci.Index;
            }
예제 #10
0
		extern static bool WriteConsoleOutput (IntPtr handle, CharInfo [] buffer, Coord bsize, Coord bpos, ref SmallRect region);
		static bool WriteConsoleOutput (IntPtr handle, CharInfo [] buffer, Coord bsize, Coord bpos, ref SmallRect region)
		{
			throw new System.NotImplementedException();
		}
예제 #12
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;

            bool isTimeToQuit = false;

            short xLoc = 43;
            short yLoc = 5;

            SafeFileHandle h = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);

            CharInfo[] buf = new CharInfo[80 * 25];
            SmallRect rect = new SmallRect() { Left = 0, Top = 0, Right = 80, Bottom = 25 };

            ConsoleKeyInfo cki = new ConsoleKeyInfo();

            Random r = new Random();
            int dir = r.Next(1, 4);

            while (isTimeToQuit == false)
            {
                if (!h.IsInvalid)
                {
                    for (int i = 0; i < buf.Length; ++i)
                    {
                        buf[i].Attributes = 7;
                        buf[i].Char.AsciiChar = 46;
                        if (i == (yLoc*80)+xLoc)
                        {
                            buf[i].Attributes = 7;
                            buf[i].Char.AsciiChar = 64;
                        }
                    }
                    if (Console.KeyAvailable == true)
                    {
                        cki = Console.ReadKey(true);
                        switch (cki.Key)
                        {
                            case ConsoleKey.LeftArrow:
                                xLoc--;
                                if (xLoc <= 0)
                                    xLoc = 0;
                                break;
                            case ConsoleKey.RightArrow:
                                xLoc++;
                                if (xLoc >= 79)
                                    xLoc = 79;
                                break;
                            case ConsoleKey.UpArrow:
                                yLoc--;
                                if (yLoc <= 0)
                                    yLoc = 0;
                                break;
                            case ConsoleKey.DownArrow:
                                yLoc++;
                                if (yLoc >= 24)
                                    yLoc = 24;
                                break;
                            case ConsoleKey.Escape:
                                isTimeToQuit = true;
                                break;
                            default:
                                break;
                        }
                    }

                    bool b = WriteConsoleOutput(h, buf,
                        new Coord() { X = 80, Y = 25 },
                        new Coord() { X = 0, Y = 0 },
                        ref rect);

                }
            }
        }
예제 #13
0
            public static CharInfo Parse(string html)
            {
                CharInfo i = new CharInfo();

                if (html == null)
                    throw new ArgumentNullException("html");

                try
                {
                    i.Name = Tools.Match(html, @"Name:</td><td>([^<]*)\s");
                    i.Sex = Tools.Match(html, @"Sex:</td><td>([^<]*)</td>");
                    i.Profession = Tools.Match(html, @"Vocation:</td><td>([^<]*)</td>");
                    i.Level = int.Parse(Tools.Match(html, @"Level:</td><td>([^<]*)</td>"));
                    i.World = Tools.Match(html, @"World:</td><td>([^<]*)<\/td>");
                    i.Achievements = Tools.Match(html, @"Achievement Points:</nobr></td><td>([^<]*)</td>");
                    i.Residence = Tools.Match(html, @"Residence:</td><td>([^<]*)</td>");
                    string guildDetails = Tools.Match(html, @"membership:</td><td>(.*?)</td>");
                    i.GuildTitle = Tools.Match(guildDetails, @"(.*) of the <a href");
                    i.GuildName = Tools.Match(guildDetails, @">([^<]*)</a>");
                    i.LastLogin = HttpUtility.HtmlDecode(Regex.Match(html, @"Last login:</td><td>([^<]*)</td>").Groups[1].Value);
                    i.Comment = Tools.Match(html, @"Comment:</td><td>(.*?)</td>").Replace("<br />", string.Empty);
                    i.AccountStatus = Tools.Match(html, @"Account&#160;Status:</td><td>([^<]*)</td>");
                    //MatchCollection deaths = Regex.Matches(html, @"<tr bgcolor=(?:#D4C0A1|#F1E0C6)><td width=25%>(.*?)?</td><td>((?:Died|Killed) at Level ([^ ]*)|and) by (?:<[^>]*>)?([^<]*)", RegexOptions.Singleline);
                    //CharDeath deads = new CharDeath();
                    
                
                }
                catch(ArgumentNullException)
                {
                    return i;
                }
                return i;
            }
예제 #14
0
        /// <summary>
        /// Extract Bitmap from WAD.
        /// </summary>
        /// <param name="index">Lump index.</param>
        /// <param name="transparent">Replace blue color with alpha 0.</param>
        /// <returns>Returns Texture. Contains image and Mipmaps.</returns>
        /// <exception cref="TextureDimensionException"></exception>
        public Texture GetLumpImage(int index, bool transparent = false)
        {
            Texture retVal = null;

            if (index > -1 && index < LumpsInfo.Count)
            {
                byte type = LumpsInfo[index].Type;

                //0x40 - tempdecal.wad
                //0x42 - cached.wad
                //0x43 - normald wads
                //0x46 - fonts
                if (type == 0x40 || type == 0x42 || type == 0x43 || type == 0x46) //Supported types
                {
                    //Go to lump
                    binReader.BaseStream.Seek(LumpsInfo[index].Offset, SeekOrigin.Begin);

                    if (type == 0x40 || type == 0x43)
                    {
                        //Skip lump name
                        binReader.BaseStream.Seek(MaxNameLength, SeekOrigin.Current);
                    }

                    //Read texture size
                    uint width = binReader.ReadUInt32();
                    uint height = binReader.ReadUInt32();

                    if (width > MaxTextureWidth || height > MaxTextureHeight)
                        throw new TextureDimensionException("Texture width or height exceeds maximum size!");

                    if (width == 0 || height == 0)
                        throw new TextureDimensionException("Texture width and height must be larger than 0!");

                    //If QFont
                    if (type == 0x46)
                    {
                        //width = width * QCharWidth;
                        width = 256;
                        uint RowCount = binReader.ReadUInt32();
                        uint RowHeight = binReader.ReadUInt32();
                        CharInfo[] FontInfo = new CharInfo[QNumbOfGlyphs];
                        for (int i = 0; i < QNumbOfGlyphs; i++)
                        {
                            FontInfo[i].StartOffset = binReader.ReadUInt16();
                            FontInfo[i].CharWidth = binReader.ReadUInt16();
                        }

                    }

                    //Initialize bitmap
                    Bitmap bmp = new Bitmap((int)width, (int)height, PixelFormat.Format8bppIndexed);

                    //Read pixel offset, skip MIPMAPS offsets
                    if (type == 0x40 || type == 0x43)
                    {
                        //Not used, but needed
                        uint pixelOffset = binReader.ReadUInt32();

                        //Skip MIPMAPS offsets, not needed
                        binReader.BaseStream.Seek(12, SeekOrigin.Current);
                    }

                    //Read RAW pixels
                    uint pixelSize = width * height;
                    pixelsBlockPos = binReader.BaseStream.Position;
                    lastImageSize = pixelSize;
                    lastImageWidth = width;
                    byte[] pixels = pixels = binReader.ReadBytes((int)pixelSize);

                    //Read MIPMAPS
                    Texture.TextureMipmaps mipmaps = null;
                    if (type == 0x40 || type == 0x43)
                    {
                        mipmaps = new Texture.TextureMipmaps();
                        mipmaps.Mipmap1 = binReader.ReadBytes((int)((width / 2) * (height / 2)));
                        mipmaps.Mipmap2 = binReader.ReadBytes((int)((width / 4) * (height / 4)));
                        mipmaps.Mipmap3 = binReader.ReadBytes((int)((width / 8) * (height / 8)));
                    }

                    //Padding 2-bytes
                    binReader.BaseStream.Seek(2, SeekOrigin.Current);

                    //Prepare new palette for bitmap
                    ColorPalette pal = bmp.Palette;
                    palleteBlockPos = binReader.BaseStream.Position;

                    //Read palette bytes from file into array
                    byte[] palBytes = binReader.ReadBytes(MaxPaletteColors * 3);
                    for (int i = 0, j = 0; i < MaxPaletteColors; i++)
                    {
                        if (type == 0x40) //e.g.: tempdecal.wad
                        {
                            pal.Entries[i] = Color.FromArgb(i, i, i);
                        }
                        else
                        {
                            //Read palette entry RGB
                            pal.Entries[i] = Color.FromArgb(palBytes[j], palBytes[j + 1], palBytes[j + 2]);
                        }

                        //Check for transparent (blue) color
                        if (transparent && i == (MaxPaletteColors - 1) && LumpsInfo[index].Name.StartsWith("{"))
                        {
                            pal.Entries[i] = Color.FromArgb(0, pal.Entries[i]);
                        }
                        j += 3;
                    }
                    bmp.Palette = pal;

                    //Lock bitmap for pixel manipulation
                    BitmapData bmd = bmp.LockBits(new Rectangle(0, 0, (int)width, (int)height), System.Drawing.Imaging.ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
                    System.Runtime.InteropServices.Marshal.Copy(pixels, 0, bmd.Scan0, pixels.Length);
                    bmp.UnlockBits(bmd);

                    retVal = new Texture();
                    retVal.Image = bmp;
                    retVal.Mipmaps = mipmaps;
                }
                else
                {
                    throw new HLToolsUnsupportedFile("Unsupported type (0x" + LumpsInfo[index].Type.ToString("X") + ") of lump (texture) in WAD!");
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }

            return retVal;
        }
예제 #15
0
        public static Bitmap GetCharImage(int font, char c)
        {
            Bitmap charImage;

            if (stream == null)
            {
                Init();
            }

            stream = streamArray[font];
            reader = readerArray[font];

            int index = c;
            stream.Seek((long)(index * 4), SeekOrigin.Begin);
            int num2 = reader.ReadInt32();
            stream.Seek((long)num2, SeekOrigin.Begin);
            CharInfo info = new CharInfo();
            uniCharCache[index] = info;
            info.Kerning = reader.ReadByte();
            info.BaseLine = reader.ReadByte();
            info.Width = reader.ReadByte();
            info.Height = reader.ReadByte();
            int num3 = info.Height - info.BaseLine;
            if ((info.Width + info.Height) != 0)
            {
                charImage = new Bitmap((info.Width + (info.Kerning * 2)) + 2, (info.Height + info.BaseLine) + 2, PixelFormat.Format32bppArgb);
                Graphics graphics = Graphics.FromImage(charImage);
                graphics.Clear(Color.Red);
                graphics.Dispose();
                int height = info.Height - 1;
                for (int i = 0; i <= height; i++)
                {
                    int width = info.Width - 1;
                    for (int k = 0; k <= width; k++)
                    {
                        byte num6 = 0;
                        int num5 = k % 8;
                        if (num5 == 0)
                        {
                            num6 = reader.ReadByte();
                        }
                        if ((((byte)(num6 >> ((7 - num5) & 7))) & 1) == 1)
                        {
                            charImage.SetPixel((k + info.Kerning) + 1, (i + info.BaseLine) + 1, Color.LightGray);
                        }
                    }
                }
                int num11 = charImage.Width - 1;
                for (int j = 0; j <= num11; j++)
                {
                    int num10 = charImage.Height - 1;
                    for (int m = 0; m <= num10; m++)
                    {
                        if (charImage.GetPixel(j, m).ToArgb() == -65536)
                        {
                            bool flag = false;
                            if ((j < (charImage.Width - 1)) && (charImage.GetPixel(j + 1, m).ToArgb() == -2894893))
                            {
                                charImage.SetPixel(j, m, Color.Black);
                                flag = true;
                            }
                            if ((!flag && (j > 0)) && (charImage.GetPixel(j - 1, m).ToArgb() == -2894893))
                            {
                                charImage.SetPixel(j, m, Color.Black);
                                flag = true;
                            }
                            if ((!flag && (m < (charImage.Height - 1))) && (charImage.GetPixel(j, m + 1).ToArgb() == -2894893))
                            {
                                charImage.SetPixel(j, m, Color.Black);
                                flag = true;
                            }
                            if ((!flag && (m > 0)) && (charImage.GetPixel(j, m - 1).ToArgb() == -2894893))
                            {
                                charImage.SetPixel(j, m, Color.Black);
                            }
                        }
                    }
                }
            }
            else
            {
                charImage = new Bitmap(3, 1, PixelFormat.Format32bppArgb);
                charImage.MakeTransparent();
            }
            charImage.MakeTransparent(Color.Red);
            info.Cache = charImage;
            return charImage;
        }
예제 #16
0
            /// <summary>
            /// Loads the passed character data into a bitmap contained within a picturebox
            /// </summary>
            /// <param name="ci">The character info to load</param>
            /// <param name="decodeImage">True to decode image into bitmap readable data block</param>
            /// <returns></returns>
            private CharInfo loadCharInfo(CharInfo ci, bool decodeImage)
            {
                if (ci == null)
                    return null;

                ms.Position = ci.Offset;
                if (ci.CompressedImageData == null)
                {
                    ci.CompressedImageData = new byte[ci.Size];
                    ms.Read(ci.CompressedImageData, 0, ci.CompressedImageData.Length);
                }
                if (ci.ImageData == null && decodeImage)
                {
                    ci.decodeData();
                }
                return ci;
            }
예제 #17
0
        public void LoadChars()
        {
            var charInfos = new Dictionary<uint, CharInfo>();
            int blockSize = reader.ReadInt32();
            int read = 0;

            while (read < blockSize)
            {
                var charInfo = new CharInfo();

                charInfo.Id = reader.ReadUInt32();
                charInfo.X = reader.ReadUInt16();
                charInfo.Y = reader.ReadUInt16();
                charInfo.Width = reader.ReadUInt16();
                charInfo.Height = reader.ReadUInt16();
                charInfo.XOffset = reader.ReadInt16();
                charInfo.YOffset = reader.ReadInt16();
                charInfo.XAdvance = reader.ReadInt16();
                charInfo.Page = reader.ReadByte();
                charInfo.Channel = reader.ReadByte();

                charInfos.Add(charInfo.Id, charInfo);
                read += CharInfo.SizeOf;
            }

            info.CharInfos = charInfos;
        }
예제 #18
0
        /// <summary>
        /// Pass in a buffer to change the current buffer.
        /// </summary>
        /// <param name="b"></param>
        public void setBuf(CharInfo[] b)
        {
            if (b == null)
            {
                throw new System.ArgumentNullException();
            }

            buf = b;
        }
예제 #19
0
		public void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
					int targetLeft, int targetTop, Char sourceChar,
					ConsoleColor sourceForeColor, ConsoleColor sourceBackColor)
		{
			if (sourceForeColor < 0)
				throw new ArgumentException ("Cannot be less than 0.", "sourceForeColor");

			if (sourceBackColor < 0)
				throw new ArgumentException ("Cannot be less than 0.", "sourceBackColor");

			if (sourceWidth == 0 || sourceHeight == 0)
				return;

			ConsoleScreenBufferInfo info = new ConsoleScreenBufferInfo ();
			GetConsoleScreenBufferInfo (outputHandle, out info);
			CharInfo [] buffer = new CharInfo [sourceWidth * sourceHeight];
			Coord bsize = new Coord (sourceWidth, sourceHeight);
			Coord bpos = new Coord (0, 0);
			SmallRect region = new SmallRect (sourceLeft, sourceTop, sourceLeft + sourceWidth - 1, sourceTop + sourceHeight - 1);
			fixed (void *ptr = &buffer [0]) {
				if (!ReadConsoleOutput (outputHandle, ptr, bsize, bpos, ref region))
					throw new ArgumentException (String.Empty, "Cannot read from the specified coordinates.");
			}

			int written;
			short attr  = GetAttrForeground (0, sourceForeColor);
			attr  = GetAttrBackground (attr, sourceBackColor);
			bpos = new Coord (sourceLeft, sourceTop);
			for (int i = 0; i < sourceHeight; i++, bpos.Y++) {
				FillConsoleOutputCharacter (outputHandle, sourceChar, sourceWidth, bpos, out written);
				FillConsoleOutputAttribute (outputHandle, attr, sourceWidth, bpos, out written);
			}

			bpos = new Coord (0, 0);
			region = new SmallRect (targetLeft, targetTop, targetLeft + sourceWidth - 1, targetTop + sourceHeight - 1);
			if (!WriteConsoleOutput (outputHandle, buffer, bsize, bpos, ref region))
				throw new ArgumentException (String.Empty, "Cannot write to the specified coordinates.");
		}
예제 #20
0
		internal static extern bool WriteConsoleOutput(
			IntPtr hConsoleOutput,
			CharInfo[] lpBuffer,
			Coord dwBufferSize,
			Coord dwBufferCoord,
			ref SmallRect lpWriteRegion);
		private void DrawBuffer(CharInfo[] buffer, short x, short y, short width, short height)
		{
			var rect = new SmallRect {Left = x, Top = y, Right = (short) (x + width - 1), Bottom = (short) (y + height - 1)};
			WriteConsoleOutput(_handle, buffer, new Coord(width, height), new Coord(0, 0), ref rect);
		}
예제 #22
0
 public L2Character(CharInfo pck)
 {
     Update(pck);
 }
예제 #23
0
 public static extern bool WriteConsoleOutput(
   SafeFileHandle hConsoleOutput,
   CharInfo[] lpBuffer,
   Coord dwBufferSize,
   Coord dwBufferCoord,
   ref SmallRect lpWriteRegion);
예제 #24
0
            /// <summary>
            /// Loads a font file into memory, disposing of any previously loaded font first
            /// </summary>
            /// <param name="filename">The filename of the font to load</param>
            private void readFont(string filename)
            {
                try
                {
                    // Load the entrie file into a memory stream for quick access
                    FileStream fs = new FileStream(filename, FileMode.Open);
                    BinaryReader br = new BinaryReader(fs);
                    this.ms = new MemoryStream(br.ReadBytes((int)br.BaseStream.Length));
                    fs.Close();
                    br = new BinaryReader(ms);
                    br.BaseStream.Position = 0x020c;
                    int indexCount = br.ReadInt32();

                    #region Load UTF Table Entries
                    // Read individual character info for each Index entry
                    // Share any common UTF entries
                    for (int i = 0; i < indexCount; i++)
                    {
                        br.BaseStream.Position = 0x40400 + i * 0x10;
                        CharInfo cInfo = new CharInfo(i);
                        cInfo.Read(br);
                        charInfos.Add(cInfo);
                        br.BaseStream.Position = cInfo.Offset;
                        cInfo.CompressedImageData = br.ReadBytes(cInfo.Size);
                    }
                    #endregion

                    #region Load Index Table entries
                    // Read index table (4 bytes per entry)
                    for (int i = 0; i < ids.Length; i++)
                    {
                        br.BaseStream.Position = 0x400 + i * 4;
                        ids[i] = new idClass(br.ReadInt32());
                        ids[i].cInfo = charInfos[ids[i].index];
                        charInfoPos[ids[i].index] = charInfos[ids[i].index];
                        charInfos[ids[i].index].IdClasses.Add(ids[i]);
                    }
                    #endregion
                    _isLoaded = true;
                }
                catch
                {
                    _isLoaded = false;
                }
            }