diff options
Diffstat (limited to 'features/hud')
-rw-r--r-- | features/hud/HudTextElement.js | 53 | ||||
-rw-r--r-- | features/hud/index.js | 28 |
2 files changed, 26 insertions, 55 deletions
diff --git a/features/hud/HudTextElement.js b/features/hud/HudTextElement.js index 46c660d..de031a2 100644 --- a/features/hud/HudTextElement.js +++ b/features/hud/HudTextElement.js @@ -1,3 +1,5 @@ +import { HudText } from "../../utils/renderJavaUtils" + class HudTextElement { constructor() { this.text = "" @@ -5,8 +7,6 @@ class HudTextElement { this.toggleSetting = undefined this.locationSetting = undefined - this.blackText = "&0" + ChatLib.removeFormatting(this.text) - this.editTempTimeV = 0 this.editTempTextV = undefined @@ -16,8 +16,9 @@ class HudTextElement { this.tempDisableTime = 0 this.renderTextCache = [""] - this.renderBlackTextCache = [""] this.textChanged = false + + this.renderElm = new HudText([""], 0, 0, true).startRender() } setBaseEditWidth(width) { @@ -34,25 +35,30 @@ class HudTextElement { if (text === this.text) return this this.text = text - if (this.locationSetting && this.locationSetting.shadowType === 2) { - this.blackText = "&0" + ChatLib.removeFormatting(text) - } + this.renderTextCache = ChatLib.addColor(this.text).split("\n") - this.renderTextCache = this.text.split("\n") - this.renderBlackTextCache = this.blackText.split("\n") + this.renderElm.setText(this.renderTextCache) return this } setToggleSetting(setting) { this.toggleSetting = setting + setting.onChange = () => { + if (this.toggleSetting.getValue()) { + this.renderElm.startRender() + } else { + this.renderElm.stopRender() + } + } return this } setLocationSetting(setting) { this.locationSetting = setting setting.setParent(this) - if (this.locationSetting.shadowType === 2) { - this.blackText = "&0" + ChatLib.removeFormatting(text) + setting.onChange = () => { + this.renderElm.setX(this.locationSetting.x).setY(this.locationSetting.y).setScale(this.locationSetting.scale) } + this.renderElm.setX(this.locationSetting.x).setY(this.locationSetting.y).setScale(this.locationSetting.scale) return this } @@ -93,24 +99,6 @@ class HudTextElement { return this.renderTextCache } - getBlackText() { - if (Date.now() - this.editTempTimeV < 100) { - let text = this.text - let blackText = this.blackText - if (this.editTempTextV) { - text = this.editTempTextV - blackText = "&0" + ChatLib.removeFormatting(text) - } - - if (ChatLib.removeFormatting(text) === "") { - blackText = "&0Empty string" - } - - return blackText.split("\n") - } - return this.renderBlackTextCache - } - renderRaw() { let text = this.getText() @@ -123,15 +111,6 @@ class HudTextElement { case 1: Renderer.drawStringWithShadow(line, this.locationSetting.x / this.locationSetting.scale, this.locationSetting.y / this.locationSetting.scale + 9 * i) break; - case 2: - let blackText = this.getBlackText() - Renderer.drawString(blackText[i], (this.locationSetting.x + 1) / this.locationSetting.scale, this.locationSetting.y / this.locationSetting.scale + 9 * i) - Renderer.drawString(blackText[i], (this.locationSetting.x - 1) / this.locationSetting.scale, this.locationSetting.y / this.locationSetting.scale + 9 * i) - Renderer.drawString(blackText[i], this.locationSetting.x / this.locationSetting.scale, (this.locationSetting.y + 1) / this.locationSetting.scale + 9 * i) - Renderer.drawString(blackText[i], this.locationSetting.x / this.locationSetting.scale, (this.locationSetting.y - 1) / this.locationSetting.scale + 9 * i) - - Renderer.drawString(line, this.locationSetting.x / this.locationSetting.scale, this.locationSetting.y / this.locationSetting.scale + 9 * i) - break; } } } diff --git a/features/hud/index.js b/features/hud/index.js index 46c4d17..b7ea05a 100644 --- a/features/hud/index.js +++ b/features/hud/index.js @@ -137,6 +137,7 @@ class Hud extends Feature { scale: this.spotifyElement.locationSetting.scale, shadowType: this.spotifyElement.locationSetting.shadowType }) + this.spotifyElement2.renderElm.stopRender() let hudStatTypes = { "cata": "Catacombs level + Exp", @@ -312,6 +313,14 @@ class Hud extends Feature { } tick() { + if (this.fpsFastSetting.getValue()) { + if (this.fpsLowSetting.getValue()) { + this.fpsElement.setText("&6Fps&7> &f" + Math.round(this.fps.get()) + "&7/" + Math.round(this.lowFps.get())) + } else { + this.fpsElement.setText("&6Fps&7> &f" + Math.round(this.fps.get())) + } + } + if (!this.lagEnabled.getValue()) return if (this.packetMoves > 0) { this.secondPackets++ @@ -330,22 +339,9 @@ class Hud extends Feature { } renderHud() { - if (this.fpsFastSetting.getValue()) { - if (this.fpsLowSetting.getValue()) { - this.fpsElement.setText("&6Fps&7> &f" + Math.round(this.fps.get()) + "&7/" + Math.round(this.lowFps.get())) - } else { - this.fpsElement.setText("&6Fps&7> &f" + Math.round(this.fps.get())) - } - } - - for (let element of this.hudElements) { - element.render() - } - if (this.showSpotifyPlaying.getValue() && Date.now() - this.spotifyElement.tempDisableTime > 100) { let scale = this.spotifyElement.locationSetting.scale let spotifyWidth1 = this.spotifyElement.getWidth() * scale - this.spotifyElement.render() this.spotifyElement2.locationSetting.x = this.spotifyElement.locationSetting.x + spotifyWidth1 this.spotifyElement2.locationSetting.y = this.spotifyElement.locationSetting.y this.spotifyElement2.locationSetting.scale = scale @@ -374,10 +370,6 @@ class Hud extends Feature { if (this.witherImpactCooldownSetting.getValue() && Date.now() - this.lastWitherImpact < 10000) { Renderer.drawString(Math.max(0, Math.ceil((5000 - (Date.now() - this.lastWitherImpact)) / 1000)) + "s", Renderer.screen.getWidth() / 2 - Renderer.getStringWidth(Math.max(0, Math.ceil((5000 - (Date.now() - this.lastWitherImpact)) / 1000)) + "s") / 2, Renderer.screen.getHeight() / 2 - 15) } - - for (let stat of this.hudStat) { - stat.textElement.render() - } } renderWorld() { @@ -485,7 +477,7 @@ class Hud extends Feature { if (!Player.getPlayer()) return if (!Player.getInventory()) return - if (!this.FeatureManager.features["dataLoader"].class.isInSkyblock) { + if (this.FeatureManager.features["dataLoader"] && !this.FeatureManager.features["dataLoader"].class.isInSkyblock) { this.soulflowElement.setText("") this.petElement.setText("") return |