Class: Window_Selectable
- Inherits:
-
Window_Base
- Object
- Window
- Window_Base
- Window_Selectable
- Defined in:
- lib/rgss3_default_scripts/Window_Selectable.rb
Overview
** Window_Selectable
This window class contains cursor movement and scroll functions.
Direct Known Subclasses
Window_BattleEnemy, Window_BattleLog, Window_BattleStatus, Window_Command, Window_DebugLeft, Window_DebugRight, Window_EquipSlot, Window_ItemList, Window_MenuStatus, Window_NameInput, Window_ShopBuy, Window_ShopNumber, Window_SkillList, Window_Status
Instance Attribute Summary collapse
-
#cursor_all ⇒ Object
select all cursors flag.
-
#cursor_fix ⇒ Object
fix cursor flag.
-
#help_window ⇒ Object
help window.
-
#index ⇒ Object
————————————————————————– * Public Instance Variables ————————————————————————–.
Instance Method Summary collapse
-
#active=(active) ⇒ Object
————————————————————————– * Change Active State ————————————————————————–.
-
#bottom_row ⇒ Object
————————————————————————– * Get Bottom Row ————————————————————————–.
-
#bottom_row=(row) ⇒ Object
————————————————————————– * Set Bottom Row ————————————————————————–.
-
#call_cancel_handler ⇒ Object
————————————————————————– * Call Cancel Handler ————————————————————————–.
-
#call_handler(symbol) ⇒ Object
————————————————————————– * Call Handler ————————————————————————–.
-
#call_ok_handler ⇒ Object
————————————————————————– * Call OK Handler ————————————————————————–.
-
#call_update_help ⇒ Object
————————————————————————– * Call Help Window Update Method ————————————————————————–.
-
#cancel_enabled? ⇒ Boolean
————————————————————————– * Get Activation State of Cancel Processing ————————————————————————–.
-
#clear_item(index) ⇒ Object
————————————————————————– * Erase Item ————————————————————————–.
-
#col_max ⇒ Object
————————————————————————– * Get Digit Count ————————————————————————–.
-
#contents_height ⇒ Object
————————————————————————– * Calculate Height of Window Contents ————————————————————————–.
-
#current_item_enabled? ⇒ Boolean
————————————————————————– * Get Activation State of Selection Item ————————————————————————–.
-
#cursor_down(wrap = false) ⇒ Object
————————————————————————– * Move Cursor Down ————————————————————————–.
-
#cursor_left(wrap = false) ⇒ Object
————————————————————————– * Move Cursor Left ————————————————————————–.
-
#cursor_movable? ⇒ Boolean
————————————————————————– * Determine if Cursor is Moveable ————————————————————————–.
-
#cursor_pagedown ⇒ Object
————————————————————————– * Move Cursor One Page Down ————————————————————————–.
-
#cursor_pageup ⇒ Object
————————————————————————– * Move Cursor One Page Up ————————————————————————–.
-
#cursor_right(wrap = false) ⇒ Object
————————————————————————– * Move Cursor Right ————————————————————————–.
-
#cursor_up(wrap = false) ⇒ Object
————————————————————————– * Move Cursor Up ————————————————————————–.
-
#draw_all_items ⇒ Object
————————————————————————– * Draw All Items ————————————————————————–.
-
#draw_item(index) ⇒ Object
————————————————————————– * Draw Item ————————————————————————–.
-
#ensure_cursor_visible ⇒ Object
————————————————————————– * Scroll Cursor to Position Within Screen ————————————————————————–.
-
#handle?(symbol) ⇒ Boolean
————————————————————————– * Check for Handler Existence ————————————————————————–.
-
#height=(height) ⇒ Object
————————————————————————– * Set Height ————————————————————————–.
-
#horizontal? ⇒ Boolean
————————————————————————– * Determine Horizontal Selection ————————————————————————–.
-
#initialize(x, y, width, height) ⇒ Window_Selectable
constructor
————————————————————————– * Object Initialization ————————————————————————-.
-
#item_height ⇒ Object
————————————————————————– * Get Item Height ————————————————————————–.
-
#item_max ⇒ Object
————————————————————————– * Get Number of Items ————————————————————————–.
-
#item_rect(index) ⇒ Object
————————————————————————– * Get Rectangle for Drawing Items ————————————————————————–.
-
#item_rect_for_text(index) ⇒ Object
————————————————————————– * Get Rectangle for Drawing Items (for Text) ————————————————————————–.
-
#item_width ⇒ Object
————————————————————————– * Get Item Width ————————————————————————–.
-
#ok_enabled? ⇒ Boolean
————————————————————————– * Get Activation State of OK Processing ————————————————————————–.
-
#page_item_max ⇒ Object
————————————————————————– * Get Number of Items Displayable on 1 Page ————————————————————————–.
-
#page_row_max ⇒ Object
————————————————————————– * Get Number of Rows Displayable on 1 Page ————————————————————————–.
-
#process_cancel ⇒ Object
————————————————————————– * Processing When Cancel Button Is Pressed ————————————————————————–.
-
#process_cursor_move ⇒ Object
————————————————————————– * Cursor Movement Processing ————————————————————————–.
-
#process_handling ⇒ Object
————————————————————————– * Handling Processing for OK and Cancel Etc.
-
#process_ok ⇒ Object
————————————————————————– * Processing When OK Button Is Pressed ————————————————————————–.
-
#process_pagedown ⇒ Object
————————————————————————– * Processing When R Button (Page Down) Is Pressed ————————————————————————–.
-
#process_pageup ⇒ Object
————————————————————————– * Processing When L Button (Page Up) Is Pressed ————————————————————————–.
-
#redraw_current_item ⇒ Object
————————————————————————– * Redraw Selection Item ————————————————————————–.
-
#redraw_item(index) ⇒ Object
————————————————————————– * Redraw Item ————————————————————————–.
-
#refresh ⇒ Object
————————————————————————– * Refresh ————————————————————————–.
-
#row ⇒ Object
————————————————————————– * Get Current Line ————————————————————————–.
-
#row_max ⇒ Object
————————————————————————– * Get Row Count ————————————————————————–.
-
#select(index) ⇒ Object
————————————————————————– * Select Item ————————————————————————–.
-
#set_handler(symbol, method) ⇒ Object
————————————————————————– * Set Handler Corresponding to Operation method : Method set as a handler (Method object) ————————————————————————–.
-
#spacing ⇒ Object
————————————————————————– * Get Spacing for Items Arranged Side by Side ————————————————————————–.
-
#top_row ⇒ Object
————————————————————————– * Get Top Row ————————————————————————–.
-
#top_row=(row) ⇒ Object
————————————————————————– * Set Top Row ————————————————————————–.
-
#unselect ⇒ Object
————————————————————————– * Deselect Item ————————————————————————–.
-
#update ⇒ Object
————————————————————————– * Frame Update ————————————————————————–.
-
#update_cursor ⇒ Object
————————————————————————– * Update Cursor ————————————————————————–.
-
#update_help ⇒ Object
————————————————————————– * Update Help Window ————————————————————————–.
-
#update_padding ⇒ Object
————————————————————————– * Update Padding ————————————————————————–.
-
#update_padding_bottom ⇒ Object
————————————————————————– * Update Bottom Padding ————————————————————————–.
Methods inherited from Window_Base
#activate, #actor_name, #calc_line_height, #change_color, #close, #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_close, #update_open, #update_tone
Constructor Details
#initialize(x, y, width, height) ⇒ Window_Selectable
-
Object Initialization
18 19 20 21 22 23 24 25 26 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 18 def initialize(x, y, width, height) super @index = -1 @handler = {} @cursor_fix = false @cursor_all = false update_padding deactivate end |
Instance Attribute Details
#cursor_all ⇒ Object
select all cursors flag
14 15 16 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 14 def cursor_all @cursor_all end |
#cursor_fix ⇒ Object
fix cursor flag
13 14 15 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 13 def cursor_fix @cursor_fix end |
#help_window ⇒ Object
help window
12 13 14 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 12 def help_window @help_window end |
#index ⇒ Object
-
Public Instance Variables
11 12 13 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 11 def index @index end |
Instance Method Details
#active=(active) ⇒ Object
-
Change Active State
93 94 95 96 97 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 93 def active=(active) super update_cursor call_update_help end |
#bottom_row ⇒ Object
-
Get Bottom Row
159 160 161 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 159 def bottom_row top_row + page_row_max - 1 end |
#bottom_row=(row) ⇒ Object
-
Set Bottom Row
165 166 167 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 165 def bottom_row=(row) self.top_row = row - (page_row_max - 1) end |
#call_cancel_handler ⇒ Object
-
Call Cancel Handler
345 346 347 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 345 def call_cancel_handler call_handler(:cancel) end |
#call_handler(symbol) ⇒ Object
-
Call Handler
211 212 213 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 211 def call_handler(symbol) @handler[symbol].call if handle?(symbol) end |
#call_ok_handler ⇒ Object
-
Call OK Handler
330 331 332 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 330 def call_ok_handler call_handler(:ok) end |
#call_update_help ⇒ Object
-
Call Help Window Update Method
390 391 392 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 390 def call_update_help update_help if active && @help_window end |
#cancel_enabled? ⇒ Boolean
-
Get Activation State of Cancel Processing
311 312 313 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 311 def cancel_enabled? handle?(:cancel) end |
#clear_item(index) ⇒ Object
-
Erase Item
419 420 421 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 419 def clear_item(index) contents.clear_rect(item_rect(index)) end |
#col_max ⇒ Object
-
Get Digit Count
30 31 32 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 30 def col_max return 1 end |
#contents_height ⇒ Object
-
Calculate Height of Window Contents
66 67 68 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 66 def contents_height [super - super % item_height, row_max * item_height].max end |
#current_item_enabled? ⇒ Boolean
-
Get Activation State of Selection Item
402 403 404 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 402 def current_item_enabled? return true end |
#cursor_down(wrap = false) ⇒ Object
-
Move Cursor Down
223 224 225 226 227 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 223 def cursor_down(wrap = false) if index < item_max - col_max || (wrap && col_max == 1) select((index + col_max) % item_max) end end |
#cursor_left(wrap = false) ⇒ Object
-
Move Cursor Left
247 248 249 250 251 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 247 def cursor_left(wrap = false) if col_max >= 2 && (index > 0 || (wrap && horizontal?)) select((index - 1 + item_max) % item_max) end end |
#cursor_movable? ⇒ Boolean
-
Determine if Cursor is Moveable
217 218 219 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 217 def cursor_movable? active && open? && !@cursor_fix && !@cursor_all && item_max > 0 end |
#cursor_pagedown ⇒ Object
-
Move Cursor One Page Down
255 256 257 258 259 260 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 255 def cursor_pagedown if top_row + page_row_max < row_max self.top_row += page_row_max select([@index + page_item_max, item_max - 1].min) end end |
#cursor_pageup ⇒ Object
-
Move Cursor One Page Up
264 265 266 267 268 269 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 264 def cursor_pageup if top_row > 0 self.top_row -= page_row_max select([@index - page_item_max, 0].max) end end |
#cursor_right(wrap = false) ⇒ Object
-
Move Cursor Right
239 240 241 242 243 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 239 def cursor_right(wrap = false) if col_max >= 2 && (index < item_max - 1 || (wrap && horizontal?)) select((index + 1) % item_max) end end |
#cursor_up(wrap = false) ⇒ Object
-
Move Cursor Up
231 232 233 234 235 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 231 def cursor_up(wrap = false) if index >= col_max || (wrap && col_max == 1) select((index - col_max + item_max) % item_max) end end |
#draw_all_items ⇒ Object
-
Draw All Items
408 409 410 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 408 def draw_all_items item_max.times {|i| draw_item(i) } end |
#draw_item(index) ⇒ Object
-
Draw Item
414 415 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 414 def draw_item(index) end |
#ensure_cursor_visible ⇒ Object
-
Scroll Cursor to Position Within Screen
383 384 385 386 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 383 def ensure_cursor_visible self.top_row = row if row < top_row self.bottom_row = row if row > bottom_row end |
#handle?(symbol) ⇒ Boolean
-
Check for Handler Existence
205 206 207 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 205 def handle?(symbol) @handler.include?(symbol) end |
#height=(height) ⇒ Object
-
Set Height
86 87 88 89 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 86 def height=(height) super update_padding end |
#horizontal? ⇒ Boolean
-
Determine Horizontal Selection
153 154 155 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 153 def horizontal? page_row_max == 1 end |
#item_height ⇒ Object
-
Get Item Height
54 55 56 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 54 def item_height line_height end |
#item_max ⇒ Object
-
Get Number of Items
42 43 44 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 42 def item_max return 0 end |
#item_rect(index) ⇒ Object
-
Get Rectangle for Drawing Items
171 172 173 174 175 176 177 178 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 171 def item_rect(index) rect = Rect.new rect.width = item_width rect.height = item_height rect.x = index % col_max * (item_width + spacing) rect.y = index / col_max * item_height rect end |
#item_rect_for_text(index) ⇒ Object
-
Get Rectangle for Drawing Items (for Text)
182 183 184 185 186 187 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 182 def item_rect_for_text(index) rect = item_rect(index) rect.x += 4 rect.width -= 8 rect end |
#item_width ⇒ Object
-
Get Item Width
48 49 50 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 48 def item_width (width - standard_padding * 2 + spacing) / col_max - spacing end |
#ok_enabled? ⇒ Boolean
-
Get Activation State of OK Processing
305 306 307 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 305 def ok_enabled? handle?(:ok) end |
#page_item_max ⇒ Object
-
Get Number of Items Displayable on 1 Page
147 148 149 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 147 def page_item_max page_row_max * col_max end |
#page_row_max ⇒ Object
-
Get Number of Rows Displayable on 1 Page
141 142 143 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 141 def page_row_max (height - padding - padding_bottom) / item_height end |
#process_cancel ⇒ Object
-
Processing When Cancel Button Is Pressed
336 337 338 339 340 341 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 336 def process_cancel Sound.play_cancel Input.update deactivate call_cancel_handler end |
#process_cursor_move ⇒ Object
-
Cursor Movement Processing
281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 281 def process_cursor_move return unless cursor_movable? last_index = @index cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN) cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP) cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT) cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT) cursor_pagedown if !handle?(:pagedown) && Input.trigger?(:R) cursor_pageup if !handle?(:pageup) && Input.trigger?(:L) Sound.play_cursor if @index != last_index end |
#process_handling ⇒ Object
-
Handling Processing for OK and Cancel Etc.
295 296 297 298 299 300 301 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 295 def process_handling return unless open? && active return process_ok if ok_enabled? && Input.trigger?(:C) return process_cancel if cancel_enabled? && Input.trigger?(:B) return process_pagedown if handle?(:pagedown) && Input.trigger?(:R) return process_pageup if handle?(:pageup) && Input.trigger?(:L) end |
#process_ok ⇒ Object
-
Processing When OK Button Is Pressed
317 318 319 320 321 322 323 324 325 326 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 317 def process_ok if current_item_enabled? Sound.play_ok Input.update deactivate call_ok_handler else Sound.play_buzzer end end |
#process_pagedown ⇒ Object
-
Processing When R Button (Page Down) Is Pressed
360 361 362 363 364 365 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 360 def process_pagedown Sound.play_cursor Input.update deactivate call_handler(:pagedown) end |
#process_pageup ⇒ Object
-
Processing When L Button (Page Up) Is Pressed
351 352 353 354 355 356 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 351 def process_pageup Sound.play_cursor Input.update deactivate call_handler(:pageup) end |
#redraw_current_item ⇒ Object
-
Redraw Selection Item
432 433 434 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 432 def redraw_current_item redraw_item(@index) end |
#redraw_item(index) ⇒ Object
-
Redraw Item
425 426 427 428 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 425 def redraw_item(index) clear_item(index) if index >= 0 draw_item(index) if index >= 0 end |
#refresh ⇒ Object
-
Refresh
438 439 440 441 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 438 def refresh contents.clear draw_all_items end |
#row ⇒ Object
-
Get Current Line
121 122 123 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 121 def row index / col_max end |
#row_max ⇒ Object
-
Get Row Count
60 61 62 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 60 def row_max [(item_max + col_max - 1) / col_max, 1].max end |
#select(index) ⇒ Object
-
Select Item
109 110 111 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 109 def select(index) self.index = index if index end |
#set_handler(symbol, method) ⇒ Object
-
Set Handler Corresponding to Operation
method : Method set as a handler (Method object)
199 200 201 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 199 def set_handler(symbol, method) @handler[symbol] = method end |
#spacing ⇒ Object
-
Get Spacing for Items Arranged Side by Side
36 37 38 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 36 def spacing return 32 end |
#top_row ⇒ Object
-
Get Top Row
127 128 129 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 127 def top_row oy / item_height end |
#top_row=(row) ⇒ Object
-
Set Top Row
133 134 135 136 137 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 133 def top_row=(row) row = 0 if row < 0 row = row_max - 1 if row > row_max - 1 self.oy = row * item_height end |
#unselect ⇒ Object
-
Deselect Item
115 116 117 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 115 def unselect self.index = -1 end |
#update ⇒ Object
-
Frame Update
273 274 275 276 277 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 273 def update super process_cursor_move process_handling end |
#update_cursor ⇒ Object
-
Update Cursor
369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 369 def update_cursor if @cursor_all cursor_rect.set(0, 0, contents.width, row_max * item_height) self.top_row = 0 elsif @index < 0 cursor_rect.empty else ensure_cursor_visible cursor_rect.set(item_rect(@index)) end end |
#update_help ⇒ Object
-
Update Help Window
396 397 398 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 396 def update_help @help_window.clear end |
#update_padding ⇒ Object
-
Update Padding
72 73 74 75 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 72 def update_padding super update_padding_bottom end |
#update_padding_bottom ⇒ Object
-
Update Bottom Padding
79 80 81 82 |
# File 'lib/rgss3_default_scripts/Window_Selectable.rb', line 79 def update_padding_bottom surplus = (height - standard_padding * 2) % item_height self.padding_bottom = padding + surplus end |