Game Development Community

GuiMLTextCtrl quesiton

by Lateral Punk · in Torque Game Engine · 07/05/2004 (5:08 pm) · 35 replies

Hi,
i'm trying to figure out how to use the GuiMLTextCtrl control. here is my defn:

new GuiMLTextCtrl(display_screen) {
profile = "GuiMLTextProfile";
horizSizing = "right";
vertSizing = "top";
position = "22 49";
extent = "335 150";
minExtent = "8 2";
visible = "1";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
};

basically i want to have it so that when there is more text then can be put in the extent defined as 335x150, i want it to scroll up. Now looking at some of the funcitons in guiMLTextCtrol.cc i see that i need my MLTextCtrl to have a parent GuiScrollCtrl. but in my case i do not have that. My question is how do i get this "scrolling" to work? Also i require that the background where the text is written to be transparent. I don't need a scroll bar or anything.
Page«First 1 2 Next»
#21
09/04/2004 (2:10 pm)
Please post about it once you've stress tested this code. It might be a good addition to HEAD!
#22
10/21/2004 (6:44 pm)
Any C programmer who wants to earn a few bucks, I will pay you to add the scrollToBottom() code for me. I must have GuiMLTextCtrl because my project uses the control tags extensively. I'm translating ANSI color graphics to torque Markup Language tags. From what I can tell, ML stands for "Markup Language" not "Multi-Line" or does someone know for certain?

Stephan was kind enough to help me fix the line width problem. Turns out they wrote the entire code to support this, but then never added the part that makes it run! However, I am assuming Stephan has grown tired of helping me with the scrolltobottom issue as he is not returning my emails any more and the above code does not work on Windows XP. I do thank him for the patience he has had so far. Way above the call of duty!

What I need done:

1. ScrollToBottom() function that works on the guiMLTextCtrl object for all platforms.
2. A tag that supports background color. (Part of my ANSI needs.)
3. Integrating my ANSI translation code to C. (I have it working now in Torque script.)
4. Discuss the fiesability of adding basic HTML support.

Please contact me at: rthawkcom@yahoo.com
#23
10/21/2004 (9:26 pm)
I just added the code Stefen posted for scrollToBottom ... and it works perfectly fine on WinXP, and from looking at the code it will work fine on any platform.

Possible Errors

1. Your GuiMLTextCtrl is not contained within a GuiScrollCtrl
2. Typo when adding the code.
#24
10/22/2004 (4:48 am)
I compiled the code using the files he gave me and I used an EXE that he built on an example I wrote and he tested. It works fine for him, but not for me! Now when I replace the guiMLTextCtrol with a guiConsole, that object works just fine.

1. It's not the layout.
2. Will not work with an EXE known to be good.
3. ??? Got an option 3?

I've tried calling the method on both the Scroll object and the ML object... nothing! It's driving me insane! I've even swapped the profile with the guiControl (that does work) thinking its a profile issue... nothing. The only scrollToBottom that works is the guiConsole.
#25
10/22/2004 (8:01 am)
Hi Hawk,

I'm sorry for not answering the emails, it's not that I've grown tired with you, however the hospital that I'm working at, is keeping me busy... So let's see if we can solve this problem together.

From your last mails, I think the status is the following:

- my scrollToBottom() is implemented into your TGE
- you're using a current version of TGE
- scrollToBottom() is being called, however the slider doesn't move
- when you call scrollToBottom() when the object is not visible, it crashes (different bug, I think)
- the setup you mailed me (GuiMLTextCtrl in GuiScrollCtrl) works in my exe but not in yours
- when you call scrollToBottom() on the scroll control, nothing happens, same thing when you call scrollToBottom() on the GuiMLTextCtrl (like I use it)

Anything else?
#26
10/22/2004 (8:03 am)
By the way, the line spacing additions look like this:

add

mCurY += mLineSpacingPixels;

to

void GuiMLTextCtrl::emitNewLine(U32 textStart)

so it looks like this:

