BrandedTales

StoryTeller
Veteran
Joined
Dec 30, 2016
Messages
203
Reaction score
116
First Language
English
Primarily Uses
N/A
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.
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,365
Reaction score
15,179
First Language
English
Primarily Uses
RMMV
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.
 

BrandedTales

StoryTeller
Veteran
Joined
Dec 30, 2016
Messages
203
Reaction score
116
First Language
English
Primarily Uses
N/A
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.
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,365
Reaction score
15,179
First Language
English
Primarily Uses
RMMV
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.
 

Latest Threads

Latest Posts

Latest Profile Posts

Doing RPG Maker News for 21st September 2021


Malak is still waiting for Dark Deception Chapter 4... This was him yesterday after another sugar crash.
Again, he's fine. He's just bored at this point, considering he's exhausted his entire vacation bucket list.
Am I the only one who files custom resources under specific folders to remember who to credit? :kaoswt2:
1632263519730.png
I always smile to myself when I see someone do the "immediate halt and spin around" from forgetting something. I find it sort of endearing how we all do it without ever being taught to.

Forum statistics

Threads
115,260
Messages
1,088,434
Members
149,864
Latest member
ratbyte
Top