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.

A Little Help Modifying A Custom Menu

I'm very very new at messing with RGSS2, in fact, all I know is how to slightly modify scripts like I was doing with this one. This is Rubymatt's Compact Custom Menu System. Try it out on your own and you'll see that what it does is add a neat compact menu sitting in the middle of the screen when you go to the menu option. What I'm posting is the version I modified and NOT the original. I edited the script to replace one of the options with another option, that worked out well. But the part I'm having trouble with is the map name I put at the bottom of the menu. It's sized just right and is in the right position; my problem is it just won't go away! In other words, it's still there when I go to any other option on the menu, not only that but the most annoying part is it's still on the screen when I exit the menu! I have no idea how to get rid of it... this is obviously a newbie's problem but I just need a little help please^^;

Code:
#==============================================================================
#  Compact Custom Menu System
#         RMVX Version
#            v1.0
#         by  Rubymatt
#==============================================================================

#------------------------------------------------------------------------------
#  Game_Map
#------------------------------------------------------------------------------
class Game_Map
#------------------------------------------------------------------------------
#  Name
#------------------------------------------------------------------------------
  def name
    $map_infos[@map_id]
  end
end


#========================================
#  Scene_Title
#--------------------------------------------------------------------------------
# Setting functions for the Title
#========================================
class Scene_Title
  $map_infos = load_data("Data/MapInfos.rvdata")
  for key in $map_infos.keys
    $map_infos[key] = $map_infos[key].name
  end
end


class Window_MapName < Window_Base
 def initialize(x, y)
   super(x, y, 224, WLH + 64)
   self.contents = Bitmap.new(width - 32, height - 32)   
   refresh
 end
 def refresh
   self.contents.clear
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 120, 32, "Location")
   self.contents.font.color = normal_color
   self.contents.draw_text(4, WLH, 150, 32, $game_map.name.to_s, 2)
 end
end



#==============================================================================
# ** NEW Window_Gold
#==============================================================================

class Window_Gold < Window_Base
  def initialize(x, y)
    super(x, y, 224, WLH + 32)
    refresh
  end
  def refresh
    self.contents.clear
    draw_currency_value($game_party.gold, 4, 0, 184)
  end
end

#==============================================================================
# ** NEW Window_MenuStatus
#==============================================================================

class Window_NewMenuStatus < Window_Selectable
  def initialize(x, y)
    super(0, 0, 64, $game_party.members.size * 36 + 32)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
    self.active = false
    self.index = -1
  end
  def refresh
    self.contents.clear
    @item_max = $game_party.members.size
    for actor in $game_party.members
      x = 66
      y = actor.index * 36
      draw_actor_graphic(actor, x - 51, y + 32)
    end
  end
  def update_cursor
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(-2, @index * 36 - 2, 36, 36)
    end
    @mapname_window = Window_MapName.new(160, 304)
    end
end

#==============================================================================
# ** NEW Scene_Menu
#==============================================================================

class Scene_Menu < Scene_Base
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  def start
    super
    create_menu_background
    create_command_window
    @gold_window = Window_Gold.new(160, 248)
    @status_window = Window_NewMenuStatus.new(160, 0)
    @status_window.x = 320
    if $game_party.members.size == 4
      @status_window.y = 72
    elsif $game_party.members.size == 3
      @status_window.y = 88
    elsif $game_party.members.size == 2
      @status_window.y = 104
    elsif $game_party.members.size == 1
      @status_window.y = 120
    else
      @status_window.y = 72
    end
  end
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
  def update
    super
    update_menu_background
    @command_window.update
    @gold_window.update
    @status_window.update
    if @command_window.active
      update_command_selection
    elsif @status_window.active
      update_actor_selection
    end
  end
  def option
        $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
$showm.call(0x70,0,0,0)   # F1 down
$showm.call(0x70,0,2,0)   # F1 up
    end
  def create_command_window
    s1 = Vocab::item
    s2 = Vocab::skill
    s3 = Vocab::status
    s4 = Vocab::save
    s5 = option = 'Option'
    s6 = Vocab::game_end
    @command_window = Window_Command.new(160, [s1, s2, s5, s3, s4, s6])
    @command_window.x = 160
    @command_window.y = 72
    @command_window.height = 176
    @command_window.index = @menu_index
    if $game_party.members.size == 0        
      @command_window.draw_item(0, false)   
      @command_window.draw_item(1, false)   
      @command_window.draw_item(2, false)     
      @command_window.draw_item(3, false)     
    end
    if $game_system.save_disabled             
      @command_window.draw_item(4, false)   
    end
  end
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 4
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0      
        $scene = Scene_Item.new
      when 1,3
        start_actor_selection
      when 2
      $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
      $showm.call(0x70,0,0,0)   # F1 down
      $showm.call(0x70,0,2,0)   # F1 up
      when 4      
        $scene = Scene_File.new(true, false, false)
      when 5    
        $scene = Scene_End.new
      end
    end
  end
  def start_actor_selection
    @command_window.active = false
    @status_window.active = true
    if $game_party.last_actor_index < @status_window.item_max
      @status_window.index = $game_party.last_actor_index
    else
      @status_window.index = 0
    end
  end
  def end_actor_selection
    @command_window.active = true
    @status_window.active = false
    @status_window.index = -1
  end
  def update_actor_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_actor_selection
    elsif Input.trigger?(Input::C)
      $game_party.last_actor_index = @status_window.index
      Sound.play_decision
      case @command_window.index
      when 1 
        $scene = Scene_Skill.new(@status_window.index)
      when 2 
        $showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
$showm.call(0x70,0,0,0)   # F1 down
$showm.call(0x70,0,2,0)   # F1 up
      when 3  
        $scene = Scene_Status.new(@status_window.index)
      end
    end
  end
end
 
Your problem is that you're not disposing of the window when the scene closes. (And you're defining the window in a completely random spot...)

Firstly, I'd move where you defined the new window to where the other windows are defined.
Basically move
Code:
@mapname_window = Window_MapName.new(160, 304)
to where these lines are in Scene_Menu
Code:
    @gold_window = Window_Gold.new(160, 248)
    @status_window = Window_NewMenuStatus.new(160, 0)
    @status_window.x = 320

Secondly, add a dispose command in the terminate function
so
Code:
@mapname_window.dispose
in with
Code:
    @command_window.dispose
    @gold_window.dispose
    @status_window.dispose

Hope that helps
 
Oh, ok, thanks! Works perfectly now^^ See I'm just starting on Ruby so like... all I know how to do is cut and paste parts of scripts to other scripts basically to attempt to make them do what I want^^;
 

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