Forum Replies Created
-
AuthorPosts
-
Fullscreen Editor is not really full screen. It is letterboxed to a 4×3 ratio and is even smaller than a non fullscreen editor. On my laptop monitor, with fullscreen window and my current font size and layout, I get 116 columns. In fullscreen editor mode, I get only 96. If I do fullscreen Window mode, and turn off all the dock views, I get 142 columns, an extra 46 columns. Problem with that solution is 1) I still get the icons and menu at top, so the vertical space is shorter, and 2) It is much easier to switch from Fullscreen editor and back with Shift-F11, instead of doing Alt-1-2-3-4-5-6-7 to switch back and forth.
What would be a nice feature is to allow any dock to become fullscreen. At times I will try and read the documentation and have to drag the window up into the editor to see more at a time. Would be handy to switch between views with a single key combination.
I’ll post this here as I think this problem is related. When someone likes a post, you can’t click on any links in the post near the bottom. For example http://monkeycoder.co.nz/forums/topic/extracting-affinematrixes/#post-15276
It seems a fix was already on Github. Compiles fine now.
If you want to read one line at a time, you need to open a stream and use ReadLine() method
Monkey1234567891011121314151617Namespace myapp#Import "<std>"#Import "assets/test.txt"Using std..Function Main()Local stream:Stream = Stream.Open("asset::test.txt","r")While Not stream.EofPrint stream.ReadLine()EndEndRevenge star is an Android game made in Monkey 2.
https://play.google.com/store/apps/details?id=com.playniax.revengestarArrays are a bit weird. A zero length array acts like a Null object, but at the same time has a Length property which it shouldn’t if the array is truly Null.
Monkey123456789Local IntArray:Int[]If IntArray = Null 'The array is NullPrint "Array is Null"ElsePrint "Array is not Null"End IfPrint "Array length = "+IntArray.Length 'However, it still has a Length propertyTo create a zero length array, use ArrayName:Type[]. Then you can use Resize or New to add to the array
Monkey12345678910111213141516171819202122232425262728293031Namespace myapp#Import "<std>"Using std..Class ControlField Name:StringField Trigger:Bool()Field Callback:Void()EndFunction Main()Local Controls:Control[] '0 length controlsFor Local i:Int = 0 To 3Print ("Length before adding control = "+Controls.Length)Controls = Controls.Resize(i+1)Print ("Length after adding control = "+Controls.Length)Controls[i] = New Control 'add the instance to the arrayControls[i].Name = "Control #"+iNextFor Local control := Eachin ControlsPrint control.NameNextEndVery useful. Thanks for sharing.
On windows, you can use GetEnv(“appdata”) to get the aplication data directory, then append “/myprogramname/data/” to it.
Local Dir:=GetEnv(“appdata”)+”/myprogramname/data/”
CreateDir(Dir)
etc…Don’t know if that would work on other platforms. Monkey probably should have a command like AppDataDir() to return the place to store persistent data across all platforms.
Maybe possible that more data is received between lines 2 and 3 causing server.ReceiveFrom to read in more data than the buffer was originally allocated?
Maybe try something like thisMonkey123456Local CanReceive:=server.CanReceiveIf CanReceive>0 Thenbuffer=New DataBuffer( CanReceive+1 )server.ReceiveFrom( Varptr buffer, CanReceive, addr )Print buffer.PeekUByte( 0 )EndifHere is the code in the source.
Monkey123456Method Resize( length:Int )Local data:=Cast<UByte Ptr>( GCMalloc( length ) )libc.memcpy( data,_data,Min( length,_length ) )GCFree( _data )_data=dataEndAs you can see, the buffer is being resized properly. The problem is that the _length field is not being updated, so it is reporting the wrong size (and could cause an error if you read or write outside the true length).
Should be a _length = length in there somewhere.Edit: just submitted an issue on Github.
I get the same error. Don’t know why. If I run the below in a command window, I get this printed to STDOUT:
SDL_PeepEvents error:and this printed to STDERR:
AL lib: (EE) alc_cleanup: 1 device not closedThis is true whether I compile in debug or release.
Without the timer, the SDL error disappears, but the AL error remains.Monkey123456789101112131415161718192021222324252627282930313233343536373839404142Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField timer:TimerField x:intMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )timer = New Timer(60,OnUpdate)x = 0EndMethod OnUpdate()x = (x+1)Mod 640endMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()canvas.DrawText( "Hello World!",x,Height/2,1,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndI have the same problem with Google Drive. Never did figure out the solution for it.
Didn’t even realize just how flexible using handles on text is until I started thinking about this more. Put text right where you want it without messing with too much math.
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )Self.ClearColor = Color.BlackEndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()Local rect:= New Rectf(100.0,30.0,Width-100.0,Height-30.0)canvas.Color = Color.Greycanvas.DrawRect(rect)canvas.Color = Color.White'Top leftcanvas.DrawText("0 ",rect.Left,rect.Top,1.0,1.0)canvas.DrawText(" 1",rect.Left,rect.Top,0.0,1.0)canvas.DrawText("2 ",rect.Left,rect.Top,1.0,0.0)canvas.DrawText(" 3",rect.Left,rect.Top,0.0,0.0)'Top Rightcanvas.DrawText("0 ",rect.Right,rect.Top,1.0,1.0)canvas.DrawText(" 1",rect.Right,rect.Top,0.0,1.0)canvas.DrawText("2 ",rect.Right,rect.Top,1.0,0.0)canvas.DrawText(" 3",rect.Right,rect.Top,0.0,0.0)'Bottom Leftcanvas.DrawText("0 ",rect.Left,rect.Bottom,1.0,1.0)canvas.DrawText(" 1",rect.Left,rect.Bottom,0.0,1.0)canvas.DrawText("2 ",rect.Left,rect.Bottom,1.0,0.0)canvas.DrawText(" 3",rect.Left,rect.Bottom,0.0,0.0)'Bottom Rightcanvas.DrawText("0 ",rect.Right,rect.Bottom,1.0,1.0)canvas.DrawText(" 1",rect.Right,rect.Bottom,0.0,1.0)canvas.DrawText("2 ",rect.Right,rect.Bottom,1.0,0.0)canvas.DrawText(" 3",rect.Right,rect.Bottom,0.0,0.0)'Leftcanvas.DrawText("Left1 ",rect.Left,rect.Center.y,1.0,.5)canvas.DrawText(" Left2",rect.Left,rect.Center.y,0.0,.5)'Rightcanvas.DrawText("Right1 ",rect.Right,rect.Center.y,1.0,.5)canvas.DrawText(" Right2",rect.Right,rect.Center.y,0.0,.5)'Topcanvas.DrawText("Top1",rect.Center.x,rect.Top,.5,1.0)canvas.DrawText("Top2",rect.Center.x,rect.Top,.5,0.0)'Bottomcanvas.DrawText("Bottom1",rect.Center.x,rect.Bottom,.5,1.0)canvas.DrawText("Bottom2",rect.Center.x,rect.Bottom,.5,0.0)'Centercanvas.DrawText("Center",rect.Center.x,rect.Center.y,.5,.5)EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndEdit: Thinking this would be good in the Code Library.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()Local text:="Hello World!"Local rightX:= Width-canvas.Font.TextWidth(text)'left justifycanvas.DrawText(text,0,10)'right justifycanvas.DrawText(text,rightX,30)'center justifycanvas.DrawText(text,rightX/2,60)'orcanvas.DrawText(text,Width/2,90,.5,0 ) '<-use handlesEndEndFunction Main()New AppInstanceNew MyWindowApp.Run()End -
AuthorPosts