ID:167538
 
Is there actually a way to avoid the lag in onscreen-menus? It is really annoying, if you want to select something, but the cursor needs 2 seconds to move or the new menu pops up slowly. I'd need something like having the menus work without connection to the server, I suppose o.0
are you using images
In response to Mxjerrett
No, I'm using .dmi's.
There are ways to speed it up. As Mxjerrett was getting at, you can avoid extra network traffic by making some of the objects in the menu /image objects attached to some of the /obj objects in it.

One of the best ways to speed up menu time is to avoid deleting and recreating them every time you need them. Store the objects in a list and recall the same ones next time. Heck, you can even reuse some of the objects between players. In some of my games I have had all players with open menus looking at the same instances of all the menu objects, except for the numbers and pictures that were unique to them.

For example...
//If you have it like this...
client/proc
delete_menu()
for(var/obj/menu/O in screen)
del(O)
menu_background(x1,y1,x2,y2)
var/obj/menu/background/O
for(var/indexx = x1 to x2)
for(var/indexy = y1 to y2)
O = new(src, "[indexx],[indexy]")
menu_text(T, x1, y1, x2, y2)
//code to show the text here, similar format...
obj/menu
New(client/C, screen_loc)
if(C) C.screen += src
if(screen_loc) src.screen_loc = screen_loc
text
background

You could change that up a bit like so.
var/list/menus[0]
world/New()
var/list/L[0]
L.Add(menu_background(3,3,7,5), menu_text("stuff",3,3,7,5))
menus["main"] = L
L = new
L.Add(menu_background(2,2,10,10), menu_text("stats",1,1,10,10))
menus["stats"] = L
//and so on
client/proc
menu_background(x1, y1, x2, y2)
if(x1 in menus)
for(var/obj/menu/background/O in menus[x1])
screen += O
return
//the rest of the function, as it would normally be
menu_text(T, x1, y1, x2, y2)
if(T in menus)
for(var/obj/menu/text/O in menus[T])
screen += O
return
//the rest of the function, as normal

If you go that route, you can also make a menu function that calls the other two to make it easier on you.
client/proc
menu(T)
if(T in menus)
menu_background(T)
menu_text(T)
return 1
return 0

That does only help the local processing load though, and it has nothing to do with the network traffic. However, if the processor gets bogged down, that can be worse than too much network traffic.

As for using /image objects, you can look them up in the help file. You just attach some to a base object and give them a pixel offset that makes them appear a tile over. When you do this, you only have to add the base object to the client's screen list, and all the images attached to it will show as well.

The reason using image objects can help network traffic as opposed to making them all /obj objects is that each object in the screen list creates constant traffic between the server and the client. /image objects, being attached to the base object, don't create this overhead since their placement is determined by the base object. I'm not sure how much this could reduce lag, but it should help somewhat. It can be a lot of work though, depending on how your system is setup, and it requires quite an overhaul of it.
In response to Loduwijk
Thanks :) Are there actually other tricks to avoid lag?(not only for the menus)
In response to CIB
CIB wrote:
Are there actually other tricks to avoid lag?(not only for the menus)

Yes; the best one is to get a midrange server or mainframe with a fiber optic connection to the nearest high-speed access point.

Seriously though, there are some things. For instance, if you have a lot going on in your world, don't make it all happen at once. Many people have creatures with AI in which they are all sleeping together then all act at the same moment. Spread it out a bit. And putting the game's resources on a different host than the running instance of the game.

Oh, another thing that creates constant downloads are those games where you can customise your color. Every time a new person comes into view, you have to download new icons - more than 1 if it uses overlays for different aspects.