I need a very specific HUD

I need something like this HUD that roughly I sketched together in MS Paint to show you how I imagine it.

Spoiler: Picture
ExampleHUD.png

On each map I want to show both the map name (on the right), and the battles won (left) by displaying it with variables. The whole thing should not be on a normal window, but on a semi-transparent black background just like the normal map name display in RM Vx Ace - with the difference that the display is permanent, unless it is deactivated via switch.

I track the fights with variables, but the special feature here is that there are different fights to win on each map. So while the counter on Map ID 1 is "1/5", it can be "2/3" on Map ID 2. So for each map I need a way to automatically display a variable for both won fights as well as for the total fights. I hope this makes sense for people reading this. :LZSjoy:

Lastly, I need the ability to display icons, both for the battles and for the map name.

Can someone help me set this up? :LZSsmile:
it might be possible to do this with yanfly's gab window script, but I don't remember enough of it to be sure.

it can create text widows like that above events, and you can simply have some events be permanently on those screen coordinates at through.
but that will need a lot of parallels and I don't know if that would create either lag (not enough waits) or jitter (too many waits)
I track the fights with variables, but the special feature here is that there are different fights to win on each map. So while the counter on Map ID 1 is "1/5", it can be "2/3" on Map ID 2. So for each map I need a way to automatically display a variable for both won fights as well as for the total fights. I hope this makes sense for people reading this. :LZSjoy:
I made it, but it's a little different that what you asked.
I missed the Won part.
I have it set so that it's like a fixed number of battles on the map and the counter goes up if you win.
Spoiler: Map Battle Hud 1.0
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Battle Victory HUD on Map    ║  Version: 1.02     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║  Show Number of Battles Won         ╠════════════════════╣
# ║  on the Current Map                 ║    17 Oct 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Allows to display Battles won on this map on screen      ║
# ║ Requested by Tw0Face                                     ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Adjust the settings to your preference                 ║
# ║   Use <no battle hud> in the map note for not show       ║
# ║   the window or just leave the data for the map blank    ║
# ║                                                          ║
# ║   Adjust the Data section for each map                   ║
# ║   Map_Data = { # instructions down below                 ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module R2_BATTLE_WON_HUD
  # Configure options
  Battle_Map_Var  = 5       # Variable used to track map battles
  Battle_Switch   = 5       # Switch used to increase battles value
  OFF_Switch      = 4       # turns off the display
  Count_Random    = 6       # switch to turn on if you wish to count 
                            # random battles as well as evented ones.
  
  Hud_X           = 0       # Hud X Position
  Hud_Y           = 0       # Hud Y Position
  Hud_Width       = Graphics.width     # Hud Width
  Hud_Height      = 48      # Hud Height
 
  Window_Opacity      = 0         # window visibility, does not affect contents
  Window_Back_Opacity = 0         # Window background opacity
  Window_Graphic      = "Window"  # Window Graphic file to use
  Use_Shadow_Back     = true      # changes to use a shaded background
  Shadow_Opacity      = 180       # set the darkness of the background
  
  Font          = "Arial"
  Font_Size     = 20
  
  Battle_Text = "Battles Won:"
  Text_Offset = 10
  
  module Data
    Map_Data = {
      # map id => [total battles, battle icon, map icon]
      1 => [5, 110, 120], # don't forget the comma
      2 => [2, 50, 75],
      4 => [15, 10, 25],
      }
  end
end
# ╔══════════════════════════════════════════════════════════╗
# ║ End of Configuration                                     ║
# ╚══════════════════════════════════════════════════════════╝

