mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
move some RenderConstants to correct class
This commit is contained in:
parent
c78f48b314
commit
45f26edd41
@ -16,6 +16,10 @@ package de.bixilon.minosoft.data.chat.message.internal
|
|||||||
import de.bixilon.minosoft.data.text.BaseComponent
|
import de.bixilon.minosoft.data.text.BaseComponent
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
|
||||||
|
|
||||||
class DebugChatMessage(message: ChatComponent) : InternalChatMessage(BaseComponent(RenderConstants.DEBUG_MESSAGES_PREFIX, ChatComponent.of(message).apply { this.setFallbackColor(ChatColors.BLUE) }))
|
class DebugChatMessage(message: ChatComponent) : InternalChatMessage(BaseComponent(PREFIX, ChatComponent.of(message).apply { this.setFallbackColor(ChatColors.BLUE) })) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val PREFIX = "§f[§e§lDEBUG§f] "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -22,7 +22,6 @@ import de.bixilon.minosoft.data.registries.chat.TypeProperties
|
|||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||||
import de.bixilon.minosoft.data.text.BaseComponent
|
import de.bixilon.minosoft.data.text.BaseComponent
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
|
||||||
|
|
||||||
open class InternalChatMessage(
|
open class InternalChatMessage(
|
||||||
val raw: ChatComponent,
|
val raw: ChatComponent,
|
||||||
@ -33,9 +32,10 @@ open class InternalChatMessage(
|
|||||||
raw.setFallbackColor(ChatUtil.DEFAULT_CHAT_COLOR)
|
raw.setFallbackColor(ChatUtil.DEFAULT_CHAT_COLOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val text: ChatComponent = BaseComponent(RenderConstants.INTERNAL_MESSAGES_PREFIX, raw)
|
override val text: ChatComponent = BaseComponent(PREFIX, raw)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TYPE = ChatMessageType(minosoft("internal_message"), TypeProperties("%s", listOf(ChatParameter.CONTENT), mapOf()), narration = null, position = ChatTextPositions.CHAT)
|
val TYPE = ChatMessageType(minosoft("internal_message"), TypeProperties("%s", listOf(ChatParameter.CONTENT), mapOf()), narration = null, position = ChatTextPositions.CHAT)
|
||||||
|
const val PREFIX = "§f[§a§lINTERNAL§f] "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,11 @@ package de.bixilon.minosoft.gui.rendering
|
|||||||
|
|
||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor.Companion.asColor
|
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||||
|
|
||||||
object RenderConstants {
|
object RenderConstants {
|
||||||
val EXPERIENCE_BAR_LEVEL_COLOR = "#80ff20".asColor()
|
|
||||||
|
|
||||||
const val COLORMAP_SIZE = 255
|
const val COLORMAP_SIZE = 255
|
||||||
|
|
||||||
const val DEBUG_MESSAGES_PREFIX = "§f[§e§lDEBUG§f] "
|
|
||||||
const val INTERNAL_MESSAGES_PREFIX = "§f[§a§lINTERNAL§f] "
|
|
||||||
|
|
||||||
val TEXT_BACKGROUND_COLOR = RGBColor(0, 0, 0, 80)
|
val TEXT_BACKGROUND_COLOR = RGBColor(0, 0, 0, 80)
|
||||||
|
|
||||||
@ -35,10 +31,7 @@ object RenderConstants {
|
|||||||
const val MAXIMUM_QUEUE_TIME_PER_FRAME = 20L
|
const val MAXIMUM_QUEUE_TIME_PER_FRAME = 20L
|
||||||
|
|
||||||
|
|
||||||
val DEBUG_TEXTURE_RESOURCE_LOCATION = minosoft("textures/debug.png")
|
val DEBUG_TEXTURE_RESOURCE_LOCATION = minosoft("debug").texture()
|
||||||
|
|
||||||
const val DOUBLE_PRESS_KEY_PRESS_MAX_DELAY = 300
|
|
||||||
const val DOUBLE_PRESS_DELAY_BETWEEN_PRESSED = 500
|
|
||||||
|
|
||||||
|
|
||||||
const val DEFAULT_LINE_WIDTH = 1.0f / 128.0f
|
const val DEFAULT_LINE_WIDTH = 1.0f / 128.0f
|
||||||
@ -48,6 +41,5 @@ object RenderConstants {
|
|||||||
|
|
||||||
const val DISABLE_GUI_CACHE = false
|
const val DISABLE_GUI_CACHE = false
|
||||||
|
|
||||||
const val OPENGL_DEBUG_MODE = false
|
|
||||||
const val DIRTY_BUFFER_UNBIND = true
|
const val DIRTY_BUFFER_UNBIND = true
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ import de.bixilon.minosoft.data.registries.enchantment.Enchantment
|
|||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.data.text.TextComponent
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.Atlas.Companion.get
|
import de.bixilon.minosoft.gui.rendering.gui.atlas.Atlas.Companion.get
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
import de.bixilon.minosoft.gui.rendering.gui.atlas.AtlasElement
|
||||||
@ -30,6 +29,7 @@ import de.bixilon.minosoft.gui.rendering.gui.elements.VerticalAlignments.Compani
|
|||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.AbstractButtonElement
|
import de.bixilon.minosoft.gui.rendering.gui.elements.input.button.AbstractButtonElement
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.AtlasImageElement
|
import de.bixilon.minosoft.gui.rendering.gui.elements.primitive.AtlasImageElement
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextElement
|
||||||
|
import de.bixilon.minosoft.gui.rendering.gui.hud.elements.hotbar.HotbarExperienceBarElement
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexConsumer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIVertexOptions
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class EnchantmentButtonElement(
|
|||||||
|
|
||||||
fun update(disabled: Boolean, cost: Int, enchantment: Enchantment?, level: Int) {
|
fun update(disabled: Boolean, cost: Int, enchantment: Enchantment?, level: Int) {
|
||||||
_disabled = disabled || cost <= 0
|
_disabled = disabled || cost <= 0
|
||||||
levelText.text = TextComponent(cost).color(RenderConstants.EXPERIENCE_BAR_LEVEL_COLOR)
|
levelText.text = TextComponent(cost).color(HotbarExperienceBarElement.LEVEL_COLOR)
|
||||||
textElement._chatComponent = if (enchantment == null) ChatComponent.EMPTY else TextComponent(enchantment.identifier.toMinifiedString() + " $level").color(ChatColors.BLUE)
|
textElement._chatComponent = if (enchantment == null) ChatComponent.EMPTY else TextComponent(enchantment.identifier.toMinifiedString() + " $level").color(ChatColors.BLUE)
|
||||||
textElement.forceSilentApply()
|
textElement.forceSilentApply()
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import de.bixilon.kotlinglm.vec2.Vec2
|
|||||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||||
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft
|
||||||
import de.bixilon.minosoft.data.text.TextComponent
|
import de.bixilon.minosoft.data.text.TextComponent
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor.Companion.asColor
|
||||||
import de.bixilon.minosoft.gui.rendering.font.renderer.element.TextRenderProperties
|
import de.bixilon.minosoft.gui.rendering.font.renderer.element.TextRenderProperties
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
import de.bixilon.minosoft.gui.rendering.gui.GUIRenderer
|
||||||
import de.bixilon.minosoft.gui.rendering.gui.atlas.Atlas.Companion.get
|
import de.bixilon.minosoft.gui.rendering.gui.atlas.Atlas.Companion.get
|
||||||
@ -66,7 +66,7 @@ class HotbarExperienceBarElement(guiRenderer: GUIRenderer) : Element(guiRenderer
|
|||||||
|
|
||||||
if (level > 0) {
|
if (level > 0) {
|
||||||
// level
|
// level
|
||||||
val text = TextElement(guiRenderer, TextComponent(level).apply { color = RenderConstants.EXPERIENCE_BAR_LEVEL_COLOR }, background = null, properties = TextRenderProperties(HorizontalAlignments.CENTER, shadow = false))
|
val text = TextElement(guiRenderer, TextComponent(level).apply { color = LEVEL_COLOR }, background = null, properties = TextRenderProperties(HorizontalAlignments.CENTER, shadow = false))
|
||||||
|
|
||||||
text.render(offset + Vec2i(HorizontalAlignments.CENTER.getOffset(size.x, text.size.x), -TEXT_PROPERTIES.lineHeight + 1), consumer, options)
|
text.render(offset + Vec2i(HorizontalAlignments.CENTER.getOffset(size.x, text.size.x), -TEXT_PROPERTIES.lineHeight + 1), consumer, options)
|
||||||
}
|
}
|
||||||
@ -95,5 +95,6 @@ class HotbarExperienceBarElement(guiRenderer: GUIRenderer) : Element(guiRenderer
|
|||||||
val ATLAS = minecraft("hud/hotbar/experience")
|
val ATLAS = minecraft("hud/hotbar/experience")
|
||||||
private val TEXT_PROPERTIES = TextRenderProperties(HorizontalAlignments.CENTER, shadow = false)
|
private val TEXT_PROPERTIES = TextRenderProperties(HorizontalAlignments.CENTER, shadow = false)
|
||||||
private val SIZE = Vec2(182, 5)
|
private val SIZE = Vec2(182, 5)
|
||||||
|
val LEVEL_COLOR = "#80ff20".asColor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ package de.bixilon.minosoft.gui.rendering.input.key.manager.binding.actions
|
|||||||
import de.bixilon.minosoft.config.key.KeyActions
|
import de.bixilon.minosoft.config.key.KeyActions
|
||||||
import de.bixilon.minosoft.config.key.KeyCodes
|
import de.bixilon.minosoft.config.key.KeyCodes
|
||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
|
||||||
import de.bixilon.minosoft.gui.rendering.input.key.manager.InputManager
|
import de.bixilon.minosoft.gui.rendering.input.key.manager.InputManager
|
||||||
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.KeyBindingFilterState
|
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.KeyBindingFilterState
|
||||||
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.KeyBindingState
|
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.KeyBindingState
|
||||||
@ -94,6 +93,9 @@ interface KeyActionFilter {
|
|||||||
|
|
||||||
|
|
||||||
object DoublePress : KeyActionFilter {
|
object DoublePress : KeyActionFilter {
|
||||||
|
const val PRESS_MAX_DELAY = 300
|
||||||
|
const val DELAY_BETWEEN_PRESSED = 500
|
||||||
|
|
||||||
|
|
||||||
override fun check(filter: KeyBindingFilterState, codes: Set<KeyCodes>, input: InputManager, name: ResourceLocation, state: KeyBindingState, code: KeyCodes, pressed: Boolean, millis: Long) {
|
override fun check(filter: KeyBindingFilterState, codes: Set<KeyCodes>, input: InputManager, name: ResourceLocation, state: KeyBindingState, code: KeyCodes, pressed: Boolean, millis: Long) {
|
||||||
if (!pressed) {
|
if (!pressed) {
|
||||||
@ -110,11 +112,11 @@ interface KeyActionFilter {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (millis - previous > RenderConstants.DOUBLE_PRESS_KEY_PRESS_MAX_DELAY) {
|
if (millis - previous > PRESS_MAX_DELAY) {
|
||||||
filter.satisfied = false
|
filter.satisfied = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (millis - state.lastChange <= RenderConstants.DOUBLE_PRESS_DELAY_BETWEEN_PRESSED) {
|
if (millis - state.lastChange <= DELAY_BETWEEN_PRESSED) {
|
||||||
filter.satisfied = false
|
filter.satisfied = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import de.bixilon.kutil.concurrent.lock.thread.ThreadMissmatchException
|
|||||||
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
import de.bixilon.minosoft.data.registries.identified.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderConstants
|
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderContext
|
import de.bixilon.minosoft.gui.rendering.RenderContext
|
||||||
import de.bixilon.minosoft.gui.rendering.events.ResizeWindowEvent
|
import de.bixilon.minosoft.gui.rendering.events.ResizeWindowEvent
|
||||||
import de.bixilon.minosoft.gui.rendering.shader.Shader
|
import de.bixilon.minosoft.gui.rendering.shader.Shader
|
||||||
@ -135,7 +134,7 @@ class OpenGLRenderSystem(
|
|||||||
glViewport(0, 0, it.size.x, it.size.y)
|
glViewport(0, 0, it.size.x, it.size.y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (RenderConstants.OPENGL_DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
glEnable(GL_DEBUG_OUTPUT)
|
glEnable(GL_DEBUG_OUTPUT)
|
||||||
glDebugMessageCallback({ source, type, id, severity, length, message, userParameter ->
|
glDebugMessageCallback({ source, type, id, severity, length, message, userParameter ->
|
||||||
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "OpenGL error: source=$source, type=$type, id=$id, severity=$severity, length=$length, message=$message, userParameter=$userParameter" }
|
Log.log(LogMessageType.RENDERING, LogLevels.VERBOSE) { "OpenGL error: source=$source, type=$type, id=$id, severity=$severity, length=$length, message=$message, userParameter=$userParameter" }
|
||||||
@ -327,6 +326,7 @@ class OpenGLRenderSystem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : RenderSystemFactory {
|
companion object : RenderSystemFactory {
|
||||||
|
const val DEBUG_MODE = false
|
||||||
|
|
||||||
override fun create(context: RenderContext) = OpenGLRenderSystem(context)
|
override fun create(context: RenderContext) = OpenGLRenderSystem(context)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user