Essentials Script Pokemon BW2 Bag for v17.2 and v16

Started by CharizardThree3 April 27th, 2020 3:26 AM
  • 2418 views
  • 40 replies
  • Public Poll

Shall I make the scroll bar work with mouse?

  • 88.89%
  • 11.11%

CharizardThree3

Male
Avon region
Seen 13 Hours Ago
Posted 1 Week Ago
282 posts
2.1 Years
BW2 Bag Stock Essentials Version
I did minor modifications to the PScreen_Bag Script to make it look and function like The BW2 Bag by Erassus. He gets all the credits. I am a noob in scripting, so I did major modifications for graphics.


Male Bag



Female Bag

First Download the files in attachment.
Put the Graphics in your Game Folder.
Put the Audio in your Game Folder.
Merge when message appears.

Download the .txt file from the attachment.
Copy all, then replace the whole PScreen_Bag with it.(You can ofcourse use a text comparer,if you have done any changes)
I copied the credits from the other thread.
Graphics: http://www.spriters-resource.com/ds/pokemonblack2white2/sheet/48047/
Backgrounds: Ripped with Desmume.
Edit: Erassus
Graphical changes : CharizardThree3 or LackDejurane
Sounds: BadSamaritan
Thanks to Maruno, Marin and Luka S.J for making me understand what to do actually.

USEARROWS is for using BW Styled Arrows for pocket changing(when true)

ANIMEBG is for using Animated Background for the bag(when true)

USETOUCHBAG is for using mouse to click and change pockets(when true)

Changelog
Spoiler:
Update 1.1
-Added Clickable Buttons
-Better Animations
Update 1.2
-Added Clickable Buttons
-Better Animations
-Touchable bag pockets
- Configuration of stuff at the start of the script
Update 1.3
-Touchable bag pockets and fixed some graphical bugs Thanks to Maruno,Marin and Luka S.J.!
-v16 Support added!

Done.
This script is compatible for both v16 and v17 (there are two scripts respectively
Bye Cya! Give credits to me too!
(You can give credits to Queen if you want, was listening to the Prophet's Song while doing this!)

BW 2 Bag(v1.3).zip
BW 2 Bag(v1.3 for v16 only).zip
Unpopular opinion:v16 bag looks a little better

Well, you can copy code from here and just download the graphical stuff.
V17 Code
Spoiler:
#==============================================================================
# PScreen Bag Graphical Overhaul by LackDeJurane or CharizardThree3
# If used please give credits.
#=============================================================================
USEARROWS = true   # Whether to use BW Styled Arrows for pocket changing 
ANIMEBG   = true  # Whether to use an Animated Background for the bag
USETOUCHBAG = true# Whether to use mouse to click and change pockets

class Window_PokemonBag < Window_DrawableCommand
  attr_reader :pocket
  attr_accessor :sorting

  def initialize(bag,filterlist,pocket,x,y,width,height)
    @bag        = bag
    @filterlist = filterlist
    @pocket     = pocket
    @sorting = false
    @adapter = PokemonMartAdapter.new
    super(x,y,width,height)
    @selarrow  = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor")
    @swaparrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor_swap")
    self.windowskin = nil
  end

  def dispose
    @swaparrow.dispose
    super
  end
  
  def pocket=(value)
    @pocket = value
    @item_max = (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1
    self.index = @bag.getChoice(@pocket)
  end
  
  def page_row_max; return PokemonBag_Scene::ITEMSVISIBLE; end
  def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end

  def item
    return 0 if @filterlist && [email protected][@pocket][self.index]
    thispocket = @bag.pockets[@pocket]
    item = (@filterlist) ? thispocket[@filterlist[@pocket][self.index]] : thispocket[self.index]
    return (item) ? item[0] : 0
  end

  def itemCount
    return (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1
  end

  def itemRect(item)
    if item<0 || item>[email protected]_max || item<self.top_item-1 ||
       item>self.top_item+self.page_item_max
      return Rect.new(0,0,0,0)
    else
      cursor_width = (self.width-self.borderX-(@column_max-1)*@column_spacing) / @column_max
      x = item % @column_max * (cursor_width + @column_spacing)
      y = item / @column_max * @row_height - @virtualOy
      return Rect.new(x, y, cursor_width, @row_height)
    end
  end

  def drawCursor(index,rect)
    if self.index==index
      bmp = (@sorting) ? @swaparrow.bitmap : @selarrow.bitmap
      pbCopyBitmap(self.contents,bmp,rect.x,rect.y+2)
    end
  end

  def drawItem(index,count,rect)
    textpos = []
    rect = Rect.new(rect.x+16,rect.y+16,rect.width-16,rect.height)
    ypos = rect.y+4
    thispocket = @bag.pockets[@pocket]
    if index==self.itemCount-1
      textpos.push([_INTL("CLOSE BAG"),rect.x,ypos,false,self.baseColor,self.shadowColor])
    else
      item = (@filterlist) ? thispocket[@filterlist[@pocket][index]][0] : thispocket[index][0]
      baseColor   = self.baseColor
      shadowColor = self.shadowColor
      if @sorting && index==self.index
        baseColor   = Color.new(224,0,0)
        shadowColor = Color.new(248,144,144)
      end

      textpos.push(
         [@adapter.getDisplayName(item),rect.x,ypos,false,baseColor,shadowColor]
      )
      if !pbIsImportantItem?(item)   # Not a Key item or HM (or infinite TM)
        qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
        qtytext = _ISPRINTF("x{1: 3d}",qty)
        xQty    = rect.x+rect.width-self.contents.text_size(qtytext).width-16
        textpos.push([qtytext,xQty,ypos,false,baseColor,shadowColor])
      end
      if pbIsImportantItem?(item)
        if @bag.pbIsRegistered?(item)
          pbDrawImagePositions(self.contents,[
             ["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,0,-1,24]
          ])
        elsif pbCanRegisterItem?(item)
          pbDrawImagePositions(self.contents,[
             ["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,ypos+4,0,24,-1,24]
          ])
        end
      end
    end
    pbDrawTextPositions(self.contents,textpos)
  end
  

  def refresh
    @item_max = itemCount()
    self.update_cursor_rect
    dwidth  = self.width-self.borderX
    dheight = self.height-self.borderY
    self.contents = pbDoEnsureBitmap(self.contents,dwidth,dheight)
    self.contents.clear
    for i in [email protected]_max
      next if i<self.top_item-1 || i>self.top_item+self.page_item_max
      drawItem(i,@item_max,itemRect(i))
    end
    drawCursor(self.index,itemRect(self.index))
  end

  def update
    super
    @uparrow.visible   = false
    @downarrow.visible = false
  end
end
  

#===============================================================================
# Bag visuals
#===============================================================================
class PokemonBag_Scene
  ITEMLISTBASECOLOR     = Color.new(255,255,255)
  ITEMLISTSHADOWCOLOR   = Color.new(156,156,156)
  ITEMTEXTBASECOLOR     = Color.new(248,248,248)
  ITEMTEXTSHADOWCOLOR   = Color.new(90,90,90)
  POCKETNAMEBASECOLOR   = Color.new(248,248,248)
  POCKETNAMESHADOWCOLOR = Color.new(90,90,90)
  ITEMSVISIBLE          = 7

  def pbUpdate
    pbUpdateSpriteHash(@sprites)
  end

  def pbStartScene(bag,choosing=false,filterproc=nil,resetpocket=true)
    @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z = 99999
    @bag        = bag
    @choosing   = choosing
    @filterproc = filterproc
    pbRefreshFilter
    lastpocket = @bag.lastpocket
    numfilledpockets = @bag.pockets.length-1
    if @choosing
      numfilledpockets = 0
      if @filterlist!=nil
        for i in [email protected]
          numfilledpockets += 1 if @filterlist[i].length>0
        end
      else
        for i in [email protected]
          numfilledpockets += 1 if @bag.pockets[i].length>0
        end
      end
      lastpocket = (resetpocket) ? 1 : @bag.lastpocket
      if (@filterlist && @filterlist[lastpocket].length==0) ||
         ([email protected] && @bag.pockets[lastpocket].length==0)
        for i in [email protected]
          if @filterlist && @filterlist[i].length>0
            lastpocket = i; break
          elsif [email protected] && @bag.pockets[i].length>0
            lastpocket = i; break
          end
        end
      end
    end
    @bag.lastpocket = lastpocket
    @sliderbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Bag/icon_slider"))
    @pocketbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Bag/icon_pocket"))
    @sprites = {}
    @arrowanim=0
    [email protected](lastpocket) 
    @sprites["grid"]=AnimatedPlane.new(@viewport) 
  if $Trainer.isFemale?
    @sprites["grid"]=AnimatedPlane.new(@viewport)  
    @sprites["grid"].bitmap = Bitmap.new("Graphics/Pictures/Bag/bg_gridf")
  else
    @sprites["grid"]=AnimatedPlane.new(@viewport)
    @sprites["grid"].bitmap = Bitmap.new("Graphics/Pictures/Bag/bg_grid") 
  end  
    @sprites["bagsprite"] = IconSprite.new(-20,10,@viewport)
    @sprites["background"] = IconSprite.new(0,0,@viewport)
    @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
    pbSetSystemFont(@sprites["overlay"].bitmap)
    @sprites["pocketicon"] = BitmapSprite.new(186,32,@viewport)
    @sprites["pocketicon"].x = 0
    @sprites["pocketicon"].y = -3
    @sprites["switchL"]=IconSprite.new(0,0,@viewport)
    @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL")
    @sprites["switchL"].x=2
    @sprites["switchL"].y=180
    @sprites["switchR"]=IconSprite.new(0,0,@viewport)
    @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR")
    @sprites["switchR"].x=162
    @sprites["switchR"].y=180
  if USEARROWS
    @sprites["switchR"].visible = true 
    @sprites["switchL"].visible = true
  else
    @sprites["switchR"].visible = false 
    @sprites["switchL"].visible = false
  end
    #@sprites["slider"]=IconSprite.new(Graphics.width-24,240,@viewport)
    #@sprites["slider"].setBitmap(sprintf("Graphics/Pictures/Bag/bagSlider"))
    @sprites["itemlist"] = Window_PokemonBag.new(@bag,@filterlist,lastpocket,168,-8,314,80+ITEMSVISIBLE*32)
    @sprites["itemlist"].viewport    = @viewport
    @sprites["itemlist"].pocket      = lastpocket
    @sprites["itemlist"].index       = @bag.getChoice(lastpocket)
    @sprites["itemlist"].baseColor   = ITEMLISTBASECOLOR
    @sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR
    @sprites["itemlist"].refresh
    @sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,-1,@viewport)
    @sprites["itemtext"] = Window_UnformattedTextPokemon.new("")
    @sprites["itemtext"].x           = 72
    @sprites["itemtext"].y           = 270
    @sprites["itemtext"].width       = Graphics.width-72-24
    @sprites["itemtext"].height      = 128
    @sprites["itemtext"].baseColor   = ITEMTEXTBASECOLOR
    @sprites["itemtext"].shadowColor = ITEMTEXTSHADOWCOLOR
    @sprites["itemtext"].visible     = true
    @sprites["itemtext"].viewport    = @viewport
    @sprites["itemtext"].windowskin  = nil
    @sprites["helpwindow"] = Window_UnformattedTextPokemon.new("")
    @sprites["helpwindow"].visible  = false
    @sprites["helpwindow"].viewport = @viewport
    @sprites["msgwindow"] = Window_AdvancedTextPokemon.new("")
    @sprites["msgwindow"].visible  = false
    @sprites["msgwindow"].viewport = @viewport
    pbBottomLeftLines(@sprites["helpwindow"],1)
    pbDeactivateWindows(@sprites)
    pbRefresh
    pbFadeInAndShow(@sprites)
  end

  def pbEndScene
    pbFadeOutAndHide(@sprites)
    pbDisposeSpriteHash(@sprites)
    @sliderbitmap.dispose
    @pocketbitmap.dispose
    @viewport.dispose
  end
  
 
def showPocketAnimation
  if $Trainer.isFemale?
    @sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_fm") 
    pbWait(3) 
    @sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f")
  else
    @sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}m")
    pbWait(3)
    @sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}")
  end   
end


  def pbDisplay(msg,brief=false)
    UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate }
  end

  def pbConfirm(msg)
    UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate }
  end

  def pbChooseNumber(helptext,maximum,initnum=1)
    return UIHelper.pbChooseNumber(@sprites["helpwindow"],helptext,maximum,initnum) { pbUpdate }
  end

  def pbShowCommands(helptext,commands,initcmd=0)
    return UIHelper.pbShowCommands(@sprites["helpwindow"],helptext,commands,initcmd) { pbUpdate }
  end
  
  def pbRefresh
    # Set the background image
    if $Trainer.isFemale?
      @sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg_f"))
    else
      @sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg"))
    end
    # Set the bag sprite
    fbagexists = pbResolveBitmap(sprintf("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f"))
    if $Trainer.isFemale? && fbagexists
    @sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f")
    else
    @sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}")
  end
    # Draw the pocket icons
    @sprites["pocketicon"].bitmap.clear
    if @choosing && @filterlist
      for i in [email protected]
        if @filterlist[i].length==0
          @sprites["pocketicon"].bitmap.blt(6+(i-1)*22,6,
             @pocketbitmap.bitmap,Rect.new((i-1)*20,30,20,20))
        end
      end
    end
    @sprites["pocketicon"].bitmap.blt(2+(@sprites["itemlist"].pocket-1)*0,2,
       @pocketbitmap.bitmap,Rect.new((@sprites["itemlist"].pocket-1)*28,0,28,28))
    # Refresh the item window
    @sprites["itemlist"].refresh
    # Refresh more things
    pbRefreshIndexChanged
  end

  def pbRefreshIndexChanged
    itemlist = @sprites["itemlist"]
    overlay = @sprites["overlay"].bitmap
    overlay.clear
    # Draw the pocket name
    pbDrawTextPositions(overlay,[
       [PokemonBag.pocketNames[@bag.lastpocket],94,180,2,POCKETNAMEBASECOLOR,POCKETNAMESHADOWCOLOR]
    ])
    
