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]Menu Window Help

Status
Not open for further replies.
I'm working on a custom menu configuration, and I have a window that displays
all the classes in the default system. All 8 of them.
But my main problem is
1. I want to know how to have the script check for a class in the party and make that class white.
2. I know I have little to no scripting experience so I would like a little help with this, if any.
Code:
#==============================================================================
# ** Window_Class
#------------------------------------------------------------------------------
#  This window displays actors class on the menu screen.
#==============================================================================

class Window_Class < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 25, "Fighter")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 55, "Lancer")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 85, "Warrior")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 115, "Thief")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 145, "Hunter")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 175, "Gunner")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 205, "Cleric")
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, 120, 235, "Mage")
  end
end
This is the window_class script I came up with to display all 8 classes within the game, but is there a script code to check for a certain class and then white or gray out that class?
 
Crude, but it should work:
Code:
#==============================================================================
# ** Window_Class
#------------------------------------------------------------------------------
#  This window displays actors class on the menu screen.
#==============================================================================

class Window_Class < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # Starting coordinates for the first line of text.
    x = 120
    y = 25
    # Creates empty array.
    avail_id = []
    # For each actor available in the party, get the Class ID and put
    # it in the avail_id array.
    for actor in $game_party.actors
      avail_id.push(actor.class_id)
    end
    # Sort the avail_id array, and truncate duplicate entries.
    # Example:
    #   arr = [1, 2, 4, 4, 6, 7, 7, 7, 7, 9, 14, 14]
    #   arr.uniq!
    #   // #=> arr is now [1, 2, 4, 6, 7, 9, 14]
    avail_id.sort!.uniq!
    # For each class available in the Database...
    for i in 1...$data_classes.size
      # Get the Class name.
      text = $data_classes[i].name
      # If Class ID's of the party matches the Class ID from database...
      if avail_id.include?(i)
        # Use System Color.
        self.contents.font.color = system_color
      else
        # Otherwise, use Disabled Color.
        self.contents.font.color = disabled_color
      end
      # Draw the text with x- and y-coordinates.
      self.contents.draw_text(0, 0, x, y, text)
      # Increase y value to space out for the next line.
      y += 32
    end
  end

end

Hope my comments are understandable. Ask if needed.
Also, you only need to use self.contents.font.color once to set a text color. It lasts for the rest of the Window's "life" until it's changed.
 
This topic has been resolved. If Chaos_Prime or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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