More MGUIGraphics moves
This commit is contained in:
parent
1dab485d29
commit
716d251ca0
@ -155,9 +155,9 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
RenderSystem.setShaderColor(0f, 0f, 0f, 0.6f)
|
||||
|
||||
val size = minecraft.window.guiScaledHeight.coerceAtMost(minecraft.window.guiScaledWidth).toFloat() * 0.35f
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
|
||||
drawArc(
|
||||
event.guiGraphics,
|
||||
wrap.drawArc(
|
||||
minecraft.window.guiScaledWidth / 2f,
|
||||
minecraft.window.guiScaledHeight / 2f,
|
||||
size,
|
||||
@ -226,8 +226,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
if (lastSelectedDegree != null && lastSelectedFeature != null) {
|
||||
RenderSystem.setShaderColor(85 / 255f, 197 / 255f, 255 / 255f, 0.3f * lastSelectProgressGlobal)
|
||||
|
||||
drawArc(
|
||||
event.guiGraphics,
|
||||
wrap.drawArc(
|
||||
minecraft.window.guiScaledWidth / 2f,
|
||||
minecraft.window.guiScaledHeight / 2f,
|
||||
ru.dbotthepony.mc.otm.core.math.linearInterpolation(lastSelectProgressGlobal, size, size * 1.2f),
|
||||
@ -245,7 +244,6 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
val poseStack = event.guiGraphics.pose()
|
||||
poseStack.pushPose()
|
||||
poseStack.translate(minecraft.window.guiScaledWidth.toDouble() / 2f, minecraft.window.guiScaledHeight.toDouble() / 2f, 0.0)
|
||||
val wrap = MGUIGraphics(event.guiGraphics)
|
||||
|
||||
for ((index, feature) in features.withIndex()) {
|
||||
var sin = sin((index + 0.5) * degreePerSlice).toFloat()
|
||||
@ -264,7 +262,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
|
||||
if (feature.isOnCooldown && feature.cooldownPercent > 0.0f) {
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
|
||||
drawArc(event.guiGraphics, shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble())
|
||||
wrap.drawArc(shift * cos, -shift * sin, iconSize / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent.toDouble())
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
||||
wrap.draw(formatTickDuration(feature.cooldown), shift * cos, -shift * sin + iconSize / 1.5f, color = RGBAColor.WHITE, gravity = RenderGravity.CENTER_CENTER)
|
||||
@ -302,7 +300,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon
|
||||
feature.renderIcon(wrap, x, y, COOLDOWN_ICON_SIZE, COOLDOWN_ICON_SIZE)
|
||||
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
|
||||
drawArc(event.guiGraphics, x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false)
|
||||
wrap.drawArc(x, y, COOLDOWN_ICON_SIZE / 2f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * feature.cooldownPercent, alignAtCenter = false)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
||||
wrap.draw(formatTickDuration(feature.cooldown), x + COOLDOWN_ICON_SIZE / 2f, y + COOLDOWN_ICON_SIZE + 1f, color = RGBAColor.WHITE, gravity = RenderGravity.TOP_CENTER)
|
||||
|
@ -369,7 +369,7 @@ object MatteryGUI {
|
||||
|
||||
val percent = ((stack.item.getUseDuration(stack) - ply.useItemRemainingTicks + minecraft.partialTick) / 5f).coerceIn(0f, 1f)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
|
||||
drawArc(graphics, x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true)
|
||||
drawArc(graphics.pose(), x + 8f, y + 8f, 8f, 0f, PI / 2.0, PI / 2.0 + PI * 2.0 * percent, alignAtCenter = true)
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
|
||||
return true
|
||||
|
@ -11,6 +11,8 @@ import net.minecraft.util.FormattedCharSequence
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
// polyfill class for 1.19.4 and older
|
||||
class MGUIGraphics(val parent: GuiGraphics) {
|
||||
@ -248,6 +250,17 @@ class MGUIGraphics(val parent: GuiGraphics) {
|
||||
)
|
||||
}
|
||||
|
||||
fun drawArc(
|
||||
x: Float,
|
||||
y: Float,
|
||||
outerRadius: Float,
|
||||
innerRadius: Float = 0f,
|
||||
startDegree: Double = 0.0,
|
||||
endDegree: Double = PI * 2.0,
|
||||
steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12),
|
||||
alignAtCenter: Boolean = true
|
||||
) = drawArc(pose, x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter)
|
||||
|
||||
companion object {
|
||||
private val defaultUV = UVCoords(0f, 0f, 1f, 1f)
|
||||
}
|
||||
|
@ -381,32 +381,6 @@ fun popScissorRect() {
|
||||
|
||||
val currentScissorRect get() = scissorStack.lastOrNull()
|
||||
|
||||
fun TextureAtlasSprite.render(
|
||||
stack: PoseStack,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float,
|
||||
height: Float,
|
||||
winding: UVWindingOrder = UVWindingOrder.NORMAL
|
||||
) {
|
||||
RenderSystem.setShaderTexture(0, atlasLocation())
|
||||
|
||||
if (winding.isIdentity) {
|
||||
renderTexturedRect(stack.last().pose(), x, y, width, height, uv = UVCoords(u0, v0, u1, v1))
|
||||
} else {
|
||||
renderTexturedRect(stack.last().pose(), x, y, width, height, uv = winding.translate(u0, v0, u1, v1))
|
||||
}
|
||||
}
|
||||
|
||||
fun TextureAtlasSprite.render(
|
||||
graphics: MGUIGraphics,
|
||||
x: Float = 0f,
|
||||
y: Float = 0f,
|
||||
width: Float,
|
||||
height: Float,
|
||||
winding: UVWindingOrder = UVWindingOrder.NORMAL
|
||||
) = render(graphics.pose, x, y, width, height, winding)
|
||||
|
||||
fun determineTooltipPosition(x: Float, y: Float, width: Float, height: Float): Pair<Float, Float> {
|
||||
val windowWidth = minecraft.window.guiScaledWidth.toFloat()
|
||||
val windowHeight = minecraft.window.guiScaledHeight.toFloat()
|
||||
@ -479,18 +453,6 @@ fun drawArc(
|
||||
alignAtCenter: Boolean = true
|
||||
) = drawArc(stack.last().pose(), x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter)
|
||||
|
||||
fun drawArc(
|
||||
graphics: GuiGraphics,
|
||||
x: Float,
|
||||
y: Float,
|
||||
outerRadius: Float,
|
||||
innerRadius: Float = 0f,
|
||||
startDegree: Double = 0.0,
|
||||
endDegree: Double = PI * 2.0,
|
||||
steps: Int = (outerRadius * (endDegree - startDegree) * 4.0).roundToInt().coerceAtLeast(12),
|
||||
alignAtCenter: Boolean = true
|
||||
) = drawArc(graphics.pose(), x, y, outerRadius, innerRadius, startDegree, endDegree, steps, alignAtCenter)
|
||||
|
||||
fun uploadArc(
|
||||
matrix: Matrix4f,
|
||||
builder: VertexConsumer,
|
||||
|
@ -13,7 +13,6 @@ import ru.dbotthepony.mc.otm.client.minecraft
|
||||
import ru.dbotthepony.mc.otm.client.render.RenderGravity
|
||||
import ru.dbotthepony.mc.otm.client.render.determineTooltipPosition
|
||||
import ru.dbotthepony.mc.otm.client.render.sprites.sprite
|
||||
import ru.dbotthepony.mc.otm.client.render.render
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.util.DiscreteScrollBarPanel
|
||||
import ru.dbotthepony.mc.otm.core.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||
@ -112,7 +111,7 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
||||
SQUARE_THIN.render(graphics, width = width, height = height)
|
||||
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f)
|
||||
minecraft.mobEffectTextures.get(effect.effect).render(graphics, x = 3f, y = 3f, width = width - 6f, height = height - 6f)
|
||||
graphics.renderSprite(minecraft.mobEffectTextures.get(effect.effect), x = 3f, y = 3f, width = width - 6f, height = height - 6f)
|
||||
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 1f)
|
||||
graphics.draw(formatTickDuration(effect.duration), width / 2f, height / 2f, scale = 0.75f, gravity = RenderGravity.CENTER_CENTER, color = RGBAColor.WHITE)
|
||||
@ -128,8 +127,8 @@ open class EffectListPanel<out S : Screen> @JvmOverloads constructor(
|
||||
val renderWidth = 18f
|
||||
val renderHeight = 18f
|
||||
|
||||
minecraft.mobEffectTextures.get(effect.effect).render(
|
||||
graphics.pose,
|
||||
graphics.renderSprite(
|
||||
minecraft.mobEffectTextures.get(effect.effect),
|
||||
x = x + 8f,
|
||||
y = y + BAR.height / 2f - renderHeight / 2f,
|
||||
width = renderWidth,
|
||||
|
Loading…
Reference in New Issue
Block a user