#======================================================================
# ** Synopsis Journal
# Version: 1.0
# Author: VianoceGames
# Date: February 14, 2015
#----------------------------------------------------------------------
# Description:
#
# This script creates a menu option which tracks a quest(s) in
# progress and passed passed events relavent to the progression of the
# story. This script needs polishing.
#
#----------------------------------------------------------------------
# Instruction:
#
# For custom defualt settings see editable region to make desired
# changes.
#
# During the progression of the games story insert the following script
# calls in events to update the journal.
#
# change_synopsis_description_text( "Insert text here")
# change_synopsis_objective_text( "Insert text here")
# change_synopsis_background_image( "Insert file name here without
# file extension.")
#
# To add a custom background simply add the image to your pictures folder
# and use the script call shown above for the background image and input
# file name for your custom image. The image will be stretched or
# compressed to fit the screen. It is recommended that the custom image
# be scalable by 544x416 (The default screen dimentions of the game. If
# you use Yanfly you may have to re-evaluate the demenions of the scale
# accordingly when creating your custom image.
#
# By default this script uses the "Book" image from the title folder;
# imported to the pictures folder.
#
# Note: If you are injecting this script into a pre-exsisting project
# you must start a new game or you will have errors.
#
#======================================================================
module VianoceGames14
module SynopsisScene
#==================================================================
#
# ** Editable Region ////////////////////////////////////////////
#
#------------------------------------------------------------------
# Here you can edit options to give the scene a custom look.
#==================================================================
Description_Window_Opacity = 255 # Opacity for windows are
# 255: means fully visable
Objective_Window_Opacity = 255 # 0: means invisable
Header_Window_opacity = 255
Default_Background_Image = "" # If background image has an error
# use this default image.
#==================================================================
# End of editable region
#==================================================================
#==================================================================
# * New Method: Word Wrapping
#==================================================================
def self.word_wrapping(window, text)
# Current text position
current_text_position = 0
for i in 0..(text.length - 1)
if text[i] == "\n"
current_text_position = 0
next
end
# Current position += character(digit) width
current_text_position += window.text_size(text[i]).width
# If current position > window width
if current_text_position >= window.width - 32
# The paragraph format
current_element = i
while(text[current_element] != " ")
break if current_element == 0
current_element -= 1
end
temp_text = ""
for j in 0..(text.length - 1)
temp_text += text[j]
temp_text += "\n" if j == current_element
end
text = temp_text
i = current_element
current_text_position = 0
end
end
return text
end
end
end
class Scene_Synopsis < Scene_Base
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super()
#------------------------------------------------------------------------
# * Background Image
#------------------------------------------------------------------------
if $game_system.synopsis_background_image != "" && !! VianoceGames14::SynopsisScene::Default_Background_Image != ""
background_image = nil
if $game_system.synopsis_background_image != ""
background_image = $game_system.synopsis_background_image
else
background_image = VianoceGames14::SynopsisScene::Default_Background_Image != ""
end
@custom_sprite = Sprite.new()
@custom_sprite.bitmap = Cache.picture(background_image)
@custom_sprite.x = 0
@custom_sprite.y = 0
@custom_sprite.z = 0
@custom_sprite.zoom_x = Graphics.width.to_f / @custom_sprite.bitmap.width
@custom_sprite.zoom_y = Graphics.height.to_f / @custom_sprite.bitmap.height
@custom_sprite.opacity = 255
@custom_sprite.visible = true
end
#------------------------------------------------------------------------
# Windows
#------------------------------------------------------------------------
@window_synopsis_header = Window_Synopsis_Header.new()
@window_synopsis_description = Window_Synopsis_Description.new()
@window_synopsis_objective = Window_Synopsis_Objective.new()
@window_synopsis_description.opacity = VianoceGames14::SynopsisScene::Description_Window_Opacity
@window_synopsis_objective.opacity = VianoceGames14::SynopsisScene::Objective_Window_Opacity
@window_synopsis_header.opacity = VianoceGames14::SynopsisScene::Header_Window_opacity
end
#--------------------------------------------------------------------------
# * Post-Start Processing
#--------------------------------------------------------------------------
def post_start
super()
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super()
return_scene() if Input.trigger?(:B)
cancel_se() if Input.trigger?(:B)
end
end
def cancel_se
cancel_sound = "Cancel2"
RPG::SE.new(cancel_sound, 70, 100).play
end
#--------------------------------------------------------------------------
# * Pre-Termination Processing
#--------------------------------------------------------------------------
def pre_terminate
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super()
if @background_image
@custom_sprite.bitmap.dispose()
@custom_sprite.dispose()
end
@window_synopsis_objective.dispose()
@window_synopsis_description.dispose()
@window_synopsis_header.dispose()
end
#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================
class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * For Adding Original Commands
#--------------------------------------------------------------------------
alias vg14_custscene_winmencmmd_addorigcmmd_43trwe add_original_commands
#--------------------------------------------------------------------------
def add_original_commands
vg14_custscene_winmencmmd_addorigcmmd_43trwe() # Call original method
add_command("Journal", :synopsis_scene, true)
end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
alias vg14_custscene_scenemenu_createcmmdwindow_43trwe create_command_window
#--------------------------------------------------------------------------
def create_command_window
vg14_custscene_scenemenu_createcmmdwindow_43trwe() # Call original method
@command_window.set_handler(:synopsis_scene, method(:command_scenesynopsis))
end
def command_scenesynopsis
SceneManager.call(Scene_Synopsis)
end
end
#==============================================================================
# ** Window_Despription.
#------------------------------------------------------------------------------
# This message window is used to display text for the quest Desription.
#==============================================================================
class Window_Synopsis_Description < Window_Base
def initialize()
super(0, (Graphics.height * 0.13), Graphics.width, (Graphics.height * 0.57))
draw_description()
end
def draw_description()
text = VianoceGames14::SynopsisScene::word_wrapping(self, $game_system.synopsis_description_text)
draw_text_ex(0, 0, text)
end
end
#==============================================================================
# ** Window_Objective
#------------------------------------------------------------------------------
# This message window is used to display text
#==============================================================================
class Window_Synopsis_Objective < Window_Base
def initialize()
super(0, (Graphics.height * 0.7), Graphics.width, (Graphics.height * 0.3))
draw_objective()
end
def draw_objective()
text = VianoceGames14::SynopsisScene::word_wrapping(self, $game_system.synopsis_objective_text)
draw_text_ex(0, 0, text)
end
end
#==============================================================================
# ** Window_Header
#------------------------------------------------------------------------------
# This message window is used to display text
#==============================================================================
class Window_Synopsis_Header < Window_Base
def initialize()
super(0, 0, Graphics.width, (Graphics.height * 0.13))
draw_image()
end
def draw_image()
text = VianoceGames14::SynopsisScene::word_wrapping(self, $game_system.synopsis_header_text)
draw_text_ex(0, 0, 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
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :synopsis_header_text
attr_accessor :synopsis_description_text
attr_accessor :synopsis_objective_text
attr_accessor :synopsis_background_image
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias vg14_gamesystem_synopsis_initialize_43eds initialize
#--------------------------------------------------------------------------
def initialize
@synopsis_description_text = "Progress: \nNothion has happened yet." # Default story synopsis
@synopsis_objective_text = "Objective(s): \nNo current Objectives." # Default objectives
@synopsis_header_text = "Header section (quest titles & or story chapter)" # Default chapter title
@synopsis_background_image = "Book" # comments -> # Default background image
vg14_gamesystem_synopsis_initialize_43eds() # Call original method
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
def change_synopsis_description_text( text )
return unless text.is_a?(String)
$game_system.synopsis_description_text = text
end
def change_synopsis_objective_text( text )
return unless text.is_a?(String)
$game_system.synopsis_objective_text = text
end
def change_synopsis_background_image( text )
return unless text.is_a?(String)
$game_system.synopsis_background_image = text
end
def change_synopsis_header_text( text )
return unless text.is_a?(String)
$game_system.synopsis_header_text = text
end
end