aboutsummaryrefslogtreecommitdiff
path: root/features/hud
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-18 22:45:54 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-18 22:45:54 +0800
commitc87c6f2703d689375518f54905ae10e2edb42d41 (patch)
tree1686e97b83bf78f658aece231e7fde6f6f060105 /features/hud
parent082d9cf4af63495a3d8709b0ee87dc935ed986dc (diff)
downloadSoopyV2-c87c6f2703d689375518f54905ae10e2edb42d41.tar.gz
SoopyV2-c87c6f2703d689375518f54905ae10e2edb42d41.tar.bz2
SoopyV2-c87c6f2703d689375518f54905ae10e2edb42d41.zip
asd
Diffstat (limited to 'features/hud')
-rw-r--r--features/hud/HudTextElement.js56
1 files changed, 30 insertions, 26 deletions
diff --git a/features/hud/HudTextElement.js b/features/hud/HudTextElement.js
index d2a2c91..8646e45 100644
--- a/features/hud/HudTextElement.js
+++ b/features/hud/HudTextElement.js
@@ -15,7 +15,8 @@ class HudTextElement {
this.tempDisableTime = 0
- this.renderTextCache = [[""], [""]]
+ this.renderTextCache = [""]
+ this.renderBlackTextCache = [""]
this.textChanged = false
}
@@ -36,7 +37,8 @@ class HudTextElement {
this.blackText = "&0" + ChatLib.removeFormatting(text)
}
- this.renderTextCache = [this.text.split("\n"), this.blackText.split("\n")]
+ this.renderTextCache = this.text.split("\n")
+ this.renderBlackTextCache = this.blackText.split("\n")
return this
}
setToggleSetting(setting) {
@@ -67,11 +69,11 @@ class HudTextElement {
getWidth(locationBox = false) {
if (locationBox && this.editBaseWidth) return this.editBaseWidth
- return Math.max(...(this.getText()[0].map(a => Renderer.getStringWidth(ChatLib.removeFormatting(a)))))
+ return Math.max(...(this.getText().map(a => Renderer.getStringWidth(ChatLib.removeFormatting(a)))))
}
getHeight(locationBox = false) {
if (locationBox && this.editBaseHeight) return this.editBaseHeight
- return 9 * this.getText()[0].length
+ return 9 * this.getText().length
}
getText() {
@@ -109,28 +111,30 @@ class HudTextElement {
}
renderRaw() {
- let text = this.getText()
-
- text.forEach((line, i) => {
- Renderer.scale(this.locationSetting.scale, this.locationSetting.scale)
- switch (this.locationSetting.shadowType) {
- case 0:
- Renderer.drawString(line, this.locationSetting.x / this.locationSetting.scale, this.locationSetting.y / this.locationSetting.scale + 9 * i)
- break;
- 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;
- }
- })
+ try {
+ let text = this.getText()
+
+ text.forEach((line, i) => {
+ Renderer.scale(this.locationSetting.scale, this.locationSetting.scale)
+ switch (this.locationSetting.shadowType) {
+ case 0:
+ Renderer.drawString(line, this.locationSetting.x / this.locationSetting.scale, this.locationSetting.y / this.locationSetting.scale + 9 * i)
+ break;
+ 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;
+ }
+ })
+ } catch (e) { }//incase of wrong opengl context
}
}