diff --git a/CMakeLists.txt b/CMakeLists.txt index 613c332..de96a46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,7 +305,7 @@ find_package(Boost REQUIRED COMPONENTS program_options) find_package(PhysFS CONFIG) find_path(PIXMAN_INCLUDE_DIR NAMES pixman.h PATH_SUFFIXES pixman-1) find_library(PIXMAN_LIBRARY NAMES pixman-1 pixman-1_static pixman-1_staticd) -find_package(Ruby 3.0 REQUIRED) +find_package(Ruby 3.0 REQUIRED COMPONENTS Development) pkg_check_modules(SIGC2 REQUIRED sigc++-2.0) pkg_check_modules(VORBISFILE REQUIRED vorbisfile) find_package_handle_standard_args(pixman-1 DEFAULT_MSG PIXMAN_LIBRARY PIXMAN_INCLUDE_DIR) diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index 0e4c7ef..a680c63 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -228,5 +228,5 @@ void graphicsBindingInit(){ 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" ); } diff --git a/binding-mri/sunshine-binding.cpp b/binding-mri/sunshine-binding.cpp index af14976..eb5b8b3 100644 --- a/binding-mri/sunshine-binding.cpp +++ b/binding-mri/sunshine-binding.cpp @@ -1,24 +1,50 @@ #include #include +#include -static VALUE string_clone(VALUE self){ - if (!RB_TYPE_P(self, T_STRING)) { - rb_raise(rb_eTypeError, "wrong argument type (expected String)"); - } +//Просто на C реализуем методы мне в падлу ебаться со статической линковкой и прочим дерьмом. +//Аминь. + +static VALUE obj_clone(VALUE self){ return rb_obj_clone(self); } +static VALUE int_times(VALUE self) { + long n = NUM2LONG(self); + + if (!rb_block_given_p()) { + ID id_to_enum = rb_intern("to_enum"); + VALUE sym = ID2SYM(rb_intern("times")); + return rb_funcall(self, id_to_enum, 1, sym); + } + + if (n <= 0) return self; + + for (long i = 0; i < n; ++i) { + rb_yield(LONG2NUM(i)); + } + + return self; +} + void SunshineBindingInit(){ printf("[SunshineBindingInit] Initializing Sunshine binding\n"); VALUE module = rb_define_module("Sunshine"); + //SDL versions, for debug info in main menu and other shi idkkkkkkkk rb_const_set(module, rb_intern("SDLVersion_major"), INT2NUM(SDL_MAJOR_VERSION)); rb_const_set(module, rb_intern("SDLVersion_minor"), INT2NUM(SDL_MINOR_VERSION)); rb_const_set(module, rb_intern("SDLVersion_micro"), INT2NUM(SDL_MICRO_VERSION)); printf("[SunshineBindingInit] SDL version: %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION); + //если методы доступны то просто не перезаписываем их if (!rb_respond_to(rb_cObject, rb_intern("class"))) { rb_define_method(rb_cObject, "class", rb_obj_class, 0); } - if (!rb_respond_to(rb_cString, rb_intern("clone"))) { - rb_define_method(rb_cString, "clone", RUBY_METHOD_FUNC(string_clone), 0); + //сразу для всех обьектов + if (!rb_respond_to(rb_cObject, rb_intern("clone"))) { + rb_define_method(rb_cObject, "clone", RUBY_METHOD_FUNC(obj_clone), 0); + } + + if (!rb_respond_to(rb_cInteger, rb_intern("times"))) { + rb_define_method(rb_cInteger, "times", RUBY_METHOD_FUNC(int_times), 0); } } diff --git a/binding-mri/time-binding.cpp b/binding-mri/time-binding.cpp index ca5b6d6..9bdeb81 100644 --- a/binding-mri/time-binding.cpp +++ b/binding-mri/time-binding.cpp @@ -1,5 +1,6 @@ #include #include +#include static VALUE get_month(VALUE self) { time_t now = time(NULL); @@ -13,9 +14,45 @@ static VALUE get_day(VALUE self) { return INT2NUM(ltm->tm_mday); } +static VALUE ctime_at(int argc, VALUE *argv, VALUE self){ + VALUE v_sec, v_sub = Qnil; + double dsec; + long long sec; + long nsec = 0; + + rb_scan_args(argc, argv, "11", &v_sec, &v_sub); + + if (TYPE(v_sec) == T_FLOAT || rb_obj_is_kind_of(v_sec, rb_cFloat)) { + dsec = NUM2DBL(v_sec); + sec = (long long) floor(dsec); + double frac = dsec - (double)sec; + nsec = (long) llround(frac * 1e9); + if (nsec >= 1000000000L) { sec += 1; nsec -= 1000000000L; } + if (nsec < 0) { + sec -= 1; + nsec += 1000000000L; + } + } else { + sec = NUM2LL(v_sec); + } + + if (!NIL_P(v_sub)) { + long usec = NUM2LONG(v_sub); + long long add_sec = usec / 1000000L; + long rem_usec = usec % 1000000L; + if (rem_usec < 0) { rem_usec += 1000000L; add_sec -= 1; } + sec += add_sec; + nsec = rem_usec * 1000L + nsec; + if (nsec >= 1000000000L) { sec += nsec / 1000000000L; nsec = nsec % 1000000000L; } + } + + return rb_time_new((time_t)sec, (long)nsec); +} + void TimeBindingInit() { printf("[TimeBindingInit] Initializing Time binding\n"); VALUE m = rb_define_module("CTime"); rb_define_module_function(m, "month", get_month, 0); rb_define_module_function(m, "day", get_day, 0); + rb_define_singleton_method(m, "at", ctime_at, -1); } diff --git a/scripts/Scene_Load.rb b/scripts/Scene_Load.rb index bf9fca4..5ab35fd 100644 --- a/scripts/Scene_Load.rb +++ b/scripts/Scene_Load.rb @@ -13,7 +13,7 @@ class Scene_Load < Scene_File $game_temp = Game_Temp.new # Timestamp selects new file $game_temp.last_file_index = 0 - latest_time = Time.at(0) + latest_time = CTime.at(0) for i in 0..99 filename = make_filename(i) if FileTest.exist?(filename) diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index 6082ec3..bb910b7 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -17,7 +17,13 @@ class Scene_Map @in_game_timer.bitmap.fill_rect(0, 0, 140, 30, Color.new(0, 0, 0)) @in_game_timer.z = 10001 @in_game_timer.visible = $game_temp.igt_timer_visible - + + @debug_info = Sprite.new + #@debug_info.x = 0; + #@debug_info.y = 670; + @debug_info.bitmap = Bitmap.new(100, 30) + @debug_info.z = 10001 + # Make sprite set @spriteset = Spriteset_Map.new # Make message window @@ -112,7 +118,11 @@ class Scene_Map total_sec * 1000 % 1000) @in_game_timer.bitmap.fill_rect(0, 0, 140, 30, Color.new(0, 0, 0, 128)) - #@in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string) + @in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string) + if Window_Settings.DebugIsEnabled == true + #@debug_info.bitmap.draw_text(0, 0, 132, 30, Graphics.frame_count.to_s) + @debug_info.bitmap.draw_text(0, 0, 132, 30, Graphics.frame_rate.to_s) + end end if Input.quit? diff --git a/scripts/Sprite_Timer.rb b/scripts/Sprite_Timer.rb index 45b00b8..f0ec164 100644 --- a/scripts/Sprite_Timer.rb +++ b/scripts/Sprite_Timer.rb @@ -45,8 +45,8 @@ class Sprite_Timer < Sprite sec = @total_sec % 60 text = sprintf("%02d:%02d", min, sec) # Draw timer - #self.bitmap.font.color.set(255, 255, 255) - #self.bitmap.draw_text(self.bitmap.rect, text, 1) + self.bitmap.font.color.set(255, 255, 255) + self.bitmap.draw_text(self.bitmap.rect, text, 1) end end end diff --git a/scripts/Window_MainMenu.rb b/scripts/Window_MainMenu.rb index 98dd72f..16d8de8 100644 --- a/scripts/Window_MainMenu.rb +++ b/scripts/Window_MainMenu.rb @@ -53,7 +53,7 @@ class Window_MainMenu < Window_Selectable # Update item rect = Rect.new(w * index, 0, w - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) - #self.contents.draw_text(rect, tr(@commands[index]), 1) + self.contents.draw_text(rect, tr(@commands[index]), 1) end #-------------------------------------------------------------------------- # * Disable Item @@ -149,10 +149,9 @@ class Window_MainMenu < Window_Selectable @fade_out = true when 3 if File.exist?("imstupidcheater.txt") - id = Integer(File.read("imstupidcheater.txt").strip.to_i) -# id = 177 - x = Integer(File.read("imstupidcheater.x").strip.to_i) - y = Integer(File.read("imstupidcheater.y").strip.to_i) + id = File.read("imstupidcheater.txt").strip.to_i + x = File.read("imstupidcheater.x").strip.to_i + y = File.read("imstupidcheater.y").strip.to_i $game_temp.player_transferring = true $game_temp.player_new_map_id = id $game_temp.player_new_x = x diff --git a/scripts/Window_SaveFile.rb b/scripts/Window_SaveFile.rb index 337523c..1ae4a22 100644 --- a/scripts/Window_SaveFile.rb +++ b/scripts/Window_SaveFile.rb @@ -20,7 +20,7 @@ class Window_SaveFile < Window_Base self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" - @time_stamp = Time.at(0) + @time_stamp = CTime.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r")