(RGSS2) Names of some items not visible on custom store menu.

Darth Equus

I *HATE* Parallax Mapping.
Veteran
Joined
Feb 7, 2013
Messages
253
Reaction score
414
First Language
English
Primarily Uses
RMVX
Hello. Hope someone can help me with two slightly annoying problems. I'm using a custom script for a synthesis shop, which I posted a bounty to fix a major problem for, and it seems to be working fine now. The only issue I have now is that the names of any items below the window are either cut off or plain invisible in the list when scrolling down. (Also, the cursor always goes back to the top of the list upon synthesizing an item):

NoShowItem.jpg

At the moment, I can't commission paid work to correct it, but decided to post it here in case it's an easy fix. Can anyone please give me a hand fixing these issues?

Here's the script I'm using:

Ruby:
#==============================================================================
# ** Crafting System.
#------------------------------------------------------------------------------
# The system works in the following way:
#
#     The items that can be crafted are displayed at all times even if the
#     player doesn't have the required items to craft it.
#     Once the player obtains the item, it is removed from the list.
#
#     To call the scene, use the following line in a call script command:
#        call_craft
#
#==============================================================================


module Crafting
  # Title displayed in the crafting command window.
  Title   = 'Crafting List'
  # Recipes for the crafting system.
  Recipes = {
  # [type, id of the final item] => [[type, id of ingredients]]
  [2, 146] => [[2, 74], [0, 113]],
  # [type, id of the final item] => [[type, id of ingredients]]
  [2, 147] => [[2, 84], [0, 113]],
  # [type, id of the final item] => [[type, id of ingredients]]
  [2, 148] => [[2, 93], [0, 113]],
  # [type, id of the final item] => [[type, id of ingredients]]
  [2, 149] => [[2, 103], [0, 113]],
  # [type, id of the final item] => [[type, id of ingredients]]
  [1, 200] => [[0, 500], [0, 501]]
  }
end


#==============================================================================
# ** Window_CraftCommand
#------------------------------------------------------------------------------
#  This window deals with general command choices in the crafting window.
#==============================================================================
class Window_CraftCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :commands
  #--------------------------------------------------------------------------
  # * Object Initialization.
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
    if row_max == 0
      row_max = (commands.size + column_max - 1) / column_max
    end
    super(0, 0, width, 240, spacing)
    @commands = commands
    @item_max = commands.size
    @column_max = column_max
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh.
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 0, self.width - WLH * 2, 32, Crafting::Title, 1)
    self.contents.fill_rect(1, 33, self.width - 2, 1, Color.new(0, 0, 0, 255))
    self.contents.fill_rect(0, 32, self.width, 1, Color.new(255, 255, 255))
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item.
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # * Get rectangle for displaying items.
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = (contents.width + @spacing) / @column_max - @spacing
    rect.height = WLH
    rect.x = index % @column_max * (rect.width + @spacing)
    rect.y = (index / @column_max * WLH) + 48
    return rect
  end
  #--------------------------------------------------------------------------
  # * Stop.
  #--------------------------------------------------------------------------
  def stop
    @craft_animation = true
  end
  #--------------------------------------------------------------------------
  # * Play.
  #--------------------------------------------------------------------------
  def play
    @craft_animation = false
  end
  #--------------------------------------------------------------------------
  # * Determine if cursor is moveable.
  #--------------------------------------------------------------------------
  def cursor_movable?
    return false if (not visible or not active)
    return false if (index < 0 or index > @item_max or @item_max == 0)
    return false if (@opening or @closing)
    return false if @craft_animation
    return true
  end
end
class Game_System
  attr_accessor :equus_craft_done
  #--------------------------------------------------------------------------
  # * Initialize.
  #--------------------------------------------------------------------------
  alias equus_craft_ini initialize
  def initialize
    equus_craft_ini
    @equus_craft_done = []
  end
