[ACE] Shana’s Map HUD-Need extra config

I’m using Adiktuzmiko’s script here: https://lescripts.wordpress.com/rgss3/map-hud/

I apologize for advance for coming off NEEDY but I have three additional things I need for the script. (Which I hope isn’t too much to ask for.)

It’s a script that shows an HUD on Map displaying the players’ current health. Problem is, I need it to show on the top right of the corner but my game is a 640x480. While the script only allows the hud to fit the default VX Ace screen. So the hud gets cut off.

The script only allows the hud to be turned off and on with a toggle script command. I was wondering if it was possible to have both an “off” and “on” command. It’ll be much more useful if I had it that way.

Lastly, I was wondering if there were a way to always hide the HUD while a text message is shown. And for it to reappear once text is gone. I know I could use the ‘toggle’ command but that’s just way too tedious. (But if there isn’t a way to include this, than it’s okay.)

Again, sorry for being needy. Thanks in advance!!!
See these?

Code:
   #X position of hp gauge
   X_HP = 24
   #Y position of hp gauge
   Y_HP = 9
   #X position of mp gauge
   X_MP = 24
   #Y position of mp gauge
   Y_MP = 34
  #X position of tp gauge
   X_TP = 24
   #Y position of tp gauge
   Y_TP = 60
  #X position of exp gauge
   X_XP = 22
   #Y position of xp gauge
   Y_XP = 416-16
  #X position of hp icon
   X_HP_ICON = 2
   #Y position of hp icon
   Y_HP_ICON = 1
   #X position of mp icon
   X_MP_ICON = 2
   #Y position of mp icon
   Y_MP_ICON = 26
  #X position of tp icon
   X_TP_ICON = 0
   #Y position of tp icon
   Y_TP_ICON = 0
  #X position of xp icon
   X_XP_ICON = 0
   #Y position of xp icon
   Y_XP_ICON = 0

Muck around with them until they're right.


Find this:

Code:
   def self.toggle
     @use_hud = !@use_hud
     if SceneManager.scene_is?(Scene_Map)
       if @use_hud
         self.update(true)
       else
         @sprite_b.bitmap.clear
       @sprite_bg.bitmap.clear
       end
     end
   end

Put this after it:
Code:
  def self.turn_on
    @use_hud = true
    if SceneManager.scene_is?(Scene_Map)
      self.update(true)
    end
  end

  def self.turn_off
    @use_hud = false
    if SceneManager.scene_is?(Scene_Map)
      @sprite_b.bitmap.clear
      @sprite_bg.bitmap.clear
    end
  end


Not sure about the message thing. Try the above first and see if those things work. If they do, give this a go ...
Find this:
Code:
   def self.update(forced=false)
     unless forced

Put some extra lines in between:
Code:
   def self.update(forced=false)
    @sprite_b.bitmap.visible = !$game_message.busy?
    @sprite_bg.bitmap.visible = !$game_message.busy?
     unless forced

I haven't tested this, so copy away the script somewhere before you make these changes, just in case it doesn't work.

If you get any errors, post back to say what they are.
Thanks! I was able to fix the X,Y Screen coordinates by replacing the numbers on line:266 and onwards.

The toggle on and off commands work perfectly.

The only thing that does not work is the off and on during the display of text messages. I get this message after inputting those two new lines:
Untitled.png
bump
Not sure why would you forcibly redraw all that thing when it's not necessary when turning the HUD on/off.
Spoiler
Code:
  def self.turn_on
    @use_hud = true
    if SceneManager.scene_is?(Scene_Map)
      @sprite_b.visible = @sprite_bg.visible = true
    end
  end

  def self.turn_off
    @use_hud = false
    if SceneManager.scene_is?(Scene_Map)
      @sprite_b.visible = @sprite_bg.visible = false
    end
  end
This should work too, and it won''t redraw anything, just changes the visibility flag of the HUD images.

You get that error because the method run there should be run on the sprites, not on their bitmaps.
Spoiler
Code:
@sprite_b.visible = @sprite_bg.visible = !$game_message.busy? && @use_hud
Try the above instead, it should work, although I haven't tested any of this.
Not sure why would you forcibly redraw all that thing when it's not necessary when turning the HUD on/off.
Spoiler
Code:
  def self.turn_on
    @use_hud = true
    if SceneManager.scene_is?(Scene_Map)
      @sprite_b.visible = @sprite_bg.visible = true
    end
  end

  def self.turn_off
    @use_hud = false
    if SceneManager.scene_is?(Scene_Map)
      @sprite_b.visible = @sprite_bg.visible = false
    end
  end