#--------------------------------------------------------------------------
# * Battle Won Hud Window
#--------------------------------------------------------------------------
class Battles_Won_Hud_Window < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    @hud_id = id
    x = R2_BATTLE_WON_HUD::Hud_X
    y = R2_BATTLE_WON_HUD::Hud_Y
    w = R2_BATTLE_WON_HUD::Hud_Width
    h = R2_BATTLE_WON_HUD::Hud_Height
    super(x,y,w,h)
    self.windowskin = Cache.system(R2_BATTLE_WON_HUD::Window_Graphic)
    self.opacity = R2_BATTLE_WON_HUD::Window_Opacity
    self.back_opacity = R2_BATTLE_WON_HUD::Window_Back_Opacity
    self.contents_opacity = 255
    @updated_battles = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Create Background Bitmap
  #--------------------------------------------------------------------------
  def create_back_battle_shade
    @shade_battle_bitmap = Bitmap.new(R2_BATTLE_WON_HUD::Hud_Width, R2_BATTLE_WON_HUD::Hud_Height)
    rect1 = Rect.new(0, 0, width, 12)
    rect2 = Rect.new(0, 12, width, height - 24)
    rect3 = Rect.new(0, height - 12, width, 12)
    @shade_battle_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @shade_battle_bitmap.fill_rect(rect2, back_color1)
    @shade_battle_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
    @shade_battle_sprite = Sprite.new
    @shade_battle_sprite.bitmap = @shade_battle_bitmap
    @shade_battle_sprite.z = z - 1
    @shade_battle_sprite.y = R2_BATTLE_WON_HUD::Hud_Y
    @shade_battle_sprite.x = R2_BATTLE_WON_HUD::Hud_X
  end
  #--------------------------------------------------------------------------
  # * Get Background Color 1
  #--------------------------------------------------------------------------
  def back_color1
    Color.new(0, 0, 0, R2_BATTLE_WON_HUD::Shadow_Opacity)
  end
  #--------------------------------------------------------------------------
  # * Get Background Color 2
  #--------------------------------------------------------------------------
  def back_color2
    Color.new(0, 0, 0, R2_BATTLE_WON_HUD::Shadow_Opacity)
  end
  #--------------------------------------------------------------------------
  # * Battle Data
  #--------------------------------------------------------------------------
  def battle_data
    data = R2_BATTLE_WON_HUD::Data::Map_Data[@hud_id]
    dispose_back_battle_bitmap if data.nil?
    return if data.nil?
    maxbat = data[0]
    bicon = data[1]
    micon = data[2]
    offset = R2_BATTLE_WON_HUD::Text_Offset
    map = load_data(sprintf("Data/Map%03d.rvdata2", @hud_id))
    mname = map.display_name
    x = R2_BATTLE_WON_HUD::Hud_X
    y = R2_BATTLE_WON_HUD::Hud_Y
    battles = $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id]
    text1 = R2_BATTLE_WON_HUD::Battle_Text
    draw_icon(bicon, x + 5, y, true)
    text = "#{text1} #{battles}/#{maxbat}"
    width = text.size * (contents.font.size / 2)
    draw_text(x + 40, y - offset, width, R2_BATTLE_WON_HUD::Hud_Height, text, 0)
    mwdth = mname.size * (contents.font.size / 2)
    x = R2_BATTLE_WON_HUD::Hud_Width - mwdth - 40
    x -= 10 if mwdth == 0
    draw_icon(micon, x, y, true)
    draw_text(x + 40, y - offset, mwdth, R2_BATTLE_WON_HUD::Hud_Height, mname, 0)
  end
  #--------------------------------------------------------------------------
  # * Dispose Background Bitmap
  #--------------------------------------------------------------------------
  def dispose
    super
    dispose_back_battle_bitmap
  end
  #--------------------------------------------------------------------------
  # * Free Background Bitmap
  #--------------------------------------------------------------------------
  def dispose_back_battle_bitmap
    @shade_battle_bitmap.dispose if @shade_battle_bitmap
    @shade_battle_sprite.dispose if @shade_battle_sprite
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    clear_data
    return if $game_switches[R2_BATTLE_WON_HUD::OFF_Switch] == true
    create_back_battle_shade if self.visible == true
    font = R2_BATTLE_WON_HUD::Font
    font_size = R2_BATTLE_WON_HUD::Font_Size
    self.contents.font = Font.new(font, font_size)
    battle_data
    @updated_battles = false
  end
  #--------------------------------------------------------------------------
  # * Hud Data Changed
  #--------------------------------------------------------------------------
  def hud_data_changed
    return true if @updated_battles == true
    return false
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias r2_hud_update_battle_hud    update
  def update
    refresh if hud_data_changed
    r2_hud_update_battle_hud
  end
  #--------------------------------------------------------------------------
  # * New Map ID
  #--------------------------------------------------------------------------
  def new_map_id(id)
    @hud_id = id
    @updated_battles = true
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] = 0 if $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id].nil?
  end
  #--------------------------------------------------------------------------
  # * Add Battles Won
  #--------------------------------------------------------------------------
  def add_battles_won
    @updated_battles = true
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var] = [] if $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var] == 0
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] = 0 if $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] == nil
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] += 1
  end
  #--------------------------------------------------------------------------
  # * Clear Data
  #--------------------------------------------------------------------------
  def clear_data
    self.contents.clear
    dispose_back_battle_bitmap
  end
  #--------------------------------------------------------------------------
  # * Visible?
  #--------------------------------------------------------------------------
  def visible?
    self.visible
  end
