Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #############################################################################################
- ############################## Choix Personnages et Difficulté ######################################
- #############################################################################################
- # Auteur : Biward
- # Date : 09/08/2010 15:53
- # Version : 1.0
- # Pour le forum RPG Maker VX BBactif et VX-fan
- # Utilité :
- # Permet de choisir le heros et la difficulté du jeu lorsque l'on fait une nouvelle partie !
- #=========================================================================================#
- # MODULE de CONFIGURATION #
- #=========================================================================================#
- module BI
- module PERSODIF
- ##### APPEL DE SCRIPT = persodif #####
- # TITLE = true or false
- # Si true alors le choix de personnage se fera après l'écran titre ("Nouvelle Partie")
- # Si false, il faudra appeller le choix des persos par un appel de script
- TITLE = false
- # PERSO = [ Les heros que l'on peut choisir (leur ID dans la BDD) ] /!\ N'oubliez pas les virgules !
- PERSO = [2, 4, 6, 8] # Maximun 4 !!
- # TEXT_INFO = Texte d'aide pour le choix du personnage /!\ N'oubliez pas les " " !
- TEXT_INFO = "Choisissez votre heros :"
- # DIF = [ Nom des difficultés ] /!\ N'oubliez pas les virgules !
- DIF = ["Facile", "Normal", "Extreme"]
- # VAR_DIF = Variable qui stocke le choix de la difficulté
- VAR_DIF = 1
- # Exemple :
- # DIF = [Facile, Extreme]
- # VAR_DIF = 1
- # Si le joueur choisit Facile, la variable 1 sera egale à 0.
- # Si le joueur choisit Extreme, la variable 1 sera egale a 1.
- # TEXT_INFO_2 = Texte d'aide pour le choix de la difficulté /!\ N'oubliez pas les " " !
- TEXT_INFO_2 = "Choisissez le niveau de difficulté :"
- end
- end
- #############################################################################################
- #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
- #___________________________________________________________________________________________#
- #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DEBUT DU SCRIPT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>#
- #___________________________________________________________________________________________#
- #////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////#
- #############################################################################################
- WLH_2 = 165
- #=========================================================================================#
- # SCENE_TITLE #
- #=========================================================================================#
- class Scene_Title
- include BI::PERSODIF
- alias command_new_game_dif command_new_game
- def command_new_game
- command_new_game_dif
- if TITLE
- $scene = Scene_PersoDif.new
- end
- end
- end
- #=========================================================================================#
- # PERSODIF #
- #=========================================================================================#
- def persodif
- if ! BI::PERSODIF::TITLE
- $scene = Scene_PersoDif.new
- end
- end
- #=========================================================================================#
- # SCENE_PERSODIF #
- #=========================================================================================#
- class Scene_PersoDif < Scene_Base
- include BI::PERSODIF
- def start
- @choix_perso, @choix_dif_perso, @commands_perso, @commands_dif = Array.new(4){[]}
- for i in PERSO
- truc = nil
- @commands_perso << truc
- end
- for i2 in DIF
- @commands_dif << i2
- end
- @choix_perso = Window_Command_PAD.new(445, @commands_perso, 4, 1, 15)
- @choix_perso.opacity = 0
- @choix_perso.x = Graphics.width/2 - 445/2
- @choix_perso.y = Graphics.height/2 - (1*24-32) - WLH_2/2
- @choix_dif = Window_Command.new(445, @commands_dif, 1, @commands_dif.size, 15)
- @choix_dif.opacity = 0
- @choix_dif.x = Graphics.width/2 - 455/2
- @choix_dif.y = Graphics.height/2 - (@commands_dif.size*24-32)/2
- @choix_dif.active = false
- @choix_dif.visible = false
- @choix_dif.z = 255
- create_window_perso
- end
- def update
- @choix_perso.update
- @choix_dif.update
- if Input.trigger?(Input::B) && @choix_perso.active && ! @choix_dif.active
- Sound.play_buzzer
- elsif Input.trigger?(Input::B) && ! @choix_perso.active && @choix_dif.active
- $perso = nil
- dispose_window_dif
- create_window_perso
- @choix_perso.active = true
- @choix_perso.visible = true
- @choix_dif.active = false
- @choix_dif.visible = false
- end
- if Input.trigger?(Input::C) && @choix_perso.active && ! @choix_dif.active
- $perso = PERSO[@choix_perso.index]
- dispose_window_perso
- create_window_dif
- @choix_perso.active = false
- @choix_perso.visible = false
- @choix_dif.active = true
- @choix_dif.visible = true
- elsif Input.trigger?(Input::C) && ! @choix_perso.active && @choix_dif.active
- change_party
- $game_variables[VAR_DIF] = @choix_dif.index
- end
- end
- def change_party
- $game_party.members.size.times { |i| $game_party.remove_actor(i) }
- $game_party.add_actor($perso)
- $perso = nil
- dispose_window_dif
- @choix_dif.dispose
- $scene = Scene_Map.new
- end
- def create_window_perso
- @win_perso = Array.new
- @x = @choix_perso.x + 5
- @y = @choix_perso.y + 5
- for i in 1..@commands_perso.size
- @win_perso.push(Window_Base.new(@x - 2.5, @y, 110+5, WLH_2+20))
- @win_perso[i.to_i-1].opacity = 100
- @x += 110
- @win_perso[i.to_i-1].draw_face($data_actors[PERSO[i - 1].to_i].face_name, $data_actors[PERSO[i - 1].to_i].face_index, -5, 10)
- @win_perso[i.to_i-1].draw_actor_graphic($data_actors[PERSO[i.to_i-1]], 25, 100)
- end
- @win_info_perso = Window_Base.new(@choix_perso.x, @choix_perso.y - 50, 445, 50)
- @win_info_perso.contents.draw_text(0, -200, 544, 416, TEXT_INFO, 0)
- end
- def dispose_window_perso
- @win_perso.each { |i| i.dispose }
- @win_info_perso.dispose
- end
- def create_window_dif
- height = @commands_dif.size * 32 + 5
- @win_dif = Window_Base.new(@choix_dif.x , @choix_dif.y + 5, 445, height)
- @win_dif.z = 0
- @win_info_dif = Window_Base.new(@win_dif.x, @win_dif.y - 50, 445, 50)
- @win_info_dif.contents.draw_text(0, -200, 544, 416, TEXT_INFO_2, 0)
- end
- def dispose_window_dif
- @win_dif.dispose
- @win_info_dif.dispose
- end
- end
- #==============================================================================
- # ** Window_Selectable_Perso_And_Dif
- #==============================================================================
- class Window_Selectable_PAD < Window_Base
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :item_max # item count
- attr_reader :column_max # digit count
- attr_reader :index # cursor position
- attr_reader :help_window # help window
- #--------------------------------------------------------------------------
- # * Object Initialization
- # x : window X coordinate
- # y : window Y coordinate
- # width : window width
- # height : window height
- # spacing : width of empty space when items are arranged horizontally
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, spacing = 32)
- @item_max = 1
- @column_max = 1
- @index = -1
- @spacing = spacing
- super(x, y, width, height)
- end
- #--------------------------------------------------------------------------
- # * Create Window Contents
- #--------------------------------------------------------------------------
- def create_contents
- self.contents.dispose
- self.contents = Bitmap.new(width - 32, [height - 32, row_max * WLH_2].max)
- end
- #--------------------------------------------------------------------------
- # * Set Cursor Position
- # index : new cursor position
- #--------------------------------------------------------------------------
- def index=(index)
- @index = index
- update_cursor
- call_update_help
- end
- #--------------------------------------------------------------------------
- # * Get Row Count
- #--------------------------------------------------------------------------
- def row_max
- return (@item_max + @column_max - 1) / @column_max
- end
- #--------------------------------------------------------------------------
- # * Get Top Row
- #--------------------------------------------------------------------------
- def top_row
- return self.oy / WLH_2
- end
- #--------------------------------------------------------------------------
- # * Set Top Row
- # row : row shown on top
- #--------------------------------------------------------------------------
- def top_row=(row)
- row = 0 if row < 0
- row = row_max - 1 if row > row_max - 1
- self.oy = row * WLH_2
- end
- #--------------------------------------------------------------------------
- # * Get Number of Rows Displayable on 1 Page
- #--------------------------------------------------------------------------
- def page_row_max
- return (self.height - 32) / WLH_2
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items Displayable on 1 Page
- #--------------------------------------------------------------------------
- def page_item_max
- return page_row_max * @column_max
- end
- #--------------------------------------------------------------------------
- # * Get bottom row
- #--------------------------------------------------------------------------
- def bottom_row
- return top_row + page_row_max - 1
- end
- #--------------------------------------------------------------------------
- # * Set bottom row
- # row : Row displayed at the bottom
- #--------------------------------------------------------------------------
- def bottom_row=(row)
- self.top_row = row - (page_row_max - 1)
- end
- #--------------------------------------------------------------------------
- # * Get rectangle for displaying items
- # index : item number
- #--------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- rect.width = (contents.width + @spacing) / @column_max - @spacing
- rect.height = WLH_2
- rect.x = index % @column_max * (rect.width + @spacing)
- rect.y = index / @column_max * WLH_2
- return rect
- end
- #--------------------------------------------------------------------------
- # * Set Help Window
- # help_window : new help window
- #--------------------------------------------------------------------------
- def help_window=(help_window)
- @help_window = help_window
- call_update_help
- end
- #--------------------------------------------------------------------------
- # * Determine if cursor is moveable
- #--------------------------------------------------------------------------
- def cursor_movable?
- return false if (not visible or not active)
- return false if (index < 0 or index > @item_max or @item_max == 0)
- return false if (@opening or @closing)
- return true
- end
- #--------------------------------------------------------------------------
- # * Move cursor down
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- if (@index < @item_max - @column_max) or (wrap and @column_max == 1)
- @index = (@index + @column_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor up
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- if (@index >= @column_max) or (wrap and @column_max == 1)
- @index = (@index - @column_max + @item_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor right
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- if (@column_max >= 2) and
- (@index < @item_max - 1 or (wrap and page_row_max == 1))
- @index = (@index + 1) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor left
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- if (@column_max >= 2) and
- (@index > 0 or (wrap and page_row_max == 1))
- @index = (@index - 1 + @item_max) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor one page down
- #--------------------------------------------------------------------------
- def cursor_pagedown
- if top_row + page_row_max < row_max
- @index = [@index + page_item_max, @item_max - 1].min
- self.top_row += page_row_max
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor one page up
- #--------------------------------------------------------------------------
- def cursor_pageup
- if top_row > 0
- @index = [@index - page_item_max, 0].max
- self.top_row -= page_row_max
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- if cursor_movable?
- last_index = @index
- if Input.repeat?(Input::DOWN)
- cursor_down(Input.trigger?(Input::DOWN))
- end
- if Input.repeat?(Input::UP)
- cursor_up(Input.trigger?(Input::UP))
- end
- if Input.repeat?(Input::RIGHT)
- cursor_right(Input.trigger?(Input::RIGHT))
- end
- if Input.repeat?(Input::LEFT)
- cursor_left(Input.trigger?(Input::LEFT))
- end
- if Input.repeat?(Input::R)
- cursor_pagedown
- end
- if Input.repeat?(Input::L)
- cursor_pageup
- end
- if @index != last_index
- Sound.play_cursor
- end
- end
- update_cursor
- call_update_help
- end
- #--------------------------------------------------------------------------
- # * Update cursor
- #--------------------------------------------------------------------------
- def update_cursor
- if @index < 0 # If the cursor position is less than 0
- self.cursor_rect.empty # Empty cursor
- else # If the cursor position is 0 or more
- row = @index / @column_max # Get current row
- if row < top_row # If before the currently displayed
- self.top_row = row # Scroll up
- end
- if row > bottom_row # If after the currently displayed
- self.bottom_row = row # Scroll down
- end
- rect = item_rect(@index) # Get rectangle of selected item
- rect.y -= self.oy # Match rectangle to scroll position
- self.cursor_rect = rect # Refresh cursor rectangle
- end
- end
- #--------------------------------------------------------------------------
- # * Call help window update method
- #--------------------------------------------------------------------------
- def call_update_help
- if self.active && @help_window
- update_help
- end
- end
- #--------------------------------------------------------------------------
- # * Update help window (contents are defined by the subclasses)
- #--------------------------------------------------------------------------
- def update_help
- end
- end
- #==============================================================================
- # ** Window_Command_Perso_And_Dif
- #==============================================================================
- class Window_Command_PAD < Window_Selectable_PAD
- attr_reader :commands # command
- def initialize(width, commands, column_max = 1, row_max = 1, spacing = 32)
- super(0, 0, width, row_max * WLH_2 + 32, spacing)
- @commands = commands
- @item_max = commands.size
- @column_max = column_max
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- create_contents
- @item_max.times { |i| draw_item(i) }
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index, enabled = true)
- rect = item_rect(index)
- rect.x += 4
- rect.width -= 8
- self.contents.clear_rect(rect)
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(rect, @commands[index])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement