Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Ring Menu Addon (for PAC Main Menu Ace)
- # 19/06/2014
- # By Pacman
- #
- #===============================================================================
- #
- # This script is an addon for PAC Main Menu Ace. This script will only work
- # reliably if you have PAC Main Menu Ace version 1.2 or higher above it in the
- # scripts menu. (To get PAC Main Menu Ace - http://pastebin.com/Z7JN31gT)
- # This script will turn the main menu in to a ring menu reminiscent of SNES-era
- # RPGs.
- # This script allows for two different radii of the ring - an x-radius and a
- # y-radius. This means it has the capacity to produce ellipses as well as
- # circles.
- # This script can also scale the selected and deselected icons independently;
- # i.e. making the selected option larger.
- #
- #===============================================================================
- module PAC::MM::RING
- MENU_RADIUS_X = 128 # X Radius
- MENU_RADIUS_Y = 64 # Y Radius
- MENU_SPEED = 8 # Changes movement speed of icons
- MENU_TEXT = true # Show menu text? (true or false)
- MENU_TEXT_SIZE = 18 # Menu Text size. integer or nil for default size
- MENU_ICON_PLACEMENT = :bottom # :top or :bottom
- BACKGROUND_ALPHA = 192 # integer (0 - 255)
- SCALE_GAIN = 8 # pixels gained in big icon scaling
- SCALE_LOSS = 4 # pixels lost in small icon scaling
- end
- #===============================================================================
- #
- # END CONFIG
- #
- #==============================================================================
- # ** Math
- #------------------------------------------------------------------------------
- # A module that supports floating-point calculations.
- #==============================================================================
- module Math
- #--------------------------------------------------------------------------
- # * Trigonometric functions in degrees
- #--------------------------------------------------------------------------
- ["sin","cos","tan"].each { |type| trig_eval_code = %Q(
- def self.#{type}d(value)
- return self.#{type}(value * PI / 180)
- end)
- eval (trig_eval_code)
- }
- end
- #==============================================================================
- # ** Window_MenuCommand
- #------------------------------------------------------------------------------
- # This command window appears on the menu screen.
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :index
- attr_reader :angle
- attr_accessor :gosh_dang_it
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- @gosh_dang_it = false
- @angle = 0
- super(0, 0)
- @list.delete_if {|i| !i[:enabled]}
- self.width = Graphics.width
- self.height = Graphics.height
- self.opacity = 0
- self.visible = self.active
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Angle Size
- #--------------------------------------------------------------------------
- def angle_size
- return 360 / item_max
- end
- #--------------------------------------------------------------------------
- # * Draw Big Icon
- # enabled : Enabled flag. When false, draw semi-transparently.
- #--------------------------------------------------------------------------
- def draw_big_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- dest = rect.clone
- dest.width = dest.height = (24 + PAC::MM::RING::SCALE_GAIN)
- dest.x = x - PAC::MM::RING::SCALE_GAIN/2
- dest.y = y - PAC::MM::RING::SCALE_GAIN/2
- contents.stretch_blt(dest, bitmap, rect, enabled ? 255 : translucent_alpha)
- end
- #--------------------------------------------------------------------------
- # * Draw Small Icon
- # enabled : Enabled flag. When false, draw semi-transparently.
- #--------------------------------------------------------------------------
- def draw_small_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- dest = rect.clone
- dest.width = dest.height = (24 - PAC::MM::RING::SCALE_LOSS)
- dest.x = x + PAC::MM::RING::SCALE_LOSS/2
- dest.y = y + PAC::MM::RING::SCALE_LOSS/2
- contents.stretch_blt(dest, bitmap, rect, translucent_alpha / 2)
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- #--------------------------------------------------------------------------
- def draw_item(method_index, enabled = true)
- radius = PAC::MM::RING::MENU_RADIUS_X
- yradius = PAC::MM::RING::MENU_RADIUS_Y
- yradius *= -1 if PAC::MM::RING::MENU_ICON_PLACEMENT == :top
- n = (method_index - self.index) * angle_size + @angle
- cx = radius * Math.sind(n) + (Graphics.width / 2)
- cy = yradius * Math.cosd(n) + (Graphics.height / 2)
- if n == 0 # Selected index
- self.contents.font.color.alpha = enabled ? 255 : 128
- s = self.contents.font.size
- self.contents.font.size = PAC::MM::RING::MENU_TEXT_SIZE || s
- self.contents.draw_text(Graphics.width / 2 - 80, Graphics.height / 2 -
- line_height, 160, line_height, PAC::MM::COMMANDS[method_index][0], 1) if
- PAC::MM::RING::MENU_TEXT
- self.contents.font.size = s
- draw_big_icon(PAC::MM::COMMANDS[method_index][2], cx - 12, cy - 12,
- (enabled))
- else # All other indexes
- draw_small_icon(PAC::MM::COMMANDS[method_index][2], cx - 12, cy - 12,
- (false))
- end
- end
- def okay
- return
- end
- #--------------------------------------------------------------------------
- # * Update Spin Animation
- #--------------------------------------------------------------------------
- def update_spin(reverse = false)
- speed = PAC::MM::RING::MENU_SPEED
- @angle += (reverse ? -angle_size : angle_size) / speed.to_f
- Graphics.update
- refresh
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- # aliasing is for chumps
- #--------------------------------------------------------------------------
- def update
- super
- update_index
- end
- #--------------------------------------------------------------------------
- # * Update input thingies
- #--------------------------------------------------------------------------
- def update_index
- return if !active
- if Input.trigger?(:LEFT) || Input.repeat?(:LEFT) || Input.trigger?(:UP) ||
- Input.repeat?(:UP)
- Sound.play_cursor
- while @angle.round < angle_size
- update_spin
- end
- @index -= 1
- @index %= item_max
- @angle = 0
- refresh
- elsif Input.trigger?(:RIGHT) || Input.repeat?(:RIGHT) ||
- Input.trigger?(:DOWN) || Input.repeat?(:DOWN)
- Sound.play_cursor
- while @angle.round > -angle_size
- update_spin(true)
- end
- @index += 1
- @index %= item_max
- @angle = 0
- refresh
- end
- end
- #--------------------------------------------------------------------------
- # * Fix the cursor
- #--------------------------------------------------------------------------
- def cursor_down(*args)
- cursor_right(*args)
- end
- def cursor_up(*args)
- cursor_left(*args)
- end
- def update_cursor
- end
- end
- #==============================================================================
- # ** Window_MenuStatus
- #------------------------------------------------------------------------------
- # This window displays party member status on the menu screen.
- #==============================================================================
- class Window_MenuStatus < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias pac_mm_rm_init initialize
- def initialize(*args)
- pac_mm_rm_init(*args)
- self.x = (Graphics.width - self.width) / 2
- self.y = (Graphics.height - self.height) / 2
- end
- end
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # This class performs the menu screen processing.
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # Aliasing things
- #--------------------------------------------------------------------------
- alias pac_mm_rm_strt start
- alias pac_mm_rm_cmdpnl command_personal
- alias pac_mm_rm_cmdfrm command_formation
- alias pac_mm_rm_onfc on_formation_cancel
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start(*args)
- pac_mm_rm_strt(*args)
- @command_window.hide if @@start_personal
- @command_window.index = (@@last_index ||= 0)
- @command_window.refresh
- @status_window.hide unless @@start_personal
- @status_window.close unless @@start_personal
- end
- #--------------------------------------------------------------------------
- # * Create Background
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, PAC::MM::RING::BACKGROUND_ALPHA)
- end
- #--------------------------------------------------------------------------
- # * [Skill], [Equipment] and [Status] Commands
- #--------------------------------------------------------------------------
- def command_personal(*args)
- @command_window.close
- @status_window.show
- @status_window.open
- pac_mm_rm_cmdpnl(*args)
- end
- #--------------------------------------------------------------------------
- # * [Formation] Command
- #--------------------------------------------------------------------------
- def command_formation(*args)
- @command_window.close
- @status_window.show
- @status_window.open
- pac_mm_rm_cmdfrm(*args)
- end
- #--------------------------------------------------------------------------
- # * [Cancel] Personal Command
- #--------------------------------------------------------------------------
- def on_personal_cancel(*args)
- pac_mm_opc(*args)
- @status_window.close
- @command_window.show
- @command_window.open
- @@start_personal = false
- end
- #--------------------------------------------------------------------------
- # * Formation [Cancel]
- #--------------------------------------------------------------------------
- def on_formation_cancel(*args)
- pac_mm_rm_onfc(*args)
- @status_window.close
- @command_window.show
- @command_window.open
- @@start_personal = false
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate(*args)
- @@last_index = @command_window.index
- super
- end
- end
- ($pac ||= {})[:ring] = 1
- unless $pac[:main_menu] >= 1.2
- msgbox "You require PAC Main Menu Ace for the Ring Menu script to work."
- msgbox "Find the script at http://pastebin.com/Z7JN31gT"; exit
- end
- #===============================================================================
- #
- # END OF SCRIPT
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement