Advertisement
FlipelyFlip

Altered Ring Menu Val

Apr 4th, 2022
1,209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.19 KB | None | 0 0
  1. #==============================================================================
  2. # ** Ring Menu
  3. #-------------------------------------------------------------------------------
  4. # by Syvkal
  5. # Version 1.1
  6. # 06-23-08
  7. #==============================================================================
  8.  
  9.    #===================================================#
  10.    #  **  C O N F I G U R A T I O N   S Y S T E M  **  #
  11.    #===================================================#
  12.  
  13.   # Amount of frames for Startup Animation
  14.   STARTUP_FRAMES = 20
  15.   # Amount of frames for Movement Animation
  16.   MOVING_FRAMES = 15
  17.   # Radius of the Menu Ring
  18.   RING_R = 118
  19.   # Disabled icon to display when disabled
  20.   ICON_DISABLE= Cache::picture('')
  21.  
  22. module FFS
  23.   DEUTSCH = [
  24.    [Vocab::item, Cache::picture('Icon_Skill'), "$scene = Scene_Picture_Gallery.new"],
  25.    ["", Cache::picture('Icon_Load'), "$scene = Scene_File.new(false,false,true)"],
  26.    [Vocab::game_end, Cache::picture('Icon_End'), "$scene = Scene_End.new"]
  27.   ]
  28.  
  29.   ENGLISCH = [
  30.    [Vocab::item, Cache::picture('Icon_Skill_EN'), "$scene = Scene_Picture_Gallery.new"],
  31.    ["", Cache::picture('Icon_Load_EN'), "$scene = Scene_File.new(false,false,true)"],
  32.    [Vocab::game_end, Cache::picture('Icon_End_EN'), "$scene = Scene_End.new"]
  33.   ]
  34.  
  35.   def self.getLanguage
  36.     if $game_switches[218]
  37.       return DEUTSCH
  38.     else
  39.       return ENGLISCH
  40.     end
  41.   end
  42. end
  43.  
  44. #==============================================================================
  45. # ** Scene_Menu
  46. #------------------------------------------------------------------------------
  47. #  Edited to add Ring Menu
  48. #==============================================================================
  49.  
  50. class Scene_Menu < Scene_Base
  51.   #--------------------------------------------------------------------------
  52.   # * Alias Listings
  53.   #--------------------------------------------------------------------------
  54.   alias initialize_original initialize
  55.   alias start_selection_original start_actor_selection
  56. #  alias end_selection_original end_actor_selection
  57.   #--------------------------------------------------------------------------
  58.   # * Object Initialization
  59.   #--------------------------------------------------------------------------
  60.   def initialize(menu_index = 0, move = true)
  61.     @move = move
  62.     initialize_original(menu_index)
  63.     @options = FFS.getLanguage
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Start processing
  67.   #--------------------------------------------------------------------------
  68.   def start
  69.     super
  70.     create_menu_background
  71.     create_command_window
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # * Termination Processing
  75.   #--------------------------------------------------------------------------
  76.   def terminate
  77.     super
  78.     dispose_menu_background
  79.     @command_window.dispose
  80.     @status_window.dispose if @status_window
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Frame Update
  84.   #--------------------------------------------------------------------------
  85.   def update
  86.     super
  87.     update_menu_background
  88.     @command_window.update
  89.     @status_window.update if @status_window
  90.     if @command_window.active
  91.       update_command_selection
  92.     elsif @status_window.active
  93.       update_actor_selection
  94.     end
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # * Create Command Window
  98.   #--------------------------------------------------------------------------
  99.   def create_command_window
  100.     commands = []
  101.     for i in 0...@options.size
  102.       commands.push(@options[i][0])
  103.     end
  104.     icons = []
  105.     for i in 0...@options.size
  106.       icons.push(@options[i][1])
  107.     end
  108.     @command_window = Window_RingMenu.new(232, 170, commands, icons, @move, @menu_index)
  109.     if $game_party.members.size == 0
  110.       @command_window.disable_item(0)
  111.       @command_window.disable_item(1)
  112.       @command_window.disable_item(2)
  113.       @command_window.disable_item(3)
  114.     end
  115.     if $game_system.save_disabled
  116.       @command_window.disable_item(4)
  117.     end
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # * Create Command Window
  121.   #--------------------------------------------------------------------------
  122.   def create_status_window
  123.     names = []
  124.     chars = []
  125.     for i in 0...$game_party.members.size
  126.       names[i] = $game_party.members[i].name
  127.       chars[i] = $game_party.members[i]
  128.     end
  129.     @status_window = Window_RingMenu.new(255, 200, names, chars, true, $game_party.last_actor_index, true)
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # * Update Command Selection
  133.   #--------------------------------------------------------------------------
  134.   def update_command_selection
  135.     if Input.trigger?(Input::B)
  136.       Sound.play_cancel
  137.       $scene = Scene_Map.new
  138.     elsif Input.trigger?(Input::C)
  139.       if $game_party.members.size == 0 and @command_window.index < 4
  140.         Sound.play_buzzer
  141.         return
  142.       elsif $game_system.save_disabled and @command_window.index == 4
  143.         Sound.play_buzzer
  144.         return
  145.       end
  146.       Sound.play_decision
  147.       eval(@options.size[@command_window.index][2])
  148.     end
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # * Start Actor Selection
  152.   #--------------------------------------------------------------------------
  153.   def start_actor_selection
  154.     @command_window.active = false
  155.     @command_window.visible = false
  156.     create_status_window
  157.     if $game_party.last_actor_index < @status_window.item_max
  158.       @status_window.index = $game_party.last_actor_index
  159.     else
  160.       @status_window.index = 0
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * End Actor Selection
  165.   #--------------------------------------------------------------------------
  166.   def end_actor_selection
  167.     @command_window.active = true
  168.     @command_window.visible = true
  169.     @status_window.dispose if @status_window
  170.     @status_window = nil
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # * Update Actor Selection
  174.   #--------------------------------------------------------------------------
  175.   def update_actor_selection
  176.     if Input.trigger?(Input::B)
  177.       Sound.play_cancel
  178.       end_actor_selection
  179.     elsif Input.trigger?(Input::C)
  180.       $game_party.last_actor_index = @status_window.index
  181.       Sound.play_decision
  182.       eval(@options[@command_window.index][3])
  183.     end
  184.   end
  185. end
  186.  
  187. #==============================================================================
  188. # ** Scene_File
  189. #------------------------------------------------------------------------------
  190. #  Edited to return to the menu properly when loading
  191. #==============================================================================
  192.  
  193. class Scene_File
  194.   alias return_scene_original return_scene
  195.   def return_scene
  196.     if @from_title
  197.       $scene = Scene_Title.new
  198.     elsif @from_event
  199.       $scene = Scene_Map.new
  200.     else
  201.       if @saving
  202.         $scene = Scene_Menu.new(FFS::DEUTSCH.size - 3)
  203.       else
  204.         $scene = Scene_Menu.new(FFS::DEUTSCH.size - 2)
  205.       end
  206.     end
  207.   end
  208. end
  209.  
  210. #==============================================================================
  211. # ** Scene_End
  212. #------------------------------------------------------------------------------
  213. #  Edited to return to the menu properly due to loading being added
  214. #==============================================================================
  215.  
  216. class Scene_End
  217.   alias return_scene_original return_scene
  218.   def return_scene
  219.     $scene = Scene_Menu.new(FFS::DEUTSCH.size - 1)
  220.   end
  221. end
  222.  
  223. #==============================================================================
  224. # ** Window_Location
  225. #------------------------------------------------------------------------------
  226. #  This class shows the current map name.
  227. #==============================================================================
  228.  
  229. class Window_location < Window_Base
  230.   #--------------------------------------------------------------------------
  231.   # * Object Initialization
  232.   #--------------------------------------------------------------------------
  233.   def initialize(x, y)
  234.     super(x, y, 235, (WLH*2) + 32)
  235.     self.contents = Bitmap.new(width - 32, height - 32)
  236.     refresh
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # * Refresh
  240.   #--------------------------------------------------------------------------
  241.   def refresh
  242.     self.contents.clear
  243.     $maps = load_data("Data/MapInfos.rvdata")
  244.     @map_id = $game_map.map_id
  245.     @currmap = $maps[@map_id].name
  246.     self.contents.font.color = system_color
  247.     self.contents.draw_text(0, -4, 128, 32, "")
  248.     self.contents.font.color = normal_color
  249.     self.contents.draw_text(0, -4+WLH, 200, 32, @currmap, 1)
  250.   end
  251. end
  252.  
  253. #==============================================================================
  254. # ** Window_RingMenu
  255. #------------------------------------------------------------------------------
  256. #  This Window creates a Ring Menu system
  257. #==============================================================================
  258.  
  259. class Window_RingMenu < Window_Base  
  260.   #--------------------------------------------------------------------------
  261.   # * Public Instance Variables
  262.   #--------------------------------------------------------------------------
  263.   attr_accessor :index
  264.   attr_reader   :item_max
  265.   #--------------------------------------------------------------------------
  266.   # * Refresh Setup
  267.   #--------------------------------------------------------------------------
  268.   START = 1
  269.   WAIT  = 2
  270.   MOVER = 3
  271.   MOVEL = 4
  272.   #--------------------------------------------------------------------------
  273.   # * Object Initialization
  274.   #--------------------------------------------------------------------------
  275.   def initialize(center_x, center_y, commands, items, move = true, index = 0, character = false)
  276.     super(0, 0, 544, 416)
  277.     self.contents = Bitmap.new(width-32, height-32)
  278.     self.opacity = 0
  279.     @move = move
  280.     @char = character
  281.     @startup = STARTUP_FRAMES
  282.     @commands = commands
  283.     @item_max = commands.size
  284.     @index = index
  285.     @items = items
  286.     @disabled = []
  287.     for i in 0...commands.size-1
  288.       @disabled[i] = false
  289.     end
  290.     @cx = center_x
  291.     @cy = center_y
  292.     start_setup
  293.     refresh
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # * Start Setup
  297.   #--------------------------------------------------------------------------
  298.   def start_setup
  299.     @mode = START
  300.     @steps = @startup
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # * Disable index
  304.   #     index : item number
  305.   #--------------------------------------------------------------------------
  306.   def disable_item(index)
  307.     @disabled[index] = true
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # * Determines if is moving
  311.   #--------------------------------------------------------------------------
  312.   def animation?
  313.     return @mode != WAIT
  314.   end
  315.   #--------------------------------------------------------------------------
  316.   # * Determine if cursor is moveable
  317.   #--------------------------------------------------------------------------
  318.   def cursor_movable?
  319.     return false if (not visible or not active)
  320.     return false if (@opening or @closing)
  321.     return false if animation?
  322.     return true
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # * Move cursor right
  326.   #--------------------------------------------------------------------------
  327.   def cursor_right
  328.     @index -= 1
  329.     @index = @items.size - 1 if @index < 0
  330.     @mode = MOVER
  331.     @steps = MOVING_FRAMES
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # * Move cursor left
  335.   #--------------------------------------------------------------------------
  336.   def cursor_left
  337.     @index += 1
  338.     @index = 0 if @index >= @items.size
  339.     @mode = MOVEL
  340.     @steps = MOVING_FRAMES
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # * Frame Update
  344.   #--------------------------------------------------------------------------
  345.   def update
  346.     super
  347.     if self.active
  348.       if cursor_movable?
  349.         last_index = @index
  350.         if Input.repeat?(Input::DOWN) or Input.repeat?(Input::RIGHT)
  351.           cursor_right
  352.         end
  353.         if Input.repeat?(Input::UP) or Input.repeat?(Input::LEFT)
  354.           cursor_left
  355.         end
  356.         if @index != last_index
  357.           Sound.play_cursor
  358.         end
  359.       end
  360.       refresh
  361.     end
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # * Refresh
  365.   #--------------------------------------------------------------------------
  366.   def refresh    
  367.     self.contents.clear
  368.     case @mode
  369.     when START
  370.       refresh_start
  371.     when WAIT
  372.       refresh_wait
  373.     when MOVER
  374.       refresh_move(1)
  375.     when MOVEL
  376.       refresh_move(0)
  377.     end
  378.     rect = Rect.new(18, 196, self.contents.width-32, 32)
  379.     self.contents.draw_text(rect, @commands[@index], 1)
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # * Refresh Start Period
  383.   #--------------------------------------------------------------------------
  384.   def refresh_start
  385.     d1 = 2.0 * Math::PI / @item_max
  386.     d2 = 1.0 * Math::PI / @startup
  387.     for i in 0...@item_max
  388.       j = i - @index
  389.       if @move
  390.         r = RING_R - 1.0 * RING_R * @steps / @startup
  391.         d = d1 * j + d2 * @steps
  392.       else
  393.         r = RING_R
  394.         d = d1 * j
  395.       end
  396.       x = @cx + ( r * Math.sin( d ) ).to_i
  397.       y = @cy - ( r * Math.cos( d ) ).to_i
  398.       draw_item(x, y, i)
  399.     end
  400.     @steps -= 1
  401.     if @steps < 1
  402.       @mode = WAIT
  403.     end
  404.   end
  405.   #--------------------------------------------------------------------------
  406.   # * Refresh Wait Period
  407.   #--------------------------------------------------------------------------
  408.   def refresh_wait
  409.     d = 2.0 * Math::PI / @item_max
  410.     for i in 0...@item_max
  411.       j = i - @index
  412.       x = @cx + ( RING_R * Math.sin( d * j ) ).to_i
  413.       y = @cy - ( RING_R * Math.cos( d * j ) ).to_i
  414.       draw_item(x, y, i)
  415.     end
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # * Refresh Movement Period
  419.   #--------------------------------------------------------------------------
  420.   def refresh_move( mode )
  421.     d1 = 2.0 * Math::PI / @item_max
  422.     d2 = d1 / MOVING_FRAMES
  423.     d2 *= -1 if mode != 0
  424.     for i in 0...@item_max
  425.       j = i - @index
  426.       d = d1 * j + d2 * @steps
  427.       x = @cx + ( RING_R * Math.sin( d ) ).to_i
  428.       y = @cy - ( RING_R * Math.cos( d ) ).to_i
  429.       draw_item(x, y, i)
  430.     end
  431.     @steps -= 1
  432.     if @steps < 1
  433.       @mode = WAIT
  434.     end
  435.   end
  436.   #--------------------------------------------------------------------------
  437.   # * Draw Item
  438.   #     x     : draw spot x-coordinate
  439.   #     y     : draw spot y-coordinate
  440.   #     index : item number
  441.   #--------------------------------------------------------------------------
  442.   def draw_item(x, y, index)
  443.     if @char
  444.       if @index == index
  445.         draw_character(@items[index].character_name, @items[index].character_index , x, y)
  446.         if @mode == WAIT
  447.           draw_actor_hp_ring(@items[index], @cx, @cy-16, 50, 6, 84, 270, true)
  448.           draw_actor_mp_ring(@items[index], @cx, @cy-16, 50, 6, 84, 180, false)
  449.           draw_actor_exp_ring(@items[index], @cx, @cy-16, 50, 6, 155, 12, false)
  450.         end
  451.       else
  452.         draw_character(@items[index].character_name, @items[index].character_index , x, y, false)
  453.       end
  454.     else
  455.       rect = Rect.new(0, 0, @items[index].width, @items[index].height)
  456.       if @index == index
  457.         self.contents.blt( x, y, @items[index], rect )
  458.         if @disabled[@index]
  459.           self.contents.blt( x, y, ICON_DISABLE, rect )
  460.         end
  461.       else
  462.         self.contents.blt( x, y, @items[index], rect, 128 )
  463.       end
  464.     end
  465.   end
  466. end
  467.  
  468. #==============================================================================
  469. # ** Window_Base
  470. #------------------------------------------------------------------------------
  471. #  Edited to allow disabled character icons
  472. #==============================================================================
  473.  
  474. class Window_Base < Window
  475.   #--------------------------------------------------------------------------
  476.   # * Draw Character Graphic
  477.   #--------------------------------------------------------------------------
  478.   def draw_character(character_name, character_index, x, y, enabled = true)
  479.     return if character_name == nil
  480.     bitmap = Cache.character(character_name)
  481.     sign = character_name[/^[\!\$]./]
  482.     if sign != nil and sign.include?('$')
  483.       cw = bitmap.width / 3
  484.       ch = bitmap.height / 4
  485.     else
  486.       cw = bitmap.width / 12
  487.       ch = bitmap.height / 8
  488.     end
  489.     n = character_index
  490.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  491.     self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enabled ? 255 : 128)
  492.   end
  493. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement