//Resize code
client
var
map_width
map_height
view_width
view_height
buffer_height
buffer_width
view_zoom
verb
onMapResize(map as text,default as num,width as num,height as num,zoom as num)
set instant = 1, hidden = 1
world.log << "[map] [default] [width] [height] [zoom]"
if(default)
map_width = width
map_height = height
view_zoom = 0
do
++view_zoom
view_width = ceil(map_width / (TILE_WIDTH * view_zoom))
if(view_width%2==0)
++view_width
view_height = ceil(map_height / (TILE_HEIGHT * view_zoom))
if(view_height%2==0)
++view_height
while(view_width>MAXIMUM_VIEW_WIDTH || view_height> MAXIMUM_VIEW_HEIGHT || view_width*view_height>MAX_VIEW_TILES)
view_width = max(MINIMUM_VIEW_WIDTH,view_width)+EXTRA_VIEW_WIDTH*2
view_height = max(MINIMUM_VIEW_HEIGHT,view_height)+EXTRA_VIEW_HEIGHT*2
buffer_width = floor((view_width*TILE_WIDTH - map_width/view_zoom)/2)
buffer_height = floor((view_height*TILE_HEIGHT - map_height/view_zoom)/2)
mob.tempvars[B_W] = buffer_width
mob.tempvars[B_H] = buffer_height
view = "[view_width]x[view_height]"
// world.log << view
// world.log << buffer_width
// world.log << buffer_height
if(zoom!=view_zoom)
winset(src,"map1","zoom=[view_zoom]")
proc
updateMapSize()
set waitfor = 0
var/v = winget(src,"map1","id;size.x;size.y;zoom")
var/list/params = params2list(v)
onMapResize(params["id"],1,text2num(params["size.x"]),text2num(params["size.y"]),params["zoom"])
//code that adds the HUD objects to the screen
Show(ID, X, Y, TIME)
if(!(ID in hud))
world.log << "could not show hud"
return FALSE
vis_contents |= hud[ID]
for(var/OBJECT in hud[ID])
animate(OBJECT, pixel_x=X,pixel_y=Y, time = TIME)
Problem description: This is currently what I'm using to resize my map and position my huds on the screen. My problem is with repositioning the HUD objects once the map resizes, I think I'm supposed to do it with buffer_width and buffer_height in mind but I'm not exactly sure how. Any help would be appreciated. :(