#=begin
    # Draw slider arrows
    showslider = false
    if itemlist.top_row>0
      overlay.blt(470,16,@sliderbitmap.bitmap,Rect.new(0,0,36,38))
      showslider = true
    end
    if itemlist.top_item+itemlist.page_item_max<itemlist.itemCount
      overlay.blt(470,228,@sliderbitmap.bitmap,Rect.new(0,38,36,38))
      showslider = true
    end
    if itemlist.top_item+itemlist.page_item_max<itemlist.itemCount
      overlay.blt(470,228,@sliderbitmap.bitmap,Rect.new(0,38,36,38))
      showslider = true
    end
#=end   
    # Draw slider box
    if showslider
      sliderheight = 174
      boxheight = (sliderheight*itemlist.page_row_max/itemlist.row_max).floor
      boxheight += [(sliderheight-boxheight)/2,sliderheight/6].min
      boxheight = [boxheight.floor,38].max
      y = 54
      y += ((sliderheight-boxheight)*itemlist.top_row/(itemlist.row_max-itemlist.page_row_max)).floor
      overlay.blt(470,y,@sliderbitmap.bitmap,Rect.new(36,0,36,4))
      i = 0; while i*16<boxheight-4-18
        height = [boxheight-4-18-i*16,16].min
        overlay.blt(470,y+4+i*16,@sliderbitmap.bitmap,Rect.new(36,4,36,height))
        i += 1
        showslider = false
      end
      overlay.blt(470,y+boxheight-18,@sliderbitmap.bitmap,Rect.new(36,20,36,18))
      showslider = false
    end

    # Set the selected item's icon
    @sprites["itemicon"].item = itemlist.item
    # Set the selected item's description
    @sprites["itemtext"].text = (itemlist.item==0) ? _INTL("Close bag.") : 
       pbGetMessage(MessageTypes::ItemDescriptions,itemlist.item)
     end
  
  def pbRefreshFilter
    @filterlist = nil
    return if [email protected]
    if @filterproc!=nil
      @filterlist = []
      for i in [email protected]
        @filterlist[i] = []
        for j in [email protected][i].length
          @filterlist[i].push(j) if @filterproc.call(@bag.pockets[i][j][0])
        end
      end
    else
    end
  end

  # Called when the item screen wants an item to be chosen from the screen
  def pbChooseItem
    @sprites["helpwindow"].visible = false
    itemwindow = @sprites["itemlist"]
    thispocket = @bag.pockets[itemwindow.pocket]
    swapinitialpos = 1
    pbActivateWindow(@sprites,"itemlist"){
      loop do
        @sprites["grid"].ox+=1 if ANIMEBG
        oldindex = itemwindow.index
        Graphics.update
        Input.update
        pbUpdate
        if itemwindow.sorting && itemwindow.index>=thispocket.length
          itemwindow.index = (oldindex==thispocket.length-1) ? 0 : thispocket.length-1
        end
        if itemwindow.index!=oldindex
          # Move the item being switched
          if itemwindow.sorting
            thispocket.insert(itemwindow.index,thispocket.delete_at(oldindex))
          end
          # Update selected item for current pocket
          @bag.setChoice(itemwindow.pocket,itemwindow.index)
          pbRefresh
        end
        if itemwindow.sorting
          if Input.trigger?(Input::A) ||
             Input.trigger?(Input::C)
            itemwindow.sorting = false
            pbPlayDecisionSE
            pbRefresh
          elsif Input.trigger?(Input::B)
            curindex = itemwindow.index
            thispocket.insert(swapinitialpos,thispocket.delete_at(itemwindow.index))
            itemwindow.index = swapinitialpos
            itemwindow.sorting = false
            pbPlayCancelSE
            pbRefresh
          end
        else       
          # Change pockets
          if Input.trigger?(Input::LEFT) #|| $mouse.leftClick?(@sprites["switchL"])
            newpocket = itemwindow.pocket
            loop do
              newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1
              break if [email protected] || newpocket==itemwindow.pocket
              if @filterlist; break if @filterlist[newpocket].length>0
              else; break if @bag.pockets[newpocket].length>0
              end
            end
            if itemwindow.pocket!=newpocket
              itemwindow.pocket = newpocket
              @bag.lastpocket   = itemwindow.pocket
              thispocket = @bag.pockets[itemwindow.pocket]
              showPocketAnimation
              @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL2") && USEARROWS
              pbWait(5)
              @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL") && USEARROWS
              pbSEPlay("BW2BagSound")
              pbRefresh
            end
            
          elsif Input.trigger?(Input::RIGHT) #|| $mouse.leftClick?(@sprites["switchR"])
            newpocket = itemwindow.pocket
            loop do             
              newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1
              break if [email protected] || newpocket==itemwindow.pocket
              if @filterlist; break if @filterlist[newpocket].length>0
              else; break if @bag.pockets[newpocket].length>0
              end
            end
            if itemwindow.pocket!=newpocket
              itemwindow.pocket = newpocket
              @bag.lastpocket   = itemwindow.pocket
              thispocket = @bag.pockets[itemwindow.pocket]
              showPocketAnimation
              @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR2") && USEARROWS
              pbWait(5)
              @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR") && USEARROWS
              pbSEPlay("BW2BagSound")
              pbRefresh
            end
            
      elsif defined?($mouse)     
        if $mouse.leftClick?(@sprites["switchL"]) && USEARROWS
            newpocket = itemwindow.pocket
            loop do
              newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1
              break if [email protected] || newpocket==itemwindow.pocket
              if @filterlist; break if @filterlist[newpocket].length>0
              else; break if @bag.pockets[newpocket].length>0
              end
            end
            if itemwindow.pocket!=newpocket
              itemwindow.pocket = newpocket
              @bag.lastpocket   = itemwindow.pocket
              thispocket = @bag.pockets[itemwindow.pocket]
              showPocketAnimation
              @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL2")
              pbWait(5)
              @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL") 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end
            
          elsif $mouse.leftClick?(@sprites["switchR"]) && USEARROWS
            newpocket = itemwindow.pocket
            loop do             
              newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1
              break if [email protected] || newpocket==itemwindow.pocket
              if @filterlist; break if @filterlist[newpocket].length>0
              else; break if @bag.pockets[newpocket].length>0
              end
            end
            if itemwindow.pocket!=newpocket
              itemwindow.pocket = newpocket
              @bag.lastpocket   = itemwindow.pocket
              thispocket = @bag.pockets[itemwindow.pocket]
              showPocketAnimation
              @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR2")
              pbWait(5)
              @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR")
              pbSEPlay("BW2BagSound")
              pbRefresh
            end  
#Using Mouse for changing pocket by clicking on them
      elsif $mouse.areaClick?(0,55,86,118) && USETOUCHBAG
          if itemwindow.pocket!=3
              @bag.lastpocket = 3
              itemwindow.pocket = 3
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end
        elsif $mouse.areaClick?(0,55,86,118,1) && USETOUCHBAG
          if itemwindow.pocket!=7
              @bag.lastpocket = 7
              itemwindow.pocket = 7
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end               
        elsif $mouse.areaClick?(86,23,72,100) && USETOUCHBAG
          if itemwindow.pocket!=1
              @bag.lastpocket = 1
              itemwindow.pocket = 1
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end    
        elsif $mouse.areaClick?(86,23,72,100,1) && USETOUCHBAG
          if itemwindow.pocket!=6
              @bag.lastpocket = 6
              itemwindow.pocket = 6
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end  
        elsif $mouse.areaClick?(0,209,48,48) && USETOUCHBAG
          if itemwindow.pocket!=2
              @bag.lastpocket = 2
              itemwindow.pocket = 2
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end 
        elsif $mouse.areaClick?(48,213,68,64) && USETOUCHBAG
          if itemwindow.pocket!=4
              @bag.lastpocket = 4
              itemwindow.pocket = 4
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end  
        elsif $mouse.inAreaLeft?(120,211,65,42) && USETOUCHBAG 
          if itemwindow.pocket!=5
              @bag.lastpocket = 5
              itemwindow.pocket = 5
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end  
           elsif $mouse.areaClick?(112,123,73,55) && USETOUCHBAG 
          if itemwindow.pocket!=8
              @bag.lastpocket = 8
              itemwindow.pocket = 8
              showPocketAnimation 
              pbSEPlay("BW2BagSound")
              pbRefresh
            end  
            elsif $mouse.inAreaLeftPress?(472,-120,40,384) && USETOUCHBAG 
             [email protected]["itemlist"]
             max=itemlist.itemCount-1
             itemlist.index=($mouse.y+5)*max/176
             itemlist.index=max if itemlist.index>max
             itemlist.index=0 if itemlist.index<0
             pbRefresh
           end
          elsif Input.trigger?(Input::F5) # Register/unregister selected item
            if [email protected] && itemwindow.index<thispocket.length
              if @bag.pbIsRegistered?(itemwindow.item)
                @bag.pbUnregisterItem(itemwindow.item)
              elsif pbCanRegisterItem?(itemwindow.item)
                @bag.pbRegisterItem(itemwindow.item)
              end
              pbSEPlay("BW2MenuChoose")
              pbRefresh
            end
          elsif Input.trigger?(Input::A) # Start switching the selected item
            if [email protected]
              if thispocket.length>1 && itemwindow.index<thispocket.length &&
                 !POCKETAUTOSORT[itemwindow.pocket]
                itemwindow.sorting = true
                swapinitialpos = itemwindow.index
                pbSEPlay("BW2MenuSelect")
                pbRefresh
              end
            end
          elsif Input.trigger?(Input::B) # Cancel the item screen
            pbSEPlay("BW2CloseMenu")
            return 0
          elsif Input.trigger?(Input::C) # Choose selected item
            pbPlayDecisionSE
            return itemwindow.item
          end
        end
      end
    }
  end
