Plain unspliced unscaled unindexed pagefeatures#47
Conversation
…ngHelper await, no adjustable size and each feature on a separate page for simplicity
alegian
left a comment
There was a problem hiding this comment.
also remove forceIndex from this PR, its for later
| if (isFirstPass) { | ||
| afterLayout { | ||
| maxWidth = this@afterLayout.size.x.toInt() | ||
| maxHeight = this@afterLayout.size.y.toInt() | ||
| isFirstPass = false | ||
| init() | ||
| } | ||
| } else { |
There was a problem hiding this comment.
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
| 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' | ||
| } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
dont use -1 (anywhere) we're not writing c++ or something 😂. you already support null type
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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 rawafterLayout, 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
nullPointerExceptionI was getting earlier if you remember was because I madeforceIndexaInt?and gave the codecnullas a default value. That did not slide.forceIndexis now a non-nullableIntand default value is -1 which will mean no preferred index.