You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-26.1.2/getting-started/step-by-step-with-datagen/step3.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,11 @@ book
44
44
-`DemoBook.java` is the main entry point for the book. It is a subclass of the type SingleBookSubProvider which sets up the book and links its categories.
45
45
- Categories are set up in `generateCategories()`. Just call `this.add(new <...>)` as shown in the existing file to link a category to the book.
46
46
-`FeaturesCategory.java`, `FormattingCategory.java`, `IndexModeCategory.java` are category providers. They work the same way as the DemoBook.java, except that they set up data for categories, and allow to add entries.
47
-
- Entries are added in generateEntries(). Just call `this.add(new <...>)` as shown in the existing file to link an entry to the category.
47
+
- Entries are added in `generateEntries()`. Just call `this.add(new <...>)` as shown in the existing file to link an entry to the category.
48
+
- Entry placement in node view is now usually handled with `this.layout()`.
49
+
- For simple category-wide layouts, use `configureLayout(...)` and place entries by id, for example `layout.entry(MyEntry.ID).at(0, 0)` or `layout.entry(MyOtherEntry.ID).rightOf(MyEntry.ID, 4).below(1)`.
50
+
- If you prefer to place entries inline while generating them, keep the generated `BookEntryModel` and use `this.layout().entry(entryModel)...`.
51
+
-`FeaturesCategory.java` still contains a `generateEntryMap()` example, but only as a legacy reference.
48
52
-`CommandEntry.java`, `ImageEntry.java`, `BasicFormattingEntry.java` (and all the other java files in the category subdirectories) are entry providers. They work the same way as the category providers, except that they set up data for entries, and allow to add pages.
49
53
- Pages are added in `generatePages()`.
50
54
- Pages are a bit more complicated than simply calling `this.add()`, it is best to take a look at some of the entries to understand how they work. Very simply put, you always need a page definition that you can set with `this.page(...)`, followed by the texts you want to display on that page.
@@ -53,8 +57,10 @@ book
53
57
54
58
1. Start by copying and renaming the FormattingCategory into e.g. "MyTestCategory.java" and adding a directory/package "mytestcategory".
55
59
2. Add a new entry (e.g. copy the "BasicFormattingEntry.java" to "/mytestcategory/MyTestEntry.java") with a few pages into that new directory.
56
-
3. Remove the references in your MyTestCategory to the entries of FormattingCategory and instead place `this.add(new MyTestEntry().generate('l'))`.
57
-
4. Modify the placement of the entry in the 2D string array in generateEntryMap() to place your entry where you would like it to be in the node view.
60
+
3. Remove the references in your MyTestCategory to the entries of FormattingCategory and instead place `this.add(new MyTestEntry(this).generate())`.
61
+
4. Place the entry in node view with one of the layout helpers:
62
+
- In `configureLayout(...)`, for example `layout.entry(MyTestEntry.ID).at(0, 0)`.
63
+
- Or inline in `generateEntries()`, for example `var myEntry = this.add(new MyTestEntry(this).generate()); this.layout().entry(myEntry).at(0, 0);`.
58
64
59
65
## Test your changes
60
66
@@ -77,4 +83,4 @@ You now have a working and already modified book that you can extend to your lik
77
83
- Remove demo content.
78
84
79
85
For an overview of the possible page types and other content settings, you can view once again the demo book content, or take a look at the [Basics](/docs/basics) and [Advanced](/docs/advanced) documentation. The documentation documents the JSON format, however if you compare it to the demo book you will notice corresponding java methods, usually prefixed with "with".
80
-
Another good resource is: https://github.com/klikli-dev/theurgy/tree/version/1.21.1/src/main/java/com/klikli_dev/theurgy/datagen/book as theurgy extensively uses Modonomicon for its in-game documentation.
86
+
Another good resource is: https://github.com/klikli-dev/theurgy/tree/version/1.21.1/src/main/java/com/klikli_dev/theurgy/datagen/book as theurgy extensively uses Modonomicon for its in-game documentation.
0 commit comments