This sound very promising!
I did eventually notice your 'textbox whole text' commit and merged it; thanks. I made some changes to it, and renamed it to 'textbox text'. There was a bug: it looped over lines 0 to 6 instead of 0 to 7. I recommend using ubound() when looping over an array, it avoids bugs and means less code needs to be updated in future if the array changes. Also, I fixed it for consistent indentation again, and changed the error level to serrBadOp (as a rule of thumb, always use serrBadOp... although actually it hardly matters, because the option to set the error reporting level was removed).
What is the recommended way to get the size of the screen (width/height in pixels)?
There are two equivalent ways to get it; either use get_resolution() (which returns an XYPair), or use vpages(page)->w and vpages(page)->h. If you're inside some function where the page is an argument, then you should use the latter because the page could possibly be just a smaller part of the screen. Otherwise it doesn't matter, use what you want.
But most of the time you don't need to know the screen size; instead you can use constants like pBottom, pRight, pCenter, etc to position sprites, text, boxes, and some other stuff relative to edges of the screen. But these can't be used with slices. (The functions that accept them take RelPos arguments instead of integers)
If you want to know the screen size the game will run at, that's gen(genResolutionX) and gen(genResolutionY)
Can I load images directly from a folder on the hard drive?
For Game: not yet, but I'm actually working on that currently. For Custom: yes, just put the file in the data/ directory and it will be packaged with Custom. Use finddatafile to get the full path to the file.
Here's an example of loading 5 icons from a file, from mapsubs.bas (cutting them out of a strip):
Code: Select all
DIM datafile as string = finddatafile("arrows2.bmp") 'Actually a walkabout set
IF LEN(datafile) = 0 THEN
visible_debug "arrows2.bmp missing"
ELSE
DIM arrowset as Frame ptr = frame_import_bmp_raw(datafile)
FOR idx as integer = 0 TO 4
st.arrow_icons(idx) = frame_resized(arrowset, 20, 20, idx * -20, 0)
NEXT
frame_unload @arrowset
END IF
(Just call fatalerror instead of visible_debug if you don't want to deal with the file being missing. I was considering making Custom check all data files are present when it starts.)
Is it possible to use images that are of other dimensions than walkabouts, enemy sprites and so on?
I tried to use standard images and only paint them in the needed size but transparent pixels still trigger mouse events.
Yes, you can, see above. (I drew arrows2.bmp in the walkabout sprite editor, but it could be any dimension.) But arrows2.bmp is monochrome and I ignore the palette. For a coloured icon you should use frame_import_bmp24_or_32() instead, and pass in master() for the palette, which will load the bmp remapped to the current master palette.
When an exported slice collection contains a sprite, does it get bundled with the collection or do I need to set the image path again when I try to "instantiate" the slice collection?
In future I want slice collections to be able to store images, but right now they can only store the sprite type and spriteset number. So yes, you will need to manually lookup the slice and set it with SetSpriteToFrame. (SetSpriteToFrame didn't support unpaletted Frames, but I just pushed a commit to allow that. I haven't tested that though!)
I have an idea: lets allow sprite slices which load their image from one of the files in data/. We just need to add a string to SpriteSliceData to hold the filename, which can be saved to the .slice file. Then by adding the ability to edit it in the slice collection editor (only when creating a collection for Custom), we'll have an easy way to use icons. I think I'll implement this tomorrow!
I have successfully managed to add slices manually via code but loading them from previously saved slice collections that I made in the Slice Collection Editor doesn't seem to work. The compiler doesn't throw any errors but all I see is a black screen when I use "SliceLoadFromFile" and then parent it to the root slice via "setSliceParent".
You need to draw whichever slice you want manually, using DrawSlice or DrawSliceAt.
I guess by the root slice you mean SliceTable.Root? That SliceTable is a global in Custom is a mistake (it's not used); I've been meaning to move it out of slices.bas. Menus in Custom which draw slices just create their own root slice (but if you're loading a slice collection, you won't necessarily need another root slice, as you can draw the root of the collection directly)