Moving resources from a Module, like Mojo SetFont
Monkey Forums/Monkey Programming/Moving resources from a Module, like Mojo SetFont
| ||
If I use mojo's DrawText I automagically get a font in my data folder. The Mojo Module has a data folder with a file called "mojo_font.png" In SetFont we find this: context.defaultFont=LoadImage( "mojo_font.png",96,Image.XPadding ) but how or where is the file copied to my data directory? If I want to do something similar in my Module, then what is the recommended approach to doing this? Or can I just use the resource from the Module's/data folder? |
| ||
Yep I was totally wrong :P |
| ||
Just had a quick checked on the computer. And it looks like it's added as an Import in graphics.monkey in modules mojo. Also in there is a BMax file to create a font. |
| ||
Been playing around and did a bit of testing. I commented out the Import at the top of graphics.monkey. Gave it a test and no file was transferred. Then placed a font with the same name and size as mojo_font.png in another directory then just added a Import to that file into the test file. Looks like it works. |
| ||
Yeah that is how you import. It would be handy if you could force monkey to manually import any file. That way we could copy along libs into the build folder. |
| ||
<double post> |
| ||
So to import a resource I simply do: Import "data/mojo_font.png" LoadImage( "mojo_font.png",96,Image.XPadding ) If I want to make use of a font, sound or other temporary graphics in a module I can import the files like that and then simply load them as if they exist, and only if the load is called the file is transferred? It would be handy if you could force monkey to manually import any file. Does it not do exactly that? What is the limitation? |
| ||
If I want to make use of a font, sound or other temporary graphics in a module I can import the files like that and then simply load them as if they exist, and only if the load is called the file is transferred? As I understand it, any file that's not a source file will be passed on into your projects build folder ( meaning that your app will require it to work if you use it in your code ). To Import a font you will have to still load it and use SetFont, unless you do what I did and disabled the Import in graphics.monkey, then you can just use a png font as long as it's the same name as mojo_font. If you didn't disable that import then I would guess that trying to Import another file with the same name may stop trans in it's tracks.I think Skn3 was thinking a long the lines on importing precompiled 3d party libraries. |
| ||
Yeah sorry I wasn't very clear, yeah it would be nice to be able to force any file to import at build time. It couldn't a while ago, so maybe it has changed now? It would be most useful for modules adding external JavaScript libraries and such! |
| ||
It can do it now. My JungleGui module does import a default font and a javascript file on HTML5 without any issues, |
| ||
What exactly does the import "filehere" do? Can I import a .js file and then simply reference things inside it? @Ziggy, so what you are saying is that as long as I have import fontmachine and I have a default font I can use for testing? Since that is similar to what I wanted to do, for adding font to quick temp test things. |
| ||
Import "myfile" will copy the file to the data folder AFAIK. |
| ||
ah ok, so it is that simple. Great :) |