#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Control_Config by Nathmatt
# Version: 1.01
# Type: control config
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Control_Config
def main
@controls = Window_Controls.new
@help_window = Window_Help.new
@info = Window_Help.new
@info.set_text('Control Config')
@help_window.y = 416
Graphics.transition
while $scene == self
Graphics.update
Input.update
update
end
Graphics.freeze
@controls.dispose
@help_window.dispose
@info.dispose
end
def update
@controls.update
if @controls.index >= 0 && Input.trigger?(Input::C) && !@get_keys
$game_system.se_play($data_system.decision_se)
@controls.active = false
@help_window.set_text('Press A Key')
@wait = 6
@get_keys = true
end
if Input.trigger?(Input::B) && !@get_keys
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
end
if @get_keys
@wait -= 1
return if @wait > 0
(0..256).each{|i|
if Input.trigger?(i)
$game_system.se_play($data_system.decision_se)
key = @controls.item
Input.change(key,i)
eval("$game_system.con_#{key.downcase} = [#{i}]")
$game_system.contols_set = true
@get_keys = false
@controls.active = true
@help_window.set_text('')
@controls.refresh
end}
end
end
end
class Window_Controls < Window_Selectable
def initialize
super(0,64,640,352)
get_keys
self.contents = Bitmap.new(width - 32, @keys.size * 32)
@key_input = Input::Key.clone
self.active = true
self.index = 0
refresh
end
def item
return @keys[self.index][0]
end
def refresh
get_keys
@item_max = @keys.size
self.contents.clear
@keys.each_index{|i|
self.contents.draw_text(4,i*32,120,32,@keys[i][0])
self.contents.draw_text(200,i*32,120,32,'>>')
self.contents.draw_text(400,i*32,200,32,@keys[i][1])}
end
def get_keys
@key_input = Input::Key.clone
['NumberPad 0','NumberPad 1','NumberPad 2','NumberPad 3',
'NumberPad 4','NumberPad 5','NumberPad 6', 'NumberPad 7','NumberPad 8',
'NumberPad 9'].each{|key|@key_input.delete(key)}
@keys = []
$game_system.keys.each{|key|
@keys.push(eval("['#{key}',@key_input.index(Input::#{key}[0])]"))}
end
end
module Input
def self.change(key,value)
eval("#{key}[0] = #{value}")
end
end
class Scene_Load < Scene_File
alias set_controls_read_save_data read_save_data
def read_save_data(file)
set_controls_read_save_data(file)
$game_system.set_controls
end
end
class Game_System
attr_accessor :contols_set,:con_up,:con_down,:con_left,:con_right,
:con_b,:con_c,:con_l,:con_r,:con_attack,:con_defend,:con_skill,:con_item,
:con_select,:con_hud,:con_hotkey,:con_minimap,:con_run,:con_sneak,:con_jump,
:con_turn,:con_escape,:keys
alias set_controls_initialize initialize
def initialize
set_controls_initialize
@keys = ['UP','LEFT','DOWN','RIGHT','B','C','L','R']
if $BlizzABS != nil
@keys.push('Attack','Defend','Skill','Item','Select','Hud','Hotkey',
'Minimap','Run','Sneak','Jump')
end
if $Battle_Dome != nil
@keys.push('Escape')
end
@keys.each{|key|
eval("@con_#{key.downcase} = Input::#{key}[0]")}
end
def set_controls
return if !@contols_set
@keys.each{|key|
eval("Input.change('#{key}',@con_#{key.downcase})")}
end
end