Large icons

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,613
Reaction score
5,154
First Language
Dutch
Primarily Uses
RMXP
Hi there!
I really want to use 48x48 icons in my game, unfortunately I can't seem to figure out how. :aswt: I know there's a script for VXAce, but I don't seem to find one for XP.
I only really need the big icons in my inventory/item menu.

Also I am using a custom item menu script (Icon Items by Polraudio).

Let me know if something's unclear and I'll do my best to explain :ahappy:
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Try this:
Code:
#==============================================================================#
# ICON ITEMS                                                                   #
# Version: 1.0                                                                 #
# By: Polraudio                                                                #
# Exclusive to RMU or GDU                                                      #
#==============================================================================#
class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 7
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 48, row_max * 48)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = index % 7 * (59+28)
    #x = 2 / 24 + index % 7 * 91
    y = (index / 7) * 48
    rect = Rect.new(x, y, self.width / @column_max - 32, 48)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 255
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 48, 48), opacity)
  
    #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.font.size = 12
    self.contents.font.color = Color.new(0, 0, 0, 255)
    self.contents.draw_text(x + 27, y+2, 24, 32, "x" + number.to_s, 2)
    #self.contents.font.color = normal_color
    self.contents.font.color = Color.new(255, 255, 255, 255)
    self.contents.draw_text(x + 25, y, 24, 32, "x" + number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max
    # Compute rows from number of items and columns
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    # Divide y-coordinate of window contents transfer origin by 1 row
    # height of 32
    return self.oy / 48
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------
  def top_row=(row)
    # If row is less than 0, change it to 0
    if row < 0
      row = 0
    end
    # If row exceeds row_max - 1, change it to row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # Multiply 1 row height by 32 for y-coordinate of window contents
    # transfer origin
    self.oy = row * 48
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max
    # Subtract a frame height of 32 from the window height, and divide it by
    # 1 row height of 32
    return (self.height - 48) / 48
  end 
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get current row
    row = @index / @column_max
    # If current row is before top row
    if row < self.top_row
      # Scroll so that current row becomes top row
      self.top_row = row
    end
    # If current row is more to back than back row
    if row > self.top_row + (self.page_row_max - 1)
      # Scroll so that current row becomes back row
      self.top_row = row - (self.page_row_max - 1)
    end
    # Calculate cursor width
    cursor_width = self.width / @column_max - 32
    # Calculate cursor coordinates
    x = @index % @column_max * (cursor_width + 28)
    y = @index / @column_max * 48 - self.oy
    # Update cursor rectangle
    self.cursor_rect.set(x, y, cursor_width, 48)
  end 
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.name+": "+self.item.description)
  end
end

I had to adapt a few things in his script to allow the pasting of 48x48 icons, and space out the icons in there. I also had to include some edited portions of Window_Selectable which handles the rectangle cursor... lest it not properly scroll for 48x48 icons.

Just a rough draft before I hit the sack. :D

Wait. what? Did the Big Bad VVulf just help out Little Red Riding Hood?
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,613
Reaction score
5,154
First Language
Dutch
Primarily Uses
RMXP
You're my hero! That totally worked. :kaojoy:

Thanks so much, Mr VVulf! :kaothx:
 

Zamazawarma

Villager
Member
Joined
Sep 28, 2020
Messages
10
Reaction score
2
First Language
French
Primarily Uses
RMXP
Hello @DerVVulfman,

Mind if I use this, giving you credit as well as Polraudio?

Edit: Also, I've slightly edited your code to make it work with the 'Pixel Unicode' font, display the amount in the lower-right corner of the "item box", and draw that specific text in black instead of white.

Code:
#==============================================================================#
# ICON ITEMS                                                                   #
# Version: 1.0                                                                 #
# By: Polraudio, edited by DerVVulfmann to work with 48x48 icons               #
# Exclusive to RMU or GDU                                                      #
#==============================================================================#
class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 7
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  #--------------------------------------------------------------------------
  # * Get Item
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 48, row_max * 48)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = index % 7 * (59+28)
    #x = 2 / 24 + index % 7 * 91
    y = (index / 7) * 48
    rect = Rect.new(x, y, self.width / @column_max - 32, 48)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 255
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 48, 48), opacity)

    #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.font.size = 24
    self.contents.font.color = Color.new(100, 100, 100, 255)
    self.contents.draw_text(x + 30, y+1, 24, 72, "x" + number.to_s, 2)
    #self.contents.font.color = normal_color
    self.contents.font.color = Color.new(0, 0, 0, 255)
    self.contents.draw_text(x + 29, y, 24, 72, "x" + number.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max
    # Compute rows from number of items and columns
    return (@item_max + @column_max - 1) / @column_max
  end
  #--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    # Divide y-coordinate of window contents transfer origin by 1 row
    # height of 32
    return self.oy / 48
  end
  #--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------
  def top_row=(row)
    # If row is less than 0, change it to 0
    if row < 0
      row = 0
    end
    # If row exceeds row_max - 1, change it to row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # Multiply 1 row height by 32 for y-coordinate of window contents
    # transfer origin
    self.oy = row * 48
  end
  #--------------------------------------------------------------------------
  # * Get Number of Rows Displayable on 1 Page
  #--------------------------------------------------------------------------
  def page_row_max
    # Subtract a frame height of 32 from the window height, and divide it by
    # 1 row height of 32
    return (self.height - 48) / 48
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    if @index < 0
      self.cursor_rect.empty
      return
    end
    # Get current row
    row = @index / @column_max
    # If current row is before top row
    if row < self.top_row
      # Scroll so that current row becomes top row
      self.top_row = row
    end
    # If current row is more to back than back row
    if row > self.top_row + (self.page_row_max - 1)
      # Scroll so that current row becomes back row
      self.top_row = row - (self.page_row_max - 1)
    end
    # Calculate cursor width
    cursor_width = self.width / @column_max - 32
    # Calculate cursor coordinates
    x = @index % @column_max * (cursor_width + 28)
    y = @index / @column_max * 48 - self.oy
    # Update cursor rectangle
    self.cursor_rect.set(x, y, cursor_width, 48)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.name+": "+self.item.description)
  end
end
 
Last edited:

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

Latest Threads

Latest Profile Posts

Anyone else find it amusing that people watch videos of tragedy and then try to take the "moral high ground" by having sympathy for the victims? Dude, you watched the tragedy for the same reason everyone else. People being injured is an instinctive human curiosity.
Say, does anyone know any other indie game development forums? Progress on my uni survey has been a little slow, so I wanna look into posting it around a bit more.

Forum statistics

Threads
104,305
Messages
1,005,418
Members
135,829
Latest member
LordPenguin666
Top