I had someone send me a message asking about how to use $RESIZE to set a screen to reflow text (not stretch or scale it), so I thought I'd write up a quick little demo and share with everyone.
'$Dynamic
If DW
> 1920 Then 'I'm going to assume it's a super highres screen FontSize = 40
FontSize = 20
Font
= _LoadFont("courbd.ttf", FontSize
, "monospace")
Print "This is just a demo of a resizable screen and how we'd adjust our text to give us more words per row with a wide screen and fewer words with a narrower screen. This will also change font size automatically to a much larger font, if your screen resolution is greater than 1920 pizels wide, and still look proper for you. This is just a demo and really does nothing beyond this point..." Print "Note, there is *NO* word-wrap built into this demo."
If Delay#
= 0 Then Delay#
= ExtendedTimer
+ 10.0 '10 seconds to view and resize my pretty little title screen If Delay#
< ExtendedTimer
Then Room = 1
Text1$ = "Resizing Screen Demo"
Text2$ = "By. SMcNeill"
Text3$ = "2021"
CenterText Text1$, Top
Sub CenterText
(text$
, Ypos
)
DisplayScreen = tempscreen
l1
= InStr(l
+ 1, d$
, "-") Select Case i
'Add the number of days for each previous month passed Case 1: d
= d
'January doestn't have any carry over days. Case 2, 4, 6, 8, 9, 11: d
= d
+ 31 Case 5, 7, 10, 12: d
= d
+ 30 d = d + 365
If m
> 2 Then d
= d
+ 1 'add an extra day for leap year every 4 years, starting in 1970 d = d - 1 'for year 2000
s~&& = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
ExtendedTimer##
= (s~&&
+ Timer)
Now this makes a simple little program for us with a resizable screen. The first screen is nothing but some text that centers itself for us as a simple title screen. It's configured to remain visible for 10 seconds while you play with the size of the screen and watch the text move to reposition itself always into the center of your screen, regardless of the dimensions you set. (Unless you scrunch the screen too small, of course. I'm keeping the demo simple here, so there's no limit to how large/small you can make your screen, and if it's too small, the text won't have room to display properly, so be aware of that. :P )
Note the resize SUB in particular -- it's the one which is in charge of the screen dimensions:
DisplayScreen = tempscreen
RX = _ResizeWidth: RY = _ResizeHeight -- read the resized dimensions
_Font 16 -- get ready to free the screen by making certain to swap to a default font for the display
tempscreen = _NewImage(RX, RY, 32) -- make the new screen
Screen tempscreen -- swap to the new screen
_FreeImage DisplayScreen -- free the old screen
DisplayScreen = tempscreen -- make the new screen the old screen
_Font Font -- set the proper font back for the new screen
And that's basically the whole process in a nutshell!
If anyone has questions about this little resizing technique, feel free to ask, and I'll answer all I can for you guys until the process makes sense to everybody. It's really not as difficult as some people make it out to be. ;)