예제 #1
0
        public BookPageInfo[] Copy()
        {
            BookPageInfo[] copy = new BookPageInfo[m_Pages.Length];

            for (int i = 0; i < copy.Length; ++i)
            {
                copy[i] = new BookPageInfo(m_Pages[i].Lines);
            }

            return(copy);
        }
예제 #2
0
        public BaseBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID)
        {
            m_Title    = title;
            m_Author   = author;
            m_Writable = writable;

            BookContent content = this.DefaultContent;

            if (content == null)
            {
                m_Pages = new BookPageInfo[pageCount];

                for (int i = 0; i < m_Pages.Length; ++i)
                {
                    m_Pages[i] = new BookPageInfo();
                }
            }
            else
            {
                m_Pages = content.Copy();
            }
        }
예제 #3
0
        public BookPageDetails(BaseBook book) : base(0x66)
        {
            EnsureCapacity(256);

            Stream.Write((int)book.Serial);
            Stream.Write((ushort)book.PagesCount);

            for (int i = 0; i < book.PagesCount; ++i)
            {
                BookPageInfo page = book.Pages[i];

                Stream.Write((ushort)(i + 1));
                Stream.Write((ushort)page.Lines.Length);

                for (int j = 0; j < page.Lines.Length; ++j)
                {
                    byte[] buffer = Utility.UTF8.GetBytes(page.Lines[j]);

                    Stream.Write(buffer, 0, buffer.Length);
                    Stream.Write((byte)0);
                }
            }
        }
예제 #4
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 4:
            {
                m_SecureLevel = (SecureLevel)reader.ReadInt();
                goto case 3;
            }

            case 3:
            case 2:
            {
                BookContent content = this.DefaultContent;

                SaveFlags flags = (SaveFlags)reader.ReadByte();

                if ((flags & SaveFlags.Title) != 0)
                {
                    m_Title = Utility.Intern(reader.ReadString());
                }
                else if (content != null)
                {
                    m_Title = content.Title;
                }

                if ((flags & SaveFlags.Author) != 0)
                {
                    m_Author = reader.ReadString();
                }
                else if (content != null)
                {
                    m_Author = content.Author;
                }

                m_Writable = (flags & SaveFlags.Writable) != 0;

                if ((flags & SaveFlags.Content) != 0)
                {
                    m_Pages = new BookPageInfo[reader.ReadEncodedInt()];

                    for (int i = 0; i < m_Pages.Length; ++i)
                    {
                        m_Pages[i] = new BookPageInfo(reader);
                    }
                }
                else
                {
                    if (content != null)
                    {
                        m_Pages = content.Copy();
                    }
                    else
                    {
                        m_Pages = new BookPageInfo[0];
                    }
                }

                break;
            }

            case 1:
            case 0:
            {
                m_Title    = reader.ReadString();
                m_Author   = reader.ReadString();
                m_Writable = reader.ReadBool();

                if (version == 0 || reader.ReadBool())
                {
                    m_Pages = new BookPageInfo[reader.ReadInt()];

                    for (int i = 0; i < m_Pages.Length; ++i)
                    {
                        m_Pages[i] = new BookPageInfo(reader);
                    }
                }
                else
                {
                    BookContent content = this.DefaultContent;

                    if (content != null)
                    {
                        m_Pages = content.Copy();
                    }
                    else
                    {
                        m_Pages = new BookPageInfo[0];
                    }
                }

                break;
            }
            }

            if (version < 3 && (Weight == 1 || Weight == 2))
            {
                Weight = -1;
            }
        }