ID:156304
 
Well, since my map control takes up the entirety of the main window, I would like it to look...a little better. I have seen games that have their view perfectly sized for your resolution to fit your screen size. But alas, the only demos that I have seen that have this implemented have implemented it poorly(Or my screen resolution[1280x800] just doesn't work for it.), because the view is too large.

Does anyone know a foolproof way(If there is one) or doing this?
Could you explain more detailed what's wrong?
I usually use a simple set of interface utilities for this.
    proc/GetHeight(control)
{
var/string = winget(src, control, "size")
var/delimeter = findtext(string, "x")
var/height = text2num(copytext(string,delimeter+1))
return height
}

proc/GetWidth(control)
{
var/string = winget(src,control, "size")
var/delimeter = findtext(string, "x")
var/width = text2num(copytext(string,1,delimeter))
return width
}


Simply get the width of your map control, divide it by 32 and round the resultant value. That's the width your map needs to be in tiles. Then repeat the process for height and set the view accordingly.
view = "[width]x[height]"


You may see some black space at the edges of the map, but it shouldn't exceed 31 pixels wide.
In response to Cody123100
Sorry for taking so long to reply, I forgot completely about this. After trying this method, I noticed it was giving me a black screen. So, I gave it a simple src<<"[width] x [height]", and it told me 0 x 0. Is there any logical reason for it to do this? Because I don't see one.

Edit: Never mind, fixed it. Thanks.
In response to Albro1
Only one, the control you're trying to get the width/height of is less than 32x32. In that case if you divided by 32 and used round() then it would approximate width and height to 0.

Otherwise, no there's no logical reason why it should be giving you 0x0. Even if it couldn't find the specific control you are trying to get the width or height of it would return nullxnull.
In response to Cody123100
I found the issue. You did winget(src,control,"size"), but there was no src specified. I simply changed it to a mob/proc, and it worked fine.
In response to Cody123100
You could always properly round the number to reflect floor() or ceiling();

proc/proc_properRound(var_number)
if(var_number >= (round(var_number)+(1/2)))
return (round(var_number)+1)
else
return round(var_number)
In response to CauTi0N
In this case you always want it to go to the floor, because otherwise your view might exceed the boundaries of the actual map control by a small amount.
In response to Albro1
Albro1 wrote:
I found the issue. You did winget(src,control,"size"), but there was no src specified. I simply changed it to a mob/proc, and it worked fine.

That looked like he wrote it intended for a specific type path; given the indentation.