mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-24 22:04:33 +00:00
Table of Contents
- Not ready for prime implementation of 3D structures - Added table of contents to beginning of each section - Extended load method to PageContent - A less hard-coded imagedata loading implementation (DataLocation) - Repositories handle their own files - Removed title from SectionData, replaced with translation strings - BookTransformers now invoked after loading pages - Fixed TextDataRenderer incorrectly calculating condition for ellipsis
This commit is contained in:
1 parent
4e98678f46
commit
341ef7e41d
37 files changed
+1149
-263
No files matched your search
@@ -12,15 +12,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
import slimeknights.mantle.client.book.data.content.ContentError;
|
||||
import slimeknights.mantle.client.book.data.element.ImageData;
|
||||
import static slimeknights.mantle.client.book.ResourceHelper.getResource;
|
||||
import static slimeknights.mantle.client.book.ResourceHelper.getResourceLocation;
|
||||
import static slimeknights.mantle.client.book.ResourceHelper.resourceToString;
|
||||
import slimeknights.mantle.client.book.repository.BookRepository;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SectionData implements IDataItem {
|
||||
|
||||
public String name = null;
|
||||
public String title = "";
|
||||
public ImageData icon = new ImageData();
|
||||
public String[] requirements = new String[0];
|
||||
public boolean hideWhenLocked = false;
|
||||
@@ -28,6 +25,7 @@ public class SectionData implements IDataItem {
|
||||
|
||||
public transient int unnamedPageCounter = 0;
|
||||
public transient BookData parent;
|
||||
public transient BookRepository source;
|
||||
public transient ArrayList<PageData> pages = new ArrayList<>();
|
||||
|
||||
public SectionData() {
|
||||
@@ -47,9 +45,9 @@ public class SectionData implements IDataItem {
|
||||
name = name.toLowerCase();
|
||||
|
||||
if (!data.equals("no-load")) {
|
||||
IResource pagesInfo = getResource(getResourceLocation(data));
|
||||
IResource pagesInfo = source.getResource(source.getResourceLocation(data));
|
||||
if (pagesInfo != null) {
|
||||
String data = resourceToString(pagesInfo);
|
||||
String data = source.resourceToString(pagesInfo);
|
||||
if (!data.isEmpty())
|
||||
try {
|
||||
pages = new ArrayList<>(Arrays.asList(BookLoader.GSON.fromJson(data, PageData[].class)));
|
||||
@@ -65,15 +63,21 @@ public class SectionData implements IDataItem {
|
||||
|
||||
for (PageData page : pages) {
|
||||
page.parent = this;
|
||||
page.source = source;
|
||||
page.load();
|
||||
}
|
||||
|
||||
icon.location = getResourceLocation(icon.file, true);
|
||||
icon.location = source.getResourceLocation(icon.file, true);
|
||||
}
|
||||
|
||||
public void update(@Nullable StatFileWriter writer) {
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
String title = parent.strings.get(name);
|
||||
return title == null ? name : title;
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
return pages.size();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user