profiles: hud

This commit is contained in:
Bixilon 2021-12-04 15:29:36 +01:00
parent 0cde1daa2c
commit c50db6eb56
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
24 changed files with 266 additions and 137 deletions

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.config.config
import de.bixilon.minosoft.config.config.chat.ChatConfig
import de.bixilon.minosoft.config.config.game.GameConfig
import de.bixilon.minosoft.config.config.general.GeneralConfig
import de.bixilon.minosoft.config.config.network.NetworkConfig
@ -22,7 +21,6 @@ import de.bixilon.minosoft.config.config.server.ServerConfig
data class Config(
val general: GeneralConfig = GeneralConfig(),
val game: GameConfig = GameConfig(),
val chat: ChatConfig = ChatConfig(),
val network: NetworkConfig = NetworkConfig(),
val server: ServerConfig = ServerConfig(),
)

View File

@ -1,19 +0,0 @@
/*
* Minosoft
* Copyright (C) 2020 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.config.chat
data class ChatConfig(
var colored: Boolean = true,
var obfuscated: Boolean = true,
)

View File

@ -15,11 +15,8 @@ package de.bixilon.minosoft.config.config.game
import de.bixilon.minosoft.config.config.game.controls.ControlsGameConfig
import de.bixilon.minosoft.config.config.game.graphics.GraphicsGameConfig
import de.bixilon.minosoft.config.config.game.hud.HUDGameConfig
data class GameConfig(
var graphics: GraphicsGameConfig = GraphicsGameConfig(),
var hud: HUDGameConfig = HUDGameConfig(),
var controls: ControlsGameConfig = ControlsGameConfig(),
var skin: SkinConfig = SkinConfig(),
)

View File

@ -1,20 +0,0 @@
/*
* Minosoft
* Copyright (C) 2021 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.config.game.hud
data class ChatConfig(
var enabled: Boolean = true,
var width: Int = 320,
var height: Int = 180,
)

View File

@ -1,20 +0,0 @@
/*
* Minosoft
* Copyright (C) 2021 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.config.game.hud
data class InternalMessagesConfig(
var enabled: Boolean = true,
var width: Int = 320,
var height: Int = 120,
)

View File

@ -16,6 +16,5 @@ package de.bixilon.minosoft.config.config.network
import com.squareup.moshi.Json
data class NetworkConfig(
@Json(name = "fake_network_brand") var fakeNetworkBrand: Boolean = false,
@Json(name = "show_lan_servers") var showLanServers: Boolean = true,
)

View File

@ -8,6 +8,7 @@ import de.bixilon.minosoft.config.profile.profiles.block.BlockProfileManager
import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfileManager
import de.bixilon.minosoft.config.profile.profiles.entity.EntityProfileManager
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfileManager
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
@ -36,6 +37,7 @@ object GlobalProfileManager {
RenderingProfileManager,
BlockProfileManager,
ConnectionProfileManager,
HUDProfileManager,
)
private val SELECTED_PROFILES_TYPE: MapType = Jackson.MAPPER.typeFactory.constructMapType(HashMap::class.java, ResourceLocation::class.java, String::class.java)
val CLASS_MAPPING: Map<Class<out Profile>, ProfileManager<*>>

View File

@ -10,6 +10,8 @@ import de.bixilon.minosoft.config.profile.profiles.entity.EntityProfile
import de.bixilon.minosoft.config.profile.profiles.entity.EntityProfileManager
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfile
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfile
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfile
import de.bixilon.minosoft.config.profile.profiles.particle.ParticleProfileManager
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfile
@ -26,4 +28,5 @@ data class ProfileCollection(
val rendering: RenderingProfile = RenderingProfileManager.selected,
val block: BlockProfile = BlockProfileManager.selected,
val connection: ConnectionProfile = ConnectionProfileManager.selected,
val hud: HUDProfile = HUDProfileManager.selected,
)

View File

@ -5,6 +5,7 @@ import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.deleg
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.latestVersion
import de.bixilon.minosoft.config.profile.profiles.eros.general.GeneralC
import de.bixilon.minosoft.config.profile.profiles.eros.server.ServerC
import de.bixilon.minosoft.config.profile.profiles.eros.text.TextC
/**
* Profile for Eros
@ -19,8 +20,9 @@ class ErosProfile(
override val description by delegate(description ?: "")
val general: GeneralC = GeneralC()
val server: ServerC = ServerC()
val general = GeneralC()
val server = ServerC()
val text = TextC()
override fun toString(): String {
return ErosProfileManager.getName(this)

View File

@ -11,13 +11,21 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.config.game.hud
package de.bixilon.minosoft.config.profile.profiles.eros.text
import com.squareup.moshi.Json
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager.delegate
data class HUDGameConfig(
var scale: Float = 2.0f,
var crosshair: CrosshairConfig = CrosshairConfig(),
var chat: ChatConfig = ChatConfig(),
@Json(name = "internal_messages") var internalMessages: InternalMessagesConfig = InternalMessagesConfig(),
)
class TextC {
/**
* Displays colored text
* If disables it displays the css defined language (defaults to white)
*/
var colored by delegate(true)
/**
* Enables the obfuscated formatting style
* If false, the text will just blink
*/
var obfuscated by delegate(true)
}

