Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Need help with my menu - Current issue is item grid layout
#11
I always seem to flip scripts around a bit and break them into modules of their own. Hell, I took the filenames and put them into a separate LilyFrog config module:
Code:
module LilyMenu
  
  # HERO'S VARIABLE OF CHOICE
  # =========================
  #
    HEROVARIABLE = 1
  
  # MENU BACKGROUND
  # ===============
  #
    MENUBACK = [ 'backtest1', 'backtest2'  ]

  # HERO'S EMOTIONAL REACTION
  # =========================
  #
    HEROFACE  = [ 'hanneutral', 'hanworry', 'penneutral', 'penhappy',
                  'penworry',   'penpsych', 'penaffect' ]
  
  # HERO'S NAME
  # ===========
  #
    HERONAME = [ 'testname1', 'testname2'  ]                  
    

end

#==============================================================================
# ** Menu_Graphics
#------------------------------------------------------------------------------
#  This window displays the main window for LilyFrog's game using graphics
#  based on standard RMXP game variables
#==============================================================================

class Menu_Graphics < Window_Base
  #----------------------------------------------------------------------
  # * Object Initialization
  #----------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity  = 0
    # Acquire value of game variable
    gamevar = $game_variables[LilyMenu::HEROVARIABLE]
    # Now draw them
    initialize_background(gamevar)
    initialize_character_graphic(gamevar)
    initialize_character_name(gamevar)
  end
  #-----------------------------------------------------------------------
  # * Draw Background
  #     gamevar : game variable data
  #-----------------------------------------------------------------------
  def initialize_background(gamevar)
    # Create the Background Sprite and set position
    @menuback     = Sprite.new
    @menuback.x   = 0
    @menuback.y   = 0
    # Determine Background based on game variable state
    temp_image = (gamevar < 5 ) ? LilyMenu::MENUBACK[0] : LilyMenu::MENUBACK[1]
    # Load Background Bitmap
    @menuback.bitmap = RPG::Cache.picture(temp_image)
  end
  #-----------------------------------------------------------------------
  # * Draw Character Graphic
  #     gamevar : game variable data
  #-----------------------------------------------------------------------
  def initialize_character_graphic(gamevar)
    # Create the character graphic and set position
    @charactergraphic     = Sprite.new    
    @charactergraphic.x   = 375
    @charactergraphic.y   = 50
    # Acquire image from array by game variable data
    temp_image = LilyMenu::HEROFACE[gamevar]
    # Draw image
    @charactergraphic.bitmap = RPG::Cache.picture(temp_image)
  end
  #-----------------------------------------------------------------------
  # * Character Names And Changes
  #     gamevar : game variable data
  #-----------------------------------------------------------------------
  def initialize_character_name(gamevar)
    # Create the character name display and set position
    @charactername    = Sprite.new    
    @charactername.x  = 310
    @charactername.y  = 15
    # Acquire image from array by game variable data
    temp_image = (gamevar <= 2 ) ? LilyMenu::HERONAME[0] : LilyMenu::HERONAME[1]
    # Draw image
    @charactername.bitmap = RPG::Cache.picture(temp_image)
  end
end

I hate those icon menus. They give ME headaches. Unless you have something that overwrites the default hidden Window class, remember that you should have a 16px border around everything. So if you have a window with 4qty 32x32 icons, it isn't the space of 32x4 (or 128), but with 16px on either side too... (128+32 ... aka 160) That eliminates the scrolling arrow appearing on the right.

EDIT: There was a flub in the initial posting of the script.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply
#12
Seeing you ALREADY in here.... um

Repasted the above script with a fix. OOPS.

This doesn't count as a double-post as you already saw the previously damaged script.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply
#13
I was actually about to ask about an error I was getting but that fixed it. Good thing I obsessively double check posts before I respond to them.
I've gotta head to bed for now, but this is really interesting. This seems like a much neater way to do this. I'll have to mess around with it for a bit to understand how it works though. Seems to be how my brain works, generally. Thank you so much.

As for the item grid, this might be a dumb question, but where would I plug those numbers in? The draw section of the item script looks like a mathematical war zone to me.
Reply
#14
Send it . Winking

