[VXACE] How to make enemy window automatic sized?

Hello, could you help me please how to make enemy window automatic sized like Dragon Quest? So if there are 2 only enemy, the blank space can't show.

In my game, max enemy is 4. So, i hope the window only 1 column with 4 lines. Thank you!
Ruby:
class Window_BattleEnemy < Window_Selectable
  def initialize(info_viewport)
    super(200, 296, 344, item_max * 24 + 24)
    refresh 
    self.visible = false
  end
  def col_max
    return 1
  end
end
@Roninator2 i figure it out hehe. But, could you help me to make enemy battle window always show?

1651586048907.png


this is my custom from your script:
class Window_BattleEnemy < Window_Selectable
def initialize(info_viewport)
super(100, 296, 150, item_max * 24 + 24)
refresh
self.visible = false
end
def col_max
return 1
end
end
Ruby:
class Scene_Battle < Scene_Base
  def on_enemy_ok
    BattleManager.actor.input.target_index = @enemy_window.enemy.index
    @enemy_window.unselect
    @skill_window.hide
    @item_window.hide
    next_command
  end
  def on_enemy_cancel
    @enemy_window.unselect
    case @actor_command_window.current_symbol
    when :attack
      @actor_command_window.activate
    when :skill
      @skill_window.activate
    when :item
      @item_window.activate
    end
  end
  def create_enemy_window 
    @enemy_window = Window_BattleEnemy.new(@help_window) 
    @enemy_window.set_handler(:ok,     method(:on_enemy_ok)) 
    @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
  end 
  def start_party_command_selection
    @enemy_window.refresh
    @enemy_window.show
    unless scene_changing?   
    refresh_status   
    @DQ_status_window.open   
    if BattleManager.input_start     
      @actor_command_window.close     
      @party_command_window.setup   
    else     
      @party_command_window.deactivate     
      turn_start   
    end 
    end
  end
  def command_escape
    @enemy_window.hide
    turn_start unless BattleManager.process_escape
  end
  def turn_start 
    @party_command_window.close 
    @actor_command_window.close 
    @enemy_window.hide
    @subject =  nil 
    BattleManager.turn_start 
    if Jami_DQ_Battle::HUD_HIDE == true 
      @info_viewport.rect.height = 60 
    end #if HUDE_HIDE 
    @log_window.clear
  end
end

I'm surprised you haven't asked for the enemies to be grouped like DQ XI.
Which I have 80% working. It just shows lines for all enemies not the group. Haven't figured that out yet.
@Roninator2 it's working, thank you! But how to remove selected enemy before player start to select? And if i escape, the enemy window still not hide.

1651588663931.png
code above updated
@Roninator2 genius! thank you so much haha.

Edit: Sorry, i have trouble here. When enemy died (SlimeA), and then player start 2nd turn, the SlimeA's name can't be removed/still showing or enemy window not updated.

After i try to launch attack and select enemy, and then the enemy window update finally.

Edit2: it's work! Thank you so much!
removed/still showing or enemy window not updated.
Yes I just found that as well. Need one more line to refresh the window.
I'll update the code above in a sec

Original thread: https://forums.rpgmakerweb.com/threads/vxace-how-to-make-enemy-window-automatic-sized.147271/