Skip to content

Plain unspliced unscaled unindexed pagefeatures#47

Open
KorrAn34 wants to merge 7 commits into
alegian:0.13from
KorrAn34:retry-dynren-pagefeatures
Open

Plain unspliced unscaled unindexed pagefeatures#47
KorrAn34 wants to merge 7 commits into
alegian:0.13from
KorrAn34:retry-dynren-pagefeatures

Conversation

@KorrAn34

Copy link
Copy Markdown

Re-re-re-re-implementation of pagefeatures. This PR contains a foundation for the three properties highlighted in the title (splicing paragraphs, adjusting scale and indexing at specific pages) but they are not used yet.

Currently, page features are put in their raw form one per page.
Figure features do not yet render their caption but the option to add them is there.

I figured out my own way how to extract the width and height from the layout system. When an EntryScreen is first opened, it does nothing, only calculates the layout (isFirstPass). Then it runs the layout again and does the actual rendering. Similar logic is used for turning pages so I think it is a valid option. When done without the re-initiation in raw afterLayout, the first double-page does not know what its maxWidth is but when pages are turned there and back it realises what it is supposed to do.

PS: the nullPointerException I was getting earlier if you remember was because I made forceIndex a Int? and gave the codec null as a default value. That did not slide. forceIndex is now a non-nullable Int and default value is -1 which will mean no preferred index.

@alegian alegian left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove forceIndex from this PR, its for later

Comment thread src/main/java/me/alegian/thavma/impl/common/research/ResearchEntry.kt Outdated
Comment thread src/main/java/me/alegian/thavma/impl/common/book/FormCharSeqFeature.kt Outdated
Comment thread src/main/java/me/alegian/thavma/impl/client/gui/book/EntryScreen.kt Outdated
Comment thread src/main/java/me/alegian/thavma/impl/init/registries/deferred/PageFeatureTypes.kt Outdated
Comment thread src/main/java/me/alegian/thavma/impl/client/event/T7ClientModEvents.kt Outdated
Comment thread src/main/java/me/alegian/thavma/impl/client/gui/book/DynamicRenderingHelper.kt Outdated
Comment thread src/main/java/me/alegian/thavma/impl/client/gui/book/EntryScreen.kt Outdated
Comment on lines +56 to +63
if (isFirstPass) {
afterLayout {
maxWidth = this@afterLayout.size.x.toInt()
maxHeight = this@afterLayout.size.y.toInt()
isFirstPass = false
init()
}
} else {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a red flag that should tell you: im not using the layout system correctly.
remove all usages of maxwidth & maxheight (including the parameters of initpagefeature). use height = derived{...} instead. if you need help tell me

Comment thread src/main/java/me/alegian/thavma/impl/client/gui/layout/LayoutExtensions.kt Outdated
Comment on lines +368 to +383
private fun addPageFeature(identifier: Char, entryKey: ResourceKey<ResearchEntry>, featureIndex: Int, text: String) {
val baseId = ResearchEntry.translationId(entryKey)
when (identifier) {
'P' -> add(ParagraphFeature.translationId(baseId, featureIndex), text.trimIndent().replace("\n", " "))
'T' -> add(TitleFeature.translationId(baseId, featureIndex), text.trimIndent().replace("\n", " "))
'F' -> add(FigureFeature.translationId(baseId, featureIndex), text.trimIndent().replace("\n", " "))
'R' -> add(RecipeFeature.translationId(baseId, featureIndex), text.trimIndent().replace("\n", " "))
}
}

companion object {
val PARAGRAPH = 'P'
val TITLE = 'T'
val FIGURE = 'F'
val RECIPE = 'R'
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave this open for me, ill find a way to make it more compact

val image: Texture,
val caption: Component?,
override val startsPage: Boolean = false,
override val forceIndex: Int = -1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont use -1 (anywhere) we're not writing c++ or something 😂. you already support null type

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason when I try to include this forceIndex with a nullable Int and a default null value in the CODEC, I get nullPointerExceptions because the JSON file cannot be parsed, the game does not allow null values there. I don't know why null Components are fine but I could not get the null forceIndex to work for the love of my life.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right that the game has some forced null checks deep inside codecs somewhere. i remember that ive made nullable codec helpers to bypass this, but ill need to remember them. another task for me i guess

Comment thread src/main/java/me/alegian/thavma/impl/client/gui/book/EntryScreen.kt Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants