The options system - Sheol - 09-26-2005
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
Simple steps to add a nice options system to your Menu.
Add this in the main method:
Code: @opt = Window_Command.new(160,["Skin","BGM volumen","SE volumen"])
@skin = Window_Command.new(100,["Black","Blue","Red"])
@bgm = Slipknot_Slider.new("BGM")
@bgm.index = $game_system.bgm_volume
@se = Slipknot_Slider.new("SE")
@se.index = $game_system.se_volume
yo = 240 - @opt.height/2
xo = 16
xox = xo + @opt.width
visact(@opt,false); @opt.x = xo; @opt.y = yo
visact(@skin,false); @skin.x = xox; @skin.y = yo
visact(@bgm,false); @bgm.x = xox; @bgm.y = yo
visact(@se,false); @se.x = xox; @se.y = yo
@optwins = [@opt,@skin,@bgm,@se]
Below this:
Code: @command_window.x = 320 - @command.width/2
@command_window.y = 480 - @command.height
Paste this:
Code: for i in @optwins
i.z = @command_window.z + 100 # or the name of your command window
end
This below Graphics.Freeze:
[Code] for i in @optwins
i.dispose
end
This in the update method:
Code: for i in @optwins
i.update
end
In the end of the update method:
Code: if @opt.active; update_opt; return; end
if @sbs; update_sbs; return; end
This below (not inside) the update method:
Code: #-----------------------------------------------------------------
def update_opt
if Input.trigger?(Input::B)
visact(@opt,false)
@command_window.active = true # or the name of your command window
end
if Input.trigger?(Input::C)
case @opt.index
when 0; optacc(@skin)
when 1; optacc(@bgm)
when 2; optacc(@se)
end; return
end
end
#-----------------------------------------------------------------
def optacc(w)
@opt.active = false; @sbs = true; visact(w,true)
end
#-----------------------------------------------------------------
def update_sbs
if Input.trigger?(Input::B)
case @opt.index
when 0; optcan(@skin)
when 1; optcan(@bgm)
when 2; optcan(@se)
end
end
case @opt.index
when 1; volacc(1,@bgm.index); return
when 2; volacc(2,@se.index); return
end
if Input.trigger?(Input::C) and @skin.active
case @skin.index
when 0; skinacc("SlipBlack")
when 1; skinacc("SlipBlue")
when 2; skinacc("SlipRed")
end
return
end
end
#-----------------------------------------------------------------
def volacc(pla,vol)
case pla; when 1
$game_system.bgm_volume = vol
when 2
$game_system.se_volume = vol
end
end
#-----------------------------------------------------------------
def skinacc(sk1)
$game_system.se_play($data_system.decision_se)
$game_system.windowskin_name = sk1
end
#-----------------------------------------------------------------
def optcan(w)
visact(w,false); @opt.active = true; @sbs = false
end
#-----------------------------------------------------------------
def visact(w,tf)
w.visible = tf; w.active = tf
end
Then add this in the bottom of your menu or in a new page:
Code: #-----------------------------------------------------------------
class Slipknot_Slider < Window_Base
#-----------------------------------------------------------------
def initialize(text = "")
super(0,0,160,290)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $defaultfonttype
self.contents.font.size = $defaultfontsize
self.active = false; @text = text
if @index == nil; @index = 0; end
@item_max = 100; self.visible = false
@scale = 2; refresh
end
#-----------------------------------------------------------------
def index=(index)
@index = index; refresh
end
#-----------------------------------------------------------------
def index
return @index
end
#-----------------------------------------------------------------
def refresh
self.contents.clear
self.contents.draw_text(0,0,128,24,@text+" volume",1)
self.contents.draw_text(30,32,80,24,"0%")
self.contents.draw_text(30,82,80,24,"25%")
self.contents.draw_text(30,132,80,24,"50%")
self.contents.draw_text(30,182,80,24,"75%")
self.contents.draw_text(30,232,80,24,"100%")
curhei = 18; mish = @item_max * @scale + curhei
self.contents.fill_rect(0,32,20,mish+8,Color.new(200,200,200,140))
self.contents.fill_rect(2,34,16,mish+4,Color.new(128,128,128,190))
self.contents.fill_rect(4,36,12,mish,Color.new(64,64,64,190))
y = (@index*(@item_max*@scale))/@item_max + 36
self.contents.fill_rect(3,y,14,curhei, Color.new(100,100,100,215))
self.contents.fill_rect(6,y+4,8,curhei - 8, Color.new(90,90,90,215))
end
#-----------------------------------------------------------------
alias slipknot_slider_update update
def update
slipknot_slider_update
if self.active and @item_max > 0
if Input.repeat?(Input::UP)
if @index != 0
case @text
when "BGM"
@index -= 5
$game_system.bgm_play($game_system.bgm_memorize)
when "SE"
$game_system.se_play($data_system.decision_se)
@index -= 5
end; return
end
$game_system.se_play($data_system.buzzer_se)
end
if Input.repeat?(Input::DOWN)
if @index < @item_max
case @text
when "BGM"
@index += 5
$game_system.bgm_play($game_system.bgm_memorize)
when "SE"
$game_system.se_play($data_system.decision_se)
@index += 5
end; return
end
$game_system.se_play($data_system.buzzer_se)
end
refresh; return
end
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Game_System
#-----------------------------------------------------------------
attr_accessor :bgm_volume
attr_accessor :se_volume
#-----------------------------------------------------------------
alias slipknot_options_initiliaze initialize
def initialize
slipknot_options_initiliaze
@bgm_volume = 100
@se_volume = 100
end
#-----------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/"+bgm.name,bgm.volume * bgm_volume/100,bgm.pitch)
else; Audio.bgm_stop
end; Graphics.frame_reset
end
#-----------------------------------------------------------------
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil and bgs.name != ""
Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume * se_volume / 100, bgs.pitch)
else; Audio.bgs_stop
end; Graphics.frame_reset
end
#-----------------------------------------------------------------
def me_play(me)
if me != nil and me.name != ""
Audio.me_play("Audio/ME/"+me.name, me.volume*se_volume / 100, me.pitch)
else; Audio.me_stop
end; Graphics.frame_reset
end
#-----------------------------------------------------------------
def se_play(se)
if se != nil and se.name != ""
Audio.se_play("Audio/SE/"+se.name,se.volume*se_volume/100,se.pitch)
end
end
#-----------------------------------------------------------------
end
To activate it, use that:
Code: @opt.index = 0; visact(@opt,true)
|