Skip to content

Commit

Permalink
reset to empty since vanilla mode has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jun 29, 2024
1 parent b07f6a5 commit 40c7ebc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cc.polyfrost.oneconfig.utils.dsl.runAsync
import org.polyfrost.crosshair.utils.*

class CrosshairEntry(
var img: String = "iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAGUlEQVR42mNgGH7gPxAMd83/iQCjATYkAQAXJEO9Ljp2dQAAAABJRU5ErkJggg\u003d\u003d",
var img: String = "iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAEUlEQVR42mNgGAWjYBQMIgAAA5MAAecADfkAAAAASUVORK5CYII\u003d",
) {

@Slider(name = "Scale %", min = 0f, max = 200f)
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/org/polyfrost/crosshair/config/Drawer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {

private val colorSelector = ColorSelector()

var inArea = false

init {
toBufferedImage(ModConfig.newCurrentCrosshair.img)?.let { it ->
if (it.width == 0 || it.height == 0) return@let
loadImage(it, false, ModConfig.newCurrentCrosshair)?.let {
CrosshairRenderer.updateTexture(it)
}
Expand Down Expand Up @@ -151,7 +154,9 @@ object Drawer : BasicOption(null, null, "", "", "", "", 2) {

val scissor = ScissorHelper.INSTANCE.scissor(vg, (x + 349).toFloat(), y.toFloat(), 644f, 256f)

if (scissor.isInScissor(inputHandler.mouseX(), inputHandler.mouseY())) {
inArea = scissor.isInScissor(inputHandler.mouseX(), inputHandler.mouseY())

if (inArea) {
inputHandler.unblockDWheel()

val dWheel = inputHandler.dWheel.toFloat()
Expand Down
34 changes: 27 additions & 7 deletions src/main/kotlin/org/polyfrost/crosshair/elements/PresetElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

package org.polyfrost.crosshair.elements

import cc.polyfrost.oneconfig.gui.elements.*
import cc.polyfrost.oneconfig.renderer.asset.*
import cc.polyfrost.oneconfig.gui.elements.BasicButton
import cc.polyfrost.oneconfig.gui.elements.BasicElement
import cc.polyfrost.oneconfig.platform.Platform
import cc.polyfrost.oneconfig.renderer.asset.AssetHelper
import cc.polyfrost.oneconfig.renderer.asset.Image
import cc.polyfrost.oneconfig.renderer.asset.SVG
import cc.polyfrost.oneconfig.utils.InputHandler
import cc.polyfrost.oneconfig.utils.color.ColorPalette
import cc.polyfrost.oneconfig.utils.dsl.nanoVGHelper
import org.polyfrost.crosshair.PolyCrosshair
import org.polyfrost.crosshair.config.CrosshairEntry
import org.polyfrost.crosshair.config.Drawer
import org.polyfrost.crosshair.utils.*
import org.polyfrost.crosshair.utils.copy
import org.polyfrost.crosshair.utils.export
import org.polyfrost.crosshair.utils.toBufferedImage
import java.io.File
import java.util.UUID
import java.util.*

private val remove = SVG("/assets/polycrosshair/trashcan.svg")
private val copy = SVG("/assets/polycrosshair/copy.svg")
Expand All @@ -33,14 +39,28 @@ class PresetElement(val crosshair: CrosshairEntry) : BasicElement(149, 149, Colo
}
}

override fun update(x: Float, y: Float, inputHandler: InputHandler) {
hovered = Drawer.inArea && inputHandler.isAreaHovered(x - hitBoxX, y - hitBoxY, (width + hitBoxX).toFloat(), (height + hitBoxY).toFloat())
pressed = hovered && Platform.getMousePlatform().isButtonDown(0)
clicked = inputHandler.isClicked(false) && hovered

if (clicked) {
toggled = !toggled
onClick()
}

currentColor = if (hoverFx) colorAnimation.getColor(hovered, pressed)
else colorAnimation.getColor(false, false)
}

override fun draw(vg: Long, x: Float, y: Float, inputHandler: InputHandler?) {
super.draw(vg, x, y, inputHandler)
val half = 135 / 2f
nanoVGHelper.translate(vg, x + 7 + half, y + 7 + half)
nanoVGHelper.rotate(vg, crosshair.rotation.toDouble())
nanoVGHelper.drawImage(vg, image, - half, - half, 135f, 135f, -1)
nanoVGHelper.rotate(vg, - crosshair.rotation.toDouble())
nanoVGHelper.translate(vg, - (x + 7 + half), - (y + 7 + half))
nanoVGHelper.drawImage(vg, image, -half, -half, 135f, 135f, -1)
nanoVGHelper.rotate(vg, -crosshair.rotation.toDouble())
nanoVGHelper.translate(vg, -(x + 7 + half), -(y + 7 + half))
if (hovered) {
copyButton.draw(vg, x + 117, y + 32, inputHandler)
removeButton.draw(vg, x + 117, y, inputHandler)
Expand Down

0 comments on commit 40c7ebc

Please sign in to comment.