class Game_Locker
attr_accessor :lockercombo
def initialize
@lockercombo = Hash.new("45-64-75")
#@lockercombo = []
#for i in 0..5000
# @lockercombo[i] = "45-64-75" #default combination
#end
@lockercombo[0] = "45-64-75" #first combination
@lockercombo[1] = "456475" #other usable combination
@lockercombo[2] = "45 64 75" #other usable combination
end
end
class Scene_Locker
attr_accessor :lockerinput
attr_accessor :lc
attr_accessor :sename
attr_accessor :se
attr_accessor :template
def initialize
@sename = "032-Switch01" #"032-Switch01" used to make locker sound
@se = false #Put false if you do not like the sound.
@changecombination = true #Allows character to change combination
@template = true #Changes Template of Scene.
end
def main
@spriteset = Spriteset_Map.new
@lockerinput = Window_LockerInput.new(0,8)
@lockerinto = Window_LockerInstructions.new
@lockerinput.opacity = 175
@lockerinto.opacity = 175
s1 = "Change Combination"
s2 = "Enter Combination"
@lc2 = Window_Command.new(350,[s1,s2])#(155,130,350,200)
@lc2.x = 320 - @lc2.width / 2
@lc2.y = 130
@lc2.height = 200
@lc2.opacity = 175
@lc2.active = false
@lc2.visible = false
@lc = Window_LockerChange.new(0,8)
@lc.active = false
@lc.visible = false
@lc.opacity = 175
#if @changecombination == true
#end
if @changecombination == true
secondupdate
end
if @template == true
@lc.draw_locker_graphic
@lockerinput.draw_locker_graphic
end
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
@spriteset.dispose
@lockerinto.dispose
@lc2.dispose
@lockerinput.dispose
@lc.dispose
end
def secondupdate
@lc2.visible = true
@lc2.active = true
@lockerinput.active = false
@lockerinput.visible = false
end
def update
@spriteset.update
@lc.update
@lockerinput.update
@lockerinto.update
@lc2.update
if @lockerinput.active
@lockerinto.set_text("Insert your locker combination and then click the screen")
update2
elsif @lc2.active
@lockerinto.set_text("Change combination or enter combination")
update3
elsif @lc.active
@lockerinto.set_text("Change your locker combination and then click the screen")
update4
end
end
#--------------------------------------------------------------------------
def change_name
#if @lockerinput.index == $game_temp.name_max_char
# $game_system.se_play($data_system.buzzer_se)
# return
#end
$game_system.se_play($data_system.decision_se)
if @lockerinput.index < 6
$scene = Scene_Map.new
end
if @lockerinput.name == $game_locker.lockercombo[0]
$scene = Scene_Inventory_Items.new
end
if @lockerinput.name == $game_locker.lockercombo[1]
$scene = Scene_Inventory_Items.new
end
#if @lockerinput.name == $game_locker.lockercombo[2]
# $scene = Scene_Inventory_Items.new
#end
end
#--------------------------------------------------------------------------
def input_processing
if @lockerinput.index == $game_temp.name_max_char
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
end
end
#--------------------------------------------------------------------------
def update3
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
case @lc2.index
when 0
# Play decision SE
$game_system.se_play($data_system.decision_se)
@lc.active = true
@lc.visible = true
@lc2.active = false
@lc2.visible = false
when 1
# Play decision SE
$game_system.se_play($data_system.decision_se)
@lockerinput.active = true
@lockerinput.visible = true
@lc2.active = false
@lc2.visible = false
end
return
end
end
def update2
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
@lockerinput.active = false
@lockerinput.visible = false
@lc2.active = true
@lc2.visible = true
return
end
if Input.triggered?(32) # [SPACE]
input_processing
@lockerinput.add(" ")
end
if Input.triggered?(1)
change_name
end
@lockerinput.update
if Input.triggered?(27) # [ESCAPE]
$game_system.se_play($data_system.decision_se)
@lockerinput.restore_default
return
end
if Input.triggered?(8) # [BACKSPACE]
if @lockerinput.index == 0
return
end
$game_system.se_play($data_system.cancel_se)
@lockerinput.back
return
end
if Input.triggered?(13) # [ENTER]
if @lockerinput.name == ""
@lockerinput.restore_default
return
end
end
if Input.triggered?(189) # [SPACE]
input_processing
@lockerinput.add("-")
end
#for letter in 'A'..'Z'
# if Input.triggered?(letter[0])
# if Input.pressed?(16)
# input_processing
# @lockerinput.add(letter.upcase)
# else
# input_processing
# @lockerinput.add(letter.downcase)
# end
# end
#end
for letter in '0'..'9'
if Input.triggered?(letter[0])
input_processing
@lockerinput.add(letter)
end
end
end
def input_processing2
if @lc.index == $game_temp.name_max_char
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
end
end
def update4
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
@lc.active = false
@lc.visible = false
@lc2.active = true
@lc2.visible = true
return
end
if Input.triggered?(32) # [SPACE]
input_processing2
@lc.add(" ")
end
if Input.triggered?(1)
change_name2
end
@lc.update
if Input.triggered?(27) # [ESCAPE]
$game_system.se_play($data_system.decision_se)
@lc.restore_default
return
end
if Input.triggered?(8) # [BACKSPACE]
if @lc.index == 0
return
end
$game_system.se_play($data_system.cancel_se)
@lc.back
return
end
if Input.triggered?(13) # [ENTER]
if @lc.name == ""
@lc.restore_default
return
end
end
if Input.triggered?(189) # [SPACE]
input_processing2
@lc.add("-")
end
#for letter in 'A'..'Z'
# if Input.triggered?(letter[0])
# if Input.pressed?(16)
# input_processing
# @lockerinput.add(letter.upcase)
# else
# input_processing
# @lockerinput.add(letter.downcase)
# end
# end
#end
for letter in '0'..'9'
if Input.triggered?(letter[0])
input_processing2
@lc.add(letter)
end
end
end
def change_name2
#if @lockerinput.index == $game_temp.name_max_char
# $game_system.se_play($data_system.buzzer_se)
# return
#end
$game_system.se_play($data_system.decision_se)
for i in 0..1
$game_locker.lockercombo[i] = @lc.name #default combination
end
@lc.active = false
@lc.visible = false
@lc2.active = true
@lc2.visible = true
end
end
class Window_LockerChange < Window_Base
attr_reader :name
attr_reader :index
attr_accessor :max_char
#--------------------------------------------------------------------------
def initialize(actor, max_char)
super(155,130,350,200)
self.contents = Bitmap.new(width - 32, height - 32)
self.x = 320 - self.width / 2
#@actor = $game_party.actors[actor]
@name = ""#@actor.name
@max_char = max_char
name_array = @name.split(//)[0...@max_char]
@name = ""
for i in 0...name_array.size
@name += name_array[i]
end
@default_name = @name
@index = name_array.size
@sprite_size = 0 # 0 for small sprites, 1 for bigger sprites
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
def restore_default
@name = @default_name
@index = @name.split(//).size
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
def add(character)
if @index < @max_char and character != ""
@name += character
@index += 1
refresh
update_cursor_rect
end
end
#--------------------------------------------------------------------------
def back
if @index > 0
name_array = @name.split(//)
@name = ""
for i in 0...name_array.size-1
@name += name_array[i]
end
@index -= 1
refresh
update_cursor_rect
end
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
name_array = @name.split(//)
for i in 0...@max_char
c = name_array[i]
if c == nil
c = "?"
end
if $scene.template == true
x = 320 - 16 * 14 + i * 28
else
x = 320 - 16 * 14 + i * 28 - width / 4
end
self.contents.draw_text(x, 49, 28, 32, c, 1)
end
#if @sprite_size == 0
# draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 92)
#else
# draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 112)
#end
end
def draw_locker_graphic
@bitmap = 0
if @bitmap != nil
@bitmap = nil
end
#self.contents2.clear
@bitmap = RPG::Cache.picture("locker")
@timing = 4
@counter = 0
@pattern = 0
end
#--------------------------------------------------------------------------
def update_cursor_rect
if $scene.template == true
if @index < @max_char-1
self.cursor_rect.set(-96 + @max_char * 25 + @index * 28, 48, 28, 32)#16
else
self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28, 48, 28, 32)
end
else
if @index < @max_char-1
self.cursor_rect.set(-96 + @max_char * 25 + @index * 28 - width / 4, 48, 28, 32)#16
else
self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28 - width / 4, 48, 28, 32)
end
end
end
#--------------------------------------------------------------------------
def update
super
if $scene.template == true
bitmap = @bitmap
cw = bitmap.width / 4
ch = bitmap.height
if @counter == @timing
@counter = 0
if @pattern == 3
@pattern = 0
else
@pattern += 1
end
pt = @pattern
src_rect = Rect.new(cw * pt, 0, cw, ch)
else
@counter += 1
#if $scene.lockerinput.active
# Audio.se_play("Audio/SE/" + "032-Switch01", 70, 50)
#elsif $scene.lc.active
# Audio.se_play("Audio/SE/" + "032-Switch01", 70, 50)
#end
#$game_system.se_play("032-Switch01")
pt = @pattern
src_rect = Rect.new(cw * pt, 0, cw, ch)
end
self.contents.blt(x - cw * 1.5, y - ch, bitmap, src_rect)
end
update_cursor_rect
end
#--------------------------------------------------------------------------
end
class Window_LockerInstructions < Window_Base
attr_accessor :text
def initialize
super(155,85,350,45)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 14
@text = ""
self.x = 320 - self.width / 2
self.contents.draw_text(4, 0, width, 17, @text,1)
end
def set_text(text)
self.contents.clear
@text = text
self.contents.draw_text(4, 0, width, 17, @text,1)
end
end
class Window_LockerInput < Window_Base
attr_reader :name
attr_reader :index
attr_accessor :max_char
attr_accessor :face_frame
#--------------------------------------------------------------------------
def initialize(actor, max_char)
super(155,130,350,200)
self.contents = Bitmap.new(width - 32, height - 32)
self.x = 320 - self.width / 2
#self.contents = Bitmap.new(width - 32, height - 32)
#@actor = $game_party.actors[actor]
@name = ""#@actor.name
@max_char = max_char
name_array = @name.split(//)[0...@max_char]
@name = ""
for i in 0...name_array.size
@name += name_array[i]
end
@default_name = @name
@index = name_array.size
@sprite_size = 0 # 0 for small sprites, 1 for bigger sprites
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
def restore_default
@name = @default_name
@index = @name.split(//).size
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
def add(character)
if @index < @max_char and character != ""
@name += character
@index += 1
refresh
update_cursor_rect
end
end
#--------------------------------------------------------------------------
def back
if @index > 0
name_array = @name.split(//)
@name = ""
for i in 0...name_array.size-1
@name += name_array[i]
end
@index -= 1
refresh
update_cursor_rect
end
end
#--------------------------------------------------------------------------
def refresh
self.contents.clear
name_array = @name.split(//)
for i in 0...@max_char
c = name_array[i]
if c == nil
c = "?"
end
if $scene.template == true
x = 320 - 16 * 14 + i * 28
else
x = 320 - 16 * 14 + i * 28 - width / 4
end
self.contents.draw_text(x, 49, 28, 32, c, 1)
end
#if @sprite_size == 0
# draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 92)
#else
# draw_actor_graphic(@actor, 320 - 16 * 14 - 40, 112)
#end
end
def draw_locker_graphic
@bitmap = 0
if @bitmap != nil
@bitmap = nil
end
#self.contents2.clear
@bitmap = RPG::Cache.picture("locker")
@timing = 4
@counter = 0
@pattern = 0
end
#--------------------------------------------------------------------------
def update_cursor_rect
if $scene.template == true
if @index < @max_char-1
self.cursor_rect.set(-96 + @max_char * 25 + @index * 28, 48, 28, 32)#16
else
self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28, 48, 28, 32)
end
else
if @index < @max_char-1
self.cursor_rect.set(-96 + @max_char * 25 + @index * 28 - width / 4, 48, 28, 32)#16
else
self.cursor_rect.set(-96 + @max_char * 25 + (@max_char-1) * 28 - width / 4, 48, 28, 32)
end
end
end
#--------------------------------------------------------------------------
def update
super
if $scene.template == true
bitmap = @bitmap
cw = bitmap.width / 4
ch = bitmap.height
if @counter == @timing
@counter = 0
if @pattern == 3
@pattern = 0
else
@pattern += 1
end
pt = @pattern
src_rect = Rect.new(cw * pt, 0, cw, ch)
else
@counter += 1
if $scene.se == true
if $scene.lockerinput.active
Audio.se_play("Audio/SE/" + $scene.sename, 70, 50)
elsif $scene.lc.active
Audio.se_play("Audio/SE/" + $scene.sename, 70, 50)
end
end
#$game_system.se_play("032-Switch01")
pt = @pattern
src_rect = Rect.new(cw * pt, 0, cw, ch)
end
self.contents.blt(x - cw * 1.5, y - ch, bitmap, src_rect)
end
update_cursor_rect
end
#--------------------------------------------------------------------------
end
class Scene_Load < Scene_File
alias save_data read_save_data
def read_save_data(file)
save_data(file)
$game_locker = Marshal.load(file)
end
end
class Scene_Save < Scene_File
alias save_data write_save_data
def write_save_data(file)
save_data(file)
Marshal.dump($game_locker, file)
end
end
class Scene_Title
alias newgame command_new_game
def command_new_game
newgame
$game_locker = Game_Locker.new
end
end