var breaks = q.desc.split('\n');
var newLines = [];
for(var i = 0; i < breaks.length; i ++){
newLines = newLines + breaks + ' breakLine ';
}
this.questBitmap.textColor = this.normalColor();
var lines = this.sliceText(newLines, this.contentsWidth());
for (var i = 0; i < lines.length; i += 1) {
this.questBitmap.drawText(lines, 0, this.lineY, this.contentsWidth(), this.lineHeight());
this.write();
}
this.drawHorzLine(this.lineY);
this.write();
}
I am trying to add line breaks to a string but my JavaScript skills are really poor and I could use some help. I am working with Gameus Quest System plugin which draws the quest description in this part of the script, however, it does not recognize \n as a line break but draws a space instead. I'm trying to fix that.
The snippet above is what I am using right now. My plan is to use the 'breakLine' part to identify the breaks and then turn them into actual breaks (which is what I'm having trouble with).
Any ideas?
Edit: I think this is what controls the sliceText part:
var newLines = [];
for(var i = 0; i < breaks.length; i ++){
newLines = newLines + breaks + ' breakLine ';
}
this.questBitmap.textColor = this.normalColor();
var lines = this.sliceText(newLines, this.contentsWidth());
for (var i = 0; i < lines.length; i += 1) {
this.questBitmap.drawText(lines, 0, this.lineY, this.contentsWidth(), this.lineHeight());
this.write();
}
this.drawHorzLine(this.lineY);
this.write();
}
I am trying to add line breaks to a string but my JavaScript skills are really poor and I could use some help. I am working with Gameus Quest System plugin which draws the quest description in this part of the script, however, it does not recognize \n as a line break but draws a space instead. I'm trying to fix that.
The snippet above is what I am using right now. My plan is to use the 'breakLine' part to identify the breaks and then turn them into actual breaks (which is what I'm having trouble with).
Any ideas?
Edit: I think this is what controls the sliceText part:
Code:
Window_Base.prototype.sliceText = function(text, width) {
var words = text.split(" ");
if (words.length === 1)
return words;
var result = [];
var current_text = words.shift();
for (var i = 0; i < words.length; i += 1) {
var word = words[i];
var textW = this.contents.measureTextWidth(current_text + " " + word);
if (textW > width) {
result.push(current_text);
current_text = word;
} else {
current_text += " " + word;
}
if (i >= words.length - 1)
result.push(current_text)
}
return result
}