Advertisement
FlipelyFlip

Menu Sys

Jul 16th, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 18.42 KB | None | 0 0
  1. #===================================================
  2. # ¦ Ring Menu - Show Player Location - Release #1 (Enhanced By Dubealex)
  3. #===================================================
  4. # For more infos and update, visit:
  5. # asylum.dubealex.com
  6. #
  7. # Original Ring Menu by: ?? (From XRXS)
  8. # Original Edit and Fix by: Maki
  9. # Show Player Location Version by: Dubealex
  10. #
  11. # You can customize this script at line #35 - Have fun !!
  12. # If you want to show more stuff, its easy to do, you can try to ask in the forum.
  13. #
  14. # alex@dubealex.com
  15. #===================================================
  16.  
  17.  
  18. #===================================================
  19. # ? CLASS Scene_Menu Begins
  20. #===================================================
  21.  
  22. class Scene_Menu
  23. #--------------------------------------------------------------------------
  24. # ?? ?I?u?W?F?N?g??????
  25. # menu_index : ?R?}???h??J?[?\????????u
  26. #--------------------------------------------------------------------------
  27.   def initialize(menu_index = 0)
  28.     @menu_index = menu_index
  29.     $location_text=[]
  30.     $window_size=[]
  31.     $ring_menu_text=[]
  32.     $chara_select=[]
  33.     @window_opacity=[]
  34.     @chara_select=[]
  35.     @window_position=[]
  36.  
  37.   #--------------------------------------------------------------------------------------------------
  38.   # ¦ Ring Menu Customization Section: (By Dubealex)
  39.   #--------------------------------------------------------------------------------------------------
  40.   # Those variables defines how the script will act.
  41.   # Simply change the value by those you want.
  42.   # Remember that changing the font size has its limitation due to text space allocation.
  43.   #
  44.   # ? TEXT SETTINGS FOR SHOW PLAYER LOCATION WINDOW:
  45.   $location_text[0]="Tahoma"  # Font Type
  46.   $location_text[1]=22    # Font Size
  47.   $location_text[2]=6  # Location Title Color
  48.   $location_text[4]=0  # Map Name Color
  49.   $location_text[3]="Location:" # Customize the "Location" Title Text
  50.  
  51.   # ? SHOW LOCATION WINDOW SETTINS:
  52.   @show_location_window=false   #Set to false to not use it !
  53.   @window_opacity[0]=255 # Border Opacity
  54.   @window_opacity[1]=130 # Background Opacity
  55.   $window_location_skin="Pheniox"    # Window Skin
  56.   @window_position[0]=20 # X Axis Position
  57.   @window_position[1]=20 # Y Axis Position
  58.   $window_size[0]=160  # Lengh
  59.   $window_size[1]=96    # Heigh
  60.  
  61.   # ?  TEXT SETTINGS FOR INSIDE THE RING MENU:
  62.   $ring_menu_text[0]="Tahoma"  # Font Type
  63.   $ring_menu_text[7]=0  # Font Color
  64.   $ring_menu_text[8]=22    # Font Size
  65.   $ring_menu_text[1]="Key Items" # Items Menu Text
  66.   $ring_menu_text[2]="Controls"  # Skills Menu Text
  67.   $ring_menu_text[3]="Save"  # Save Menu Text
  68.   $ring_menu_text[4]="Quit"   # Quit Menu Text
  69.  
  70.   # ?  CHARACTER SELECTION WINDOW SETTINGS :
  71.   @chara_select[0]=400   # X Axis Position
  72.   @chara_select[1]=0  # Y Axis Position
  73.   $chara_select[0]="Tahoma"   # Font Type
  74.   $chara_select[1]=0   # Font Color
  75.   $chara_select[5]=22  # Font Size
  76.   $chara_select[2]=255   # Window Border Opacity
  77.   $chara_select[3]=130   # Window Background Opacity
  78.   $chara_select[4]="Pheniox"  # Window Skin to use
  79.  #--------------------------------------------------------------------------------------------------
  80.  
  81.   end
  82. #--------------------------------------------------------------------------
  83. # ?? ???C?????
  84. #--------------------------------------------------------------------------
  85.   def main
  86.  
  87.  # Show Player Location Feature:
  88.     if @show_location_window==true    
  89.  @window_location = Window_Location.new
  90. @window_location.x = @window_position[0]
  91. @window_location.y = @window_position[1]
  92. @window_location.opacity = @window_opacity[0]
  93. @window_location.back_opacity = @window_opacity[1]
  94.     end
  95.  #End of Show Player Location
  96.  
  97.  # ?X?v???C?g?Z?b?g???? ?
  98.  @spriteset = Spriteset_Map.new
  99.  # ?R?}???h?E?B???h?E???? ?
  100.  px = $game_player.screen_x - 15
  101.  py = $game_player.screen_y - 24
  102.  @command_window = Window_RingMenu.new(px,py)
  103.  @command_window.index = @menu_index
  104.  # ?p?[?e?B l ??? 0  l??????
  105.    if $game_party.actors.size == 0
  106.    # ?A?C?e???A?X?L???A?????A?X?e?[?^?X????????
  107.    @command_window.disable_item(0)
  108.    @command_window.disable_item(1)
  109.    end
  110.  @command_window.z = 100
  111.  # ?Z?[?u??~??????
  112.    if $game_system.save_disabled
  113.    # ?Z?[?u???????????
  114.    @command_window.disable_item(4)
  115.    end
  116.  # ?X?e?[?^?X?E?B???h?E???? ?
  117.  @status_window = Window_RingMenuStatus.new
  118.  @status_window.x = @chara_select[0]
  119.  @status_window.y = @chara_select[1]
  120.  @status_window.z = 200
  121.  @status_window.opacity=$chara_select[2]
  122.  @status_window.back_opacity=$chara_select[3]
  123.  @status_window.visible = false
  124.  # ?g?????W?V???????s
  125.  Graphics.transition
  126.  # ???C?????[?v
  127.  loop do
  128.    # ?Q?[????????X V
  129.    Graphics.update
  130.    # ???????????X V
  131.    Input.update
  132.    # ?t???[???X V
  133.    update
  134.    # ????? ????????????[?v?????f
  135.    if $scene != self
  136.      break
  137.    end
  138.  end
  139.  # ?g?????W?V????????
  140.  Graphics.freeze
  141.  # ?X?v???C?g?Z?b?g??????
  142.  @spriteset.dispose
  143.  # ?E?B???h?E??????
  144.  if @show_location_window==true
  145.  @window_location.dispose
  146.  end
  147.  @command_window.dispose
  148.  @status_window.dispose
  149. end
  150. #--------------------------------------------------------------------------
  151. # ?? ?t???[???X V
  152. #--------------------------------------------------------------------------
  153. def update
  154.  # ?E?B???h?E???X V
  155.  if @show_location_window==true
  156.  @window_location.update
  157.  end
  158.  @command_window.update
  159.  @status_window.update
  160.  # ?R?}???h?E?B???h?E???A?N?e?B?u??????: update_command ?????
  161.  if @command_window.active
  162.    update_command
  163.    return
  164.  end
  165.  # ?X?e?[?^?X?E?B???h?E???A?N?e?B?u??????: update_status ?????
  166.  if @status_window.active
  167.    update_status
  168.    return
  169.  end
  170. end
  171. #--------------------------------------------------------------------------
  172. # ?? ?t???[???X V (?R?}???h?E?B???h?E???A?N?e?B?u??????)
  173. #--------------------------------------------------------------------------
  174. def update_command
  175.  # B ?{?^??????????????
  176.  if Input.trigger?(Input::B)
  177.    # ?L?????Z?? SE ?????t
  178.    $game_system.se_play($data_system.cancel_se)
  179.    # ?}?b?v????? ?????
  180.    $scene = Scene_Map.new
  181.    return
  182.  end
  183.  # C ?{?^??????????????
  184.  if Input.trigger?(Input::C)
  185.    # ?p?[?e?B l ??? 0  l???A?Z?[?u?A?Q?[???I????O??R?}???h??????
  186.    if $game_party.actors.size == 0 and @command_window.index < 2
  187.  # ?u?U?[ SE ?????t
  188.  $game_system.se_play($data_system.buzzer_se)
  189.  return
  190.    end
  191.    # ?R?}???h?E?B???h?E??J?[?\????u?????
  192.    case @command_window.index
  193.    when 0  # ?A?C?e??
  194.  # ????  SE ?????t
  195.  $game_system.se_play($data_system.decision_se)
  196.  # ?A?C?e??????? ?????
  197.  $scene = Scene_Item.new
  198.    when 1  # ?X?L??
  199.  # ???? SE ?????t
  200.  $game_system.se_play($data_system.decision_se)
  201.  # ?X?e?[?^?X?E?B???h?E???A?N?e?B?u?????
  202.  @command_window.active = false
  203.  @status_window.active = true
  204.  @status_window.visible = true
  205.  @status_window.index = 0
  206.    when 2  # ????
  207.  # ?Z?[?u??~??????
  208.  if $game_system.save_disabled
  209.    # ?u?U?[ SE ?????t
  210.    $game_system.se_play($data_system.buzzer_se)
  211.    return
  212.  end
  213.  # ???? SE ?????t
  214.  $game_system.se_play($data_system.decision_se)
  215.  # ?Z?[?u????? ?????
  216.  $scene = Scene_Save.new
  217.    when 3  # ?Q?[???I??
  218.  # ???? SE ?????t
  219.  $game_system.se_play($data_system.decision_se)
  220.  # ?Q?[???I??????? ?????
  221.  $scene = Scene_End.new
  222.    end
  223.    return
  224.  end
  225.  # ?A?j???[?V??????????J?[?\??????? ???s?????
  226.  return if @command_window.animation?
  227.  # ??or?? ?{?^??????????????
  228.  if Input.press?(Input::UP) or  Input.press?(Input::LEFT)
  229.    $game_system.se_play($data_system.cursor_se)
  230.    @command_window.setup_move_move(Window_RingMenu::MODE_MOVEL)
  231.    return
  232.  end
  233.  # ??or?? ?{?^??????????????
  234.  if Input.press?(Input::DOWN) or  Input.press?(Input::RIGHT)
  235.    $game_system.se_play($data_system.cursor_se)
  236.    @command_window.setup_move_move(Window_RingMenu::MODE_MOVER)
  237.    return
  238.  end
  239. end
  240. end
  241. #--------------------------------------------------------------------------
  242. # ?? ?t???[???X V (?X?e?[?^?X?E?B???h?E???A?N?e?B?u??????)
  243. #--------------------------------------------------------------------------
  244. def update_status
  245.  # B ?{?^??????????????
  246.  if Input.trigger?(Input::B)
  247.    # ?L?????Z?? SE ?????t
  248.    $game_system.se_play($data_system.cancel_se)
  249.    # ?R?}???h?E?B???h?E???A?N?e?B?u?????
  250.    @command_window.active = true
  251.    @status_window.active = false
  252.    @status_window.visible = false
  253.    @status_window.index = -1
  254.    return
  255.  end
  256.  # C ?{?^??????????????
  257.  if Input.trigger?(Input::C)
  258.    # ?R?}???h?E?B???h?E??J?[?\????u?????
  259.    case @command_window.index
  260.    when 1  # ?X?L??
  261.  # ????A?N?^?[???s?? ????? 2 ??????????
  262.  if $game_party.actors[@status_window.index].restriction >= 2
  263.    # ?u?U?[ SE ?????t
  264.    $game_system.se_play($data_system.buzzer_se)
  265.    return
  266.  end
  267.  # ???? SE ?????t
  268.  $game_system.se_play($data_system.decision_se)
  269.  # ?X?L??????? ?????
  270.  $scene = Scene_Skill.new(@status_window.index)
  271.    return
  272.  end
  273. end
  274. end
  275.  
  276. #===================================================
  277. # ? CLASS Scene_Menu Ends
  278. #===================================================
  279.  
  280.  
  281. #===================================================
  282. # ? CLASS Window_RingMenu  Begins
  283. #===================================================
  284. class Window_RingMenu < Window_Base
  285. #--------------------------------------------------------------------------
  286. # ?? ?N???X?? ?
  287. #--------------------------------------------------------------------------
  288. STARTUP_FRAMES = 20
  289. MOVING_FRAMES = 5  
  290. RING_R = 64    
  291. ICON_ITEM   = RPG::Cache.icon("034-Item03")
  292. ICON_SKILL  = RPG::Cache.icon("049-Skill06")
  293. ICON_SAVE   = RPG::Cache.icon("save")
  294. ICON_EXIT   = RPG::Cache.icon("Quit")
  295. ICON_DISABLE= RPG::Cache.icon("")
  296. SE_STARTUP = "terrain2"
  297. MODE_START = 1
  298. MODE_WAIT  = 2
  299. MODE_MOVER = 3
  300. MODE_MOVEL = 4
  301. #--------------------------------------------------------------------------
  302. # ?? ?A?N?Z?T
  303. #--------------------------------------------------------------------------
  304. attr_accessor :index
  305. #--------------------------------------------------------------------------
  306. # ?? ?I?u?W?F?N?g??????
  307. #--------------------------------------------------------------------------
  308. def initialize( center_x, center_y )
  309.  super(0, 0, 640, 480)
  310.  self.contents = Bitmap.new(width-32, height-32)
  311.  self.contents.font.name = $ring_menu_text[0]
  312.  self.contents.font.color = text_color($ring_menu_text[7])
  313.  self.contents.font.size = $ring_menu_text[8]
  314.  self.opacity = 0
  315.  self.back_opacity = 0
  316.  s1 = $ring_menu_text[1]
  317.  s2 = $ring_menu_text[2]
  318.  s3 = $ring_menu_text[3]
  319.  s4 = $ring_menu_text[4]
  320.  @commands = [ s1, s2, s3, s4 ]
  321.  @item_max = 4
  322.  @index = 0
  323.  @items = [ ICON_ITEM, ICON_SKILL, ICON_SAVE, ICON_EXIT ]
  324.  @disabled = [ false, false, false, false ]
  325.  @cx = center_x - 16
  326.  @cy = center_y - 16
  327.  setup_move_start
  328.  refresh
  329. end
  330. #--------------------------------------------------------------------------
  331. # ?? ?t???[???X V
  332. #--------------------------------------------------------------------------
  333. def update
  334.  super
  335.  refresh
  336. end
  337. #--------------------------------------------------------------------------
  338. # ?? ??????`??
  339. #--------------------------------------------------------------------------
  340. def refresh
  341.  self.contents.clear
  342.  # ?A?C?R?????`??
  343.  case @mode
  344.  when MODE_START
  345.    refresh_start
  346.  when MODE_WAIT
  347.    refresh_wait
  348.  when MODE_MOVER
  349.    refresh_move(1)
  350.  when MODE_MOVEL
  351.    refresh_move(0)
  352.  end
  353.  # ?A?N?e?B?u??R?}???h???\??
  354.  rect = Rect.new(@cx - 272, @cy + 24, self.contents.width-32, 32)
  355.  self.contents.draw_text(rect, @commands[@index],1)
  356. end
  357. #--------------------------------------------------------------------------
  358. # ?? ??????`??(????????)
  359. #--------------------------------------------------------------------------
  360. def refresh_start
  361.  d1 = 2.0 * Math::PI / @item_max
  362.  d2 = 1.0 * Math::PI / STARTUP_FRAMES
  363.  r = RING_R - 1.0 * RING_R * @steps / STARTUP_FRAMES
  364.  for i in 0...@item_max
  365.    j = i - @index
  366.    d = d1 * j + d2 * @steps
  367.    x = @cx + ( r * Math.sin( d ) ).to_i
  368.    y = @cy - ( r * Math.cos( d ) ).to_i
  369.    draw_item(x, y, i)
  370.  end
  371.  @steps -= 1
  372.  if @steps < 1
  373.    @mode = MODE_WAIT
  374.  end
  375. end
  376. #--------------------------------------------------------------------------
  377. # ?? ??????`??(??@??)
  378. #--------------------------------------------------------------------------
  379. def refresh_wait
  380.  d = 2.0 * Math::PI / @item_max
  381.  for i in 0...@item_max
  382.    j = i - @index
  383.    x = @cx + ( RING_R * Math.sin( d * j ) ).to_i
  384.    y = @cy - ( RING_R * Math.cos( d * j ) ).to_i
  385.    draw_item(x, y, i)
  386.  end
  387. end
  388. #--------------------------------------------------------------------------
  389. # ?? ??????`??(???]??)
  390. #  mode : 0=?????v???? 1=???v????
  391. #--------------------------------------------------------------------------
  392. def refresh_move( mode )
  393.  d1 = 2.0 * Math::PI / @item_max
  394.  d2 = d1 / MOVING_FRAMES
  395.  d2 *= -1 if mode != 0
  396.  for i in 0...@item_max
  397.    j = i - @index
  398.    d = d1 * j + d2 * @steps
  399.    x = @cx + ( RING_R * Math.sin( d ) ).to_i
  400.    y = @cy - ( RING_R * Math.cos( d ) ).to_i
  401.    draw_item(x, y, i)
  402.  end
  403.  @steps -= 1
  404.  if @steps < 1
  405.    @mode = MODE_WAIT
  406.  end
  407. end
  408. #--------------------------------------------------------------------------
  409. # ?? ?????`??
  410. # x :
  411. # y :
  412. # i : ???????
  413. #--------------------------------------------------------------------------
  414. def draw_item(x, y, i)
  415.  #p "x=" + x.to_s + " y=" + y.to_s + " i=" + @items[i].to_s
  416.  rect = Rect.new(0, 0, @items[i].width, @items[i].height)
  417.  if @index == i
  418.    self.contents.blt( x, y, @items[i], rect )
  419.    if @disabled[@index]
  420.  self.contents.blt( x, y, ICON_DISABLE, rect )
  421.    end
  422.  else
  423.    self.contents.blt( x, y, @items[i], rect, 128 )
  424.    if @disabled[@index]
  425.  self.contents.blt( x, y, ICON_DISABLE, rect, 128 )
  426.    end
  427.  end
  428. end
  429. #--------------------------------------------------------------------------
  430. # ?? ??????????????
  431. # index : ???????
  432. #--------------------------------------------------------------------------
  433. def disable_item(index)
  434.  @disabled[index] = true
  435. end
  436. #--------------------------------------------------------------------------
  437. # ?? ???????A?j???[?V??????????
  438. #--------------------------------------------------------------------------
  439. def setup_move_start
  440.  @mode = MODE_START
  441.  @steps = STARTUP_FRAMES
  442.  if  SE_STARTUP != nil and SE_STARTUP != ""
  443.    Audio.se_play("Audio/SE/" + SE_STARTUP, 80, 100)
  444.  end
  445. end
  446. #--------------------------------------------------------------------------
  447. # ?? ???]?A?j???[?V??????????
  448. #--------------------------------------------------------------------------
  449. def setup_move_move(mode)
  450.  if mode == MODE_MOVER
  451.    @index -= 1
  452.    @index = @items.size - 1 if @index < 0
  453.  elsif mode == MODE_MOVEL
  454.    @index += 1
  455.    @index = 0 if @index >= @items.size
  456.  else
  457.    return
  458.  end
  459.  @mode = mode
  460.  @steps = MOVING_FRAMES
  461. end
  462. #--------------------------------------------------------------------------
  463. # ?? ?A?j???[?V?????????????
  464. #--------------------------------------------------------------------------
  465. def animation?
  466.  return @mode != MODE_WAIT
  467. end
  468. end
  469.  
  470. #===================================================
  471. # ? CLASS Window_RingMenu Ends
  472. #===================================================
  473.  
  474.  
  475. #===================================================
  476. # ? CLASS Window_RingMenuStatus Begins
  477. #===================================================
  478.  
  479. class Window_RingMenuStatus < Window_Selectable
  480. #--------------------------------------------------------------------------
  481. # ?? ?I?u?W?F?N?g??????
  482. #--------------------------------------------------------------------------
  483. def initialize
  484.  super(204, 64, 232, 352)
  485.  self.contents = Bitmap.new(width - 32, height - 32)
  486.  self.contents.font.size = $chara_select[5]
  487.  refresh
  488.  self.active = false
  489.  self.index = -1
  490. end
  491. #--------------------------------------------------------------------------
  492. # ?? ???t???b?V??
  493. #--------------------------------------------------------------------------
  494. def refresh
  495.  self.contents.clear
  496.  self.windowskin = RPG::Cache.windowskin($chara_select[4])
  497.  self.contents.font.name = $chara_select[0]
  498.  self.contents.font.color = text_color($chara_select[1])
  499.  @item_max = $game_party.actors.size
  500.  for i in 0...$game_party.actors.size
  501.    x = 80
  502.    y = 80 * i
  503.    actor = $game_party.actors[i]
  504.    draw_actor_graphic(actor, x - 40, y + 80)
  505.    draw_actor_name(actor, x, y + 24)
  506.  end
  507. end
  508. #--------------------------------------------------------------------------
  509. # ?? ?J?[?\??????`?X V
  510. #--------------------------------------------------------------------------
  511. def update_cursor_rect
  512.  if @index < 0
  513.    self.cursor_rect.empty
  514.  else
  515.    self.cursor_rect.set(0, @index * 80, self.width - 32, 80)
  516.  end
  517. end
  518. end
  519. #===================================================
  520. # ? CLASS Window_RingMenuStatus Ends
  521. #===================================================
  522.  
  523.  
  524. #===================================================
  525. # ? CLASS Game_Map Additional Code Begins
  526. #===================================================
  527. class Game_Map
  528.  
  529. #Dubealex Addition (from XRXS) to show Map Name on screen
  530. def name
  531.  $map_infos[@map_id]
  532. end
  533. end
  534.  
  535. #===================================================
  536. # ? CLASS Game_Map Additional Code Ends
  537. #===================================================
  538.  
  539.  
  540. #===================================================
  541. # ? CLASS Scene_Title Additional Code Begins
  542. #===================================================
  543. class Scene_Title
  544.  
  545. #Dubealex Addition (from XRXS) to show Map Name on screen
  546.  $map_infos = load_data("Data/MapInfos.rxdata")
  547.  for key in $map_infos.keys
  548.    $map_infos[key] = $map_infos[key].name
  549.  end
  550. end
  551.  
  552. #===================================================
  553. # ? CLASS Scene_Title Additional Code Ends
  554. #===================================================
  555.  
  556.  
  557. #===================================================
  558. # ? CLASS Window_Location Begins
  559. #===================================================
  560.  
  561. class Window_Location < Window_Base
  562.  
  563. def initialize
  564. super(0, 0, $window_size[0], $window_size[1])
  565.  self.contents = Bitmap.new(width - 32, height - 32)
  566.  self.contents.font.name = $location_text[0]
  567.  self.contents.font.size = $location_text[1]
  568. refresh
  569. end
  570.  
  571. def refresh
  572. self.contents.clear
  573. self.windowskin = RPG::Cache.windowskin($window_location_skin)
  574. self.contents.font.color = text_color($location_text[2])
  575. self.contents.draw_text(4, 0, 120, 32, $location_text[3])
  576. self.contents.font.color = text_color($location_text[4])
  577. self.contents.draw_text(4, 32, 120, 32, $game_map.name, 2)
  578. end
  579. end
  580. #===================================================
  581. # ? CLASS Window_Location Ends
  582. #===================================================
  583.  
  584. #===================================================
  585. # ? Ring Menu - Show Player Location R1 - Ends
  586. #===================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement