ÿþ#==============================================================================# # æ% Name Input Recreated æ% # #------------------------------------------------------------------------------# # æ% By Mesiah A.K.A. MakoInfused # # æ% Exclusively for http://www.rpgmakervx.net & http://www.cetrastudios.com/ # # æ% Released on: 01/16/2010 # # æ% My Website: http://www.cetrastudios.com/ # # æ% Version: 1.0 # # # # æ% Summary: This script makes the Name Input scene...well...basically it # # æ% makes it ACTUALLY useful. I found it lacking in customization before. In # # æ% addition this script will fix some glitches with the name input window. # # # # æ% Credit: Credit me (MakoInfused) IF you want, you don't need to. # # # # æ% Terms of use: # # æ% This goes for both commerical and non commerical games # # 1. This script is free to use, BUT please don't claim you created it. # # 2. If you do use this; leave me a comment, I would like to check it out :). # # # # æ% Call in script command: # # æ% None at this time # # Mainly because I can't really find any use for wanting to change the name # # input window during the course of the game. # # HOWEVER, this is subject to change in a future release. # # # # æ% Example: # # æ% None at this time # # # #==============================================================================# module MESI module ADVANCED_INPUT MAX_SIZE = 0 #Minimum: 0, Maximum: 16. # Note: If this value is set to 0 the number from the Name Input event # command will be used instead of this value. # Otherwise the value from the event will be disregarded. # The maximum amount of characters that can be used during the name input # process. This will also readjust the subsequent window automatically. #----------------------------------------------------------------------------- AUTO_LENGTH = false # When AUTO_LENGTH is activated the name input window will automatically adjust # itself to fit the length of the characters original name. # # Example: # If we're renaming Ralph (5 letters) but the window is set to only allow 3 # letters, the name input will always allow Ralph to have 5 letters in his name. #----------------------------------------------------------------------------- WINDOW_SIZE_X = 416 #Default: 368; Maxiumum: Game Resolution. # The window width of the name input box; this number will readjust ALL of # the associated graphics in the name input box so they appear correctly. #----------------------------------------------------------------------------- WINDOW_SIZE_Y = 248 #Default: 248; Maxiumum: Game Resolution - Name Window. # The window height of the name input box; this number will readjust ALL of # the associated graphics in the name input box so they appear correctly. USE_FACE = true # If set to true: the actor's face will be displayed in the name input window. #----------------------------------------------------------------------------- USE_CHAR = true # If set to true: the actor's sprite will be displayed in the name input window. #----------------------------------------------------------------------------- DEFAULT_NAME = false # If set to true: the actor's name will appear in input name box as # the starting value. #----------------------------------------------------------------------------- NAMING_TYPE = 1 # Don't delete. # 1 = Changes the actors name. # 2 = Changes the actors CLASS name. DISPLAY_OTHER = true # If set to true: this will display the OPPOSITE of what is being input in # the naming type under the input area. # Example: If NAMING_TYPE is 1 # Displays: A c t o r N a m e # ActorClassName #----------------------------------------------------------------------------- RANDOM_NAME = true # If set to true: a name will be randomly selected from RANDOM_NAMES list. # If set to false: the FIRST name from the RANDOM_NAMES list will be used. # This can be useful if you want just a default value for names to appear #----------------------------------------------------------------------------- RANDOM_NAMES = [ # Don't delete. # This is a list of random names that will appear in the name input window #----------------------------------------------------------------------------- "Barrius", # Don't forget the "" (quotes) for the name. "Jeffery", "Dunham" # No comma for the last line. ] # Don't delete. RANDOM_CLASS = [ # Don't delete. # This is a list of random names that will appear in the name input window # Remember though, that this will change that class name for EVERYONE who # uses it! #----------------------------------------------------------------------------- "Adventurer", # Don't forget the "" (quotes) for the name. "Traveller", "Holy Knight" # No comma for the last line. ] # Don't delete. EXIT_KEY = false # This decides whether or not the name input window should have an Exit key. #----------------------------------------------------------------------------- MODE_SWITCH = true # This decides whether or not the name input window should have a Mode Key. # The Mode Key dictates whether or not you can switch the characters that are # displayed and can be input. # Basically this allows you to use symbols such # or @ or $, etc. # Modes can also be switched using the Q and W buttons on the keyboard. #----------------------------------------------------------------------------- ENGLISH = ['A','B','C','D','E', 'a','b','c','d','e', 'F','G','H','I','J', 'f','g','h','i','j', 'K','L','M','N','O', 'k','l','m','n','o', 'P','Q','R','S','T', 'p','q','r','s','t', 'U','V','W','X','Y', 'u','v','w','x','y', 'Z','', '', '', '' , 'z','', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '1','2','3','4','5', '', '', '', '', '' , '6','7','8','9','0', ' ','','SYMBOL','EXIT','OK'] SYMBOLS = ['`','~','!','@','#', '$','%','^','&','*', '(',')','-','_','=', '+','[',']','{','}', '|',';',':','"',',', '<','.','>','?','©', '®','±','²','³','¶', '¥','§','¦','«','»', '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , '', '', '', '', '' , ' ','','ICON','EXIT','OK'] # These are the symbols used in the naming input process. The symbols category # can ONLY be seen if the MODE_SWITCH flag is set to true. #----------------------------------------------------------------------------- USE_PICTURE = false # USE_PICTURE determines whether or not a picutre should be used for the # background. BG_LOCATION = "Input_Background" # BG_LOCATION is the name of the picture, located in the Pictures Folder. BG_RED = 150 #Determines BG Red Hue. BG_GRN = 150 #Determines BG Green Hue. BG_BLU = 150 #Determines BG Blue Hue. BG_SAT = 100 #Determines BG Saturation or Grey Color. #----------------------------------------------------------------------------- WINDOW_PICS = false # Determines whether picture based windows are used. # # Note: When using window pictures make sure to set MAX_SIZE to a length # that is appropriate for your pictures. In addition you should set # AUTO_LENGTH to false. #----------------------------------------------------------------------------- WINDOW_MAIN = "Input_Main" WINDOW_EDIT = "Input_Edit" # These names are what the script looks for when processing the picture. # WINDOW_MAIN is the picture used for the window displaying the name. # WINDOW_EDIT is the picture used for the inputting part of the window. #----------------------------------------------------------------------------- end end #============================================================================== # ** Window_NameEdit #------------------------------------------------------------------------------ # This window is used to edit an actor's name on the name input screen. #============================================================================== class Window_NameEdit < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # actor : actor # max_char : maximum number of characters #-------------------------------------------------------------------------- def initialize(actor, max_char) @max_char = MESI::ADVANCED_INPUT::MAX_SIZE @actor = actor # Random Name Change if MESI::ADVANCED_INPUT::DEFAULT_NAME new_name = actor.name else if MESI::ADVANCED_INPUT::RANDOM_NAME if MESI::ADVANCED_INPUT::NAMING_TYPE == 1 name_size = MESI::ADVANCED_INPUT::RANDOM_NAMES.size else name_size = MESI::ADVANCED_INPUT::RANDOM_CLASS.size end else name_size = 0 end if MESI::ADVANCED_INPUT::NAMING_TYPE == 1 new_name = MESI::ADVANCED_INPUT::RANDOM_NAMES[rand(name_size)] else new_name = MESI::ADVANCED_INPUT::RANDOM_CLASS[rand(name_size)] end end # Auto Correct Lengths if MESI::ADVANCED_INPUT::RANDOM_NAME long_name = new_name.size else if MESI::ADVANCED_INPUT::NAMING_TYPE == 1 long_name = actor.name.size else long_name = actor.class.name.size end end @max_char = max_char if @max_char == 0 @max_char = long_name if long_name > @max_char and MESI::ADVANCED_INPUT::AUTO_LENGTH @max_char = 16 unless @max_char < 17 # Create Windows window_x = (@max_char * 9) * 2 + 272 window_x = Graphics.width unless window_x < Graphics.width @position_x = (Graphics.width - window_x) / 2 window_y = 128 if MESI::ADVANCED_INPUT::WINDOW_SIZE_Y < 288 @position_y = 20 else @position_y = 0 end super(@position_x, @position_y, window_x, window_y) self.opacity = 0 if MESI::ADVANCED_INPUT::WINDOW_PICS @name = new_name name_array = @name.split(//)[0...@max_char] # Fit within max length @name = "" for i in 0...name_array.size @name += name_array[i] end @default_name = @name # Name that is restored when nothing is input. @index = name_array.size self.active = false refresh update_cursor picture_window if MESI::ADVANCED_INPUT::WINDOW_PICS end #-------------------------------------------------------------------------- # * Draw a purdy picture #-------------------------------------------------------------------------- def picture_window @edi_window = Sprite.new @edi_window.bitmap = Cache.picture(MESI::ADVANCED_INPUT::WINDOW_MAIN) @edi_window.x = @position_x @edi_window.y = @position_y @edi_window.opacity = 255 @edi_window.z = 99 end #-------------------------------------------------------------------------- # * Erase the edit window picture #-------------------------------------------------------------------------- def erase @edi_window.dispose end #-------------------------------------------------------------------------- # * Get rectangle for displaying items # index : item number #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new(0, 0, 0, 0) base = 10 * @max_char + 160 rect.x = base - (@max_char + 1) * 12 + index * 24 @first_item = rect.x + 6 if @first_item.nil? rect.y = 36 rect.width = 24 rect.height = WLH return rect end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear if MESI::ADVANCED_INPUT::USE_FACE and MESI::ADVANCED_INPUT::USE_CHAR draw_actor_face(@actor, -6, 0) draw_actor_graphic(@actor, 96, 64) else if MESI::ADVANCED_INPUT::USE_FACE draw_actor_face(@actor, 0, 0) end if MESI::ADVANCED_INPUT::USE_CHAR draw_actor_graphic(@actor, 48, 64) end end name_array = @name.split(//) for i in 0...@max_char c = name_array[i] c = '_' if c == nil self.contents.draw_text(item_rect(i), c, 1) end if MESI::ADVANCED_INPUT::DISPLAY_OTHER if MESI::ADVANCED_INPUT::NAMING_TYPE == 1 draw_actor_class(@actor, @first_item, 64) else draw_actor_name(@actor, @first_item, 64) end end end end #============================================================================== # ** Window_NameInput #------------------------------------------------------------------------------ # This window is used to select text characters on the name input screen. #============================================================================== class Window_NameInput < Window_Base #-------------------------------------------------------------------------- # * Text Character Table #-------------------------------------------------------------------------- ENGLISH = MESI::ADVANCED_INPUT::ENGLISH SYMBOLS = MESI::ADVANCED_INPUT::SYMBOLS TABLE = [ENGLISH, SYMBOLS] #-------------------------------------------------------------------------- # * Object Initialization # mode : Default input mode (USUALLY always 0 in the English version) #-------------------------------------------------------------------------- def initialize(mode = 0) window_x = MESI::ADVANCED_INPUT::WINDOW_SIZE_X window_y = MESI::ADVANCED_INPUT::WINDOW_SIZE_Y window_x = Graphics.width unless window_x < Graphics.width window_y = Graphics.height unless window_y < Graphics.height window_realign = 128 realign_y = window_y + window_realign if realign_y > Graphics.height realign_y = realign_y - Graphics.height window_y = window_y - realign_y end @position_x = (Graphics.width - window_x) / 2 @position_y = (Graphics.height - window_y) / 2 + 64 super(@position_x, @position_y, window_x, window_y) self.opacity = 0 if MESI::ADVANCED_INPUT::WINDOW_PICS @mode = mode @index = 0 refresh update_cursor picture_window if MESI::ADVANCED_INPUT::WINDOW_PICS end #-------------------------------------------------------------------------- # * Draw a purdy picture #-------------------------------------------------------------------------- def picture_window @inp_window = Sprite.new @inp_window.bitmap = Cache.picture(MESI::ADVANCED_INPUT::WINDOW_EDIT) @inp_window.x = @position_x @inp_window.y = @position_y @inp_window.opacity = 255 @inp_window.z = 99 end #-------------------------------------------------------------------------- # * Erase the edit window picture #-------------------------------------------------------------------------- def erase @inp_window.dispose end #-------------------------------------------------------------------------- # * Text Character Acquisition #-------------------------------------------------------------------------- def character if @index < 87 return TABLE[@mode][@index] else return "" end end #-------------------------------------------------------------------------- # * Determine Cursor Position: Skippable Key # * This method is just here to remove one of the unnecessary keys #-------------------------------------------------------------------------- def skippable_key return (@index == 86) end #-------------------------------------------------------------------------- # * Determine Cursor Position: Mode Switch #-------------------------------------------------------------------------- def is_mode_change return (@index == 87) if MESI::ADVANCED_INPUT::MODE_SWITCH end #-------------------------------------------------------------------------- # * Determine Cursor Position: Exit Key #-------------------------------------------------------------------------- def exit_key return (@index == 88) end #-------------------------------------------------------------------------- # * Forced Action: Forces the Cursor to Skip an unnecessary Key #-------------------------------------------------------------------------- def skip_key @index = 86 update end #-------------------------------------------------------------------------- # * Forced Action: Forces the Cursor to the Exit Key #-------------------------------------------------------------------------- def force_exit_key @index = 88 update end #-------------------------------------------------------------------------- # * Get rectangle for displaying items # index : item number #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new(0, 0, 0, 0) window_x = MESI::ADVANCED_INPUT::WINDOW_SIZE_X window_x = Graphics.width unless window_x < Graphics.width c_size = (window_x / 12).truncate + 2 c_half = c_size / 2 if index == 86 index = 87 end rect.x = index % 10 * c_size + index % 10 / 5 * c_half rect.x = rect.x + (c_size - 38) unless c_size < 38 rect.y = index / 10 * WLH rect.width = c_size rect.height = WLH if index == 87 rect.width *= 2 position_x = rect.x - (rect.width / 2) rect.x = position_x end return rect end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0..89 rect = item_rect(i) rect.x += 2 rect.width -= 4 draw_next = true if i == 87 and MESI::ADVANCED_INPUT::MODE_SWITCH == false draw_next = false end if i == 88 and MESI::ADVANCED_INPUT::EXIT_KEY == false draw_next = false end if draw_next self.contents.draw_text(rect, TABLE[@mode][i], 1) end end end #-------------------------------------------------------------------------- # * Move cursor down # wrap : Wraparound allowed #-------------------------------------------------------------------------- def cursor_down(wrap) if @index == 87 @index -= 81 else if @index == 76 @index += 11 else if @index < 80 @index += 10 elsif wrap @index -= 80 end end end end #-------------------------------------------------------------------------- # * Move cursor up # wrap : Wraparound allowed #-------------------------------------------------------------------------- def cursor_up(wrap) if @index == 87 @index -= 11 else if @index == 6 @index += 81 else if @index >= 10 @index -= 10 elsif wrap @index += 80 end end end end end #============================================================================== # ** Scene_Name #------------------------------------------------------------------------------ # This class performs name input screen processing. #============================================================================== class Scene_Name < Scene_Base #-------------------------------------------------------------------------- # * Start processing #-------------------------------------------------------------------------- def start super create_menu_background if MESI::ADVANCED_INPUT::USE_PICTURE @menuback_sprite.bitmap = Cache.picture(MESI::ADVANCED_INPUT::BG_LOCATION) @menuback_sprite.tone.set(150, 150, 150, 100) end @actor = $game_actors[$game_temp.name_actor_id] @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char) @input_window = Window_NameInput.new end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super update_menu_background @edit_window.update @input_window.update if @input_window.skippable_key @input_window.skip_key end if Input.repeat?(Input::B) if @edit_window.index > 0 # Not at the left edge Sound.play_cancel @edit_window.back elsif MESI::ADVANCED_INPUT::EXIT_KEY @input_window.force_exit_key Graphics.wait(10) erase_pictures if MESI::ADVANCED_INPUT::WINDOW_PICS return_scene end elsif Input.trigger?(Input::C) if @input_window.exit_key and MESI::ADVANCED_INPUT::EXIT_KEY erase_pictures if MESI::ADVANCED_INPUT::WINDOW_PICS return_scene end if @input_window.is_decision # If cursor is positioned on [OK] if @edit_window.name == "" # If name is empty @edit_window.restore_default # Return to default name if @edit_window.name == "" Sound.play_buzzer else Sound.play_decision end else Sound.play_decision if MESI::ADVANCED_INPUT::NAMING_TYPE == 2 @actor.class.name = @edit_window.name # Change actor class name else @actor.name = @edit_window.name # Change actor name end erase_pictures if MESI::ADVANCED_INPUT::WINDOW_PICS return_scene end elsif @input_window.character != "" # If text characters are not empty if @edit_window.index == @edit_window.max_char # at the right edge Sound.play_buzzer else Sound.play_decision @edit_window.add(@input_window.character) # Add text character end end end end #-------------------------------------------------------------------------- # * Erase Pictures (If used) #-------------------------------------------------------------------------- def erase_pictures @input_window.erase @edit_window.erase end end #------------------------------------------------------------------------------- # ** End Script #===============================================================================