Class: Window_NameInput
- Inherits:
-
Window_Selectable
- Object
- Window
- Window_Base
- Window_Selectable
- Window_NameInput
- Defined in:
- lib/rgss3_default_scripts/Window_NameInput.rb
Overview
** Window_NameInput
This window is used to select text characters on the name input screen.
Constant Summary collapse
- LATIN1 =
-
Character Tables (Latin)
-
[ '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','{','}','|','~', '0','1','2','3','4', '!','#','$','%','&', '5','6','7','8','9', '(',')','*','+','-', '/','=','@','<','>', ':',';',' ','Page','OK']
- LATIN2 =
[ 'Á','É','Í','Ó','Ú', 'á','é','í','ó','ú', 'À','È','Ì','Ò','Ù', 'à','è','ì','ò','ù', 'Â','Ê','Î','Ô','Û', 'â','ê','î','ô','û', 'Ä','Ë','Ï','Ö','Ü', 'ä','ë','ï','ö','ü', 'Ā','Ē','Ī','Ō','Ū', 'ā','ē','ī','ō','ū', 'Ã','Å','Æ','Ç','Ð', 'ã','å','æ','ç','ð', 'Ñ','Õ','Ø','Š','Ŵ', 'ñ','õ','ø','š','ŵ', 'Ý','Ŷ','Ÿ','Ž','Þ', 'ý','ÿ','ŷ','ž','þ', 'IJ','Œ','ij','œ','ß', '«','»',' ','Page','OK']
- JAPAN1 =
-
Character Tables (Japanese)
-
[ 'あ','い','う','え','お', 'が','ぎ','ぐ','げ','ご', 'か','き','く','け','こ', 'ざ','じ','ず','ぜ','ぞ', 'さ','し','す','せ','そ', 'だ','ぢ','づ','で','ど', 'た','ち','つ','て','と', 'ば','び','ぶ','べ','ぼ', 'な','に','ぬ','ね','の', 'ぱ','ぴ','ぷ','ぺ','ぽ', 'は','ひ','ふ','へ','ほ', 'ぁ','ぃ','ぅ','ぇ','ぉ', 'ま','み','む','め','も', 'っ','ゃ','ゅ','ょ','ゎ', 'や','ゆ','よ','わ','ん', 'ー','~','・','=','☆', 'ら','り','る','れ','ろ', 'ゔ','を',' ','カナ','決定']
- JAPAN2 =
[ 'ア','イ','ウ','エ','オ', 'ガ','ギ','グ','ゲ','ゴ', 'カ','キ','ク','ケ','コ', 'ザ','ジ','ズ','ゼ','ゾ', 'サ','シ','ス','セ','ソ', 'ダ','ヂ','ヅ','デ','ド', 'タ','チ','ツ','テ','ト', 'バ','ビ','ブ','ベ','ボ', 'ナ','ニ','ヌ','ネ','ノ', 'パ','ピ','プ','ペ','ポ', 'ハ','ヒ','フ','ヘ','ホ', 'ァ','ィ','ゥ','ェ','ォ', 'マ','ミ','ム','メ','モ', 'ッ','ャ','ュ','ョ','ヮ', 'ヤ','ユ','ヨ','ワ','ン', 'ー','~','・','=','☆', 'ラ','リ','ル','レ','ロ', 'ヴ','ヲ',' ','英数','決定']
- JAPAN3 =
[ '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','{','}','|','~', '0','1','2','3','4', '!','#','$','%','&', '5','6','7','8','9', '(',')','*','+','-', '/','=','@','<','>', ':',';',' ','かな','決定']
Instance Attribute Summary
Attributes inherited from Window_Selectable
#cursor_all, #cursor_fix, #help_window, #index
Instance Method Summary collapse
-
#character ⇒ Object
————————————————————————– * Get Text Character ————————————————————————–.
-
#cursor_down(wrap) ⇒ Object
————————————————————————– * Move Cursor Down wrap : Wraparound allowed ————————————————————————–.
-
#cursor_left(wrap) ⇒ Object
————————————————————————– * Move Cursor Left wrap : Wraparound allowed ————————————————————————–.
-
#cursor_movable? ⇒ Boolean
————————————————————————– * Determine if Cursor is Moveable ————————————————————————–.
-
#cursor_pagedown ⇒ Object
————————————————————————– * Move to Next Page ————————————————————————–.
-
#cursor_pageup ⇒ Object
————————————————————————– * Move to Previous Page ————————————————————————–.
-
#cursor_right(wrap) ⇒ Object
————————————————————————– * Move Cursor Right wrap : Wraparound allowed ————————————————————————–.
-
#cursor_up(wrap) ⇒ Object
————————————————————————– * Move Cursor Up wrap : Wraparound allowed ————————————————————————–.
-
#initialize(edit_window) ⇒ Window_NameInput
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#is_ok? ⇒ Boolean
————————————————————————– * Determine Cursor Location: Confirmation ————————————————————————–.
-
#is_page_change? ⇒ Boolean
————————————————————————– * Determining if Page Changed and Cursor Location ————————————————————————–.
-
#item_rect(index) ⇒ Object
————————————————————————– * Get Rectangle for Displaying Item ————————————————————————–.
-
#on_name_add ⇒ Object
————————————————————————– * Add Text to Name ————————————————————————–.
-
#on_name_ok ⇒ Object
————————————————————————– * Decide Name ————————————————————————–.
-
#process_back ⇒ Object
————————————————————————– * Go Back One Character ————————————————————————–.
-
#process_cursor_move ⇒ Object
————————————————————————– * Cursor Movement Processing ————————————————————————–.
-
#process_handling ⇒ Object
————————————————————————– * Handling Processing for OK and Cancel Etc.
-
#process_jump ⇒ Object
————————————————————————– * Jump to OK ————————————————————————–.
-
#process_ok ⇒ Object
————————————————————————– * Processing When OK Button Is Pressed ————————————————————————–.
-
#refresh ⇒ Object
————————————————————————– * Refresh ————————————————————————–.
-
#table ⇒ Object
————————————————————————– * Get Text Table ————————————————————————–.
-
#update_cursor ⇒ Object
————————————————————————– * Update Cursor ————————————————————————–.
Methods inherited from Window_Selectable
#active=, #bottom_row, #bottom_row=, #call_cancel_handler, #call_handler, #call_ok_handler, #call_update_help, #cancel_enabled?, #clear_item, #col_max, #contents_height, #current_item_enabled?, #draw_all_items, #draw_item, #ensure_cursor_visible, #handle?, #height=, #horizontal?, #item_height, #item_max, #item_rect_for_text, #item_width, #ok_enabled?, #page_item_max, #page_row_max, #process_cancel, #process_pagedown, #process_pageup, #redraw_current_item, #redraw_item, #row, #row_max, #select, #set_handler, #spacing, #top_row, #top_row=, #unselect, #update, #update_help, #update_padding, #update_padding_bottom
Methods inherited from Window_Base
#activate, #actor_name, #calc_line_height, #change_color, #close, #contents_height, #contents_width, #convert_escape_characters, #create_contents, #crisis_color, #deactivate, #dispose, #draw_actor_class, #draw_actor_face, #draw_actor_graphic, #draw_actor_hp, #draw_actor_icons, #draw_actor_level, #draw_actor_mp, #draw_actor_name, #draw_actor_nickname, #draw_actor_param, #draw_actor_simple_status, #draw_actor_tp, #draw_character, #draw_currency_value, #draw_current_and_max_values, #draw_face, #draw_gauge, #draw_icon, #draw_item_name, #draw_text, #draw_text_ex, #fitting_height, #gauge_back_color, #hide, #hp_color, #hp_gauge_color1, #hp_gauge_color2, #knockout_color, #line_height, #make_font_bigger, #make_font_smaller, #mp_color, #mp_cost_color, #mp_gauge_color1, #mp_gauge_color2, #normal_color, #obtain_escape_code, #obtain_escape_param, #open, #param_change_color, #party_member_name, #pending_color, #power_down_color, #power_up_color, #process_character, #process_draw_icon, #process_escape_character, #process_new_line, #process_new_page, #process_normal_character, #reset_font_settings, #show, #standard_padding, #system_color, #text_color, #text_size, #tp_color, #tp_cost_color, #tp_gauge_color1, #tp_gauge_color2, #translucent_alpha, #update, #update_close, #update_open, #update_padding, #update_tone
Constructor Details
#initialize(edit_window) ⇒ Window_NameInput
-
Object Initialization
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 62 def initialize(edit_window) super(edit_window.x, edit_window.y + edit_window.height + 8, edit_window.width, fitting_height(9)) @edit_window = edit_window @page = 0 @index = 0 refresh update_cursor activate end |
Instance Method Details
#character ⇒ Object
-
Get Text Character
82 83 84 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 82 def character @index < 88 ? table[@page][@index] : "" end |
#cursor_down(wrap) ⇒ Object
-
Move Cursor Down
wrap : Wraparound allowed
132 133 134 135 136 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 132 def cursor_down(wrap) if @index < 80 or wrap @index = (index + 10) % 90 end end |
#cursor_left(wrap) ⇒ Object
-
Move Cursor Left
wrap : Wraparound allowed
161 162 163 164 165 166 167 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 161 def cursor_left(wrap) if @index % 10 > 0 @index -= 1 elsif wrap @index += 9 end end |
#cursor_movable? ⇒ Boolean
-
Determine if Cursor is Moveable
125 126 127 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 125 def cursor_movable? active end |
#cursor_pagedown ⇒ Object
-
Move to Next Page
171 172 173 174 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 171 def cursor_pagedown @page = (@page + 1) % table.size refresh end |
#cursor_pageup ⇒ Object
-
Move to Previous Page
178 179 180 181 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 178 def cursor_pageup @page = (@page + table.size - 1) % table.size refresh end |
#cursor_right(wrap) ⇒ Object
-
Move Cursor Right
wrap : Wraparound allowed
150 151 152 153 154 155 156 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 150 def cursor_right(wrap) if @index % 10 < 9 @index += 1 elsif wrap @index -= 9 end end |
#cursor_up(wrap) ⇒ Object
-
Move Cursor Up
wrap : Wraparound allowed
141 142 143 144 145 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 141 def cursor_up(wrap) if @index >= 10 or wrap @index = (index + 80) % 90 end end |
#is_ok? ⇒ Boolean
-
Determine Cursor Location: Confirmation
94 95 96 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 94 def is_ok? @index == 89 end |
#is_page_change? ⇒ Boolean
-
Determining if Page Changed and Cursor Location
88 89 90 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 88 def is_page_change? @index == 88 end |
#item_rect(index) ⇒ Object
-
Get Rectangle for Displaying Item
100 101 102 103 104 105 106 107 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 100 def item_rect(index) rect = Rect.new rect.x = index % 10 * 32 + index % 10 / 5 * 16 rect.y = index / 10 * line_height rect.width = 32 rect.height = line_height rect end |
#on_name_add ⇒ Object
-
Add Text to Name
231 232 233 234 235 236 237 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 231 def on_name_add if @edit_window.add(character) Sound.play_ok else Sound.play_buzzer end end |
#on_name_ok ⇒ Object
-
Decide Name
241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 241 def on_name_ok if @edit_window.name.empty? if @edit_window.restore_default Sound.play_ok else Sound.play_buzzer end else Sound.play_ok call_ok_handler end end |
#process_back ⇒ Object
-
Go Back One Character
212 213 214 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 212 def process_back Sound.play_cancel if @edit_window.back end |
#process_cursor_move ⇒ Object
-
Cursor Movement Processing
185 186 187 188 189 190 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 185 def process_cursor_move last_page = @page super update_cursor Sound.play_cursor if @page != last_page end |
#process_handling ⇒ Object
-
Handling Processing for OK and Cancel Etc.
194 195 196 197 198 199 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 194 def process_handling return unless open? && active process_jump if Input.trigger?(:A) process_back if Input.repeat?(:B) process_ok if Input.trigger?(:C) end |
#process_jump ⇒ Object
-
Jump to OK
203 204 205 206 207 208 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 203 def process_jump if @index != 89 @index = 89 Sound.play_cursor end end |
#process_ok ⇒ Object
-
Processing When OK Button Is Pressed
218 219 220 221 222 223 224 225 226 227 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 218 def process_ok if !character.empty? on_name_add elsif is_page_change? Sound.play_ok cursor_pagedown elsif is_ok? on_name_ok end end |
#refresh ⇒ Object
-
Refresh
111 112 113 114 115 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 111 def refresh contents.clear change_color(normal_color) 90.times {|i| draw_text(item_rect(i), table[@page][i], 1) } end |
#table ⇒ Object
-
Get Text Table
75 76 77 78 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 75 def table return [JAPAN1, JAPAN2, JAPAN3] if $game_system.japanese? return [LATIN1, LATIN2] end |
#update_cursor ⇒ Object
-
Update Cursor
119 120 121 |
# File 'lib/rgss3_default_scripts/Window_NameInput.rb', line 119 def update_cursor cursor_rect.set(item_rect(@index)) end |