ID:2437659
 
Code:
#define floor(x) round(x)
#define ceil(x) (-round(-x))
#define TILE_WIDTH 32
#define TILE_HEIGHT 32
#define MAX_VIEW_TILES 800

world
icon_size = 32

client
var
view_width
view_height
buffer_x
buffer_y
map_zoom
verb
onResize()
set hidden = 1
set waitfor = 0
var/sz = winget(src,"map1","size")
var/map_width = text2num(sz)
var/map_height = text2num(copytext(sz,findtext(sz,"x")+1,0))
map_zoom = 1
view_width = ceil(map_width/TILE_WIDTH)
if(!(view_width%2)) ++view_width
view_height = ceil(map_height/TILE_HEIGHT)
if(!(view_height%2)) ++view_height

while(view_width*view_height>MAX_VIEW_TILES)
view_width = ceil(map_width/TILE_WIDTH/++map_zoom)
if(!(view_width%2)) ++view_width
view_height = ceil(map_height/TILE_HEIGHT/map_zoom)
if(!(view_height%2)) ++view_height

buffer_x = floor((view_width*TILE_WIDTH - map_width/map_zoom)/2)
buffer_y = floor((view_height*TILE_HEIGHT - map_height/map_zoom)/2)

src.view = "[view_width]x[view_height]"
winset(src,"map1","zoom=[map_zoom];")

mob
Login()
client.onResize()
return ..()


Problem description: I'm trying to get full screen working for my game, but I'm running into issues. The code above is from the almighty Ter13's article: http://www.byond.com/forum/?post=1816091.

When using any value lower than 2000 for MAX_VIEW_TILES, the screen is super zoomed in and looks terribly blurry, like so: https://gyazo.com/ff3e49de8f077a8d9747bb6660039e40

When using a value of 2000 or higher for MAX_VIEW_TILES, the screen is super zoomed out, but not blurry, like so: https://gyazo.com/411830cbbe2c17b49ee546f797138e25.

There is only two outcomes no matter what value I use, either super zoomed in and blurry, or too zoomed out.

I cannot for the life of me figure out how to make it so the screen is zoomed in the right amount and maintains image quality.

Any help would be greatly appreciated, thanks!

I really don't like the look of that code. So I'm gonna post the route that I use. First, here is code using javascript to get the user's actual resolution:
//this gets their real screen resolution using javascript

var/fullscreenJS = {"
<html>
<head>
<script type='text/javascript'>
var height = screen.height;
var width = screen.width;
document.location.href='byond://?action=get_resolution&height=' + height + '&width=' + width;
</script>
</head>
<body>
</body>
</html>
"}


client/var
resolutionX = 1920 //just some default values for no real reason
resolutionY = 1080

// You probably want to place this in your client/New()
client/proc
JSresolutionCheck()
set waitfor=0
src << browse(fullscreenJS, "window=InvisBrowser.invisbrowser")

client/Topic(href, href_list[])
if(href_list["action"] == "get_resolution")
resolutionX = text2num(href_list["width"])
resolutionY = text2num(href_list["height"])
else ..()

With their resolution known, it should be easy to know the client.view width & height to use.
Then to make the window fullscreen you just:
winset(src, "mainwindow", "titlebar=false")
winset(src, "mainwindow", "is-maximized=false") //for some reason i find you need to run this first to de-maximize the window before telling it to maximize
//again or it doesnt work in certain situations like if the user dragged some edges of the window around
winset(src, "mainwindow", "is-maximized=true")

Maybe some of this helps maybe it doesn't. Gotta go.
There are other factors such as whether you have set your map element in the skin to "stretch" or whatever other options that may interfere with this.
How would I go about setting their client.view using this method?

I don’t use “stretch” either.
I can't figure this out :/
var/fullscreenJS = {"
<html>
<head>
<script type='text/javascript'>
var height = screen.height;
var width = screen.width;
document.location.href='byond://?action=get_resolution&height=' + height + '&width=' + width;
</script>
</head>
<body>
</body>
</html>
"}


client/var
resolutionX = 1920
resolutionY = 1080


client/proc
JSresolutionCheck()
set waitfor=0
src << browse(fullscreenJS, "window=InvisBrowser.invisbrowser")

client/Topic(href, href_list[])
if(href_list["action"] == "get_resolution")
resolutionX = text2num(href_list["width"])
resolutionY = text2num(href_list["height"])
else ..()

client
New()
spawn()
JSresolutionCheck()
src.view = "41x21" //this isn't right, need to find out how to calculate client.view based on the player's resolution
..()
mob
Login()
winset(src, "mainwindow", "is-maximized=false") //I don't think this is supposed to be under mob/Login() either?
winset(src, "mainwindow", "is-maximized=true")
return ..()


This is what I'm using now, from Team7Star, thank you for helping.

I think I only need to find out how to set client.view based on the player's screen resolution now. I'm not really sure how to go about doing that
I don't remember exactly but I think in the map element you need to make sure the anchors are set (you've probably done that) so that it will stretch the map to any size the user has resized the game window to. Uncheck "Use Letter Boxing" on the map. Check "Stretch icons to fit map" (pretty sure it should be checked for this but try both).

Then right after JSresolutionCheck() put this proc:
client/proc/SetViewSize(size) //horizontal view size. the vertical view size will be calculated to the proper amount by checking the user's resolution
var/aspectRatio = resolutionY / resolutionX
client.view = "[size]x[size * aspectRatio]"
//i dont think it needs rounded but if it does just comment out the line above and use this one instead
//client.view = "[size]x[round(size * aspectRatio)]"

//example to show it goes in client/New (but after JSresolutionCheck())
client/New()
SetViewSize(41)


In the skin options for whatever your main window is there is an area to put a "Resize Command". You may need to use that. It can only use verbs. So to call SetViewSize() in it, you need to change it to this:
var/viewSize = 41

client/verb/SetViewSize() //horizontal view size. the vertical view size will be calculated to the proper amount by checking the user's resolution
set hidden = 1
var/aspectRatio = resolutionY / resolutionX
client.view = "[viewSize]x[viewSize * aspectRatio]"
//i dont think it needs rounded but if it does just comment out the line above and use this one instead
//client.view = "[viewSize]x[round(viewSize * aspectRatio)]"

Then in the area to type a "Resize Command" just put "SetViewSize" without the quotes, no () at the end or anything. I think you will have to do it this way to keep the map scaled properly no matter how the user resizes the window.
I was told to never ever use "stretch icons".
Yeah that may be but you might have to temporarily check it on and off to see the difference. Not sure how it will behave.
I'm trying to get full screen, reasonable zoom level, while maintaining image quality as much as possible. No matter what I try, can't get it to work
I think the advice not to use "stretch" is from before Lummox Jr improved it.
It was from the article Ter13 made about full screen
I've still not been able to figure this out
These forums aren't very active anymore I see :/
Still trying to get this to work to get optimal image quality and zoom in values. any help would be greatly appreciated.