end
#===============================================================================
# Bag mechanics
#===============================================================================
class PokemonBagScreen
  def initialize(scene,bag)
    @bag   = bag
    @scene = scene
  end

  def pbStartScreen
    @scene.pbStartScene(@bag)
    item = 0
    loop do
      item = @scene.pbChooseItem
      break if item==0
      cmdRead     = -1
      cmdUse      = -1
      cmdRegister = -1
      cmdGive     = -1
      cmdToss     = -1
      cmdDebug    = -1
      commands = []
      # Generate command list
      commands[cmdRead = commands.length]        = _INTL("Read") if pbIsMail?(item)
      if ItemHandlers.hasOutHandler(item) || (pbIsMachine?(item) && $Trainer.party.length>0)
        if ItemHandlers.hasUseText(item)
          commands[cmdUse = commands.length]     = ItemHandlers.getUseText(item)
        else
          commands[cmdUse = commands.length]     = _INTL("Use")
        end
      end
      commands[cmdGive = commands.length]        = _INTL("Give") if $Trainer.pokemonParty.length>0 && pbCanHoldItem?(item)
      commands[cmdToss = commands.length]        = _INTL("Toss") if !pbIsImportantItem?(item) || $DEBUG
      if @bag.pbIsRegistered?(item)
        commands[cmdRegister = commands.length]  = _INTL("Deselect")
      elsif pbCanRegisterItem?(item)
        commands[cmdRegister = commands.length]  = _INTL("Register")
      end
      commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
      commands[commands.length]                  = _INTL("Cancel")
      # Show commands generated above
      itemname = PBItems.getName(item) # Get item name
      command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
      if cmdRead>=0 && command==cmdRead   # Read mail
        pbFadeOutIn(99999){
          pbDisplayMail(PokemonMail.new(item,"",""))
        }
      elsif cmdUse>=0 && command==cmdUse   # Use item
        ret = pbUseItem(@bag,item,@scene)
        # ret: 0=Item wasn't used; 1=Item used; 2=Close Bag to use in field
        break if ret==2 # End screen
        @scene.pbRefresh
        next
      elsif cmdGive>=0 && command==cmdGive   # Give item to Pokémon
        if $Trainer.pokemonCount==0
          @scene.pbDisplay(_INTL("There is no Pokémon."))
        elsif pbIsImportantItem?(item)
          @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
        else
          pbFadeOutIn(99999){
            sscene = PokemonParty_Scene.new
            sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
            sscreen.pbPokemonGiveScreen(item)
            @scene.pbRefresh
          }
        end
      elsif cmdToss>=0 && command==cmdToss   # Toss item
        qty = @bag.pbQuantity(item)
        if qty>1
          helptext = _INTL("Toss out how many {1}?",PBItems.getNamePlural(item))
          qty = @scene.pbChooseNumber(helptext,qty)
        end
        if qty>0
          itemname = PBItems.getNamePlural(item) if qty>1
          if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
            pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
            qty.times { @bag.pbDeleteItem(item) }
            @scene.pbRefresh
          end
        end   
      elsif cmdRegister>=0 && command==cmdRegister   # Register item
        if @bag.pbIsRegistered?(item)
          @bag.pbUnregisterItem(item)
        else
          @bag.pbRegisterItem(item)
        end
        @scene.pbRefresh
      elsif cmdDebug>=0 && command==cmdDebug   # Debug
        command = 0
        loop do
          command = @scene.pbShowCommands(_INTL("Do what with {1}?",itemname),[
            _INTL("Change quantity"),
            _INTL("Make Mystery Gift"),
            _INTL("Cancel")
            ],command)
          case command
          ### Cancel ###
          when -1, 2
            break
          ### Change quantity ###
          when 0
            qty = @bag.pbQuantity(item)
            itemplural = PBItems.getNamePlural(item)
            params = ChooseNumberParams.new
            params.setRange(0,BAGMAXPERSLOT)
            params.setDefaultValue(qty)
            newqty = Kernel.pbMessageChooseNumber(
               _INTL("Choose new quantity of {1}.",itemplural),params) { @scene.pbUpdate }
            if newqty>qty
              @bag.pbStoreItem(item,newqty-qty)
            elsif newqty<qty
              @bag.pbDeleteItem(item,qty-newqty)
            end
            @scene.pbRefresh
            break if newqty==0
          ### Make Mystery Gift ###
          when 1
            pbCreateMysteryGift(1,item)
          end
        end
      end
    end
    @scene.pbEndScene
    return item
  end

  def pbDisplay(text)
    @scene.pbDisplay(text)
  end

  def pbConfirm(text)
    return @scene.pbConfirm(text)
  end

  # UI logic for the item screen for choosing an item.
  def pbChooseItemScreen(proc=nil)
    oldlastpocket = @bag.lastpocket
    oldchoices = @bag.getAllChoices
    @scene.pbStartScene(@bag,true,proc)
    item = @scene.pbChooseItem
    @scene.pbEndScene
    @bag.lastpocket = oldlastpocket
    @bag.setAllChoices(oldchoices)
    return item
  end

  # UI logic for withdrawing an item in the item storage screen.
  def pbWithdrawItemScreen
    if !$PokemonGlobal.pcItemStorage
      $PokemonGlobal.pcItemStorage = PCItemStorage.new
    end
    storage = $PokemonGlobal.pcItemStorage
    @scene.pbStartScene(storage)
    loop do
      item = @scene.pbChooseItem
      break if item==0
      commands = [_INTL("Withdraw"),_INTL("Give"),_INTL("Cancel")]
      itemname = PBItems.getName(item)
      command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
      if command==0 # Withdraw
        qty = storage.pbQuantity(item)
        if qty>1 && !pbIsImportantItem?(item)
          qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty)
        end
        if qty>0
          if [email protected]?(item,qty)
            pbDisplay(_INTL("There's no more room in the Bag."))
          else
            dispqty = (pbIsImportantItem?(item)) ? 1 : qty
            itemname = PBItems.getNamePlural(item) if dispqty>1
            pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname))
            if !storage.pbDeleteItem(item,qty)
              raise "Can't delete items from storage"
            end
            if [email protected](item,qty)
              raise "Can't withdraw items from storage"
            end
          end
        end
      elsif command==1 # Give
        if $Trainer.pokemonCount==0
          @scene.pbDisplay(_INTL("There is no Pokémon."))
          return 0
        elsif pbIsImportantItem?(item)
          @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
        else
          pbFadeOutIn(99999){
            sscene  = PokemonParty_Scene.new
            sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
            if sscreen.pbPokemonGiveScreen(item)
              # If the item was held, delete the item from storage
              if !storage.pbDeleteItem(item,1)
                raise "Can't delete item from storage"
              end
            end
            @scene.pbRefresh
          }
        end
      end
    end
    @scene.pbEndScene
  end

  # UI logic for depositing an item in the item storage screen.
  def pbDepositItemScreen
    @scene.pbStartScene(@bag)
    if !$PokemonGlobal.pcItemStorage
      $PokemonGlobal.pcItemStorage = PCItemStorage.new
    end
    storage = $PokemonGlobal.pcItemStorage
    item = 0
    loop do
      item = @scene.pbChooseItem
      break if item==0
      qty = @bag.pbQuantity(item)
      if qty>1 && !pbIsImportantItem?(item)
        qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty)
      end
      if qty>0
        if !storage.pbCanStore?(item,qty)
          pbDisplay(_INTL("There's no room to store items."))
        else
          dispqty  = (pbIsImportantItem?(item)) ? 1 : qty
          itemname = (dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item)
          pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname))
          if [email protected](item,qty)
            raise "Can't delete items from bag"
          end
          if !storage.pbStoreItem(item,qty)
            raise "Can't deposit items to storage"
          end
        end
      end
    end
    @scene.pbEndScene
  end

  # UI logic for tossing an item in the item storage screen.
  def pbTossItemScreen
    if !$PokemonGlobal.pcItemStorage
      $PokemonGlobal.pcItemStorage = PCItemStorage.new
    end
    storage = $PokemonGlobal.pcItemStorage
    @scene.pbStartScene(storage)
    loop do
      item = @scene.pbChooseItem
      break if item==0
      if pbIsImportantItem?(item)
        @scene.pbDisplay(_INTL("That's too important to toss out!"))
        next
      end
      qty = storage.pbQuantity(item)
      itemname       = PBItems.getName(item)
      itemnameplural = PBItems.getNamePlural(item)
      if qty>1
        [email protected](_INTL("Toss out how many {1}?",itemnameplural),qty)
      end
      if qty>0
        itemname = itemnameplural if qty>1
        if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
          if !storage.pbDeleteItem(item,qty)
            raise "Can't delete items from storage"
          end
          pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
        end
      end
    end
    @scene.pbEndScene
  end
