Dynamic rendering#41
Conversation
This reverts commit 63a3219.
There was a problem hiding this comment.
it looks like you deleted content here
| } | ||
| } | ||
|
|
||
| fun relativeCenteredRenderable(renderable: Renderable, maxWidth: Int, texture: Texture) { |
There was a problem hiding this comment.
appears to only be used below, why not inline it
| private var maxWidth = BG.width/2 - 65 | ||
| private var maxHeight = BG.height - 90 |
There was a problem hiding this comment.
theres no point in passing maxwidth like this. the whole point of the layout system is to dynamically calculate/center all containers. didnt look in detail, but this can probably be achieved with a combination of containers/alignment options
There was a problem hiding this comment.
I am sorry I couldn't think of a better way. I am glad I somehow got the Rows(){} and Columns(){} to work.
| val mustOccupySetPage: Boolean | ||
| val preferredPageIndex: Int |
There was a problem hiding this comment.
mustOccupySetPage and preferredPageIndex i think are too complicated/hacky. i would remove them completely
There was a problem hiding this comment.
My thought was if you e.g. want a crafting recipe to always be on the first doublepage on the right, you specify it easily. If the preceding text overspills due to a large font size (coming in in parallax) then it could be annoying to have to turn pages to find the recipe.
There was a problem hiding this comment.
thats solvable via extra features (eg bookmarks, shortcuts, previews, whatever). buggy spaghetti code is not solvable
There was a problem hiding this comment.
because this should support other modders addons, and other modders wont understand this
| event.register(PageFeatureTypes.PARAGRAPH.get(), ParagraphFeatureRenderer) | ||
| event.register(PageFeatureTypes.TITLE.get(), TitleFeatureRenderer) | ||
| event.register(PageFeatureTypes.FIGURE.get(), FigureFeatureRenderer) | ||
| event.register(PageFeatureTypes.FORMATTED.get(), FormattedTextFeatureRenderer) |
There was a problem hiding this comment.
which by the way, we eventually need to add ways for modders to render their custom recipes if they want to
| println("lineheight is $lineHeight") | ||
|
|
||
| // so that we get at least 2 lines at the end of the first page | ||
| val lineHeight = ceil((font.lineHeight * scale + 2)) |
|
|
||
| fun GuiGraphics.drawCenteredString(font: Font, text: Component, centerX: Float, color: Int = 0) { | ||
| drawString(font, text, (centerX - font.width(text) / 2f).toInt(), 0, color, false) | ||
| drawString(font, text, (centerX - font.width(text.visualOrderText) / 2f).toInt(), 0, color, false) |
There was a problem hiding this comment.
the point is to use the function below to reduce copy paste
| ComponentSerialization.CODEC.listOf().fieldOf("text").forGetter { _ -> | ||
| emptyList() | ||
| } |
There was a problem hiding this comment.
?? youre passing emptyList as getter???
There was a problem hiding this comment.
read codecs and understand what forGetter is
| Codec.BOOL.optionalFieldOf("starts_page", false).forGetter(ParagraphFeature::mustStartPage), | ||
| Codec.BOOL.optionalFieldOf("has_set_page", false).forGetter(ParagraphFeature::mustOccupySetPage), | ||
| Codec.INT.optionalFieldOf("preferred_page", 1).forGetter(ParagraphFeature::preferredPageIndex) |
There was a problem hiding this comment.
why are the string names different from the getters
| return { entryKey, titleIndex -> | ||
| return { _, _ -> |
There was a problem hiding this comment.
returning a lambda that ignores arguments makes no sense
There was a problem hiding this comment.
also this func is unused? we need to test an example
Please don't look at the files that were changed just jump in the game and look at the one story research entry thanks you won't regret it ok bye
Implemented rendering of research entry titles, paragraphs and figures (images with optional captions) so that one does not have to think of the page layout beforehand but rather just plop everything in there and it handles itself automatically.
Makes use of "PageFeatures" with three important Boolean properties
mustStartPage - this feature will cause a page break, starting on a new page
coversWholePage - if it is known that this feature is going to cover the whole page already during research entry creation, this is a small quality of life thing that makes it more straightforward to order entries
mustOccupySetPage - if set to true, this feature will always appear on a given page in the entry (represented by the next field in the constructor - preferredPageIndex). Must have sufficient content to cover pages preceding this and does not check whether features with the same preferred index all fit in the page, if they overspill outside the screen, so be it.
Also the code might be redundant in places and still contains some informative and debug snippets especially in DynamicRenderingHelper so please don't hate me uwu