Instead of piling all the parameters into mysterious nonsense, use a style of builder pattern of creating UText objects.
Expectation:
UText()
.addText("My Text")
.applyColor(-4, Color.Red) --Applies the color to the last 4 characters; from the right
.addText(" is fantastic")
.applyColor(Color.Green) --Applies the color to the last added text (" is fantastic")
.addText("!!!!!!!!!!")
.applyColor(3, Color.Orange) --Applies the color to the first 3 characters; from the left
.addText(" This is great")
.applyColor(10, 15, Color.Yellow) --Applies the color to characters 10 through 15 (1-indexed), or "great"
.optimize()
Format objects will be expected to add apply(Format) functions to UTextBuilder. If this isn't possible with the class system, some alternative with automated magic will be provided (like .applyFormat(-4, Format("Color", Color.Red)) )
The following more traditional style would also be acceptable (this is what would internally be happening when you use builder methods):
UText({
text = "My Text is fantastic!!!!!!!!!! This is great"
formats = {
Format("Color", Color.Red).applyTo(4, 7),
Format("Color", Color.Green).applyTo(8, 13),
Format("Color", Color.Orange).applyTo(14, 16),
Format("Color", Color.Yellow).applyTo(26, 30)
}
})
Instead of piling all the parameters into mysterious nonsense, use a style of builder pattern of creating UText objects.
Expectation:
Format objects will be expected to add apply(Format) functions to UTextBuilder. If this isn't possible with the class system, some alternative with automated magic will be provided (like
.applyFormat(-4, Format("Color", Color.Red)))The following more traditional style would also be acceptable (this is what would internally be happening when you use builder methods):