Forum Replies Created
-
AuthorPosts
-
But in your first example – maybe I’m wrong – it seems to tell to compiler
Class Image has ‘new’ function added now..Not quite. Extension members are translated into global functions but allow us to use ‘dot’ to get access to them.
Monkey123456789Class Image ExtensionMethod Crop( r:Recti ).....EndEnd' converted version is like this:Function Crop( me:Image,r:Recti ).....EndQuick question: you could use Class Image Extension many times or there’s a limit to use it ONCE, for all the ‘new features’?
Many times, in different files.
More info:
http://monkeycoder.co.nz/forums/topic/possible-to-add-method-to-rect-with-extention/
http://monkeycoder.co.nz/forums/topic/class-extensions/
Let’s continue discussion in topics above.
There is an updated code for MaskedImage:
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061Class MaskedImage Extends ImageFunction Create:MaskedImage( imagePath:String,maskPath:String,textureFlags:TextureFlags=TextureFlags.FilterMipmap )Local pixmap:=Pixmap.Load( imagePath,Null,True )If Not pixmap Return NullLocal shader:=mojo.graphics.Shader.GetShader( "sprite-masked" )Local image:=New MaskedImage( pixmap,textureFlags,shader )Local tex:=mojo.graphics.Texture.Load( maskPath,textureFlags )image._mask=teximage.MaskEnabled=TrueReturn imageEnd' you can override any (all) constructor of Image classMethod New( pixmap:Pixmap,textureFlags:TextureFlags=TextureFlags.FilterMipmap,shader:Shader=Null )Super.New( pixmap,textureFlags,shader )EndProperty Mask:Texture()Return _maskSetter( value:Texture )_mask=valueIf _maskShader=Shader.GetShader( "sprite-masked" )Material.SetTexture( "MaskTexture",_mask )ElseShader=Shader.GetShader( "sprite" )EndifEndProperty MaskEnabled:Bool()Return _maskEnabledSetter( value:Bool )_maskEnabled=valueIf _maskEnabled And _maskShader=Shader.GetShader( "sprite-masked" )Material.SetTexture( "MaskTexture",_mask )ElseShader=Shader.GetShader( "sprite" )EndifEndPrivateField _mask:TextureField _maskEnabled:BoolEndFull code is here: https://www.dropbox.com/s/x7uvftczs7ie9pg/masked-image2.zip?dl=0
Attachments:
but no the ‘Extension’ thing (seems quite clear what it does… but I would know better!)
Extensions are awesome part of language!
It’s very useful to everybody learn it.
You can open monkey2 folder as a project in Ted2Go and right-click on the root and choose Find..., then find by Extension keyword. And see what monkey2 already have.
Class SomeClassName Extension is familiar for me, but I found something new:
Monkey1234567Class cpBody Extends VoidProperty Type:cpBodyType() Extension="cpBodyGetType"Setter( type:cpBodyType ) Extension="cpBodySetType".......EndIt looks like a magic.
PS. I was surprised c# does not support operators overloading via extensions but monkey2 do that !
Attachments:
Since Image.Shader property became writable, we can create Class MaskedImage extends Image with Property Mask:Image and change mask on-the-fly.
Never really used annotations, are they a bit like compiler warnings in c/c++? I have never been a huge fan of warnings in c/c++.
There are annotation processors for processing annotation – we can add our processers for our custom annotation.
Processors are based on reflection and can inspect our annotated code parts – and generate new code if necessary.
Result compilation start after preprocessing to compile all that stuff.
Huge article for Java: http://hannesdorfmann.com/annotation-processing/annotationprocessing101
I have seen @override used in java I think. Why is it optional? Because it would break too much existing code? What does it actually do then?
It’s a helper annotation which check “have superclass/interface this annotated member or not”.
If you remove some methods from interface
- w/o @override – removed methods stay as a own class methods, stopped overriding and don’t accessible via interface, but you have no notified about any problems here
- with @override – compiler stopped and say “you have no such interface method”, so you don’t break your expected logic.
And why not add @nulable as a language keyword?
There are many other annotation which processed the same way, so is better to use Processors and don’t clutter the language itself.
Annotations can have params – therefore they have more power than keywords.
As you may have guessed, I’m not really into just throwing every possible consteuct at the language (simple as possible, no simpler etc) ala c#, and it’d be nice to have some ‘examples’ of why this is useful too?
I agree with that.
Main barrier here is how to processing annotations in monkey – processors should be usual monkey classes, I don’t know is it possible to run them and pass all annotated items..
There are can be json’s annotations as a real example:
Monkey12345678@Serializable("JSON")Class MyObject@JsonName("personName")Field name:StringField total:Double@JsonIgnoreField number:IntEnd@JsonName("personName") – allow us rename variable name and always have it as personName – don’t break deserialize process.
@JsonIgnore allow to skip any fields by serializer
All this stuff is looks hard to implement and have a phantom benefit, at least this time.
Greetings from Russia.
I like that too. Maybe can add soon.
(I already done with that in jentos.code – IDE for monkey-x.)
Wow! I like it.
To construct generic-like system we already have minimal ‘reflection w/o reflection’ via typeName:
Monkey1234Function TypeName<T>:String( obj:T ) Where T Extends ObjectReturn String.FromCString( obj.typeName() )EndCode for Map’s fans as me
Monkey123456789101112131415161718192021222324252627282930313233Function TypeName<T>:String( obj:T ) Where T Extends ObjectReturn String.FromCString( obj.typeName() )EndClass ComponentMethod New()EndEndClass Component123 Extends ComponentMethod New()EndEndClass GoMethod Add<T>() Where T Extends ComponentLocal comp:=New TLocal type:=TypeName( comp )components[type]=compEndField components:=New StringMap<Component>EndLocal go:=New Gogo.Add<Component123>()I like this generic way because
- you can’t compile if did mistake
- avoid to use ComponentType (at least for a first look) (with moving priority + unique properties into component class)
Maybe ‘Unique’ might be a better name for this to prevent confusion?
+1.
Also Enabled propertywould be useful.
Monkey123456[offtop]Please, don't extends Sprite by Player.Sprite is a part of Player and better to make it player's field.[/offtop]I also like monkey2 (and b3d & bmax) and try to do it better working on IDE.
Earlier I chosen the QT Creator for desktop tools, but this time I prefer monkey2!
And I’m waiting for v1.1.08.
Great work! Subscribed.
Yay! I rewrite Project tree while fixing files filtering logic. Now it should work properly.
What’s new in dev branch:
- Project (Explorer) tree:
- Added – storing/restoring of expanded items, and selected item – you will see tree state on start app the same as when closed it;
- Fixed – expanding behaviour for double-clicks (also have-no-icons bug fixed);
- Fixed – files filtering – read more here;
- Added – option “Project tree single-click mode” into ‘Prefs — Common’ (False by default).
- Fixed – crash using backspace at the end of file;
- Fixed – IntelliSense + Zoom out #2;
- Improved – correct “Find results” when remove / add lines in document;
- Fixed – broken Ins/Ovr shitching by Ins key;
- Fixed – capitalizing when press space / tab;
- Improved – Source tree expanding state (was collapsed after parsing);
- Improved – jump to find result – made centered line with result;
- Added – Simple_Mojo3d_app template into ‘File — Templates’ (it’s bloom test file).
It’s still v2.7. Please, test it.
If all is OK I want to merge it into master.
Does anyone else experience the IDE throttling CPU? Right now it’s at 98% CPU on my MacBook Air early-2014, and it regularly idles around 15% CPU on my desktop Windows 10.
I hope with v1.1.08 compiler things will became better.
Could it read my .gitignore file instead, because it already selects almost the same files?
Maybe in a future, when regex will be a core part of monkey2.
Behavior is kinda random… sometimes the filter is not applied until I switch away from ted2Go, then back. Sometimes the filter is applied when alt+tab switching, but all files under subfolders disappear.
Just collapse then expand root project node should adjust filtering.
Another problem to be fixed here – I’m using App.Idle to process tree, but it works only when there are sdl events, else it’s waiting for any event and then call Idle().
I’m also confused with the explanation for the use of *. You say that *filter checks for text that starts with filter, but your example project.json file has the string *.products, which doesn’t seem to work. Shouldn’t it be .products* if you want to check for strings that end with .products?
You are right, thanks!
Think you’ve got startswith/endswith mixed up wrt: the ‘*’ filter.
Probably yes. Will fix.
Also, just added a tiny regex module called tinyregex to develop branch if that’s useful.
Nice!
Regex’s aren’t quite like yer standard file filters though, think I prefer plain file filters. Maybe * in filter could be replaced with .* or something before being regexed?
Don’t know yet.
I’m interested in is there someone who use project folder filtering via project.json ?
- This file should be placed in project folder root.
- Supported only “exclude” parameter yet.
Project filter was introduced 4th december..
http://monkeycoder.co.nz/forums/topic/ted2go-fork/page/6/#post-5582
There is my project.json file for Ted2Go:
Monkey123{"exclude":[".git", "bin", "*.buildv*", "*.products", "logo"]}There is no regexp, but a little magic with * char:
- *filter (starts with star) – check text.StartsWith( filter );
- filter* (ends with star) – check text.EndsWith( filter );
- *filter* (starts and ends) – check text.Find( filter );
- filter (w/o stars) – check equals, text = filter.
Usecase: c#-like string.Format() where {0},{1},… will be replaced with args[i] in order you pass params.
Monkey123456789101112' c#-like string.FormatMethod Format:String( str:String,args:String[] Params)For Local i:=0 Until args.Lengthstr=str.Replace( "{"+i+"}",args[i] )NextReturn strEnd' usageLocal template:="{0} is the best {1} for {3}!"Print Format( template,"Ted2Go","IDE","Monkey2" )Print Format( template,"Monkey2","tool","gemedev" )I’ve been using Ted2Go for a few weeks now and enjoying it. Thank you for the work nerobot!
Glad to hear!
-
AuthorPosts

