Home   Help Search Login Register  

Author Topic: Multiple text lines in Control (Dialog)  (Read 1307 times)

0 Members and 1 Guest are viewing this topic.

Offline CrashDome

  • Members
  • *
Re:Multiple text lines in Control (Dialog)
« Reply #15 on: 03 Jul 2004, 20:19:00 »
Hello everyone,


Armstrong: Thanks for the comments!

Ponq: Multiline dialog ctrls are very limited in ofp. Only the textbox can be multiline and there are no scroll bars that I am aware of. Even if you use pages, you will have to manually set the length of each page as you cannot determine a count of characters in a string and break it up programmatically.

I did write a dialog that resembles something like old RPG games where the top portion is a multiline textbox of talking and the lower portion is a listbox of single line responses you can make. Check it out at http://www.crashdome.net/ofpsx
No need to register just click on the anonymous link to access the files.

To summarize what you need to get a multiline text box (in case you do not want to download my dialog and browse through it:

in the description.ext file define a textbox class like so:
Code: [Select]
class multiTextBox
{
   type = CT_STATIC;
   idc = -1;
   style = ST_MULTI;
   colorBackground[] = <any color you want>;
   colorText[] = <any color you want>;
   font = <any font you want>;
   sizeEx = <height of each line - 0.025 is a good start but try and match the font so it is not fuzzy>;
   linespacing = 1.0;
   text = "";
};

Create the actual textbox as a control:
Code: [Select]
   class myTextBox : multiTextBox
   {
      idc = 100;
      text = "";
      x = 0.0625; y = 0.3625; w = 0.875; h = 0.25;
   };

Then, to get your text into the textbox, you will need to use a single string in a script to set the text (or write it into the description.ext directly if it never changes)
Here is an example:

Code: [Select]
ctrlSetText [100, "Here is an example of a multiline text box, blah, blah. I can write text and keep going and going and going..."]
The text will be displayed and it will break wherever it wants. "\n" doesn't work and you will be stuck with however it looks. To fine tune, you will need to maybe add spaces to the text to get it to look right - or adjust the size of the box.


Edit: forgot a "   :)
« Last Edit: 03 Jul 2004, 20:26:31 by CrashDome »

ponq

  • Guest
Re:Multiple text lines in Control (Dialog)
« Reply #16 on: 03 Jul 2004, 20:53:04 »
Thanks for your reply!

I guess I have to accept there's no decent line-breaks in ofp-dialogs ;)

LOL at your demo mission btw

Offline CrashDome

  • Members
  • *
Re:Multiple text lines in Control (Dialog)
« Reply #17 on: 03 Jul 2004, 23:28:31 »
Glad I can (still) help!   ;D