Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Picture Text Command
- # By gerkrt/gerrtunk
- # Version: 2.1
- # License: GPL, credits
- #==============================================================================
- =begin
- ----------------------------------
- Instalation and compatiility
- ----------------------------------
- -Put this script before main.
- -To use advance effects install MACL. Here: http://etheon.net/public/dl/macl_complete.txt
- Here the forum thread: viewtopic.php?f=11&t=9417
- -To install read the instructions. Anyway, you have to put before main but after
- this script.
- ----------------------------------
- Instructions
- ----------------------------------
- This script can show pictures based on a text line. The image will be treated like
- a normal picture loaded with the show picture event command. It have the same
- rules and can be moved, changue tone, erased, etc...
- A call script example:
- @m = Message.new
- @m.bold = true
- @m.size = 48
- @m.font = "Arial"
- @m.italic = true
- @m.color = Color.new(134,176,188,154)
- @m.t"Text to show"
- Then you need to put a command show picture with any image(its not used) and the
- values that you will put in a normal event command show picture. The script then creates
- creates a bitmap based on your text and options and loading a event picture with it.
- You have to use this structure of call script+show picture to use this new command.
- ----------------------------------
- Options and meanings
- ----------------------------------
- Basic options. Description before #:
- @m = Message.new # Dont changue or remove this. Always the first thing.
- @m.bold = true # Bold letter
- @m.size = 48 # Size of the font
- @m.font = "Arial" # Fontname
- @m.italic = true # Cursive italic
- @m.color = Color.new(134,176,188,154) # Text basic color.
- @m.t"Wep" # Text to write in the brackets "".
- Advanced options. Only with MACL.
- @m.shadow = true # Shadowed font
- @m.s_color = Color.new(134,176,188,154) # Shadow color
- @m.outline = true # Shows a outline
- @m.o_color = Color.new(134,176,188,154) # Outline color
- @m.horiz_grad = true # Horizontal gradient with two colors
- @m.vert_grad = true # Vertical gradient with two colors
- @m.g1_color = Color.new(134,176,188,154) # Gradiet Starting color
- @m.g2_color = Color.new(1,255,188,154) # Gradiet Endig color
- -The only fixed option is @m = Message.new. If you only put this will chargue
- a picture based only in your predefenided values.
- -Then you have to compose your call scripts adding a option in a new line every time
- This a example:
- Show message "Noooooo", size 16 and horizontal gradient with defined colors:
- @m = Message.new
- @m.t"Nooooooooooooooooo"
- @m.size = 16
- @m.horiz_grad = true
- @m.g1_color = Color.new(134,176,188,154)
- @m.g2_color = Color.new(1,255,188,154)
- -The order dont care. The only rule is to put the @m = Message.new first.
- -The two gradients use the same colors values.
- -Incompatible effects: the two gradients, shadow/outline.
- -Remember to quit the #'s.
- -You can make a large call script in two call scripts, simply continue writting
- in the next. The other option is:
- @m.size = 16 ; @m.horiz_grad = true
- The ; is a ruby line internal separator. Its like they are in different lines.
- -Some advice about the values:
- Color.new(134,176,188,154) Red,Green,Blue+alpha Only changue the numbers. 0-255.
- "Texts": You must use the "" and the text inside of them.
- true/false: It means Active or Inactive. For example to write bold: @m.bold = true
- If the sucker call script gives you strange errors this is what you can try:
- -Recolocate the larger scripts lines: spaces,intros,etc
- -Add a new option at the end, event if its inactive one.
- --------------------------------------------
- Advices to write the text
- --------------------------------------------
- -To only write a event variable value :
- @m.t$game_variables[variable_id].to_s
- -Complex phrases:
- @m.t"HP:"+$game_variables[variable_id].to_s+" "+"Z"
- It writes HP:var Z.
- -In ruby the + concatenate words to make larger ones.
- -Use " " if you need some spaces or aligns
- -Respect the "" word delimitators.
- -The $game_variables[variable_id].to_s dont use "", but internslly its treated like a word
- -variable_id: The number ID of a event variable
- ----------------------------------
- Long lines
- ----------------------------------
- Call script command suck for these. This a example of what you have to do:
- @m.t"HP:"+$game_variables[variable_id].to_s
- @m.t" MP:"+$game_variables[variable_id2].to_s
- @m.t" Limit: "+$game_variables[variable_id3].to_s
- The script automatically concatenates all. Just write it in order.
- ------------------------
- Default values
- ------------------------
- If you need this, you can make your predefenided values for all the options.
- With this, the command can be shorter, removing the lines you dont need.
- The constants names are Def_font_+ the option of the @ that you alreadyknow.
- =end
- module Wep
- Def_font_name = "Arial"
- Def_font_text = "Wep"
- Def_font_size = 24
- Def_font_bold = false
- Def_font_italic = false
- Def_font_color = Color.new(255, 255, 255, 255) # The normal color
- Def_font_horiz_grad = false
- Def_font_vert_grad = false
- Def_font_outline = false
- Def_font_shadow = false
- Def_font_s_color = Color.new(0, 0, 0, 100)
- Def_font_o_color = Color.new(0, 0, 0)
- Def_font_g1_color = Color.new(255, 45, 255)
- Def_font_g2_color = Color.new(12, 128, 128)
- end
- #==============================================================================
- class Message
- attr_accessor :text
- attr_accessor :font
- attr_accessor :size
- attr_accessor :bold
- attr_accessor :italic
- attr_accessor :color
- attr_accessor :horiz_grad
- attr_accessor :vert_grad
- attr_accessor :shadow
- attr_accessor :outline
- attr_accessor :s_color
- attr_accessor :o_color
- attr_accessor :g1_color
- attr_accessor :g2_color
- def initialize(text=Wep::Def_font_text,font=Wep::Def_font_name,size=Wep::Def_font_size,bold=Wep::Def_font_bold,italic=Wep::Def_font_italic, color=Wep::Def_font_color, horiz_grad=Wep::Def_font_horiz_grad,vert_grad=Wep::Def_font_vert_grad,outline=Wep::Def_font_outline,shadow=Wep::Def_font_shadow, s_color=Wep::Def_font_s_color, o_color=Wep::Def_font_o_color,g1_color=Wep::Def_font_g1_color,g2_color=Wep::Def_font_g2_color) @text = text
- @font = font
- @size = size
- @bold = bold
- @italic = italic
- @color = color
- @s_color = s_color
- @o_color = o_color
- @g1_color = g1_color
- @g2_color = g2_color
- @horiz_grad = horiz_grad
- @vert_grad = vert_grad
- @shadow = shadow
- @text = ""
- @text = text
- @outline = outline
- @first_concat = true
- end
- #--------------------------------------------------------------------------
- # *t This metod concatenates the text string.
- # Optimitzed to be very short.
- #--------------------------------------------------------------------------
- def t(text)
- # Check if the text is the predefined and its the first time to add
- # and clears it
- if Wep::Def_font_text == @text and @first_concat
- @text = ""
- end
- @first_concat = false
- @text += text
- end
- end
- class Sprite_Picture
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- # If picture file name is different from current one and have a message
- if @picture_name != @picture.name and @picture.message
- # Remember file name to instance variables
- @picture_name = @picture.name
- #if @picture_name != ""
- # Get picture graphic
- #end
- # Use the testing bitmap to know text size
- testing_bitmap = Bitmap.new(1,1)
- testing_bitmap.font.name = @picture.message.font
- testing_bitmap.font.size = @picture.message.size
- testing_bitmap.font.bold = @picture.message.bold
- testing_bitmap.font.italic = @picture.message.italic
- line = @picture.message.text
- needed_rect = testing_bitmap.text_size(line)
- # Changue basic font options
- self.bitmap = Bitmap.new(needed_rect.width, needed_rect.height)
- self.bitmap.font.name = @picture.message.font
- self.bitmap.font.size = @picture.message.size
- self.bitmap.font.bold = @picture.message.bold
- self.bitmap.font.italic = @picture.message.italic
- self.bitmap.font.color = @picture.message.color
- # Exception check if MACL is instaled or not
- begin
- if MACL != nil
- # Changue advanced font options
- self.bitmap.font.horiz_grad = @picture.message.horiz_grad
- self.bitmap.font.vert_grad = @picture.message.vert_grad
- self.bitmap.font.outline = @picture.message.outline
- self.bitmap.font.shadow = @picture.message.shadow
- self.bitmap.font.shadow_color = @picture.message.s_color
- self.bitmap.font.outline_color = @picture.message.o_color
- self.bitmap.font.grad_s_color = @picture.message.g1_color
- self.bitmap.font.grad_e_color = @picture.message.g2_color
- end
- rescue
- end
- self.bitmap.draw_text(0, 0, needed_rect.width, needed_rect.height, line)
- end
- # If picture file name is different from current one
- if @picture_name != @picture.name and @picture.message == nil
- # Remember file name to instance variables
- @picture_name = @picture.name
- # If file name is not empty
- if @picture_name != ""
- # Get picture graphic
- self.bitmap = RPG::Cache.picture(@picture_name)
- end
- end
- # If file name is empty
- if @picture_name == ""
- # Set sprite to invisible
- self.visible = false
- return
- end
- # Set sprite to visible
- self.visible = true
- # Set transfer starting point
- if @picture.origin == 0
- self.ox = 0
- self.oy = 0
- else
- self.ox = self.bitmap.width / 2
- self.oy = self.bitmap.height / 2
- end
- # Set sprite coordinates
- self.x = @picture.x
- self.y = @picture.y
- self.z = @picture.number
- # Set zoom rate, opacity level, and blend method
- self.zoom_x = @picture.zoom_x / 100.0
- self.zoom_y = @picture.zoom_y / 100.0
- self.opacity = @picture.opacity
- self.blend_type = @picture.blend_type
- # Set rotation angle and color tone
- self.angle = @picture.angle
- self.tone = @picture.tone
- end
- end
- class Game_Picture
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :message # text
- #--------------------------------------------------------------------------
- # * Object Initialization
- # number : picture number
- #--------------------------------------------------------------------------
- alias gp_init initialize
- def initialize(number)
- gp_init(number)
- @message = nil
- end
- alias gp_show show
- def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type, message=nil)
- gp_show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
- @message = message
- end
- alias gp_erase erase
- def erase
- gp_erase
- @message = nil
- end
- end
- class Interpreter
- #--------------------------------------------------------------------------
- # * Show Picture
- #--------------------------------------------------------------------------
- def command_231
- # Get picture number
- number = @parameters[0] + ($game_temp.in_battle ? 50 : 0)
- # If appointment method is [direct appointment]
- if @parameters[3] == 0
- x = @parameters[4]
- y = @parameters[5]
- # If appointment method is [appoint with variables]
- else
- x = $game_variables[@parameters[4]]
- y = $game_variables[@parameters[5]]
- end
- # Show picture
- # If message is written
- if @m != nil
- $game_screen.pictures[number].show(@parameters[1], @parameters[2],
- x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9], @m)
- # Format m for other calls
- @m = nil
- else
- $game_screen.pictures[number].show(@parameters[1], @parameters[2],
- x, y, @parameters[6], @parameters[7], @parameters[8], @parameters[9])
- end
- # Continue
- return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement