FANDOM


Simple HUD Fixed
This tutorial is deprecated. It is no longer relevant to the latest version of Pokémon Essentials.

This tutorial was written by SunakazeKun. Please give credit.

Click here for more tutorials!


This was originally created by -FL-, but I decided to fix some lines and add small features to it, like disabling the displayed text. To make this script work, put it above Main.

#===============================================================================
# * Simple HUD - by FL, fixed by SunakazeKun (Credits will be apreciated)
#===============================================================================
#
# This script is for Pokémon Essentials. It displays a simple HUD with the
# party icons and some small text.
#
# To manually refresh the HUD use the line '$hud_need_refresh = true'
#
#===============================================================================
# * Settings
#===============================================================================
  BGPATH="Graphics/Pictures/HUDBar"
# Put the image path between the two ". I recommend a 512x64 picture.

  USEBAR=false
# Make as 'true' to show a coded blue bar. Make sure to remove "BGPATH".

  DRAWATBOTTOM=false
# Make as 'true' to draw the HUD at bottom.

  UPDATESPERSECONDS=1.00
# More updates = more lag. 

  HUDTEXT=true
# Make as 'false' to disable the HUD text.
#===============================================================================
# * Main
#===============================================================================
class Spriteset_Map
  
  alias :initializeOldFL :initialize
  alias :disposeOldFL :dispose
  alias :updateOldFL :update
  
  def initialize(map=nil)
    @hud = []
    initializeOldFL(map)
    $hud_need_refresh = true 
  end
    
  def dispose
    disposeOldFL
    disposeHud
  end
  
  def update
    updateOldFL
    updateHud
  end

#===============================================================================
# * HUD Data
#===============================================================================

  def createHud
    return if !$Trainer # Don't draw the hud if the player wasn't defined
    yposition = DRAWATBOTTOM ? Graphics.height-64 : 0
    @hud = []
#===============================================================================
# * Coded Blue Bar
#===============================================================================
    if USEBAR
      bar=IconSprite.new(0,yposition,@viewport1)
      bar.bitmap=Bitmap.new(Graphics.width,64)
      bar.bitmap.fill_rect(Rect.new(0,0,bar.bitmap.width,bar.bitmap.height), 
          Color.new(128,128,192))  
      @hud.push(bar)
    end
#===============================================================================
# * Image
#===============================================================================
    if BGPATH != "" # Make sure that there is nothing between the two ".
      bgbar=IconSprite.new(0,yposition,@viewport1)
      bgbar.setBitmap(BGPATH)
      @hud.push(bgbar)
    end
#===============================================================================
# * Text
#===============================================================================
    if HUDTEXT
    baseColor=Color.new(72,72,72)
    shadowColor=Color.new(160,160,160)
    @hud.push(BitmapSprite.new(Graphics.width,Graphics.height,@viewport1))
    text1=_INTL("{1}",$Trainer.name)
    text2=_INTL("${1}",$Trainer.money)
    textPosition=[
      [text1,Graphics.width-64,yposition,2,baseColor,shadowColor],
      [text2,Graphics.width-64,yposition+32,2,baseColor,shadowColor]
    ]
    pbSetSystemFont(@hud[-1].bitmap)
    pbDrawTextPositions(@hud[-1].bitmap,textPosition)
    end
#===============================================================================
# * Pokémon Icons
#===============================================================================
    for i in 0...$Trainer.party.size
      pokeicon=IconSprite.new(16+64*i,yposition-0,@viewport1)
      pokeicon.setBitmap(pbPokemonIconFile($Trainer.party[i]))
      pokeicon.src_rect=Rect.new(0,0,64,64)
      @hud.push(pokeicon)
    end
    for sprite in @hud
      sprite.z+=600 
    end
  end
  
#===============================================================================
  
  def updateHud
    for sprite in @hud
      sprite.update
    end
  end 
  
  def disposeHud
    for sprite in @hud
      sprite.dispose
    end
    @hud.clear
  end
end

#===============================================================================

class Scene_Map
  alias :updateOldFL :update
  alias :miniupdateOldFL :miniupdate
  alias :createSpritesetsOldFL :createSpritesets
  
  UPDATERATE = (Spriteset_Map::UPDATESPERSECONDS>0) ? 
      (Graphics.frame_rate/Spriteset_Map::UPDATESPERSECONDS).floor : 0x3FFF 
    
  def update
    updateOldFL
    checkAndUpdateHud
  end
  
  def miniupdate
    miniupdateOldFL
    checkAndUpdateHud
  end
  
  def createSpritesets
    createSpritesetsOldFL
    checkAndUpdateHud
  end  
  
  def checkAndUpdateHud
    $hud_need_refresh = (Graphics.frame_count%UPDATERATE==0 ||
      $hud_need_refresh)
    if $hud_need_refresh
      for s in @spritesets.values
        s.disposeHud
        s.createHud
      end
      $hud_need_refresh = false
    end
  end
end

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.