class Scene_Contols
def main
# Make command window
commands = [
'Up',
'Left',
'Down',
'Right',
'Prevpage',
'Nextpage',
'Confirm',
'Cancel',
'Attack',
'Defend',
'Skill',
'Item',
'Select',
'Run',
'Sneak',
'Jump',
'Turn']
@help_window = Window_Help.new
@help_window.set_text('Controls',1)
@command_window = Window_Item_Command.new(commands,get_contols)
@text_window = Window_Help.new
@text_window.set_text('Press A Key')
@text_window.width = 200
@text_window.x = 220
@text_window.y = 176
@text_window.z = 100
@text_window.visible = false
# 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
# Dispose of windows
end
def update
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(4)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
@text_window.visible = true
loop do
Input::Key.each_value{|i|
if Input.trigger?(i)
Input.change(@command_window.index,i)
break
end}
end
@text_window.visible = false
end
end
def get_contols
name = [
Input::Up,
Input::Left,
Input::Down,
Input::Right,
Input::Prevpage,
Input::Nextpage,
Input::Confirm,
Input::Cancel,
Input::Attack,
Input::Defend,
Input::Skill,
Input::Item,
Input::Select,
Input::Run,
Input::Sneak,
Input::Jump,
Input::Turn]
name.each_index{|i| name[i] = Input::Key.index(name[i][0])}
return name
end
end
#==============================================================================
# Window_Item_Command
#==============================================================================
class Window_Item_Command < Window_Selectable
def initialize(commands,name)
super(0, 64, 640, 416)
@commands = commands
@name = name
refresh
self.index = 0
self.active = true
end
def item
return @commands[self.index]
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@item_max = @commands.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
@commands.each_index{|i|draw_item(i)}
end
end
def draw_item(index)
y = index * 32
self.contents.draw_text(4, y, 120, 32, @commands[index])
self.contents.draw_text(420, y, 120, 32, @name[index])
end
end
module Input
def self.change(key,value)
case key
when 0
Up = value
when 1
Left = value
when 2
Down = value
when 3
Right = value
when 4
Prevpage = value
when 5
Nextpage = value
when 6
Confirm = value
when 7
Cancel = value
when 8
Attack = value
when 9
Defend = value
when 10
Skill = value
when 11
Item = value
when 12
Select = value
when 13
Run = value
when 14
Sneak = value
when 15
Jump = value
when 16
Turn = value
end
end
end