Oh, I have been slicing and dicing things into smaller bite-sized sections. Granted, I tend to put enough comments to fill em up too.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply
#15
WOOF.   I have a little something for ya, LilyFrog.  This might fix your Inventory system's cursor selection issue.  I added an option in the config so you can add a second windowskin which can render a DIFFERENT cursor over the inventory items.  The grid is currently suggesting you only have16 items right now.



.zip   Scripts.zip (Size: 111.38 KB / Downloads: 3)
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply
#16
Oh gosh, thank you. I can't actually check it out right now or really do much of anything because as of sometime yesterday evening my computer refuses to load this website. I can't figure out why. As soon as I can get it to load again I'll be back around.

EDIT: Problem is fixed, not really sure what was going on there. It was an issue with my browser, I think.

I checked it out and it's working! Thank you again.

I'm trying to change the windowskin but it doesn't seem to be working. I've tried it in both a new project and in my main one, but I can't get it to display anything beside the one assigned in the database.
I'm still checking different things out to try to figure it out myself, but I figured it'd be good to mention it in case it's really obvious and I'm just missing it.
Reply
#17
Yep. Found the issue... My bad.

Code:
#===========================================================#
# ICON ITEMS                                                                  
# Version: 1.0                                                                
# By: Polraudio                                              
# Haphazardly butchered by LilyFrog                                            
# Exclusive to RMU or GDU                                                      
#===========================================================#

module LilyItems
  
  
  # DIMENSIONS
  # ==========
  #
    MENU_DIMENSIONS = [4,4] # Number of columns across, and rows down
  
  
  # POSITIONING
  # ===========
  #
    MENU_COORD    = [10,40] # X Position / Y position
    BATTLE_COORD  = [10,40] # X Position / Y position
    
    
  # SPACING
  # =======
  #
    X_SPACING     = 18      # Horizontal spacing between icons
    Y_SPACING     = 18      # Vertical spacing between icons    
  
    WINDOWSKIN    = "Bluish"
  
    BACKGROUND    = nil
    HELP_DISPLAY  = nil
  
end



