Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Auteur: Zouzaka
- Requiert ce script de "Keroro" :
- http://www.rpg2s.net/forum/index.php/topic/14903-keyboard-input-v-30-by-keroro/
- =end
- class Scene_Note < Scene_MenuBase
- def start
- super
- @insert_title = false
- @insert_text = false
- creat_window
- end
- def update
- super
- insert_text_cmd
- update_notes
- end
- def creat_window
- @edition = Window_Editing.new(0,0)
- @note_list = Window_NoteList.new(0,@edition.height)
- @note_title = Window_NoteTitle.new(@note_list.width,@edition.height,Graphics.width-@note_list.width)
- @note_text = Window_NoteText.new(@note_list.width,@edition.height+@note_title.height,Graphics.width-@note_list.width,Graphics.height-(@edition.height+@note_title.height))
- @edition.set_handler(:add, method(:cmd_add))
- @edition.set_handler(:del, method(:cmd_del))
- @edition.set_handler(:exit, method(:return_scene))
- end
- def cmd_add
- @title = ""
- @text = ""
- @note_text.set_text("Appui sur Echap pour valider") if @text.empty?
- @note_title.set_text("Inserez Titre") if @title.empty?
- $game_note[:title] << "Inserez Titre"
- $game_note[:text] << "Inserez Text"
- @note_list.deactivate
- @insert_title = true
- end
- def cmd_del
- $game_note[:title].slice!(-1)
- $game_note[:text].slice!(-1)
- @edition.activate
- @note_list.refresh
- @note_list.height = @note_list.window_height unless @note_list.height >= (Graphics.height-@edition.height-25)
- end
- def update_notes
- unless @insert_title == true || @insert_text == true
- @note_title.set_text($game_note[:title][@note_list.index])
- @note_text.set_text($game_note[:text][@note_list.index])
- end
- end
- def insert_text_cmd
- #------------------------------------------------------
- #Title Zone
- #------------------------------------------------------
- if @insert_title == true
- Input::LETTERS.each do |k|
- if Input.trigger?(k)
- @title += k.to_s[3].downcase
- end
- end
- if Input.trigger?(:ESC)
- @insert_title = false
- $game_note[:title].slice!(-1)
- $game_note[:title] << @title.capitalize
- @insert_text = true
- 5.times{|i| update_basic}
- end
- if Input.trigger?(:BACK)
- @title.slice!(-1)
- end
- if Input.trigger?(:SPACE)
- @title += " "
- end
- @note_title.set_text(@title.capitalize)
- end
- #-------------------------------------------------------
- #Text Zone
- #-------------------------------------------------------
- if @insert_text == true
- Input::LETTERS.each do |k|
- if Input.trigger?(k)
- @text += k.to_s[3].downcase
- end
- end
- if Input.trigger?(:ENTER)
- @text += "
- "
- end
- if Input.trigger?(:BACK)
- @text.slice!(-1)
- end
- if Input.trigger?(:SPACE)
- @text += " "
- end
- if Input.trigger?(:ESC)
- @insert_text = false
- $game_note[:text].slice!(-1)
- $game_note[:text] << @text.capitalize
- @note_list.refresh
- @note_list.height = @note_list.window_height unless @note_list.height >= (Graphics.height-@edition.height-25)
- @edition.activate
- @note_list.activate
- end
- @note_text.set_text(@text.capitalize)
- end
- end
- end
- #===============================================================================
- # Windows
- #===============================================================================
- class Window_NoteList < Window_Command
- def make_command_list
- $game_note[:title].each{|t| add_command(t, :title)}
- end
- end
- class Window_Editing < Window_HorzCommand
- def make_command_list
- add_command("Nouveau", :add)
- add_command("Supprimer", :del)
- add_command("Quitter", :exit)
- end
- def window_width
- return Graphics.width
- end
- def process_handling
- return unless open? && active
- return process_ok if ok_enabled? && Input.trigger?(:SPACE)
- 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
- end
- class Window_NoteTitle < Window_Base
- def initialize(x, y, width)
- super(x, y, width, fitting_height(1))
- @text = ""
- end
- def update
- super
- contents.clear
- @text_pos = (self.width-text_size(@text).width)/2
- draw_text_ex(@text_pos, 0, @text)
- end
- def set_text(text)
- @text = text
- end
- end
- class Window_NoteText < Window_Base
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @text = ""
- end
- def update
- super
- contents.clear
- draw_text_ex(0, 0, @text)
- end
- def set_text(text)
- @text = text
- end
- end
- #===============================================================================
- #Modification des sauvgardes
- #===============================================================================
- module DataManager
- #-------------------------------------------------------------------------
- # * Aliased methods
- #-------------------------------------------------------------------------
- class << self
- alias :make_note_save :make_save_contents
- alias :extract_note_save :extract_save_contents
- alias :creat_note_object :create_game_objects
- def make_save_contents
- make_note_save.merge({:note =>$game_note})
- end
- #--------------------------------------------------------------------------
- # * Extract Save Contents
- #--------------------------------------------------------------------------
- def extract_save_contents(contents)
- extract_note_save(contents)
- $game_note = contents[:note]
- end
- def create_game_objects
- $game_note = {:title => [],
- :text => [] }
- creat_note_object
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement