wrapTextL(text,line,offset_x,offset_y,wF,T_Layer=TEXT_LAYER,oBreak, font_color=FONT_ICON)
var
list/words=list()
width=0
tempWidth=0
py=line*16+16-offset_y
py_top = py
py_bottom = 1*16+16-offset_y
px=offset_x*32+36
max_pixels=((wF-1)*32)-8
linebreak=0
breaks=0
// scroll_tmp = line - scroll // opposite of
draw_scroll = 0 // bitfield; whether or not to draw scroll buttons, NORTH = up, SOUTH = down
bottom_py = py_bottom
if(py_top > top_py)
top_py = py_top
if(oBreak)
breaks=oBreak
words=findWords(text)
for(var/L in words)
if(linebreak)
if(L==" ")continue
else linebreak=0
tempWidth+=getWidthWord(L)
if(tempWidth>=max_pixels)
line--
breaks++
//if(line<=0)return breaks
//if(line<=0)draw_scroll |= NORTH // toggle up scroll
width=offset_x*32
tempWidth=width
py-=16
linebreak=1
for(var/N in explode(L))
var/image/I=image(icon=font_color,icon_state=N,layer=T_Layer+layer)
I.pixel_x=width+px
I.pixel_y=py + (scroll*16)
I.tag = N
if(I.pixel_y < py_bottom)
if(!(draw_scroll & SOUTH))
draw_scroll |= SOUTH // toggle down arrow
else if(I.pixel_y > py_top)
if(!(draw_scroll & NORTH))
draw_scroll |= NORTH // toggle up arrow
else overlays+=I
text_images+=I
width+=getWidth(N)
width+=2
tempWidth=width
if(draw_scroll)
if(draw_scroll & NORTH)
for(var/obj/hud/textscroll_up/T in scrollarrows)
if(top_py != 0 && bottom_py != 0)
T.py_top = top_py
T.py_bottom = bottom_py
T.layer = T_Layer + layer + 1
T.invisibility = 0
if(draw_scroll & SOUTH)
for(var/obj/hud/textscroll_down/T in scrollarrows)
if(top_py != 0 && bottom_py != 0)
T.py_top = top_py
T.py_bottom = bottom_py
T.layer = T_Layer + layer + 1
T.invisibility = 0
return breaks
Problem description:
This code snippet seems to be taking up an abnormal amount of CPU. I am not that good of an optimizer, so I'm posting this here if anyone has any pointer as to how this behemoth could be reduced or more efficiently executed.