end

#--------------------------------------------------------------------------
# * BattleManager
#--------------------------------------------------------------------------
module BattleManager
  class << self
    alias battle_hud_victory_add  process_victory
    alias battle_hud_victory_encounter  on_encounter
    alias battle_hud_victory_init  init_members
  end
  #--------------------------------------------------------------------------
  # * Process Victory
  #--------------------------------------------------------------------------
  def self.process_victory
    battle_hud_victory_add
    return if ($game_switches[R2_BATTLE_WON_HUD::Count_Random] == false) && (@rand_enc) == true
    $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] = true
  end
  #--------------------------------------------------------------------------
  # * Initialize Members Data
  #--------------------------------------------------------------------------
  def self.init_members
    @rand_enc = false
    battle_hud_victory_init
  end
  #--------------------------------------------------------------------------
  # * On Encounter
  #--------------------------------------------------------------------------
  def self.on_encounter
    battle_hud_victory_encounter
    @rand_enc = true
  end
end

#--------------------------------------------------------------------------
# * Game Map
#--------------------------------------------------------------------------
class Game_Map
  def map
    @map
  end
end

#--------------------------------------------------------------------------
# * Scene Map
#--------------------------------------------------------------------------
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Start
  #--------------------------------------------------------------------------
  alias r2_battle_won_hud_start  start
  def start
    r2_battle_won_hud_start
    battle_hud
  end
  #--------------------------------------------------------------------------
  # * Battle Hud
  #--------------------------------------------------------------------------
  def battle_hud
    @battles_won_hud = Battles_Won_Hud_Window.new($game_map.map_id)
    check_battle_hud_visible
  end
  #--------------------------------------------------------------------------
  # * Battle Hud Visible
  #--------------------------------------------------------------------------
  def check_battle_hud_visible
    @battles_won_hud.visible = !$game_map.map.note.include?("<no battle hud>")
    @battles_won_hud.refresh
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias r2_map_update_battle_won_hud    update
  def update
    r2_map_update_battle_won_hud
    battle_won_hud_update if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
    @battles_won_hud.refresh if @battles_won_hud.visible?
  end
  #--------------------------------------------------------------------------
  # * Battle Won Hud Update
  #--------------------------------------------------------------------------
  def battle_won_hud_update
    @battles_won_hud.add_battles_won
    $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] = false if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
    return if @battles_won_hud.visible == false
    @battles_won_hud.refresh
  end
  #--------------------------------------------------------------------------
  # * Pre Processing for Transferring Player
  #--------------------------------------------------------------------------
  alias r2_battle_hud_visible_transfer_pre  pre_transfer
  def pre_transfer
    battle_won_hud_update if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
    @battles_won_hud.update
    r2_battle_hud_visible_transfer_pre
  end
  #--------------------------------------------------------------------------
  # * Post Processing for Transferring Player
  #--------------------------------------------------------------------------
  alias r2_battle_hud_visible_transfer_post  post_transfer
  def post_transfer
    check_battle_hud_visible
    @battles_won_hud.clear_data
    r2_battle_hud_visible_transfer_post
    @battles_won_hud.new_map_id($game_map.map_id)
    @battles_won_hud.update
  end
end
* updated
@Roninator2 Hi Ronny. Thank you; you're once again a hell of a lifesaver when it comes to coding. :LZSjoy:

