Skip to content

Commit

Permalink
scuffed mouse icons for tool gun overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
ttttdoy committed Jun 27, 2024
1 parent 4023869 commit 2368565
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions src/main/kotlin/breadmod/hud/ToolGunOverlay.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import breadmod.datagen.tool_gun.BreadModToolGunModeProvider.Companion.TOOL_GUN_
import breadmod.datagen.tool_gun.ModToolGunModeDataLoader
import breadmod.item.tool_gun.ToolGunItem
import breadmod.item.tool_gun.ToolGunItem.Companion.MODE_NAMESPACE_TAG
import com.mojang.blaze3d.platform.InputConstants
import com.mojang.blaze3d.vertex.PoseStack
import net.minecraft.ChatFormatting
import net.minecraft.client.gui.GuiGraphics
Expand Down Expand Up @@ -58,6 +59,8 @@ class ToolGunOverlay: IGuiOverlay {
// Icon renders
pGuiGraphics.blit(overlayTexture, pX + 1, pY + 33, 0, 41, 8, 8)

// start rendering key (with the key letter on them) and mouse icons, fix positioning on description and controls, set up 9 sliced key texture for wider keys

// Action source
drawScaledText(Component.literal(namespace).withStyle(ChatFormatting.BLUE, ChatFormatting.ITALIC),
pPose, pGuiGraphics, pGui, pX + 2, pY + 2, 0.8f, true
Expand All @@ -72,20 +75,38 @@ class ToolGunOverlay: IGuiOverlay {
drawScaledText((pMode?.tooltip?.copy() ?: modTranslatable(TOOL_GUN_DEF, "broken_tooltip")), pPose, pGuiGraphics, pGui,
pX + 13, pY + 43, 0.4f, true
)
// Keybinds
// KeyBinds
pMode?.keyBinds?.forEachIndexed { index, control ->
val moved = ((index+1) * 9) + 3
val moved = ((index+1) * 12) + 2
drawScaledText(
toolGunBindList[control]!!.translatedKeyMessage.copy()
.withStyle { it.withColor(ChatFormatting.GOLD).withItalic(true) }
.append(control.toolGunComponent.copy().withStyle(ChatFormatting.WHITE)),
pPose, pGuiGraphics, pGui,
pX + 43, pY + 43 + moved, 1f, true
pX + 10, pY + 43 + moved, 1f, true
)
// toolGunBindList[control]?.key = InputConstants.getKey("key.mouse.right")
when(toolGunBindList[control]?.key) {
getInput("key.mouse.right") -> {
pPose.pushPose()
pPose.scaleFlat(0.68f)
pGuiGraphics.blit(overlayTexture, pX , pY + 69 + moved, 240, 63, 16, 16)
pPose.popPose()
}
getInput("key.mouse.middle") -> {
pPose.pushPose()
pPose.scaleFlat(0.68f)
pGuiGraphics.blit(overlayTexture, pX , pY + 73 + moved, 240, 47, 16, 16)
pPose.popPose()
}
}
}
pPose.popPose()
}

private fun getInput(input: String) = InputConstants.getKey(input)


private fun drawScaledText(pText: Component, pPose: PoseStack, pGuiGraphics: GuiGraphics, pGui: ForgeGui, pX: Int, pY: Int, pScale: Float, pDropShadow: Boolean) {
pPose.scaleFlat(pScale)
pGuiGraphics.drawString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ToolGunItemRenderer : BlockEntityWithoutLevelRenderer(

val f: Float = 1f + timer
if(!instance.isPaused) angle += f; angle %= 360
println(angle)
// println(angle)

pPoseStack.pushPose()
// todo smooth rotation after firing toolgun, quickly tapering off. GameRenderer.java@1177 found a function that uses the same posestack calls as this, could be used for smooth anims
Expand Down

0 comments on commit 2368565

Please sign in to comment.