From 29fd8915507765a3fa5cbb558279d4d2b3d7a47d Mon Sep 17 00:00:00 2001 From: root Date: Sun, 1 Jan 2017 04:48:40 -0600 Subject: [PATCH 1/9] Adding backend changes for settings menu Committer: mshirt --- binding-mri/audio-binding.cpp | 26 +++++++++++++++ binding-mri/graphics-binding.cpp | 2 ++ src/audio.cpp | 57 +++++++++++++++++++++++++++++++- src/audio.h | 6 ++++ src/graphics.cpp | 10 ++++++ src/graphics.h | 1 + 6 files changed, 101 insertions(+), 1 deletion(-) diff --git a/binding-mri/audio-binding.cpp b/binding-mri/audio-binding.cpp index 262f5c7..883f958 100644 --- a/binding-mri/audio-binding.cpp +++ b/binding-mri/audio-binding.cpp @@ -86,6 +86,21 @@ RB_METHOD(audio_##entity##Fade) \ return rb_float_new(shState->audio().entity##Pos()); \ } +#define DEF_AUD_PROP_I(PropName) \ + RB_METHOD(audio##Get##PropName) \ + { \ + RB_UNUSED_PARAM; \ + return rb_fix_new(shState->audio().get##PropName()); \ + } \ + RB_METHOD(audio##Set##PropName) \ + { \ + RB_UNUSED_PARAM; \ + int value; \ + rb_get_args(argc, argv, "i", &value RB_ARG_END); \ + shState->audio().set##PropName(value); \ + return rb_fix_new(value); \ + } + DEF_PLAY_STOP_POS( bgm ) DEF_PLAY_STOP_POS( bgs ) @@ -97,6 +112,9 @@ DEF_FADE( me ) DEF_PLAY_STOP( se ) +DEF_AUD_PROP_I(BGM_Volume) +DEF_AUD_PROP_I(SFX_Volume) + RB_METHOD(audioReset) { RB_UNUSED_PARAM; @@ -121,6 +139,11 @@ RB_METHOD(audioReset) #define BIND_POS(entity) \ _rb_define_module_function(module, #entity "_pos", audio_##entity##Pos); +#define INIT_AUD_PROP_BIND(PropName, prop_name_s) \ +{ \ + _rb_define_module_function(module, prop_name_s, audio##Get##PropName); \ + _rb_define_module_function(module, prop_name_s "=", audio##Set##PropName); \ +} void audioBindingInit() @@ -140,4 +163,7 @@ audioBindingInit() BIND_PLAY_STOP( se ) _rb_define_module_function(module, "__reset__", audioReset); + + INIT_AUD_PROP_BIND( BGM_Volume, "bgm_volume" ); + INIT_AUD_PROP_BIND( SFX_Volume, "sfx_volume" ); } diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index d8a874e..01bc8e5 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -202,6 +202,7 @@ DEF_GRA_PROP_I(Brightness) DEF_GRA_PROP_B(Fullscreen) DEF_GRA_PROP_B(ShowCursor) DEF_GRA_PROP_B(Smooth) +DEF_GRA_PROP_B(Frameskip) #define INIT_GRA_PROP_BIND(PropName, prop_name_s) \ { \ @@ -244,4 +245,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" ); } diff --git a/src/audio.cpp b/src/audio.cpp index fbc62c1..827e61c 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -34,10 +34,17 @@ struct AudioPrivate { + int bgm_volume; + int sfx_volume; + AudioStream bgm; AudioStream bgs; AudioStream me; + int current_bgm_volume; + int current_bgs_volume; + int current_me_volume; + SoundEmitter se; SyncPoint &syncPoint; @@ -69,6 +76,11 @@ struct AudioPrivate se(rtData.config), syncPoint(rtData.syncPoint) { + bgm_volume = 100; + sfx_volume = 100; + current_bgm_volume = 100; + current_bgs_volume = 100; + current_me_volume = 100; meWatch.state = MeNotPlaying; meWatch.thread = createSDLThread (this, "audio_mewatch"); @@ -246,6 +258,7 @@ void Audio::bgmPlay(const char *filename, int pitch, float pos) { + p->current_bgm_volume = volume; p->bgm.play(filename, volume, pitch, pos); } @@ -265,6 +278,7 @@ void Audio::bgsPlay(const char *filename, int pitch, float pos) { + p->current_bgs_volume = volume; p->bgs.play(filename, volume, pitch, pos); } @@ -283,6 +297,7 @@ void Audio::mePlay(const char *filename, int volume, int pitch) { + p->current_me_volume = volume; p->me.play(filename, volume, pitch); } @@ -301,7 +316,7 @@ void Audio::sePlay(const char *filename, int volume, int pitch) { - p->se.play(filename, volume, pitch); + p->se.play(filename, (volume*p->sfx_volume)/100, pitch); } void Audio::seStop() @@ -327,4 +342,44 @@ void Audio::reset() p->se.stop(); } +int Audio::getBGM_Volume() const +{ + return p->bgm_volume; +} + +void Audio::setBGM_Volume(int value) +{ + if(value > 100){ + value = 100; + }else if(value < 0){ + value = 0; + } + p->bgm_volume = value; + p->bgm.lockStream(); + p->bgm.setVolume(AudioStream::External, ((float)(p->bgm_volume * p->current_bgm_volume))/10000.0f ); + p->bgm.unlockStream(); + p->me.lockStream(); + p->me.setVolume(AudioStream::External, ((float)(p->bgm_volume * p->current_me_volume))/10000.0f ); + p->me.unlockStream(); +} + +int Audio::getSFX_Volume() const +{ + return p->sfx_volume; +} + +void Audio::setSFX_Volume(int value) +{ + if(value > 100){ + value = 100; + }else if(value < 0){ + value = 0; + } + p->sfx_volume = value; + p->bgs.lockStream(); + p->bgs.setVolume(AudioStream::External, ((float)(p->sfx_volume * p->current_bgs_volume))/10000.0f ); + p->bgs.unlockStream(); + +} + Audio::~Audio() { delete p; } diff --git a/src/audio.h b/src/audio.h index e231fb6..80e10ec 100644 --- a/src/audio.h +++ b/src/audio.h @@ -22,6 +22,8 @@ #ifndef AUDIO_H #define AUDIO_H +#include "util.h" + /* Concerning the 'pos' parameter: * RGSS3 actually doesn't specify a format for this, * it's only implied that it is a numerical value @@ -68,6 +70,10 @@ public: void reset(); + /* Non-standard extension */ + DECL_ATTR( BGM_Volume, int) + DECL_ATTR( SFX_Volume, int) + private: Audio(RGSSThreadData &rtData); ~Audio(); diff --git a/src/graphics.cpp b/src/graphics.cpp index 0f921ef..7ca53c6 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -1046,6 +1046,16 @@ void Graphics::setSmooth(bool value) p->threadData->config.smoothScaling = value; } +bool Graphics::getFrameskip() const +{ + return p->threadData->config.frameSkip; +} + +void Graphics::setFrameskip(bool value) +{ + p->threadData->config.frameSkip = value; +} + bool Graphics::getShowCursor() const { return p->threadData->ethread->getShowCursor(); diff --git a/src/graphics.h b/src/graphics.h index c52f95d..5202b54 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -63,6 +63,7 @@ public: DECL_ATTR( Fullscreen, bool ) DECL_ATTR( ShowCursor, bool ) DECL_ATTR( Smooth, bool ) + DECL_ATTR( Frameskip, bool ) /* */ Scene *getScreen() const; From 03f4610e20d82063fe27038499583f61d9b660c2 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 1 Jan 2017 04:56:41 -0600 Subject: [PATCH 2/9] Forgot to change volume when starting to play bgm, me, and bgs Committer: gir --- src/audio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 827e61c..02f6664 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -259,7 +259,7 @@ void Audio::bgmPlay(const char *filename, float pos) { p->current_bgm_volume = volume; - p->bgm.play(filename, volume, pitch, pos); + p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos); } void Audio::bgmStop() @@ -279,7 +279,7 @@ void Audio::bgsPlay(const char *filename, float pos) { p->current_bgs_volume = volume; - p->bgs.play(filename, volume, pitch, pos); + p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos); } void Audio::bgsStop() @@ -298,7 +298,7 @@ void Audio::mePlay(const char *filename, int pitch) { p->current_me_volume = volume; - p->me.play(filename, volume, pitch); + p->me.play(filename, (volume*p->bgm_volume)/100, pitch); } void Audio::meStop() From 79e70e8821a3e7c7a1ab1d407e1622d7292a4de0 Mon Sep 17 00:00:00 2001 From: mshirt Date: Fri, 23 Dec 2016 14:07:11 -0600 Subject: [PATCH 3/9] Fixed being able to open both menus at once You could open both inventory and menu at once if you were walking. But now you can't. --- scripts/Scene_Map.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index 5f91e55..4a52775 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -250,7 +250,7 @@ class Scene_Map # Process menu opening unless $game_system.map_interpreter.running? || $game_system.menu_disabled || - @fast_travel.visible + @fast_travel.visible || $game_temp.menu_calling == true || $game_temp.item_menu_calling == true if !@menu.visible && Input.trigger?(Input::MENU) $game_temp.menu_calling = true $game_temp.menu_beep = true From b1b907a6e64e44eba31b2cbe600d5e5a0d673aa9 Mon Sep 17 00:00:00 2001 From: mshirt Date: Sun, 1 Jan 2017 05:04:21 -0600 Subject: [PATCH 4/9] Settings menu script additions Settings menu now fully works, but will need to add more changes in a bit to make it save a settings file (so user won't have to change settings every relaunch) --- scripts/Game_Player.rb | 6 +- scripts/Game_Temp.rb | 2 + scripts/Scene_Map.rb | 21 ++- scripts/Window_MainMenu.rb | 6 +- scripts/Window_Settings.rb | 308 +++++++++++++++++++++++++++++++++++++ scripts/_scripts.txt | 1 + 6 files changed, 338 insertions(+), 6 deletions(-) create mode 100644 scripts/Window_Settings.rb diff --git a/scripts/Game_Player.rb b/scripts/Game_Player.rb index 522859b..8cc98ed 100644 --- a/scripts/Game_Player.rb +++ b/scripts/Game_Player.rb @@ -177,7 +177,11 @@ class Game_Player < Game_Character unless $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing or $game_temp.menus_visible # Adjust move speed - @move_speed = Input.press?(Input::RUN) ? 4 : 3 + if $game_switches[251] == false + @move_speed = Input.press?(Input::RUN) ? 4 : 3 + else + @move_speed = Input.press?(Input::RUN) ? 3 : 4 + end unless moving? # Move player in the direction the directional button is being pressed case Input.dir4 diff --git a/scripts/Game_Temp.rb b/scripts/Game_Temp.rb index b2d2cd6..8bfd83f 100644 --- a/scripts/Game_Temp.rb +++ b/scripts/Game_Temp.rb @@ -45,6 +45,7 @@ class Game_Temp attr_accessor :menu_calling # menu calling flag attr_accessor :item_menu_calling # item menu calling flag attr_accessor :travel_menu_calling # fast travel menu calling flag + attr_accessor :window_settings_calling # fast travel menu calling flag attr_accessor :menu_beep # menu: play sound effect flag attr_accessor :save_calling # save calling flag attr_accessor :debug_calling # debug calling flag @@ -102,6 +103,7 @@ class Game_Temp @menu_calling = false @item_menu_calling = false @travel_menu_calling = false + @window_settings_calling = false @menu_beep = false @save_calling = false @debug_calling = false diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index 4a52775..d0c25af 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -41,6 +41,7 @@ class Scene_Map @item_icon_flash_wait = 100 # Make fast travel menu @fast_travel = FastTravel.new + @window_settings = Window_Settings.new # Fade to black transition @blackfade = Sprite.new @blackfade.bitmap = Bitmap.new(640, 480) @@ -76,6 +77,7 @@ class Scene_Map @menu.dispose @item_menu.dispose @fast_travel.dispose + @window_settings.dispose # Dispose of item icon @item_icon.dispose @item_icon_flash.dispose @@ -118,7 +120,7 @@ class Scene_Map return end $game_system.map_interpreter.update - $game_temp.menus_visible = @menu.visible || @item_menu.visible || @fast_travel.visible + $game_temp.menus_visible = @menu.visible || @item_menu.visible || @fast_travel.visible || @window_settings.visible $game_player.update $game_followers.each{|f| f.update} # Update system (timer), screen @@ -233,6 +235,7 @@ class Scene_Map end # Update fast travel @fast_travel.update + @window_settings.update if Input.trigger?(Input::F8) && !$game_switches[123] if Graphics.fullscreen == true @@ -242,6 +245,10 @@ class Scene_Map Graphics.fullscreen = true $console = true end + if @window_settings.visible + sleep(0.100) + @window_settings.redraw_setting_index(2) + end end # If showing message window if $game_temp.message_window_showing || @ed_message.visible || @doc_message.visible || @desktop_message.visible || @credits_message.visible @@ -250,7 +257,7 @@ class Scene_Map # Process menu opening unless $game_system.map_interpreter.running? || $game_system.menu_disabled || - @fast_travel.visible || $game_temp.menu_calling == true || $game_temp.item_menu_calling == true + @fast_travel.visible || @window_settings.visible || $game_temp.menu_calling == true || $game_temp.item_menu_calling == true if !@menu.visible && Input.trigger?(Input::MENU) $game_temp.menu_calling = true $game_temp.menu_beep = true @@ -288,6 +295,8 @@ class Scene_Map call_item_menu elsif $game_temp.travel_menu_calling call_travel_menu + elsif $game_temp.window_settings_calling + call_window_settings elsif $game_temp.save_calling call_save elsif $game_temp.debug_calling @@ -379,6 +388,14 @@ class Scene_Map # Open the menu @fast_travel.open end + def call_window_settings + # Clear menu call flag + $game_temp.window_settings_calling = false + # Straighten player position + $game_player.straighten + # Open the menu + @window_settings.open + end #-------------------------------------------------------------------------- # * Save Call #-------------------------------------------------------------------------- diff --git a/scripts/Window_MainMenu.rb b/scripts/Window_MainMenu.rb index 28f8adc..905183f 100644 --- a/scripts/Window_MainMenu.rb +++ b/scripts/Window_MainMenu.rb @@ -134,9 +134,9 @@ class Window_MainMenu < Window_Selectable $game_temp.common_event_id = 15 @fade_out = true else - $game_system.se_play($data_system.buzzer_se) - self.active = true - self.opacity = 255 + $game_system.se_play($data_system.decision_se) + $game_temp.window_settings_calling = true + @fade_out = true end return end diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb new file mode 100644 index 0000000..8e1b6cf --- /dev/null +++ b/scripts/Window_Settings.rb @@ -0,0 +1,308 @@ +class Window_Settings + MARGIN = 30 + TITLE_TOP_MARGIN = 32 + TITLE_MARGIN = 100 + ITEM_SPACING = 28 + ACTIVE_MARGIN = MARGIN * 2 + 20 + + def initialize + @viewport = Viewport.new(0, 0, 640, 480) + @bg = Sprite.new(@viewport) + @bg.bitmap = Bitmap.new(640, 480) + @bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 128)) + @title = Sprite.new(@viewport) + @title.bitmap = Bitmap.new(320, TITLE_MARGIN) + @title.bitmap.font.size = 40 + @title.y = TITLE_TOP_MARGIN + @title.x = MARGIN + @data_sprites = [] + @viewport.z = 9998 + + @left_hold_timer = 0 + @right_hold_timer = 0 + + self.visible = false + @index = 0 + @fade_in = false + @fade_out = false + + @transfer_player = nil + end + + def dispose + @bg.dispose + @title.dispose + @data_sprites.each do |spr| + spr.dispose + end + @viewport.dispose + end + + def open + self.visible = true + self.opacity = 0 + @fade_in = true + @data = [ + tr('BGM Volume'), + tr('SFX Volume'), + tr('Fullscreen'), + tr('Default movement'), + tr('Colorblind mode'), + tr('Frameskip'), + tr('Configure Controls (Press F1)'), + ] + + @index = 0 + + # Create title + @title.bitmap.clear + @title.bitmap.draw_text(0, 0, @title.bitmap.width, @title.bitmap.height, tr("Settings")) + + # Create menu options + @data.each_with_index do |item, i| + spr = Sprite.new(@viewport) + spr.bitmap = Bitmap.new(320, ITEM_SPACING) + spr.x = MARGIN + spr.y = TITLE_MARGIN + TITLE_TOP_MARGIN + ITEM_SPACING * i + spr.opacity = 0 + redraw_setting(spr, i) + + @data_sprites << spr + end + end + + def redraw_setting(spr, i) + spr.bitmap.clear + spr.bitmap.draw_text(0, 0, spr.bitmap.width, spr.bitmap.height, @data[i]) + spr.bitmap.draw_text(0, 0, spr.bitmap.width, spr.bitmap.height, @data[i]) + case i + when 0 + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, Audio.bgm_volume.to_s) + when 1 + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, Audio.sfx_volume.to_s) + when 2 #fullscreen + if(Graphics.fullscreen == true) + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("ON")) + else + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF")) + end + when 3 #default movement + if($game_switches[251] == true) + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("RUN")) + else + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("WALK")) + end + when 4 #colorblind mode + if($game_switches[252] == true) + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("ON")) + else + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF")) + end + when 5 #frameskip + if(Graphics.frameskip == true) + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("ON")) + else + spr.bitmap.draw_text(260, 0, spr.bitmap.width, spr.bitmap.height, tr("OFF")) + end + end + end + + def redraw_setting_index(i) + redraw_setting(@data_sprites[i], i) + end + + def update + if @fade_in + self.opacity += 20 + active_spr = nil + @data_sprites.each do |spr| + spr.opacity += 10 + spr.opacity = 128 if spr.opacity > 128 + active_spr = spr if !active_spr && spr.x < MARGIN * 2 + end + if active_spr + active_spr.x += 6 + active_spr.x = MARGIN * 2 if active_spr.x > MARGIN * 2 + elsif self.opacity == 255 + @fade_in = false + end + return + end + + if @fade_out + self.opacity -= 20 + @data_sprites.each do |spr| + spr.opacity -= 10 + end + if self.opacity == 0 + @fade_out = false + self.visible = false + @data_sprites.each do |spr| + spr.dispose + end + @data_sprites = [] + + if @transfer_player + $game_temp.player_transferring = true + $game_temp.player_new_map_id = @transfer_player.id + $game_temp.player_new_x = @transfer_player.x + $game_temp.player_new_y = @transfer_player.y + $game_temp.player_new_direction = @transfer_player.dir + Graphics.freeze + $game_temp.transition_processing = true + $game_temp.transition_name = "black" + @transfer_player = nil + end + end + return + end + + return if !self.visible + + # Adjust position and visibility + @data_sprites.each_with_index do |spr, i| + if i == @index + if spr.x < ACTIVE_MARGIN + spr.x += 6 + spr.x = ACTIVE_MARGIN if spr.x > ACTIVE_MARGIN + end + spr.opacity += 10 if spr.opacity < 255 + else + if spr.x > MARGIN * 2 + spr.x -= 6 + spr.x = MARGIN * 2 if spr.x < MARGIN * 2 + end + spr.opacity -= 10 if spr.opacity > 128 + spr.opacity = 128 if spr.opacity < 128 + end + end + + if Input.trigger?(Input::UP) + @index = (@index - 1) % @data.size + $game_system.se_play($data_system.cursor_se) + end + if Input.trigger?(Input::DOWN) + @index = (@index + 1) % @data.size + $game_system.se_play($data_system.cursor_se) + end + + if Input.press?(Input::LEFT) + @left_hold_timer += 1 + else + @left_hold_timer = 0 + end + + if Input.press?(Input::RIGHT) + @right_hold_timer += 1 + else + @right_hold_timer = 0 + end + + case @index + when 0 #bgm vol + old_vol = Audio.bgm_volume + if Input.trigger?(Input::LEFT) || (Input.press?(Input::LEFT) && (@left_hold_timer >= 15)) + @left_hold_timer -= 2 + Audio.bgm_volume -= 1 + if old_vol > 1 + Audio.se_play("Audio/SE/text_robot.wav", 70, (Audio.bgm_volume/2) + 75) + end + elsif Input.trigger?(Input::RIGHT) || (Input.press?(Input::RIGHT) && (@right_hold_timer >= 15)) + @right_hold_timer -= 2 + Audio.bgm_volume += 1 + if old_vol < 100 + Audio.se_play("Audio/SE/text_robot.wav", 70, (Audio.bgm_volume/2) + 75) + end + end + redraw_setting_index(0) + + when 1 #sfx vol + old_vol = Audio.sfx_volume + if Input.trigger?(Input::LEFT) || (Input.press?(Input::LEFT) && (@left_hold_timer >= 15)) + @left_hold_timer -= 2 + Audio.sfx_volume -= 1 + if old_vol > 1 + Audio.se_play("Audio/SE/text_robot.wav", 70, (Audio.sfx_volume/2) + 75) + end + elsif Input.trigger?(Input::RIGHT) || (Input.press?(Input::RIGHT) && (@right_hold_timer >= 15)) + @right_hold_timer -= 2 + Audio.sfx_volume += 1 + if old_vol < 100 + Audio.se_play("Audio/SE/text_robot.wav", 70, (Audio.sfx_volume/2) + 75) + end + end + redraw_setting_index(1) + + when 2 #fullscreen + if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) + + $game_system.se_play($data_system.decision_se) + if Graphics.fullscreen == true + Graphics.fullscreen = false + $console = false + else + Graphics.fullscreen = true + $console = true + end + sleep(0.100) + redraw_setting_index(2) + end + + when 3 #default movement + if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) + + $game_system.se_play($data_system.decision_se) + if $game_switches[251] == true + $game_switches[251] = false + else + $game_switches[251] = true + end + redraw_setting_index(3) + end + + when 4 #colorblind mode + if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) + + $game_system.se_play($data_system.decision_se) + if $game_switches[252] == true + $game_switches[252] = false + else + $game_switches[252] = true + end + redraw_setting_index(4) + end + + when 5 #frameskip + if Input.trigger?(Input::ACTION) || Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT) + + $game_system.se_play($data_system.decision_se) + if Graphics.frameskip == true + Graphics.frameskip = false + else + Graphics.frameskip = true + end + redraw_setting_index(5) + end + end + + if Input.trigger?(Input::CANCEL) + $game_system.se_play($data_system.cancel_se) + @fade_out = true + end + end + + # Attributes + def visible + @viewport.visible + end + def visible=(val) + @viewport.visible = val + end + def opacity=(val) + @bg.opacity = val + @title.opacity = val + end + def opacity + @bg.opacity + end +end diff --git a/scripts/_scripts.txt b/scripts/_scripts.txt index 55df880..e4e58ea 100644 --- a/scripts/_scripts.txt +++ b/scripts/_scripts.txt @@ -56,6 +56,7 @@ Window_EquipRight Window_EquipItem Window_Status Window_SaveFile +Window_Settings Window_ShopCommand Window_ShopBuy Window_ShopSell From 102e0aea6cf63ecf39402cf8d1c90bab5abd4f44 Mon Sep 17 00:00:00 2001 From: mshirt Date: Sun, 1 Jan 2017 16:16:43 -0600 Subject: [PATCH 5/9] Game now saves settings to file So the user doesn't have to customize their settings everytime they launch. --- scripts/Scene_Title.rb | 1 + scripts/Window_Settings.rb | 61 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/scripts/Scene_Title.rb b/scripts/Scene_Title.rb index 2182d78..b1e7683 100644 --- a/scripts/Scene_Title.rb +++ b/scripts/Scene_Title.rb @@ -40,6 +40,7 @@ class Scene_Title $scene = Scene_Map.new return end + Window_Settings.load_settings # Make title graphic @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index 8e1b6cf..3387010 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -4,6 +4,66 @@ class Window_Settings TITLE_MARGIN = 100 ITEM_SPACING = 28 ACTIVE_MARGIN = MARGIN * 2 + 20 + SETTINGS_FILE_NAME = Oneshot::SAVE_PATH + '/settings.conf' + + def save_settings + File.open(SETTINGS_FILE_NAME, 'w') do |file| + file.puts('bgm_volume=' + Audio.bgm_volume.to_s) + file.puts('sfx_volume=' + Audio.sfx_volume.to_s) + file.puts('fullscreen=' + Graphics.fullscreen.to_s) + file.puts('default_run=' + $game_switches[251].to_s) + file.puts('colorblind_mode=' + $game_switches[252].to_s) + file.puts('frameskip=' + Graphics.frameskip.to_s) + end + end + + def self.load_settings + return false if !FileTest.exist?(SETTINGS_FILE_NAME) + File.foreach(SETTINGS_FILE_NAME).with_index do |line, line_num| + if !line.include? "=" + next + end + vals = line.strip.split("=") + case vals[0] + when "bgm_volume" + if !!(vals[1] =~ /\A[-+]?[0-9]+\z/) #is a number + number = vals[1].to_i + Audio.bgm_volume = number + end + when "sfx_volume" + if !!(vals[1] =~ /\A[-+]?[0-9]+\z/) #is a number + number = vals[1].to_i + Audio.sfx_volume = number + end + when "fullscreen" + if vals[1] == "true" + Graphics.fullscreen = true + $console = true + elsif vals[1] == "false" + Graphics.fullscreen = false + $console = false + end + when "default_run" + if vals[1] == "true" + $game_switches[251] = true + elsif vals[1] == "false" + $game_switches[251] = false + end + when "colorblind_mode" + if vals[1] == "true" + $game_switches[252] = true + elsif vals[1] == "false" + $game_switches[252] = false + end + when "frameskip" + if vals[1] == "true" + Graphics.frameskip = true + elsif vals[1] == "false" + Graphics.frameskip = false + end + end + end + end def initialize @viewport = Viewport.new(0, 0, 640, 480) @@ -288,6 +348,7 @@ class Window_Settings if Input.trigger?(Input::CANCEL) $game_system.se_play($data_system.cancel_se) @fade_out = true + save_settings end end From 505f4214c19caa371f2b6e8dcd100c550ac5263f Mon Sep 17 00:00:00 2001 From: mshirt Date: Sun, 1 Jan 2017 18:25:11 -0600 Subject: [PATCH 6/9] Fixing EACCES error That occurs when trying to copy the ______.exe when you already have it running in the destination folder. --- scripts/Script.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/Script.rb b/scripts/Script.rb index 47b02f0..b401a3c 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -279,13 +279,17 @@ module Script def self.copy_journal Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games") Dir.mkdir(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") unless File.exists?(Oneshot::DOCS_PATH + "\\My Games\\Oneshot") - File.open("_______.exe", "rb") do |input| - File.open(Oneshot::DOCS_PATH + "\\My Games\\Oneshot\\_______.exe","wb") do |output| - while buff = input.read(4096) - output.write(buff) + begin + File.open("_______.exe", "rb") do |input| + File.open(Oneshot::DOCS_PATH + "\\My Games\\Oneshot\\_______.exe","wb") do |output| + while buff = input.read(4096) + output.write(buff) + end end end - end + rescue Errno::EACCES => e + #this probably means the clover.exe already exists and is running, so no need to create it again + end if File.exists?("README.txt") File.open("README.txt", "rb") do |input| File.open(Oneshot::DOCS_PATH + "\\My Games\\Oneshot\\README.txt","wb") do |output| From 546edc33b8c524d3133498fac8db9f407df42373 Mon Sep 17 00:00:00 2001 From: mshirt Date: Mon, 2 Jan 2017 17:33:33 -0600 Subject: [PATCH 7/9] Preventing saving if intro variable isn't set This is to prevent the "[Niko feels uneasy.]" infinite loop that can occur if you somehow save in the INIT room. --- scripts/SaveLoad.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/SaveLoad.rb b/scripts/SaveLoad.rb index a761c3f..0f6f27e 100644 --- a/scripts/SaveLoad.rb +++ b/scripts/SaveLoad.rb @@ -37,6 +37,9 @@ def fake_save end def save + if ($game_variables[3] == 0) #don't save if intro variable isn't set + return + end File.open(SAVE_FILE_NAME, 'wb') do |file| # Wrire frame count for measuring play time Marshal.dump(Graphics.frame_count, file) From 4a459cb33066191013c85ea4730286de72107fdb Mon Sep 17 00:00:00 2001 From: mshirt Date: Tue, 3 Jan 2017 02:23:03 -0600 Subject: [PATCH 8/9] Fixing text being corrupted when fullscreening Mainly by increasing delay when fullscreening. --- scripts/Scene_Map.rb | 3 ++- scripts/Window_Settings.rb | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/Scene_Map.rb b/scripts/Scene_Map.rb index d0c25af..4198a11 100644 --- a/scripts/Scene_Map.rb +++ b/scripts/Scene_Map.rb @@ -245,9 +245,10 @@ class Scene_Map Graphics.fullscreen = true $console = true end + sleep(0.500) if @window_settings.visible - sleep(0.100) @window_settings.redraw_setting_index(2) + sleep(0.500) end end # If showing message window diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index 3387010..db8ff30 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -87,6 +87,7 @@ class Window_Settings @fade_out = false @transfer_player = nil + @visible = false end def dispose @@ -132,6 +133,9 @@ class Window_Settings end def redraw_setting(spr, i) + if @visible == false + return + end spr.bitmap.clear spr.bitmap.draw_text(0, 0, spr.bitmap.width, spr.bitmap.height, @data[i]) spr.bitmap.draw_text(0, 0, spr.bitmap.width, spr.bitmap.height, @data[i]) @@ -168,6 +172,12 @@ class Window_Settings end def redraw_setting_index(i) + if !@data_sprites.kind_of?(Array) + return + end + if @data_sprites.length - 1 < i + return + end redraw_setting(@data_sprites[i], i) end @@ -304,8 +314,9 @@ class Window_Settings Graphics.fullscreen = true $console = true end - sleep(0.100) + sleep(0.500) redraw_setting_index(2) + sleep(0.500) end when 3 #default movement @@ -354,10 +365,11 @@ class Window_Settings # Attributes def visible - @viewport.visible + return @visible end def visible=(val) @viewport.visible = val + @visible = val end def opacity=(val) @bg.opacity = val From 9fb6ca4d89b12f9ea9cd03fbd8f57ef4a293f900 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Jan 2017 19:57:29 -0600 Subject: [PATCH 9/9] Committer: gir Changes to be committed: modified: src/audio.cpp --- src/audio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 02f6664..84abe29 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -356,10 +356,10 @@ void Audio::setBGM_Volume(int value) } p->bgm_volume = value; p->bgm.lockStream(); - p->bgm.setVolume(AudioStream::External, ((float)(p->bgm_volume * p->current_bgm_volume))/10000.0f ); + p->bgm.setVolume(AudioStream::Base, ((float)(p->bgm_volume * p->current_bgm_volume))/10000.0f ); p->bgm.unlockStream(); p->me.lockStream(); - p->me.setVolume(AudioStream::External, ((float)(p->bgm_volume * p->current_me_volume))/10000.0f ); + p->me.setVolume(AudioStream::Base, ((float)(p->bgm_volume * p->current_me_volume))/10000.0f ); p->me.unlockStream(); } @@ -377,7 +377,7 @@ void Audio::setSFX_Volume(int value) } p->sfx_volume = value; p->bgs.lockStream(); - p->bgs.setVolume(AudioStream::External, ((float)(p->sfx_volume * p->current_bgs_volume))/10000.0f ); + p->bgs.setVolume(AudioStream::Base, ((float)(p->sfx_volume * p->current_bgs_volume))/10000.0f ); p->bgs.unlockStream(); }