As for the missing part: Per map there's a certain number of fixed fights that must be won by the player. Let's say 5 battles for Map 1 and 3 battles for Map 2. The total number of fights per map might or might not be different, means the HUD should show the total number of fights on each map and the number of fights won on that map, depending on which map you're currently on.
As for the missing part: Per map there's a certain number of fixed fights that must be won by the player. Let's say 5 battles for Map 1 and 3 battles for Map 2. The total number of fights per map might or might not be different, means the HUD should show the total number of fights on each map and the number of fights won on that map, depending on which map you're currently on.
Then I believe it is done.
give the script a try.
Then I believe it is done.
give the script a try.
I tested the script and didn't understand it at first. Then I realized I had to turn on Battle_Switch every time a battle is won. Doing so, the counter goes up by 1 and the switch is turned off automatically by the script - am I doing that right? Not quite sure about this but it seems to work perfectly that way. :LZSjoy: First attempt, I tried to increase Battle_Map_Var by 1 after a battle was won but this didn't affect the counter, so I guess it's the switch here doing the magic.

If I have completed all fights on a map, do I have the option to query this in a conditional branch? So if all the battles on a map are won I can run an event telling the player this area is cleared?
Then I realized I had to turn on Battle_Switch every time a battle is won. Doing so, the counter goes up by 1 and the switch is turned off automatically by the script - am I doing that right? Not quite sure about this but it seems to work perfectly that way.
Depends on how your battles are done. Is it on the map and you don't go to the normal battle screen?
I had a part in there so that if you used the normal battle screen it would turn the switch on after winning.
The BattleManager section

If I have completed all fights on a map, do I have the option to query this in a conditional branch? So if all the battles on a map are won I can run an event telling the player this area is cleared?
The number of battles won is held in the variable. It's made as an array.
If you know the map has 4 battles, and its map 12 then you can collect the value from the variable and do a conditional branch check.
$game_variables[xx] = $game_variables[script variable][map id]

This gets the proper value as the array starts at 0 and your map id is the location for the battles won.
[nil, 2, 6, nil, 8, 2, 5, nil, nil, 9, 10, 3, 4] -> 4 is index 12
@Roninator2

Still a bit confused, but I might get the hang of this soon after enough testing with the script.

I start my battles via Event. Like seen in the screen below. I noticed that, if I win, the counter does nothing by itself. So I set my Battle_Switch to ON. Doing this, it works fine.

Screen1.png

I didn't check random battles yet, but I might have some later. If the player wins, the counter shouldn't go up.

As for the conditional branch check, let's say my Battle_Map_Var is 5 like it is set as default in the script, for Map ID 1 I have to make a branch like...

$game_variables[5] = $game_variables[script variable][1]

...this, right?
I start my battles via Event. Like seen in the screen below. I noticed that, if I win, the counter does nothing by itself. So I set my Battle_Switch to ON. Doing this, it works fine.
There is one thing to change in the script. I'll mention it here and update it above.
Line 181 $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] = false if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
Move down to line 279 before the return if @battles_won_hud.visible == false

Then random battle will be counted as well. I could maybe add a condition that if is is a random then to ignore the switch. I'll try that and update the script. But I will add a condition in the module so that others that use the script can keep it if they want.
@Roninator2 I tried to add a functionality to set the OFF_Switch to true / false upon key press. What I want to have is the ability to basically toggle the HUD upon key press. I threw some code in but it basically does nothing. Can you help me check on what I'm missing out here?

Code:
#--------------------------------------------------------------------------
  # * Set HUD Visibility upon key press
  #--------------------------------------------------------------------------
  def press_key_to_toggle_switch
  if Input.trigger?(:L) && $game_switches[R2_BATTLE_WON_HUD::OFF_Switch] == true
    return $game_switches[R2_BATTLE_WON_HUD::OFF_Switch] = false
  else
    return $game_switches[R2_BATTLE_WON_HUD::OFF_Switch] = true
  end
  end

Also, is there a way to add some gradient in the HUD background just like Yanfly does in his Yanfly Event Window?

