Skip to content

Commit

Permalink
new: blackbar speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Dec 15, 2021
1 parent 8e6438b commit 599e410
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2G

# Define project properties.
mod_name=REDACTION
mod_ver=0.4.0
mod_ver=0.4.1
2 changes: 1 addition & 1 deletion src/main/kotlin/net/wyvest/redaction/Redaction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object Redaction {
private val particleGenerator = ParticleGenerator()

const val NAME = "REDACTION"
const val VERSION = "0.4.0"
const val VERSION = "0.4.1"
const val ID = "redaction"
val mc: Minecraft
get() = Minecraft.getMinecraft()
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/net/wyvest/redaction/config/RedactionConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import net.wyvest.redaction.Redaction.NAME
import net.wyvest.redaction.Redaction.hasChanged
import net.wyvest.redaction.Redaction.mc
import net.wyvest.redaction.gui.DownloadConfirmGui
import net.wyvest.redaction.hud.HudManager
import net.wyvest.redaction.utils.Updater
import java.awt.Color
import java.io.File
Expand Down Expand Up @@ -39,6 +40,16 @@ object RedactionConfig : Vigilant(File(Redaction.modDir, "${Redaction.ID}.toml")
)
var blackbar = false

@Property(
type = PropertyType.SLIDER,
name = "Blackbar Update Speed",
description = "Select the speed of the blackbar animation updating. Measured in milliseconds",
category = "Blackbar",
min = 10,
max = 100
)
var blackbarSpeed = 10

@Property(
type = PropertyType.COLOR,
name = "Blackbar Color",
Expand Down Expand Up @@ -100,5 +111,9 @@ object RedactionConfig : Vigilant(File(Redaction.modDir, "${Redaction.ID}.toml")
particles = newValue
hasChanged = true
}
registerListener("blackbarSpeed") { newValue: Int ->
blackbarSpeed = newValue
HudManager.elements[0].setTimer()
}
}
}
12 changes: 10 additions & 2 deletions src/main/kotlin/net/wyvest/redaction/hud/elements/BlackBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import net.wyvest.redaction.config.RedactionConfig
import net.wyvest.redaction.hud.Element
import net.wyvest.redaction.utils.GlUtil
import net.wyvest.redaction.utils.MathUtil
import java.awt.event.ActionListener
import javax.swing.Timer

class BlackBar : Element() {
Expand All @@ -21,8 +22,9 @@ class BlackBar : Element() {
private val texPath = ResourceLocation("textures/gui/widgets.png")
private var firstTime = true
private var entityplayer: EntityPlayer? = null
private var timer: Timer? = null

private val timer = Timer(25) {
private val timerTask: ActionListener = ActionListener {
if (entityplayer != null && mc.thePlayer != null && mc.theWorld != null && scaledResolution != null && partialTicks != null) {
data?.let {
val scaledHeight = scaledResolution!!.scaledHeight
Expand Down Expand Up @@ -53,12 +55,18 @@ class BlackBar : Element() {


override fun initialize() {
timer.start()
setTimer()
val resolution = ScaledResolution(Minecraft.getMinecraft())
scaledResolution = resolution
data = BlackBarData(-1.0F, resolution.scaledHeight - 22)
}

fun setTimer() {
timer?.stop()
timer = Timer(RedactionConfig.blackbarSpeed, timerTask)
timer?.start()
}

override fun render(
res: ScaledResolution,
partialTicks: Float
Expand Down

0 comments on commit 599e410

Please sign in to comment.