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] Adding window to the status menu

Hi all,

my problem is quite simple. Except i'm a complete newbie at scripting.

I read through the forums but i either don't understand the explanation or it does'nt do what i want.
I want to make box around certain stats of my Status menu.

I'm able to make the box appear at the right place, but my problem is I don't know how to make them go away when I get out of the menu.
I'm using ''Guillaume 777 multi-equip'' script.
     
This is my Scene_Status script (with my box added...at line 23)
#==============================================================================
# ** Scene_Status
#------------------------------------------------------------------------------
#  This class performs status screen processing.
#==============================================================================

class Scene_Status
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make status window
    @status_window = Window_Status.new(@actor)
    # This what i use to draw box around the text.
    # I just don't know how to make it vanish when i return to the Scene_map
      @Name_window = Window_Base.new(4, 10, 160, 40)
      @Level_window = Window_Base.new(100, 50, 220, 95)
      @Stats_window = Window_Base.new(0, 145, 320, 50)
      @Defense_window = Window_Base.new(0, 200, 320, 50)
      @equipment_window = Window_Base.new(325, 95, 300, 350)
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @status_window.dispose

  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(3)
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different status screen
      $scene = Scene_Status.new(@actor_index)
      return
    end
  end
end

And this is my Guillaume 777 multi-equip script (some minor change of placement but mostly default for all the rest.)
#==============================================================================
# Multi-slot equipment script
#------------------------------------------------------------------------------
# Section 3:  Windows
#------------------------------------------------------------------------------
# Guillaume777
# 6.2.1
# 2006/02/14
#==============================================================================

