Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

CMS: Equipped items shown as pictures

I'm creating a one-scene menu for a single character. Its almost working as I planned, but since I'm a new scripter, there's some stuff I haven't figured out yet.
The main issue now is how to make a window that shows the equipped items as pictures. Let me illustrate:
http://img204.imageshack.us/img204/4329/shotdr4.th.png[/img]

I guess the code should be something like this:
Code:
# WINDOW_EQUIP =================================================================

class Window_Equip < Window_Base

  # Object Initialization ------------------------------------------------------
  #     actor : actor
  def initialize(actor)
    super(480, 64, 160, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  
  # Refresh --------------------------------------------------------------------
  def refresh
    self.contents.clear
    # Get weapon ID
    case $data_weapons[@actor.weapon_id]
    # Draw weapon pictures
    when 0
      bitmap = RPG::Cache.picture("noweapon")
      self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 64, 192))
    when 1
      bitmap = RPG::Cache.picture("weapon_id1")
      self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 64, 192))
    end

...or something. I couldn' get anything to work correctly, so could someone give me a hint how to proceed? Thank in advance!
 
Can't you just use the icon-names for pictures, making this much more simple?
So the code would be something similar to:
Code:
bitmap = RPG::Cache.picture($data_weapons[@actor.weapon_id].icon_name)
self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 64, 192))
Instead of using cases for every single item, basically have an icon (anything, not like it matters since they won't be used), and have a picture (which will be displayed) with the EXACT same name in the pictures folder. Just do the same with the other gear types. Just go through every type and provide different coordinates for the type.

If you are unsure how to do this, I could bring a rough example code for you if you want.

Hope this helps.
 
Some new issues with my menu:

Firstly, the inventory cursor doesn't show up right, as you can see from the screenie. It should be 32x32, but its much thinner.

Secondly, I need to change the Window_Target to this:

[Use]
  (Uses the item as normal, but only for first actor (since there is only one player character))
[Drop]
  (Removes the item from the inventory (and creates an event in the map where you can pick it up later, this is optional, I might look into it  later if it turns out to be too difficult))
[Cancel]
  (Returns to the inventory)

Finally, I need to somehow "merge" the equip scene to the inventory, so I can equip items in inventory. So, instead of showing the target window, you'd have a window like this when you push an equipment icon in the inventory:

[Equip]/[Unequip]
  (Equips the item or when it is already equipped removes the item from the slot)
[Drop]
  (Same as in the target window)
[Cancel]
  (Same as in the target window)

I might add more options to the equip window, for example [reload] for weapons, but thats for later.

Here's the inventory window:
Code:
# WINDOW_ITEM ==================================================================

class Window_Item < Window_Selectable

  # Object Initialization ------------------------------------------------------
  def initialize
    super(0, 64, 160, 352)
    @column_max = 4
    refresh
    self.index = 0
  end

  # Get Items ------------------------------------------------------------------
  def item
    return @data[self.index]
  end

  # Refresh --------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add items
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    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
    # 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 - 32, row_max * 32)
      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
    x = 4 + index % 4 * 32
    y = index / 4 * 32
    rect = Rect.new(x, y, self.width / @column_max - 24, 24)
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    # Draw item amount
    self.contents.font.size = 14
    self.contents.draw_text(x, y - 8, 24, 24, number.to_s, 2)
  end

  # Help Text Update -----------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.name + ": " + self.item.description)
  end
end

If someone can help with this, I would be very grateful!
 
for the cursor issue, you might want to try writing your own "update_cursor_rect" method for the item window.
in it's most basic form it could look something like
Code:
def update_cursor_rect
  if @index < 0
    self.cursor_rect.empty
  else
    x = @index*32
    y = (@index%4)*32
    self.cursor_rect.set(x,y,32,32)
  end
end

Hope that helps (just put that method somewhere within the Window_Item class)
 
no worries ^_^. If it weren't so cold I would also help you with some of the other stuff, but I'll leave that for some other time/someone else since I can't really think straight and am trying to fix one of my own scripts :P
 
Thats cool. I'm making progress with other things.
By the way, how can I change the saturation of a bitmap? I need the status window to show character state icons in grayscale when inactive and normal color when active.
 
well...I just did a quick search for you on the forums, and it appears there's a color.saturation function. See if you can figure it out from here
That seems to be a nice tool for creating gradient bars and it has that function.
 
Okay, it's been like 10+ days, so i'm bumping this one.

I found a Tone class built in RGSS. It also has a gray value. Does anyone know how to use this to change a bitmap's saturation? Is it even possible or am I completely lost here?
 
It appears to me, without use of extended libraries this is not possible. I have got no luck in finding such a tool for you.
By default RMXP has the Tone class which has the syntax:
Code:
Tone.new(red, green, blue[, gray])
The tone class is applied to the Plane, Sprite and Viewport classes.

Since you were looking for saturation fixes, I guess this is of no use. But bare in mind that as far as I'm concerned saturation cannot be changed without the proper libraries. I wouldn't know which to use in this case.

What exactly are you hoping to accomplish with saturation tools? Maybe we can come up with a different solution if we get to know what you're trying to accomplish.
 
FireRaven":27pr0642 said:
What exactly are you hoping to accomplish with saturation tools? Maybe we can come up with a different solution if we get to know what you're trying to accomplish.

I was looking for a simple way to make inventory items, state icons and other bitmaps inside windows appear in grayscale when inactive.
I thought it would be as easy as changing the saturation in Show Picture in Event commands, but I guess it's too difficult to change it by scripting.  :sad:

Beran":27pr0642 said:
perhaps you could achieve a similar effect by creating a semi-transparant overlay for the menu...or perhaps you should just duplicate all the icons in grayscale...

Yeah, I decided to make grayscacle versions of the icons. It's a pretty simple solution, that's what I first tried, but then I wanted a more 'stylish' way to do it. As you can see from the updated screenie above, it's working fine now (the small window in the lower left corner with 8 icons).
Thanks for help, guys!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top