Spoiler: Screen
Unbenannt.png
Done. *updated
Spoiler: Battle Victory Hud on Map V1.04
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Battle Victory HUD on Map    ║  Version: 1.04     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║  Show Number of Battles Won         ╠════════════════════╣
# ║  on the Current Map                 ║    17 Oct 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Allows to display Battles won on this map on screen      ║
# ║ Requested by Tw0Face                                     ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║   Adjust the settings to your preference                 ║
# ║   Use <no battle hud> in the map note for not show       ║
# ║   the window or just leave the data for the map blank    ║
# ║                                                          ║
# ║   Adjust the Data section for each map                   ║
# ║   Map_Data = { # instructions down below                 ║
# ╚══════════════════════════════════════════════════════════╝
# ╔═════════════════════════════════════╗
# ║ Terms of use:                       ║
# ║ Free for all uses in RPG Maker      ║
# ╚═════════════════════════════════════╝

module R2_BATTLE_WON_HUD
  # Configure options
  Battle_Map_Var  = 5       # Variable used to track map battles
  Battle_Switch   = 5       # Switch used to increase battles value
  OFF_Switch      = 4       # turns off the display
  Count_Random    = 6       # switch to turn on if you wish to count
                            # random battles as well as evented ones.
 
  Hud_X           = 0       # Hud X Position
  Hud_Y           = 0       # Hud Y Position
  Hud_Width       = Graphics.width     # Hud Width
  Hud_Height      = 48      # Hud Height
 
  Window_Opacity      = 0         # window visibility, does not affect contents
  Window_Back_Opacity = 0         # Window background opacity
  Window_Graphic      = "Window"  # Window Graphic file to use
  Use_Shadow_Back     = true      # changes to use a shaded background
  Shadow_Opacity      = 180       # set the darkness of the background
  Shadow_Opacity1     = 80        # set the darkness of the background
  Shadow_Opacity2     = 250       # set the darkness of the background
 
  Shade_Type    = 1     # set the shade type for the background of the window
                        # 0 = three layers from inside to out.
                        # 1 = two layers from left to right
 
  Shade_Colours_Red = 0     # Set colour for Red in shade
  Shade_Colours_Green = 0   # Set colour for Green in shade
  Shade_Colours_Blue = 0    # Set colour for Blue in shade
 
  Font          = "Arial"
  Font_Size     = 20
 
  Battle_Text = "Battles Won:"
  Text_Offset = 10
 
  module Data
    Map_Data = {
      # map id => [total battles, battle icon, map icon]
      1 => [5, 110, 120], # don't forget the comma
      2 => [2, 50, 75],
      4 => [15, 10, 25],
      }
  end
end
# ╔══════════════════════════════════════════════════════════╗
# ║ End of Configuration                                     ║
# ╚══════════════════════════════════════════════════════════╝

