summaryrefslogtreecommitdiffstats
path: root/src/BookContent.h
diff options
context:
space:
mode:
authorLukas Pioch <lukas@zgow.de>2017-07-28 12:11:07 +0200
committerLukas Pioch <lukas@zgow.de>2017-08-27 14:54:40 +0200
commitc171b272d96453f1a9d13d4623ac4bd3aa7d19e8 (patch)
tree32828d71b3de14de7489b080f07066dcf49e913e /src/BookContent.h
parentImplement anvil chunk sparsing (diff)
downloadcuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.gz
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.bz2
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.lz
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.xz
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.tar.zst
cuberite-c171b272d96453f1a9d13d4623ac4bd3aa7d19e8.zip
Diffstat (limited to 'src/BookContent.h')
-rw-r--r--src/BookContent.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/BookContent.h b/src/BookContent.h
new file mode 100644
index 000000000..042ebff50
--- /dev/null
+++ b/src/BookContent.h
@@ -0,0 +1,64 @@
+
+// BookContent.h
+
+#pragma once
+
+#include "WorldStorage/FastNBT.h"
+#include "json/json.h"
+
+
+
+
+// tolua_begin
+class cBookContent
+{
+public:
+ /** Creates a empty book */
+ cBookContent() {}
+
+ /** Set the author of the book */
+ void SetAuthor(const AString & a_Author) { m_Author = a_Author; }
+
+ /** Returns the author of the book */
+ const AString GetAuthor(void) const { return m_Author; }
+
+ /** Set the title of the book */
+ void SetTitle(const AString & a_Title) { m_Title = a_Title; }
+
+ /** Returns the title of the book */
+ const AString GetTitle(void) const { return m_Title; }
+
+ /** Add a page to the end of the book */
+ void AddPage(const AString & a_Page) { m_Pages.emplace_back(a_Page); }
+
+ /** Clears the whole book */
+ void Clear();
+
+ /** Returns true if the book has no author, no title and no pages */
+ bool IsEmpty(void) const;
+
+ // tolua_end
+
+ /** Returns a AStringVector ref to the pages. Used in ManualBindings and for saving the book */
+ const AStringVector & GetPages(void) const { return m_Pages; }
+
+ /** Set the pages. Used in ManualBindings */
+ void SetPages(const AStringVector & a_Pages) { m_Pages = a_Pages; }
+
+ /** Read the book content from nbt. The boolean a_SaveAsJson is optional. If a player creates a book, the text should be in a json string */
+ static void ParseFromNBT(int TagTag, cBookContent & a_BookContent, const cParsedNBT & a_NBT, bool a_SaveAsJson = false);
+
+ /** Write book content to nbt */
+ static void WriteToNBTCompound(const cBookContent & a_BookContent, cFastNBTWriter & a_Writer);
+
+private:
+ /** Author of the book */
+ AString m_Author;
+
+ /** Title of the book */
+ AString m_Title;
+
+ /** Contains the pages */
+ AStringVector m_Pages;
+
+}; // tolua_export