diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index bb49078..c937a67 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -188,6 +188,7 @@ DEF_GRA_PROP_B(Frameskip) void graphicsBindingInit(){ VALUE module = rb_define_module("Graphics"); + _rb_define_module_function(module, "update", graphicsUpdate); _rb_define_module_function(module, "freeze", graphicsFreeze); _rb_define_module_function(module, "transition", graphicsTransition); @@ -200,8 +201,6 @@ void graphicsBindingInit(){ _rb_define_module_function(module, "width", graphicsWidth); _rb_define_module_function(module, "height", graphicsHeight); - const Config &conf = shState->rtData().config; - rb_define_const(module, "ASPECT", rb_str_new_cstr(conf.AspectPreset.c_str())); _rb_define_module_function(module, "wait", graphicsWait); _rb_define_module_function(module, "fadeout", graphicsFadeout); _rb_define_module_function(module, "fadein", graphicsFadein); @@ -209,9 +208,11 @@ void graphicsBindingInit(){ _rb_define_module_function(module, "resize_screen", graphicsResizeScreen); INIT_GRA_PROP_BIND( Brightness, "brightness" ); - INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" ); INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" ); INIT_GRA_PROP_BIND( Smooth, "smooth" ); - INIT_GRA_PROP_BIND( Frameskip, "frameskip" ); + INIT_GRA_PROP_BIND( Frameskip, "frameskip" ); + + const Config &conf = shState->rtData().config; + rb_define_const(module, "RESOLUTION_ASPECT", rb_str_new_cstr(conf.AspectPresetRubyConst.c_str())); } diff --git a/binding-mri/module_rpg1.rb b/binding-mri/module_rpg1.rb index 3cdf735..b948f15 100644 --- a/binding-mri/module_rpg1.rb +++ b/binding-mri/module_rpg1.rb @@ -1,26 +1,3 @@ -# aspects, resolutions and filenames -# 4:3 - 640x480 - "_4_3" -# 16:9 - 960x540 - "_16_9" -# 16:10 - 960x600 - "_16_10" -# -# extra (not recomendated) -# 16:9 HD - 1280x720 - "_16_9_hd" -# 16:9 FHD - 1920x1080 - "_16_9_fhd" -module Graphics - RESOLUTION_ASPECT = - if Graphics.width == 1920 && Graphics.height == 1080 - "_16_9_fhd" - elsif Graphics.width == 1280 && Graphics.height == 720 - "_16_9_hd" - elsif Graphics.width == 1920 / 2 && Graphics.height == 1080 / 2 - "_16_9" - elsif Graphics.width == 640 && Graphics.height == 480 - "_4_3" - else - "" - end -end - module Kernel alias_method :original_puts, :puts diff --git a/oneshot.conf b/oneshot.conf index a868623..36145e6 100644 --- a/oneshot.conf +++ b/oneshot.conf @@ -26,16 +26,22 @@ printFPS=false fixedAspectRatio=true # Set Monitor Aspect preset -# Aviable: -# _4_3 (default) -# _16_9 -# _16_10 -# _2_3 -AspectPreset="_4_3" +# Value, Aspect, Window Resolusion +# (ratio and resolution are not acceptable values) +# Where X - not recommended, the correctness of +# the game is not guaranteed. +# 0 - 2:3 - 640x960 +# 1 - 4:3 - 640x480 (default) +# 2 - 16:9 - 960x540 +# 3 - 16:10 - 960x600 +# 4 - 16:9 HD - 1280x720 X +# 5 - 16:9 FHD - 1920x1080 X +AspectPreset=1 # Controlling the resolution of the game window, # it is not recommended to change. -# If you want to configure 16:9, use EnableSixteenByNine. +# If you want to configure 16:9 or any other, +# use AspectPreset. # defScreenW=0 # defScreenH=0 diff --git a/src/config.cpp b/src/config.cpp index 22325d8..e89a79b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -63,8 +63,7 @@ namespace po = boost::program_options; #define CONF_FILE "oneshot.conf" -Config::Config() -{} +Config::Config() {} void Config::read(int argc, char *argv[]){ #define PO_DESC_ALL \ @@ -73,7 +72,7 @@ void Config::read(int argc, char *argv[]){ PO_DESC(printFPS, bool, false) \ PO_DESC(fullscreen, bool, false) \ PO_DESC(fixedAspectRatio, bool, true) \ - PO_DESC(AspectPreset, std::string, "_4_3") \ + PO_DESC(AspectPreset, int, 1) \ PO_DESC(smoothScaling, bool, false) \ PO_DESC(vsync, bool, true) \ PO_DESC(defScreenW, int, 640) \ @@ -177,6 +176,28 @@ void Config::read(int argc, char *argv[]){ game.title = "OneShot: Sunshine"; game.scripts = "Data/xScripts.rxdata"; + #define ASPECT_SELECT(id, x, y, rubyConst) \ + case id: { \ + defScreenW = x; \ + defScreenH = y; \ + AspectPresetRubyConst = #rubyConst;\ + break; \ + } + + if (defScreenW == 640 && defScreenH == 480) + switch (AspectPreset) { + RESOLUTIONS_LIST(ASPECT_SELECT) + default: { + AspectPreset = 1; + AspectPresetRubyConst = "_4_3"; + defScreenW = 640; + defScreenH = 480; + break; + } + } + + #undef ASPECT_SELECT + #ifdef STEAM /* Override fullscreen config if Big Picture */ if (const char *env = SDL_getenv("SteamTenfoot")){ diff --git a/src/config.h b/src/config.h index cfd392f..4e9a430 100644 --- a/src/config.h +++ b/src/config.h @@ -50,7 +50,8 @@ struct Config{ int maxTextureSize; std::string gameFolder; - std::string AspectPreset; + int AspectPreset; + std::string AspectPresetRubyConst; bool allowSymlinks; bool pathCache; @@ -96,4 +97,20 @@ struct Config{ void read(int argc, char *argv[]); }; +// 0 - 2:3 - 640x960 +// 1 - 4:3 - 640x480 (default) +// 2 - 16:9 - 960x540 +// 3 - 16:10 - 960x600 +// 4 - 16:9 HD - 1280x720 X +// 5 - 16:9 FHD - 1920x1080 X + +// Value X Y Ruby const +#define RESOLUTIONS_LIST(X) \ + X(0, 640, 960, _2_3) \ + X(1, 640, 480, _4_3) \ + X(2, 960, 540, _16_9) \ + X(3, 960, 600, _16_10) \ + X(4, 1280, 720, _16_9_hd) \ + X(5, 1920, 1080, _16_9_fhd) + #endif // CONFIG_H