void GuiMLTextCtrl::emitNewLine(U32 textStart)
{
//clear any clipping
mCurClipX = 0;
Line *l = (Line *) mViewChunker.alloc(sizeof(Line));
l->height = mCurStyle->font->fontRes->getHeight();
l->y = mCurY;
l->textStart = mLineStart;
l->len = textStart - l->textStart;
mLineStart = textStart;
l->atomList = mLineAtoms;
l->next = 0;
l->divStyle = mCurDiv;
*mLineInsert = l;
mLineInsert = &(l->next);
mCurX = mCurLMargin;
mCurTabStop = 0;
if(mLineAtoms)
{
// scan through the atoms in the line, get the largest height
U32 maxBaseLine = 0;
U32 maxDescent = 0;
Atom* walk;
for(walk = mLineAtoms; walk; walk = walk->next)
{
if(walk->baseLine > maxBaseLine)
maxBaseLine = walk->baseLine;
if(walk->descent > maxDescent)
maxDescent = walk->descent;
if(!walk->next)
{
l->len = walk->textStart + walk->len - l->textStart;
mLineStart = walk->textStart + walk->len;
}
}
l->height = maxBaseLine + maxDescent;
for(walk = mLineAtoms; walk; walk = walk->next)
walk->yStart = mCurY + maxBaseLine - walk->baseLine;
}
mCurY += l->height;

//-----------------------------------------------
//this is the line I added
//-----------------------------------------------
mCurY += mLineSpacingPixels;
//-----------------------------------------------


mLineAtoms = NULL;
mLineAtomPtr = &mLineAtoms;
// clear out the blocker list
BitmapRef **blockList = &mBlockList;
while(*blockList)
{
BitmapRef *blk = *blockList;
if(blk->point.y + blk->extent.y <= mCurY)
*blockList = blk->nextBlocker;
else
blockList = &(blk->nextBlocker);
}
if(mCurY > mMaxY)
mMaxY = mCurY;
}
#27
10/22/2004 (8:11 am)
I don't know if that is a feasible solution for you, but I could have a look at your source and setup if you could send me your torque directory (yes, the whole thing, including scripts). The size is probably a problem for my email account, but if you have webspace somewhere, I could download it from there, I'll have a look at it over the weekend while working for Britton LaRoche for gamebeavers a little and doing some more research stuff for the hospital. When I'm finished, I'll erase the whole thing from my HD, so I won't copy/steal/misuse any of your code. Think about it. I think we can find this heisenbug and make a small resource.
#28
10/22/2004 (8:24 am)
We have a chat window that is a guiScrollCtrl with a guiMLTextCtrl child. To get the guiSCrollCtrl to stay at the bottom whenever the text of the guiMLTextCtrl is changed, I added a call in GuiScrollCtrl::childResized() to scroll to the bottom.

void GuiScrollCtrl::childResized(GuiControl *child)
{
   ...
   scrollTo( 0, 0x7FFFFFFF );
}

I think I made some minor changes to guiMLTextCtrl as well.
#29
10/22/2004 (8:29 am)
Ah yes, in void GuiMLTextCtrl::reflow() there's a call to ensureCursorOnScreen(); that I had to comment out in order to get it working correctly
#30
10/22/2004 (2:04 pm)
Owen! It worked! There is a small side effect of everything now scrolling to the bottom, but this is more preferable then it always going to the top!

Stefan, does this shed some light on what is going on? I can send my project to you if you are still curious to know why your method is not working on my setup? I would prefer it to work as designed, but this is trivial to it not working at all.
#31
10/22/2004 (11:03 pm)
That might have something to do with it, I'm going to check this. It's still strange though, that it works in my setup.
#32
06/14/2006 (4:14 am)
I don't know if this is still something people are struggling with, but I know I have.

I found it odd that scrollToBottom() would work fine if I called it manually from the console but wouldn't work when called from a script. Interposing the forcereflow() command solved this problem for me without altering any source code.

I'm new to torque but I would imagine that when you add text the control doesn't reflow and so the size of the control isn't correctly altered.
#33
06/14/2006 (4:31 am)
Hi Stewart,

It cannot work from the console and not from script. They use the same engine internals to run so you're doing something fishy somewhere. Are you passing the correct object ID?

As for your other questions, I don't know. Sorry.
#34
07/24/2006 (7:59 am)
Here are some additions to Owen's code:
in guiSCrollCtrl.h after:
bool mWillFirstRespond;     // for automatically handling arrow keys
add:
bool mAutoBottom;     // do we need to scroll to bottom automatically?
in guiSCrollCtrl.h in function GuiScrollCtrl::GuiScrollCtrl() after:
mWillFirstRespond = true;
add:
mAutoBottom = false;
in guiSCrollCtrl.h in function void GuiScrollCtrl::initPersistFields() after:
addField("willFirstRespond",     TypeBool,    Offset(mWillFirstRespond, GuiScrollCtrl));
add:
addField("autoBottom",           TypeBool,    Offset(mAutoBottom, GuiScrollCtrl));
then, make your void GuiScrollCtrl::childResized(GuiControl *child) function to look like:
void GuiScrollCtrl::childResized(GuiControl *child)
{
   Parent::childResized(child);
   computeSizes();
   if (mAutoBottom) scrollTo( 0, 0x7FFFFFFF );
}
Then, while you design your GUI, you will have a checkbox where you can enable/disable that parameter. Enjoy!

P.S. dont forget to update your guiMLTextCtrl.cc as Owen said:
Quote:in void GuiMLTextCtrl::reflow() there's a call to ensureCursorOnScreen(); that I had to comment out in order to get it working correctly
#35
09/09/2008 (1:38 am)
I know this is an old post, I am just adding to it for future reference of anyone that stumbles across this thread in their search.

Make sure your GuiMLTextCtrl is a child of GuiScrollCtrl and that they both have a name. Then simply call..

GuiMLTextCtrlName.forceReflow();
GuiScrollCtrlName.scrollToBottom();

.. and voila. Works like a charm.
Page«First 1 2 Next»