Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Synopsis Scene
- # Version 1.0
- # Author: You
- # Date: 13th March, 2013
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # Description:
- #
- # This Script allows you to maintain a database signifying what your
- # current objective is, as well as provided a brief summary of recent
- # events.
- #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #--------------------------------------------------------------------------
- # Instructions:
- #
- # - Head into the editable region and modify things as appropriate.
- #
- # - To change Description Text during game, use the following in a
- # script call:
- # change_synopsis_description_text("Text")
- # Replacing "Text" with the text you wish to have in your description.
- #
- # - To change Objective Text during game, use the following in a
- # script call:
- # change_synopsis_objective_text("Text")
- # Replacing "Text" with the text you wish to have in your description.
- #
- # - To change Background_Image during game, use the following in a
- # script call:
- # change_synopsis_backgroundimage("Filename")
- # Picture must be located in your pictures folder.
- #
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- module DiamondandPlatinum3
- module SynopsisScene
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # #
- # EDITABLE REGION /////// #
- # #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Description_Window_Opacity = 255 # Opacity for Objective Window,
- # 255 means fully visible,
- # 0 means fully transparent
- Objective_Window_Opacity = 255 # Objective Window Opacity, same as above
- Default_Background_Image = "" # If Backgroud Image has an error, use
- # this default image.
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # #
- # END 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 width
- current_text_position += window.text_size(text[i]).width
- # If Current Position > Window Width
- if current_text_position >= window.width - 32
- # Then Format the Sentence to fit Line
- 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()
- if $game_system.synopsis_background_image != "" || DiamondandPlatinum3::SynopsisScene::Default_Background_Image != ""
- # Background Image ------------------
- background_image = nil
- if $game_system.synopsis_background_image != ""
- background_image = $game_system.synopsis_background_image
- else
- background_image = DiamondandPlatinum3::SynopsisScene::Default_Background_Image
- end
- @background_image = Sprite.new()
- @background_image.bitmap = Cache.picture(background_image)
- @background_image.x = 0
- @background_image.y = 0
- @background_image.zoom_x = Graphics.width.to_f / @background_image.bitmap.width
- @background_image.zoom_y = Graphics.height.to_f / @background_image.bitmap.height
- #-------------------------------------
- end
- @window_synopsis_description = Window_Sypnopsis_Description.new()
- @window_synopsis_objective = Window_Sypnopsis_Objective.new()
- @window_synopsis_description.x = -400
- @window_synopsis_objective.x = 400
- @window_synopsis_description.opacity = DiamondandPlatinum3::SynopsisScene::Description_Window_Opacity
- @window_synopsis_objective.opacity = DiamondandPlatinum3::SynopsisScene::Objective_Window_Opacity
- end
- #--------------------------------------------------------------------------
- # * Post-Start Processing
- #--------------------------------------------------------------------------
- def post_start
- super()
- while(@window_synopsis_description.x < 0)
- @window_synopsis_description.x += 5
- @window_synopsis_objective.x -= 5
- Graphics.update()
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super()
- return_scene() if Input.trigger?(:B)
- @window_synopsis_description.update()
- end
- #--------------------------------------------------------------------------
- # * Pre-Termination Processing
- #--------------------------------------------------------------------------
- def pre_terminate
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super()
- if @background_image
- @background_image.bitmap.dispose()
- @background_image.dispose()
- end
- @window_synopsis_description.dispose()
- @window_synopsis_objective.dispose()
- end
- end
- #==============================================================================
- # ** Window_MenuCommand
- #------------------------------------------------------------------------------
- # This command window appears on the menu screen.
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # * For Adding Original Commands
- #--------------------------------------------------------------------------
- alias dp3_custscene_windowmenucommand_addorigcomnd_023fj add_original_commands
- #--------------------------------------------------------------------------
- def add_original_commands
- dp3_custscene_windowmenucommand_addorigcomnd_023fj() # Call Original Method
- add_command("Custom Scene", :synosis_scene, true)
- end
- end
- #==============================================================================
- # ** Window_Message
- #------------------------------------------------------------------------------
- # This message window is used to display text.
- #==============================================================================
- class Window_Sypnopsis_Description < Window_ScrollText
- def initialize()
- super()#(0, 0, Graphics.width, (Graphics.height * 0.7))
- self.height = (Graphics.height * 0.7)
- self.opacity = 255
- show()
- draw_description()
- @scroll_pos = 0
- @page = 1
- end
- def draw_description()
- text = DiamondandPlatinum3::SynopsisScene::word_wrapping(self, $game_system.synopsis_description_text)
- draw_text_ex(0, 0, text)
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super()
- page = @page
- @page -= 1 if Input.trigger?(:LEFT) && @page > 1
- @page += 1 if Input.trigger?(:RIGHT)
- @scroll_pos -= 1 if Input.press?(:UP)
- @scroll_pos += 1 if Input.press?(:DOWN)
- self.oy = @scroll_pos
- if @page != page
- create_contents # Remove all text in window & resize contents bitmap
- @scroll_pos = 0 # ScrollPos back to default
- # Draw Page number if not main page
- draw_text_ex(0, 0, "Page #{@page.to_s}") if @page != 1
- # Draw Description if main Page
- draw_description() if @page == 1
- end
- end
- def contents_height
- return Graphics.width - 32 #~ complete size of all text ~#
- end
- end
- #==============================================================================
- # ** Window_Message
- #------------------------------------------------------------------------------
- # This message window is used to display text.
- #==============================================================================
- class Window_Sypnopsis_Objective < Window_Base
- def initialize()
- super(0, (Graphics.height * 0.7), Graphics.width, (Graphics.height * 0.3))
- draw_objective()
- end
- def draw_objective()
- text = DiamondandPlatinum3::SynopsisScene::word_wrapping(self, $game_system.synopsis_objective_text)
- draw_text_ex(0, 0, text)
- end
- end
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # This class performs the menu screen processing.
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- alias dp3_custscene_scenemenu_createcmmdwindow_023fj create_command_window
- #--------------------------------------------------------------------------
- def create_command_window
- dp3_custscene_scenemenu_createcmmdwindow_023fj() # Call Original Method
- @command_window.set_handler(:synosis_scene, method(:command_scenesynopsis))
- end
- def command_scenesynopsis
- SceneManager.call(Scene_Synopsis)
- 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_description_text
- attr_accessor :synopsis_objective_text
- attr_accessor :synopsis_background_image
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias dp3_gamesystem_sypnopsis_initialize_p1d9y initialize
- def initialize
- @synopsis_description_text = "Should we choose to continue on this line and break it here \nWhat you will encounter is that once we get up to a certain point the word wrapper pushes text onto a new line for apparently no reason" +
- "Should we choose to continue on this line and break it here \nWhat you will encounter is that once we get up to a certain point the word wrapper pushes text onto a new line for apparently no reason" +
- "Should we choose to continue on this line and break it here \nWhat you will encounter is that once we get up to a certain point the word wrapper pushes text onto a new line for apparently no reason" +
- "Should we choose to continue on this line and break it here \nWhat you will encounter is that once we get up to a certain point the word wrapper pushes text onto a new line for apparently no reason" +
- "Should we choose to continue on this line and break it here \nWhat you will encounter is that once we get up to a certain point the word wrapper pushes text onto a new line for apparently no reason"
- @synopsis_objective_text = "Objective Text in here"
- @synopsis_background_image = ""
- dp3_gamesystem_sypnopsis_initialize_p1d9y() # 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_backgroundimage( text )
- return unless text.is_a?(String)
- $game_system.synopsis_background_image = text
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement