From ff714cd0ac2482a12028dcfda0471110c50dd47a Mon Sep 17 00:00:00 2001 From: ZakatTeamI2P Date: Fri, 8 May 2026 22:13:16 +0400 Subject: [PATCH] I hate ruby --- CMakeLists.txt | 1 + binding-mri/binding-mri.cpp | 3 +++ binding-mri/sunshine-binding.cpp | 2 +- binding-mri/time-binding.cpp | 22 ++++++++++++++++++++++ scripts/Game_Player.rb | 2 +- scripts/RPG.rb | 4 +--- scripts/Scene_Title.rb | 23 ++++++++++++++--------- scripts/Window_Message.rb | 3 +-- 8 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 binding-mri/time-binding.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b3ccd9..613c332 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,6 +279,7 @@ set(BINDING_SOURCE binding-mri/journal-binding.cpp binding-mri/chroma-binding.cpp binding-mri/niko-binding.cpp + binding-mri/time-binding.cpp ) source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS}) diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 408050d..5f34e00 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -65,6 +65,7 @@ void windowBindingInit(); void tilemapBindingInit(); void windowVXBindingInit(); void tilemapVXBindingInit(); +void TimeBindingInit(); void inputBindingInit(); void audioBindingInit(); @@ -107,6 +108,8 @@ static void mriBindingInit(){ windowBindingInit(); tilemapBindingInit(); + TimeBindingInit(); + inputBindingInit(); audioBindingInit(); graphicsBindingInit(); diff --git a/binding-mri/sunshine-binding.cpp b/binding-mri/sunshine-binding.cpp index eb7b628..3aa9314 100644 --- a/binding-mri/sunshine-binding.cpp +++ b/binding-mri/sunshine-binding.cpp @@ -20,6 +20,6 @@ void SunshineBindingInit(){ } if (!rb_respond_to(rb_cString, rb_intern("clone"))) { rb_define_method(rb_cString, "clone", RUBY_METHOD_FUNC(string_clone), 0); - } + } printf("[SunshineBindingInit] Done\n"); } diff --git a/binding-mri/time-binding.cpp b/binding-mri/time-binding.cpp new file mode 100644 index 0000000..cbdeea6 --- /dev/null +++ b/binding-mri/time-binding.cpp @@ -0,0 +1,22 @@ +#include +#include + +static VALUE get_month(VALUE self) { + time_t now = time(NULL); + struct tm *ltm = localtime(&now); + return INT2NUM(1 + ltm->tm_mon); +} + +static VALUE get_day(VALUE self) { + time_t now = time(NULL); + struct tm *ltm = localtime(&now); + return INT2NUM(ltm->tm_mday); +} + +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); + printf("[TimeBindingInit] Done\n"); +} diff --git a/scripts/Game_Player.rb b/scripts/Game_Player.rb index 51405ca..d13a081 100644 --- a/scripts/Game_Player.rb +++ b/scripts/Game_Player.rb @@ -291,7 +291,7 @@ class Game_Player < Game_Character @wheel_squeak = false end end - Audio.se_play("Audio/SE/#{name}.wav", (vol * volume).to_i, pitch.to_i) + Audio.se_play("Audio/SE/#{name}.wav", vol * volume, pitch) end emit_footsplash(@direction) end diff --git a/scripts/RPG.rb b/scripts/RPG.rb index 3d79194..36bf3c8 100644 --- a/scripts/RPG.rb +++ b/scripts/RPG.rb @@ -13,10 +13,8 @@ module RPG #lowercasing facepic name to be more case insensitive #to catch the few instances where we use "Niko" instead of "niko" filename = filename.downcase - #april fools! - t = Time.now - if t.month == 4 && t.day == 1 && filename.start_with?("niko") + if CTime.month == 4 && CTime.day == 1 && filename.start_with?("niko") filename = "af" end diff --git a/scripts/Scene_Title.rb b/scripts/Scene_Title.rb index f99ba23..01d0b7f 100644 --- a/scripts/Scene_Title.rb +++ b/scripts/Scene_Title.rb @@ -7,7 +7,7 @@ class Scene_Title MENU_X = 640 - 150 MENU_Y = 480 - 100 - + SDLVer = "#{Sunshine::SDLVersion_major}.#{Sunshine::SDLVersion_minor}.#{Sunshine::SDLVersion_micro}" #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- @@ -68,11 +68,14 @@ class Scene_Title @menu = Sprite.new @menu.z += 1 @menu.bitmap = Bitmap.new(640, 480) -# @menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start")) -# @menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings")) -# @menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit")) + @menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start")) + @menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings")) + @menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit")) + #Debug info like in minecraft Forge :P + @menu.bitmap.draw_text(5, 5, 150, 20, tr("Ruby: #{RUBY_VERSION}")) + @menu.bitmap.draw_text(5, 25, 150, 20, tr("SDL: #{SDLVer}")) if $game_switches[160] && $game_switches[152] -# @menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("...")) + @menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("...")) end Language.register_text_sprite(self.class.name + "_contents", @menu.bitmap) # Make cursor graphic @@ -131,11 +134,13 @@ class Scene_Title #-------------------------------------------------------------------------- def update @menu.bitmap.clear -# @menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start")) -# @menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings")) -# @menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit")) + @menu.bitmap.draw_text(MENU_X, MENU_Y, 150, 24, tr("Start")) + @menu.bitmap.draw_text(MENU_X, MENU_Y + 25, 150, 24, tr("Settings")) + @menu.bitmap.draw_text(MENU_X, MENU_Y + 50, 150, 24, tr("Exit")) + @menu.bitmap.draw_text(5, 5, 150, 20, tr("Ruby: #{RUBY_VERSION}")) + @menu.bitmap.draw_text(5, 25, 150, 20, tr("SDL: #{SDLVer}")) if $game_switches[160] && $game_switches[152] -# @menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("...")) + @menu.bitmap.draw_text(MENU_X, MENU_Y + 75, 150, 24, tr("...")) end # Handle cursor movement if !@window_settings_title.visible diff --git a/scripts/Window_Message.rb b/scripts/Window_Message.rb index ce71501..c0a1423 100644 --- a/scripts/Window_Message.rb +++ b/scripts/Window_Message.rb @@ -394,8 +394,7 @@ class Window_Message < Window_Selectable else if @blip >= BLIP_TIME #april fools - t = Time.now - if $game_temp.message_face != nil && t.month == 4 && t.day == 1 && $game_temp.message_face.start_with?("niko") + if $game_temp.message_face != nil && CTime.month == 4 && CTime.day == 1 && $game_temp.message_face.start_with?("niko") niko_sounds = [ "cat_2"] @blipsound = niko_sounds[rand(niko_sounds.length)] Audio.se_play("Audio/SE/#{@blipsound}.wav", 50, rand(100..125)) unless @text.empty?