mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-21 06:19:56 +00:00
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)
This commit is contained in:
parent
79e70e8821
commit
b1b907a6e6
6 changed files with 338 additions and 6 deletions
|
|
@ -177,7 +177,11 @@ class Game_Player < Game_Character
|
||||||
unless $game_system.map_interpreter.running? or @move_route_forcing or
|
unless $game_system.map_interpreter.running? or @move_route_forcing or
|
||||||
$game_temp.message_window_showing or $game_temp.menus_visible
|
$game_temp.message_window_showing or $game_temp.menus_visible
|
||||||
# Adjust move speed
|
# 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?
|
unless moving?
|
||||||
# Move player in the direction the directional button is being pressed
|
# Move player in the direction the directional button is being pressed
|
||||||
case Input.dir4
|
case Input.dir4
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ class Game_Temp
|
||||||
attr_accessor :menu_calling # menu calling flag
|
attr_accessor :menu_calling # menu calling flag
|
||||||
attr_accessor :item_menu_calling # item menu calling flag
|
attr_accessor :item_menu_calling # item menu calling flag
|
||||||
attr_accessor :travel_menu_calling # fast travel 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 :menu_beep # menu: play sound effect flag
|
||||||
attr_accessor :save_calling # save calling flag
|
attr_accessor :save_calling # save calling flag
|
||||||
attr_accessor :debug_calling # debug calling flag
|
attr_accessor :debug_calling # debug calling flag
|
||||||
|
|
@ -102,6 +103,7 @@ class Game_Temp
|
||||||
@menu_calling = false
|
@menu_calling = false
|
||||||
@item_menu_calling = false
|
@item_menu_calling = false
|
||||||
@travel_menu_calling = false
|
@travel_menu_calling = false
|
||||||
|
@window_settings_calling = false
|
||||||
@menu_beep = false
|
@menu_beep = false
|
||||||
@save_calling = false
|
@save_calling = false
|
||||||
@debug_calling = false
|
@debug_calling = false
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ class Scene_Map
|
||||||
@item_icon_flash_wait = 100
|
@item_icon_flash_wait = 100
|
||||||
# Make fast travel menu
|
# Make fast travel menu
|
||||||
@fast_travel = FastTravel.new
|
@fast_travel = FastTravel.new
|
||||||
|
@window_settings = Window_Settings.new
|
||||||
# Fade to black transition
|
# Fade to black transition
|
||||||
@blackfade = Sprite.new
|
@blackfade = Sprite.new
|
||||||
@blackfade.bitmap = Bitmap.new(640, 480)
|
@blackfade.bitmap = Bitmap.new(640, 480)
|
||||||
|
|
@ -76,6 +77,7 @@ class Scene_Map
|
||||||
@menu.dispose
|
@menu.dispose
|
||||||
@item_menu.dispose
|
@item_menu.dispose
|
||||||
@fast_travel.dispose
|
@fast_travel.dispose
|
||||||
|
@window_settings.dispose
|
||||||
# Dispose of item icon
|
# Dispose of item icon
|
||||||
@item_icon.dispose
|
@item_icon.dispose
|
||||||
@item_icon_flash.dispose
|
@item_icon_flash.dispose
|
||||||
|
|
@ -118,7 +120,7 @@ class Scene_Map
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
$game_system.map_interpreter.update
|
$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_player.update
|
||||||
$game_followers.each{|f| f.update}
|
$game_followers.each{|f| f.update}
|
||||||
# Update system (timer), screen
|
# Update system (timer), screen
|
||||||
|
|
@ -233,6 +235,7 @@ class Scene_Map
|
||||||
end
|
end
|
||||||
# Update fast travel
|
# Update fast travel
|
||||||
@fast_travel.update
|
@fast_travel.update
|
||||||
|
@window_settings.update
|
||||||
|
|
||||||
if Input.trigger?(Input::F8) && !$game_switches[123]
|
if Input.trigger?(Input::F8) && !$game_switches[123]
|
||||||
if Graphics.fullscreen == true
|
if Graphics.fullscreen == true
|
||||||
|
|
@ -242,6 +245,10 @@ class Scene_Map
|
||||||
Graphics.fullscreen = true
|
Graphics.fullscreen = true
|
||||||
$console = true
|
$console = true
|
||||||
end
|
end
|
||||||
|
if @window_settings.visible
|
||||||
|
sleep(0.100)
|
||||||
|
@window_settings.redraw_setting_index(2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
# If showing message window
|
# If showing message window
|
||||||
if $game_temp.message_window_showing || @ed_message.visible || @doc_message.visible || @desktop_message.visible || @credits_message.visible
|
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
|
# Process menu opening
|
||||||
unless $game_system.map_interpreter.running? ||
|
unless $game_system.map_interpreter.running? ||
|
||||||
$game_system.menu_disabled ||
|
$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)
|
if !@menu.visible && Input.trigger?(Input::MENU)
|
||||||
$game_temp.menu_calling = true
|
$game_temp.menu_calling = true
|
||||||
$game_temp.menu_beep = true
|
$game_temp.menu_beep = true
|
||||||
|
|
@ -288,6 +295,8 @@ class Scene_Map
|
||||||
call_item_menu
|
call_item_menu
|
||||||
elsif $game_temp.travel_menu_calling
|
elsif $game_temp.travel_menu_calling
|
||||||
call_travel_menu
|
call_travel_menu
|
||||||
|
elsif $game_temp.window_settings_calling
|
||||||
|
call_window_settings
|
||||||
elsif $game_temp.save_calling
|
elsif $game_temp.save_calling
|
||||||
call_save
|
call_save
|
||||||
elsif $game_temp.debug_calling
|
elsif $game_temp.debug_calling
|
||||||
|
|
@ -379,6 +388,14 @@ class Scene_Map
|
||||||
# Open the menu
|
# Open the menu
|
||||||
@fast_travel.open
|
@fast_travel.open
|
||||||
end
|
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
|
# * Save Call
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -134,9 +134,9 @@ class Window_MainMenu < Window_Selectable
|
||||||
$game_temp.common_event_id = 15
|
$game_temp.common_event_id = 15
|
||||||
@fade_out = true
|
@fade_out = true
|
||||||
else
|
else
|
||||||
$game_system.se_play($data_system.buzzer_se)
|
$game_system.se_play($data_system.decision_se)
|
||||||
self.active = true
|
$game_temp.window_settings_calling = true
|
||||||
self.opacity = 255
|
@fade_out = true
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
||||||
308
scripts/Window_Settings.rb
Normal file
308
scripts/Window_Settings.rb
Normal file
|
|
@ -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
|
||||||
|
|
@ -56,6 +56,7 @@ Window_EquipRight
|
||||||
Window_EquipItem
|
Window_EquipItem
|
||||||
Window_Status
|
Window_Status
|
||||||
Window_SaveFile
|
Window_SaveFile
|
||||||
|
Window_Settings
|
||||||
Window_ShopCommand
|
Window_ShopCommand
|
||||||
Window_ShopBuy
|
Window_ShopBuy
|
||||||
Window_ShopSell
|
Window_ShopSell
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue