public void ImportImageThumbnail(string path) { if (!DoesLibraryContain(currentBookTitle)) { Debug.Log("Cannot add thumbnail to non-existent book " + currentBookTitle + ". Import book first."); return; } BookInfo bookInfo = BookInfoMapper.DeserializeInfo(currentBookTitle); bookInfo.thumbnailPath = path; string[] pathParts = path.Split('.'); if (pathParts.Length < 2) { throw new InvalidBookFormatException("Invalid image format. Must include extension"); } string ext = pathParts[pathParts.Length - 1]; CopyOriginal(path, Config.Instance.BookLibraryPath + "/" + Config.Instance.ApplicationName + "/" + currentBookTitle + "/" + currentBookTitle + "-thumb." + ext); string outputPath = Config.Instance.BookLibraryPath + "/" + Config.Instance.ApplicationName + "/" + bookInfo.title + "/info.yaml"; BookInfoMapper.SerializeInfo(outputPath, bookInfo); }
public void InitBook(string title) { if (books == null) { LoadLibrary(); } if (!books.Contains(title)) { // throw error } BookFormat bookType = BookInfoMapper.DeserializeInfo(title).format; switch (bookType) { case BookFormat.TXT: InitTxtBasedBook(title); break; default: Debug.Log("Invalid book format"); return; } }
private void ImportDotText(string path) { string outputDir = GenerateDirs(path); string title = GetTitleFromPath(path); BookInfoMapper.SerializeInfo(outputDir + "/info.yaml", BookFormat.TXT, path, title); CopyOriginal(path, outputDir + "/" + title + ".txt"); }
private void ImportPdf(string path) { string outputDir = GenerateDirs(path); string title = GetTitleFromPath(path); PdfConversion.ToJpegs(path, outputDir + "/" + "pages/"); BookInfoMapper.SerializeInfo(outputDir + "/info.yaml", BookFormat.PDF, path, title); CopyOriginal(path, outputDir + "/" + title + ".pdf"); }
// Loads book images from library private void Start() { List <BookInfo> booksInfo = BookInfoMapper.DeserializeAll(); foreach (var bookInfo in booksInfo) { if (File.Exists(bookInfo.thumbnailPath)) { sprites.Add(Generators.GenSpriteFromImg(bookInfo.thumbnailPath)); } } if (sprites.Count > 0) { DisplayedImage.sprite = sprites.ElementAt(0); } // todo handle if no books added to library - replace selection with link to import books? // todo use default image with book title if no thumbnail exists }
private void Start() { List <BookInfo> booksInfo = BookInfoMapper.DeserializeAll(); Debug.Log(""); }