From 3947ca0a07fdbe27a737522b366cca026a757c65 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Thu, 3 Jan 2019 21:25:37 -0800 Subject: 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. --- ext/ruby2d/ruby2d.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ext') diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index 3d300dc..300c8e0 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -154,6 +154,18 @@ double normalize_controller_axis(int val) { } +/* + * Ruby2D#self.ext_base_path + */ +#if MRUBY +static R_VAL ruby2d_ext_base_path(mrb_state* mrb, R_VAL self) { +#else +static R_VAL ruby2d_ext_base_path(R_VAL self) { +#endif + return r_str_new(SDL_GetBasePath()); +} + + /* * Ruby2D#self.ext_screenshot */ @@ -1102,6 +1114,9 @@ void Init_ruby2d() { // Ruby2D R_CLASS ruby2d_module = r_define_module("Ruby2D"); + // Ruby2D#self.ext_base_path + r_define_class_method(ruby2d_module, "ext_base_path", ruby2d_ext_base_path, r_args_none); + // Ruby2D::Triangle R_CLASS ruby2d_triangle_class = r_define_class(ruby2d_module, "Triangle"); -- cgit v1.2.3