end

V16 Code
Spoiler:
#============================================================================== # PScreen Bag Graphical Overhaul by LackDeJurane or CharizardThree3 # If used please give credits.(This is for v16) #============================================================================= USEARROWS = false # Whether to use BW Styled Arrows for pocket changing ANIMEBG = true # Whether to use an Animated Background for the bag USETOUCHBAG = true # Whether to use mouse to click and change pockets. #DONT USE THE LAST OPTION ABOVE IF YOU DONT HAVE LUKA S.J's Easy Mouse System! class Window_PokemonBag < Window_DrawableCommand attr_reader :pocket attr_reader :sortIndex def initialize(bag,pocket,x,y,width,height) @bag=bag @pocket=pocket @sortIndex=-1 @adapter=PokemonMartAdapter.new super(x,y,width,height) @selarrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor") @swaparrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor_swap") self.windowskin=nil end def dispose @swaparrow.dispose super end def pocket=(value) @pocket=value [email protected][@pocket] @item_max=thispocket.length+1 [email protected](@pocket) refresh end def sortIndex=(value) @sortIndex=value refresh end def page_row_max; return PokemonBag_Scene::ITEMSVISIBLE; end def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end def itemCount return (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1 end def itemRect(item) if item<0 || item>[email protected]_max || item<self.top_item-1 || item>self.top_item+self.page_item_max return Rect.new(0,0,0,0) else cursor_width = (self.width-self.borderX-(@column_max-1)*@column_spacing) / @column_max x = item % @column_max * (cursor_width + @column_spacing) y = item / @column_max * @row_height - @virtualOy return Rect.new(x, y, cursor_width, @row_height) end end def drawCursor(index,rect) if self.index==index bmp = (@sorting) ? @swaparrow.bitmap : @selarrow.bitmap pbCopyBitmap(self.contents,bmp,rect.x,rect.y+14) end return Rect.new(rect.x+16,rect.y+16,rect.width-16,rect.height) end def pbCanRegisterItem?(item) return ItemHandlers.hasKeyItemHandler(item) end def item [email protected][self.pocket] item=thispocket[self.index] return item ? item[0] : 0 end def itemCount return @bag.pockets[self.pocket].length+1 end def drawItem(index,count,rect) textpos=[] rect=drawCursor(index,rect) ypos=rect.y+4 if [email protected][self.pocket].length textpos.push([_INTL("CLOSE BAG"),rect.x,ypos,false, self.baseColor,self.shadowColor]) else [email protected][self.pocket][index][0] [email protected](item) qty=_ISPRINTF("x{1: 2d}",@bag.pockets[self.pocket][index][1]) sizeQty=self.contents.text_size(qty).width xQty=rect.x+rect.width-sizeQty-16 baseColor=([email protected]) ? Color.new(224,0,0) : self.baseColor shadowColor=([email protected]) ? Color.new(248,144,144) : self.shadowColor textpos.push([itemname,rect.x,ypos,false,baseColor,shadowColor]) if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM) textpos.push([qty,xQty,ypos,false,baseColor,shadowColor]) end end pbDrawTextPositions(self.contents,textpos) if [email protected][self.pocket].length if @[email protected][self.pocket][index][0] pbDrawImagePositions(self.contents,[ ["Graphics/Pictures/Bag/bagReg",rect.x+rect.width-72,ypos+4,0,0,-1,-1] ]) elsif pbCanRegisterItem?(item) && pbIsKeyItem?(item) pbDrawImagePositions(self.contents,[ ["Graphics/Pictures/Bag/bagReg2",rect.x+rect.width-72,ypos+4,0,0,-1,-1] ]) end end end def refresh @item_max=itemCount() dwidth=self.width-self.borderX dheight=self.height-self.borderY self.contents=pbDoEnsureBitmap(self.contents,dwidth,dheight) self.contents.clear for i in [email protected]_max if i<self.top_item-1 || i>self.top_item+self.page_item_max next end drawItem(i,@item_max,itemRect(i)) end drawCursor(self.index,itemRect(self.index)) end end class PokemonBag_Scene ## Configuration ITEMLISTBASECOLOR = Color.new(255,255,255) ITEMLISTSHADOWCOLOR = Color.new(156,156,156) ITEMTEXTBASECOLOR = Color.new(248,248,248) ITEMTEXTSHADOWCOLOR = Color.new(90,90,90) POCKETNAMEBASECOLOR = Color.new(248,248,248) POCKETNAMESHADOWCOLOR = Color.new(90,90,90) ITEMSVISIBLE = 7 def update pbUpdateSpriteHash(@sprites) end def pbStartScene(bag) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 @bag=bag @sprites={} [email protected] [email protected](lastpocket) @sprites["grid"]=AnimatedPlane.new(@viewport) if $Trainer.isFemale? @sprites["grid"]=AnimatedPlane.new(@viewport) @sprites["grid"].bitmap = Bitmap.new("Graphics/Pictures/Bag/bg_gridf") else @sprites["grid"]=AnimatedPlane.new(@viewport) @sprites["grid"].bitmap = Bitmap.new("Graphics/Pictures/Bag/bg_grid") end @sprites["bag"]=IconSprite.new(-20,10,@viewport) @sprites["background"]=IconSprite.new(0,0,@viewport) @sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg")) if $Trainer.isMale? @sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg_f")) if $Trainer.isFemale? @sprites["switchL"]=IconSprite.new(0,0,@viewport) @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL") @sprites["switchL"].x=2 @sprites["switchL"].y=180 @sprites["switchR"]=IconSprite.new(0,0,@viewport) @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR") @sprites["switchR"].x=162 @sprites["switchR"].y=180 if USEARROWS @sprites["switchR"].visible = true @sprites["switchL"].visible = true else @sprites["switchR"].visible = false @sprites["switchL"].visible = false end @sprites["icon"]=ItemIconSprite.new(48,Graphics.height-48,-1,@viewport) @sprites["itemwindow"]=Window_PokemonBag.new(@bag,lastpocket,168,-8,314,40+32+ITEMSVISIBLE*32) @sprites["itemwindow"][email protected] @sprites["itemwindow"].pocket=lastpocket @sprites["itemwindow"].index=lastitem @sprites["itemwindow"].baseColor=ITEMLISTBASECOLOR @sprites["itemwindow"].shadowColor=ITEMLISTSHADOWCOLOR @sprites["itemwindow"].refresh @sprites["slider"]=IconSprite.new(Graphics.width-40,60,@viewport) @sprites["slider"].setBitmap(sprintf("Graphics/Pictures/Bag/bagSlider")) @sprites["pocketwindow"]=BitmapSprite.new(186,228,@viewport) pbSetSystemFont(@sprites["pocketwindow"].bitmap) @sprites["itemtextwindow"]=Window_UnformattedTextPokemon.new("") @sprites["itemtextwindow"].x=72 @sprites["itemtextwindow"].y=270 @sprites["itemtextwindow"].width=Graphics.width-72 @sprites["itemtextwindow"].height=128 @sprites["itemtextwindow"].baseColor=ITEMTEXTBASECOLOR @sprites["itemtextwindow"].shadowColor=ITEMTEXTSHADOWCOLOR @sprites["itemtextwindow"].visible=true @sprites["itemtextwindow"][email protected] @sprites["itemtextwindow"].windowskin=nil @sprites["helpwindow"]=Window_UnformattedTextPokemon.new("") @sprites["helpwindow"].visible=false @sprites["helpwindow"][email protected] @sprites["msgwindow"]=Window_AdvancedTextPokemon.new("") @sprites["msgwindow"].visible=false @sprites["msgwindow"][email protected] pbBottomLeftLines(@sprites["helpwindow"],1) pbDeactivateWindows(@sprites) pbRefresh pbFadeInAndShow(@sprites) end def pbEndScene pbFadeOutAndHide(@sprites) pbDisposeSpriteHash(@sprites) @viewport.dispose end def pbChooseNumber(helptext,maximum) return UIHelper.pbChooseNumber( @sprites["helpwindow"],helptext,maximum) { update } end def pbDisplay(msg,brief=false) UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { update } end def pbConfirm(msg) UIHelper.pbConfirm(@sprites["msgwindow"],msg) { update } end def pbShowCommands(helptext,commands) return UIHelper.pbShowCommands( @sprites["helpwindow"],helptext,commands) { update } end def showPocketAnimation pockets=pbPocketNames for i in 8..pockets.length if $Trainer.isFemale? @sprites["bag"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_fm") pbWait(3) @sprites["bag"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f") else @sprites["bag"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}m") pbWait(3) @sprites["bag"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}") end end end def pbRefresh [email protected]["pocketwindow"].bitmap bm.clear # Set the background bitmap for the currently selected pocket @sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg")) if $Trainer.isMale? @sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg_f")) if $Trainer.isFemale? # Set the bag picture for the currently selected pocket fbagexists = pbResolveBitmap(sprintf("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f")) if $Trainer.isFemale? && fbagexists @sprites["bag"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f") else @sprites["bag"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}") end # Draw the pocket name name=PokemonBag.pocketNames()[@bag.lastpocket] base=POCKETNAMEBASECOLOR shadow=POCKETNAMESHADOWCOLOR pbDrawTextPositions(bm,[ [name,bm.width/2,180,2,base,shadow] ]) # Reset positions of left/right arrows around the bag #@sprites["leftarrow"].x=-4 # @sprites["leftarrow"].y=76 # @sprites["rightarrow"].x=150 # @sprites["rightarrow"].y=76 [email protected]["itemwindow"] # Draw the slider ycoord=60 if itemwindow.itemCount>1 ycoord+=116.0 * itemwindow.index/(itemwindow.itemCount-1) end @sprites["slider"].y=ycoord # Set the icon for the currently selected item @sprites["icon"].item=itemwindow.item # Display the item's description @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Close bag.") : pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item) # Refresh the item window itemwindow.refresh end # Called when the item screen wants an item to be chosen from the screen def pbChooseItem(lockpocket=false) pbRefresh @sprites["helpwindow"].visible=false [email protected]["itemwindow"] itemwindow.refresh sorting=false sortindex=-1 pbActivateWindow(@sprites,"itemwindow"){ loop do @sprites["grid"].ox+=1 if ANIMEBG Graphics.update Input.update olditem=itemwindow.item oldindex=itemwindow.index self.update if itemwindow.item!=olditem # Update slider position ycoord=60 if itemwindow.itemCount>1 ycoord+=116.0 * itemwindow.index/(itemwindow.itemCount-1) end @sprites["slider"].y=ycoord # Update item icon and description @sprites["icon"].item=itemwindow.item @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Close bag.") : pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item) end if itemwindow.index!=oldindex # Update selected item for current pocket @bag.setChoice(itemwindow.pocket,itemwindow.index) end if !lockpocket # Change pockets if Left/Right pressed numpockets=PokemonBag.numPockets if Input.trigger?(Input::LEFT) if !sorting itemwindow.pocket=(itemwindow.pocket==1) ? numpockets : itemwindow.pocket-1 @bag.lastpocket=itemwindow.pocket showPocketAnimation pbSEPlay("BW2BagSound") @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL2") pbWait(5) @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL") pbRefresh end elsif Input.trigger?(Input::RIGHT) if !sorting itemwindow.pocket=(itemwindow.pocket==numpockets) ? 1 : itemwindow.pocket+1 @bag.lastpocket=itemwindow.pocket showPocketAnimation pbSEPlay("BW2BagSound") @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR2") pbWait(5) @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR") pbRefresh end end end if defined?($mouse) if $mouse.leftClick?(@sprites["switchL"]) && USEARROWS if !sorting itemwindow.pocket=(itemwindow.pocket==1) ? numpockets : itemwindow.pocket-1 @bag.lastpocket=itemwindow.pocket showPocketAnimation pbSEPlay("BW2BagSound") @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL2") pbWait(5) @sprites["switchL"].setBitmap("Graphics/Pictures/Bag/switchL") pbRefresh end elsif $mouse.leftClick?(@sprites["switchR"]) && USEARROWS if !sorting itemwindow.pocket=(itemwindow.pocket==numpockets) ? 1 : itemwindow.pocket+1 @bag.lastpocket=itemwindow.pocket showPocketAnimation pbSEPlay("BW2BagSound") @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR2") pbWait(5) @sprites["switchR"].setBitmap("Graphics/Pictures/Bag/switchR") pbRefresh end elsif $mouse.areaClick?(0,55,86,118) && USETOUCHBAG if itemwindow.pocket!=3 @bag.lastpocket = 3 itemwindow.pocket = 3 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.areaClick?(0,55,86,118,1) && USETOUCHBAG if itemwindow.pocket!=7 @bag.lastpocket = 7 itemwindow.pocket = 7 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.areaClick?(86,23,72,100) && USETOUCHBAG if itemwindow.pocket!=1 @bag.lastpocket = 1 itemwindow.pocket = 1 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.areaClick?(86,23,72,100,1) && USETOUCHBAG if itemwindow.pocket!=6 @bag.lastpocket = 6 itemwindow.pocket = 6 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.areaClick?(0,209,48,48) && USETOUCHBAG if itemwindow.pocket!=2 @bag.lastpocket = 2 itemwindow.pocket = 2 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.areaClick?(48,213,68,64) && USETOUCHBAG if itemwindow.pocket!=4 @bag.lastpocket = 4 itemwindow.pocket = 4 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.inAreaLeft?(120,211,65,42) && USETOUCHBAG if itemwindow.pocket!=5 @bag.lastpocket = 5 itemwindow.pocket = 5 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end elsif $mouse.areaClick?(112,123,73,55) && USETOUCHBAG if itemwindow.pocket!=8 @bag.lastpocket = 8 itemwindow.pocket = 8 showPocketAnimation pbSEPlay("BW2BagSound") pbRefresh end end end # Select item for switching if A is pressed if Input.trigger?(Input::A) [email protected][itemwindow.pocket] if itemwindow.index<thispocket.length && thispocket.length>1 && !POCKETAUTOSORT[itemwindow.pocket] sortindex=itemwindow.index sorting=true @sprites["itemwindow"].sortIndex=sortindex else next end end # Cancel switching or cancel the item screen if Input.trigger?(Input::B) if sorting sorting=false @sprites["itemwindow"].sortIndex=-1 else return 0 end end # Confirm selection or item switch if Input.trigger?(Input::C) [email protected][itemwindow.pocket] if itemwindow.index<thispocket.length if sorting sorting=false tmp=thispocket[itemwindow.index] thispocket[itemwindow.index]=thispocket[sortindex] thispocket[sortindex]=tmp @sprites["itemwindow"].sortIndex=-1 pbRefresh next else pbRefresh return thispocket[itemwindow.index][0] end else return 0 end end end } end end class PokemonBagScreen def initialize(scene,bag) @bag=bag @scene=scene end def pbDisplay(text) @scene.pbDisplay(text) end def pbConfirm(text) return @scene.pbConfirm(text) end # UI logic for the item screen when an item is to be held by a Pokémon. def pbGiveItemScreen @scene.pbStartScene(@bag) item=0 loop do [email protected] break if item==0 itemname=PBItems.getName(item) # Key items and hidden machines can't be held if pbIsImportantItem?(item) @scene.pbDisplay(_INTL("The {1} can't be held.",itemname)) next else break end end @scene.pbEndScene return item end # UI logic for the item screen when an item is used on a Pokémon from the party screen. def pbUseItemScreen(pokemon) @scene.pbStartScene(@bag) item=0 loop do [email protected] break if item==0 itemname=PBItems.getName(item) # Can't use certain items on Pokémon if !ItemHandlers.hasUseOnPokemon(item) && !pbIsMachine?(item) @scene.pbDisplay(_INTL("The {1} can't be used on {2}.",itemname,pokemon.name)) next else break end end @scene.pbEndScene return item end # UI logic for the item screen for choosing an item def pbChooseItemScreen [email protected] @scene.pbStartScene(@bag) [email protected] @scene.pbEndScene @bag.lastpocket=oldlastpocket return item end # UI logic for the item screen for choosing a Berry def pbChooseBerryScreen [email protected] @bag.lastpocket=BERRYPOCKET @scene.pbStartScene(@bag) item=0 loop do [email protected](true) break if item==0 itemname=PBItems.getName(item) if !pbIsBerry?(item) @scene.pbDisplay(_INTL("That's not a Berry.",itemname)) next else break end end @scene.pbEndScene @bag.lastpocket=oldlastpocket return item end # UI logic for tossing an item in the item screen. def pbTossItemScreen if !$PokemonGlobal.pcItemStorage $PokemonGlobal.pcItemStorage=PCItemStorage.new end storage=$PokemonGlobal.pcItemStorage @scene.pbStartScene(storage) loop do [email protected] break if item==0 if pbIsImportantItem?(item) @scene.pbDisplay(_INTL("That's too important to toss out!")) next end qty=storage.pbQuantity(item) itemname=PBItems.getName(item) itemnameplural=PBItems.getNamePlural(item) if qty>1 [email protected](_INTL("Toss out how many {1}?",itemnameplural),qty) end if qty>0 itemname=itemnameplural if qty>1 if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname)) if !storage.pbDeleteItem(item,qty) raise "Can't delete items from storage" end pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname)) end end end @scene.pbEndScene end # UI logic for withdrawing an item in the item screen. def pbWithdrawItemScreen if !$PokemonGlobal.pcItemStorage $PokemonGlobal.pcItemStorage=PCItemStorage.new end storage=$PokemonGlobal.pcItemStorage @scene.pbStartScene(storage) loop do [email protected] break if item==0 commands=[_INTL("Withdraw"),_INTL("Give"),_INTL("Cancel")] itemname=PBItems.getName(item) [email protected](_INTL("{1} is selected.",itemname),commands) if command==0 qty=storage.pbQuantity(item) if qty>1 && !pbIsImportantItem?(item) [email protected](_INTL("How many do you want to withdraw?"),qty) end if qty>0 dispqty=(pbIsImportantItem?(item)) ? 1 : qty itemname=PBItems.getNamePlural(item) if dispqty>1 if [email protected]?(item,qty) pbDisplay(_INTL("There's no more room in the Bag.")) else pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname)) if !storage.pbDeleteItem(item,qty) raise "Can't delete items from storage" end if [email protected](item,qty) raise "Can't withdraw items from storage" end end end elsif command==1 # Give if $Trainer.pokemonCount==0 @scene.pbDisplay(_INTL("There is no Pokémon.")) return 0 elsif pbIsImportantItem?(item) @scene.pbDisplay(_INTL("The {1} can't be held.",itemname)) else pbFadeOutIn(99999){ sscene=PokemonScreen_Scene.new sscreen=PokemonScreen.new(sscene,$Trainer.party) if sscreen.pbPokemonGiveScreen(item) # If the item was held, delete the item from storage if !storage.pbDeleteItem(item,1) raise "Can't delete item from storage" end end @scene.pbRefresh } end end end @scene.pbEndScene end # UI logic for depositing an item in the item screen. def pbDepositItemScreen @scene.pbStartScene(@bag) if !$PokemonGlobal.pcItemStorage $PokemonGlobal.pcItemStorage=PCItemStorage.new end storage=$PokemonGlobal.pcItemStorage item=0 loop do [email protected] break if item==0 [email protected](item) if qty>1 && !pbIsImportantItem?(item) [email protected](_INTL("How many do you want to deposit?"),qty) end if qty>0 if !storage.pbCanStore?(item,qty) pbDisplay(_INTL("There's no room to store items.")) else dispqty=(pbIsImportantItem?(item)) ? 1 : qty itemname=(dispqty>1) ? PBItems.getNamePlural(item) : PBItems.getName(item) pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname)) if [email protected](item,qty) raise "Can't delete items from bag" end if !storage.pbStoreItem(item,qty) raise "Can't deposit items to storage" end end end end @scene.pbEndScene end def pbStartScreen @scene.pbStartScene(@bag) item=0 loop do [email protected] break if item==0 cmdUse = -1 cmdRegister = -1 cmdGive = -1 cmdToss = -1 cmdRead = -1 cmdMysteryGift = -1 commands=[] # Generate command list commands[cmdRead=commands.length]=_INTL("Read") if pbIsMail?(item) commands[cmdUse=commands.length]=_INTL("Use") if ItemHandlers.hasOutHandler(item) || (pbIsMachine?(item) && $Trainer.party.length>0) commands[cmdGive=commands.length]=_INTL("Give") if $Trainer.pokemonParty.length>0 && !pbIsImportantItem?(item) commands[cmdToss=commands.length]=_INTL("Toss") if !pbIsImportantItem?(item) || $DEBUG if @bag.registeredItem==item commands[cmdRegister=commands.length]=_INTL("Deselect") elsif pbIsKeyItem?(item) && ItemHandlers.hasKeyItemHandler(item) commands[cmdRegister=commands.length]=_INTL("Register") end commands[cmdMysteryGift=commands.length]=_INTL("Make Mystery Gift") if $DEBUG commands[commands.length]=_INTL("Cancel") # Show commands generated above itemname=PBItems.getName(item) # Get item name [email protected](_INTL("{1} is selected.",itemname),commands) if cmdUse>=0 && command==cmdUse # Use item ret=pbUseItem(@bag,item,@scene) # 0=Item wasn't used; 1=Item used; 2=Close Bag to use in field break if ret==2 # End screen @scene.pbRefresh next elsif cmdRead>=0 && command==cmdRead # Read mail pbFadeOutIn(99999){ pbDisplayMail(PokemonMail.new(item,"","")) } elsif cmdRegister>=0 && command==cmdRegister # Register key item @bag.pbRegisterKeyItem(item) @scene.pbRefresh elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon if $Trainer.pokemonCount==0 @scene.pbDisplay(_INTL("There is no Pokémon.")) elsif pbIsImportantItem?(item) @scene.pbDisplay(_INTL("The {1} can't be held.",itemname)) else # Give item to a Pokémon pbFadeOutIn(99999){ sscene=PokemonScreen_Scene.new sscreen=PokemonScreen.new(sscene,$Trainer.party) sscreen.pbPokemonGiveScreen(item) @scene.pbRefresh } end elsif cmdToss>=0 && command==cmdToss # Toss item [email protected](item) if qty>1 helptext=_INTL("Toss out how many {1}?",PBItems.getNamePlural(item)) [email protected](helptext,qty) end if qty>0 itemname=PBItems.getNamePlural(item) if qty>1 if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname)) pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname)) qty.times { @bag.pbDeleteItem(item) } end end elsif cmdMysteryGift>=0 && command==cmdMysteryGift # Export to Mystery Gift pbCreateMysteryGift(1,item) end end @scene.pbEndScene return item end end #=============================================================================== # The Bag object, which actually contains all the items #=============================================================================== class PokemonBag attr_reader :registeredItem attr_accessor :lastpocket attr_reader :pockets def self.pocketNames() return pbPocketNames end def self.numPockets() return self.pocketNames().length-1 end def initialize @lastpocket=1 @pockets=[] @choices=[] # Initialize each pocket of the array for i in 0..PokemonBag.numPockets @pockets[i]=[] @choices[i]=0 end @registeredItem=0 end def pockets rearrange return @pockets end def rearrange if (@pockets.length-1)!=PokemonBag.numPockets newpockets=[] for i in 0..PokemonBag.numPockets newpockets[i]=[] @choices[i]=0 if [email protected][i] end nump=PokemonBag.numPockets for i in [email protected] for item in @pockets[i] p=pbGetPocket(item[0]) newpockets[p].push(item) if p<=nump end end @pockets=newpockets end end # Gets the index of the current selected item in the pocket def getChoice(pocket) if pocket<=0 || pocket>PokemonBag.numPockets raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect)) end rearrange return [@choices[pocket],@pockets[pocket].length].min || 0 end # Clears the entire bag def clear for pocket in @pockets pocket.clear end end # Sets the index of the current selected item in the pocket def setChoice(pocket,value) if pocket<=0 || pocket>PokemonBag.numPockets raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect)) end rearrange @choices[pocket]=value if value<[email protected][pocket].length end # Registers the item as a key item. Can be retrieved with $PokemonBag.registeredItem def pbRegisterKeyItem(item) if item.is_a?(String) || item.is_a?(Symbol) item=getID(PBItems,item) end if !item || item<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return end @registeredItem=([email protected]) ? item : 0 end def maxPocketSize(pocket) maxsize=MAXPOCKETSIZE[pocket] return -1 if !maxsize return maxsize end def pbQuantity(item) if item.is_a?(String) || item.is_a?(Symbol) item=getID(PBItems,item) end if !item || item<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return 0 end pocket=pbGetPocket(item) maxsize=maxPocketSize(pocket) [email protected][pocket].length if maxsize<0 return ItemStorageHelper.pbQuantity(@pockets[pocket],maxsize,item) end def pbHasItem?(item) return pbQuantity(item)>0 end def pbDeleteItem(item,qty=1) if item.is_a?(String) || item.is_a?(Symbol) item=getID(PBItems,item) end if !item || item<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return false end pocket=pbGetPocket(item) maxsize=maxPocketSize(pocket) [email protected][pocket].length if maxsize<0 ret=ItemStorageHelper.pbDeleteItem(@pockets[pocket],maxsize,item,qty) if ret @registeredItem=0 if @registeredItem==item && !pbHasItem?(item) end return ret end def pbCanStore?(item,qty=1) if item.is_a?(String) || item.is_a?(Symbol) item=getID(PBItems,item) end if !item || item<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return false end pocket=pbGetPocket(item) maxsize=maxPocketSize(pocket) [email protected][pocket].length+1 if maxsize<0 return ItemStorageHelper.pbCanStore?( @pockets[pocket],maxsize,BAGMAXPERSLOT,item,qty) end def pbStoreAllOrNone(item,qty=1) if item.is_a?(String) || item.is_a?(Symbol) item=getID(PBItems,item) end if !item || item<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return false end pocket=pbGetPocket(item) maxsize=maxPocketSize(pocket) [email protected][pocket].length+1 if maxsize<0 return ItemStorageHelper.pbStoreAllOrNone( @pockets[pocket],maxsize,BAGMAXPERSLOT,item,qty) end def pbStoreItem(item,qty=1) if item.is_a?(String) || item.is_a?(Symbol) item=getID(PBItems,item) end if !item || item<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return false end pocket=pbGetPocket(item) maxsize=maxPocketSize(pocket) [email protected][pocket].length+1 if maxsize<0 return ItemStorageHelper.pbStoreItem( @pockets[pocket],maxsize,BAGMAXPERSLOT,item,qty,true) end def pbChangeItem(olditem,newitem) if olditem.is_a?(String) || olditem.is_a?(Symbol) olditem=getID(PBItems,olditem) end if newitem.is_a?(String) || newitem.is_a?(Symbol) newitem=getID(PBItems,newitem) end if !olditem || olditem<1 || !newitem || newitem<1 raise ArgumentError.new(_INTL("The item number is invalid.")) return false end pocket=pbGetPocket(olditem) maxsize=maxPocketSize(pocket) [email protected][pocket].length if maxsize<0 ret=false for i in 0...maxsize [email protected][pocket][i] if itemslot && itemslot[0]==olditem itemslot[0]=newitem ret=true end end return ret end end #=============================================================================== # PC item storage screen #=============================================================================== class Window_PokemonItemStorage < Window_DrawableCommand attr_reader :bag attr_reader :pocket attr_reader :sortIndex def sortIndex=(value) @sortIndex=value refresh end def initialize(bag,x,y,width,height) @bag=bag @sortIndex=-1 @adapter=PokemonMartAdapter.new super(x,y,width,height) self.windowskin=nil end def item [email protected][self.index] return item ? item[0] : 0 end def itemCount return @bag.length+1 end def drawItem(index,count,rect) textpos=[] rect=drawCursor(index,rect) ypos=rect.y if [email protected] textpos.push([_INTL("CANCEL"),rect.x,ypos,false, self.baseColor,self.shadowColor]) else [email protected][index][0] [email protected](item) qty=_ISPRINTF("x{1: 2d}",@bag[index][1]) sizeQty=self.contents.text_size(qty).width xQty=rect.x+rect.width-sizeQty-2 baseColor=([email protected]) ? Color.new(248,24,24) : self.baseColor textpos.push([itemname,rect.x,ypos,false,self.baseColor,self.shadowColor]) if !pbIsImportantItem?(item) # Not a Key item or HM (or infinite TM) textpos.push([qty,xQty,ypos,false,baseColor,self.shadowColor]) end end pbDrawTextPositions(self.contents,textpos) end end class ItemStorageScene ## Configuration ITEMLISTBASECOLOR = Color.new(88,88,80) ITEMLISTSHADOWCOLOR = Color.new(168,184,184) ITEMTEXTBASECOLOR = Color.new(248,248,248) ITEMTEXTSHADOWCOLOR = Color.new(0,0,0) TITLEBASECOLOR = Color.new(248,248,248) TITLESHADOWCOLOR = Color.new(0,0,0) ITEMSVISIBLE = 7 def initialize(title) @title=title end def update pbUpdateSpriteHash(@sprites) end def pbStartScene(bag) @viewport=Viewport.new(0,0,Graphics.width,Graphics.height) @viewport.z=99999 @bag=bag @sprites={} @sprites["background"]=IconSprite.new(0,0,@viewport) @sprites["background"].setBitmap("Graphics/Pictures/pcItembg") @sprites["icon"]=ItemIconSprite.new(50,334,-1,@viewport) # Item list @sprites["itemwindow"]=Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32) @sprites["itemwindow"][email protected] @sprites["itemwindow"].index=0 @sprites["itemwindow"].baseColor=ITEMLISTBASECOLOR @sprites["itemwindow"].shadowColor=ITEMLISTSHADOWCOLOR @sprites["itemwindow"].refresh # Title @sprites["pocketwindow"]=BitmapSprite.new(88,64,@viewport) @sprites["pocketwindow"].x=14 @sprites["pocketwindow"].y=16 pbSetNarrowFont(@sprites["pocketwindow"].bitmap) # Item description @sprites["itemtextwindow"]=Window_UnformattedTextPokemon.newWithSize("",84,270,Graphics.width-84,128,@viewport) @sprites["itemtextwindow"].baseColor=ITEMTEXTBASECOLOR @sprites["itemtextwindow"].shadowColor=ITEMTEXTSHADOWCOLOR @sprites["itemtextwindow"].windowskin=nil @sprites["helpwindow"]=Window_UnformattedTextPokemon.new("") @sprites["helpwindow"].visible=false @sprites["helpwindow"][email protected] # Letter-by-letter message window @sprites["msgwindow"]=Window_AdvancedTextPokemon.new("") @sprites["msgwindow"].visible=false @sprites["msgwindow"][email protected] pbBottomLeftLines(@sprites["helpwindow"],1) pbDeactivateWindows(@sprites) pbRefresh pbFadeInAndShow(@sprites) end def pbEndScene pbFadeOutAndHide(@sprites) pbDisposeSpriteHash(@sprites) @viewport.dispose end def pbRefresh [email protected]["pocketwindow"].bitmap # Draw title at upper left corner ("Toss Item/Withdraw Item") drawTextEx(bm,0,0,bm.width,2,@title,TITLEBASECOLOR,TITLESHADOWCOLOR) [email protected]["itemwindow"] # Draw item icon @sprites["icon"].item=itemwindow.item # Get item description @sprites["itemtextwindow"].text=(itemwindow.item==0) ? _INTL("Close storage.") : pbGetMessage(MessageTypes::ItemDescriptions,itemwindow.item) itemwindow.refresh end def pbChooseItem pbRefresh @sprites["helpwindow"].visible=false [email protected]["itemwindow"] itemwindow.refresh pbActivateWindow(@sprites,"itemwindow"){ loop do Graphics.update Input.update olditem=itemwindow.item self.update if itemwindow.item!=olditem self.pbRefresh end if Input.trigger?(Input::B) return 0 end if Input.trigger?(Input::C) if itemwindow.index<@bag.length pbRefresh return @bag[itemwindow.index][0] else return 0 end end end } end def pbChooseNumber(helptext,maximum) return UIHelper.pbChooseNumber( @sprites["helpwindow"],helptext,maximum) { update } end def pbDisplay(msg,brief=false) UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { update } end def pbConfirm(msg) UIHelper.pbConfirm(@sprites["msgwindow"],msg) { update } end def pbShowCommands(helptext,commands) return UIHelper.pbShowCommands( @sprites["helpwindow"],helptext,commands) { update } end end class WithdrawItemScene < ItemStorageScene def initialize super(_INTL("Withdraw\nItem")) end end class TossItemScene < ItemStorageScene def initialize super(_INTL("Toss\nItem")) end end #=============================================================================== # The PC item storage object, which actually contains all the items #=============================================================================== class PCItemStorage MAXSIZE = 50 # Number of different slots in storage MAXPERSLOT = 999 # Max. number of items per slot def initialize @items=[] # Start storage with a Potion if hasConst?(PBItems,:POTION) ItemStorageHelper.pbStoreItem( @items,MAXSIZE,MAXPERSLOT,getConst(PBItems,:POTION),1) end end def empty? return @items.length==0 end def length @items.length end def [](i) @items[i] end def getItem(index) if index<0 || index>[email protected] return 0 else return @items[index][0] end end def getCount(index) if index<0 || index>[email protected] return 0 else return @items[index][1] end end def pbQuantity(item) return ItemStorageHelper.pbQuantity(@items,MAXSIZE,item) end def pbDeleteItem(item,qty=1) return ItemStorageHelper.pbDeleteItem(@items,MAXSIZE,item,qty) end def pbCanStore?(item,qty=1) return ItemStorageHelper.pbCanStore?(@items,MAXSIZE,MAXPERSLOT,item,qty) end def pbStoreItem(item,qty=1) return ItemStorageHelper.pbStoreItem(@items,MAXSIZE,MAXPERSLOT,item,qty) end end #=============================================================================== # Common UI functions used in both the Bag and item storage screens. # Allows the user to choose a number. The window _helpwindow_ will # display the _helptext_. #=============================================================================== module UIHelper def self.pbChooseNumber(helpwindow,helptext,maximum) oldvisible=helpwindow.visible helpwindow.visible=true helpwindow.text=helptext helpwindow.letterbyletter=false curnumber=1 ret=0 using(numwindow=Window_UnformattedTextPokemon.new("x000")){ numwindow.viewport=helpwindow.viewport numwindow.letterbyletter=false numwindow.text=_ISPRINTF("x{1:03d}",curnumber) numwindow.resizeToFit(numwindow.text,480) pbBottomRight(numwindow) # Move number window to the bottom right helpwindow.resizeHeightToFit(helpwindow.text,480-numwindow.width) pbBottomLeft(helpwindow) # Move help window to the bottom left loop do Graphics.update Input.update numwindow.update block_given? ? yield : helpwindow.update if Input.repeat?(Input::LEFT) curnumber-=10 curnumber=1 if curnumber<1 numwindow.text=_ISPRINTF("x{1:03d}",curnumber) pbPlayCursorSE() elsif Input.repeat?(Input::RIGHT) curnumber+=10 curnumber=maximum if curnumber>maximum numwindow.text=_ISPRINTF("x{1:03d}",curnumber) pbPlayCursorSE() elsif Input.repeat?(Input::UP) curnumber+=1 curnumber=1 if curnumber>maximum numwindow.text=_ISPRINTF("x{1:03d}",curnumber) pbPlayCursorSE() elsif Input.repeat?(Input::DOWN) curnumber-=1 curnumber=maximum if curnumber<1 numwindow.text=_ISPRINTF("x{1:03d}",curnumber) pbPlayCursorSE() elsif Input.trigger?(Input::C) ret=curnumber pbPlayDecisionSE() break elsif Input.trigger?(Input::B) ret=0 pbPlayCancelSE() break end end } helpwindow.visible=oldvisible return ret end def self.pbDisplayStatic(msgwindow,message) oldvisible=msgwindow.visible msgwindow.visible=true msgwindow.letterbyletter=false msgwindow.width=Graphics.width msgwindow.resizeHeightToFit(message,Graphics.width) msgwindow.text=message pbBottomRight(msgwindow) loop do Graphics.update Input.update if Input.trigger?(Input::B) break end if Input.trigger?(Input::C) break end block_given? ? yield : msgwindow.update end msgwindow.visible=oldvisible Input.update end # Letter by letter display of the message _msg_ by the window _helpwindow_. def self.pbDisplay(helpwindow,msg,brief) cw=helpwindow cw.letterbyletter=true cw.text=msg+"\1" pbBottomLeftLines(cw,2) oldvisible=cw.visible cw.visible=true loop do Graphics.update Input.update block_given? ? yield : cw.update if brief && !cw.busy? cw.visible=oldvisible return end if Input.trigger?(Input::C) && cw.resume && !cw.busy? cw.visible=oldvisible return end end end # Letter by letter display of the message _msg_ by the window _helpwindow_, # used to ask questions. Returns true if the user chose yes, false if no. def self.pbConfirm(helpwindow,msg) dw=helpwindow oldvisible=dw.visible dw.letterbyletter=true dw.text=msg dw.visible=true pbBottomLeftLines(dw,2) commands=[_INTL("Yes"),_INTL("No")] cw = Window_CommandPokemon.new(commands) cw.viewport=helpwindow.viewport pbBottomRight(cw) cw.y-=dw.height cw.index=0 loop do cw.visible=!dw.busy? Graphics.update Input.update cw.update block_given? ? yield : dw.update if Input.trigger?(Input::B) && dw.resume && !dw.busy? cw.dispose dw.visible=oldvisible pbPlayCancelSE() return false end if Input.trigger?(Input::C) && dw.resume && !dw.busy? cwIndex=cw.index cw.dispose dw.visible=oldvisible pbPlayDecisionSE() return (cwIndex==0)?true:false end end end def self.pbShowCommands(helpwindow,helptext,commands) ret=-1 oldvisible=helpwindow.visible helpwindow.visible=helptext ? true : false helpwindow.letterbyletter=false helpwindow.text=helptext ? helptext : "" cmdwindow=Window_CommandPokemon.new(commands) begin cmdwindow.viewport=helpwindow.viewport pbBottomRight(cmdwindow) helpwindow.resizeHeightToFit(helpwindow.text,480-cmdwindow.width) pbBottomLeft(helpwindow) loop do Graphics.update Input.update yield cmdwindow.update if Input.trigger?(Input::B) ret=-1 pbPlayCancelSE() break end if Input.trigger?(Input::C) ret=cmdwindow.index pbPlayDecisionSE() break end end ensure cmdwindow.dispose if cmdwindow end helpwindow.visible=oldvisible return ret end end
Spoiler:

