Class: Window_NameInput

Inherits:
Window_Selectable show all
Defined in:
Window_NameInput.rb

Overview

** Window_NameInput


This window is used to select text characters on the name input screen.

Constant Summary

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 =
[ '','','','','',  '','','','','',
'','','','','',  '','','','','',
'','','','','',  '','','','','',
'','','','','',  '','','','','',
'','','','','',  '','','','','',
'','','','','_',  '','','','','',
'','','','','',  '','','','','',
'','','','','',  '','','','','',
'','','','','',  '','',' ','かな','決定']

Instance Attribute Summary

Attributes inherited from Window_Selectable

#cursor_all, #cursor_fix, #help_window, #index

Instance Method Summary (collapse)

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

- (Window_NameInput) initialize(edit_window)


  • Object Initialization




62
63
64
65
66
67
68
69
70
71
# File '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

- (Object) character


  • Get Text Character




82
83
84
# File 'Window_NameInput.rb', line 82

def character
  @index < 88 ? table[@page][@index] : ""
end

- (Object) cursor_down(wrap)


  • Move Cursor Down

    wrap : Wraparound allowed



132
133
134
135
136
# File 'Window_NameInput.rb', line 132

def cursor_down(wrap)
  if @index < 80 or wrap
    @index = (index + 10) % 90
  end
end

- (Object) cursor_left(wrap)


  • Move Cursor Left

    wrap : Wraparound allowed



161
162
163
164
165
166
167
# File 'Window_NameInput.rb', line 161

def cursor_left(wrap)
  if @index % 10 > 0
    @index -= 1
  elsif wrap
    @index += 9
  end
end

- (Boolean) cursor_movable?


  • Determine if Cursor is Moveable


Returns:

  • (Boolean)


125
126
127
# File 'Window_NameInput.rb', line 125

def cursor_movable?
  active
end

- (Object) cursor_pagedown


  • Move to Next Page




171
172
173
174
# File 'Window_NameInput.rb', line 171

def cursor_pagedown
  @page = (@page + 1) % table.size
  refresh
end

- (Object) cursor_pageup


  • Move to Previous Page




178
179
180
181
# File 'Window_NameInput.rb', line 178

def cursor_pageup
  @page = (@page + table.size - 1) % table.size
  refresh
end

- (Object) cursor_right(wrap)


  • Move Cursor Right

    wrap : Wraparound allowed



150
151
152
153
154
155
156
# File 'Window_NameInput.rb', line 150

def cursor_right(wrap)
  if @index % 10 < 9
    @index += 1
  elsif wrap
    @index -= 9
  end
end

- (Object) cursor_up(wrap)


  • Move Cursor Up

    wrap : Wraparound allowed



141
142
143
144
145
# File 'Window_NameInput.rb', line 141

def cursor_up(wrap)
  if @index >= 10 or wrap
    @index = (index + 80) % 90
  end
end

- (Boolean) is_ok?


  • Determine Cursor Location: Confirmation


Returns:

  • (Boolean)


94
95
96
# File 'Window_NameInput.rb', line 94

def is_ok?
  @index == 89
end

- (Boolean) is_page_change?


  • Determining if Page Changed and Cursor Location


Returns:

  • (Boolean)


88
89
90
# File 'Window_NameInput.rb', line 88

def is_page_change?
  @index == 88
end

- (Object) item_rect(index)


  • Get Rectangle for Displaying Item




100
101
102
103
104
105
106
107
# File '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

- (Object) on_name_add


  • Add Text to Name




231
232
233
234
235
236
237
# File 'Window_NameInput.rb', line 231

def on_name_add
  if @edit_window.add(character)
    Sound.play_ok
  else
    Sound.play_buzzer
  end
end

- (Object) on_name_ok


  • Decide Name




241
242
243
244
245
246
247
248
249
250
251
252
# File '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

- (Object) process_back


  • Go Back One Character




212
213
214
# File 'Window_NameInput.rb', line 212

def process_back
  Sound.play_cancel if @edit_window.back
end

- (Object) process_cursor_move


  • Cursor Movement Processing




185
186
187
188
189
190
# File 'Window_NameInput.rb', line 185

def process_cursor_move
  last_page = @page
  super
  update_cursor
  Sound.play_cursor if @page != last_page
end

- (Object) process_handling


  • Handling Processing for OK and Cancel Etc.




194
195
196
197
198
199
# File '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

- (Object) process_jump


  • Jump to OK




203
204
205
206
207
208
# File 'Window_NameInput.rb', line 203

def process_jump
  if @index != 89
    @index = 89
    Sound.play_cursor
  end
end

- (Object) process_ok


  • Processing When OK Button Is Pressed




218
219
220
221
222
223
224
225
226
227
# File '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

- (Object) refresh


  • Refresh




111
112
113
114
115
# File '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

- (Object) table


  • Get Text Table




75
76
77
78
# File 'Window_NameInput.rb', line 75

def table
  return [JAPAN1, JAPAN2, JAPAN3] if $game_system.japanese?
  return [LATIN1, LATIN2]
end

- (Object) update_cursor


  • Update Cursor




119
120
121
# File 'Window_NameInput.rb', line 119

def update_cursor
  cursor_rect.set(item_rect(@index))
end