requesters.monkey2 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. Namespace std.requesters
  2. #If __TARGET__="windows"
  3. #Import "<libole32.a>"
  4. #Import "<libComdlg32.a>"
  5. #Import "<libshell32.a>"
  6. #import "<libuser32.a>"
  7. #Import "native/requesters_windows.cpp"
  8. #Import "native/requesters.h"
  9. #Elseif __TARGET__="macos"
  10. #Import "<Cocoa.framework>"
  11. #Import "native/requesters_macos.mm"
  12. #Import "native/requesters.h"
  13. #Elseif __TARGET__="linux"
  14. 'Nice, but no yesnocancel!
  15. '
  16. #Import "native/tinyfiledialogs.c"
  17. #Import "native/requesters_linux.cpp"
  18. #Import "native/requesters.h"
  19. #Elseif __TARGET__="android"
  20. #Import "native/Monkey2Requesters.java"
  21. #Elseif __TARGET__="ios"
  22. #Import "native/requesters_ios.mm"
  23. #Import "native/requesters.h"
  24. #Endif
  25. #If __DESKTOP_TARGET__
  26. Extern
  27. #rem monkeydoc Activates a modal notification dialog.
  28. Notify activates a simple modal dialog informing the user of an event. The optional `serious` flag can be used to indicate a 'critical' event.
  29. #end
  30. Function Notify:Void( title:String,text:String,serious:Bool=False )="bbRequesters::Notify"
  31. #rem monkeydoc Activates a modal Yes/No dialog.
  32. Confirm activates a simple modal dialog requesting the user to select between Yes and No options. If the user selects Yes, then Confirm returns true. Otherwise, false is returned.
  33. #end
  34. Function Confirm:Bool( title:String,text:String,serious:Bool=False )="bbRequesters::Confirm"
  35. #rem monkeydoc Activates a modal Yes/No/Cancel dialog.
  36. Proceed activates a simple modal dialog requesting the user to select between Yes, No and Cancel options. If the user selects Yes, then Proceed return 1. If the user selects No, then Proceed returns 0. Otherwise, Proceed returns -1.
  37. #end
  38. Function Proceed:Int( title:String,text:String,serious:Bool=False )="bbRequesters::Proceed"
  39. #rem monkeydoc Activates a modal file requester dialog.
  40. RequestFile activates a modal file requester dialog.
  41. The optional filters string can either be a comma separated list of file extensions or, as in the following example, groups of extensions that begin with a "group:" label and are separated by a semicolon. For example:
  42. "Image files:png,jpg;Audio files:was,ogg;All files:*"
  43. The save parameter should be true to create a save-style requester, false to create a load-style requester.
  44. The `path` parameter can be used to specify an initial file path.
  45. Returns selected file path, or an empty string if dialog was cancelled.
  46. #end
  47. Function RequestFile:String( title:String,filter:String="",save:Bool=False,file:String="" )="bbRequesters::RequestFile"
  48. #rem monkeydoc Activates a modal directory requester dialog.
  49. RequestDir activates a modal directory path dialog.
  50. The `dir` parameter can be used to specify an initial directory path.
  51. Returns selected directory path, or an empty string if dialog was cancelled.
  52. #end
  53. Function RequestDir:String( title:String,dir:String="" )="bbRequesters::RequestDir"
  54. #rem monkeydoc Opens a URL using the desktop manager.
  55. Opens a URL using the desktop manager.
  56. The behavior of OpenURL is highly target dependent, but in general it should at least be able to open web pages for you!
  57. #end
  58. Function OpenUrl( url:String )="bbRequesters::OpenUrl"
  59. Public
  60. #Elseif __TARGET__="android"
  61. Function OpenUrl( url:String )
  62. Local env:=sdl2.Android_JNI_GetEnv()
  63. Local cls:=env.FindClass( "com/monkey2/lib/Monkey2Requesters" )
  64. Local mth:=env.GetStaticMethodID( cls,"openUrl","(Ljava/lang/String;)V" )
  65. env.CallStaticVoidMethod( cls,mth,New Variant[]( url ) )
  66. End
  67. #Elseif __TARGET__="ios"
  68. Extern
  69. Function OpenUrl( url:String )="bbRequesters::OpenUrl"
  70. Public
  71. #Elseif __TARGET__="emscripten"
  72. Function OpenUrl( url:String )
  73. emscripten.emscripten_run_script( "window.location.href='"+url+"'" )
  74. End
  75. #Endif