#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
#  This class performs equipment screen processing.
#==============================================================================
class Scene_Equip
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias g7_ms_scene_equip_main main
  def main
    @additional_initialize_done = false
    g7_ms_scene_equip_main
    for i in 5...@item_windows.size
      @item_windows.dispose unless @item_windows.nil?
    end
  end
  #--------------------------------------------------------------------------
  # * Initialize the extra right windows
  #--------------------------------------------------------------------------
  def g7_ms_scene_equip_additional_initialize
  unless @additional_initialize_done
    @item_windows = []
    @item_windows[0] = @item_window1  # Weapon
    @item_windows[1] = @item_window2  # Shield
    @item_windows[2] = @item_window3  # Helmet
    @item_windows[3] = @item_window4  # Armor
    @item_windows[4] = @item_window5  # Accessory
    nb_old_windows = @item_windows.size
    for i in nb_old_windows...@actor.armor_slots.max+1
      # Add the remaining windows for extra slots
      @item_windows.push(Window_EquipItem.new(@actor, i) )
      @item_windows.help_window = @help_window
    end
    @item_windows.push(Window_EquipOffHand.new(@actor, 0))
    @item_windows[-1].help_window = @help_window
    # If windows_stretch is true, stretch window
    if G7_MS_MOD::WINDOWS_STRETCH
      h = (@actor.weapon_slots.size + @actor.armor_slots.size + 1) * 32
      h2 = (G7_MS_MOD::MAX_SHOW_SLOTS+1) * 32
      h = [h, h2].min
      @right_window.height = h
      if @right_window.index > @actor.weapon_slots.size + @actor.armor_slots.size - 1
        @right_window.index = @actor.weapon_slots.size + @actor.armor_slots.size - 1
      end
      if @left_window.y + @left_window.height == 256
        @left_window.height = @right_window.height
      elsif G7_MS_MOD::HELP_AT_BOTTOM == true and @left_window.height == 416 then
        # Make left window shorter
        @left_window.height -= 64
      end
      y_pos = (@right_window.y + @right_window.height)
      y_space = 480 - y_pos
      # If help at bottom, reduce bottom item window size
      if G7_MS_MOD::HELP_AT_BOTTOM == true then y_space -= 64  end
      for item_window in @item_windows
        next if item_window.nil?
        item_window.y = y_pos
        item_window.height = y_space
      end
    end
    @additional_initialize_done = true
    end
  end
  #--------------------------------------------------------------------------
  # * Refresh and make visible the correct right window
  #--------------------------------------------------------------------------
  alias g7_ms_scene_equip_refresh refresh
  def refresh
    # This part is used to refresh the equipped item at the right window
    g7_ms_scene_equip_additional_initialize
    @actor.translucent_texts.fill(false)
    @actor.equip_type_force = index_to_equip_part(@right_window.index)
    @right_window.item_fix_on
    @right_window.scroll_fix_on
    save = @right_window.index
    @right_window.index = index_to_equip_kind(@right_window.index)
    if @right_window.index == 0 and @actor.ignore_offhand? != true then
      if @actor.nb_offhand_required(save) > 0 then
        @right_window.index = @item_windows.size-1
      end
    end
    @actor.equip_from_menu = true
    # Ensure current equipment will get properly stored...
    @actor.equip_mode = 'STORE'
    # ...and re-equiped
    @item_window = @item_windows[@right_window.index]
    @item_windows[@right_window.index].visible = true
    for i in 0...@item_windows.size
      if i != @right_window.index then
        @item_windows.visible = false
      end
    end
    # Equip and remove item
    g7_ms_scene_equip_refresh
    @actor.equip_from_menu = false                           
    @actor.equip_mode = nil
    @actor.equip_type_force = nil
    @right_window.index = save
    @right_window.scroll_fix_off
    @right_window.item_fix_off
    if @item_window.index != @old_index
      @right_window.refresh
    end
    @old_index = @item_window.index
  end
  #--------------------------------------------------------------------------
  # * Convert the right_window.index to equip_type
  #--------------------------------------------------------------------------
  alias g7_ms_scene_equip_update_item update_item
  def update_item
    # This changes the @right_window.index to the correct value to take
    # account of extra slots
    @actor.equip_type_force = index_to_equip_part(@right_window.index)
    @right_window.item_fix_on
    @right_window.scroll_fix_on
    save = @right_window.index
    @right_window.index = index_to_equip_kind(@right_window.index)
    @actor.equip_from_menu = true
    # Equip item
    g7_ms_scene_equip_update_item
    @actor.equip_from_menu = false
    @actor.equip_type_force = nil
    # If not in item_window screen
    if @item_window.index == -1
      # If shield-weapon can modify each other
      if @actor.shield_hand_wield == true and
        if @right_window.index == @actor.shield_hand_slot then
          @item_windows[0].refresh
          @item_windows[-1].refresh
        elsif @right_window.index == 0
          # Refresh the shield slot
          @item_windows[@actor.shield_hand_slot].refresh
        end
      end
      if @right_window.index == 0 and @actor.ignore_offhand? != true then
        if @item_window == @item_windows[-1] then
          @item_windows[0].refresh
        elsif @item_window == @item_windows[0] then
          @item_windows[-1].refresh
        end
      end
    end
    @right_window.index = save
    @right_window.scroll_fix_off
    @right_window.item_fix_off
    @actor.equip_type_force = nil
  end
  #--------------------------------------------------------------------------
  # * Convert index to equip part
  #     index : slot number
  #--------------------------------------------------------------------------
  def index_to_equip_part(index)
    # Return index of slot in the
    # array [0, @actor.armor_slots, actor.weapon_slots]
    # If Armor
    if index >= @actor.weapon_slots.size
      return index - (@actor.weapon_slots.size - 1)
    # If extra weapon
    elsif index >= 1
      # Make it last
      return index + [@actor.armor_slots.size, 4].max
    else
      return 0
    end
end
  #--------------------------------------------------------------------------
  # Convert index to equip kind
  #     index : slot number
  #--------------------------------------------------------------------------
  def index_to_equip_kind(index)
    # Return index of slot in either actor.weapon_slots or actor.armor_slots
    i = index_to_equip_part(index)
    # If armor
    if index >= @actor.weapon_slots.size
      set = @actor.armor_slots[i-1]
    # If weapon 
    else
      i = i == 0 ? 0 : i - [@actor.armor_slots.size, 4].max
      set = @actor.weapon_slots
    end
    return set != nil ? set : 0
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Scene Equip
  #-------------------------------------------------------------------------- 
end



