Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Text picture new command

Remember making eternal event systems in old makers? Creating the numbers and words images? And the condition systems to show that numbers and words?

I remember, and hate xD. Maybe its just for the XP but... anyway this script will help in that things.
textz.png


This script can show pictures based on a text line. The image will be treated lik ea normal picture loaded with the show picture event command. It have the same rules and can be moved, changue tone, erased, etc...

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.

The basic options are:
-Color
-Size
-Font type
-Bold
-Italic
-Default values
-Optimitzed large lines support.

Advanced options(Using MACL script, more info inside)
-Shadow
-Vertical gradient
-Horizontal gradient
-Outline

It includes advices to draw event variables.


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"
+Event command Show Picture

Note: This is my first completed script. Its in development, tell me any suggerences or bugs. My english is bad, if you see some thing to improve in the instructions...

Complete instructions in the script.

Code:
#==============================================================================

# 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: [url=http://etheon.net/public/dl/macl_complete.txt]http://etheon.net/public/dl/macl_complete.txt[/url] 

Here the forum thread: [url=http://www.arpgmaker.com/viewtopic.php?f=11&t=9417]viewtopic.php?f=11&t=9417[/url]

-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

 
 
Well, it's not really that bad to let the user edit some message attributes with accessors but some things are so basic that it'd be best to teach the user to include them right at the new Message class initialization like...

@m = Message.new(text, font)

Things like...

@m = Message.new
@m.font = "Arial"
@m.t "Text to show"

...look awkward, especially @m.t... t standing for what? Method names shouldn't be that cryptic. Besides your initialization method could scare anyone trying to learn from that script...
 
kyonides":2llkek53 said:
Well, it's not really that bad to let the user edit some message attributes with accessors but some things are so basic that it'd be best to teach the user to include them right at the new Message class initialization like...

@m = Message.new(text, font)

Things like...

@m = Message.new
@m.font = "Arial"
@m.t "Text to show"

...look awkward, especially @m.t... t standing for what? Method names shouldn't be that cryptic.


Is for the sucking call script. @m.t let you use all the space easily, compare it to a normal @m.text+="Text". Think if @m were @message, like in the beggining.

Font or message arent that basic. Specially font, you can predefine anything...

I changued for this comodity, the system have it in mind. Anyway, with the show picture now it uses less arguments, but... .font or .size is bad? or is only the @m?
 
text = 'My String'
@mess = Message.new(text,'Arial')

That's all you would need just in case the string is too long.

I changued for this comodity...
Normally I wouldn't say anything against making something more comfortable, but that isn't exactly what you did there, gerr. Your t method should really be named after what it is, some text, right, text. It'd only be used if and only if the user wants to replace an existing string not to make the first one.
 
kyonides":1we8icvo said:
text = 'My String'
@mess = Message.new(text,'Arial')

That's all you would need just in case the string is too long.

I changued for this comodity...

Normally I wouldn't say anything against making something more comfortable, but that isn't exactly what you did there, gerr.

I dont understand. Here a example:

@m.t"HP:"+$game_variables[1].to_s
@m.t" MP:"+$game_variables[2].to_s
@m.t" Lv: "+$game_variables[3].to_s
@m.size = 34
@m.font = "Times New Roman"
@m.outline = true

.t is a method that concatenates strings and checks to format it.

how can you this with this? text = 'My String'?. Xp suck for these long lines...
Also i doubt the font will be changued a lot more than any other option...
 
The idea behind using text = "My very long String"+any_variable.to_s is not calling a method like @m.text where a simple local variable can do the job easily whenever you use the the initialization method properly. That's not the only way you can REALLY make it more comfortable for the user, actually you could do this...

text = "My very long string \v[15]"
@mess = Message.new(text, :djvsmono, 22)

...then you'll make sure there are substitutions and if or case statements or hashes that will replace those values with some common ones that aren't the default font. Let's say :djvsmono stands for 'DejaVu Sans Mono', so include something like this...

[rgss]  def initialize(text,font,size)
    text.sub!(/\\v\[[0-9]+\]/, $game_variables[$1].to_s)
    case font
    when :djvsmono  ; font = 'DejaVu Sans Mono'
    when :lucidacons ; font = 'Lucida Console'
    else;  font = DEFAULT_FONT_NAME
    end
   # rest of the code
  end
[/rgss]

I know you might not have any experience with Regexp, but it might be quite useful here.
 
kyonides":2nfegcfq said:
The idea behind using text = "My very long String"+any_variable.to_s is not calling a method like @m.text where a simple local variable can do the job easily whenever you use the the initialization method properly. That's not the only way you can REALLY make it more comfortable for the user, actually you could do this...

text = "My very long string \v[15]"
@mess = Message.new(text, :djvsmono, 22)

...then you'll make sure there are substitutions and if or case statements or hashes that will replace those values with some common ones that aren't the default font. Let's say :djvsmono stands for 'DejaVu Sans Mono', so include something like this...

[rgss]  def initialize(text,font,size)
    text.sub!(/\\v\[[0-9]+\]/, $game_variables[$1].to_s)
    case font
    when :djvsmono  ; font = 'DejaVu Sans Mono'
    when :lucidacons ; font = 'Lucida Console'
    else;  font = DEFAULT_FONT_NAME
    end
   # rest of the code
  end
[/rgss]

I know you might not have any experience with Regexp, but it might be quite useful here.

Ok. The \v is a nice idea, and opens my mind with some new things, like adding suport for drawing actors,etc.... and mayb drawing entire paragraphs.

But about the font, its just that it normally will be used the same for all. Why make this, or make a case or strange codes? In this case i dont think that :lucidacons is more comode than 'Lucida Console'. Is not alot more short, and have to use a limited table... and learn it.

Maybe if the user can set his own codes...

The size will be more used. The thing is that this make two tipes of asignements, that complicate things. Anyway, i will need to add suport for long lines even using regexp...
 
Important bug fixed

Code:
#==============================================================================

# 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: [url=http://etheon.net/public/dl/macl_complete.txt]http://etheon.net/public/dl/macl_complete.txt[/url] 

Here the forum thread: [url=http://www.arpgmaker.com/viewtopic.php?f=11&t=9417]viewtopic.php?f=11&t=9417[/url]

-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

 
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top