CODE
#------------------------------------------------------------------------------
# * Munkis' Message pop-up V 1.1
# * Made by munkis
# ╔══════════╗
# ║ FEATURES ║
# ╚══════════╝
# * Makes a pop-up message window appear without blocking player movement.
# Script configuration is handled a little differently; I made all
# changeable values into required arguments for the script call. This way
# you can dynamically change the window, in case you want different looking
# windows for different events.
# * You can call this script with:
#
# ╔═════════════════════════════════════════════════════════════════════════╗
# ║ $scene.show_message("text", window_x, window_y, window_width, ║
# ║ window_height, icon, manual_disable_switch, display_time, "font", size, ║
# ║ bold, italic, shadow, align, color, "sound", opacity) ║
# ╚═════════════════════════════════════════════════════════════════════════╝
#
# "text": The text to be displayed.
# window_x: The X-coordinate of the window.
# window_y: The Y-coordinate of the window.
# window_width: The wdth of the window.
# window_height: The height of the window.
# icon: The ID of the icon to be displayed.
# manual_disable_switch: In-game switch used to manually disable the
# message. Does not disable the button press.
# display_time: How long (in frames) to keep the window visible.
# "font": The name of the font to use for the message.
# size: The size of the text in the message.
# bold: Wether or not to make the text bold. TRUE/FALSE
# italic: Wether or not to make the text italic. TRUE/FALSE
# shadow: Wether or not to let the text have shadows. TRUE/FALSE
# align: Alignment of text. 0 = LEFT 1 = CENTER 2 = RIGHT
# color: Window text color to be used. Color.new(Red,Green,Blue,Alpha). 0-255
# "sound": The name of the SE to be played when the window pops up. Use nil
# for no SE.
# opacity: The opacity of the window displayed. 0-255
#
# All you really need to use though is $scene.show_message("text"), the rest
# of the settings have default values. You also have the ability to hide the
# window with Input::X or an in-game switch (directions above).
#
# * V 1.0: Initial release
# * V 1.1: Fixed a couple of text alignment bugs.
#------------------------------------------------------------------------------
class Pop_Up_Main < Window_Base
def initialize
super(0,((Graphics.height/2)-32),Graphics.width,64)
self.visible = false
end
def show_message(text, window_x = 0, window_y=((Graphics.height/2)-32), window_width = Graphics.width, window_height = 64, icon=0, manual_disable_switch=0, display_time=240, font=Font.default_name, size=Font.default_size, bold=Font.default_bold, italic=Font.default_italic, shadow=Font.default_shadow, align=0, color=Font.default_color, sound=nil, opacity=255)
@text = text
@display_time = display_time
@icon = icon
@font = font
@size = size
@bold = bold
@italic = italic
@shadow = shadow
@align = align
@color = color
if window_width > Graphics.width - window_x
@window_width = Graphics.width - window_x
else
@window_width = window_width
end
@manual_disable_switch = manual_disable_switch
Audio.se_play("audio/se/"+sound,100,100) unless sound.nil?
self.opacity = opacity
self.visible = true
self.x = window_x
self.y = window_y
if window_width > Graphics.width - window_x
self.width = Graphics.width - window_x
else
self.width = window_width
end
if window_height > Graphics.height - window_y
self.height = Graphics.height - window_y
else
self.height = window_height
end
create_contents
refresh
end
def refresh
self.contents.clear
self.contents.font.name = @font
self.contents.font.size = @size
self.contents.font.bold = @bold
self.contents.font.italic = @italic
self.contents.font.shadow = @shadow
self.contents.font.color = @color
x = 0
if @icon != 0
draw_icon (@icon, x, 0)
x += @window_width-55
draw_icon (@icon, x, 0)
x = 24
end
if @align == 1
if @icon == 0
self.contents.draw_text(x-15, 0, @window_width, WLH, @text, @align)
else
self.contents.draw_text(x-39, 0, @window_width, WLH, @text, @align)
end
elsif @align == 2
if @icon == 0
self.contents.draw_text(x-31, 0, @window_width, WLH, @text, @align)
else
self.contents.draw_text(x-79, 0, @window_width, WLH, @text, @align)
end
else
self.contents.draw_text(x, 0, @window_width, WLH, @text, @align)
end
return
end
def update
return unless self.visible
@display_time -= 1
if Input.trigger?(Input::X) or $game_switches[@manual_disable_switch] == true
@display_time = 0
$game_switches[@manual_disable_switch] = false
end
self.visible = (@display_time > 0)
end
end
class Scene_Map < Scene_Base
alias munkis_message_start start
alias munkis_message_update update
alias munkis_message_terminate terminate
def start
munkis_message_start
@popupmain = Pop_Up_Main.new
end
def show_message(*args)
@popupmain.show_message(*args)
end
def update
munkis_message_update
@popupmain.update
end
def terminate
munkis_message_terminate
@popupmain.dispose
return
end
end