private void performAddBook(object sender, string bookId)
        {
            // If some value was typed and the identifier is valid
            if (!controller.isElementIdValid(bookId))
            {
                bookId = controller.makeElementValid(bookId);
            }

            // Add thew new book
            Book newBook = new Book(bookId);

            newBook.setType(Book.TYPE_PARAGRAPHS);

            // Set default background
            ResourcesUni resources = new ResourcesUni();

            resources.addAsset("background", SpecialAssetPaths.ASSET_DEFAULT_BOOK_IMAGE);
            resources.addAsset("arrowLeftNormal", SpecialAssetPaths.ASSET_DEFAULT_ARROW_NORMAL);
            resources.addAsset("arrowLeftOver", SpecialAssetPaths.ASSET_DEFAULT_ARROW_OVER);
            newBook.addResources(resources);

            BookDataControl newDataControl = new BookDataControl(newBook);

            booksList.Add(newBook);
            booksDataControlList.Add(newDataControl);
            controller.IdentifierSummary.addId <Book>(bookId);
        }
Ejemplo n.º 2
0
        protected override void DrawInspector()
        {
            workingBook = Controller.Instance.SelectedChapterDataControl.getBooksList().getBooks()[GameRources.GetInstance().selectedBookIndex];

            // Appearance table
            appearanceEditor.Data = workingBook;
            appearanceEditor.OnInspectorGUI();

            GUILayout.Space(10);

            // Background
            EditorGUI.BeginChangeCheck();
            background.Path = workingBook.getPreviewImage();
            background.DoLayout();
            if (EditorGUI.EndChangeCheck())
            {
                workingBook.setPreviewImage(background.Path);
            }

            // Arrows
            GUILayout.BeginHorizontal();
            DoArrowField(left, BookDataControl.ARROW_LEFT, BookDataControl.ARROW_NORMAL);
            DoArrowField(right, BookDataControl.ARROW_RIGHT, BookDataControl.ARROW_NORMAL);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            DoArrowField(left_over, BookDataControl.ARROW_LEFT, BookDataControl.ARROW_OVER);
            DoArrowField(right_over, BookDataControl.ARROW_RIGHT, BookDataControl.ARROW_OVER);
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 3
0
 /**
  * Constructor.
  *
  * @param bookParagraphsList
  *            List of book paragraphs
  */
 public BookPagesListDataControl(List <BookPage> bookPagesList, BookDataControl dControl)
 {
     this.bookPagesList = bookPagesList;
     this.dControl      = dControl;
     selectedPage       = -1;
     defaultType        = BookPage.TYPE_RESOURCE;
     defaultMargin      = 0;
     defaultScrollable  = false;
 }
Ejemplo n.º 4
0
        public override bool addElement(int type, string bookId)
        {
            bool elementAdded = false;

            if (type == Controller.BOOK)
            {
                int bookType = -1;
                //TODO: tmp, delete this line
                bookType = 0;
                //TODO: implement
                //BookTypesDialog bookTypesDialog = new BookTypesDialog(Book.TYPE_PARAGRAPHS);
                //bookType = bookTypesDialog.getOptionSelected();

                if (bookType != -1)
                {
                    // Show a dialog asking for the book id
                    if (bookId == null || bookId.Equals(""))
                    {
                        bookId = controller.showInputDialog(TC.get("Operation.AddBookTitle"), TC.get("Operation.AddBookMessage"), TC.get("Operation.AddBookDefaultValue"));
                    }

                    // If some value was typed and the identifier is valid
                    if (!controller.isElementIdValid(bookId))
                    {
                        bookId = controller.makeElementValid(bookId);
                    }

                    // Add thew new book
                    Book newBook = new Book(bookId);
                    newBook.setType(bookType);

                    // Set default background
                    ResourcesUni resources = new ResourcesUni();
                    resources.addAsset("background", SpecialAssetPaths.ASSET_DEFAULT_BOOK_IMAGE);
                    resources.addAsset("arrowLeftNormal", SpecialAssetPaths.ASSET_DEFAULT_ARROW_NORMAL);
                    resources.addAsset("arrowLeftOver", SpecialAssetPaths.ASSET_DEFAULT_ARROW_OVER);
                    newBook.addResources(resources);

                    BookDataControl newDataControl = new BookDataControl(newBook);
                    booksList.Add(newBook);
                    booksDataControlList.Add(newDataControl);
                    controller.getIdentifierSummary().addBookId(bookId);
                    //controller.dataModified( );
                    elementAdded = true;
                }
            }

            return(elementAdded);
        }
        public override bool moveElementDown(DataControl dataControl)
        {
            bool elementMoved = false;
            int  elementIndex = booksList.IndexOf((Book)dataControl.getContent());

            if (elementIndex < booksList.Count - 1)
            {
                Book            e = booksList[elementIndex];
                BookDataControl c = booksDataControlList[elementIndex];
                booksList.RemoveAt(elementIndex);
                booksDataControlList.RemoveAt(elementIndex);
                booksList.Insert(elementIndex + 1, e);
                booksDataControlList.Insert(elementIndex + 1, c);
                controller.DataModified();
                elementMoved = true;
            }

            return(elementMoved);
        }
Ejemplo n.º 6
0
        public void Init(DialogReceiverInterface e, BookDataControl book)
        {
            bookRef = book;

            string backgroundPath = book.getPreviewImage();

            backgroundPreviewTex =
                (Texture2D)Resources.Load(backgroundPath.Substring(0, backgroundPath.LastIndexOf(".")), typeof(Texture2D));

            string leftNormalArrowPath = book.getArrowImagePath_WithDefault(BookDataControl.ARROW_LEFT,
                                                                            BookDataControl.ARROW_NORMAL);

            leftArrowTex =
                (Texture2D)
                Resources.Load(leftNormalArrowPath.Substring(0, leftNormalArrowPath.LastIndexOf(".")),
                               typeof(Texture2D));

            string rightNormalArrowPath = book.getArrowImagePath_WithDefault(BookDataControl.ARROW_RIGHT,
                                                                             BookDataControl.ARROW_NORMAL);

            rightArrowTex =
                (Texture2D)
                Resources.Load(rightNormalArrowPath.Substring(0, rightNormalArrowPath.LastIndexOf(".")),
                               typeof(Texture2D));

            imageBackgroundRect = new Rect(0f, 0f, backgroundPreviewTex.width, backgroundPreviewTex.height);

            defaultPreviousPageArrowPosition = new Vector2(MARGIN,
                                                           backgroundPreviewTex.height - leftArrowTex.height - MARGIN);
            defaultNextPageArrowPosition = new Vector2(backgroundPreviewTex.width - rightArrowTex.width - MARGIN,
                                                       backgroundPreviewTex.height - rightArrowTex.height - MARGIN);

            if (bookRef.getPreviousPagePosition() == Vector2.zero && bookRef.getNextPagePosition() == Vector2.zero)
            {
                SetDefaultArrowsPosition();
            }

            CalculateArrowsPosition();

            base.Init(e, backgroundPreviewTex.width, backgroundPreviewTex.height);
        }
Ejemplo n.º 7
0
        private Texture2D LoadArrowTexture(BookDataControl book, int arrowType, int arrowMode)
        {
            var path = book.getArrowImagePath(arrowType, arrowMode);

            return(!string.IsNullOrEmpty(path) ? Controller.ResourceManager.getImage(path) : null);
        }