#==============================================================================
# Window_InputNumber Edit by Wecoc (version 1.1)
#==============================================================================
class Game_Temp
attr_accessor :input_type
alias input_type_initialize initialize
def initialize
input_type_initialize
@input_type = "default"
end
end
class Window_InputNumber < Window_Base
def initialize(digits_max,type="default")
case type
when "default"
@character_array = ["0","1","2","3","4","5","6","7","8","9"]
when "binary"
@character_array = ["0","1"]
when "hexa"
@character_array = ["0","1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F"]
when "upcase_letters"
@character_array = [" ","A","B","C","D","E","F","G","H","I",
"J","K","L","M","N","O","P","Q","R","S",
"T","U","V","W","X","Y","Z"]
when "all_letters"
@character_array = [" ","A","B","C","D","E","F","G","H","I",
"J","K","L","M","N","O","P","Q","R","S",
"T","U","V","W","X","Y","Z","a","b","c",
"d","e","f","g","h","i","j","k","l","m",
"n","o","p","q","r","s","t","u","v","w",
"x","y","z"]
when "all_characters"
@character_array = [" ","A","B","C","D","E","F","G","H","I",
"J","K","L","M","N","O","P","Q","R","S",
"T","U","V","W","X","Y","Z","a","b","c",
"d","e","f","g","h","i","j","k","l","m",
"n","o","p","q","r","s","t","u","v","w",
"x","y","z","0","1","2","3","4","5","6",
"7","8","9","+","-","*","/","!","#","$",
"%","&","@",".",",","-"]
# when...
end
@digits_max = digits_max
@type = type
@letter_array = []
@digits_max.times{@letter_array.push(0)}
dummy_bitmap = Bitmap.new(32, 32)
@cursor_width = 8
for i in 0...@character_array.size
letter_size = dummy_bitmap.text_size(@character_array[i]).width + 8
@cursor_width = [@cursor_width, letter_size].max
end
dummy_bitmap.dispose
super(0, 0, @cursor_width * @digits_max + 32, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.z += 9999
self.opacity = 0
@index = 0
refresh
update_cursor_rect
end
def letter(index)
return @character_array[@letter_array[index]]
end
def increase_letter_array(index)
if @letter_array[index] == (@character_array.size-1)
@letter_array[index] = 0
else
@letter_array[index] += 1
end
end
def decrease_letter_array(index)
if @letter_array[index] == 0
@letter_array[index] = (@character_array.size-1)
else
@letter_array[index] -= 1
end
end
def update_cursor_rect
self.cursor_rect.set(@index * @cursor_width, 0, @cursor_width, 32)
end
def update
super
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
increase_letter_array(@index)
refresh
end
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
decrease_letter_array(@index)
refresh
end
if Input.repeat?(Input::RIGHT)
if @digits_max >= 2
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @digits_max
end
end
if Input.repeat?(Input::LEFT)
if @digits_max >= 2
$game_system.se_play($data_system.cursor_se)
@index = (@index + @digits_max - 1) % @digits_max
end
end
if Input.trigger?(Input::B)
@letter_array[@index] = 0
refresh
end
update_cursor_rect
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
for i in 0...@digits_max
self.contents.draw_text(i*@cursor_width,0,@cursor_width,32,letter(i),1)
end
end
def number
@number = []
for i in 0...@digits_max
@number.push(letter(i))
end
if @number.to_s.to_i != 0 and @number.to_s != "0"
return @number.to_s.to_i
else
return @number.to_s
end
end
def number=(number)
if number != 0
if number.is_a?(Integer)
num = number.to_s
else
num = number
end
@array = num.scan(/./)
if @array.size != @digits_max
begin
@array.unshift(@character_array[0])
end until @array.size == @digits_max
end
for i in 0...@digits_max
for j in 0..@character_array.size
if @array[i] == @character_array[j]
@letter_array[i] = j
end
end
end
end
refresh
end
end