public BaseBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID) { m_Title = title; m_Author = author; m_Pages = new BookPageInfo[pageCount]; 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(); } Weight = BookWeight; }
public bool IsMatch(BookPageInfo[] cmp) { if (cmp.Length != this.m_Pages.Length) return false; for (int i = 0; i < cmp.Length; ++i) { string[] a = this.m_Pages[i].Lines; string[] b = cmp[i].Lines; if (a.Length != b.Length) { return false; } else if (a != b) { for (int j = 0; j < a.Length; ++j) { if (a[j] != b[j]) return false; } } } return true; }
public void UpdateBook() { int line = 0; int page = 0; Size = (int)Math.Ceiling((double)DonationList.Count / 8); string[] lines = new string[8]; ScorePages = new BookPageInfo[Size]; foreach (KeyValuePair <PlayerMobile, int> kvp in DonationList) { if (line == 8) { ScorePages[page] = new BookPageInfo(lines); line = 0; page++; } lines[line] = String.Format("{0}: {1} ingot{2}", kvp.Key.Name, kvp.Value, (kvp.Value > 1 ? "s" : "")); line++; } while (line < 8) { lines[line] = ""; line++; } ScorePages[page] = new BookPageInfo(lines); }
public PublishedBook(int index) : base(Utility.RandomList(0xFF2, 0xFEF, 0xFF1, 0xFF0)) { Writable = false; if (index >= Publisher.Books.Count) { return; } BookContent bc = Publisher.Books[index]; Title = bc.Title; Author = bc.Author; BookPageInfo[] pagesSrc = bc.Pages; for (int i = 0; i < pagesSrc.Length && i < Pages.Length; i++) { BookPageInfo pageSrc = pagesSrc[i]; BookPageInfo pageDst = Pages[i]; int length = pageSrc.Lines.Length; pageDst.Lines = new string[length]; for (int j = 0; j < length; j++) { pageDst.Lines[j] = pageSrc.Lines[j]; } } }
private void SetText(string text) { var words = text.Split(' '); int wordCount, wordsPerLine, linesPerPage, index, pageCount; ParseFactors(words, out wordCount, out wordsPerLine, out linesPerPage, out index, out pageCount); for (int currentPage = 0; currentPage < pageCount; currentPage++) { for (int currentLine = 0; currentLine < linesPerPage; currentLine++) { Pages[currentPage] = new BookPageInfo(new string[linesPerPage]); StringBuilder line = new StringBuilder(); for (int currentWord = 0; currentWord < wordsPerLine; currentWord++) { if (index >= wordCount) { continue; } line.AppendFormat(" {0}", words[index]); index++; } Pages[currentPage].Lines[currentLine] = line.ToString(); } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 0: { m_Title = reader.ReadString(); m_Author = reader.ReadString(); m_Writable = reader.ReadBool(); m_Pages = new BookPageInfo[reader.ReadInt()]; for (int i = 0; i < m_Pages.Length; ++i) { m_Pages[i] = new BookPageInfo(reader); } break; } } Weight = BookWeight; }
public virtual void AddPage(BookPageInfo bpi) { // wea: modified so that new bpi is generated rather than associating source BookPageInfo bpiNewPage = new BookPageInfo(); bpiNewPage.Lines = bpi.Lines; m_Pages.Add(bpiNewPage); }
public BookPageInfo[] Copy() { BookPageInfo[] copy = new BookPageInfo[this.m_Pages.Length]; for (int i = 0; i < copy.Length; ++i) copy[i] = new BookPageInfo(this.m_Pages[i].Lines); return copy; }
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); }
public BaseEntryBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID) { m_Title = title; m_Author = author; m_Pages = new BookPageInfo[pageCount]; m_Writable = writable; for (int i = 0; i < m_Pages.Length; ++i) { m_Pages[i] = new BookPageInfo(); } }
public void BuildBookFromString(string content) { if (content == null) { return; } const int cpl = 22; //characters per line int pos = 0, nextpos; List <string[]> newpages = new List <string[]>(); while (newpages.Count < m_Pages.Length && pos < content.Length) { List <string> lines = new List <string>(); for (int i = 0; i < 8; ++i) { if (content.Length - pos < cpl) { lines.Add(content.Substring(pos)); pos = content.Length; break; } else { if ((nextpos = content.LastIndexOfAny(" /|\\.!@#$%^&*()_+=-".ToCharArray(), pos + cpl, cpl)) > 0) { lines.Add(content.Substring(pos, (nextpos - pos) + 1)); pos = nextpos + 1; } else { lines.Add(content.Substring(pos, cpl)); pos += cpl; } } } newpages.Add(lines.ToArray()); } for (int i = 0; i < m_Pages.Length; ++i) { if (i < newpages.Count) { m_Pages[i] = new BookPageInfo(newpages[i]); } else { m_Pages[i] = new BookPageInfo(); } } }
public BaseBook( int itemID, string title, string author, int pageCount, bool writable ) : base(itemID) { m_Title = title; m_Author = author; m_Pages = new BookPageInfo[pageCount]; m_Writable = writable; for ( int i = 0; i < m_Pages.Length; ++i ) m_Pages[i] = new BookPageInfo(); Weight = BookWeight; }
public BaseReadBook(ReadBookInfo bookInfo, int pageCount, String title, String author, BaseBook sourceBook) : base(bookInfo.ItemID) { m_Background = bookInfo.BackgroundID; m_CustomArt = bookInfo.CustomArt; m_BigBook = bookInfo.BigBook; BookContent content = this.DefaultContent; if (sourceBook != null) { m_Author = sourceBook.Author; m_Title = sourceBook.Title; m_Pages = (BookPageInfo[])sourceBook.Pages.Clone(); m_Full = true; } else { if (content == null) { m_Pages = new BookPageInfo[pageCount]; for (int i = 0; i < m_Pages.Length; ++i) { m_Pages[i] = new BookPageInfo(); } } else { m_Title = content.Title; m_Author = content.Author; m_Pages = content.Copy(); } } if (author != null) { m_Author = author; } if (title != null) { m_Title = title; } if ((author != null) && (title != null)) { m_Full = true; } Weight = BookWeight; }
public BookPageDetails(BaseBook book, int page, BookPageInfo info) : base(0x66) { EnsureCapacity(256); m_Stream.Write((int)book.Serial); m_Stream.Write((ushort)0x1); m_Stream.Write((ushort)page); m_Stream.Write((ushort)info.Lines.Length); for (int i = 0; i < info.Lines.Length; ++i) { byte[] buffer = Utility.UTF8.GetBytes(info.Lines[i]); m_Stream.Write(buffer, 0, buffer.Length); m_Stream.Write((byte)0); } }
public virtual void AddPage(BookPageInfo bpi) { /* * // wea: modified so that new bpi is generated rather than associating source * BookPageInfo bpiNewPage = new BookPageInfo(); * bpiNewPage.Lines = bpi.Lines; * m_Pages.Add(bpiNewPage);*/ BookPageInfo[] copy = new BookPageInfo[m_Pages.Length + 1]; for (int i = 0; i < copy.Length - 1; ++i) { copy[i] = new BookPageInfo(m_Pages[i].Lines); } // add new page copy[copy.Length - 1] = bpi; m_Pages = copy; }
private void Deserialize(IGenericReader reader, int version) { Level = (SecureLevel)reader.ReadInt(); var content = DefaultContent; var flags = (OldSaveFlags)reader.ReadEncodedInt(); if ((flags & OldSaveFlags.Title) != 0) { _title = Utility.Intern(reader.ReadString()); } else if (content != null) { _title = content.Title; } if ((flags & OldSaveFlags.Author) != 0) { _author = reader.ReadString(); } else if (content != null) { _author = content.Author; } Writable = (flags & OldSaveFlags.Writable) != 0; if ((flags & OldSaveFlags.Content) != 0) { Pages = new BookPageInfo[reader.ReadEncodedInt()]; for (var i = 0; i < Pages.Length; ++i) { Pages[i] = new BookPageInfo(reader); } } else { Pages = content?.Copy() ?? Array.Empty <BookPageInfo>(); } }
private Dictionary<int, List<HTMLTag>> m_Words = new Dictionary<int, List<HTMLTag>>(); // see GetWordIndex #endregion Fields #region Constructors public HTMLContent( int pages, int maxLines, HTMLBook book ) { m_Book = book; m_CachedHTMLContent = new BookPageInfo[pages]; for ( int i = 0; i < m_CachedHTMLContent.Length; i++ ) { m_CachedHTMLContent[i] = new BookPageInfo(); m_CachedHTMLContent[i].Lines = new string[maxLines]; } // set default body styling m_Body = new List<HTMLTag>(); HTMLTag tag = new ColorTag(); tag.Value = "111111"; // #000000 (black) is invisible m_Body.Add( tag ); tag = new LeftAlignTag(); m_Body.Add( tag ); tag = new MediumFontTag(); m_Body.Add( tag ); }
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(); } }
public BaseBook(int itemID, string title, string author, int pageCount, bool writable) : base(itemID) { var content = DefaultContent; _title = title ?? content?.Title; _author = author ?? content?.Author; _writable = writable; if (content == null) { _pages = new BookPageInfo[pageCount]; for (var i = 0; i < _pages.Length; ++i) { _pages[i] = new BookPageInfo(); } } else { _pages = content.Copy(); } }
public EntryBookPageDetails(BaseEntryBook book) : base(0x66) { EnsureCapacity(256); m_Stream.Write(book.Serial); m_Stream.Write((ushort)book.PagesCount); for (int i = 0; i < book.PagesCount; ++i) { BookPageInfo page = book.Pages[i]; m_Stream.Write((ushort)(i + 1)); m_Stream.Write((ushort)page.Lines.Length); foreach (byte[] buffer in page.Lines.Select(line => Utility.UTF8.GetBytes(line))) { m_Stream.Write(buffer, 0, buffer.Length); m_Stream.Write((byte)0); } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 0: { int pic_number = reader.ReadInt(); for (int i = 0; i < pic_number; i++) { Picture pic = new Picture(PictureTypes.gump, -1, -1, -1, -1, -1); pic.Deserialize(reader); m_Pictures.Add(pic); } m_Title = reader.ReadString(); m_Author = reader.ReadString(); m_Background = reader.ReadInt(); m_Titlepage = reader.ReadBool(); m_Full = reader.ReadBool(); m_BigBook = reader.ReadBool(); m_CustomArt = reader.ReadBool(); m_Pages = new BookPageInfo[reader.ReadInt()]; for (int i = 0; i < m_Pages.Length; ++i) { m_Pages[i] = new BookPageInfo(reader); } break; } } Weight = BookWeight; }
public BookPageDetails(BaseBook book) : base(0x66) { EnsureCapacity(256); m_Stream.Write((int)book.Serial); m_Stream.Write((ushort)book.PagesCount); for (int i = 0; i < book.PagesCount; ++i) { BookPageInfo page = book.Pages[i]; m_Stream.Write((ushort)(i + 1)); m_Stream.Write((ushort)page.Lines.Length); for (int j = 0; j < page.Lines.Length; ++j) { byte[] buffer = Utility.UTF8.GetBytes(page.Lines[j]); m_Stream.Write(buffer, 0, buffer.Length); m_Stream.Write((byte)0); } } }
public BaseReadBook(ReadBookInfo bookInfo, int pageCount, String title, String author, BaseBook sourceBook) : base(bookInfo.ItemID) { m_Background = bookInfo.BackgroundID; m_CustomArt = bookInfo.CustomArt; m_BigBook = bookInfo.BigBook; BookContent content = this.DefaultContent; if (sourceBook != null) { m_Author = sourceBook.Author; m_Title = sourceBook.Title; m_Pages = (BookPageInfo[])sourceBook.Pages.Clone(); m_Full = true; } else { if (content == null) { m_Pages = new BookPageInfo[pageCount]; for (int i = 0; i < m_Pages.Length; ++i) m_Pages[i] = new BookPageInfo(); } else { m_Title = content.Title; m_Author = content.Author; m_Pages = content.Copy(); } } if (author != null) { m_Author = author; } if (title != null) { m_Title = title; } if ((author != null) && (title != null)) { m_Full = true; } Weight = BookWeight; }
public virtual void FixContent() { string content = ""; StringBuilder sb; for( int i = 0; i < Pages.Length; i++ ) { for ( int k = 0; k < Pages[i].Lines.Length; k++ ) { if ( Pages[i].Lines[k].Length < 1 ) continue; sb = null; // make sure html tags are surrounded by spaces, but don't remove illegal html tags here, we'll do that later if ( Pages[i].Lines[k].IndexOf( '<' ) != -1 ) { sb = new StringBuilder(Pages[i].Lines[k]); for ( int q = 1; q < sb.Length; q++ ) { if ( sb[q] == '<' && sb[q-1] != ' ' ) sb.Insert( q, ' ' ); else if ( sb[q-1] == '>' && sb[q] != ' ' ) sb.Insert( q, ' ' ); } } if ( sb != null ) content += sb.ToString(); else content += Pages[i].Lines[k]; if ( content[content.Length-1] != ' ' ) content += ' '; } } string[] pieces = content.Split( new char[] { ' ' } ); int page = 0; int j = 0; m_FormattedBookContent = new BookPageInfo[PagesCount]; for ( int i = 0; i < m_FormattedBookContent.Length; i++ ) m_FormattedBookContent[i] = new BookPageInfo(); m_FormattedBookContent[page].Lines = new string[MaxLines]; for ( int i = 0; i < MaxLines; i++ ) m_FormattedBookContent[page].Lines[i] = ""; bool skipLine = false; int lineFillFactor = 0; int textCost = new MediumFontTag().CharacterCost; foreach( string word in pieces ) { if ( word.IndexOf( '<' ) != -1 ) { if ( String.Compare( word, "<BR>", true ) != 0 ) // ignore case continue; // do not want else { m_FormattedBookContent[page].Lines[j] += word; skipLine = true; // avoids text screwups } } if ( lineFillFactor + word.Length + 1 + textCost > CharactersPerLineMax || skipLine ) // count the space towards limit { j++; lineFillFactor = 0; if ( j >= MaxLines ) { j = 0; page++; if ( page >= m_FormattedBookContent.Length ) { // no more space in book return; } m_FormattedBookContent[page].Lines = new string[MaxLines]; for ( int i = 0; i < MaxLines; i++ ) m_FormattedBookContent[page].Lines[i] = ""; } } if ( !skipLine ) { m_FormattedBookContent[page].Lines[j] += word; m_FormattedBookContent[page].Lines[j] += ' '; lineFillFactor += 1 + textCost + word.Length; } else skipLine = false; } }
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; } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_Copyable = true; // take care of all the grandfathered-in books m_LastEdited = ""; // erl: init LastEdited string switch (version) { case 4: { m_Subtype = (BookSubtype)reader.ReadInt(); m_Version = reader.ReadDouble(); goto case 3; } case 3: // wea: mirrored bpi fix { goto case 2; } case 2: // erl: new LastEdited property { m_LastEdited = reader.ReadString(); goto case 1; } case 1: { m_Copyable = reader.ReadBool(); goto case 0; } case 0: { m_Title = reader.ReadString(); m_Author = reader.ReadString(); m_Writable = reader.ReadBool(); BookPageInfo[] bpi = new BookPageInfo[reader.ReadInt()]; for (int i = 0; i < bpi.Length; ++i) { bpi[i] = new BookPageInfo(reader); } m_Pages = bpi; /* Run2.0 style now * if (version <= 2) * { * // wea: freshen up this bpi list so that the book's pages * // are properly defined * * m_Pages = new ArrayList(); * * for (int i = 0; i < bpi.Length; ++i) * { * BookPageInfo bpiFresh = new BookPageInfo(); * bpiFresh.Lines = bpi[i].Lines; * * m_Pages.Add(bpiFresh); * } * } * else * { * // This book doesn't need fixing * m_Pages = new ArrayList(bpi); * }*/ break; } } Weight = BookWeight; }
public virtual void FixStyling() { // Recalculates the word positions due to style changes (font size, etc) // Reconstructs the content and then discards the old one int newPage = 0; int newLine = 0; int newLineFillFactor = 0; int newLineWordCount = 0; BookPageInfo[] newPages = new BookPageInfo[PagesCount]; for ( int i = 0; i < newPages.Length; i++ ) newPages[i] = new BookPageInfo(); newPages[newPage].Lines = new string[MaxLines]; for ( int i = 0; i < MaxLines; i++ ) newPages[newPage].Lines[i] = ""; // the new word hashtable with rearranged word positions Dictionary<int, List<HTMLTag>> newWordsTable = new Dictionary<int, List<HTMLTag>>(); int CharacterCost; string[] splitWords; bool skipLine = false; if ( m_FormattedBookContent == null ) m_FormattedBookContent = new BookPageInfo[0]; for( int i = 0; i < m_FormattedBookContent.Length; i++ ) { for ( int k = 0; k < m_FormattedBookContent[i].Lines.Length; k++ ) { if ( m_FormattedBookContent[i].Lines[k].Length < 1 ) continue; splitWords = m_FormattedBookContent[i].Lines[k].Split( new char[] { ' ' } ); for( int z = 0; z < splitWords.Length; z++ ) { if ( splitWords[z].Length < 1 ) continue; else if ( splitWords[z].IndexOf( '<' ) != -1 ) // this can only be a <BR> { skipLine = true; newPages[newPage].Lines[newLine] += splitWords[z]; List<HTMLTag> temp = m_HTMLContent.GetWordTags( i, k, z ); if ( temp.Count > 0 ) { newWordsTable[HTMLContent.GetWordIndex( newPage, newLine, newLineWordCount )] = temp; int newlh = HTMLContent.GetLineIndex( newPage, newLine ); if ( HTMLContent.HTMLPage.ContainsKey( newPage ) ) // add tag HTMLContent.HTMLPage[newPage]++; else HTMLContent.HTMLPage[newPage] = 1; if ( HTMLContent.HTMLLines.ContainsKey( newlh ) ) HTMLContent.HTMLLines[newlh]++; else HTMLContent.HTMLLines[newlh] = 1; if ( HTMLContent.HTMLPage.ContainsKey( i ) ) if (--HTMLContent.HTMLPage[i] <= 0) HTMLContent.HTMLPage.Remove( i ); // no more tags there anyway int lh = HTMLContent.GetLineIndex( i, k ); if ( HTMLContent.HTMLLines.ContainsKey( lh ) ) if (--HTMLContent.HTMLLines[lh] <= 0) HTMLContent.HTMLLines.Remove( lh ); // no more tags there anyway } newLineWordCount++; } CharacterCost = m_HTMLContent.CalculateCharacterCost( i, k, z ); if ( newLineFillFactor + splitWords[z].Length + CharacterCost + 1 > CharactersPerLineMax || skipLine ) // count the space towards limit { newLine++; newLineFillFactor = 0; newLineWordCount = 0; if ( newLine >= MaxLines ) { newLine = 0; newPage++; if ( newPage >= newPages.Length ) { // no more space in book return; } newPages[newPage].Lines = new string[MaxLines]; for ( int g = 0; g < MaxLines; g++ ) newPages[newPage].Lines[g] = ""; } } if ( !skipLine ) { newPages[newPage].Lines[newLine] += splitWords[z]; List<HTMLTag> oldWordTags = m_HTMLContent.GetWordTags( i, k, z ); if ( oldWordTags.Count > 0 ) { int newlinehash = HTMLContent.GetLineIndex( newPage, newLine ); newWordsTable[HTMLContent.GetWordIndex( newPage, newLine, newLineWordCount )] = oldWordTags; if ( HTMLContent.HTMLPage.ContainsKey( newPage ) ) // add tag HTMLContent.HTMLPage[newPage]++; else HTMLContent.HTMLPage[newPage] = 1; if ( HTMLContent.HTMLLines.ContainsKey( newlinehash ) ) HTMLContent.HTMLLines[newlinehash]++; else HTMLContent.HTMLLines[newlinehash] = 1; if ( HTMLContent.HTMLPage.ContainsKey( i ) ) if (--HTMLContent.HTMLPage[i] <= 0) HTMLContent.HTMLPage.Remove( i ); // no more tags there anyway int linehash = HTMLContent.GetLineIndex( i, k ); if ( HTMLContent.HTMLLines.ContainsKey( linehash ) ) if (--HTMLContent.HTMLLines[linehash] <= 0) HTMLContent.HTMLLines.Remove( linehash ); // no more tags there anyway } newLineWordCount++; newLineFillFactor += splitWords[z].Length + CharacterCost; newPages[newPage].Lines[newLine] += ' '; newLineFillFactor++; // for the space } else skipLine = false; } } } m_FormattedBookContent = newPages; m_HTMLContent.WordsTable = newWordsTable; }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); m_Copyable = true; // take care of all the grandfathered-in books m_LastEdited = ""; // erl: init LastEdited string switch ( version ) { case 3: // wea: mirrored bpi fix { goto case 2; } case 2: // erl: new LastEdited property { m_LastEdited = reader.ReadString(); goto case 1; } case 1: { m_Copyable = reader.ReadBool(); goto case 0; } case 0: { m_Title = reader.ReadString(); m_Author = reader.ReadString(); m_Writable = reader.ReadBool(); BookPageInfo[] bpi = new BookPageInfo[reader.ReadInt()]; for ( int i = 0; i < bpi.Length; ++i ) bpi[i] = new BookPageInfo( reader ); if( version <= 2 ) { // wea: freshen up this bpi list so that the book's pages // are properly defined m_Pages = new ArrayList(); for( int i = 0; i < bpi.Length; ++i ) { BookPageInfo bpiFresh = new BookPageInfo(); bpiFresh.Lines = bpi[i].Lines; m_Pages.Add(bpiFresh); } } else { // This book doesn't need fixing m_Pages = new ArrayList(bpi); } break; } } Weight = BookWeight; }
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; }
// updates the HTML cache with the content from the parent book public void UpdateCache() { m_CachedHTMLContent = new BookPageInfo[m_Book.FormattedBookContent.Length]; for( int i = 0; i < m_Book.FormattedBookContent.Length; i++ ) { m_CachedHTMLContent[i] = new BookPageInfo(); m_CachedHTMLContent[i].Lines = new string[m_Book.FormattedBookContent[i].Lines.Length]; for ( int k = 0; k < m_Book.FormattedBookContent[i].Lines.Length; k++ ) { m_CachedHTMLContent[i].Lines[k] = ""; if ( k == 0 ) m_CachedHTMLContent[i].Lines[k] += OpenPageAlignmentTags( i ); if ( !PageContainsHTML( i ) ) { if ( k == 0 ) m_CachedHTMLContent[i].Lines[k] += OpenPageTags( i ); m_CachedHTMLContent[i].Lines[k] += m_Book.FormattedBookContent[i].Lines[k]; if ( m_Book.FormattedBookContent[i].Lines[k].IndexOf( '<' ) == -1 ) m_CachedHTMLContent[i].Lines[k] += "<BR>"; if ( k == m_Book.FormattedBookContent[i].Lines.Length-1 ) m_CachedHTMLContent[i].Lines[k] += ClosePageTags( i ); } else { if ( !LineContainsHTMLWords( i, k ) ) m_CachedHTMLContent[i].Lines[k] += OpenLineTags( i, k ) + m_Book.FormattedBookContent[i].Lines[k] + CloseLineTags( i, k ); else // handle individual words { string[] pieces = m_Book.FormattedBookContent[i].Lines[k].Split( new char[] { ' ' } ); for ( int j = 0; j < pieces.Length; j++ ) { m_CachedHTMLContent[i].Lines[k] += OpenWordTags( i, k, j ) + pieces[j] + CloseWordTags( i, k, j ); if ( j != pieces.Length - 1 ) m_CachedHTMLContent[i].Lines[k] += " "; } } if ( m_Book.FormattedBookContent[i].Lines[k].IndexOf( '<' ) == -1 ) m_CachedHTMLContent[i].Lines[k] += "<BR>"; } } } }
public void UpdateBook() { int line = 0; int page = 0; Size = (int)Math.Ceiling((double)DonationList.Count / 8); string[] lines = new string[8]; ScorePages = new BookPageInfo[Size]; foreach (KeyValuePair<PlayerMobile, int> kvp in DonationList) { if (line == 8) { ScorePages[page] = new BookPageInfo(lines); line = 0; page++; } lines[line] = String.Format("{0}: {1} ingot{2}", kvp.Key.Name, kvp.Value, (kvp.Value > 1 ? "s" : "")); line++; } while (line < 8) { lines[line] = ""; line++; } ScorePages[page] = new BookPageInfo(lines); }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch ( version ) { case 0: { m_Title = reader.ReadString(); m_Author = reader.ReadString(); m_Writable = reader.ReadBool(); m_Pages = new BookPageInfo[reader.ReadInt()]; for ( int i = 0; i < m_Pages.Length; ++i ) m_Pages[i] = new BookPageInfo( reader ); break; } } Weight = BookWeight; }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 0: { int pic_number = reader.ReadInt(); for (int i = 0; i < pic_number; i++) { Picture pic = new Picture(PictureTypes.gump, -1, -1, -1, -1, -1); pic.Deserialize(reader); m_Pictures.Add(pic); } m_Title = reader.ReadString(); m_Author = reader.ReadString(); m_Background = reader.ReadInt(); m_Titlepage = reader.ReadBool(); m_Full = reader.ReadBool(); m_BigBook = reader.ReadBool(); m_CustomArt = reader.ReadBool(); m_Pages = new BookPageInfo[reader.ReadInt()]; for (int i = 0; i < m_Pages.Length; ++i) m_Pages[i] = new BookPageInfo(reader); break; } } Weight = BookWeight; }