Maximum resolution

Silver
Okay, this is well advanced I guess. My project has background images that are 1920 x 1080. I think that reasonably covers most home setups. But there are monitors nowadays that run at higher resolutions. If I import images to cater to the highest denominator it's just going to drive up the game file size to ridiculous levels. Is there any way to put in code that reduces their monitor's resolution to 1920 x 1080 if it's higher? I realise that I'm probably asking for a feature here. But if my game is loaded on a higher resolution it's just going to tile the background imagery in a weird way.

pzolla
Not sure where you are at technically, but I have used this jQuery plugin and it is amazing. It resizes an image to the size of the container. Works really well for me in a revised Quest UI I developed.

https://github.com/karacas/imgLiquid

Silver
Thanks. I mean the entire game though, rather than an image in it.

The Pixie
I would guess that that is not possible. For security reasons, browser restrict what web pages can do, and changing the screen resolution almost certainly has to be prohibited.

HegemonKhan
just to echo+add extra comment~content to Pixie's post:

absurdly large webpage resolution + blocks to removing the infection~webpage and~or blocks to getting past the webpage to the desktop, is the 'fbi~ice' malware, that people get (infection seems to have died down now, due to crypto-malware and etc, but a few years ago it was more prevalent).

jaynabonne
Lowering the screen resolution to display your image full screen should have the same effect as scaling your image up on a higher resolution screen. If you're having trouble scaling your background image, post a sample, and we should be able to make it happen. (This is HTML after all, and people size images all the time.)

Silver
Ah, that makes sense. So for example, I'd have a 1920 x 1080 image that I code to display at the highest res there is but if the res is just 1920 x 1080 it'll just display as normal?

Is there a way to just tell the game I want background images to stretch rather than tile? Or is that what you're saying? (the former being that I have to find out the figure for what are the highest res monitors which is likely to change again in the future).

jaynabonne
In CSS/HTML parlance, if the width and height are 100%, then it will stretch. How are you setting the background image? (I haven't used the Quest APIs for that, so I don't yet know a solution if that's what you're using.)

Silver
SetBackgroundImage ("backgroundimage.jpg")


Is the only way I know of doing it and afaict if it isn't bang on the same resolution as the monitor, it tiles.

jaynabonne
This works for me:

    <start type="script">
<![CDATA[
SetBackgroundImage("9cropped.png")
msg("<style>body { background-size: 100% 100%; }</style>")
]]>
</start>


Note that the style will be lost if the screen is cleared.

Silver
Hmm, that probably won't work then. I do quite a bit with clearscreen; not so bad if it's location specific as I'd know to reset the background image, but I have an object that does a clearscreen and it could be used anywhere. Having said that I could utilise a location flag and an if script to re-set it.

Silver
What do the start tags mean? I guess I can't just c&p that script in anywhere?

jaynabonne
That was just a complete example (well, sort of), using the game's start script. You can drop the "msg" in anywhere you have the set background image, though if you do it via code view, you'll have to make sure it's wrapped in CDATA tags, since it includes "< >" characters.

What I did in my game was create my own clear screen function, which called the Quest clear screen and then sent out the css styles. Then I just called that wherever I needed to clear the screen. That's one way, at least, that isn't too painful.

Silver
Thinking about this a bit more, ClearScreen seems a bit brute force in that it clears everything including the CSS when all you want (or all I seem to want) is to clear the game text. So to avoid that would this work to those ends?

$("#divOutput").empty()

jaynabonne
It's not so much that it clears the CSS as much as it deletes all the divs in the output (which yours does as well). If you've printed some CSS with msg, then it lives in the output div as well and gets erased. The solution would be to somehow inject the css as an actual style sheet, something which we've made several attempts at with limited success.

To be honest, I've always been a bit surprised that css living inside a div works, but it seems to. :)

Silver
Oh right, so anything I do that clears the divoutput is going to remove any styling too? That throws jquery effects out of the window then. Although this didn't clear my background image:

$("#gameBorder").hide()


which means that:

$("#gameBorder").empty()


might work?

jaynabonne
Your background image is an attribute of the body element. Like this:

<body style="background-image: url(quest://local/9cropped.png?c=96822171); ">
....
</body>

You could get rid of it by setting the background-image attribute to none:

$('body').css('background-image', 'none');

Silver
Okay, I think you misunderstand. We were discussing how to overcome monitors with a larger resolution than 1920 x 1080 tiling images instead of stretching them. You then provided some code that would allow me to change background images but warned that a clearscreen command would also get rid of the background image.

So I was thinking of a way to clear text from the screen other than using clearscreen. Alex utilised:

$("#gameBorder").hide()


To hide his game text whilst waiting for his intro image to load which led me to think that:

$("#gameBorder").empty()


Might be a way of clearing the text without clearing the screen background image - although by that point I'd probably stopped thinking about it in terms of your code so it may well just do the same thing again and clear the background image if it's displayed using your code rather than SetBackgroundImage.

Silver
Actually the solution is to flag every location and override the clearscreen function to add an if script that resends the location specific screen background directly after it, I think.

Silver
Coming back to this and the CDATA tags, as their any particular reason why the html has to live inside msg ("")? I suppose if not i'd have to start using these /// which might complicate it somewhat. My only issue with with placing html inside print messages is that surely that would generate a line break where I might not want one?

jaynabonne
You can use OutputTextNoBr instead of msg, to avoid the automatic line break.

Silver
Ah! Cheers. There's an answer for everything. :)

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums