ID:1939004
 
(See the best response by Kozuma3.)
Hi, I was wondering if it's possible to have a resizeable window with a minimum size. The idea being that it would become impossible to cover important interface elements by making the window tiny.
With Dream Seeker, I don't think so. Here's a relevant feature request:

http://www.byond.com/forum/?post=717931
With an interface you can set your window size and do it the way I did and simply make the minimize button that window size and the maximize, well, maximize.

the commands are: .maximize and .normal
Simply make a menu in the dmf and add options with these commands. Customize the winset options to suit your needs; as you can see I have a background set.

mob/verb
Maximize()
set name=".maximize"
winset(src, "default", {"
titlebar=false;
is-minimized=true;
"}
)
sleep(1)
winset(src, "default", {"
is-minimized=false;
is-maximized=true;
"}
)


mob/verb
Normal()
set name=".normal"
winset(src, "default", {"
titlebar=true;
is-maximized=false;
image=/imgs/bckgrnd2.png;
"}
)
Hmm, that's not quite what I'm looking for but thank you. I'd really like people to be able to resize however they like rather than lock them into an either/or situation.
In response to Zecronious
Yeah, so would I. Currently I don't think there is a minimum window size, which is why I use the above method.
Let me know if you find anything or maybe make a feature request and I'll +1 it! :)
As an alternative, in the mean time, you could just offer menu options for window size. An option for smallest, default, and large windowed resolutions seems fair. That would allow the player control for both normal resizing and for playing how you, the developer, feel is optimal if they choose to do that.
I'll wait and see if any DM wizards have an answer, I certainly can't find it.

If not I'll make the feature request for sure.
The simple answer is no; in the current version of BYOND there is no way appealing way to force a minimum window size. If you'd like to make it ugly, you could do some fancy work with winset(), checking the size of the window when resized, then resizing it to the minimum if it is less. Or you could simply disable resizing altogether for the window. But any DM dev would advise you to avoid that.

However, if one were to be using the Webclient, this would easily be possible. In the current state of BYOND, the webclient seems to prove superior in terms of limitations. Check it out here to see if it fits your needs.
Best response
In the interface editor set the windows on-resize command to the verb.

You can also use on-size using winset() if prefered.

mob
var
win_min_x = 320; win_min_y = 240
win_max_x = 640; win_max_y = 480
verb
Size()
var
win_size = winget(src,"window1","size")
X = text2num(copytext(win_size,1,findtext(win_size,"x")))
Y = text2num(copytext(win_size,findtext(win_size,"x")+1))
if(X>win_max_x)X=win_max_x
else if(X<win_min_x)X=win_min_x
if(Y>win_max_y)Y=win_max_y
else if(Y<win_min_y)Y=win_min_y
winset(src,"window1","size=[X]x[Y]")
In response to Kozuma3
Here is the "fancy work with winset" ;)
In response to Konlet
Konlet wrote:
Here is the "fancy work with winset" ;)

30 seconds of work ;)

[Edit]
There seems to be a bug where it isn't called if the window is stretched using windows stretchy feature thingy, or if it's maximized. But will fix itself if pulled away from the edge of the screen so I don't see this being a issue :)
BROWSER HACK AHOY!

This is a client-side way of limiting how far a window can be resized. It'll auto-detect when it exceeds the limits and forcibly end the resize operation momentarily by disabling the window. Then it'll resize itself to the minimum/maximum size depending on which axis was over the limit, then re-enable the window and give focus back to that window.

It's ugly, it's dirty, but it happens entirely on the client-side, so it's got that going for it, which is nice.

Here's a gif of it in action:

http://gfycat.com/UnevenUnhealthyAmbushbug

And here's the example project:

http://files.byondhome.com/Ter13/sizertest_src.zip

And if anybody's interested in how the guts of this thing work:

Basically, I just hide a browser under the content of a window and anchor it to the top-left and bottom-right of the window and set the browser to the full size of the window element. Then I use some Javascript magic to capture when the browser resizes and do some winsets on the client-side via javascript there.

client
verb
setSizeLimit(wnd as text,min_w as num,min_h as num,max_w as num,max_h as num)
min_w = max(0,round(min_w))
max_w = max(0,round(max_w))
min_h = max(0,round(min_h))
max_h = max(0,round(max_h))
setWndSize(wnd,min_w,min_h,max_w,max_h)
proc
setWndSize(wnd,min_w,min_h,max_w,max_h)
src << output(list2params(args),"[wnd].hiddenbrowser:setSizeTargets")
New()
. = ..()
src << browse('sizelimit.html')


This is the document that does the client-side work:

<!DOCTYPE html>
<HTML>
<HEAD>
<META http-equiv="X-UA-Compatible" content="IE=edge">
<STYLE type="text/css">
html, body {
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
}
</STYLE>
</HEAD>
</HTML>
<BODY>
</BODY>
<SCRIPT type="text/javascript">
var parentWin, min_w = 0, min_h = 0, max_w = 0, max_h = 0;

window.onload = loadPage;

function loadPage() {
window.addEventListener("resize",onResize);
}

function setSizeTargets(pwin,lw,lh,hw,hh) {
parentWin = encodeURIComponent(pwin);
min_w = Number(lw);
min_h = Number(lh);
max_w = Number(hw);
max_h = Number(hh);
onResize();
}

var ncw, nch;

function onResize() {
if(typeof parentWin !== 'undefined') {
var cw = document.body.clientWidth, ch = document.body.clientHeight;
ncw = cw;
nch = ch;
if(min_w&&ncw<min_w) ncw = min_w;
if(min_h&&nch<min_h) nch = min_h;
if(max_w&&ncw>max_w) ncw = max_w;
if(max_h&&nch>max_h) nch = max_h;
if(nch!==ch||ncw!==cw) {window.location = "byond://winset?id="+parentWin+"&is-disabled=true&size="+ncw+"x"+nch;window.location = "byond://winset?id="+parentWin+"&is-disabled=false&focus=true";}
}
}
</SCRIPT>
</HTML>


This is a hack. You probably shouldn't use this. I repeat. You probably shouldn't use this. It's a hack.
I just wanted to add to this, the reason that I requested .winset, .winget, and .output is because I hate the BYOND 3.5/4.0 feature set with a fiery burning passion.

It wasn't a step backward, but it wasn't a step forward. BYOND as a platform has only been getting better in my opinion since the late 400 and especially since 500.
In response to Ter13
Oh it's very usefull. I hope see this in tutorials. This would help for a lot of people.