Sujet n°5864
Posté par GT.Onizuka le 17 Jan - 02:01 (2010)
Titre : [Script] Effet dans messages
Voilà en me baladant sur le net j'ai découvert un script pas dur d'ailleurs, et qui aidera pour endre son jeu .... raffiné si vous voulez.
Ce tuto consiste à donner un effet (lumineux) à un message .

Image


C'est beau!!!!


Vous devez donc réer un nouveau script au dessus de Main qui s'appellera "Advanced Text Effects Script" et vous y collez ce bout de code :

Bout de code


Code:


=begin
 
  Advanced Text Effects(ATE) V1.0 by Samo, the thief.
 
  This script will evitate you doing your methods of special drawing text manually.
  You will be able to do an outline, a shadow, and something else, by only putting
  when you draw the text:
  (x,y,width,height,str,align,method)
Name        Description         Type
  x         x coordinate        Integer
  y         y coordinate        Integer
  width     width               Integer
  height    height              Integer
  str       string              Integer
  align     alignment:          Integer
            Like in Micro Word 
            0 Left, 1 Medium,   
            2 Right.           
  method    The Method That     String
            will indicate
            what we want.
            Look Down for a List.
  In a Normal window, a draw_text with outline should be like this:
 
  self.contents.draw_text(60,45,120,32,"Thanks Outline Script! Now i look Better!", 1, 'outline')
 
  List of Methods:
 
  'outline'
  'Shadow Wide'
  'Shadow Small'
  'Selected Item'
  'Light Bisel'
  'Small Bisel'
  'Medium Bisel'
 
 
  This also comes with a message system(if you don't like it, just erase the part
  of Window_Mesagge)
 
  The message System Works in this Way. There are especial Characters that will
  define the type of effect to apply. Just put them, they will appear invisible:
 
  ~       No method is used in the message. It makes special characters appear.
  @       Outline
  #       Small Shadow
  $       Big Shadow
  %       Selected Item
  ^       Light Bisel
  &       Small Bisel
  *       Medium Bisel
  `       Text is Drawn Normally, text effects can appear in the message.
=end


class Bitmap
#-----------------------------------------------------------------------
  alias samo_outline_bitmap_draw_text draw_text  #Alias of original Draw_text
#------------------------------------------------------------------------ 
  def draw_text(x, y, width, height, str, align = 0, method = 'normal')
    if method == 'outline'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color= Color.new(0,0,0) #Color Black
      draw_text(x - 1, y, width, height, str, align)
      draw_text(x + 1, y, width, height, str, align)
      draw_text(x , y+1, width, height, str, align)
      draw_text(x , y-1, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
    samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
    end
    if method == 'Shadow Wide'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color =  Color.new(0,0,0,75)
      draw_text(x +12, y + 4, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
    samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
    end
    if method == 'Shadow Small'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color =  Color.new(0,0,0,175)
      draw_text(x +3, y + 3, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
    samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
    end
    if method == 'Selected Item'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color= Color.new(120,255,120,225)
      draw_text(x - 1, y, width, height, str, align)
      draw_text(x + 1, y, width, height, str, align)
      draw_text(x , y+1, width, height, str, align)
      draw_text(x , y-1, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
    samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline     
  end
    if method == 'Light Bisel'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color= Color.new(0,0,0,255)
      draw_text(x + 1, y, width, height, str, align)
      draw_text(x , y+1, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
    samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline     
  end
    if method == 'Small Bisel'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color= Color.new(0,0,0,255)
      draw_text(x + 1, y, width, height, str, align)
      draw_text(x , y+1, width, height, str, align)
      font.color= Color.new(125,125,125,255)
      draw_text(x - 1, y, width, height, str, align)
      draw_text(x , y-1, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
      samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline     
    end
    if method == 'Medium Bisel'
      r = font.color.red    #Takes the original color of the window by numbers
      g = font.color.green
      b = font.color.blue
      a = font.color.alpha
      font.color= Color.new(0,0,0,255)
      draw_text(x + 2, y, width, height, str, align)
      draw_text(x , y+2, width, height, str, align)
      draw_text(x + 2, y+2, width, height, str, align)
      font.color= Color.new(125,125,125,255)
      draw_text(x - 2, y, width, height, str, align)
      draw_text(x , y-2, width, height, str, align)
      draw_text(x - 2, y-2, width, height, str, align)
      font.color = Color.new(r,g,b,a) #Returns teh color no to normal
      samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline     
    end
    if method == 'normal'
    samo_outline_bitmap_draw_text(x, y, width, height, str, align) #draw the text without outline
    end
  end
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
end


class Sprite_Timer < Sprite
  #--------------------------------------------------------------------------
  def update
    super
    self.visible = $game_system.timer_working
    if $game_system.timer / Graphics.frame_rate != @total_sec
      self.bitmap.clear
      @total_sec = $game_system.timer / Graphics.frame_rate
      min = @total_sec / 60
      sec = @total_sec % 60
      text = sprintf("%02d:%02d", min, sec)
      self.bitmap.font.color.set(255, 255, 255)
      self.bitmap.draw_text(0,0,88,48, text, 1, true)
    end
  end
end

#==============================================================================
# ¦ Window_Command
#------------------------------------------------------------------------------

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect.x,rect.y,rect.width,rect.height, @commands[index])
  end
end


#==============================================================================
# ¦ Window_PartyCommand
#------------------------------------------------------------------------------

class Window_PartyCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(160 + index * 160 + 4, 0, 128 - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect.x,rect.y,rect.width,rect.height, @commands[index], 1)
  end
end


#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
#  This message window is used to display text.
#==============================================================================

class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    @cursor_width = 0
    # Indent if choice
    if $game_temp.choice_start == 0
      x = 8
    end
    @method = 'normal'
    # If waiting for a message to be displayed
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      if text.include?('~')
        not_effects = true
        @method = 'normal'
      else
        not_effects = false
      end 
      # Control text processing
      begin
        last_text = text.clone
        text.gsub!(/\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      text.gsub!(/\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      # Change "\\" to "\000" for convenience
      text.gsub!(/\\/) { "\000" }
      # Change "\C" to "\001" and "\G" to "\002"
      text.gsub!(/\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\[Gg]/) { "\002" }
      # Get 1 text character in c (loop until unable to get text)
      while ((c = text.slice!(/./m)) != nil)
        # If \
        if c == "\000"
          # Return to original text
          c = "\"
        end
        # If \C[n]
        if c == "\001"
          # Change text color
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          if color >= 0 and color <= 7
            self.contents.font.color = text_color(color)
          end
          # go to next text
          next
        end
        # If \G
        if c == "\002"
          # Make gold window
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # go to next text
          next
        end
        # If new line text
        if c == "\n"
          # Update cursor width if choice
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          # Add 1 to y
          y += 1
          x = 0
          # Indent if choice
          if y >= $game_temp.choice_start
            x = 8
          end
          # go to next text
          next
        end
        # Draw text
      unless not_effects == true
        if c == "@"
          @method = 'outline'
          next
        elsif c == "#"
          @method = 'Shadow Small'
          next
        elsif c == "$"
          @method = 'Shadow Wide'
          next 
        elsif c == "%"
          @method = 'Selected Item'
          next
        elsif c == "^"
          @method = 'Light Bisel'
          next
        elsif c == "&"
          @method = 'Small Bisel'
          next
        elsif c == "`"
          @method = 'normal'
          next
        elsif c == "*"
          @method = 'Medium Bisel'
          next
        end
      end
      if c == "~"
        next
      end 
        self.contents.draw_text(4 + x, 32 * y, 40, 32, c,0,@method)
        # Add x to drawn text width
        x += self.contents.text_size(c).width
      end
    end
    # If choice
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # If number input
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
  end
end






Mettez avant le mot les signes suivants (attention les chiffres correspondants aux chiffres sur l'image)
Code:



1) @Oui
 2) #Oui
 3) $Oui
 4) %Oui 




Voilou voilou c'était pas magique mais ça m'a servi à plein de choses.

REMERCIEMENTS:
Samo

Posté par Pαlвσlѕку le 17 Jan - 11:42 (2010)
Ca à l'air pas mal mais seulement ton image ne s'affiche plus donc difficile de juger davantage.

Posté par Schtroumpf Anarchiste le 17 Jan - 12:23 (2010)
Palbolsky a écrit:

Ca à l'air pas mal mais seulement ton image ne s'affiche plus donc difficile de juger davantage.

Si si, on la voit Clin d'œil foireux

Posté par Pαlвσlѕку le 17 Jan - 12:42 (2010)
Là oui mais tout à l'heure non.

C'est pas mal mais les textes 2 et 3 sont à revoir.

Posté par Solfay1 le 17 Jan - 14:04 (2010)
Testé sous psp 0.7 ?

Posté par GT.Onizuka le 17 Jan - 14:29 (2010)
@solfay  Oui  :D   mais pas par moi

@pal'    t'as raison mais bon

Posté par Sphinx le 17 Jan - 18:44 (2010)
moi ca me fait une erreur de syntaxe ligne 254 Mollasse enragé Mais je ne vois pas pk... Ca le fait à d'autres ?

Posté par Solfay1 le 17 Jan - 20:03 (2010)
Oui  :?

Posté par Mini' le 17 Jan - 21:10 (2010)
Peut-être bien qu'il est fonctionnel sous 0.7 mais pas sous 4G+. ^.^"

Posté par Solfay1 le 17 Jan - 21:46 (2010)
je suis bien sous 0.7

Posté par souhailhadgi le 10 Fév - 19:45 (2010)
Je veux pas paraître naab mais c'est où Main??

Posté par GT.Onizuka le 10 Fév - 19:47 (2010)
BASES DE RPGMXP !!!!!

mais pour toi
Regarde


Posté par souhailhadgi le 12 Fév - 19:22 (2010)
Thaink You Clin d'œil foireux

Posté par Mini' le 17 Fév - 22:07 (2010)
Sphinx a écrit:

moi ca me fait une erreur de syntaxe ligne 254 Mollasse enragé Mais je ne vois pas pk... Ca le fait à d'autres ?

Même bug pour moi. Et puis j'aime pas les rendus, je trouve ça soit trop flash soit trop trop, donc je le prends pas. Désolé. :/

Posté par GT.Onizuka le 18 Fév - 12:19 (2010)
Comme tu veux
Mais pour le bug je verrais ca
Merci.