Developing Pokemon Dark Platinum
Join Discord Server down here!!
https://discord.gg/4XDfTNm

CharizardThree3

Male
Avon region
Seen 13 Hours Ago
Posted 1 Week Ago
282 posts
2.1 Years
Next Update's gonna be tomorrow at this time. Removing animated Backgrounds for more smoothness and improved animations.( + new arrows)
If you don't want to remove animated Backgrounds, and have lag there will be some tweaks
Developing Pokemon Dark Platinum
Join Discord Server down here!!
https://discord.gg/4XDfTNm

bravestbat

Male
Faroe Islands
Seen 2 Days Ago
Posted May 10th, 2020
50 posts
199 Days
This is really great! Thank you!

rekman

Italy
Seen 4 Weeks Ago
Posted May 10th, 2020
44 posts
2.5 Years
Awesome graphic!
I encountered 2 errors that I resolved (easy things that can happen to anyone):
  • Syntax error: the comment section that starts with "=start" and ends with "=end" MUST be with zero indentation, or it wil return error. It can happen that with copy&paste the indentation gets wrong; (Line 453 and 514)
  • $mouse.leftClick?
    is undefined. Probably since it is connected with some scripting mouse utility that I don't have.
    Just substitute line 389 with
    if Input.trigger?(Input::LEFT) #|| $mouse.leftClick?(@sprites["switchL"])
    and line 421 with
    elsif Input.trigger?(Input::RIGHT) #|| $mouse.leftClick?(@sprites["switchR"])

