Change Popup Window v1.2d to Dim Background

Can someone help me having this script popup appear in dim background? Currently, the text pops up in the normal message box style but I want to have the semi-transparent black color scheme for consistency (just like the map name display).

Spoiler: Here's the script
Ruby:
#Popup Window v1.2d
#----------#
#Features: Create a popup window for anything you want! How magical!
#
#Usage:    Script calls:
#           (In Events:)
#           pop_up(['text','text', ... ], timer(opt), x(opt), y(opt))
#           (Anywhere else:)
#           Popup.add(['text','text', ... ], timer(opt), x(opt), y(opt))
#
#          Examples:
#           pop_up(['\i[5] Mage class unlocked!!'])
#           pop_up(['\c[16] Class Change:\c[0]',
#                   ' Speak to any mysterious hermit to change class!'],240)
#
#   Escape codes not working? You have two options... switch to '' singe quotes
#    instead of "" double quotes, or double up on \\ slashes.
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
$imported = {} if $imported.nil?
$imported[:Vlue_PopupWindow] = true
 
POPUP_DURATION = 180
 
class Popup_Window < Window_Base
  def initialize(text,timer,x,y)
    super(0,0,25,100)
    text.each do |string|
      temp_string = string.gsub(/\\[^invpgINVPG]\[\d{0,3}\]/) { "" }
      temp_string = temp_string.gsub(/\\i\[\d{0,3}\]/) { icon_width }
      temp_string = convert_escape_characters(temp_string)
      self.width = [text_size(temp_string).width+standard_padding*2+12,self.width].max
    end
    self.height = text.size * line_height + line_height
    if x.nil?
      self.x = Graphics.width / 2 - self.width / 2
    else
      self.x = x
    end
    if y.nil?
      self.y = Graphics.height / 2 - self.height / 2
    else
      self.y = y
    end
    @text = text
    @timer = timer
    create_contents
    refresh
    self.openness = 0
    open
  end
  def icon_width
    size = text_size(' ').width
    ' ' * (24 / size)
  end
  def refresh
    contents.clear
    yy = 0
    @text.each do |string|
      draw_text_ex(0,yy,string)
      yy += line_height
    end
  end
  def update
    super
    @timer -= 1
    close if @timer == 0
  end
end
 
module Popup
  def self.init
    @queue = []
  end
  def self.add(text, timer = POPUP_DURATION, x = nil, y = nil)
    @queue.push([text,timer,x,y])
  end
  def self.queue
    @queue
  end
end 
 
Popup.init
 
class Scene_Base
  alias popupwin_preterminate pre_terminate
  alias popupwin_update update
  def update
    popupwin_update
    update_popup_window_text unless $popup.nil?
    return if Popup.queue.empty?
    if $popup.nil? or $popup.close?
      text = Popup.queue.pop
      $popup = Popup_Window.new(text[0], text[1], text[2], text[3])
    end
  end
  def update_popup_window_text
    $popup.update
    $popup.close if Input.trigger?(:C)
    if !$popup.disposed? and $popup.close?
      $popup.dispose
      $popup = nil
    end
  end
  def pre_terminate
    popupwin_preterminate
    $popup.visible = false unless $popup.nil?
  end
end
 
class Game_Interpreter
  alias popup_command_355 command_355
  def pop_up(text, timer = POPUP_DURATION, x = nil, y = nil)
    Popup.add(text, timer, x, y)
  end
  def command_355
    popup_command_355
    wait_for_popup #if SceneManager.scene.is_a?(Scene_Map)
  end
  def wait_for_popup
    Fiber.yield while !Popup.queue.empty? || $popup
  end
end

I know I have to work with this functions:

Ruby:
def back_color1
    Color.new(0, 0, 0, 255)
  end


  def back_color2
    Color.new(0, 0, 0, 0)
  end

And then make something like that:

Ruby:
@back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
@back_bitmap.fill_rect(rect2, back_color1)
@back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)

But I have no clue where to add this and how.
You can include those methods inside the Popup_Window class. Then you can call both of them right underneath the contents.clear command.
You can include those methods inside the Popup_Window class. Then you can call both of them right underneath the contents.clear command.
I tried it. But when I do so, the game shuts down saying "rect1" is not defined. Then I copied this over from Window_Base, like...

Ruby:
rect1 = Rect.new(0, 0, width, 12)
rect2 = Rect.new(0, 12, width, height - 24)
rect3 = Rect.new(0, height - 12, width, 12)

... but then the game shuts down saying "width" is not defined. Then I tried to copy over the part where "width" is defined, like...

Ruby:
def window_width
    Graphics.width
  end

Then the game shuts down saying "width" is a undefined local variable or method.

Seems like I'm doing it wrong.
Weird. width and height are predefined by that custom class so you should not get any issue at all.

Can you post the whole script + your edits here? Either as a whole unit or your complete add-on script if you're not modifying the original directly.
Weird. width and height are predefined by that custom class so you should not get any issue at all.

Can you post the whole script + your edits here? Either as a whole unit or your complete add-on script if you're not modifying the original directly.
Here's my try. The whole script without my edits is in the OP.

Spoiler: Script Edit
Ruby:
#Popup Window v1.2d
#----------#
#Features: Create a popup window for anything you want! How magical!
#
#Usage:    Script calls:
#           (In Events:)
#           pop_up(['text','text', ... ], timer(opt), x(opt), y(opt))
#           (Anywhere else:)
#           Popup.add(['text','text', ... ], timer(opt), x(opt), y(opt))
#
#          Examples:
#           pop_up(['\i[5] Mage class unlocked!!'])
#           pop_up(['\c[16] Class Change:\c[0]',
#                   ' Speak to any mysterious hermit to change class!'],240)
#
#   Escape codes not working? You have two options... switch to '' singe quotes
#    instead of "" double quotes, or double up on \\ slashes.
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
$imported = {} if $imported.nil?
$imported[:Vlue_PopupWindow] = true
 
POPUP_DURATION = 180
 
class Popup_Window < Window_Base
   def window_width
    Graphics.width
  end
  rect1 = Rect.new(0, 0, width, 12)
    rect2 = Rect.new(0, 12, width, height - 24)
    rect3 = Rect.new(0, height - 12, width, 12)
  def back_color1
    Color.new(0, 0, 0, 255)
  end


  def back_color2
    Color.new(0, 0, 0, 0)
  end
 
  def initialize(text,timer,x,y)
    super(0,0,25,100)
    text.each do |string|
      temp_string = string.gsub(/\\[^invpgINVPG]\[\d{0,3}\]/) { "" }
      temp_string = temp_string.gsub(/\\i\[\d{0,3}\]/) { icon_width }
      temp_string = convert_escape_characters(temp_string)
      self.width = [text_size(temp_string).width+standard_padding*2+12,self.width].max
    end
    self.height = text.size * line_height + line_height
    if x.nil?
      self.x = Graphics.width / 2 - self.width / 2
    else
      self.x = x
    end
    if y.nil?
      self.y = Graphics.height / 2 - self.height / 2
    else
      self.y = y
    end
    @text = text
    @timer = timer
    create_contents
    refresh
    self.openness = 0
    open
  end
  def icon_width
    size = text_size(' ').width
    ' ' * (24 / size)
  end
  def refresh
    contents.clear
    
    @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(rect2, back_color1)
    @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
    
    yy = 0
    @text.each do |string|
      draw_text_ex(0,yy,string)
      yy += line_height
    end
  end
  def update
    super
    @timer -= 1
    close if @timer == 0
  end
end
 
module Popup
  def self.init
    @queue = []
  end
  def self.add(text, timer = POPUP_DURATION, x = nil, y = nil)
    @queue.push([text,timer,x,y])
  end
  def self.queue
    @queue
  end
end 
 
Popup.init
 
