mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
sign: option for text aligning
Aligning text on a sign is now a config option. Closes GH-7
This commit is contained in:
parent
7a9b092784
commit
906195d4c1
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user