This should work too, and it won''t redraw anything, just changes the visibility flag of the HUD images.

You get that error because the method run there should be run on the sprites, not on their bitmaps.
Spoiler
Code:
@sprite_b.visible = @sprite_bg.visible = !$game_message.busy? && @use_hud
Try the above instead, it should work, although I haven't tested any of this.

Thanks so much! It worked!
@Sixth How dangerous is the reported memory leak?
Spoiler: leak
Code:
Time: 2019-03-14 10:07:09 -0400
Memory Leak #<Sprite_Base:0x113966b8>
In Scene Scene_Title
Creation Stack::
Script 0126 -- map hud, Line: 268:in `init'
Script 0126 -- map hud, Line: 533:in `start'
Script 0100 -- Scene_Base, Line: 12:in `main'
Script 0123 -- Mithran | Grap Obj Ref, Line: 246:in `main'
Script 0006 -- SceneManager, Line: 23:in `run'
Script 0130 -- Hime | Backtrace, Line: 9:in `block in <main>'
:1:in `block in rgss_main'
:1:in `loop'
:1:in `rgss_main'
Script 0130 -- Hime | Backtrace, Line: 7:in `<main>'
ruby:in `eval'
-----
Time: 2019-03-14 10:07:09 -0400
Memory Leak #<Sprite_Base:0x113964ec>
In Scene Scene_Title
Creation Stack::
Script 0126 -- map hud, Line: 271:in `init'
Script 0126 -- map hud, Line: 533:in `start'
Script 0100 -- Scene_Base, Line: 12:in `main'
Script 0123 -- Mithran | Grap Obj Ref, Line: 246:in `main'
Script 0006 -- SceneManager, Line: 23:in `run'
Script 0130 -- Hime | Backtrace, Line: 9:in `block in <main>'
:1:in `block in rgss_main'
:1:in `loop'
:1:in `rgss_main'
Script 0130 -- Hime | Backtrace, Line: 7:in `<main>'
ruby:in `eval'
It does not seem to cause any problems and does not increase in numbers or reduce fps.
I was able to make the reported leaks go away by putting the init into the scene map part and adding on sprite dispose to the def clear.
The only issue after that was the hud did not show up after exiting the menu.

*EDIT

I got it working.
no messages about memory leaks and works as expected.
Spoiler: self.toggle
Code:
    def self.toggle
      @use_hud = !@use_hud
      if SceneManager.scene_is?(Scene_Map)
        if @use_hud
          @use_hud = true
          @hud_on = true
          self.update(true)
        else
          @use_hud = false
          @hud_on = false
        end
      end
    end
Spoiler: turn on off
Code:
  def self.turn_on
    self.update
    @use_hud = true if @hud_on == true
  end

  def self.turn_off
    @use_hud = false if @hud_on == false
    self.clear
  end
Spoiler: self.clear
Code:
  def self.clear
    @sprite_b.bitmap.clear
    @sprite_bg.bitmap.clear
    @sprite_b.dispose
    @sprite_bg.dispose
  end
Spoiler: self.update
Code:
    def self.update(forced=false)
    self.init if @sprite_b.disposed?
    @sprite_b.visible = @sprite_bg.visible = !$game_message.busy? && @use_hud
      unless forced
Spoiler: scene map start
Code:
  alias start_adik_map_hud start
  def start
    start_adik_map_hud
    ADIK::MAP_HUD.init
    ADIK::MAP_HUD.update(true) if ADIK::MAP_HUD.use_hud
  end
Spoiler: scene map new method
Code:
  alias r2_update_call_menu_827f  update_call_menu
  def update_call_menu
    r2_update_call_menu_827f
    @use_hud = true if @hud_on == true
      ADIK::MAP_HUD.turn_on
  end
Deleting the scene title section

*DOUBLE EDIT

Forget all of this. Turns out the issue of the possible memory leak is still there, but now shows up when the map hud is not on and you enter the menu.

Original thread: https://forums.rpgmakerweb.com/threads/ace-shanas-map-hud-need-extra-config.106636/