#==============================================================================
# ** Window_EquipRight
#------------------------------------------------------------------------------
#  This window displays items the actor is currently equipped with on the
#  equipment screen.
#==============================================================================
class Window_EquipRight < Window_Selectable
  #--------------------------------------------------------------------------
  # * Item Fix On
  #--------------------------------------------------------------------------
  def item_fix_on
    # Fix window
    @fixed_item = @data[self.index]
    @fixed = true
  end
  #--------------------------------------------------------------------------
  # * Item Fix Off
  #--------------------------------------------------------------------------
  def item_fix_off
    #stop fixing window
    @fixed_item = nil
    @fixed = false
  end
  #--------------------------------------------------------------------------
  # * Don't scroll right window if you press L or R
  #--------------------------------------------------------------------------
  def update
    if Input.repeat?(Input::R) or  Input.repeat?(Input::L) then
      return
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # Draws equipped items with support of translucent and cursed items
  #     item        : item
  #     x           : draw spot x-coordinate
  #     y           : draw spot y-coordinate
  #     translucent : draw translucent
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y, translucent = false)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    if item.cursed
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
      self.contents.font.color = G7_MS_MOD::CURSED_COLOR
    elsif translucent
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), 128)
      self.contents.font.color = disabled_color
    else
      self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
      self.contents.font.color = normal_color
    end
    self.contents.draw_text(x + 28, y, 212, 32, item.name)
  end
  #--------------------------------------------------------------------------
  # * Prevent needless update of item quantities in item window
  #--------------------------------------------------------------------------
  alias g7_ms_window_equipright_item item
  def item
    # This ensures that the number of items doesn't get updated if you move
    # cursor in item window
    return @fixed_item if @fixed
    return g7_ms_window_equipright_item
  end
  #--------------------------------------------------------------------------
  # * Change the height of right windows to fit the slots
  #     actor : actor
  #--------------------------------------------------------------------------
  alias g7_ms_window_equipright_initialize initialize
  def initialize(actor)
    # Initialize with a different height
    g7_ms_window_equipright_initialize(actor)
    # Total height of right window
    h = (actor.weapon_slots.size + actor.armor_slots.size) * 32
    # Change the height                                                       
    self.contents = Bitmap.new(width - 32, h)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Shows the slot names and the name of the items you have equipped
  #--------------------------------------------------------------------------
  def refresh
    # Replaced method to show caption of all items and slot
    self.contents.clear
    @data = []
    # Begin Multi-slot equipment script Edit
    self.contents.font.name = G7_MS_MOD::FONT_NAME
    for i in 0...@actor.weapon_slots.size
      # Push the name(s) of the weapon(s)
      @data.push($data_weapons[@actor.weapon_ids])
    end
    for i in 0...@actor.armor_slots.size
      # Push the names of the armors
      @data.push($data_armors[@actor.armor_ids])
    end
    @caption = []
    for i in 0...@actor.weapon_slots.size
      # Push the name(s) of the weapon slots
      @caption.push(@actor.weapon_slot_names)
    end
    for i in 0...@actor.armor_slots.size
      # Push the names of the armor slots
      @caption.push(@actor.armor_slot_names[@actor.armor_slots-1])
    end
    @item_max = @data.size
    if @actor.translucent_texts == nil then @actor.translucent_texts = Array.new end
    for i in 0...@data.size
      if @caption != nil
        self.contents.font.color = system_color
        # Draw the name of the slots
        self.contents.draw_text(4, 32 * i, 92, 32, @caption)
      end
      # Draw the name of the equipment
      draw_item_name(@data, 92, 32 * i, @actor.translucent_texts)
    end
    # Support for other script
    if defined? xrxs_additional_refresh
      xrxs_additional_refresh
    end
  # End Multi-slot equipment script Edit
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Window EquipRight
  #--------------------------------------------------------------------------
end



#============================================================================
# ** Window_EquipOffHand
#----------------------------------------------------------------------------
#  A new window class that displays an equipped item in the actor's off hand.
#============================================================================
class Window_EquipOffHand < Window_EquipItem
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add equippable weapons
    weapon_set = $data_classes[@actor.class_id].weapon_set
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
        weapon = $data_weapons
        if weapon.needs_offhand == false
          if G7_MS_MOD::TWOHANDED_IN_OFFHAND != false and weapon.nb_hands <= 1 then
            @data.push(weapon)
          end
        end
      end
    end
    # Add blank page
    @data.push(nil)
    # Make a bit map and draw all items
    @item_max = @data.size
    self.contents = Bitmap.new(width - 32, row_max * 32)
    self.contents.font.name = G7_MS_MOD::FONT_NAME
    #self.contents.font.size = 24
    for i in 0...@item_max-1
      draw_item(i)
    end
    if G7_MS_MOD::SHOW_REMOVE then
       i = @item_max -1
       x = 4 + i % @column_max * (288 + 32)
       y = i / @column_max * 32
       self.contents.draw_text(x+4, y, 100, 32, '[Remove]')
    end
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Window EquipOffHand
  #--------------------------------------------------------------------------