#--------------------------------------------------------------------------
# * Battle Won Hud Window
#--------------------------------------------------------------------------
class Battles_Won_Hud_Window < Window_Base
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  def initialize(id)
    @hud_id = id
    x = R2_BATTLE_WON_HUD::Hud_X
    y = R2_BATTLE_WON_HUD::Hud_Y
    w = R2_BATTLE_WON_HUD::Hud_Width
    h = R2_BATTLE_WON_HUD::Hud_Height
    super(x,y,w,h)
    self.windowskin = Cache.system(R2_BATTLE_WON_HUD::Window_Graphic)
    self.opacity = R2_BATTLE_WON_HUD::Window_Opacity
    self.back_opacity = R2_BATTLE_WON_HUD::Window_Back_Opacity
    self.contents_opacity = 255
    @updated_battles = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Create Background Bitmap
  #--------------------------------------------------------------------------
  def create_back_battle_shade
    @shade_battle_bitmap = Bitmap.new(R2_BATTLE_WON_HUD::Hud_Width, R2_BATTLE_WON_HUD::Hud_Height)
    rect  = Rect.new(0, 0, width, height)
    rect1 = Rect.new(0, 0, width, 12)
    rect2 = Rect.new(0, 12, width, height - 24)
    rect3 = Rect.new(0, height - 12, width, 12)
    r = R2_BATTLE_WON_HUD::Shade_Colours_Red
    g = R2_BATTLE_WON_HUD::Shade_Colours_Green
    b = R2_BATTLE_WON_HUD::Shade_Colours_Blue
    if R2_BATTLE_WON_HUD::Shade_Type == 0
      @shade_battle_bitmap.gradient_fill_rect(rect1, back_colour2(r, g, b), back_colour1(r, g, b), true)
      @shade_battle_bitmap.fill_rect(rect2, back_colour3(r, g, b))
      @shade_battle_bitmap.gradient_fill_rect(rect3, back_colour1(r, g, b), back_colour2(r, g, b), true)
    else
      @shade_battle_bitmap.gradient_fill_rect(rect, back_colour1(r, g, b), back_colour2(r, g, b))
    end
    @shade_battle_sprite = Sprite.new
    @shade_battle_sprite.bitmap = @shade_battle_bitmap
    @shade_battle_sprite.z = z - 1
    @shade_battle_sprite.y = R2_BATTLE_WON_HUD::Hud_Y
    @shade_battle_sprite.x = R2_BATTLE_WON_HUD::Hud_X
  end
  #--------------------------------------------------------------------------
  # * Get Background Color 1
  #--------------------------------------------------------------------------
  def back_colour1(r, g, b)
    Color.new(r, g, b, R2_BATTLE_WON_HUD::Shadow_Opacity)
  end
  #--------------------------------------------------------------------------
  # * Get Background Color 2
  #--------------------------------------------------------------------------
  def back_colour2(r, g, b)
    Color.new(r, g, b, R2_BATTLE_WON_HUD::Shadow_Opacity1)
  end
  #--------------------------------------------------------------------------
  # * Get Background Color 3
  #--------------------------------------------------------------------------
  def back_colour3(r, g, b)
    Color.new(r, g, b, R2_BATTLE_WON_HUD::Shadow_Opacity2)
  end
  #--------------------------------------------------------------------------
  # * Battle Data
  #--------------------------------------------------------------------------
  def battle_data
    data = R2_BATTLE_WON_HUD::Data::Map_Data[@hud_id]
    dispose_back_battle_bitmap if data.nil?
    return if data.nil?
    maxbat = data[0]
    bicon = data[1]
    micon = data[2]
    offset = R2_BATTLE_WON_HUD::Text_Offset
    map = load_data(sprintf("Data/Map%03d.rvdata2", @hud_id))
    mname = map.display_name
    x = R2_BATTLE_WON_HUD::Hud_X
    y = R2_BATTLE_WON_HUD::Hud_Y
    battles = $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id]
    text1 = R2_BATTLE_WON_HUD::Battle_Text
    draw_icon(bicon, x + 5, y, true)
    text = "#{text1} #{battles}/#{maxbat}"
    width = text.size * (contents.font.size / 2)
    draw_text(x + 40, y - offset, width, R2_BATTLE_WON_HUD::Hud_Height, text, 0)
    mwdth = mname.size * (contents.font.size / 2)
    x = R2_BATTLE_WON_HUD::Hud_Width - mwdth - 40
    x -= 10 if mwdth == 0
    draw_icon(micon, x, y, true)
    draw_text(x + 40, y - offset, mwdth, R2_BATTLE_WON_HUD::Hud_Height, mname, 0)
  end
  #--------------------------------------------------------------------------
  # * Dispose Background Bitmap
  #--------------------------------------------------------------------------
  def dispose
    super
    dispose_back_battle_bitmap
  end
  #--------------------------------------------------------------------------
  # * Free Background Bitmap
  #--------------------------------------------------------------------------
  def dispose_back_battle_bitmap
    @shade_battle_bitmap.dispose if @shade_battle_bitmap
    @shade_battle_sprite.dispose if @shade_battle_sprite
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    clear_data
    return if $game_switches[R2_BATTLE_WON_HUD::OFF_Switch] == true
    create_back_battle_shade if self.visible == true
    font = R2_BATTLE_WON_HUD::Font
    font_size = R2_BATTLE_WON_HUD::Font_Size
    self.contents.font = Font.new(font, font_size)
    battle_data
    @updated_battles = false
  end
  #--------------------------------------------------------------------------
  # * Hud Data Changed
  #--------------------------------------------------------------------------
  def hud_data_changed
    return true if @updated_battles == true
    return false
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias r2_hud_update_battle_hud    update
  def update
    refresh if hud_data_changed
    r2_hud_update_battle_hud
  end
  #--------------------------------------------------------------------------
  # * New Map ID
  #--------------------------------------------------------------------------
  def new_map_id(id)
    @hud_id = id
    @updated_battles = true
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] = 0 if $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id].nil?
  end
  #--------------------------------------------------------------------------
  # * Add Battles Won
  #--------------------------------------------------------------------------
  def add_battles_won
    @updated_battles = true
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var] = [] if $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var] == 0
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] = 0 if $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] == nil
    $game_variables[R2_BATTLE_WON_HUD::Battle_Map_Var][@hud_id] += 1
  end
  #--------------------------------------------------------------------------
  # * Clear Data
  #--------------------------------------------------------------------------
  def clear_data
    self.contents.clear
    dispose_back_battle_bitmap
  end
  #--------------------------------------------------------------------------
  # * Visible?
  #--------------------------------------------------------------------------
  def visible?
    self.visible
  end
