-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Books may now have several 'repositories' which they load sections from - Page numbers dynamically calculated
- Loading branch information
Showing
10 changed files
with
131 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,5 @@ | |
|
||
@SideOnly(Side.CLIENT) | ||
public interface IDataItem { | ||
|
||
int cascadeLoad(); | ||
void load(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/slimeknights/mantle/client/book/repository/BookRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package slimeknights.mantle.client.book.repository; | ||
|
||
import java.util.List; | ||
import slimeknights.mantle.client.book.data.SectionData; | ||
|
||
public abstract class BookRepository { | ||
|
||
public final boolean hasAppearanceData; | ||
|
||
public BookRepository () { | ||
this(false); | ||
} | ||
|
||
public BookRepository (boolean hasAppearanceData) { | ||
this.hasAppearanceData = hasAppearanceData; | ||
} | ||
|
||
public abstract List<SectionData> getSections(); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/slimeknights/mantle/client/book/repository/FileRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package slimeknights.mantle.client.book.repository; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import slimeknights.mantle.client.book.BookLoader; | ||
import slimeknights.mantle.client.book.data.SectionData; | ||
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 static slimeknights.mantle.client.book.ResourceHelper.setRoot; | ||
|
||
public class FileRepository extends BookRepository { | ||
|
||
public final String location; | ||
|
||
public FileRepository(String location) { | ||
this(location, false); | ||
} | ||
|
||
public FileRepository(String location, boolean hasAppearanceData) { | ||
super(hasAppearanceData); | ||
|
||
this.location = location; | ||
} | ||
|
||
@Override | ||
public List<SectionData> getSections() { | ||
setRoot(location); | ||
return new ArrayList<>(Arrays.asList(BookLoader.GSON.fromJson(resourceToString(getResource(getResourceLocation("index.json"))), SectionData[].class))); | ||
} | ||
} |
Oops, something went wrong.