class Scene_Base
  alias popupwin_preterminate pre_terminate
  alias popupwin_update update
  def update
    popupwin_update
    update_popup_window_text unless $popup.nil?
    return if Popup.queue.empty?
    if $popup.nil? or $popup.close?
      text = Popup.queue.pop
      $popup = Popup_Window.new(text[0], text[1], text[2], text[3])
    end
  end
  def update_popup_window_text
    $popup.update
    $popup.close if Input.trigger?(:C)
    if !$popup.disposed? and $popup.close?
      $popup.dispose
      $popup = nil
    end
  end
  def pre_terminate
    popupwin_preterminate
    $popup.visible = false unless $popup.nil?
  end
end
 
class Game_Interpreter
  alias popup_command_355 command_355
  def pop_up(text, timer = POPUP_DURATION, x = nil, y = nil)
    Popup.add(text, timer, x, y)
  end
  def command_355
    popup_command_355
    wait_for_popup #if SceneManager.scene.is_a?(Scene_Map)
  end
  def wait_for_popup
    Fiber.yield while !Popup.queue.empty? || $popup
  end
end
Well, I guess it might work now.

EDIT 1

Ruby:
#Popup Window v1.2d
#----------#
#Features: Create a popup window for anything you want! How magical!
#
#Usage:    Script calls:
#           (In Events:)
#           pop_up(['text','text', ... ], timer(opt), x(opt), y(opt))
#           (Anywhere else:)
#           Popup.add(['text','text', ... ], timer(opt), x(opt), y(opt))
#
#          Examples:
#           pop_up(['\i[5] Mage class unlocked!!'])
#           pop_up(['\c[16] Class Change:\c[0]',
#                   ' Speak to any mysterious hermit to change class!'],240)
#
#   Escape codes not working? You have two options... switch to '' singe quotes
#    instead of "" double quotes, or double up on \\ slashes.
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
$imported = {} if $imported.nil?
$imported[:Vlue_PopupWindow] = true
 
POPUP_DURATION = 180
 
