does this work?
Displaying 1-6 of 6 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
relaxis

would this code work for having scrolling text-boxes that show text inputted via Maped3?


void TextBox()

{int textfont = LoadFont("font1.png", 10, 12);
EnableVariableWidth(textfont);
int fps=0;
int fpscount=0;
int choice=0;

int blue=RGB(0,0,255);
int black=RGB(0,0,0);
int yellow=RGB(255,255,0);
int red=RGB(255,0,0);
int green=RGB(0,255,0);

int textbox5=TT64_TextBox(textfont,12,4,20,300,blue,blue,black,black, 35, SCAN_A,

100, PrintString(screen,MyFont,text));
int time=systemtime;
int wait=systemtime;
while (!key[SCAN_ESC])
{
Splash(0,255,0);
if (choice!=2)
{
if (choice==0) TT64_RenderTextBox(textbox1);
if (choice==1) TT64_RenderTextBox(textbox4);
TT64_RenderTextBox(textbox2);
TT64_RenderTextBox(textbox3);
}
if (choice==2)
{
TT64_RenderTextBox(textbox5);
}

if (systemtime>=time+100)
{
time=systemtime;
fps=fpscount;
fpscount=0;
}
else fpscount++;
printstring(2,2,screen,textfont,"FPS: "+str(fps));
ShowPage();
if (key[SCAN_ENTER] && systemtime>=wait+20)
{
wait=systemtime;
if (choice==0) choice=1;
else choice=0;
TT64_OpenTextBox(textbox5);
}
if (key[SCAN_T] && systemtime>=wait+20)
{
wait=systemtime;
choice=2;
}

Posted on 2006-07-14 07:18:46

relaxis

Hello? Is anyone out there???

Posted on 2006-07-17 15:54:20

Overkill

Did you try it? The way to see if something works is to run it, usually. And, no, doesn't look like it'll work. You'll probably get a compile error, which you'll find in v3.log

Posted on 2006-07-17 16:09:14

relaxis

i can't run it because I'm at work - i just write them. I'm not expecting the script to work on it's own - it's part of the scrolling text-box script that features on the demo (downloads section) and I'm trying to customise it so that instead of having to type in what appears in the text box in the actualy textbox code (and everytime you want a textbox having to recode the whole thing) I'm trying to get the textbox to display text according to the entity inputs on maped3.

Posted on 2006-07-17 16:13:51

Gayo

Sorry, I never replied because I was having some trouble figuring out how it worked. And now that I look at it again, I still can't see how it works. Am I right in thinking that the actual scrolling textbox code is in the TT64 functions?

Posted on 2006-07-18 01:39:06 (last edited on 2006-07-18 01:40:13)

relaxis

yeah, there are 2 other files outside of the system file which are defined at the beginning - tt64 graphics -

void Splash(int r,int g,int b)
{
rectfill(0,0,ImageWidth(screen),ImageHeight(screen),rgb(r,g,b),screen);
}

int Mixcolors(int c1, int c2, int weight)
{
int r1=GetR(c1);
int r2=GetR(c2);
int g1=GetG(c1);
int g2=GetG(c2);
int bb1=GetB(c1);
int bb2=GetB(c2);


int r=(r1*(255-weight))+(r2*weight);
int g=(g1*(255-weight))+(g2*weight);
int b=(bb1*(255-weight))+(bb2*weight);

return RGB(r >> 8, g >> 8, b >> 8);
}

int MakeGradient(int c1, int c2, int c3, int c4, int w, int h)
{
int xstart;
int xend;
int img=NewImage(w, h);
int x=0;

int y=0;
int color;

for (y=0; y<h; y++)
{
xstart = Mixcolors(c1, c3, 256 * y / h);
xend = Mixcolors(c2, c4, 256 * y / h);

for (x = 0; x < w; x++)
{
color=Mixcolors(xstart, xend, 256 * x / w);
SetPixel(x, y, color, img);
}
}
return img;
}


and this one - tt64_textbox



#define _TT64_MAXBOXES 20
#define _TT64_MAXLINES 50
#define _TT64_TEXTBOXDELAY 25

#include "tt64_graphics.vc"

int _tt64_bottomarrow=LoadImage("bottomarrow.pcx");

struct _tt64_textbox
{
int gradientbg;
int x;
int y;
int w;
int h;
int scankey;
int topline;
int linesthatfit;
int font;
int fontheight;
int lucency;
int wait;
int closed;
string texts[_TT64_MAXLINES];
int textfill;
};

_tt64_textbox _tt64_boxes[_TT64_MAXBOXES];
int _tt64_boxfill=0;

int TT64_TextBox(int font, int fontheight, int x, int y, int w, int c1, int c2, int c3, int c4, int lucency, int scankey, int maxheight, string text)
{
text=text+" ";
//Log("text="+text);
int i=0;
int j=0;
int h=0;
int temp=0;
int textlen=0;
int origend=len(text);
//Log("origend="+str(origend));
int end=origend;
string temptext=text;
string lasttext="";
string lastchar="";
string temptextholder="";
if (_tt64_boxfill<_TT64_MAXBOXES)
{
_tt64_boxes[_tt64_boxfill].textfill=0;

for (i=0; i<_TT64_MAXLINES; i++)
{
while (TextWidth(font,temptext)>=w-4)
{
end--;
temptext=left(temptext,end);
}
if (len(temptext) && strcmp(lasttext, temptext))
{
temptextholder=temptext;
lastchar=mid(temptext,len(temptext)-1,len(temptext));
while (!IsSpace(lastchar) && end>=0)
{
end--;
temptext=left(temptext,end);
lastchar=mid(temptext,len(temptext)-1,len(temptext));
}
if (end<0)
{
temptext=temptextholder;
}
//Log(temptext);
if (TextWidth(font,temptext)<w-4)
{
_tt64_boxes[_tt64_boxfill].texts[_tt64_boxes[_tt64_boxfill].textfill]=temptext;
_tt64_boxes[_tt64_boxfill].textfill++;
lasttext=temptext;
for (j=0; j<_tt64_boxes[_tt64_boxfill].textfill; j++)
{
textlen+=len(_tt64_boxes[_tt64_boxfill].texts[j]);
}
//Log("textlen="+str(textlen));
//Log("origend="+str(origend));
if (textlen<origend)
{
temptext=mid(text,textlen,origend);
}
textlen=0;
end=origend;
}
}
}

h=(_tt64_boxes[_tt64_boxfill].textfill*(fontheight+4))+3;
if (h>maxheight) h=maxheight;

j=0;
//Log("Textfill="+str(_tt64_boxes[_tt64_boxfill].textfill));
for (i=0; i<_tt64_boxes[_tt64_boxfill].textfill; i++)
{
if (y+4+(fontheight*(i-1))+(4*i)<=h) j++;
}
if (j==0) _tt64_boxes[_tt64_boxfill].linesthatfit=_tt64_boxes[_tt64_boxfill].textfill;
else _tt64_boxes[_tt64_boxfill].linesthatfit=j;
//Log("Lines that fit="+str(_tt64_boxes[_tt64_boxfill].linesthatfit));

_tt64_boxes[_tt64_boxfill].x=x;
_tt64_boxes[_tt64_boxfill].y=y;
_tt64_boxes[_tt64_boxfill].w=w;
_tt64_boxes[_tt64_boxfill].h=h;
_tt64_boxes[_tt64_boxfill].scankey=scankey;
_tt64_boxes[_tt64_boxfill].topline=0;
_tt64_boxes[_tt64_boxfill].lucency=lucency;
_tt64_boxes[_tt64_boxfill].font=font;
_tt64_boxes[_tt64_boxfill].wait=0;
_tt64_boxes[_tt64_boxfill].closed=0;
_tt64_boxes[_tt64_boxfill].fontheight=fontheight;

_tt64_boxes[_tt64_boxfill].gradientbg=MakeGradient(c1,c2,c3,c4,w,h);

_tt64_boxfill++;
temp=_tt64_boxfill-1;
return temp;
}
else return _TT64_MAXBOXES;
}

int IsSpace(string s)
{
if (!strcmp(s, " "))
{
return 1;
}
else
{
return 0;
}
}

void TT64_OpenTextBox(int boxindex)
{
_tt64_boxes[boxindex].closed=0;
_tt64_boxes[boxindex].topline=0;
}

void TT64_RenderTextBox(int boxindex)
{
int i=0;
if (!_tt64_boxes[boxindex].closed)

{
BlitLucent(_tt64_boxes[boxindex].x,_tt64_boxes[boxindex].y,_tt64_boxes[boxindex].lucency,_tt64_boxes[boxindex].gradientbg,screen);
rect(_tt64_boxes[boxindex].x,_tt64_boxes[boxindex].y,_tt64_boxes[boxindex].x+_tt64_boxes[boxindex].w-1,_tt64_boxes[boxindex].y+_tt64_boxes[boxindex].h-1,rgb(255,255,255),screen);
for (i=_tt64_boxes[boxindex].topline; i<_tt64_boxes[boxindex].topline+_tt64_boxes[boxindex].linesthatfit; i++)
{
printstring(_tt64_boxes[boxindex].x+4,_tt64_boxes[boxindex].y+4+(_tt64_boxes[boxindex].fontheight*(i-_tt64_boxes[boxindex].topline))+(4*(i-_tt64_boxes[boxindex].topline)),screen,_tt64_boxes[boxindex].font,_tt64_boxes[boxindex].texts[i]);
}
if (key[_tt64_boxes[boxindex].scankey] && systemtime>=_tt64_boxes[boxindex].wait+_TT64_TEXTBOXDELAY)
{
if (_tt64_boxes[boxindex].topline+1<=_tt64_boxes[boxindex].textfill-_tt64_boxes[boxindex].linesthatfit) _tt64_boxes[boxindex].topline++;
else _tt64_boxes[boxindex].closed=1;
_tt64_boxes[boxindex].wait=systemtime;
}
if (_tt64_boxes[boxindex].topline+_tt64_boxes[boxindex].linesthatfit<_tt64_boxes[boxindex].textfill)
{
if (systemtime%50<=25)
{
Blit(_tt64_boxes[boxindex].x+_tt64_boxes[boxindex].w-10,_tt64_boxes[boxindex].y+_tt64_boxes[boxindex].h-5,_tt64_bottomarrow,screen);
}
}
}
}


then this is the original script for the text box (not modified by me) -


#include "tt64_textbox.vc"
#include "tt64_graphics.vc"
//You must have the above two files for this to work

void Autoexec()
{
int textfont = LoadFont("font3_vw.gif", 10, 12);
EnableVariableWidth(textfont);
SetAppName("Verge 3 TextBox Demo by TomT64, v0.94");

int fps=0;
int fpscount=0;
int choice=0;

int blue=RGB(0,0,255);
int black=RGB(0,0,0);
int yellow=RGB(255,255,0);
int red=RGB(255,0,0);
int green=RGB(0,255,0);

int textbox1=TT64_TextBox(textfont,12,4,20,300,blue,blue,black,black, 35, 0, 240, "Hi! This is a small demo of a translucent textbox, which creates a text box with a gradient background, and automatically cuts the text up into lines based on spaces in the text. Press Enter for another text box. Press the 'T' key to see a scrolling textbox.");
int textbox2=TT64_TextBox(0,7,10,150,200,blue,blue,black,black, 50, 0, 240, "Example Text box using the builtin font. Notice that I used the number 0 as the first parameter for this textbox, and the font's height is 7.");
int textbox3=TT64_TextBox(textfont,12,216,150,100,blue,blue,black,black, 0, 0, 240, "NoSpacesInThisTextBoxHHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
int textbox4=TT64_TextBox(textfont,12,4,20,300,blue,green,yellow,red, 35, 0, 240, "This is a new box with a neat gradient effect. HUZZAH! Press Enter for previous textbox.");
int textbox5=TT64_TextBox(textfont,12,4,20,300,blue,blue,black,black, 35, SCAN_A, 100, "Press ENTER at any time to return to the other text boxes. This is a scrolling textbox which will continue scrolling as long as you hit or hold the 'a' key. It has a maximum height (in pixels) which, when exceeded, will not show the text that is next until you do hit the 'a' key. Once it reaches the end, pressing the 'a' key will close the text box. You can define which key to use for this purpose when making your textbox.");
int time=systemtime;
int wait=systemtime;
while (!key[SCAN_ESC])
{
Splash(0,255,0);
if (choice!=2)
{
if (choice==0) TT64_RenderTextBox(textbox1);
if (choice==1) TT64_RenderTextBox(textbox4);
TT64_RenderTextBox(textbox2);
TT64_RenderTextBox(textbox3);
}
if (choice==2)
{
TT64_RenderTextBox(textbox5);
}

if (systemtime>=time+100)
{
time=systemtime;
fps=fpscount;
fpscount=0;
}
else fpscount++;
printstring(2,2,screen,textfont,"FPS: "+str(fps));
ShowPage();
if (key[SCAN_ENTER] && systemtime>=wait+20)
{
wait=systemtime;
if (choice==0) choice=1;
else choice=0;
TT64_OpenTextBox(textbox5);
}
if (key[SCAN_T] && systemtime>=wait+20)
{
wait=systemtime;
choice=2;
}
}

}

Posted on 2006-07-18 07:21:14


Displaying 1-6 of 6 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.