end



#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
#  This window class contains cursor movement and scroll functions.
#==============================================================================
class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # * Scroll Fix On
  #--------------------------------------------------------------------------
  def scroll_fix_on
    @scroll_fixed = true
  end
  #--------------------------------------------------------------------------
  # * Scroll Fix Off
  #-------------------------------------------------------------------------- 
  def scroll_fix_off
    @scroll_fixed = false
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  alias g7_ms_update_cursor_rect update_cursor_rect
  def update_cursor_rect
    # This prevents the windows from scrolling if scroll is fixed
    # This was added to ensure that if there are few slots, the right equip
    # screen doesn't scroll needlessly
    return if @scroll_fixed
    g7_ms_update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * End of CLASS:  Window Selectable
  #-------------------------------------------------------------------------- 
end



#==============================================================================
# *** Global IF condition
#     Shows a new status window if Status_window_arrange is true
#==============================================================================
if G7_MS_MOD::STATUS_WINDOW_ARRANGE
  #============================================================================
  # ** Window_Status
  #----------------------------------------------------------------------------
  #  This window displays full status specs on the status screen.
  #============================================================================
  class Window_Status < Window_Base
    #--------------------------------------------------------------------------
    # * Refresh
    #--------------------------------------------------------------------------
    def refresh
      # End Multi-slot equipment script Edit
      self.contents.clear
      draw_actor_graphic(@actor, 24, 112)
      draw_actor_name(@actor, 0, 0)
      draw_actor_class(@actor, 96, 32)
      draw_actor_level(@actor, 96, 52)
      draw_actor_state(@actor, 10, 0)
      draw_actor_hp(@actor, 96, 80, 172)
      draw_actor_sp(@actor, 96, 96, 172)
      draw_actor_parameter(@actor, 0 + 160, 185, 0)
      draw_actor_parameter(@actor, 4, 185, 1)
      draw_actor_parameter(@actor, 0, 205, 2)
      draw_actor_parameter(@actor, 4, 130, 3)
      draw_actor_parameter(@actor, 0, 150, 4)
      draw_actor_parameter(@actor, 0 + 160, 130, 5)
      draw_actor_parameter(@actor, 0 + 160, 150, 6)
      # Begin Multi-slot equipment script Edit
      if G7_MS_MOD::EVADE
        # Activate if you have a draw_actor_paramter method that draws evade
        draw_actor_parameter(@actor, 96, 432, 7)
      end
      self.contents.font.color = system_color
      self.contents.draw_text(320, 6, 40, 20, 'EXP')
      self.contents.draw_text(320, 24, 40, 20, 'NEXT')
      self.contents.font.color = normal_color
      self.contents.draw_text(320 + 50, 6, 84, 20, @actor.exp_s, 2)
      self.contents.draw_text(320 + 50, 24, 84, 20, @actor.next_rest_exp_s, 2)
      self.contents.font.color = system_color
      self.contents.draw_text(320, 80, 96, 32, 'Equipment')
      y = 108
      for i in 0...@actor.weapon_slots.size
        draw_item_name($data_weapons[@actor.weapon_ids], 320 + 16, y)
        y += G7_MS_MOD::STATUS_WINDOW_SPACING
      end
      for i in 0...@actor.armor_slots.size
        draw_item_name($data_armors[@actor.armor_ids], 320 + 16, y)
        y += G7_MS_MOD::STATUS_WINDOW_SPACING     
      end
    end
     
              # End Multi-slot equipment script Edit     
    #------------------------------------------------------------------------
    # * End of CLASS:  Window Status
    #------------------------------------------------------------------------
  end
  #--------------------------------------------------------------------------
  # * End of Global IF condition
  #--------------------------------------------------------------------------
end


So what i want is the box to be visible when in status (the guillaume 777 status...) and to be invisible when in the Scene_map.

If you guys need ANY other info just let me know.

Thanks for your help.
 

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