#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays items in possession on the item and battle screens.
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Get Columns for basic system
    @column_max = LilyItems::MENU_DIMENSIONS[1]
    # Calculate width of window (icon width x columns) + 32px border
    width  = ((32 + LilyItems::X_SPACING) * @column_max) + 32
    # Calculate height of window (icon width x icons down) + 32px border
    height = ((32 + LilyItems::Y_SPACING) * LilyItems::MENU_DIMENSIONS[0]) + 32
    # Super (as in inheriting from Window_Selectable class)
    super(0, 0, width, height)
    # Define position in menu
    self.x = LilyItems::MENU_COORD[0]
    self.y = LilyItems::MENU_COORD[1]
    # If in battle, reposition based on config
    # and make it semi-transparent
    if $game_temp.in_battle
      self.x = LilyItems::BATTLE_COORD[0]
      self.y = LilyItems::BATTLE_COORD[1]
      self.back_opacity = 160
    end
    #
    if LilyItems::BACKGROUND.nil?
      self.opacity = 0
      self.back_opacity = 0
    end
    # Special Windowskin only for this menu.....
    self.windowskin = RPG::Cache.windowskin(LilyItems::WINDOWSKIN)
    # Ensure newly loaded content
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    # Also add weapons and items if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0
          @data.push($data_armors[i])
        end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      # THE CHANGE HERE ---------------------------
      height = LilyItems::MENU_DIMENSIONS[0] * 32
      self.contents = Bitmap.new(width - 32, height)
      # END OF CHANGE HERE ------------------------
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
      when RPG::Item : number = $game_party.item_number(item.id)
      when RPG::Weapon : number = $game_party.weapon_number(item.id)
      when RPG::Armor : number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = index % 4 * (32 + LilyItems::X_SPACING)
    y = index / 4 * (32 + LilyItems::Y_SPACING)
    rect = Rect.new(x, y, 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    # Change icon opacity if disabled color
    opacity = self.contents.font.color == normal_color ? 255 : 128
    # Draw the icon
    self.contents.blt(x+4, y+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    return if LilyItems::HELP_DISPLAY.nil?
    @help_window.set_text(self.item == nil ? "" : self.item.name+": "+self.item.description)
  end
  #--------------------------------------------------------------------------
  # * Get Row Count
  #--------------------------------------------------------------------------
  def row_max
    # Compute rows from number of items and columns
    x = LilyItems::MENU_DIMENSIONS[0]
    y = LilyItems::MENU_DIMENSIONS[1]
    return (@item_max + (x * y) - 1) / (x * y)
  end
  #--------------------------------------------------------------------------
  # * Update Cursor Rectangle
  #--------------------------------------------------------------------------
  def update_cursor_rect
    # If cursor position is less than 0
    return self.cursor_rect.empty if @index < 0
    # Deal with rectangle settings
    x     = @index % 4 * (32 + LilyItems::X_SPACING)
    y     = @index / 4 * (32 + LilyItems::Y_SPACING)
    width = 32
    # Draw Rectangle
    self.cursor_rect.set(x, y, width, 32)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If cursor is movable
    if self.active and @item_max > 0 and @index >= 0
      # If pressing down on the directional buttons
      if Input.repeat?(Input::DOWN)
        # If the cursor position is above the bottom-most row
        if (@index / 4) < (LilyItems::MENU_DIMENSIONS[0] - 1)
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index += 4
        end
      end
      # If the up directional button was pressed
      if Input.repeat?(Input::UP)
        # If the cursor position is below the top-most row
        if (@index / 4) > 0
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index -= 4
        end
      end
      # If the right directional button was pressed
      if Input.repeat?(Input::RIGHT)
        # If the cursor position is to the left of the right-most columb
        if (@index % 4) < (LilyItems::MENU_DIMENSIONS[1] - 1)
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index += 1
        end
      end
      # If the left directional button was pressed
      if Input.repeat?(Input::LEFT)
        # If the cursor position is to the right of the left-most columb
        if (@index % 4) > 0
          # Move cursor right
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
        end
      end
      # Ensure not beyond the item limits ^_^
      @index = 0 if @index < 0
      @index = @item_max-1 if @index >= @item_max
    end
    # Update help text (update_help is defined by the subclasses)
    if self.active and @help_window != nil
      update_help
    end
    # Update cursor rectangle
    update_cursor_rect
  end
end

Haphazard stupidity by the Resident Werewolf. Laughing
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply
#18
Thank you! It's totally fine. I completely missed that, wow.

I think that pretty much covers everything that comes to mind so far with the menu itself. I don't know if menu functions qualify here, or if I should bring up the question in another thread. It's still to do with items, and it stems from the menu, but I just wanna be sure this is the right place to ask.
Reply
#19
If it's still related to the same menu, yeah, go post it here. Feel no shame. You already haphazardly butchered a script, what could be worse than that? Laughing
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 2 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX
Reply
#20
*COUGH* ... don't ask.

Of course, the Menu grid for your inventory assumes you are using only 16 items in the 4x4 lineup, and no scrolling beyond that. I take it that is your wish?
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
   I want to merge item classification and description extensions. zlsl 7 4,322 11-25-2019, 06:46 AM
Last Post: kyonides
   Handling very long Item Names Melana 4 4,557 09-24-2018, 06:37 PM
Last Post: Melana
   Special Items Separate Menu Diorm 41 21,015 02-10-2018, 06:06 PM
Last Post: Diorm
Question  Mog Menu script: help me stop the crazy picture movement during transitions Zachariad 4 5,670 05-31-2017, 05:10 AM
Last Post: Zachariad
   A fourth column in MOG Scene Item Laura V1.2 Noctis 13 10,236 11-27-2016, 05:12 PM
Last Post: DerVVulfman
   Bizarre issue with Lanzer counter script. Steel Beast 6Beets 2 4,801 10-04-2016, 11:46 AM
Last Post: Steel Beast 6Beets
   XAIL MENU from RPG VX ACE to RPG XP RASHIDA12 46 25,250 05-02-2016, 08:08 PM
Last Post: RASHIDA12
Tongue  Healing Spell doesn't work right in Menu? Bounty Hunter Lani 8 7,395 01-15-2015, 07:45 PM
Last Post: Bounty Hunter Lani
   My Options Menu needs help firestalker 0 2,079 08-11-2014, 02:31 PM
Last Post: firestalker
   Vx Ace Custom Menu help? Skitzen 1 3,703 10-07-2013, 03:10 PM
Last Post: JayRay



Users browsing this thread: