1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
class HudTextElement{
constructor(){
this.text = ""
this.toggleSetting = undefined
this.locationSetting = undefined
this.blackText = "&0" + ChatLib.removeFormatting(this.text)
this.editTempTimeV = 0
this.editTempTextV = undefined
this.tempDisableTime = 0
}
setText(text){
this.text = text
if(this.locationSetting.shadowType === 2){
this.blackText = "&0" + ChatLib.removeFormatting(text)
}
return this
}
setToggleSetting(setting){
this.toggleSetting = setting
return this
}
setLocationSetting(setting){
this.locationSetting = setting
setting.setParent(this)
return this
}
render(){
if(this.toggleSetting && !this.toggleSetting.getValue() || !this.locationSetting) return
if(Date.now()-this.tempDisableTime < 100) return
this.renderRaw()
}
getText(){
let text = this.text
let blackText = this.blackText
if(Date.now()-this.editTempTimeV < 100){
if(this.editTempTextV){
text = this.editTempTextV
blackText = "&0" + ChatLib.removeFormatting(text)
}
if(ChatLib.removeFormatting(text) === ""){
text = "&0Empty string"
blackText = "&0Empty string"
}
}
return [text.split("\n"), blackText.split("\n")]
}
renderRaw(){
let [text, blackText] = 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:
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;
}
})
Renderer.scale(1, 1)
}
}
export default HudTextElement
|