Class: Scene_File
- Inherits:
-
Scene_MenuBase
- Object
- Scene_Base
- Scene_MenuBase
- Scene_File
- Defined in:
- lib/rgss3_default_scripts/Scene_File.rb
Overview
** Scene_File
This class performs common processing for the save screen and load screen.
Direct Known Subclasses
Instance Method Summary collapse
-
#bottom_index ⇒ Object
————————————————————————– * Get Bottom Index ————————————————————————–.
-
#bottom_index=(index) ⇒ Object
————————————————————————– * Set Bottom Index ————————————————————————–.
-
#create_help_window ⇒ Object
————————————————————————– * Create Help Window ————————————————————————–.
-
#create_savefile_viewport ⇒ Object
————————————————————————– * Create Save File Viewport ————————————————————————–.
-
#create_savefile_windows ⇒ Object
————————————————————————– * Create Save File Window ————————————————————————–.
-
#cursor_down(wrap) ⇒ Object
————————————————————————– * Move Cursor Down ————————————————————————–.
-
#cursor_pagedown ⇒ Object
————————————————————————– * Move Cursor One Page Down ————————————————————————–.
-
#cursor_pageup ⇒ Object
————————————————————————– * Move Cursor One Page Up ————————————————————————–.
-
#cursor_up(wrap) ⇒ Object
————————————————————————– * Move Cursor Up ————————————————————————–.
-
#ensure_cursor_visible ⇒ Object
————————————————————————– * Scroll Cursor to Position Within Screen ————————————————————————–.
-
#first_savefile_index ⇒ Object
————————————————————————– * Get File Index to Select First ————————————————————————–.
-
#help_window_text ⇒ Object
————————————————————————– * Get Help Window Text ————————————————————————–.
-
#index ⇒ Object
————————————————————————– * Get Current Index ————————————————————————–.
-
#init_selection ⇒ Object
————————————————————————– * Initialize Selection State ————————————————————————–.
-
#item_max ⇒ Object
————————————————————————– * Get Number of Items ————————————————————————–.
-
#on_savefile_cancel ⇒ Object
————————————————————————– * Save File [Cancel] ————————————————————————–.
-
#on_savefile_ok ⇒ Object
————————————————————————– * Save File [OK] ————————————————————————–.
-
#savefile_height ⇒ Object
————————————————————————– * Get Height of Save File Window ————————————————————————–.
-
#start ⇒ Object
————————————————————————– * Start Processing ————————————————————————–.
-
#terminate ⇒ Object
————————————————————————– * Termination Processing ————————————————————————–.
-
#top_index ⇒ Object
————————————————————————– * Get Top Index ————————————————————————–.
-
#top_index=(index) ⇒ Object
————————————————————————– * Set Top Index ————————————————————————–.
-
#update ⇒ Object
————————————————————————– * Frame Update ————————————————————————–.
-
#update_cursor ⇒ Object
————————————————————————– * Update Cursor ————————————————————————–.
-
#update_savefile_selection ⇒ Object
————————————————————————– * Update Save File Selection ————————————————————————–.
-
#visible_max ⇒ Object
————————————————————————– * Get Number of Save Files to Show on Screen ————————————————————————–.
Methods inherited from Scene_MenuBase
#create_background, #dispose_background, #next_actor, #on_actor_change, #prev_actor
Methods inherited from Scene_Base
#check_gameover, #create_main_viewport, #dispose_all_windows, #dispose_main_viewport, #fadeout_all, #main, #perform_transition, #post_start, #pre_terminate, #return_scene, #scene_changing?, #transition_speed, #update_all_windows, #update_basic
Instance Method Details
#bottom_index ⇒ Object
-
Get Bottom Index
120 121 122 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 120 def bottom_index top_index + visible_max - 1 end |
#bottom_index=(index) ⇒ Object
-
Set Bottom Index
126 127 128 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 126 def bottom_index=(index) self.top_index = index - (visible_max - 1) end |
#create_help_window ⇒ Object
-
Create Help Window
37 38 39 40 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 37 def create_help_window @help_window = Window_Help.new(1) @help_window.set_text(help_window_text) end |
#create_savefile_viewport ⇒ Object
-
Create Save File Viewport
50 51 52 53 54 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 50 def @savefile_viewport = Viewport.new @savefile_viewport.rect.y = @help_window.height @savefile_viewport.rect.height -= @help_window.height end |
#create_savefile_windows ⇒ Object
-
Create Save File Window
58 59 60 61 62 63 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 58 def create_savefile_windows @savefile_windows = Array.new(item_max) do |i| Window_SaveFile.new(savefile_height, i) end @savefile_windows.each {|window| window. = @savefile_viewport } end |
#cursor_down(wrap) ⇒ Object
-
Move Cursor Down
167 168 169 170 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 167 def cursor_down(wrap) @index = (@index + 1) % item_max if @index < item_max - 1 || wrap ensure_cursor_visible end |
#cursor_pagedown ⇒ Object
-
Move Cursor One Page Down
181 182 183 184 185 186 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 181 def cursor_pagedown if top_index + visible_max < item_max self.top_index += visible_max @index = [@index + visible_max, item_max - 1].min end end |
#cursor_pageup ⇒ Object
-
Move Cursor One Page Up
190 191 192 193 194 195 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 190 def cursor_pageup if top_index > 0 self.top_index -= visible_max @index = [@index - visible_max, 0].max end end |
#cursor_up(wrap) ⇒ Object
-
Move Cursor Up
174 175 176 177 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 174 def cursor_up(wrap) @index = (@index - 1 + item_max) % item_max if @index > 0 || wrap ensure_cursor_visible end |
#ensure_cursor_visible ⇒ Object
-
Scroll Cursor to Position Within Screen
199 200 201 202 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 199 def ensure_cursor_visible self.top_index = index if index < top_index self.bottom_index = index if index > bottom_index end |
#first_savefile_index ⇒ Object
-
Get File Index to Select First
94 95 96 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 94 def first_savefile_index return 0 end |
#help_window_text ⇒ Object
-
Get Help Window Text
44 45 46 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 44 def help_window_text return "" end |
#index ⇒ Object
-
Get Current Index
100 101 102 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 100 def index @index end |
#init_selection ⇒ Object
-
Initialize Selection State
67 68 69 70 71 72 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 67 def init_selection @index = first_savefile_index @savefile_windows[@index].selected = true self.top_index = @index - visible_max / 2 ensure_cursor_visible end |
#item_max ⇒ Object
-
Get Number of Items
76 77 78 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 76 def item_max DataManager.savefile_max end |
#on_savefile_cancel ⇒ Object
-
Save File [Cancel]
145 146 147 148 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 145 def on_savefile_cancel Sound.play_cancel return_scene end |
#on_savefile_ok ⇒ Object
-
Save File [OK]
140 141 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 140 def on_savefile_ok end |
#savefile_height ⇒ Object
-
Get Height of Save File Window
88 89 90 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 88 def savefile_height @savefile_viewport.rect.height / visible_max end |
#start ⇒ Object
-
Start Processing
11 12 13 14 15 16 17 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 11 def start super create_help_window create_savefile_windows init_selection end |
#terminate ⇒ Object
-
Termination Processing
21 22 23 24 25 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 21 def terminate super @savefile_viewport.dispose @savefile_windows.each {|window| window.dispose } end |
#top_index ⇒ Object
-
Get Top Index
106 107 108 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 106 def top_index @savefile_viewport.oy / savefile_height end |
#top_index=(index) ⇒ Object
-
Set Top Index
112 113 114 115 116 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 112 def top_index=(index) index = 0 if index < 0 index = item_max - visible_max if index > item_max - visible_max @savefile_viewport.oy = index * savefile_height end |
#update ⇒ Object
-
Frame Update
29 30 31 32 33 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 29 def update super @savefile_windows.each {|window| window.update } update_savefile_selection end |
#update_cursor ⇒ Object
-
Update Cursor
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 152 def update_cursor last_index = @index cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN) cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP) cursor_pagedown if Input.trigger?(:R) cursor_pageup if Input.trigger?(:L) if @index != last_index Sound.play_cursor @savefile_windows[last_index].selected = false @savefile_windows[@index].selected = true end end |
#update_savefile_selection ⇒ Object
-
Update Save File Selection
132 133 134 135 136 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 132 def update_savefile_selection return on_savefile_ok if Input.trigger?(:C) return on_savefile_cancel if Input.trigger?(:B) update_cursor end |
#visible_max ⇒ Object
-
Get Number of Save Files to Show on Screen
82 83 84 |
# File 'lib/rgss3_default_scripts/Scene_File.rb', line 82 def visible_max return 4 end |