sign: option for text aligning

Aligning text on a sign is now a config option. Closes GH-7
This commit is contained in:
Bixilon 2023-06-15 21:38:30 +02:00
parent 7a9b092784
commit 906195d4c1
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 60 additions and 2 deletions

View File

@ -15,6 +15,7 @@ package de.bixilon.minosoft.config.profile.profiles.block.rendering
import de.bixilon.minosoft.config.profile.delegate.primitive.BooleanDelegate
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfile
import de.bixilon.minosoft.config.profile.profiles.block.rendering.entities.EntitiesC
class RenderingC(profile: BlockProfile) {
@ -23,4 +24,6 @@ class RenderingC(profile: BlockProfile) {
* If set position based random block models are disabled
*/
var antiMoirePattern by BooleanDelegate(profile, true, "profile.block.rendering.anti_moire_pattern")
val entities = EntitiesC(profile)
}

View File

@ -0,0 +1,21 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.profile.profiles.block.rendering.entities
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfile
import de.bixilon.minosoft.config.profile.profiles.block.rendering.entities.sign.SignC
class EntitiesC(profile: BlockProfile) {
val sign = SignC(profile)
}

View File

@ -0,0 +1,25 @@
/*
* Minosoft
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.profile.profiles.block.rendering.entities.sign
import de.bixilon.minosoft.config.profile.delegate.types.EnumDelegate
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfile
import de.bixilon.minosoft.gui.rendering.gui.elements.HorizontalAlignments
class SignC(profile: BlockProfile) {
/**
* Font alignment of the text on a sign
*/
var fontAlignment by EnumDelegate(profile, HorizontalAlignments.LEFT, HorizontalAlignments)
}

View File

@ -14,6 +14,8 @@
package de.bixilon.minosoft.gui.rendering.gui.elements
import de.bixilon.kotlinglm.vec2.Vec2
import de.bixilon.kutil.enums.EnumUtil
import de.bixilon.kutil.enums.ValuesEnum
enum class HorizontalAlignments {
LEFT,
@ -21,7 +23,10 @@ enum class HorizontalAlignments {
RIGHT,
;
companion object {
companion object : ValuesEnum<HorizontalAlignments> {
override val VALUES = values()
override val NAME_MAP = EnumUtil.getEnumValues(VALUES)
fun HorizontalAlignments.getOffset(width: Float, childWidth: Float): Float {
return when (this) {
LEFT -> 0.0f

View File

@ -74,8 +74,12 @@ class SignBlockEntityRenderer(
}
textMesh.data.ensureSize(primitives * textMesh.order.size * SingleWorldMesh.WorldMeshStruct.FLOATS_PER_VERTEX)
val alignment = context.connection.profiles.block.rendering.entities.sign.fontAlignment
val properties = if (alignment == TEXT_PROPERTIES.alignment) TEXT_PROPERTIES else TEXT_PROPERTIES.copy(alignment = alignment)
for (line in sign.lines) {
ChatComponentRenderer.render3dFlat(context, textPosition, TEXT_PROPERTIES, Vec3(0.0f, -yRotation, 0.0f), MAX_SIZE, mesh, line, light)
ChatComponentRenderer.render3dFlat(context, textPosition, properties, Vec3(0.0f, -yRotation, 0.0f), MAX_SIZE, mesh, line, light)
textPosition.y -= 0.11f
}
}