Forum Replies Created
-
AuthorPosts
-
We can’t get any TabButton from TabView. And TabButton has no property Closable.
Easiest way to manage closable state is to add additional parameter closable:Bool=True into TabView.AddTab().
You can do it yourself or ask to Mark to add this ability.
It would be better to have it in mojox.
Topic about image saving: http://monkeycoder.co.nz/forums/topic/how-to-save-a-image/
There is also ExternalDir() function along with InternalDir.
I’m not sure is it sdcard dir or not.
But if it’s so, you can use something like this:
Monkey12345Function SaveImageMobile( img:Image,path:String )Local path:=ExternalDir()+path(New Canvas(img)).CopyPixmap(New Recti(0,0,img.Width,img.Height)).Save(path)EndIn addition to GUI app:
- there is a single output file now, info section with names / offsets / sizes placed alogn with binaries;
- addet GetText() method to extract textual files.
November 17, 2017 at 10:00 am in reply to: Home Run Tri Peaks Solitaire – Out Now on Google Play for Android #11773Congrats!!
I think you always should to use virtual resolution and relative coords to get the same result on all devices.
Also you can load HD resources according to real resolution.
LoadString based on DataBuffer.Load
Look at std.filesystem functions. There is an InternalDir() for example. Maybe it’s what you need.
Monkey1234567891011Function LoadStringMobile:String( path:String )Return LoadString( InternalDir()+path )EndFunction SaveStringMobile( text:String,path:String )SaveString( text,InternalDir()+path )End' usage:SaveStringMobile( "hello","text-data.txt" ).....Local str:=LoadStringMobile( "text-data.txt" )Print strI can’t insert link to docs page because docs is dynamically showing by JavaScript, therefore I insert link to source code:
Some ideas about using data packer.
I want to use it for release but don’t want to re-pack every time while developing.
My approach is to have 2 imports with different ‘configs’ for resource manager:
Monkey12#Import "ResDev"'#Import "ResRelease"We use one of them at a time – just comment/uncomment two lines.
Inside of them we have something like:
Monkey123456789101112' ResDevNamespace datapacker' just import assets files#Import "assets/"Function InitAssets()' do nothingEndMonkey1234567891011121314' ResReleaseNamespace datapacker' import our packed files instead of all assets files#Import "packs/@/"' Assets is a singleton class, you should use it for all loading stuffFunction InitAssets()Assets.UsePack( "assets.bin" ) ' or do it another wayEndDon’t forget to call our InitAssets() in Main():
Monkey12345678910Function Main()InitAssets()New AppInstanceNew MyWindowApp.Run()EndOf course, we should use our Assets class for any loading stuff to get all discussed here benefits (easy swapping between loading-from-single-files and loading-from-packs).
Also, we can try to find single-files in assets folder if not found in pack-file.
Attachments:
Function LessThan<T>:Bool( val:T )( cmp:T )
Wow, two pairs of brackets, it’s an undocumented cheat!
And it works. My life will never be the same…Ok I though this was not new and that the new feature announced in the blog post was not for generics.
New part of Where is abilitity to combine conditions by And / Or / Not operators.
You can write Where T Extends Component Or T=MyUpdater. Yes, we also can use = and <> in conditions.
Combined condition is needed also for multi-generic classes, for example:
Monkey123Class Dictionary<K,V> Where K Implements IKey And V Implements IValue.......EndI still don’t get when the class has been instantiated if the program could not run. Afaik you have to call New() to get an instance. Or Mark meant instantiated in the compiler logic?
Here: “instantiated” means “code part where we call New()”. Monkey2’s compiler check all New() calls to check are they correct accordingly with Where. C++ compiler do its own checks but doesn’t allow us to deny using of unwanted types as a generics (allow to deny, sounds good:) ).
If you want a function to be called when a value is modified, you’ll need a ‘Set’ style method for assignments
Yes, I want this! But don’t want to use Set or properties.:)
Saying about Class Assignable<T> above I meant to have it as a core type of monkey2 like a Variant is.
Variant have an assignment magic on a c++ side. I need right the same plus event Assigned to be able to react on value changes.
I know that this is very specific thing, but maybe it sounds useful not for me only.
This solution depends on Stream.Seek( position:Int ) method, but not all streams are seek-able.
This time I know only that it works fine for desktops.
Also need to test very big pack file – about 500 mb and monitoring RAM usage.
I expect to see low RAM usage because it just jumps to resource offset in file stream and read only needed data part.
No, I will not supporting assignment overloading in the near future, if ever.
I agree, and I never used it in c++.
Any ideas how to get what I want?
My idea is to have special base class with Assigned event. So we can’t break anything by overloading but can react on assignment:
Monkey1234567Class Assignable<T>ProtectedField Assigned:Void( value:T ).....EndMaybe this class will extends Variant but with generic type.
And usage:
Monkey12345678910111213Class Changable<T> Extends Assignable<T>Field Changed:Void()Method New()Assigned=Lambda( value:T )_value=valueChanged()EndEnd.........EndWhat would be the syntax for the new where for class conditions? And what is the purpose of this feature?
Don’t use it just because you can if you don’t really need that.
And I don’t get how a compilation error can occur while the class is instantiated, wouldn’t it be a runtime error?
Not a runtime error but compile time error!
mx2cc checks variables types at compile time.
See my example below. There is an compilation error. Just comment where condition and you can compile it.
Both classes have DoSomething methods => we can use them as generic type.
But if we want to use ComponentHolder with components only – we add Where condition to deny other types.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748Namespace myapp#Import "<std>"Using std..Function Main()Local h1:=New ComponentHolder<Component>( New Component )Local h2:=New ComponentHolder<NotComponent>( New NotComponent )h1.Exec()h2.Exec()EndClass ComponentMethod DoSomething()Print "I'm a component"EndEndClass NotComponentMethod DoSomething()Print "I'm not a component"EndEndClass ComponentHolder<T> Where T Extends ComponentMethod New( comp:T)_component=compEndMethod Exec()_component.DoSomething()EndPrivateField _component:TEndThe truth is, I don’t want to have such magic in monkey2.
I agree – operator To + extensions = powerful coding.
So the monkey2 equivalent might be: if ‘operator from’ WAS supported, and a dst type implemented ‘operator from’ and a src type implemented ‘operator to’, which would get used when converting from src type to dst type?
Left-sided vars have a bigger priority, I think…
If there’s something you can’t do this way, let me know and we can try to come up with a solution.
I’m triyng to do observable variables – sort of plain values wrapper which would notify listeners about value changing.
And I want to use this wrapper as a plain type, but I can’t catch value assignment without overriding of assign operator.
Variant type have a magic with value assigning – we can assign anything.
I want to do something like that but with strong types checking via generics.
My example:
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950Namespace myappFunction Main()Local i1:=New Changable<Int>( 10 )i1.Changed+=Lambda()Print "changed: "+i1Endi1=7 ' can't assign'i1=i1+15EndClass Changable<T>Field Changed:Void()Method New()EndMethod New( value:T )_value=valueEndOperator =( value:T ) 'trouble is here_value=valueChanged()EndOperator To:T()Return _valueEndOperator To:String()Return ""+_valueEndProperty Value:T()Return _valueEndPrivateField _value:TEndTry to compile template app.
Menu File — Templates — Simple mojo app.
-
AuthorPosts
