Superior AI will fix wrap for me
This commit is contained in:
parent
b878bbbac5
commit
3d3454e92d
1 changed files with 49 additions and 1 deletions
|
|
@ -2289,7 +2289,7 @@ function Window_GlossaryComplete() {
|
|||
};
|
||||
|
||||
Window_Glossary.prototype.standardFontSize = function() {
|
||||
return param.FontSize ? param.FontSize : Window_Base.prototype.standardFontFace();
|
||||
return param.FontSize ? param.FontSize - 2 : Window_Base.prototype.standardFontFace();
|
||||
};
|
||||
|
||||
Window_Glossary.prototype.calcMaxPages = function(index) {
|
||||
|
|
@ -2640,14 +2640,62 @@ function Window_GlossaryComplete() {
|
|||
|
||||
Window_Glossary.prototype.processNormalCharacter = function(textState) {
|
||||
var c = textState.text[textState.index];
|
||||
// If starting a new line, ensure line start index is tracked
|
||||
if (typeof textState._lineStartIndex === 'undefined') {
|
||||
textState._lineStartIndex = 0;
|
||||
}
|
||||
// If this char starts a word (previous is space or at line start) and
|
||||
// the upcoming full word would not fit on this line, break before it.
|
||||
// This avoids breaking English words in the middle.
|
||||
var isWhitespace = function(ch) {
|
||||
return ch === ' ' || ch === '\n' || ch === '\f' || ch === '\t';
|
||||
};
|
||||
var prevChar = textState.index > 0 ? textState.text[textState.index - 1] : '\n';
|
||||
var startsWord = !isWhitespace(c) && (textState.index === textState._lineStartIndex || isWhitespace(prevChar));
|
||||
if (startsWord) {
|
||||
// Collect full word until next whitespace or control (escape) char
|
||||
var j = textState.index;
|
||||
while (j < textState.text.length) {
|
||||
var ch = textState.text[j];
|
||||
if (ch === '\x1b' || ch === '\n' || ch === '\f' || ch === ' ' || ch === '\t') break;
|
||||
j++;
|
||||
}
|
||||
if (j > textState.index) {
|
||||
var word = textState.text.substring(textState.index, j);
|
||||
var wordWidth = this.textWidth(word);
|
||||
var remain = this.contentsWidth() - textState.x;
|
||||
// If the whole word fits on an empty line but not in the remaining space,
|
||||
// move it to the next line. If the word itself is wider than the line,
|
||||
// allow normal mid-word breaking.
|
||||
if (wordWidth <= this.contentsWidth() && wordWidth > remain) {
|
||||
// Start new line before the word. Window_Base.processNewLine
|
||||
// increments textState.index (it assumes a literal '\n' was consumed),
|
||||
// so decrement it here so the current character isn't skipped.
|
||||
this.processNewLine(textState);
|
||||
textState.index--;
|
||||
// After adjusting index, mark the start of the new line
|
||||
textState._lineStartIndex = textState.index;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default drawing of single character
|
||||
var w = this.textWidth(c);
|
||||
if (textState.x + w > this.contentsWidth()) {
|
||||
// If still overflows (e.g., long word), break line normally
|
||||
this.processNewLine(textState);
|
||||
textState.index--;
|
||||
// Reset line start index after manual break
|
||||
textState._lineStartIndex = textState.index + 1;
|
||||
}
|
||||
Window_Base.prototype.processNormalCharacter.apply(this, arguments);
|
||||
};
|
||||
|
||||
Window_Glossary.prototype.processNewLine = function(textState) {
|
||||
// Call base implementation then track character index at new line start
|
||||
Window_Base.prototype.processNewLine.call(this, textState);
|
||||
textState._lineStartIndex = textState.index;
|
||||
};
|
||||
|
||||
Window_Glossary.prototype.drawPicture = function(bitmap, text, y) {
|
||||
if (!bitmap) return;
|
||||
var item = this._itemData;
|
||||
|
|
|
|||
Loading…
Reference in a new issue