White Dragon
New member
I noticed that openBOR have a drawsprite() limit.
Can you increment that please?
Can you increment that please?
char draw_fontstring(int x, int y, int z, int sortid, char str, char font_path, int wfont, int hfont, char mem_var, int reset_flag, void screen, int monospace_flag, int space_pixel, char complete_font_path, char mem_var2) {
int i = 0;
int wchar = wfont/16;
int hchar = hfont/16;
int down_space = 0, xshift = 0, escape_n = 0;
slv("__prev_dx_space",NULL());
slv("__prev_sx_space",NULL());
if ( sortid == NULL() ) sortid = 0;
if ( z == NULL() ) z = 2000;
str += ""; // format to string
for ( i = 0; i < strlength(str); ++i ) {
char chara = getchar(str,i);
int chara_int = byte_to_int(chara);
if ( chara == "\n" ) {
down_space += hchar;
xshift = (i-escape_n)*wchar;
++escape_n;
}
draw_fontchar(x + i*wchar - xshift,y+down_space,z,sortid,font_path,wfont,hfont,chara_int,mem_var,reset_flag,screen,monospace_flag,space_pixel,chara,complete_font_path,mem_var2);
//drawstring(x+i*wchar,y,0,chara);
//drawstring(x,y+i*hchar,0,reset_flag);
}
slv("__prev_dx_space",NULL());
slv("__prev_sx_space",NULL());
}
char draw_fontchar(int x, int y, int z, int sortid, char font_path, int wfont, int hfont, int value, char mem_var, int reset_flag, void screen, int monospace_flag, int space_pixel, char chara, char complete_font_path, char mem_var2) {
void font = getlocalvar(mem_var);
void complete_font = NULL();
if ( mem_var2 != NULL() ) complete_font = getlocalvar(mem_var2);
if ( font == NULL() ) { font = loadsprite(font_path); setlocalvar(mem_var,font); font = getlocalvar(mem_var); }
if ( complete_font == NULL() && complete_font_path != NULL() ) { complete_font = loadsprite(complete_font_path); setlocalvar(mem_var2,complete_font); complete_font = getlocalvar(mem_var2); }
if ( reset_flag > 0 ) {
if ( font ) { free(font); setlocalvar(mem_var,NULL()); }
if ( complete_font ) { free(complete_font); setlocalvar(mem_var2,NULL()); }
return("");
}
if ( font ) {
//int wfont = getgfxproperty(font, "srcwidth");
//int hfont = getgfxproperty(font, "srcheight");
int wchar = wfont/16;
int hchar = hfont/16;
int row = 0, column = 0;
int sx_space = 0, dx_space = 0;
int xcoord, ycoord, prev_sx_space = 0, prev_dx_space = 0;
row = value%16;
column = trunc(value/16);
xcoord = row*wchar;
ycoord = column*hchar;
//changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "enabled", 1);
// shift the single chara to (0,0) coords. then shift it to x,y coords
x = 0 - xcoord + x;
y = 0 - ycoord + y;
// ### MONOSPACE ###
if ( monospace_flag != NULL() && monospace_flag > 0 ) {
int i1 = 0, i2 = 0;
int tmp_space = wchar;
int space_flag = 0;
// scan sx -> dx
i1 = 0; i2 = 0; tmp_space = wchar;
for ( i2 = ycoord; i2 < ycoord+hchar; ++i2 ) {
sx_space = 0;
for ( i1 = xcoord; i1 < xcoord+wchar; ++i1 ) {
int pixel;
if ( complete_font ) pixel = getgfxproperty(complete_font,"pixel",i1,i2);
else pixel = getgfxproperty(font,"pixel",i1,i2);
if ( pixel == 0 ) ++sx_space;
else break;
}
if ( sx_space < tmp_space ) tmp_space = sx_space;
if ( tmp_space == 0 ) break;
}
if ( tmp_space != wchar ) sx_space = tmp_space;
else { sx_space = 0; space_flag = 1; }
// scan dx -> sx
i1 = 0; i2 = 0; tmp_space = wchar;
for ( i2 = ycoord; i2 < ycoord+hchar; ++i2 ) {
dx_space = 0;
for ( i1 = xcoord+wchar-1; i1 >= xcoord; --i1 ) {
int pixel;
if ( complete_font ) pixel = getgfxproperty(complete_font,"pixel",i1,i2);
else pixel = getgfxproperty(font,"pixel",i1,i2);
if ( pixel == 0 ) ++dx_space;
else break;
}
if ( dx_space < tmp_space ) tmp_space = dx_space;
if ( tmp_space == 0 ) break;
}
if ( tmp_space != wchar ) dx_space = tmp_space;
else { dx_space = 0; space_flag = 1; }
if ( space_flag == 1 ) {
sx_space = 0;
if ( space_pixel == NULL() ) space_pixel = 2;
dx_space = wchar-space_pixel;
wchar = space_pixel;
}
if ( glv("__prev_dx_space") == NULL() ) slv("__prev_dx_space",0);
prev_dx_space = glv("__prev_dx_space");
slv("__prev_dx_space",glv("__prev_dx_space")+dx_space);
if ( glv("__prev_sx_space") == NULL() ) slv("__prev_sx_space",0);
prev_sx_space = glv("__prev_sx_space");
slv("__prev_sx_space",glv("__prev_sx_space")+sx_space);
/*drawstring(20,50,0,"sx_space: "+sx_space);
drawstring(20,60,0,"dx_space: "+dx_space);
drawstring(20,70,0,"xcoord: "+xcoord);
drawstring(20,80,0,"ycoord: "+ycoord);
drawstring(20,90,0,"pixel: "+getgfxproperty(font,"pixel",0,16));
drawstring(20,100,0,"space: "+wchar);*/
}
// ### MONOSPACE ###
changedrawmethod(NULL(), "clipx", xcoord + x-prev_dx_space-prev_sx_space);
changedrawmethod(NULL(), "clipy", ycoord + y);
changedrawmethod(NULL(), "cliph", hchar);
changedrawmethod(NULL(), "clipw", wchar);
//drawstring(20,20,0, getgfxproperty(font,"pixel",6,0));
if ( screen == NULL() ) drawsprite(font, x-prev_dx_space-prev_sx_space, y, z, sortid);
else drawspritetoscreen(font, screen, x-prev_dx_space-prev_sx_space, y);
//changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "enabled", 0);
//drawstring(10,200,0,wfont+" - "+hfont);
//drawstring(10,210,0,wchar+" - "+hchar);
//drawstring(10,220,0,row+" - "+column);
//free(font);
}
return ("");
}