Jump to content
Sign in to follow this  
roninator2

Syvkal Ring Menu addon - Title Screen Ring

Recommended Posts

Syvkal Ring Menu addon - Title Screen Ring 1.02
by Roninator2


Introduction
An addon to make the Title Screen menu's show icons in a ring for the Syvkal ring menu

Features
- Plug & play
- set parameter to use the shaded background or not

How to Use
Put below Syvkal Ring Menu script

Images

Spoiler

1609630763943.png.e5d0d27a04e68b06edeb88ee6a321db4.png


Script

Spoiler

# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Syvkal Title Ring            ║  Version: 1.02     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║    Add ring menu to title menu      ╠════════════════════╣
# ║                                     ║    02 Jan 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Using code from Syvkal's Ring Menu                       ║
# ║ I created the title screen menu                          ║
# ║                                                          ║
# ║ If other options are added, it will require changes.     ║
# ║ Icons must be in the format of ''choice' + space + icon' ║
# ║ example                                                  ║
# ║ 'yes icon'.png or 'no icon'.png  - without quotes        ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - 02 Jan 2021 - Initial publish                     ║
# ║ 1.01 - 02 Jan 2021 - Created Circle Background           ║
# ║ 1.02 - 03 Jan 2021 - Added color options for background  ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Follow the Original Authors terms   ║
# ╚═════════════════════════════════════╝
module R2_Title_Shade
  Use_Background = true
  # Set colors to the circle image
  Background_Red = 0
  Background_Green = 0
  Background_Blue = 0
  Background_Opacity = 180
