# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Animated Message Log VXA
# Author: Soulpour777
# Credits / Original: Sui
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Description: Creates a message log of all present messages. They are stored
# and can be viewed anytime. Messages from Events, Battles, and Choices are
# shown through the press of a button.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Controls:
# Press Up and Down to Scroll Messages.
# Press Assigned Button to Open the Message Log
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Changes:
# I added two accessors for the game system for the row and choices for two
# different reasons, that being:
# - if the developer wants to change the max row anytime they like (in map).
# - if they want to save choices or no through the progress of the game.
# ----------------------------------------------------------------------------
# Add Ons and Features:
# - Message Log
# - Animated Background
# - Controlled Choice Saving
# - Controlled Max Rows for Message Log
# - Battle Log
# ----------------------------------------------------------------------------
# Script Calls:
#
# $game_system.change_choice_saving(false) - will not save choices.
# $game_system.change_choice_saving(true) - will save choices
#
# $game_system.change_message_rows(value)
# Place the value on the argument for the new max rows: for example:
#
# $game_system.change_message_rows(50)
# This will give me maximum of 50 rows. Note that the excess logs will be
# deleted to store the new ones.
# ----------------------------------------------------------------------------
#==============================================================================
# ** Soulpour777
#------------------------------------------------------------------------------
# This module carries the name of the scripter as well as the three important
# things for the whole script's functions, the switch, the button and the
# parallax background.
#==============================================================================
module Soulpour777
module Animated_Log
# Message Log Switch ID
Message_Log_Switch = 1
# Display MessageLog Button Key
Message_Log_Button_Mode = Input::L # Button Q on your Keyboard
Parallax_Name = "LogBG"
end
end
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Window Message
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
class Window_Message < Window_Base
#--------------------------------------------------------------------------
# * Process All Text
#--------------------------------------------------------------------------
alias soul_process_all_text process_all_text
def process_all_text
log = convert_escape_characters($game_message.all_text)
Soulpour777::Animated_Log.push(log)
soul_process_all_text
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
# ----------------------------------------------------------------------
# Initializes an attribute accessor so players can access max rows
# and choice saving anytime.
# ----------------------------------------------------------------------
attr_accessor :save_choices
attr_accessor :max_rows_for_message
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Alias Listings
# ----------------------------------------------------------------------
alias choice_initialize initialize
# ----------------------------------------------------------------------
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Initialize (aliased)
# This stores both choices and max rows that enables the developer to
# change it everytime he / she wants to.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def initialize
choice_initialize() # Call Original Method
@save_choices = true
@max_rows_for_message = 50
end
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Choice Saving
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def change_choice_saving(choice_save)
@save_choices = choice_save
end
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Message Rows
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
def change_message_rows(new_rows)
@max_rows_for_message = new_rows
end
end
#==============================================================================
# ** Window_ChoiceList
#------------------------------------------------------------------------------
# This window is used for the event command .
#==============================================================================
class Window_ChoiceList < Window_Command
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
alias soul_mcl make_command_list
def make_command_list
soul_mcl
return unless $game_system.save_choices
log = ""
$game_message.choices.each do |choice|
next if choice.empty?
log += " " + choice + "\n"
end
return if log.empty?
Soulpour777::Animated_Log.push(log)
end
end
module Soulpour777::Animated_Log
Animated_Log =
#--------------------------------------------------------------------------
# Push Text (Add)
#--------------------------------------------------------------------------
def self.push(text)
Animated_Log.push(text)
Animated_Log.shift if Animated_Log.size > $game_system.max_rows_for_message
end
end
#==============================================================================
# ** Window_MessageLog
#------------------------------------------------------------------------------
# This message window is used to display the messages.
#==============================================================================
class Window_MessageLog < Window_Base
#--------------------------------------------------------------------------
# Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, Graphics.width, Graphics.height)
self.z = 250
self.opacity = 0
self.active = false
self.openness = 0
self.padding *= 2
@index = 0
create_animated_bg
open
refresh
end
#--------------------------------------------------------------------------
# Dispose
#--------------------------------------------------------------------------
def dispose
super
@back.bitmap.dispose
@back.dispose
end
#--------------------------------------------------------------------------
# Update Parallax
#--------------------------------------------------------------------------
def update_anime
@back.ox += 2
end
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
def update
super
update_anime
return if @opening || @closing
dispose if close?
if !self.disposed? && self.open?
if Input::trigger?(:B)
Sound.play_cancel
close
elsif Input::repeat?(:UP)
self.index = @index - 1
elsif Input::repeat?(:DOWN)
self.index = @index + 1
elsif Input::repeat?(:LEFT)
self.index = @index - 5
elsif Input::repeat?(:RIGHT)
self.index = @index + 5
elsif Input::repeat?(:L)
self.index = @index - 15
elsif Input::repeat?(:R)
self.index = @index + 15
end
end
end
#--------------------------------------------------------------------------
# Row Max
#--------------------------------------------------------------------------
def page_row_max
contents_height / line_height
end
#--------------------------------------------------------------------------
# Index
#--------------------------------------------------------------------------
def index=(row)
@index = [.min, 0].max
self.oy = @index * line_height
end
#--------------------------------------------------------------------------
# Create Parallax
#--------------------------------------------------------------------------
def create_animated_bg
@back = Plane.new
@back.ox = 0
@back.oy = 0
@back.z = self.z - 1
@back.bitmap = Cache.system(Soulpour777::Animated_Log::Parallax_Name)
end
#--------------------------------------------------------------------------
# Push Text
#--------------------------------------------------------------------------
def push(text)
Soulpour777::Animated_Log::Animated_Log.push(text)
Soulpour777::Animated_Log::Animated_Log.shift if Soulpour777::Animated_Log::Animated_Log.size > $game_system.max_rows_for_message
end
#--------------------------------------------------------------------------
# Create Log Contents
#--------------------------------------------------------------------------
def create_log_contents(size)
self.contents.dispose
self.contents = Bitmap.new(width - padding * 2, .max)
end
#--------------------------------------------------------------------------
# ? Convert Special Characters
#--------------------------------------------------------------------------
def convert_special_characters(text)
text.gsub!(/\e.\/) { "" }
text.gsub!(/\e./) { "" }
text
end
#--------------------------------------------------------------------------
# Refresh
#--------------------------------------------------------------------------
def refresh
y = 0
texts =
for i in 0...Soulpour777::Animated_Log::Animated_Log.size
texts.push("") if i > 0
texts.concat(Soulpour777::Animated_Log::Animated_Log.split("\n"))
end
create_log_contents(texts.size)
for i in 0...texts.size
text = convert_special_characters(texts)
self.contents.draw_text(0, y, self.width - padding * 2, line_height, text)
y += line_height
end
@row_max = texts.size
self.index = texts.size
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias animated_message_log_upd update
def update
if @window_log
update_message_log
elsif Input.trigger?(Soulpour777::Animated_Log::Message_Log_Button_Mode)
@window_log = Window_MessageLog.new
update_message_log
else
animated_message_log_upd
end
end
#--------------------------------------------------------------------------
# Update Message Log
#--------------------------------------------------------------------------
def update_message_log
Graphics.update
Input.update
@window_log.update
@window_log = nil if @window_log.disposed?
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# Update
#--------------------------------------------------------------------------
alias animated_message_log_upd update
def update
if @window_log
update_message_log
elsif Input.trigger?(Soulpour777::Animated_Log::Message_Log_Button_Mode)
@window_log = Window_MessageLog.new
update_message_log
else
animated_message_log_upd
end
end
#--------------------------------------------------------------------------
# Update Message Log
#--------------------------------------------------------------------------
def update_message_log
Graphics.update
Input.update
@window_log.update
@window_log = nil if @window_log.disposed?
end
end