Advertisement
estriole

EST - INPUT NAME USING KEYBOARD

Feb 15th, 2013
3,781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.78 KB | None | 0 0
  1. =begin
  2. EST - NAME INPUT USING KEYBOARD
  3. v.1.0
  4.  
  5. Requires:
  6. Neon Black Keyboard Input 1.0a
  7. http://forums.rpgmakerweb.com/index.php?/topic/3456-developer-console/#entry37268
  8. enter the link to his keyboard module script there.
  9. or
  10. http://pastebin.com/raw.php?i=rD4rQtKP
  11. for direct link to his pastebin.
  12.  
  13. version history
  14. v.1.0 - 2013.02.15 - finish the script
  15.  
  16. Introduction:
  17. Have you ever feel it's not comfortable to input name by choosing which symbol
  18. then press enter. letter by letter. so time consuming.
  19.  
  20. this script change that!. instead of choosing symbol and press enter.
  21. you type letter directly from keyboard.
  22.  
  23. press esc / backspace to erase a character
  24. press enter when you're done. maybe will put confirmation window later.
  25.  
  26. btw the name input window still there. i just hide it from view and change
  27. some behavior. :D.
  28.  
  29. Usage
  30. Plug and Play
  31.  
  32. Compatibility
  33. it should compatible with most script.
  34. If you using Tsukihime Simple Text Input.
  35. put this script ABOVE that script. so the script will also use KEYBOARD :D.
  36. since the script is using name input window too.
  37.  
  38. =end
  39. module ESTRIOLE
  40.   module KEYBOARD_PRESS
  41.     KEYBOARDPRESS = {
  42.       :k0 => 48, :k1 => 49, :k2 => 50, :k3 => 51, :k4 => 52, :k5 => 53,
  43.       :k6 => 54, :k7 => 55, :k8 => 56, :k9 => 57,
  44.          
  45.       :kA => 65, :kB => 66, :kC => 67, :kD => 68, :kE => 69, :kF => 70,
  46.       :kG => 71, :kH => 72, :kI => 73, :kJ => 74, :kK => 75, :kL => 76,
  47.       :kM => 77, :kN => 78, :kO => 79, :kP => 80, :kQ => 81, :kR => 82,
  48.       :kS => 83, :kT => 84, :kU => 85, :kV => 86, :kW => 87, :kX => 88,
  49.       :kY => 89, :kZ => 90,
  50.          
  51.       :kCOLON => 186,     :kQUOTE => 222,
  52.       :kCOMMA => 188,     :kPERIOD => 190,     :kSLASH => 191,
  53.       :kBACKSLASH => 220, :kLEFTBRACE => 219,  :kRIGHTBRACE => 221,
  54.       :kMINUS => 189,     :kEQUAL => 187,     :kTILDE => 192,          
  55.     }
  56.   end
  57. end
  58.  
  59. class Window_NameInput < Window_Selectable
  60.   include ESTRIOLE::KEYBOARD_PRESS
  61.   alias est_keyboard_name_input_init initialize
  62.   def initialize(edit_window)
  63.     est_keyboard_name_input_init(edit_window)
  64.     self.visible = false
  65.   end
  66.  
  67.   def process_handling
  68.     return unless open? && active
  69.     process_back if Input.repeat?(:kESC) or Input.repeat?(:kBACKSPACE)
  70.     check_keyboard_input
  71.   end
  72.   alias cursor_page_change cursor_pagedown
  73.   def check_keyboard_input
  74.     KEYBOARDPRESS.each {|key|
  75.     @edit_window.add(Keyboard.add_char(Ascii::SYM[key[0]])) if Input.trigger?(key[0])
  76.     Sound.play_ok if Input.trigger?(key[0])
  77.     }
  78.     check_spaces
  79.     check_enter
  80.   end
  81.   def check_spaces
  82.     if Input.trigger?(:kSPACE)
  83.     @edit_window.add(" ")
  84.     Sound.play_ok
  85.     end
  86.   end
  87.   def check_enter
  88.     on_name_ok if Input.trigger?(:kENTER)
  89.   end
  90.   def cursor_pageup;end
  91.   def cursor_pagedown;end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement