Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Script : Dark Animated Custom Menu.
- # Author : Dark Sky ( Nhat Nguyen )
- # Released on : April 19th 2016
- # Forum : TaoTroChoi.com
- #-------------------------------------------------------------------------------
- # Version: 1.0 -> Release!
- #===============================================================================
- module Dark_CustomMenu2
- Command_Font = "Impact"
- end
- include Dark_CustomMenu2
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # This class performs the menu screen processing.
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super
- create_sprites
- create_command_window
- create_gold_window
- create_status_window
- end
- #--------------------------------------------------------------------------
- # * Create Sprites
- #--------------------------------------------------------------------------
- def create_sprites
- @sprites = {}
- @sprites[:bg] = Sprite.new
- @sprites[:bg].bitmap = Cache.picture("D_Background")
- @sprites[:bg].viewport = @viewport
- @sprites[:bg].z = 0
- @sprites[:fog] = Plane.new
- @sprites[:fog].bitmap = Cache.picture("D_Fog")
- @sprites[:fog].viewport = @viewport
- @sprites[:fog].opacity = 20
- @sprites[:fog].z = 10
- @sprites[:menu_main] = Sprite.new
- @sprites[:menu_main].bitmap = Cache.picture("D_Background3")
- @sprites[:menu_main].viewport = @viewport
- @sprites[:menu_main].z = 15
- @sprites[:menu_title] = Sprite.new
- @sprites[:menu_title].bitmap = Cache.picture("D_Background2")
- @sprites[:menu_title].viewport = @viewport
- @sprites[:menu_title].z = 20
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- alias dark_animated_menu_custom_update update
- def update
- dark_animated_menu_custom_update
- @sprites[:fog].ox += 1
- if @menu
- @menu.update
- end
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- alias dark_animated_menu_custom_create_command_window create_command_window
- def create_command_window
- dark_animated_menu_custom_create_command_window()
- @command_window.opacity = 0
- @command_window.viewport = @viewport
- @command_window.y += 30
- @command_window.visible = false
- @command_window.back_opacity = 0
- @menu = DarkMenu.new(@command_window.list,@command_window,@viewport)
- end
- #--------------------------------------------------------------------------
- # * Create Gold Window
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_Gold.new
- @gold_window.x = -34
- @gold_window.y = Graphics.height - @gold_window.height + 12
- @gold_window.opacity = 0
- @gold_window.back_opacity = 0
- @gold_window.viewport = @viewport
- end
- #--------------------------------------------------------------------------
- # * Create Status Window
- #--------------------------------------------------------------------------
- def create_status_window
- @status_window = Window_MenuStatus.new(@command_window.width, 0)
- @status_window.viewport = @viewport
- @status_window.opacity = 0
- @status_window.back_opacity = 200
- @status_window.x += 60
- @status_window.y += 40
- end
- #--------------------------------------------------------------------------
- # * Terminate
- #--------------------------------------------------------------------------
- alias dark_animated_menu_custom_terminate terminate
- def terminate
- dark_animated_menu_custom_terminate
- @sprites.values.each do |sprite|
- sprite.bitmap.dispose
- sprite.dispose
- end
- @menu.dispose_sprites
- end
- end
- #==============================================================================
- # ** DarkMenu
- #==============================================================================
- class DarkMenu
- attr_accessor :list
- #--------------------------------------------------------------------------
- # * Initialize
- #--------------------------------------------------------------------------
- def initialize(list,window,viewport)
- @list = list
- @size = list.size
- @viewport = viewport
- @index = window.index
- @window = window
- @command_sprites = []
- @cur_index = 0
- for i in 0..(@list.size - 1)
- @command_sprites.push(Sprite_Menu_Command.new(@list[i][:name],window,i,viewport))
- end
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- def dispose_sprites
- p "Menu Sprite Disposed!"
- @command_sprites.each do |sprite|
- sprite.bitmap.dispose
- sprite.dispose
- end
- @command_sprites.clear
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- @command_sprites.each do |sprite|
- sprite.update
- end
- end
- end
- #--------------------------------------------------------------------------
- # Window_Command
- #--------------------------------------------------------------------------
- class Window_Command < Window_Selectable
- attr_accessor :list
- end
- #--------------------------------------------------------------------------
- # Sprite_Menu_Command
- #--------------------------------------------------------------------------
- class Sprite_Menu_Command < Sprite
- def initialize(name,window,index,viewport)
- super(viewport)
- @name = name
- @menu_index = window.index
- @window = window
- @index = index
- @contents = Sprite.new
- if @index == @menu_index
- self.bitmap = Cache.picture("D_Selected")
- else
- self.bitmap = Cache.picture("D_Selection")
- end
- @contents.bitmap = Bitmap.new(self.bitmap.width,self.bitmap.height)
- self.viewport = viewport
- self.y = 70 + index*40
- self.z = 40
- self.opacity = 255 - (@menu_index - @index).abs*40
- @contents.viewport = viewport
- @contents.bitmap.font.name = [Command_Font]
- @contents.bitmap.font.outline = false
- @contents.x = self.x
- @contents.y = self.y
- @contents.z = 50
- @contents.opacity = self.opacity
- @slicer = Sprite.new
- @slicer.bitmap = Cache.picture("D_Slicer")
- @slicer.viewport = viewport
- @slicer.z = 60
- @slicer.x = self.x
- @slicer.y = self.y
- @slicer.opacity = 0
- @target_opacity = 255 - (@menu_index - @index).abs*40
- @chosing = false
- end
- def update_opacity
- self.opacity += @target_opacity*0.08 if @target_opacity != self.opacity && @target_opacity - self.opacity > 0
- self.opacity -= @target_opacity*0.08 if @target_opacity != self.opacity && @target_opacity - self.opacity < 0
- end
- def update_chosing
- if @chosing == true
- @slicer.ox += 5
- @slicer.bitmap.rect.set(0,0,162,35)
- if @slicer.ox > 200
- @slicer.ox = 0
- end
- @slicer.opacity = 255 - @slicer.ox
- else
- @slicer.opacity = 0
- end
- end
- def update
- super
- update_chosing
- update_opacity
- @contents.bitmap.clear
- @contents.bitmap.draw_text(10,0,100,32,@name)
- @target_opacity = (255 - (@window.index - @index).abs*40)
- if @index == @window.index
- @chosing = true
- self.bitmap = Cache.picture("D_Selected")
- else
- @chosing = false
- self.bitmap = Cache.picture("D_Selection")
- end
- @contents.opacity = self.opacity
- end
- def dispose
- super
- @contents.bitmap.dispose
- @contents.dispose
- @slicer.bitmap.dispose
- @slicer.dispose
- end
- end
- #==============================================================================
- # ** Window_Gold
- #------------------------------------------------------------------------------
- # This window displays the party's gold.
- #==============================================================================
- class Window_Gold < Window_Base
- #--------------------------------------------------------------------------
- # * Draw Number (Gold Etc.) with Currency Unit
- #--------------------------------------------------------------------------
- def draw_currency_value(value, unit, x, y, width)
- cx = text_size(unit).width
- change_color(normal_color)
- draw_text(x, y, width - cx - 2, line_height, value, 2)
- change_color(crisis_color)
- draw_text(x, y, width, line_height, unit, 2)
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- contents.font.outline = false
- draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
- end
- end
- #==============================================================================
- # ** Window_MenuStatus
- #------------------------------------------------------------------------------
- # This window displays party member status on the menu screen.
- #==============================================================================
- class Window_MenuStatus < Window_Selectable
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :pending_index # Pending position (for formation)
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias dark_animated_custom_menu_init_asd initialize
- def initialize(*args)
- dark_animated_custom_menu_init_asd(*args)
- @sprites = {}
- @sprites[:select] = Sprite.new
- @sprites[:select].bitmap = Cache.picture("D_Selection2")
- @sprites[:select].z = 999
- @sprites[:select].visible = self.active
- end
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- alias dark_animated_custom_menu_dispose dispose
- def dispose
- dark_animated_custom_menu_dispose
- @sprites.values.each do |sprite|
- sprite.bitmap.dispose
- sprite.dispose
- end
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- 310
- end
- #--------------------------------------------------------------------------
- # * Get Window Height
- #--------------------------------------------------------------------------
- def window_height
- 400
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- $game_party.members.size
- end
- #--------------------------------------------------------------------------
- # * Get Item Width
- #--------------------------------------------------------------------------
- def item_width
- 300
- end
- #--------------------------------------------------------------------------
- # * Get Item Height
- #--------------------------------------------------------------------------
- def item_height
- 100
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(index)
- actor = $game_party.members[index]
- enabled = $game_party.battle_members.include?(actor)
- rect = item_rect(index)
- draw_item_background(index)
- draw_actor_face(actor, rect.x + 1, rect.y + 1, enabled)
- draw_actor_simple_status(actor, rect.x + 10, rect.y + line_height / 2)
- end
- #--------------------------------------------------------------------------
- # * Draw Simple Status
- #--------------------------------------------------------------------------
- def draw_actor_simple_status(actor, x, y)
- contents.font.size = 18
- draw_actor_name(actor, x + 90, y)
- draw_actor_level(actor, x + 90, y + line_height * 1)
- reset_font_settings
- draw_actor_icons(actor, x, y + line_height * 2)
- draw_actor_hp(actor, x + 150, y + line_height * 1)
- draw_actor_mp(actor, x + 150, y + line_height * 2)
- contents.font.size = 16
- draw_actor_class(actor, x + 155, y)
- reset_font_settings
- end
- #--------------------------------------------------------------------------
- # * Update
- #--------------------------------------------------------------------------
- def update
- super
- cursor_rect.width = 0
- cursor_rect.height = 0
- rect = cursor_rect
- @sprites[:select].y = self.y + rect.y - self.oy + 10
- @sprites[:select].visible = self.active
- @sprites[:select].x = self.x
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment