Advertisement
SSTrihan

Mjshi main menu candy/token amendment

Feb 8th, 2023
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.28 KB | Source Code | 0 0
  1. #======================================================================
  2. # A Custom Menu Script by mjshi
  3. #----------------------------------------------------------------------
  4. # Place images into Graphics/System.
  5. #----------------------------------------------------------------------
  6.  
  7. module ACMenu
  8. #----------------------------------------------------------------------
  9. #  Config
  10.   ActorPictures = {
  11.     "1" => "charactercardalice",
  12.     "2" => "charactercardwraps",
  13.     "3" => "charactercardscruffy",
  14.     "4" => "charactercardjekyll",
  15.     "5" => "charactercardbolt",
  16.     "6" => "charactercardwebs",
  17.     "7" => "charactercardbeatrice",
  18.     "8" => "charactercardjackie",
  19.     "9" => "charactercardkenneth",
  20.     "10" => "charactercardmask",
  21.     "11" => "charactercardbarnaby",
  22.     "12" => "charactercardjack",
  23.     "13" => "charactercardscotty",
  24.     "14" => "charactercardrosette",
  25.     "15" => "charactercardfluche",
  26.     "16" => "charactercardmizure",
  27.     "17" => "charactercardwendy",
  28.     "18" => "charactercardkris",
  29.     "19" => "charactercardflynt",
  30.     "20" => "charactercardraven",
  31.     "21" => "charactercardjuno",
  32.     "22" => "charactercardplum",
  33.     "23" => "charactercardbubbles",
  34.     "24" => "charactercardbuckethead",
  35.     "25" => "charactercardhenry",
  36.     "26" => "charactercardskippy",
  37.     "27" => "charactercardfig",
  38.     "28" => "charactercardgwen",
  39.     "29" => "charactercardeva",
  40.     "30" => "charactercardmillie",
  41.     "31" => "charactercardrojo",
  42.     "32" => "charactercardhuntress",
  43.     "33" => "charactercardgeorge",
  44.     "34" => "charactercardmothman",
  45.     "35" => "charactercardalice2",
  46.     "36" => "charactercardludwig",
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.   }
  55.  
  56.   ActorIcons =[
  57.     # Command Name => FileName (place file in Graphics/System
  58.     ["Items", "IconItems"],
  59.     ["Abilities", "IconAbilities"],
  60.     ["Equip", "IconEquip"],
  61.     ["Status", "IconStatus"],
  62.     ["Exit", "IconEscape"],
  63.   ]
  64.  
  65.   # Jekyll's actor id
  66.   Jekyll = 4
  67.   # turn on switch if jekyll's switched
  68.   JekyllSwitch = 108
  69.   # alternate image to use for jekyll when he's switched
  70.   JekyllImage = "charactercardchad"
  71.  
  72.   #-How many columns to show
  73.   Columns = 5
  74.  
  75.   #-Width
  76.   WindowWidth = 300
  77.   WindowHeight = 50
  78.  
  79.   ActorWindowHeight = 294
  80.  
  81.   #-Cursor Icon
  82.   CursorIcon = "IconPointer"
  83.   XOffset = 10
  84.   YOffset = 10
  85.  
  86.   ## edit this if your cursor "jumps"
  87.   InitialCursorLocation = [
  88.     [123, 10],
  89.     [183, 10],
  90.     [243, 10],
  91.     [303, 10],
  92.     [363, 10],
  93.   ]
  94.  
  95.   TextOffset = 35
  96.   FontSize = 12
  97.   CommandOffset = [-5, -3, -3, -2, 0]
  98.   ItemSkillHeightAdjust = 194
  99.  
  100.   HPMPTopBuffer = 180
  101.  
  102.   # [x,y]
  103.   StateIconLocation = [0, 240]
  104.   LvLocation = [54, 148]
  105.  
  106.   GoldIconIndex = 304
  107.   GoldIconOffset = -2
  108.  
  109.   TokenIconIndex = 431
  110.   TokenSwitch = 1461
  111.  
  112. #  ** End Config **
  113. #----------------------------------------------------------------------
  114. end
  115.  
  116. class Window_Base
  117.   def draw_currency_value(value, unit, x, y, width)
  118.     change_color(normal_color)
  119.     draw_text(x, y + 2, width, line_height, value, 1)
  120.     if $game_switches[ACMenu::TokenSwitch]
  121.       icon = ACMenu::TokenIconIndex
  122.       offset = 0
  123.     else
  124.       icon = ACMenu::GoldIconIndex
  125.       offset = ACMenu::GoldIconOffset
  126.     end
  127.     draw_icon(icon, x, y + offset)
  128.   end
  129. end
  130.  
  131. #----------------------------------------------------------------------
  132. #  Window_MenuCommand
  133. #
  134. class Window_MenuCommand
  135.   def initialize
  136.     super((Graphics.width - window_width)/2, 0)
  137.     select_last
  138.   end
  139.  
  140.   # def visible_line_number
  141.   #   return 1
  142.   # end
  143.   def col_max
  144.     return ACMenu::Columns
  145.   end
  146.   def window_height
  147.     return ACMenu::WindowHeight + standard_padding * 2
  148.   end
  149.   def window_width
  150.     return ACMenu::WindowWidth + standard_padding * 1.5
  151.   end
  152.   def contents_height
  153.     return ACMenu::WindowHeight
  154.   end
  155.   def item_width
  156.     return ACMenu::WindowWidth / col_max
  157.   end
  158.   def item_height
  159.     return ACMenu::WindowHeight
  160.   end
  161.   def contents_width
  162.     return ACMenu::WindowWidth
  163.   end
  164.   def top_col
  165.     ox / (item_width + spacing)
  166.   end
  167.   def top_col=(col)
  168.     col = 0 if col < 0
  169.     col = col_max - 1 if col > col_max - 1
  170.     self.ox = col * (item_width + spacing)
  171.   end
  172.   def bottom_col
  173.     top_col + col_max - 1
  174.   end
  175.   def bottom_col=(col)
  176.     self.top_col = col - (col_max - 1)
  177.   end
  178.   def ensure_cursor_visible
  179.     self.top_col = index if index < top_col
  180.     self.bottom_col = index if index > bottom_col
  181.   end
  182.   def item_rect(index)
  183.     rect = super
  184.     rect.x = index * (item_width + spacing)
  185.     rect.y = 0
  186.     rect
  187.   end
  188.  
  189.   def draw_image(file, index, enabled = true)
  190.     bitmap = Cache.system(file)
  191.     rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  192.     contents.blt(contents.width / col_max * index, 0, bitmap, rect, enabled ? 255 : translucent_alpha)
  193.   end
  194.  
  195.   def draw_item(index)
  196.     draw_image(ACMenu::ActorIcons[index][1], index, command_enabled?(index))
  197.     rect = item_rect(index)
  198.     contents.font.size = ACMenu::FontSize
  199.     draw_text(index * item_width + ACMenu::CommandOffset[index], rect.y + ACMenu::TextOffset, item_width, line_height, command_name(index), 1)
  200.   end
  201.  
  202.   def make_command_list
  203.     add_command(ACMenu::ActorIcons[0][0],   :item)
  204.     add_command(ACMenu::ActorIcons[1][0],   :skill)
  205.     add_command(ACMenu::ActorIcons[2][0],   :equip)
  206.     add_command(ACMenu::ActorIcons[3][0],   :status)
  207.     add_command(ACMenu::ActorIcons[4][0],   :game_end)
  208.   end
  209.  
  210.   def update_help
  211.     @help_window.set_text(command_name(index))
  212.   end
  213.  
  214.   def update_cursor
  215.   end
  216.  
  217.   def process_ok
  218.     @@last_command_symbol = current_symbol
  219.     super
  220.   end
  221. end
  222.  
  223. class Scene_Menu
  224.   def create_gold_window
  225.     @gold_window = Window_Gold.new
  226.     @gold_window.x = (Graphics.width - @gold_window.width) / 2
  227.     @gold_window.y = Graphics.height - @gold_window.height
  228.   end
  229.  
  230.   def create_command_window
  231.     @command_window = Window_MenuCommand.new
  232.     @command_window.set_handler(:item,      method(:command_item))
  233.     @command_window.set_handler(:skill,     method(:command_personal))
  234.     @command_window.set_handler(:equip,     method(:command_personal))
  235.     @command_window.set_handler(:status,    method(:command_personal))
  236.     @command_window.set_handler(:game_end,  method(:command_game_end))
  237.     @command_window.set_handler(:cancel,    method(:return_scene))
  238.     @command_window.arrows_visible = false
  239.    
  240.     bitmap = Cache.system(ACMenu::CursorIcon)
  241.     rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  242.     @pointer = Window_Base.new(0, 0, bitmap.width + @command_window.standard_padding * 2, bitmap.height + @command_window.standard_padding * 2)
  243.     @pointer.opacity = 0
  244.     @pointer.contents.blt(0, 0, bitmap, rect)
  245.     @pointer.x = ACMenu::InitialCursorLocation[@command_window.index][0]
  246.     @pointer.y = ACMenu::InitialCursorLocation[@command_window.index][1]
  247.    
  248.     @pointer.arrows_visible = false
  249.     @pointer.visible = true
  250.   end
  251.  
  252.   def create_status_window
  253.     @status_window = Window_MenuStatus.new(0, @command_window.height)
  254.     @status_window.height = Graphics.height - @command_window.height - @gold_window.height
  255.   end
  256.  
  257.   alias acmenu_update_basic update_basic
  258.   def update_basic(*args)
  259.     acmenu_update_basic(*args)
  260.     update_pointer
  261.   end
  262.  
  263.   def update_pointer
  264.     @lastindex = -1 if !defined? @lastindex
  265.     @pointer.visible = @command_window.visible
  266.    
  267.    # uncomment below to find the cursor x, y position for initial setup
  268.   #  puts @pointer.x.to_s + " " + @pointer.y.to_s
  269.    
  270.     return if !@pointer.visible
  271.     @lastindex = @command_window.index
  272.    
  273.     if @lastindex >= 0
  274.       rect = Rect.new(@command_window.x + @command_window.contents.width / @command_window.col_max * @lastindex, @command_window.y, @command_window.contents.width, @command_window.contents.height)
  275.       @pointer.x = rect.x + ACMenu::XOffset
  276.       @pointer.y = rect.y + ACMenu::YOffset
  277.     end
  278.   end
  279. end
  280.  
  281. class Window_MenuStatus
  282.   def draw_item(idx)
  283.     #TODO: draw slices instead of stuff
  284.    
  285.     actor = $game_party.members[idx]
  286.     enabled = $game_party.battle_members.include?(actor)
  287.     rect = item_rect(idx)
  288.    
  289.     if ACMenu::ActorPictures[actor.id.to_s]
  290.       if actor.id == ACMenu::Jekyll && $game_switches[ACMenu::JekyllSwitch]
  291.         acmenu_draw_image(ACMenu::JekyllImage, rect.x + 2, rect.y + 2)
  292.       else
  293.         acmenu_draw_image(ACMenu::ActorPictures[actor.id.to_s], rect.x + 2, rect.y + 2)
  294.       end
  295.     end
  296.     draw_item_background(idx)
  297.    
  298.     rect.x += 2
  299.     change_color(text_color(0))
  300.     draw_text(rect.x + ACMenu::LvLocation[0], rect.y + ACMenu::LvLocation[1], rect.width, line_height, actor.level)
  301.     reset_font_settings
  302.     draw_actor_icons(actor, rect.x + ACMenu::StateIconLocation[0], rect.y + ACMenu::StateIconLocation[1])
  303.     draw_actor_hp(actor, rect.x, rect.y + ACMenu::HPMPTopBuffer)
  304.     draw_actor_mp(actor, rect.x, rect.y + ACMenu::HPMPTopBuffer + line_height)
  305.   end
  306.  
  307.   def window_width
  308.     Graphics.width
  309.   end
  310.  
  311.   def window_height
  312.     ACMenu::ActorWindowHeight
  313.   end
  314.   def item_height
  315.     window_height - standard_padding * 2
  316.   end
  317.   def item_max
  318.     $game_party.members.size
  319.   end
  320.   def visible_line_number
  321.     return 1
  322.   end
  323.   def col_max
  324.     return 4
  325.   end
  326.   def spacing
  327.     return 8
  328.   end
  329.   def contents_width
  330.     (item_width + spacing) * item_max - spacing
  331.   end
  332.   def contents_height
  333.     item_height
  334.   end
  335.  
  336.   def top_col
  337.     ox / (item_width + spacing)
  338.   end
  339.   def top_col=(col)
  340.     col = 0 if col < 0
  341.     self.ox = (col - 3) * (item_width + spacing)
  342.   end
  343.   def bottom_col
  344.     top_col + col_max - 1
  345.   end
  346.   def bottom_col=(col)
  347.     self.top_col = col - (col_max - 1)
  348.   end
  349.  
  350.   def ensure_cursor_visible
  351.     self.top_col = index + 3 if index < top_col
  352.     self.top_col = index if index > bottom_col
  353.   end
  354.  
  355.   def item_rect(index)
  356.     rect = super
  357.     rect.x = index * (item_width + spacing)
  358.     rect.y = 0
  359.     rect
  360.   end
  361.  
  362.   def cursor_down(wrap = false);  end;
  363.   def cursor_up(wrap = false);  end;
  364.   def cursor_pagedown; end;
  365.   def cursor_pageup; end;
  366.  
  367.   def acmenu_draw_image(file, x, y)
  368.     bitmap = Cache.system(file)
  369.     rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  370.     contents.blt(x, y, bitmap, rect)
  371.   end
  372.  
  373.   def draw_item_background(index)
  374.     if index == @pending_index
  375.       contents.fill_rect(item_rect(index), pending_color)
  376.     end
  377.   end
  378. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement