Map text console in Developer Help
|
|
Code:
mob/var/obj/console mob/var/console_lines_displayed mob/var/console_timeout = 0 mob/var/list/mem_text mob Login() ..() console = new console.screen_loc = "1,1" src.client.screen += console mem_text = new spawn while(src) console_timeout()
proc console_timeout() console_timeout-=10 if(console_timeout <= 0) console_timeout = 0 if(console_lines_displayed <= 1) console.overlays.Cut() else redraw(1) sleep(10)
redraw(lines) console_lines_displayed = lines console.overlays.Cut() console_timeout = 80
if(lines <= 1) lines = 1 if(lines >= mem_text.len) lines = mem_text.len
var/iy = lines * 8 - 8 for(var/i = mem_text.len - lines + 1, i <= mem_text.len, i++) var/ret = draw_text(mem_text[i], iy) iy -= 8 + ret
mob/proc/draw_text(t as text, py) var/px = 0 var/ppy=py
for(var/i = 1, i <= lentext(t), i++) var/chr = copytext(t, i, i+1) var/image/img = image(icon = 'font_black_new.dmi', icon_state = chr) if(px >= 480) px = 0 ppy -= 8 img.pixel_x = px img.pixel_y = ppy console.overlays += img px += 8 return py-ppy
mob/verb/say(t as text) for(var/mob/m in view()) m.add_mem_text("[src.key]:[t]", 8)
mob/proc/add_mem_text(t, max_text) if(mem_text.len >= 256) mem_text -= mem_text[1] mem_text += t redraw(max_text)
|
Problem description:
Looking for criticism / ways to improve this. This is inspirit of using zero windows controls in game and having everything happen in the map screen control.
So far the only thing that feels bad about it, aside from the code being a very quick proof in concept and sloppy, is the console_timeout loop. Also, the fact that I can't make it a client-oriented function that sorts out lines of text onto the screen instead of what happens by default (server tells the client to draw stuff on the screen instead of giving it some text to draw).
|