end
#==============================================================================
# ** Window_TitleCommand
#------------------------------------------------------------------------------
#  This window is for selecting New Game/Continue on the title screen.
#==============================================================================
class Window_TitleCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    @cx = contents.width / 2; @cy = contents.height / 2
    @icons = []
    @titlecom = []
    @startup = 20
    @steps = @startup
    @list.clear
    make_command_list
    update_placement
    make_title_icons
    select(1) if continue_enabled
    select(0) if !continue_enabled
    self.opacity = 0
    if R2_Title_Shade::Use_Background
      create_back_bitmap_turn
      create_back_sprite_turn
    end
    @mode = :start
    open
    activate
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh Start Period
  #--------------------------------------------------------------------------
  def refresh_start
    d1 = 2.0 * Math::PI / item_max
    d2 = 1.0 * Math::PI / @startup
    r = RING_R - 1.0 * RING_R * @steps / @startup
    for i in 0...item_max
      j = i - index
      d = d1 * j + d2 * @steps
      x = @cx + ( r * Math.sin( d ) ).to_i
      y = @cy - ( r * Math.cos( d ) ).to_i
      draw_item_icons(x, y, i)
    end
    @steps -= 1
    if @steps < 0
      @mode = :wait
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Wait Period
  #--------------------------------------------------------------------------
  def refresh_wait
    d = 2.0 * Math::PI / item_max
    for i in 0...item_max
      j = i - index
      x = @cx + ( RING_R * Math.sin( d * j) ).to_i
      y = @cy - ( RING_R * Math.cos( d * j) ).to_i
      draw_item_icons(x, y, i)
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Movement Period
  #--------------------------------------------------------------------------
  def refresh_move( mode )
    d1 = 2.0 * Math::PI / item_max
    d2 = d1 / MOVING_FRAMES
    d2 *= -1 unless mode != 0
    for i in 0...item_max
      j = i - index
      d = d1 * j + d2 * @steps
      x = @cx + ( RING_R * Math.sin( d ) ).to_i
      y = @cy - ( RING_R * Math.cos( d ) ).to_i
      draw_item_icons(x, y, i)
    end
    @steps -= 1
    if @steps < 0
      @mode = :wait
    end
  end
  #--------------------------------------------------------------------------
  # * Update Cursor
  #--------------------------------------------------------------------------
  def update_cursor
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    refresh if animation?
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh   
    self.contents.clear
    case @mode
    when :start
      refresh_start
    when :wait
      refresh_wait
    when :mover
      refresh_move(1)
    when :movel
      refresh_move(0)
    end
    rect = Rect.new(self.x, self.y + 60, self.contents.width, line_height)
    draw_text(rect, choice_name(index), 1)
  end
  #--------------------------------------------------------------------------
  # * Determines if is moving
  #--------------------------------------------------------------------------
  def animation?
    return @mode != :wait
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Down
  #--------------------------------------------------------------------------
  def cursor_down(wrap)
    cursor_right(wrap)
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Up
  #--------------------------------------------------------------------------
  def cursor_up(wrap)
    cursor_left(wrap)
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Right
  #--------------------------------------------------------------------------
  def cursor_right(wrap)
    unless animation?
      select((index + 1) % item_max)
      @mode = :mover
      @steps = MOVING_FRAMES
      Sound.play_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Move Cursor Left
  #--------------------------------------------------------------------------
  def cursor_left(wrap)
    unless animation?
      select((index - 1 + item_max) % item_max)
      @mode = :movel
      @steps = MOVING_FRAMES
      Sound.play_cursor
    end
  end
  #--------------------------------------------------------------------------
  # * Update Window Position
  #--------------------------------------------------------------------------
  def update_placement
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height * 1.6 - height) / 2.2
  end
  #--------------------------------------------------------------------------
  # * Get Activation State of Continue
  #--------------------------------------------------------------------------
  def continue_enabled
    DataManager.save_file_exists?
  end
  #--------------------------------------------------------------------------
  # * make_title_icons
  #--------------------------------------------------------------------------
  def make_title_icons
    @titlecom.each_with_index do |command, i|
      @icons.push(Cache::picture(command + ' Icon'))
      rect = Rect.new(self.x, self.y, @icons[i].width / 2, @icons[i].height / 2)
      draw_item_icons(x, y, i)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return Graphics.width
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    return Graphics.height
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    @titlecom = []
    add_command(Vocab::new_game, :new_game)
    add_command(Vocab::continue, :continue, continue_enabled)
    add_command(Vocab::shutdown, :shutdown)
    @titlecom.push(Vocab::new_game)
    @titlecom.push(Vocab::continue)
    @titlecom.push(Vocab::shutdown)
  end
  #--------------------------------------------------------------------------
  # * Get Command Name
  #--------------------------------------------------------------------------
  def choice_name(index)
    return if @titlecom == nil
    @titlecom[index]
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     i     : item number
  #--------------------------------------------------------------------------
  def draw_item_icons(x, y, i)
    return if @icons.nil?
    rect = Rect.new(0, 0, @icons[i].width, @icons[i].height)
    if i == index
      self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect )
      unless command_enabled?(index)
        self.contents.blt(x - rect.width/2, y - rect.height/2, ICON_DISABLE, rect )
      end
    else
      self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect, 128 )
    end
  end
  #--------------------------------------------------------------------------
  # * Create Background Bitmap
  #--------------------------------------------------------------------------
  def create_back_bitmap_turn
    @back_bitmap_turn = Bitmap.new(width, height)
    r = R2_Title_Shade::Background_Red
    g = R2_Title_Shade::Background_Green
    b = R2_Title_Shade::Background_Blue
    o = R2_Title_Shade::Background_Opacity
    @back_bitmap_turn.draw_circle(275,200,100,Color.new(r,g,b,o))
  end
  #--------------------------------------------------------------------------
  # * Create Background Sprite
  #--------------------------------------------------------------------------
  def create_back_sprite_turn
    @back_sprite_turn = Sprite.new
    @back_sprite_turn.bitmap = @back_bitmap_turn
    @back_sprite_turn.z = z - 1
    @back_sprite_turn.y = self.y
    @back_sprite_turn.x = self.x
  end
  #--------------------------------------------------------------------------
  # * Free Background Bitmap
  #--------------------------------------------------------------------------
  def dispose_back_bitmap_turn
    @back_bitmap_turn.dispose
  end
  #--------------------------------------------------------------------------
  # * Free Background Sprite
  #--------------------------------------------------------------------------
  def dispose_back_sprite_turn
    @back_sprite_turn.dispose
  end
  #--------------------------------------------------------------------------
  # * Dispose Background
  #--------------------------------------------------------------------------
  alias r2_title_back_dispose dispose
  def dispose
    r2_title_back_dispose
    dispose_back_bitmap_turn
    dispose_back_sprite_turn
  end
end
#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap
  #----------------------------------------------------------------------------
  # * Draw a Circle
  #----------------------------------------------------------------------------
def draw_circle(y,x,r,color)

  for i in (y - r).. (y + r)
    j1 = Math.sqrt((r**2) - ((i - y)*(i - y))) + x
    j2 = - Math.sqrt((r**2) - ((i - y)*(i - y))) + x
    j1 = j1.to_i
    j2 = j2.to_i

    for k in j2..j1
      self.set_pixel(i,k,color)
    end
  
  end

  for j in (x - r).. (x + r)
    i1 = Math.sqrt((r**2) - ((j - x)*(j - x))) + y
    i2 = - Math.sqrt((r**2) - ((j - x)*(j - x))) + y
    self.set_pixel(i1,j,color)
    self.set_pixel(i2,j,color)
  end
end
end

 


Credit and Thanks
- Syvkal
- Roninator2
- Masked
- Shiroyasha

Terms of use
Follow original authors terms

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted