Module Development.

Monkey Targets Forums/Android/Module Development.

debonzi(Posted 2014) [#1]
Hi everyone,

I am looking forward to implements some modules that I really miss for my ideas on game development, but as I am pretty new to monkey I have some open points to figure out.

Well, let's go for the question.

I notice that if I create the following directory structure inside <MonkeyProXX>

/modules
- mymodule
- mymodule.monkey
/native
-mymodule.java
-modulelib.jar

I automaticaly get modulelib.jar placed under libs on my application build folder and code from mymodule.java included into MonkeyGame.java.

So far so good.
But I also would like to add a file, lets say mymodule.xml in a way that after code update, it would appear into MyApp.build/android/res/values/ .

Is monkey prepared in a way to have this behavior?
I've tried to create a native/res/values/mymodule.xml inside my module folder hoping it would be automaticaly copied into the build folder but I got no luck on that.

Does anyone know about it or have any page describing "module development for Monkey"?

Regards,


AdamRedwoods(Posted 2014) [#2]
the jar file is copied over? that's good, i never knew that.

you could also try using
'' mymodule.monkey
import "mymodule.xml"

''the rest of your module here

which will copy that file to the build/data folder (assets/monkey on android). does that work?

another way is manually add it to the TARGET/template folder. (which is a bit cumbersome, but easy to create a new target, just by copying the original target and renaming it.) you'd also use this option for more advanced things that require specific compiler builds, or even specific mods to source code.


MikeHart(Posted 2014) [#3]
I am surprised by the native folder being copied too. Are you sure about that? It would be a hidden functionality. Or are you adding these files via the #libs statement in your code?


Danilo(Posted 2014) [#4]
@MikeHart:
What is the #libs statement? Can't find it in Monkey X docs. Preprocessor has only #If / #Else / #End etc.

I am asking because I'm looking for a way to include static libs/obj instead target source.
ImportLib "my.lib" ' import binary .lib, .obj, .o, .a, ...

Extern
    Function myFunction:Int()
Public

' ...


EDIT:
Found an example in modules/brl/admob.monkey
#If TARGET="android"

    Import "native/admob.android.java"
    #LIBS+="${CD}/native/GoogleAdMobAdsSdk-6.4.1.jar"

#Else

    Import "native/admob.ios.cpp"
    #LIBS+="${CD}/native/GoogleAdMobAdsSdkiOS-6.4.2/libGoogleAdMobAds.a"
    #LIBS+="${CD}/native/GoogleAdMobAdsSdkiOS-6.4.2/GADBannerView.h"
    #LIBS+="StoreKit.framework"

#End

Extern
    Class Admob Extends Null="BBAdmob"
        Function GetAdmob:Admob()        
    End
Public

Looks like what I'm looking for, will test it with .lib/.obj...

So #LIBS is a secret preprocessor string and you can add to it? More such undocumented preprocessor stuff?
The use of "${CD}" for evaluating CONSTANTS within strings is also not documented in the string section of the help. It lists only ~q, ~n, etc.


Import can be used with binary files to copy them?
Import "mymodule.xml"
Import "data/mojo_font.png" ' found in modules/mojo/graphics.monkey

Documentation for Import is missing this. When importing .cpp/.java files, it is included in the source, other files get copied?
Or everything gets copied, but to different folders (source directory, data directory, ..)?


What does an '@' mean in front of a class name?
Class @Object Extends Null="Object" ' found in modules/monkey/lang.monkey
End

What is '$' in strings in general?
Function Print( message$ )="$print" ' what is the different between "print" and "$print"?
Method ToChars:Int[]()="$tochars"



Looks like Monkey X has some useful advanced features that are all undocumented.


debonzi(Posted 2014) [#5]
Hi Mike,
I think I was not clear enough on my explanation.
I am using #LIBS statement to import it and I see it gets copied to the eclipse workspace under <workspace>/<mymonkeyproject>/libs.
Sorry if I made it confusing.

As Danilo said, there are some features that I could not find on docs (or possibly I am looking to the wrong places) and I am constantly digging into someone else's code trying to figure stuff out.
Actually Mike, I noticed the #LIBS statement and the .jar file been copied when I used your flurry module.

When I created this post in first place, I was trying to make a module for Google Analytics and as far as it requires an analitics.xml to be created under eclipse workspace/<mymonkeyproject>/res/values I was trying to figure out if it possible to somehow have those bits processed as they are processed from MonkeyProXXX/target/android/template/templates where, for instance, AndroidManifest.xml is have some of its values replaced (#ANDROID_VERSION_CODE and so on) and copied to its workspace under myproject.build directory.

I don't know if I made myself clear but if you guys want to discuss more about it, just drop a note here.

Regards,
Debonzi


debonzi(Posted 2014) [#6]
Looks like that part of the answer to my question is here:

http://www.monkeycoder.co.nz/Community/posts.php?topic=8139&post=81644

Particularly to the line:

#ANDROID_MANIFEST_APPLICATION+="<activity android:name=~qcom.google.ads.AdActivity~q android:configChanges=~qkeyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize~q />"