Class: Window_NameEdit
- Inherits:
-
Window_Base
- Object
- Window
- Window_Base
- Window_NameEdit
- Defined in:
- lib/rgss3_default_scripts/Window_NameEdit.rb
Overview
** Window_NameEdit
This window is used to edit an actor's name on the name input screen.
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
cursor position.
-
#max_char ⇒ Object
readonly
maximum number of characters.
-
#name ⇒ Object
readonly
————————————————————————– * Public Instance Variables ————————————————————————–.
Instance Method Summary collapse
-
#add(ch) ⇒ Object
————————————————————————– * Add Text Character ch : character to add ————————————————————————–.
-
#back ⇒ Object
————————————————————————– * Go Back One Character ————————————————————————–.
-
#char_width ⇒ Object
————————————————————————– * Get Character Width ————————————————————————–.
-
#draw_char(index) ⇒ Object
————————————————————————– * Draw Text ————————————————————————–.
-
#draw_underline(index) ⇒ Object
————————————————————————– * Draw Underline ————————————————————————–.
-
#face_width ⇒ Object
————————————————————————– * Get Width of Face Graphic ————————————————————————–.
-
#initialize(actor, max_char) ⇒ Window_NameEdit
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#item_rect(index) ⇒ Object
————————————————————————– * Get Rectangle for Displaying Item ————————————————————————–.
-
#left ⇒ Object
————————————————————————– * Get Coordinates of Left Side for Drawing Name ————————————————————————–.
-
#refresh ⇒ Object
————————————————————————– * Refresh ————————————————————————–.
-
#restore_default ⇒ Object
————————————————————————– * Revert to Default Name ————————————————————————–.
-
#underline_color ⇒ Object
————————————————————————– * Get Underline Color ————————————————————————–.
-
#underline_rect(index) ⇒ Object
————————————————————————– * Get Underline Rectangle ————————————————————————–.
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(actor, max_char) ⇒ Window_NameEdit
-
Object Initialization
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 17 def initialize(actor, max_char) x = (Graphics.width - 360) / 2 y = (Graphics.height - (fitting_height(4) + fitting_height(9) + 8)) / 2 super(x, y, 360, fitting_height(4)) @actor = actor @max_char = max_char @default_name = @name = actor.name[0, @max_char] @index = @name.size deactivate refresh end |
Instance Attribute Details
#index ⇒ Object (readonly)
cursor position
12 13 14 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 12 def index @index end |
#max_char ⇒ Object (readonly)
maximum number of characters
13 14 15 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 13 def max_char @max_char end |
#name ⇒ Object (readonly)
-
Public Instance Variables
11 12 13 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 11 def name @name end |
Instance Method Details
#add(ch) ⇒ Object
-
Add Text Character
ch : character to add
41 42 43 44 45 46 47 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 41 def add(ch) return false if @index >= @max_char @name += ch @index += 1 refresh return true end |
#back ⇒ Object
-
Go Back One Character
51 52 53 54 55 56 57 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 51 def back return false if @index == 0 @index -= 1 @name = @name[0, @index] refresh return true end |
#char_width ⇒ Object
-
Get Character Width
67 68 69 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 67 def char_width text_size($game_system.japanese? ? "あ" : "A").width end |
#draw_char(index) ⇒ Object
-
Draw Text
112 113 114 115 116 117 118 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 112 def draw_char(index) rect = item_rect(index) rect.x -= 1 rect.width += 4 change_color(normal_color) draw_text(rect, @name[index] || "") end |
#draw_underline(index) ⇒ Object
-
Draw Underline
106 107 108 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 106 def draw_underline(index) contents.fill_rect(underline_rect(index), underline_color) end |
#face_width ⇒ Object
-
Get Width of Face Graphic
61 62 63 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 61 def face_width return 96 end |
#item_rect(index) ⇒ Object
-
Get Rectangle for Displaying Item
81 82 83 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 81 def item_rect(index) Rect.new(left + index * char_width, 36, char_width, line_height) end |
#left ⇒ Object
-
Get Coordinates of Left Side for Drawing Name
73 74 75 76 77 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 73 def left name_center = (contents_width + face_width) / 2 name_width = (@max_char + 1) * char_width return [name_center - name_width / 2, contents_width - name_width].min end |
#refresh ⇒ Object
-
Refresh
122 123 124 125 126 127 128 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 122 def refresh contents.clear draw_actor_face(@actor, 0, 0) @max_char.times {|i| draw_underline(i) } @name.size.times {|i| draw_char(i) } cursor_rect.set(item_rect(@index)) end |
#restore_default ⇒ Object
-
Revert to Default Name
31 32 33 34 35 36 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 31 def restore_default @name = @default_name @index = @name.size refresh return !@name.empty? end |
#underline_color ⇒ Object
-
Get Underline Color
98 99 100 101 102 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 98 def underline_color color = normal_color color.alpha = 48 color end |
#underline_rect(index) ⇒ Object
-
Get Underline Rectangle
87 88 89 90 91 92 93 94 |
# File 'lib/rgss3_default_scripts/Window_NameEdit.rb', line 87 def underline_rect(index) rect = item_rect(index) rect.x += 1 rect.y += rect.height - 4 rect.width -= 2 rect.height = 2 rect end |