Jaber's Super-Simple Message System - Jaberwocky - 04-25-2011
Jaber's Super-Simple Message System
by Jaberwocky
v1.11
Apr 25 2011
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
This is an add-on to the default message system that does two things:
1. Allows for more control over the positioning and display of message windows
2. Allows for the display of a face/name in a side window
You just stick it above main and you're done:
>
Code:
# Jaber's Super-Simple Message System v1.11
class Message_Data
def get_data
return [@pos, @face, @face_pos, @name, @name_pos]
end
end
class Game_System
attr_accessor :message_settings
alias jaber_init initialize unless method_defined?(:jaber_init)
def initialize
jaber_init
$message = nil
end
end
class Scene_Save < Scene_File
alias jaber_write_save write_save_data unless method_defined?(:jaber_write_save)
def write_save_data(file)
$game_system.message_settings = $message
jaber_write_save(file)
end
end
class Window_Message < Window_Selectable
alias jaber_init initialize unless method_defined?(:jaber_init)
def initialize
jaber_init
@face_window = Window_Face.new
if $message == nil
if $game_system.message_settings != nil
$message = $game_system.message_settings
else
$message = Message_Data.new
end
end
end
alias jaber_dispose dispose unless method_defined?(:jaber_dispose)
def dispose
@face_window.dispose
jaber_dispose
end
def reset_window
pos = $game_temp.in_battle ? $message.battle_pos : $message.pos
off = $game_temp.in_battle ? $message.battle_offset : $message.offset
self.x = 0 if [1,4,7].include?(pos)
self.x = 80 if [2,5,8].include?(pos)
self.x = 160 if [3,6,9].include?(pos)
self.y = 0 + off if [7,8,9].include?(pos)
self.y = 160 if [4,5,6].include?(pos)
self.y = 320 - off if [1,2,3].include?(pos)
self.x += pos == 4 ? off : pos == 6 ? -off : 0
self.back_opacity = $message.back_opacity
self.opacity = $message.opacity
@face_window.opacity = self.opacity
@face_window.back_opacity = self.back_opacity
case $message.face_pos
when 1
@face_window.x = self.x
@face_window.y = self.y + self.height
when 2
@face_window.x = (self.x + (self.width / 2)) - (@face_window.width / 2)
@face_window.y = self.y + self.height
when 3
@face_window.x = (self.x + self.width) - @face_window.width
@face_window.y = self.y + self.height
when 4
@face_window.x = self.x - @face_window.width
@face_window.y = self.y
when 5 # derp
@face_window.x = self.x + (self.width / 2) - (@face_window.width / 2)
@face_window.y = self.y
when 6
@face_window.x = self.x + self.width
@face_window.y = self.y
when 7
@face_window.x = self.x
@face_window.y = self.y - @face_window.height
when 8
@face_window.x = (self.x + (self.width / 2)) - (@face_window.width / 2)
@face_window.y = self.y - @face_window.height
when 9
@face_window.x = (self.x + self.width) - @face_window.width
@face_window.y = self.y - @face_window.height
end
@face_window.update_name
if $message.name == nil and $message.face == nil
@face_window.visible = false
else
@face_window.visible = true
end
if @face_window.need_update
@face_window.contents_opacity = 0 if @face_window.face != $message.face or @face_window.face == nil
@face_window.update_face
end
end
alias jaber_update update unless method_defined?(:jaber_update)
def update
@face_window.opacity = self.opacity
@face_window.back_opacity = self.back_opacity
@face_window.contents_opacity += 24 if @face_window.contents_opacity < 255
@face_window.visible = false if $game_temp.message_text == nil and @face_window.showing
@face_window.update
jaber_update
end
end
class Window_Face < Window_Base # Hey, that rhymes! Sort of!
The 'Change Text Options' event command will no longer have any effect on message windows, but that's okay because it won't be needed anymore.
The features are controlled from a script call by making changes to the new $message variables:
>
$message.small_name = X
This will toggle the use of the smaller name box when a face is not being displayed. X is true/false.
$message.pos = X
$message.battle_pos = X
$message.face_pos = X
$message.name_pos = X
These will change the location of the message window out of and during battle, the side of the message box that the face window is displayed on, and where the name text will be displayed in the face window, respectively. X is 1-9, where the location corresponds to that number's location on the numberpad, i.e. 1 = lower left, 5 = center, 8 = top, etc.
If a small name box is being used, name_pos determines the vertical alignment of the box(if face_pos is 4/5/6) and the alignment of the text inside(i.e. 1/4/7 = left justification, 2/5/8 = centered, 3/6/9 = right)
$message.offset = X
$message.battle_offset = X
$message.face_offset = X
This will modify the distance of the message box from the edge of the screen, and how high/low the face picture will be displayed in the face window.
$message.face = "X"
This will display an image from the pictures folder in the face window, where X is the name of the image in quotation marks. Set it to nil to stop displaying the image.
$message.name = "X"
This will write some text to the face window, where X is the text to be written, again in quotation marks. Set it to nil to stop displaying the text. If both $message.face and $message.text are set to nil, the face window will not be displayed.
$message.opacity = X
This will change the opacity of both the message window and face window. X is 0-255.
$message.back_opacity = X
This will change the opacity of the back of both the message window and face window. It won't display at a higher opacity than the $message.opacity is set to, though.
Changelog
v1.11
-Fixed issue with displaying the same name/face twice in a row
v1.1
-Added small name window
-Improved face window display transitions
-Fixed a bug wherein the face window would be cleared instead of hidden