View File

@ -0,0 +1,37 @@
package de.bixilon.minosoft.config.profile.profiles.hud
import de.bixilon.minosoft.config.profile.profiles.Profile
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager.delegate
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager.latestVersion
import de.bixilon.minosoft.config.profile.profiles.hud.chat.ChatC
import de.bixilon.minosoft.config.profile.profiles.hud.crosshair.CrosshairC
/**
* Profile for hud (rendering)
*/
class HUDProfile(
description: String? = null,
) : Profile {
override var initializing: Boolean = true
private set
override var saved: Boolean = true
override val version: Int = latestVersion
override val description by delegate(description ?: "")
/**
* The scale of the hud
* Must be non-negative
*/
var scale by delegate(2.0f) { check(it >= 0.0f) { "HUD scale must be non-negative" } }
val chat = ChatC()
val crosshair = CrosshairC()
override fun toString(): String {
return HUDProfileManager.getName(this)
}
init {
initializing = false
}
}

View File

@ -0,0 +1,36 @@
package de.bixilon.minosoft.config.profile.profiles.hud
import com.google.common.collect.HashBiMap
import de.bixilon.minosoft.config.profile.GlobalProfileManager
import de.bixilon.minosoft.config.profile.ProfileManager
import de.bixilon.minosoft.modding.event.master.GlobalEventMaster
import de.bixilon.minosoft.util.KUtil.toResourceLocation
import de.bixilon.minosoft.util.KUtil.unsafeCast
import java.util.concurrent.locks.ReentrantLock
object HUDProfileManager : ProfileManager<HUDProfile> {
override val namespace = "minosoft:hud".toResourceLocation()
override val latestVersion = 1
override val saveLock = ReentrantLock()
override val profileClass = HUDProfile::class.java
override var currentLoadingPath: String? = null
override val profiles: HashBiMap<String, HUDProfile> = HashBiMap.create()
override var selected: HUDProfile = null.unsafeCast()
set(value) {
field = value
GlobalProfileManager.selectProfile(this, value)
GlobalEventMaster.fireEvent(HUDProfileSelectEvent(value))
}
override fun createDefaultProfile(name: String): HUDProfile {
currentLoadingPath = name
val profile = HUDProfile("Default hud profile")
currentLoadingPath = null
profiles[name] = profile
return profile
}
}

View File

@ -0,0 +1,7 @@
package de.bixilon.minosoft.config.profile.profiles.hud
import de.bixilon.minosoft.modding.event.events.Event
class HUDProfileSelectEvent(
val profile: HUDProfile,
) : Event

View File

@ -0,0 +1,56 @@
/*
* Minosoft
* Copyright (C) 2021 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.hud.chat
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager.delegate
import de.bixilon.minosoft.config.profile.profiles.hud.chat.internal.InternalC
import de.bixilon.minosoft.protocol.packets.c2s.play.ClientSettingsC2SP
class ChatC {
val internal = InternalC()
/**
* Hides the chat
*/
var hidden by delegate(false)
/**
* The width of the chat in scaled pixels
*/
var width by delegate(320)
/**
* The height of the chat in scaled pixels
*/
var height by delegate(180)
/**
* ToDo: Unknown purpose
* Will be sent to the server
*/
var textFiltering by delegate(false) // ToDo: Implement in the client
/**
* If false, the chat will appear in white
* Will be sent to the server
*/
var chatColors by delegate(true) // ToDo: Implement in the client
/**
* Chat mode
* Will be sent to the server
*/
var chatMode by delegate(ClientSettingsC2SP.ChatModes.EVERYTHING)
}

View File

@ -11,11 +11,24 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.config.game
package de.bixilon.minosoft.config.profile.profiles.hud.chat.internal
import com.squareup.moshi.Json
import de.bixilon.minosoft.data.player.Arms
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager.delegate
data class SkinConfig(
@Json(name = "main_arm") val mainArm: Arms = Arms.RIGHT,
)
class InternalC {
/**
* Hides the internal chat
*/
var hidden by delegate(false)
/**
* The width of the internal chat in scaled pixels
*/
var width by delegate(320)
/**
* The height of the internal chat in scaled pixels
*/
var height by delegate(180)
}

View File

@ -11,14 +11,19 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.config.game.hud
package de.bixilon.minosoft.config.profile.profiles.hud.crosshair
import com.squareup.moshi.Json
import de.bixilon.minosoft.config.profile.profiles.hud.HUDProfileManager.delegate
import de.bixilon.minosoft.data.text.ChatColors
import de.bixilon.minosoft.data.text.RGBColor
data class CrosshairConfig(
var enabled: Boolean = true,
@Json(name = "complementary_color") var complementaryColor: Boolean = true,
var color: RGBColor = ChatColors.WHITE,
)
class CrosshairC {
/**
* Inverts the color of the crosshair according to the background color
*/
var complementaryColor by delegate(true)
/**
* The color of the crosshair
*/
var color by delegate(ChatColors.WHITE)
}

View File