end
class Scene_Craft < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing.
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_command_window
    create_info_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing.
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @info_window.dispose
    @recipe_sprite.bitmap.dispose if @recipe_sprite.bitmap
    @recipe_sprite.dispose
    @help_plane.bitmap.dispose if @help_plane.bitmap
    @help_plane.dispose
    @plane_viewport.dispose
    @recipe_viewport.dispose
    @congrats_sprite.bitmap.dispose if @congrats_sprite
    @congrats_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update.
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    update_info_animations
    @command_window.update
    if @command_window.active
      update_command_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Create Info Window.
  #--------------------------------------------------------------------------
  def create_info_window
    @recipe_scroll_c = Graphics.frame_rate
    @plane_scroll_c = Graphics.frame_rate
    @info_window = Window_Base.new(192, 88, 352, 240)
    @plane_viewport = Viewport.new(@info_window.x + 16, @info_window.y + 56, 320, 32)
    @help_plane = Plane.new(@plane_viewport)
    @plane_viewport.z = @info_window.z + 100
    @recipe_viewport = Viewport.new(@info_window.x + 16, @info_window.y + 96, 316, 120)
    @recipe_sprite = Sprite.new(@recipe_viewport)
    @recipe_viewport.z = @info_window.z + 100
    @congrats_sprite = Sprite.new
    @congrats_sprite.bitmap = Bitmap.new(544, 88)
    @congrats_sprite.opacity = 0
  end
  #--------------------------------------------------------------------------
  # * Create Command Window.
  #--------------------------------------------------------------------------
  def create_command_window
    @to_craft = []
    @names     = []
    @types     = []
    @handy     = []
    Crafting::Recipes.each {|k, c|
    #next if $game_system.equus_craft_done.include?([k[0], k[1]])
    real_item  = [$data_items, $data_weapons, $data_armors][k[0]][k[1]]
    @handy     << [k[0], k[1]]
    @types     << k[0]
    @names     << real_item.name
    @to_craft << [real_item, c]}
    @disabled = []
    @required = []
    @command_window = Window_CraftCommand.new(192, @names)
    @command_window.height = 240#416
    @command_window.y = 88
    @command_window.index = 0
    @to_craft.each {|craft| check_requirements(craft[0], craft[1])}
  end
  #--------------------------------------------------------------------------
  # * Check Requirements.
  #--------------------------------------------------------------------------
  def check_requirements(item, content)
    items   = []
    weapons = []
    armors  = []
    content.each {|i|
    real_item  = [$data_items, $data_weapons, $data_armors][i[0]][i[1]]
    [items, weapons, armors][i[0]] << real_item}
    [items, weapons, armors].each {|type|
    type.each {|req|
    @required[@to_craft.index([item, content])] ||= []
    @required[@to_craft.index([item, content])] << req
    if $game_party.item_number(req) <= 0
      @disabled[@to_craft.index([item, content])] = true
      @command_window.draw_item(@to_craft.index([item, content]), false)
    end}}
  end
  #--------------------------------------------------------------------------
  # * Process Crafting.
  #--------------------------------------------------------------------------
  def process_crafting(index)
    @required[index].each {|item| $game_party.lose_item(item, 1)}
    $game_party.gain_item(@to_craft[index][0], 1)
    $game_system.equus_craft_done << @handy[index]
    item = @to_craft[index][0]
    @command_window.index = 0
    @command_window.dispose
    create_command_window
    refresh_info
    congrats(item)
  end
  #--------------------------------------------------------------------------
  # * Congrats.
  #--------------------------------------------------------------------------
  def congrats(item)
    t = "You obtained #{item.name}!"
    @congrats_sprite.bitmap.clear
    @congrats_sprite.bitmap.draw_text(0, 0, 544, 88, t, 1)
    @congrats_sprite_stage   = 0
    @congrats_count = 60
  end
  #--------------------------------------------------------------------------
  # * Update Info Animations.
  #--------------------------------------------------------------------------
  def update_info_animations
    @congrats_sprite.update
    if @congrats_sprite_stage == 0
      @congrats_sprite.opacity = [@congrats_sprite.opacity + 5, 255].min
      if @congrats_sprite.opacity >= 255
        @congrats_sprite_stage = 1
      end
    elsif @congrats_sprite_stage == 1
      @congrats_count = [@congrats_count - 1, 0].max
      if @congrats_count <= 0
        @congrats_sprite_stage = 2
      end
    elsif @congrats_sprite_stage == 2
      @congrats_sprite.opacity = [@congrats_sprite.opacity - 5, 0].max
      if @congrats_sprite.opacity <= 0
        @congrats_sprite_stage = 3
      end
    end
    @recipe_viewport.rect.x = @info_window.x + 16
    @recipe_viewport.rect.y = @info_window.y + 96
    @recipe_scroll_c = [@recipe_scroll_c - 1, 0].max
    @plane_viewport.rect.x = @info_window.x + 16
    @plane_viewport.rect.y = @info_window.y + 56
    @plane_scroll_c = [@plane_scroll_c - 1, 0].max
    @plane_viewport.ox += 1 if @plane_scroll_c == 0
    if @recipe_scroll_c == 0
      if @recipe_sprite.bitmap.height > @recipe_viewport.rect.height
        dif = @recipe_sprite.bitmap.height - @recipe_viewport.rect.height
        @recipe_stage ||= 0
        if @recipe_sprite.oy < dif && @recipe_stage == 0
          @recipe_sprite.oy += 1
          if @recipe_sprite.oy == dif
            @recipe_scroll_c = Graphics.frame_rate
            @recipe_stage = 1
          end
        elsif @recipe_sprite.oy > 0 && @recipe_stage == 1
          @recipe_sprite.oy -= 1
          if @recipe_sprite.oy == 0
            @recipe_scroll_c = Graphics.frame_rate
            @recipe_stage = 0
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh Info.
  #--------------------------------------------------------------------------
  def refresh_info
    @recipe_scroll_c = Graphics.frame_rate
    @plane_scroll_c = Graphics.frame_rate
    @plane_viewport.ox = 0
    @recipe_sprite.oy = 0
    @recipe_stage = 0
    @info_window.contents.clear
    @info_window.contents.fill_rect(0, 33, 352, 1, Color.new(0, 0, 0))
    @info_window.contents.fill_rect(0, 32, 352, 1, Color.new(255, 255, 255))
    @info_window.contents.fill_rect(2, 32 * 2 + 14, 318, 128, Color.new(255, 255, 255, 96))
    @info_window.contents.fill_rect(3, 32 * 2 + 15, 316, 126, Color.new(0, 0, 0, 96))
    @info_window.contents.fill_rect(0, 0, 28, 28, Color.new(255, 255, 255, 96))
    @info_window.contents.fill_rect(1, 1, 26, 26, Color.new(0, 0, 0, 96))
    iconi = @to_craft[@command_window.index][0].icon_index
    @info_window.draw_icon(iconi, 2, 2, true)
    @recipe_sprite.bitmap = Bitmap.new(316, 24 * @required[@command_window.index].size)
    @recipe_sprite.bitmap.font.size = Font.default_size - 4
    @required[@command_window.index].each_with_index {|req, i|
    draw_icon_recipe(req, 8, 24 * i, $game_party.item_number(req) > 0)}
    price = @to_craft[@command_window.index][0].price
    desc  = @to_craft[@command_window.index][0].description
    type  = ['Item', 'Weapon', 'Armor'][@types[@command_window.index]]
    name  = @names[@command_window.index]
    text1 = 'Name: '
    text2 = 'Type: '
    text3 = 'Price: ' 
    text = "#{name}, #{type}, #{price}G"
    @info_window.contents.draw_text(32, 0, 304, 32, text, 0)
    ts = Bitmap.new(32, 32)
    tw = ts.text_size(desc).width + 4
    @help_plane.bitmap = Bitmap.new(tw, 32)
    ts.dispose
    @help_plane.bitmap.clear
    @help_plane.bitmap.draw_text(0, 0, tw, 32, desc, 0)
  end
  #--------------------------------------------------------------------------
  # * Draw Icon.
  #--------------------------------------------------------------------------
  def draw_icon_recipe(item, x, y, enabled = true)
    icon_index = item.icon_index
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    @recipe_sprite.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
    itype  = 'Item'   if item.is_a?(RPG::Item)
    itype  = 'Weapon' if item.is_a?(RPG::Weapon)
    itype  = 'Armor'  if item.is_a?(RPG::Armor)
    iprice = item.price
    text   = "#{item.name}, #{itype}, #{iprice}G"
    @recipe_sprite.bitmap.draw_text(x + 32, y - 2, 300, 32, text)
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection.
  #--------------------------------------------------------------------------
  def update_command_selection
    if @command_window.index != @old_command_window_index && @command_window
      @old_command_window_index = @command_window.index
      refresh_info
    end
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if @disabled[@command_window.index]
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      process_crafting(@command_window.index)
    end
  end
end
def call_craft
  $scene = Scene_Craft.new
end
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Welp, ended up at the hospital with the oldest so mebbe might make the game jam's deadline. Maybe not. Regardless, really digging MZ.
I had lots of fun! Kids loved me, and some took pictures. Unfortunately, the videos didn't send... but you'll see Chica in action when I do a trailer for Fandom Scouts!
Dama wrote on akoniti's profile.
Hi
Thanks for your review.
I was checking the trailer for details and as the woman shut the door at the exact moment the song I was hearing said "you slim the door" and I couldn't resist to add it there. :D And I used this idea one more time on another scene.
Just doing some tileset tinkering again...

Forum statistics

Threads
104,690
Messages
1,008,164
Members
136,187
Latest member
dist15
Top