Home > RGSS Script Reference > Scene_Name
Scene_Name
Inherits from: None
Description: This class handles the "Enter Hero Name" screen.
class Scene_Name
# ------------------------------------
def main
@actor = $game_actors[$game_temp.name_actor_id]
@edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
@input_window = Window_NameInput.new
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@edit_window.dispose
@input_window.dispose
end
# ------------------------------------
def update
@edit_window.update
@input_window.update
if Input.repeat?(Input::B)
if @edit_window.index == 0
return
end
$game_system.se_play($data_system.cancel_se)
@edit_window.back
return
end
if Input.trigger?(Input::C)
if @input_window.character == nil
if @edit_window.name == ""
@edit_window.restore_default
if @edit_window.name == ""
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
return
end
@actor.name = @edit_window.name
$game_system.se_play($data_system.decision_se)
$scene = Scene_Map.new
return
end
if @edit_window.index == $game_temp.name_max_char
$game_system.se_play($data_system.buzzer_se)
return
end
if @input_window.character == ""
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@edit_window.add(@input_window.character)
return
end
end
end
|
Actor: The actor whose name is being entered.
Edit_Window: A Window_NameEdit object that shows the name that's been entered so far.
Input_Window: A Window_NameInput object window that contains the name input window.
Main
Arguments: None
Local Variables: None
How it Works: This is the main method for this class. The first part of the method identifies the actor whose name is being changed and sets up the name edit and name entry windows. The next part of the method is the main loop seen in every "Scene" method. The graphics are updated, the engine checks for updated input, and the window contents are updated. This continues until the value of $Scene changes (in this case, because the user entered a name). Once this happens, the rest of the method disposes of the two window objects.
Update
Arguments: None
Local Variables: None
How it Works: This window updates the contents of the two windows and makes them respond to user input. First, the contents of the two windows are updated. Then, the current input is checked. If the user's input is "B" (cancel key), then it checks to see what the index of the edit window is (in this case, the index is the number of characters that have been entered). If the index is 0, the method does nothing and returns. If the index is 1 or more, then the cancel sound effect is played and the Window_NameEdit#Back method is called to backspace the name edit window one space. If the user's input is "C" (decision key), then it checks to see if the character selected in the name entry window is nil (the "done" option has this value). If the user hasn't entered a name at all, and a default name has been specified, then the default name is restored. If there is no default name, the buzzer sound effect is played. If the user has entered a name that is at least one character long, the actor's name is assigned the name entered in the name edit window and control is transferred back to the map. If the number of characters entered is equal to the maximum number of characters specified in the event command, the buzzer sound effect plays. Finally, if a valid character is selected, the Window_NameEdit#Add method is called to add that character to the name being constructed.
|
|