@ -12,7 +12,6 @@
*/
package de.bixilon.minosoft.data.player
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.data.Axes
import de.bixilon.minosoft.data.abilities.Gamemodes
import de.bixilon.minosoft.data.abilities.ItemCooldown
@ -581,7 +580,7 @@ class LocalPlayerEntity(
get() = healthCondition.hp.toDouble()
override val mainArm: Arms
get() = Minosoft.config.config.game.skin.mainArm
get() = connection.profiles.connection.mainArm
companion object {
private val CLIMBABLE_TAG = "minecraft:climbable".toResourceLocation()

View File

@ -12,7 +12,7 @@
*/
package de.bixilon.minosoft.data.text
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.profile.profiles.eros.ErosProfileManager
import de.bixilon.minosoft.data.text.events.ClickEvent
import de.bixilon.minosoft.data.text.events.HoverEvent
import de.bixilon.minosoft.gui.eros.dialog.ErosErrorReport.Companion.report
@ -131,7 +131,7 @@ open class TextComponent(
override fun getJavaFXText(nodes: ObservableList<Node>): ObservableList<Node> {
val text = Text(this.message)
this.color?.let {
if (Minosoft.config.config.chat.colored) {
if (ErosProfileManager.selected.text.colored) {
text.fill = Color.rgb(it.red, it.green, it.blue)
}
} ?: let {
@ -140,8 +140,8 @@ open class TextComponent(
for (chatFormattingCode in formatting) {
when (chatFormattingCode) {
PreChatFormattingCodes.OBFUSCATED -> {
// ToDo: potential memory/performance leak: Stop timeline, when TextComponent isn't shown anymore
val obfuscatedTimeline = if (Minosoft.config.config.chat.obfuscated) {
// ToDo: This is just slow
val obfuscatedTimeline = if (ErosProfileManager.selected.text.obfuscated) {
Timeline(
KeyFrame(Duration.millis(50.0), {
val chars = text.text.toCharArray()

View File

@ -13,10 +13,10 @@
package de.bixilon.minosoft.gui.rendering.gui.hud
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listenRendering
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.gui.rendering.Drawable
import de.bixilon.minosoft.gui.rendering.RenderWindow
@ -58,6 +58,7 @@ class HUDRenderer(
val connection: PlayConnection,
override val renderWindow: RenderWindow,
) : Renderer, OtherDrawable {
private val profile = connection.profiles.hud
override val renderSystem: RenderSystem = renderWindow.renderSystem
val shader = renderWindow.renderSystem.createShader("minosoft:hud".toResourceLocation())
var scaledSize: Vec2i = renderWindow.window.size
@ -87,16 +88,11 @@ class HUDRenderer(
private fun registerDefaultElements() {
registerElement(DebugHUDElement)
if (Minosoft.config.config.game.hud.crosshair.enabled) {
registerElement(CrosshairHUDElement)
}
registerElement(CrosshairHUDElement)
registerElement(BossbarHUDElement)
if (Minosoft.config.config.game.hud.chat.enabled) {
registerElement(ChatHUDElement)
}
if (Minosoft.config.config.game.hud.internalMessages.enabled) {
registerElement(InternalMessagesHUDElement)
}
registerElement(ChatHUDElement)
registerElement(InternalMessagesHUDElement)
registerElement(BreakProgressHUDElement)
registerElement(TabListHUDElement)
registerElement(HotbarHUDElement)
@ -105,19 +101,22 @@ class HUDRenderer(
registerElement(ScoreboardHUDElement)
}
override fun init() {
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> {
scaledSize = Vec2i(Vec2(it.size) / Minosoft.config.config.game.hud.scale)
matrix = glm.ortho(0.0f, scaledSize.x.toFloat(), scaledSize.y.toFloat(), 0.0f)
matrixChange = true
private fun recalculateMatrices(windowSize: Vec2i = renderWindow.window.size, scale: Float = profile.scale) {
scaledSize = Vec2i(Vec2(windowSize) / scale)
matrix = glm.ortho(0.0f, scaledSize.x.toFloat(), scaledSize.y.toFloat(), 0.0f)
matrixChange = true
for (element in hudElements.toSynchronizedMap().values) {
if (element is LayoutedHUDElement<*>) {
element.layout.silentApply()
}
element.apply()
for (element in hudElements.toSynchronizedMap().values) {
if (element is LayoutedHUDElement<*>) {
element.layout.silentApply()
}
})
element.apply()
}
}
override fun init() {
connection.registerEvent(CallbackEventInvoker.of<ResizeWindowEvent> { recalculateMatrices(it.size) })
profile::scale.listenRendering(this, profile = profile) { recalculateMatrices(scale = it) }
atlasManager.init()
registerDefaultElements()

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.chat
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listenRendering
import de.bixilon.minosoft.data.ChatTextPositions
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextFlowElement
@ -28,15 +28,23 @@ import glm_.vec2.Vec2i
class ChatHUDElement(hudRenderer: HUDRenderer) : LayoutedHUDElement<TextFlowElement>(hudRenderer) {
private val connection = renderWindow.connection
private val profile = connection.profiles.hud
private val chatProfile = profile.chat
override val layout = TextFlowElement(hudRenderer, 20000)
override var enabled: Boolean
get() = !chatProfile.hidden
set(value) {
chatProfile.hidden = !value
}
override val layoutOffset: Vec2i
get() = Vec2i(2, hudRenderer.scaledSize.y - layout.size.y - BOTTOM_OFFSET)
init {
val config = Minosoft.config.config.game.hud.chat
layout.prefMaxSize = Vec2i(config.width, config.height)
layout.prefMaxSize = Vec2i(chatProfile.width, chatProfile.height)
chatProfile::width.listenRendering(this, profile = profile) { layout.prefMaxSize = Vec2i(it, layout.prefMaxSize.y) }
chatProfile::height.listenRendering(this, profile = profile) { layout.prefMaxSize = Vec2i(layout.prefMaxSize.x, it) }
}
@ -48,7 +56,7 @@ class ChatHUDElement(hudRenderer: HUDRenderer) : LayoutedHUDElement<TextFlowElem
layout += it.message
})
connection.registerEvent(CallbackEventInvoker.of<InternalMessageReceiveEvent> {
if (Minosoft.config.config.game.hud.internalMessages.enabled) {
if (!profile.chat.internal.hidden) {
return@of
}
layout += it.message

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.chat
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listenRendering
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.gui.rendering.gui.elements.text.TextFlowElement
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
@ -26,22 +26,28 @@ import glm_.vec2.Vec2i
class InternalMessagesHUDElement(hudRenderer: HUDRenderer) : LayoutedHUDElement<TextFlowElement>(hudRenderer) {
private val connection = renderWindow.connection
private val profile = connection.profiles.hud
private val internalChatProfile = profile.chat.internal
override val layout = TextFlowElement(hudRenderer, 15000)
override var enabled: Boolean
get() = !internalChatProfile.hidden
set(value) {
internalChatProfile.hidden = !value
}
override val layoutOffset: Vec2i
get() = hudRenderer.scaledSize - Vec2i(layout.size.x, layout.size.y + BOTTOM_OFFSET)
init {
val config = Minosoft.config.config.game.hud.internalMessages
layout.prefMaxSize = Vec2i(config.width, config.height)
layout.prefMaxSize = Vec2i(internalChatProfile.width, internalChatProfile.height)
internalChatProfile::width.listenRendering(this, profile = profile) { layout.prefMaxSize = Vec2i(it, layout.prefMaxSize.y) }
internalChatProfile::height.listenRendering(this, profile = profile) { layout.prefMaxSize = Vec2i(layout.prefMaxSize.x, it) }
}
override fun init() {
connection.registerEvent(CallbackEventInvoker.of<InternalMessageReceiveEvent> {
layout += it.message
})
connection.registerEvent(CallbackEventInvoker.of<InternalMessageReceiveEvent> { layout += it.message })
}

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.gui.hud.elements.other
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listen
import de.bixilon.minosoft.data.abilities.Gamemodes
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer
@ -28,25 +28,29 @@ import de.bixilon.minosoft.util.KUtil.toResourceLocation
import de.bixilon.minosoft.util.collections.floats.DirectArrayFloatList
class CrosshairHUDElement(hudRenderer: HUDRenderer) : CustomHUDElement(hudRenderer) {
private val profile = hudRenderer.connection.profiles.hud
private val crosshairProfile = profile.crosshair
private lateinit var crosshairAtlasElement: HUDAtlasElement
private var mesh: GUIMesh? = null
private var previousDebugEnabled: Boolean? = true
private var reapply = true
override fun init() {
crosshairAtlasElement = hudRenderer.atlasManager[ATLAS_NAME]!!
crosshairProfile::color.listen(this, profile = profile) { reapply = true }
}
override fun draw() {
val debugHUDElement: DebugHUDElement? = hudRenderer[DebugHUDElement]
if (debugHUDElement?.enabled != previousDebugEnabled) {
if (debugHUDElement?.enabled != previousDebugEnabled || reapply) {
apply()
previousDebugEnabled = debugHUDElement?.enabled
}
val mesh = mesh ?: return
if (Minosoft.config.config.game.hud.crosshair.complementaryColor) {
if (crosshairProfile.complementaryColor) {
renderWindow.renderSystem.reset(blending = true, sourceAlpha = BlendingFunctions.ONE_MINUS_DESTINATION_COLOR, destinationAlpha = BlendingFunctions.ONE_MINUS_SOURCE_COLOR)
} else {
renderWindow.renderSystem.reset()
@ -60,15 +64,13 @@ class CrosshairHUDElement(hudRenderer: HUDRenderer) : CustomHUDElement(hudRender
mesh?.unload()
this.mesh = null
val config = Minosoft.config.config.game.hud.crosshair
val mesh = GUIMesh(renderWindow, hudRenderer.matrix, DirectArrayFloatList(42))
// Custom draw to make the crosshair inverted
if (renderWindow.connection.player.gamemode == Gamemodes.SPECTATOR) {
val hitResult = renderWindow.inputHandler.camera.target ?: return
if (hitResult is EntityRaycastHit && (hitResult !is BlockRaycastHit || renderWindow.connection.world.getBlockEntity(hitResult.blockPosition) == null)) {
if (hitResult !is EntityRaycastHit && (hitResult !is BlockRaycastHit || renderWindow.connection.world.getBlockEntity(hitResult.blockPosition) == null)) {
return
}
}
@ -82,13 +84,14 @@ class CrosshairHUDElement(hudRenderer: HUDRenderer) : CustomHUDElement(hudRender
val start = (hudRenderer.scaledSize - CROSSHAIR_SIZE) / 2
mesh.addQuad(start, start + CROSSHAIR_SIZE, 0, crosshairAtlasElement, config.color, null)
mesh.addQuad(start, start + CROSSHAIR_SIZE, 0, crosshairAtlasElement, crosshairProfile.color, null)
// ToDo: Attack indicator
mesh.load()
this.mesh = mesh
this.reapply = false
}

View File

@ -32,6 +32,13 @@ class ClientSettingsManager(
blocks::simulationDistance.listen(this, profile = blocks) { connection.world.view.simulationDistance = it }
val hud = connection.profiles.hud
val chat = hud.chat
chat::chatMode.listen(this, profile = hud) { sendClientSettings() }
chat::textFiltering.listen(this, profile = hud) { sendClientSettings() }
chat::chatColors.listen(this, profile = hud) { sendClientSettings() }
profile::mainArm.listen(this, profile = profile) { sendClientSettings() }
profile::playerListing.listen(this, profile = profile) { sendClientSettings() }
@ -46,6 +53,8 @@ class ClientSettingsManager(
profile::language.listen(this, profile = profile) { sendLanguage() }
connection.profiles.eros.general::language.listen(this, profile = connection.profiles.eros) { sendLanguage() }
// ToDo: Load new language files
}
@Synchronized
@ -60,13 +69,13 @@ class ClientSettingsManager(
fun sendClientSettings() {
connection.sendPacket(ClientSettingsC2SP(
locale = (language).toLanguageTag(),
chatColors = true, // ToDo
locale = language.toString(),
chatColors = connection.profiles.hud.chat.chatColors,
viewDistance = connection.profiles.block.viewDistance,
chatMode = ClientSettingsC2SP.ChatModes.EVERYTHING, // ToDo
chatMode = connection.profiles.hud.chat.chatMode,
skinParts = profile.skin.skinParts,
mainArm = profile.mainArm,
disableTextFiltering = true, // ToDo
disableTextFiltering = !connection.profiles.hud.chat.textFiltering,
allowListing = profile.playerListing,
))
}

View File

@ -170,6 +170,7 @@ class JoinGameS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
connection.settingsManager.sendClientSettings()
// ToDo: This has nothing to do here!
val brandName = DefaultRegistries.DEFAULT_PLUGIN_CHANNELS_REGISTRY.forVersion(connection.version)[DefaultPluginChannels.BRAND]!!.resourceLocation
val buffer = PlayOutByteBuffer(connection)
buffer.writeString("vanilla") // ToDo: Remove prefix