Hope it helps :)
Pokemon Desiderium ~ DEMO COMING SOON

CharizardThree3

Male
Avon region
Seen 13 Hours Ago
Posted 1 Week Ago
282 posts
2.1 Years
Awesome graphic!
I encountered 2 errors that I resolved (easy things that can happen to anyone):
  • Syntax error: the comment section that starts with "=start" and ends with "=end" MUST be with zero indentation, or it wil return error. It can happen that with copy&paste the indentation gets wrong; (Line 453 and 514)
  • $mouse.leftClick?
    is undefined. Probably since it is connected with some scripting mouse utility that I don't have.
    Just substitute line 389 with
    if Input.trigger?(Input::LEFT) #|| $mouse.leftClick?(@sprites["switchL"])
    and line 421 with
    elsif Input.trigger?(Input::RIGHT) #|| $mouse.leftClick?(@sprites["switchR"])

Hope it helps :)
You shall use Luka's Easy Mouse System.
I used the old legacy methods to which I am comfortable with. You can hash out the mouse click stuff you don't want!
Thanks for pointing out those errors!
I will try updating the post, and removing the errors
Developing Pokemon Dark Platinum
Join Discord Server down here!!
https://discord.gg/4XDfTNm

CharizardThree3

Male
Avon region
Seen 13 Hours Ago
Posted 1 Week Ago
282 posts
2.1 Years
Just thought I'd let you know, there's a check in the code for a ZCube that shouldn't really be there, since not everyone has that item defined.
Damn! I forgot about it! It was from my project! I will be updating soon!
Developing Pokemon Dark Platinum
Join Discord Server down here!!
https://discord.gg/4XDfTNm

CharizardThree3

Male
Avon region
Seen 13 Hours Ago
Posted 1 Week Ago
282 posts
2.1 Years
Hi, i tried to put it in my game, but when i lunch the bag, i can't chose an item nor close the bag. I tried every key on my keyboard. I can change pouch, and i can move the cursor to select the item, but when i hit enter, nothing. Then i try to close the bag and i can't.
I will be fixing that tomorrow, the copying did it. Btw Which bag Script are you using, the one in the post maybe broken. Use the one in the attachment.
You replaced the Pscreen_Bag or pasted it above main? It replaced PScreen_Bag.
Developing Pokemon Dark Platinum
Join Discord Server down here!!
https://discord.gg/4XDfTNm

CharizardThree3

Male
Avon region
Seen 13 Hours Ago
Posted 1 Week Ago
282 posts
2.1 Years
I tried the attachment first, then the post and i replaced PScreen_Bag
There's a txt file in the attachment, try using that
Developing Pokemon Dark Platinum
Join Discord Server down here!!
https://discord.gg/4XDfTNm