diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-29 12:04:52 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2022-05-29 12:04:52 +0800 |
commit | a6593709b0e1e99e241b6c163fe66623685b6efc (patch) | |
tree | 9714e82716caf9edd6be05a1822fa492eb6756ed /features/hud/HudTextElement.js | |
parent | a7dcf231cc43c9ef73d6a969203c2dafd2ce8caf (diff) | |
download | SoopyV2-a6593709b0e1e99e241b6c163fe66623685b6efc.tar.gz SoopyV2-a6593709b0e1e99e241b6c163fe66623685b6efc.tar.bz2 SoopyV2-a6593709b0e1e99e241b6c163fe66623685b6efc.zip |
first part of supporting java side rendering
Diffstat (limited to 'features/hud/HudTextElement.js')
-rw-r--r-- | features/hud/HudTextElement.js | 53 |
1 files changed, 16 insertions, 37 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; } } } |