summaryrefslogtreecommitdiffhomepage
path: root/lib/ruby2d.rb
diff options
context:
space:
mode:
authorTom Black <[email protected]>2019-01-03 21:25:37 -0800
committerTom Black <[email protected]>2019-01-03 23:26:39 -0800
commit3947ca0a07fdbe27a737522b366cca026a757c65 (patch)
tree40cd92960a8ba6c283e385134ec7446f0da73029 /lib/ruby2d.rb
parent8095e56c9d8532f6558316d4426c72baad50e043 (diff)
downloadruby2d-3947ca0a07fdbe27a737522b366cca026a757c65.tar.gz
ruby2d-3947ca0a07fdbe27a737522b366cca026a757c65.zip
Add an assets path variable
Adds `Ruby2D.assets/=`. By default, will resolve to `./assets`. If run in a macOS app bundle, will resolve to `App.app/Contents/Resources/assets`, for example.
Diffstat (limited to 'lib/ruby2d.rb')
-rw-r--r--lib/ruby2d.rb79
1 files changed, 51 insertions, 28 deletions
diff --git a/lib/ruby2d.rb b/lib/ruby2d.rb
index 2471888..305f065 100644
--- a/lib/ruby2d.rb
+++ b/lib/ruby2d.rb
@@ -1,36 +1,59 @@
# Ruby2D module and native extension loader, adds DSL
-require 'ruby2d/colorize'
-require 'ruby2d/exceptions'
-require 'ruby2d/renderable'
-require 'ruby2d/color'
-require 'ruby2d/window'
-require 'ruby2d/dsl'
-require 'ruby2d/quad'
-require 'ruby2d/line'
-require 'ruby2d/circle'
-require 'ruby2d/rectangle'
-require 'ruby2d/square'
-require 'ruby2d/triangle'
-require 'ruby2d/image'
-require 'ruby2d/sprite'
-require 'ruby2d/font'
-require 'ruby2d/text'
-require 'ruby2d/sound'
-require 'ruby2d/music'
-
-if RUBY_PLATFORM =~ /mingw/
- # When using the Windows CI AppVeyor
- if ENV['APPVEYOR']
- s2d_dll_path = 'C:\msys64\usr\local\bin'
- # When in a standard MinGW shell
- else
- s2d_dll_path = '~/../../usr/local/bin'
+unless RUBY_ENGINE == 'mruby'
+ require 'ruby2d/colorize'
+ require 'ruby2d/exceptions'
+ require 'ruby2d/renderable'
+ require 'ruby2d/color'
+ require 'ruby2d/window'
+ require 'ruby2d/dsl'
+ require 'ruby2d/quad'
+ require 'ruby2d/line'
+ require 'ruby2d/circle'
+ require 'ruby2d/rectangle'
+ require 'ruby2d/square'
+ require 'ruby2d/triangle'
+ require 'ruby2d/image'
+ require 'ruby2d/sprite'
+ require 'ruby2d/font'
+ require 'ruby2d/text'
+ require 'ruby2d/sound'
+ require 'ruby2d/music'
+
+ if RUBY_PLATFORM =~ /mingw/
+ # When using the Windows CI AppVeyor
+ if ENV['APPVEYOR']
+ s2d_dll_path = 'C:\msys64\usr\local\bin'
+ # When in a standard MinGW shell
+ else
+ s2d_dll_path = '~/../../usr/local/bin'
+ end
+ RubyInstaller::Runtime.add_dll_directory(File.expand_path(s2d_dll_path))
end
- RubyInstaller::Runtime.add_dll_directory(File.expand_path(s2d_dll_path))
+
+ require 'ruby2d/ruby2d' # load native extension
end
-require 'ruby2d/ruby2d' # load native extension
+
+module Ruby2D
+
+ @assets = nil
+
+ class << self
+ def assets
+ unless @assets
+ if RUBY_ENGINE == 'mruby'
+ @assets = Ruby2D.ext_base_path + 'assets'
+ else
+ @assets = './assets'
+ end
+ end
+ @assets
+ end
+
+ def assets=(path); @assets = path end
+ end
+end
include Ruby2D
extend Ruby2D::DSL