class Popup_Window < Window_Base
   def window_width
    Graphics.width
  end

  def back_color1
    Color.new(0, 0, 0, 255)
  end

  def back_color2
    Color.new(0, 0, 0, 0)
  end
 
  def initialize(text,timer,x,y)
    super(0,0,25,100)
    text.each do |string|
      temp_string = string.gsub(/\\[^invpgINVPG]\[\d{0,3}\]/) { "" }
      temp_string = temp_string.gsub(/\\i\[\d{0,3}\]/) { icon_width }
      temp_string = convert_escape_characters(temp_string)
      self.width = [text_size(temp_string).width+standard_padding*2+12,self.width].max
    end
    self.height = text.size * line_height + line_height
    if x.nil?
      self.x = Graphics.width / 2 - self.width / 2
    else
      self.x = x
    end
    if y.nil?
      self.y = Graphics.height / 2 - self.height / 2
    else
      self.y = y
    end
  
    @rect1 = Rect.new(0, 0, width, 12)
    @rect2 = Rect.new(0, 12, width, height - 24)
    @rect3 = Rect.new(0, height - 12, width, 12)
  
    @text = text
    @timer = timer
    create_contents
    refresh
    self.openness = 0
    open
  end

  def icon_width
    size = text_size(' ').width
    ' ' * (24 / size)
  end

  def refresh
    contents.clear
  
    @back_bitmap.gradient_fill_rect(@rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(@rect2, back_color1)
    @back_bitmap.gradient_fill_rect(@rect3, back_color1, back_color2, true)
  
    yy = 0
    @text.each do |string|
      draw_text_ex(0,yy,string)
      yy += line_height
    end
  end

  def update
    super
    @timer -= 1
    close if @timer == 0
  end
end
 
module Popup
  def self.init
    @queue = []
  end

  def self.add(text, timer = POPUP_DURATION, x = nil, y = nil)
    @queue.push([text,timer,x,y])
  end

  def self.queue
    @queue
  end
  init
end

class Scene_Base
  alias popupwin_preterminate pre_terminate
  alias popupwin_update update
  def update
    popupwin_update
    update_popup_window_text unless $popup.nil?
    return if Popup.queue.empty?
    if $popup.nil? or $popup.close?
      text = Popup.queue.pop
      $popup = Popup_Window.new(text[0], text[1], text[2], text[3])
    end
  end

  def update_popup_window_text
    $popup.update
    $popup.close if Input.trigger?(:C)
    if !$popup.disposed? and $popup.close?
      $popup.dispose
      $popup = nil
    end
  end

  def pre_terminate
    popupwin_preterminate
    $popup.visible = false unless $popup.nil?
  end
end
 
class Game_Interpreter
  alias popup_command_355 command_355
  def pop_up(text, timer = POPUP_DURATION, x = nil, y = nil)
    Popup.add(text, timer, x, y)
  end

  def command_355
    popup_command_355
    wait_for_popup #if SceneManager.scene.is_a?(Scene_Map)
  end

  def wait_for_popup
    Fiber.yield while !Popup.queue.empty? || $popup
  end
end
Well, I guess it might work now.
Unfortunately, it crashes saying gradient_fill_rect is not defined.
Unfortunately, it crashes saying gradient_fill_rect is not defined.
Try this version
Ruby:
#Popup Window v1.2e
#----------#
#Features: Create a popup window for anything you want! How magical!
#
#Usage:    Script calls:
#           (In Events:)
#           pop_up(['text','text', ... ], timer(opt), x(opt), y(opt))
#           (Anywhere else:)
#           Popup.add(['text','text', ... ], timer(opt), x(opt), y(opt))
#
#          Examples:
#           pop_up(['\i[5] Mage class unlocked!!'])
#           pop_up(['\c[16] Class Change:\c[0]',
#                   ' Speak to any mysterious hermit to change class!'],240)
#
#   Escape codes not working? You have two options... switch to '' singe quotes
#    instead of "" double quotes, or double up on \\ slashes.
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
$imported = {} if $imported.nil?
$imported[:Vlue_PopupWindow] = true
 
POPUP_DURATION = 180
 
class Popup_Window < Window_Base
  def initialize(text,timer,x,y)
    super(0,0,25,100)
    text.each do |string|
      temp_string = string.gsub(/\\[^invpgINVPG]\[\d{0,3}\]/) { "" }
      temp_string = temp_string.gsub(/\\i\[\d{0,3}\]/) { icon_width }
      temp_string = convert_escape_characters(temp_string)
      self.width = [text_size(temp_string).width+standard_padding*2+12,self.width].max
    end
    self.opacity = 0
    self.back_opacity = 0
    self.height = text.size * line_height + line_height
    if x.nil?
      self.x = Graphics.width / 2 - self.width / 2
    else
      self.x = x
    end
    if y.nil?
      self.y = Graphics.height / 2 - self.height / 2
    else
      self.y = y
    end
    @text = text
    @timer = timer
    create_contents
    refresh
    self.openness = 0
    open
    create_back_bitmap
    create_back_sprite
  end
  def dispose
    dispose_back_bitmap
    dispose_back_sprite
    super
  end
  def create_back_bitmap
    @back_bitmap = Bitmap.new(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)
    @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(rect2, back_color1)
    @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  end
  def back_color1
    Color.new(0, 0, 0, 200)
  end
  def back_color2
    Color.new(0, 0, 0, 100)
  end
  def create_back_sprite
    @back_sprite = Sprite.new
    @back_sprite.bitmap = @back_bitmap
    @back_sprite.z = z - 1
    @back_sprite.x = self.x
    @back_sprite.y = self.y
  end
  def dispose_back_bitmap
    @back_bitmap.dispose
  end
  def dispose_back_sprite
    @back_sprite.dispose
  end
  def icon_width
    size = text_size(' ').width
    ' ' * (24 / size)
  end
  def refresh
    contents.clear
    yy = 0
    @text.each do |string|
      draw_text_ex(0,yy,string)
      yy += line_height
    end
  end
  def update
    super
    @timer -= 1
    close if @timer == 0
  end
end
 
module Popup
  def self.init
    @queue = []
  end
  def self.add(text, timer = POPUP_DURATION, x = nil, y = nil)
    @queue.push([text,timer,x,y])
  end
  def self.queue
    @queue
  end
end 
 
Popup.init
 
class Scene_Base
  alias popupwin_preterminate pre_terminate
  alias popupwin_update update
  def update
    popupwin_update
    update_popup_window_text unless $popup.nil?
    return if Popup.queue.empty?
    if $popup.nil? or $popup.close?
      text = Popup.queue.pop
      $popup = Popup_Window.new(text[0], text[1], text[2], text[3])
    end
  end
  def update_popup_window_text
    if $popup.disposed?
      $popup = nil
      return
    end
    $popup.update
    $popup.close if Input.trigger?(:C)
    if !$popup.disposed? and $popup.close?
      $popup.dispose
      $popup = nil
    end
  end
  def pre_terminate
    popupwin_preterminate
    return if $popup.nil?
    $popup.visible = false unless $popup.nil? || $popup.disposed?
  end
end
 
class Game_Interpreter
  alias popup_command_355 command_355
  def pop_up(text, timer = POPUP_DURATION, x = nil, y = nil)
    Popup.add(text, timer, x, y)
  end
  def command_355
    popup_command_355
    wait_for_popup #if SceneManager.scene.is_a?(Scene_Map)
  end
  def wait_for_popup
    Fiber.yield while !Popup.queue.empty? || $popup
  end
end
I don't think there's a need for creating new @instance variables here.
Since the contents will be recreated every single time they get refreshed, we can call contents' methods instead of using @back_bitmap or @back_sprite there.

Ruby:
#Popup Window v1.2d
#----------#
#Features: Create a popup window for anything you want! How magical!
#
#Usage:    Script calls:
#           (In Events:)
#           pop_up(['text','text', ... ], timer(opt), x(opt), y(opt))
#           (Anywhere else:)
#           Popup.add(['text','text', ... ], timer(opt), x(opt), y(opt))
#
#          Examples:
#           pop_up(['\i[5] Mage class unlocked!!'])
#           pop_up(['\c[16] Class Change:\c[0]',
#                   ' Speak to any mysterious hermit to change class!'],240)
#
#   Escape codes not working? You have two options... switch to '' singe quotes
#    instead of "" double quotes, or double up on \\ slashes.
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: [email hidden]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#- Free to use in any project with credit given, donations always welcome!
 
$imported = {} if $imported.nil?
$imported[:Vlue_PopupWindow] = true
 
POPUP_DURATION = 180
 
class Popup_Window < Window_Base
   def window_width
    Graphics.width
  end

  def back_color1
    Color.new(0, 0, 0, 255)
  end

  def back_color2
    Color.new(0, 0, 0, 0)
  end
 
  def initialize(text,timer,x,y)
    super(0,0,25,100)
    text.each do |string|
      temp_string = string.gsub(/\\[^invpgINVPG]\[\d{0,3}\]/) { "" }
      temp_string = temp_string.gsub(/\\i\[\d{0,3}\]/) { icon_width }
      temp_string = convert_escape_characters(temp_string)
      self.width = [text_size(temp_string).width+standard_padding*2+12,self.width].max
    end
    self.height = text.size * line_height + line_height
    if x.nil?
      self.x = Graphics.width / 2 - self.width / 2
    else
      self.x = x
    end
    if y.nil?
      self.y = Graphics.height / 2 - self.height / 2
    else
      self.y = y
    end
    
    @rect1 = Rect.new(0, 0, width, 12)
    @rect2 = Rect.new(0, 12, width, height - 24)
    @rect3 = Rect.new(0, height - 12, width, 12)
    
    @text = text
    @timer = timer
    create_contents
    refresh
    self.openness = 0
    open
  end

  def icon_width
    size = text_size(' ').width
    ' ' * (24 / size)
  end

  def refresh
    contents.clear
    
    contents.gradient_fill_rect(@rect1, back_color2, back_color1, true)
    contents.fill_rect(@rect2, back_color1)
    contents.gradient_fill_rect(@rect3, back_color1, back_color2, true)
    
    yy = 0
    @text.each do |string|
      draw_text_ex(0,yy,string)
      yy += line_height
    end
  end

  def update
    super
    @timer -= 1
    close if @timer == 0
  end
end
 
module Popup
  def self.init
    @queue = []
  end

  def self.add(text, timer = POPUP_DURATION, x = nil, y = nil)
    @queue.push([text,timer,x,y])
  end

  def self.queue
    @queue
  end
  init
end

class Scene_Base
  alias popupwin_preterminate pre_terminate
  alias popupwin_update update
  def update
    popupwin_update
    update_popup_window_text unless $popup.nil?
    return if Popup.queue.empty?
    if $popup.nil? or $popup.close?
      text = Popup.queue.pop
      $popup = Popup_Window.new(text[0], text[1], text[2], text[3])
    end
  end

  def update_popup_window_text
    $popup.update
    $popup.close if Input.trigger?(:C)
    if !$popup.disposed? and $popup.close?
      $popup.dispose
      $popup = nil
    end
  end

  def pre_terminate
    popupwin_preterminate
    $popup.visible = false unless $popup.nil?
  end
end
 
class Game_Interpreter
  alias popup_command_355 command_355
  def pop_up(text, timer = POPUP_DURATION, x = nil, y = nil)
    Popup.add(text, timer, x, y)
  end

  def command_355
    popup_command_355
    wait_for_popup #if SceneManager.scene.is_a?(Scene_Map)
  end

  def wait_for_popup
    Fiber.yield while !Popup.queue.empty? || $popup
  end
end
Now it's a mix of dim background and message box. While the inside of the popup is black, the borders are from the normal message box.

Also I noticed, while the popup is active and you hit F12, there's a disposed error throwing.
If you find any alias in the code, add a white space and unless $@ at the end of the line. That prevent it from doing weird things after a reset. I could add it later on.

So it got mixed... I'll check that out.
@kyonides okay, then I will wait. Thanks, my bro.
Actually, I got fed up with how that script works so I crafted a new one. This script is based on Window_Mapname class, meaning that it will behave in the same way. Of course, it won't show up after a map transfer for obvious reasons.

The only caveat is that it doesn't parse the text to display an icon on the window.
On the other hand, it allows you to pass either a single line of text or an Array of lines as its first parameter.

By the way, it already includes the F12 bug fix for all of the aliased methods found in my script.

For Any Future Updates Click HERE.​

Ruby:
# * AlertWindow ACE * #
#   Scripter : Kyonides Arkanthes
#   2023-10-24

# - Add a new Alert
#   Pass 1 Line
# pop_up(text)
# Alert.add(text)

#   Pass 2+ Lines
# texts = ["Line1", "Line2"]
# pop_up(texts)
# Alert.add(texts)

#   Pass 2+ Parameters - Text(s) is the only mandatory argument!
# pop_up(text, frames, align, x, y)
# Alert.add(text, frames, align, x, y)

module Alert
  DURATION = 60
  extend self
  attr_accessor :show
  @data = []
  def add(texts, timer=DURATION, align=0, ax=0, ay=0)
    texts = [texts] unless texts.respond_to?(:compact)
    @data << [texts, timer, align, ax, ay]
    @show = true
  end

  def popup
    @data.shift
  end

  def empty?
    @data.empty?
  end

  def refresh
    @show = @data.any?
  end
end

class Game_Interpreter
  alias :kyon_alert_gm_int_comm355 :command_355 unless $@
  def command_355
    kyon_alert_gm_int_comm355
    Fiber.yield until Alert.empty?
  end

  def pop_up(*args)
    Alert.add(*args)
  end
end

class AlertWindow < Window_Base
  def initialize
    super(0, 0, window_width, fitting_height(4))
    self.opacity = 0
    self.contents_opacity = 0
    @show_count = 0
  end

  def window_width
    Graphics.width
  end

  def update
    super
    if Alert.show and @show_count == 0
      open
    elsif @show_count > 0
      update_fadein
      @show_count -= 1
    else
      update_fadeout
    end
  end

  def update_fadein
    self.contents_opacity += 16
  end

  def update_fadeout
    self.contents_opacity -= 16
  end

  def open
    refresh
    self.contents_opacity = 0
    self
  end

  def close
    @show_count = 0
    self
  end

  def refresh
    contents.clear
    texts, @show_count, align, ax, ay = Alert.popup
    Alert.refresh
    self.x = ax
    self.y = ay
    draw_background(contents.rect, texts.size)
    lx = 8
    text_width = contents.rect.width - lx * 2
    lh = line_height
    texts.each_with_index do |text, n|
      draw_text(lx, lh * n, text_width, lh, text, align)
    end
  end

  def draw_background(rect, lines)
    temp_rect = rect.dup
    temp_rect.height = lines * line_height
    temp_rect.width /= 2
    contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
    temp_rect.x = temp_rect.width
    contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  end

  def back_color1
    Color.new(0, 0, 0, 192)
  end

  def back_color2
    Color.new(0, 0, 0, 0)
  end
end

class Scene_Map
  alias :kyon_alert_win_scn_map_crt_mess_win :create_message_window unless $@
  alias :kyon_alert_win_scn_map_pre_transfer :pre_transfer unless $@
  def create_message_window
    kyon_alert_win_scn_map_crt_mess_win
    @alert_window = AlertWindow.new
  end

  def pre_transfer
    @alert_window.close
    kyon_alert_win_scn_map_pre_transfer
  end
end
Now it's a mix of dim background and message box. While the inside of the popup is black, the borders are from the normal message box.
That's solved with the addition of the opacity settings found in my version.
Also I noticed, while the popup is active and you hit F12, there's a disposed error throwing.
That is in the default script as well.
Why people enjoy restarting the game and hoping it doesn't crash I'll never know.
What's wrong with shutting down and starting again?
Actually, I got fed up with how that script works so I crafted a new one. This script is based on Window_Mapname class, meaning that it will behave in the same way. Of course, it won't show up after a map transfer for obvious reasons.

The only caveat is that it doesn't parse the text to display an icon on the window.
On the other hand, it allows you to pass either a single line of text or an Array of lines as its first parameter.
Thank you, @kyonides, I will kindly switch to your script and I will use it in multiple games then, however, I need the ability to use icons, variables and color codes inside the script and more I need the feature to not have the window disappear automatically, but with a button press instead. I would be really thankful if you can add those. :LZSjoy:

That is in the default script as well.
Why people enjoy restarting the game and hoping it doesn't crash I'll never know.
What's wrong with shutting down and starting again?
It's a glitch anyway. See, there's no way I can blame my players if my game crashes due to them pressing F12 at the wrong moment. :LZScheeze: It's a bug anyway, so I better have it fixed.
It's a bug anyway, so I better have it fixed.
There are a few scripts that prevent pressing F12. Have you tried those?
There are a few scripts that prevent pressing F12. Have you tried those?
I don't want to prevent my players from using the F12 reset at all. I just want the game to not crash while using this RPG Maker standard functionality. Appearently, Vlue's script has a memory leak there and I couldn't seem to fix it. I think disposed window error shows up both when a window is either not disposed or is already disposed?
I don't want to prevent my players from using the F12 reset at all.
That invite problems in my opinion. But if it's a critical feature then carry on.

Using what Kyonides said $@ I made a few changes and the memory leak is gone from this script
Script updated above.
Using what Kyonides said $@ I made a few changes and the memory leak is gone from this script
Script updated above.
Nah, I still get the disposed window error when refreshing as long as the pop-up is active. Even in your new version of the script.
I still get the disposed window error when refreshing as long as the pop-up is active.
Did you copy my updated script or get Kyonides's one?
I can display the popup and press F12 and it doesn't crash.
I get a bunch of memory leaks because I pressed F12 with Mithran GOBJ script added, but the only thing that comes up for this script is ### blah blah is already disposed!
Can you screenshot the error?

Original thread: https://forums.rpgmakerweb.com/threads/change-popup-window-v1-2d-to-dim-background.162311/