Implemented a generic book interface

Converted all books to new book interface
Converted stats command to use the new book interface
This commit is contained in:
Oven Bread
2023-04-24 14:32:52 +00:00
committed by Ryan
parent 4b20cdd001
commit 323c653275
35 changed files with 2177 additions and 2385 deletions
@@ -1,164 +1,135 @@
package content.region.kandarin.seers.quest.elementalworkshop
import core.api.setQuestStage
import core.game.dialogue.DialoguePlugin
import core.game.dialogue.book.Book
import core.game.dialogue.book.BookLine
import core.game.dialogue.book.Page
import core.game.dialogue.book.PageSet
import content.global.handlers.iface.BookInterface
import content.global.handlers.iface.BookLine
import content.global.handlers.iface.Page
import content.global.handlers.iface.PageSet
import core.api.setAttribute
import core.game.interaction.IntType
import core.game.interaction.InteractionListener
import core.game.node.entity.player.Player
import core.plugin.Initializable
import org.rs09.consts.Items
/**
* Gloughs Journal book handler for The Grand Tree quest
*
* @author crop & szu
* @author crop & szu & ovenbreado
*/
@Initializable
class GloughsJournal : Book {
constructor(player: Player?) : super(player, "Glough's Journal", Items.GLOUGHS_JOURNAL_785, *arrayOf(
PageSet(
Page(
BookLine("<col=FF2D00>The migration failed!", 55),
BookLine("After spending half", 56),
BookLine("a century hiding", 57),
BookLine("underground you", 58),
BookLine("you would think", 59),
BookLine("that the great", 60),
BookLine("migration would have", 61),
BookLine("improved life on", 62),
BookLine("Gielinor for tree gnomes.", 63),
BookLine("However, rather", 64),
BookLine("than the great liberation", 65),
class GloughsJournal : InteractionListener {
companion object {
private val TITLE = "Glough's Journal"
private val CONTENTS = arrayOf(
PageSet(
Page(
BookLine("<col=FF2D00>The migration failed!", 55),
BookLine("After spending half", 56),
BookLine("a century hiding", 57),
BookLine("underground you", 58),
BookLine("you would think", 59),
BookLine("that the great", 60),
BookLine("migration would have", 61),
BookLine("improved life on", 62),
BookLine("Gielinor for tree gnomes.", 63),
BookLine("However, rather", 64),
BookLine("than the great liberation", 65),
),
Page(
BookLine("promised to us by", 65),
BookLine("King Healthorg at the", 66),
BookLine("end of the last age,", 67),
BookLine("we have been forced", 68),
BookLine("to live in hiding,", 69),
BookLine("up trees or in the", 70),
BookLine("gnome maze, laughed", 71),
BookLine("at and mocked by man.", 72),
BookLine("Living in constant", 73),
BookLine("fear of human aggression", 74),
BookLine("we are in a no better", 75),
)
),
Page(
BookLine("promised to us by", 65),
BookLine("King Healthorg at the", 66),
BookLine("end of the last age,", 67),
BookLine("we have been forced", 68),
BookLine("to live in hiding,", 69),
BookLine("up trees or in the", 70),
BookLine("gnome maze, laughed", 71),
BookLine("at and mocked by man.", 72),
BookLine("Living in constant", 73),
BookLine("fear of human aggression", 74),
BookLine("we are in a no better", 75),
)
),
PageSet(
Page(
BookLine("we are in a no better", 55),
BookLine("situation now than", 56),
BookLine("when we lived", 57),
BookLine("in the caves!", 58),
BookLine("Change must come soon!", 59),
BookLine("<col=FF2D00>They must be stopped!", 60),
BookLine("Today I heard of three", 61),
BookLine("more gnomes slain", 62),
BookLine("by Khazard's human", 63),
BookLine("troops for fun,", 64),
BookLine("I can't control", 65),
PageSet(
Page(
BookLine("we are in a no better", 55),
BookLine("situation now than", 56),
BookLine("when we lived", 57),
BookLine("in the caves!", 58),
BookLine("Change must come soon!", 59),
BookLine("<col=FF2D00>They must be stopped!", 60),
BookLine("Today I heard of three", 61),
BookLine("more gnomes slain", 62),
BookLine("by Khazard's human", 63),
BookLine("troops for fun,", 64),
BookLine("I can't control", 65),
),
Page(
BookLine("my anger!", 66),
BookLine("Humanity seems to", 67),
BookLine("have acquired a", 68),
BookLine("level of arrogance", 69),
BookLine("comparable to that", 70),
BookLine("of Zamorak, killing", 71),
BookLine("and pillaging at will!", 72),
BookLine("We are small and at", 73),
BookLine("heart not warriors", 74),
BookLine("but something must", 75),
)
),
Page(
BookLine("my anger!", 66),
BookLine("Humanity seems to", 67),
BookLine("have acquired a", 68),
BookLine("level of arrogance", 69),
BookLine("comparable to that", 70),
BookLine("of Zamorak, killing", 71),
BookLine("and pillaging at will!", 72),
BookLine("We are small and at", 73),
BookLine("heart not warriors", 74),
BookLine("but something must", 75),
)
),
PageSet(
Page(
BookLine("be done! We will", 55),
BookLine("pick up arms and", 56),
BookLine("go forth into the", 57),
BookLine("human world! We will", 58),
BookLine("defend ourselves and", 59),
BookLine("we will pursue justice", 60),
BookLine("for all gnomes who", 61),
BookLine("fell at the hands", 62),
BookLine("of humans!", 63),
BookLine("<col=FF2D00>Gaining support.", 64),
BookLine("", 65),
PageSet(
Page(
BookLine("be done! We will", 55),
BookLine("pick up arms and", 56),
BookLine("go forth into the", 57),
BookLine("human world! We will", 58),
BookLine("defend ourselves and", 59),
BookLine("we will pursue justice", 60),
BookLine("for all gnomes who", 61),
BookLine("fell at the hands", 62),
BookLine("of humans!", 63),
BookLine("<col=FF2D00>Gaining support.", 64),
BookLine("", 65),
),
Page(
BookLine("Some of the local", 66),
BookLine("gnomes seem strangely", 67),
BookLine("deluded about humans,", 68),
BookLine("many actually believe", 69),
BookLine("that humans are not", 70),
BookLine("all naturally evil", 71),
BookLine("but instead vary", 72),
BookLine("from person to person.", 73),
BookLine("This sort of talk", 74),
BookLine("could be the end", 75),
)
),
Page(
BookLine("Some of the local", 66),
BookLine("gnomes seem strangely", 67),
BookLine("deluded about humans,", 68),
BookLine("many actually believe", 69),
BookLine("that humans are not", 70),
BookLine("all naturally evil", 71),
BookLine("but instead vary", 72),
BookLine("from person to person.", 73),
BookLine("This sort of talk", 74),
BookLine("could be the end", 75),
)
),
PageSet(
Page(
BookLine("for the tree gnomes", 55),
BookLine("and I must continue", 56),
BookLine("to convince my fellow", 57),
BookLine("gnome folk the cold", 58),
BookLine("truth about these", 59),
BookLine("human creatures!", 60),
BookLine("How they will not", 61),
BookLine("stop until all gnome", 62),
BookLine("life is destroyed!", 63),
BookLine("Unless we can ", 64),
BookLine("destroy them first!", 65),
PageSet(
Page(
BookLine("for the tree gnomes", 55),
BookLine("and I must continue", 56),
BookLine("to convince my fellow", 57),
BookLine("gnome folk the cold", 58),
BookLine("truth about these", 59),
BookLine("human creatures!", 60),
BookLine("How they will not", 61),
BookLine("stop until all gnome", 62),
BookLine("life is destroyed!", 63),
BookLine("Unless we can ", 64),
BookLine("destroy them first!", 65),
)
)
)
)
) {}
constructor() {
/**
* empty.
*/
}
override fun finish() {
}
override fun display(set: Array<Page>) {
player.lock()
player.interfaceManager.open(getInterface())
for (i in 55..76) {
player.packetDispatch.sendString("", getInterface().id, i)
private fun display(player: Player, pageNum: Int, buttonID: Int): Boolean {
BookInterface.pageSetup(player, BookInterface.FANCY_BOOK_3_49, TITLE, CONTENTS)
return true
}
player.packetDispatch.sendString("", getInterface().id, 77)
player.packetDispatch.sendString("", getInterface().id, 78)
player.packetDispatch.sendString(getName(), getInterface().id, 6)
for (page in set) {
for (line in page.lines) {
player.packetDispatch.sendString(line.message, getInterface().id, line.child)
}
}
player.packetDispatch.sendInterfaceConfig(getInterface().id, 51, index < 1)
val lastPage = index == sets.size - 1
player.packetDispatch.sendInterfaceConfig(getInterface().id, 53, lastPage)
if (lastPage) {
finish()
}
player.unlock()
}
override fun newInstance(player: Player): DialoguePlugin {
return GloughsJournal(player)
}
override fun getIds(): IntArray {
// This is all handled in `BookreadOption.java` you need to manually
// register a new dialogue key for your file there.
return intArrayOf(49610762)
override fun defineListeners() {
on(Items.GLOUGHS_JOURNAL_785, IntType.ITEM, "read") { player, _ ->
setAttribute(player, "bookInterfaceCallback", ::display)
setAttribute(player, "bookInterfaceCurrentPage", 0)
display(player, 0, 0)
return@on true
}
}
}