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.

Creating A Horizontal-Oriented Command Window

Ok, not the ACTUAL Command Window used in a menu, but very similar. I explain:

IN the CMS I'm working on, I have an option in the Command Window called "Core Equip". This command will set the command window to inactive and the core window (where this horizontal command window will be) to active.

The Core window will have ten options, each represented only by a bitmap. These bitmaps indicate either the presence or absence of a certain item in the game, which in turn represent Summons that I wish to be able to alter equipment on, much as standard player characters. Thus, they are dependent on game switches 1-10 to determine their presence.

Now, I've managed to figure out (for the most part) how this would operate, but two things elude me. First, and foremost, setting up the Core Window so that the options are side to side, not over-under.

Second (and very dependent on getting the first done) is to set up the window so that: (A) Only the options whose switches are on are selectable (if possible) and (B) When a selection is made on this window, the current party is removed, a single party member is added, and the Equip Scene is displayed. (I have some ideas on this, but without getting the first problem done, I can't hope to test this).

I provide the code for the applicable scene and the window in question... they should be enough to tell me what I need to do.

Code:
#==============================================================================
# ** EC_Scene_Menu
#------------------------------------------------------------------------------
#  Main menu screen processing for the Elemental Core CMS.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    s1 = "Status"
    s2 = "Skills"
    s3 = "Equipment"
    s4 = "Items"
    s5 = "Core Equip"
    s6 = "Save"
    s7 = "Quit"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
      @command_window.disable_item(4)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end
    #Make title picture (160x96 graphics file)
    @pic = Sprite.new
    @pic.bitmap = RPG::Cache.picture("MenuTitle.png")
    @pic.x = 0 
    @pic.y = 256
    # Make play time window
    @playtime_window = Window_PlayTimeEC.new
    @playtime_window.x = 144
    @playtime_window.y = 352    
    # Make gold window
    @gold_window = Window_GoldEC.new
    @gold_window.x = 0
    @gold_window.y = 352
    # Make status window
    @status_window = Window_MenuStatusEC.new
    @status_window.x = 160
    @status_window.y = 0
    # Make location window    
    @location_window = Window_LocationEC.new
    @location_window.x = 288
    @location_window.y = 416
    # Make core window
    @core_window = Window_CoreEC.new
    @core_window.x = 288
    @core_window.y = 352
    # 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
    @pic.dispose
    @location_window.dispose
    @command_window.dispose
    @playtime_window.dispose
    @gold_window.dispose
    @status_window.dispose
    @core_window.dispose
  end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
  def update
    # Update windows
    @pic.update
    @location_window.update
    @command_window.update
    @playtime_window.update
    @gold_window.update
    @status_window.update
    @core_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 5  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 6  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 1  # skill
        # If this actor's action limit is 2 or more
        if $game_party.actors[@status_window.index].restriction >= 2
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_SkillEC.new(@status_window.index)
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equipment screen
        $scene = Scene_EquipEC.new(@status_window.index)
      when 0  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_StatusEC.new(@status_window.index)
      end
      return
    end
  end
end

Code:
#==============================================================================
# ** EC_Window_Core
#------------------------------------------------------------------------------
#  This displays the Core status of the party (Which cores have been obtained)
#==============================================================================

class Window_CoreEC < Window_Base
  #--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 352, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.font.bold = true
    self.contents.font.size = 16
    self.contents.font.name = ["Papyrus", "MS PGothic"]
    cv = contents.text_size("CORES").width
    self.contents.draw_text(137, -10, cv, 32, "CORES")
    x = 15
    y = 12
    # If switch 1 is on
    if $game_switches[1]
      bitmap = RPG::Cache.picture("air.png")
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 2 is on
    if $game_switches[2]
      bitmap = RPG::Cache.picture("bolt.png")
      self.contents.blt(x + 30, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 30, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 3 is on
    if $game_switches[3]
      bitmap = RPG::Cache.picture("earth.png")
      self.contents.blt(x + 60, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 60, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 4 is on
    if $game_switches[4]
      bitmap = RPG::Cache.picture("fire.png")
      self.contents.blt(x + 90, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 90, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 5 is on
    if $game_switches[5]
      bitmap = RPG::Cache.picture("gem.png")
      self.contents.blt(x + 120, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 120, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 6 is on
    if $game_switches[6]
      bitmap = RPG::Cache.picture("light.png")
      self.contents.blt(x + 150, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 150, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 7 is on
    if $game_switches[7]
      bitmap = RPG::Cache.picture("nature.png")
      self.contents.blt(x + 180, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 180, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 8 is on
    if $game_switches[8]
      bitmap = RPG::Cache.picture("shadow.png")
      self.contents.blt(x + 210, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 210, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 9 is on
    if $game_switches[9]
      bitmap = RPG::Cache.picture("time.png")
      self.contents.blt(x + 240, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 240, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
    # If switch 10 is on
    if $game_switches[10]
      bitmap = RPG::Cache.picture("water.png")
      self.contents.blt(x + 270, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    else
      bitmap = RPG::Cache.picture("blank.png")
      self.contents.blt(x + 270, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    end
  end
end

I know that I need to change Window_Cores class slightly so it's based on Window_Selectable... I reverted to an older, pre-screwed with version after some bad experiments. However, feel free to add this as part of the instructions to do what I'm looking for... if nothing else, it will help other similarly clueless.

Thanks, in advance, for the assistance. If you need other bits of the scripting for this menu, I can provide on request.
 
For your first question (assuming you know how to do a vertical command window), just reference to Window_PartyCommand, which has all the necessary settings for a horizontal command window.
For your second, if you only want one window to be triggerable (active) and all of the others not affected by key input, just change the window's settings with
Code:
@window.active = aBoolean
 
I missed PartyCommand altogether, somehow. Thanks for pointing it out.

As it happens, I ended up rearranging the menu to support a vertical one anyhow... But all the same, it may help me figure it out for anything else later on.
 

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