Drawing large quantities of text in the .refresh

Greetings all -


Seeking some implementation wisdom.  I can post code if it helps, but my question is more at the implementation level than specific syntax.


I have a scene with two windows.  One window pulls a list of actors in a specific state.  This is a command window that the player can scroll through.


The second window dynamically generates information (essentially an NPC detail page) based on the actor currently selected.


One of the things I'm putting on that detail page is the actor.profile() segment.  I use the DrawTextEx for this.  Unforutnately, as soon as I do, the frame rate drops to terminal levels, and I can barely even navigate through the list any more.  I can truncate the profile to 100 characters and it works fine, but I start pushing 200 and I've got problems.  Some of these profiles may have upwards of 500 characters.


I'm currently drawing this content in the .refresh() function of the detail window.  To me, it seemed reasonable since I want the text to change when a new ._index is selected from the command window.  


My question is two-fold:


1) Is this behavior expected?  If not, I can post code and we can work through what I've done wrong...


2) If it is expected (and seems reasonable that it would be), is there a better way to draw large volumes of text on a page than using the DrawTextEx feature in the window.refresh()?


Thanks in advance!


EDIT:  I suppose I can try calculating the selected actor and pulling the text at the Scene level.  Then do my update during initialize (and open/close windows instead of using refresh).  That would save wear and tear on the refresh, but it feels a little clunky.  


Still very interested in other people's thoughts.
Is there a reason you're using drawTextEx instead of drawText?  drawTextEx first reads through all your text looking for replacements where you've used \v \n and other escape codes that are replaced by text.  Then when it draws, it does it character by character, checking to see each time whether an escape code (like \i) is encountered.  It's a very slow process, and unless you are using escape codes in your profiles, there's no reason for it.


I suggest you try using drawText instead, and see what kind of difference it makes.
I'm using <WordWrap> (not sure if that is built in or came from Yanfly's MessageCore)


Is there a better solution to get word-wrapping with DrawText?  As a note, DrawText definitely fixes the problem.


Thanks for advice!


Apologies for the questions! Still new to the scripting piece of this.  (=


EDIT:


Just wrote a function to parse/wordwrap the profile:


------
Window_NotablesDetails.prototype.parseProfile = function(profileText, lineLength) {
    var wordArray = profileText.split(" ");
    
    var retValArray = [];
    retValArray[0] = "";
    var rvIterator = 0;
    
    for (var i=0;i<wordArray.length;i++)
    {
        if ((retValArray[rvIterator].length || 0 + wordArray.length + 1) > lineLength) {

            rvIterator++;


            retValArray[rvIterator] = "";


        }


        retValArray[rvIterator] += (" " + wordArray
);

    }


    return retValArray;


};





--------





 





This works for my purposes, but I'm still very curious if others have answers more robust than this.
No - the approach you've used is probably best - write a new function to take the features of drawTextEx that you're actually using, and use drawText instead.  It means you still get that extra bit of functionality but it's not checking every single thing.
Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/drawing-large-quantities-of-text-in-the-refresh.74263/