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.

[resolved] Status Window Selectable-Highlight?

lmkris

Member

Random question...

Is it possible to make the selectable-highlight surround the image inside it, and not the whole status window?

Err, an example for clarification...  Let's say, in the status window, I'd want just hte face graphic to be highlighted when selecting the character for the items/skills/status whatever.  How would I tell it to just highlight the image and not the whole character's section?  Is that possible?

Thanks; if I'm not making any sense, let me know and I'll try to explain better. :thumb:
 

khmp

Sponsor

Yes it is possible. You would need to override the Window_Status.update_cursor_rect method. It just requires playing around with the numbers a bit. Normally:
Code:
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
#self.cursor_rect.set(x, y, width, height)
We can keep the math that offsets the y which is @index * 116 but we will add to it so it isn't awkward looking. The third parameter is the width. By default it's given the whole editable portion of the window. This you will need to shrink to something much smaller. The fourth and final parameter is the height of the rect. If we added to the second parameter we should decrease the height by an amount a tad larger than what was added to y parameter.

Code:
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 116 + 24, 48, 64)
    end
  end
end

Good luck with it Imkris! :thumb:
 

lmkris

Member

Thanks - I'll play with it!

... *snort*  I never realized how 12-year-old lmkris looks if the L gets turned into an I. It's short for "Le Mademoiselle Kris"  From my old high school french class days.
 

lmkris

Member

No problem at all; it gave me a couple giggles.  I might have to make an avatar for clarification or something...

Okay, what if the images are different sizes?  My first thought was to just make a new status window for each image, but if there's an easier/better way, I'm all for it.  *heh*
 

khmp

Sponsor

Alright a much more dynamic approach. This way the characters' width and height are figured out beforehand. I created an array to hold the width and height of each actor in the party. Then when the index reaches their position it should adjust dynamically to fit the size of the character.

Code:
#==============================================================================
# ** Window_MenuStatus
#------------------------------------------------------------------------------
#  This window displays party member status on the menu screen.
#==============================================================================

class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 480, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    
    # The array that will hold the width's and height of each character in
    # the party.
    @sizes = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      bitmap = 
        RPG::Cache.character(actor.character_name, actor.character_hue)
      @sizes << [bitmap.width / 4, bitmap.height / 4]
    end
    
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(24 - @sizes[@index][0] / 2, @index * 116 + 80 - 
        @sizes[@index][1], @sizes[@index][0], @sizes[@index][1])
    end
  end
end

Good luck with it lmkris! :thumb:
 

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