end

#--------------------------------------------------------------------------
# * BattleManager
#--------------------------------------------------------------------------
module BattleManager
  class << self
    alias battle_hud_victory_add  process_victory
    alias battle_hud_victory_encounter  on_encounter
    alias battle_hud_victory_init  init_members
  end
  #--------------------------------------------------------------------------
  # * Process Victory
  #--------------------------------------------------------------------------
  def self.process_victory
    battle_hud_victory_add
    return if ($game_switches[R2_BATTLE_WON_HUD::Count_Random] == false) && (@rand_enc) == true
    $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] = true
  end
  #--------------------------------------------------------------------------
  # * Initialize Members Data
  #--------------------------------------------------------------------------
  def self.init_members
    @rand_enc = false
    battle_hud_victory_init
  end
  #--------------------------------------------------------------------------
  # * On Encounter
  #--------------------------------------------------------------------------
  def self.on_encounter
    battle_hud_victory_encounter
    @rand_enc = true
  end
end

#--------------------------------------------------------------------------
# * Game Map
#--------------------------------------------------------------------------
class Game_Map
  def map
    @map
  end
end

#--------------------------------------------------------------------------
# * Scene Map
#--------------------------------------------------------------------------
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Start
  #--------------------------------------------------------------------------
  alias r2_battle_won_hud_start  start
  def start
    r2_battle_won_hud_start
    battle_hud
  end
  #--------------------------------------------------------------------------
  # * Battle Hud
  #--------------------------------------------------------------------------
  def battle_hud
    @battles_won_hud = Battles_Won_Hud_Window.new($game_map.map_id)
    check_battle_hud_visible
  end
  #--------------------------------------------------------------------------
  # * Battle Hud Visible
  #--------------------------------------------------------------------------
  def check_battle_hud_visible
    @battles_won_hud.visible = !$game_map.map.note.include?("<no battle hud>")
    @battles_won_hud.refresh
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias r2_map_update_battle_won_hud    update
  def update
    r2_map_update_battle_won_hud
    if Input.trigger?(:L)
      sw = R2_BATTLE_WON_HUD::OFF_Switch
      $game_switches[sw] = !$game_switches[sw]
    end
    battle_won_hud_update if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
    @battles_won_hud.refresh if @battles_won_hud.visible?
  end
  #--------------------------------------------------------------------------
  # * Battle Won Hud Update
  #--------------------------------------------------------------------------
  def battle_won_hud_update
    @battles_won_hud.add_battles_won
    $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] = false if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
    return if @battles_won_hud.visible == false
    @battles_won_hud.refresh
  end
  #--------------------------------------------------------------------------
  # * Pre Processing for Transferring Player
  #--------------------------------------------------------------------------
  alias r2_battle_hud_visible_transfer_pre  pre_transfer
  def pre_transfer
    battle_won_hud_update if $game_switches[R2_BATTLE_WON_HUD::Battle_Switch] == true
    @battles_won_hud.update
    r2_battle_hud_visible_transfer_pre
  end
  #--------------------------------------------------------------------------
  # * Post Processing for Transferring Player
  #--------------------------------------------------------------------------
  alias r2_battle_hud_visible_transfer_post  post_transfer
  def post_transfer
    check_battle_hud_visible
    @battles_won_hud.clear_data
    r2_battle_hud_visible_transfer_post
    @battles_won_hud.new_map_id($game_map.map_id)
    @battles_won_hud.update
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/i-need-a-very-specific-hud.152039/