示例#1
0
        protected bool TryToDisplayChapter(int chapterNumber)
        {
            bool result = false;
            //get the current chapter
            Chapter newChapter = null;

            if (EditObject.ReadChapter(chapterNumber, out newChapter))
            {
                //Debug.Log ("GUIBookReader Trying to display chapter " + chapterNumber + ", failed");
                //if we can read this chapter number, great - set it as our official chapter number
                mCurrentChapterNumber = chapterNumber;
                mCurrentChapter       = newChapter;
                result = true;
            }

            if (result)
            {
                //Debug.Log ("GUIBookReader successfully loaded chapter " + chapterNumber);
                //load the chapter
                BookFont font  = Books.Get.SimpleFont;
                Color    color = Color.black;                                             //Color.white;
                //if (Type != DisplayType.Simple) {
                font = Books.Get.GetFont(mCurrentChapter.FontName);
                if (Type != DisplayType.WhiteOnBlack)
                {
                    color = mCurrentChapter.ChapterFontColor;
                }
                //}
                if (font.NGUIFont == null)
                {
                    //Debug.Log ("Font NGUI font was null using font name " + mCurrentChapter.FontName);
                }
                CurrentDisplayLeft.SetChapterProperties(
                    mCurrentChapter.FormattedContents,
                    mCurrentChapter.ChapterAlignment,
                    font.NGUIFont,
                    font.DisplayScale,
                    color,
                    (mEditObject.NumChapters > 0),
                    mCurrentChapterNumber);

                CurrentDisplayLeft.RefreshChapterFormat();

                if (CurrentDisplayRight != null)
                {
                    //Debug.Log ("GUIBookReader Using display right");
                    CurrentDisplayRight.SetChapterProperties(
                        mCurrentChapter.FormattedContents,
                        mCurrentChapter.ChapterAlignment,
                        font.NGUIFont,
                        font.DisplayScale,
                        color,
                        (mEditObject.NumChapters > 0),
                        mCurrentChapterNumber);

                    CurrentDisplayRight.RefreshChapterFormat();
                }
            }
            //if we can't, then don't set our chapter number
            return(result);
        }