Class: Scene_File

Inherits:
Scene_MenuBase show all
Defined in:
Scene_File.rb

Overview

** Scene_File


This class performs common processing for the save screen and load screen.

Direct Known Subclasses

Scene_Load, Scene_Save

Instance Method Summary (collapse)

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

- (Object) bottom_index


  • Get Bottom Index




120
121
122
# File 'Scene_File.rb', line 120

def bottom_index
  top_index + visible_max - 1
end

- (Object) bottom_index=(index)


  • Set Bottom Index




126
127
128
# File 'Scene_File.rb', line 126

def bottom_index=(index)
  self.top_index = index - (visible_max - 1)
end

- (Object) create_help_window


  • Create Help Window




37
38
39
40
# File 'Scene_File.rb', line 37

def create_help_window
  @help_window = Window_Help.new(1)
  @help_window.set_text(help_window_text)
end

- (Object) create_savefile_viewport


  • Create Save File Viewport




50
51
52
53
54
# File 'Scene_File.rb', line 50

def create_savefile_viewport
  @savefile_viewport = Viewport.new
  @savefile_viewport.rect.y = @help_window.height
  @savefile_viewport.rect.height -= @help_window.height
end

- (Object) create_savefile_windows


  • Create Save File Window




58
59
60
61
62
63
# File '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.viewport = @savefile_viewport }
end

- (Object) cursor_down(wrap)


  • Move Cursor Down




167
168
169
170
# File 'Scene_File.rb', line 167

def cursor_down(wrap)
  @index = (@index + 1) % item_max if @index < item_max - 1 || wrap
  ensure_cursor_visible
end

- (Object) cursor_pagedown


  • Move Cursor One Page Down




181
182
183
184
185
186
# File '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

- (Object) cursor_pageup


  • Move Cursor One Page Up




190
191
192
193
194
195
# File '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

- (Object) cursor_up(wrap)


  • Move Cursor Up




174
175
176
177
# File 'Scene_File.rb', line 174

def cursor_up(wrap)
  @index = (@index - 1 + item_max) % item_max if @index > 0 || wrap
  ensure_cursor_visible
end

- (Object) ensure_cursor_visible


  • Scroll Cursor to Position Within Screen




199
200
201
202
# File '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

- (Object) first_savefile_index


  • Get File Index to Select First




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

def first_savefile_index
  return 0
end

- (Object) help_window_text


  • Get Help Window Text




44
45
46
# File 'Scene_File.rb', line 44

def help_window_text
  return ""
end

- (Object) index


  • Get Current Index




100
101
102
# File 'Scene_File.rb', line 100

def index
  @index
end

- (Object) init_selection


  • Initialize Selection State




67
68
69
70
71
72
# File '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

- (Object) item_max


  • Get Number of Items




76
77
78
# File 'Scene_File.rb', line 76

def item_max
  DataManager.savefile_max
end

- (Object) on_savefile_cancel


  • Save File [Cancel]




145
146
147
148
# File 'Scene_File.rb', line 145

def on_savefile_cancel
  Sound.play_cancel
  return_scene
end

- (Object) on_savefile_ok


  • Save File [OK]




140
141
# File 'Scene_File.rb', line 140

def on_savefile_ok
end

- (Object) savefile_height


  • Get Height of Save File Window




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

def savefile_height
  @savefile_viewport.rect.height / visible_max
end

- (Object) start


  • Start Processing




11
12
13
14
15
16
17
# File 'Scene_File.rb', line 11

def start
  super
  create_help_window
  create_savefile_viewport
  create_savefile_windows
  init_selection
end

- (Object) terminate


  • Termination Processing




21
22
23
24
25
# File 'Scene_File.rb', line 21

def terminate
  super
  @savefile_viewport.dispose
  @savefile_windows.each {|window| window.dispose }
end

- (Object) top_index


  • Get Top Index




106
107
108
# File 'Scene_File.rb', line 106

def top_index
  @savefile_viewport.oy / savefile_height
end

- (Object) top_index=(index)


  • Set Top Index




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

- (Object) update


  • Frame Update




29
30
31
32
33
# File 'Scene_File.rb', line 29

def update
  super
  @savefile_windows.each {|window| window.update }
  update_savefile_selection
end

- (Object) update_cursor


  • Update Cursor




152
153
154
155
156
157
158
159
160
161
162
163
# File '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

- (Object) update_savefile_selection


  • Update Save File Selection




132
133
134
135
136
# File '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

- (Object) visible_max


  • Get Number of Save Files to Show on Screen




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

def visible_max
  return 4
end