E-magination
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.


~ S'évader de la banalité... Et entrer dans l'imaginaire ! ~
 
AccueilGuelnika, le site de E-m !ChatDernières imagesS'enregistrerConnexion
Le Deal du moment :
Jeux, jouets et Lego : le deuxième à ...
Voir le deal

 

 [SCRIPT] Menu "Entrer un nom" amélioré

Aller en bas 
AuteurMessage
Kira
RTP de base Lv 2
RTP de base Lv 2
Kira


Nombre de messages : 43
Age : 31

[SCRIPT] Menu "Entrer un nom" amélioré Empty
MessageSujet: [SCRIPT] Menu "Entrer un nom" amélioré   [SCRIPT] Menu "Entrer un nom" amélioré Icon_minitimeLun 24 Mar 2008, 19:05

Je vais vous présenter un script qui permet d'obtenir une fenêtre "Entrer le nom d'un héros" beaucoup plus belle (je trouve celle par défaut assez laide).

Ce script vient à la base de rpgcréative, mais je lui ai apporté quelques améliorations :

1.Possibilité de choisir le sexe des prénoms choisis au hasard

2.Entièrement traduit en français du script originalement en anglais (avec une ptite explication des touches en haut)

3.Rajout des caractères "é" et "è"

Voila le script en question :

Code:

class Window_Name < Window_Selectable
  attr_accessor :string
  attr_accessor :name
  attr_accessor :default_name
  attr_accessor :max_char
def initialize(actor, max_char)
  super(135, 60, 440, 70)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name =  "Tahoma"
    self.contents.font.size = 18
    self.visible = true
    self.active = true
    @string = ""
    @max_char = max_char
    @actor = actor
    @name = @actor.name
    @name_text = @name.split(//)[0...@max_char]
    for i in 0...@name_text.size
      @string += @name_text[i]
    end
      @default_name = @string
    refresh
  end
 
  def add_char(char)
    @string += char
  end
 
  def remove
    @name_text = @string.split(//)
      @string = ""
      for i in 0...@name_text.size-1
        @string += @name_text[i]
      end
    end
 
 
  def refresh
    self.contents.clear
    @name_text = @string.split(//)
    for i in 0...@max_char
      text = @name_text[i]
      if text == nil
        text = "__"
      end
      x = 120 - @max_char * 14 + i * 28
      self.contents.draw_text(x, 0, 28, 32, text, 1)
    end
  end
 
 
end#end of class

class Window_Array < Window_Selectable
  attr_accessor :alpha
  $checker = " "
  ALPHABET_CHARACTER = [
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0",
"1", "2", "3", "4", "5", "6", "7", "8", "9", " " ," "," ", " ", " ", " ", " ", " "
]
  def initialize
  super(135, 130, 440, 330)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name =  "Tahoma"
    self.contents.font.size = 18
    self.visible = true
    self.active = false
    self.index = 0
    @alpha = alpha
    @item_max = ALPHABET_CHARACTER.size
    refresh
  end
 
  def refresh
    self.contents.clear
      $checker = "capital"
    for i in 0...28
    x = 4 + i / 7 / 9 * 152 + i % 7 * 28
      y = i / 7 % 9 * 32
    self.contents.draw_text(x, y, 120, 32, ALPHABET_CHARACTER[i])
    end
    for i in 0...16
    x = 150 + i / 4 / 9 * 152 + i % 4 * 28
      y = i / 4 % 9 * 32
    self.contents.draw_text(x, y, 120, 32, ALPHABET_CHARACTER[i + 28], 2)
  end
end

def small_case
  self.contents.clear
    $checker = "small"
  @new_alpha = ["é","è"]
  for i in 0...ALPHABET_CHARACTER.size
    @new_alpha.push(ALPHABET_CHARACTER[i].downcase)
  end
    for i in 0...28
      x = 4 + i / 7 / 9 * 152 + i % 7 * 28
    y = i / 7 % 9 * 32
      self.contents.draw_text(x, y, 120, 32, @new_alpha[i])
    end
    for i in 0...16
      x = 150 + i / 4 / 9 * 152 + i % 4 * 28
      y = i / 4 % 9 * 32
    self.contents.draw_text(x, y, 120, 32, @new_alpha[i + 28], 2)
  end
end

def collect_char(character)
  @alpha = " "
  @character = character
  if $checker == "small"
    @alpha = @new_alpha[@character]
  end
  if $checker == "capital"
      @alpha =  ALPHABET_CHARACTER[@character]
    end
    return @alpha
  end

 def update_cursor_rect
  x = 4 + @index / 7 / 9 * 152 + @index % 7 * 28
  y =  y = @index / 7 % 9 * 32
        case @index
        when 0...26
      x = 4 + @index / 7 / 9 * 152 + @index % 7 * 28
      y = @index / 7 % 9 * 32
      when 27...43
        x = 260 + (@index - 27) / 4 / 9 * 152 + (@index - 27) % 4 * 28
      y = (@index - 27) / 4 % 9 * 32
    end
    self.cursor_rect.set(x - 5, y + 5, 22, 22)
  end
 
 
  def update
    if self.active
      super
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      @index += 1
      if @index == 37
      @index = 0
      end
  end
  if Input.repeat?(Input::LEFT)
    $game_system.se_play($data_system.cursor_se)
    @index -= 1
    if @index == -1
      @index = 36
    end
  end


  if Input.repeat?(Input::DOWN)
    $game_system.se_play($data_system.cursor_se)
    if @index >= 1 && @index <= 6 || @index >= 8 && @index <= 13 || @index >= 15 && @index <= 20 || @index >= 22 && @index <= 27
      if @index >= 22 && @index <= 27
            @index -= 22
        else
          @index += 6
        end
      elsif @index == 7 || @index == 14 || @index == 21
        if @index == 21
            @index -= 15
          else
          @index += 6
        end
      elsif @index == 28 || @index == 29 || @index == 32 || @index == 33 || @index == 36 || @index == 37
        if @index == 36 || @index == 37
        @index -= 9
        else
          @index += 3
        end
        elsif @index == 30 || @index == 31 || @index == 34 || @index ==35
          if @index == 34 || @index == 35
            @index -= 5
          else
              @index += 3
          end
      end
    end#end of if statement
 
  if Input.repeat?(Input::UP)
    $game_system.se_play($data_system.cursor_se)
    if @index <= 25 && @index >= 20 || @index <= 18 && @index >= 13 || @index <= 11 && @index >= 6 || @index <= 4 && @index >= 0 || @index == 43
      if @index <= 4 && @index >= 0
          @index += 22
        elsif @index == 43
          @index = 21       
        else
          @index -= 6
        end
    elsif @index == 19 || @index == 12 || @index == 5
        if @index == 5
          @index = 20
        else
          @index -= 6
        end
    elsif @index == 35 || @index == 34 || @index == 31 || @index == 30 || @index == 27 || @index == 26
      if @index == 27 || @index == 26
        @index +=  9
      else
        @index -= 3
      end
    elsif @index == 28 || @index == 29 || @index == 33 || @index == 32
      if @index == 28 || @index == 29
        @index += 5
      else
        @index -= 3
      end
  end
  end
      update_cursor_rect
    end
  end
end#end of class

class Scene_Namer
  def initialize(actor_id , name_max, sexe)
    @actor_id = actor_id
    @name_max = name_max
    @sexe = sexe
  end
  def main
    if @sexe == 1
    @rand_name = ["Jack",  "Ryu", "Ryain", "Sin", "Matt", "Sirus", "James", "Anthony","Michael","Mohamed","Ichigo","Mehdi","Paul"]
  elsif @sexe ==2
    @rand_name = ["Maria", "Rukia", "Félicia", "Julie", "Anna", "Sonia", "Leila", "Stéphanie", "Isabelle", "Angela"]
  else
  @rand_name = ["Anonymous"]
  end
    @actor = $game_party.actors[@actor_id]
    @window = Window_Base.new(0,0,130,130)
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.character("Faces/" + @actor.character_name, @actor.character_hue)
    @sprite.z = 800
    @sprite.x = 5
    @sprite.y = 5
    @choice = Window_Command.new(130, ["Défaut", "Majuscules", "Minuscules", "Hasard"])
    @choice.x = 0
    @choice.y = 175
    @lvl = Window_Help.new
    @lvl.width = 130
    @lvl.height = 150
    @lvl.x = 0
    @lvl.y = 120
    @lvl.set_text("Level #{@actor.level}")
    @lvl.opacity = 0
    @cov = Window_Base.new(0,130,130,50)
    @help = Window_Help.new()
    @help.x = 135
    @help.y = 0
    @help.contents.draw_text(50,0,600,32,"X pour commencer, A pour effacer")
    @help.width = 440
    @name_window = Window_Name.new(@actor, @name_max)
    @content = Window_Array.new
    list = ["Sauver", "Editer", "Sortir" ]
    @command = Window_Command.new(130, list)
    @command.active = false
    @command.x = 0
    @command.y = 330
    @help_text = "Menu Nom"
    @show = Window_Help.new
    @show.width = 60
    @show.height = 459
    @show.y = 0
    @show.x = 578
    @show.contents = Bitmap.new(@show.width - 32, @show.height - 32)
    @show.contents.font.name = "Tahoma"
    @show.contents.font.size = 20
    @new_text = @help_text.split("")
    for i in 0...@new_text.size
      x = 4
      y = i * 42
      @show.contents.draw_text(x , y, 120, 32, @new_text[i])
    end
      Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
 
    Graphics.freeze
    @window.dispose
    @sprite.dispose
    @choice.dispose
    @lvl.dispose
    @cov.dispose
    @help.dispose
    @name_window.dispose
    @content.dispose
    @command.dispose
    @show.dispose
  end
 
  def update
    @window.update
    @sprite.update
    @choice.update
    @lvl.update
    @cov.update
    @help.update
    @name_window.update
    @content.update
    @command.update
    @show.update
    if @choice.active
      update_choice
      return
    end
    if @command.active
      update_command
      return
    end
    if @content.active
      update_content
      return
    end
  end
 
  def update_choice
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      case @choice.index
      when 0
        @name_window.string = @name_window.default_name
        @name_window.refresh
        when 1
          @content.refresh
          when 2
            @content.small_case
            when 3
              @new_name = @rand_name[rand(@rand_name.size - 1)]
              @name_window.string = @new_name
              @name_window.refresh
            end
          end
          if Input.trigger?(Input::B)
              @choice.active = false
              @command.active = true
          end
        end
     
        def update_command
          if Input.trigger?(Input::C)
            $game_system.se_play($data_system.decision_se)
            case @command.index
            when 0
              @counter = 0
              @registered_name = @name_window.default_name
              if @name_window.string == "" or nil
                @name_window.string = @registered_name
                @actor.name = @registered_name
                @name_window.refresh
              else
                  @actor.name = @name_window.string
              end
              @first_text = "#{@name_window.default_name} est supprimé "
              @second_text = "Patientez........."
              @third_text = "#{@name_window.default_name} est maintenant #{@actor.name}"
              @saved = Window_Help.new
              @saved.x = 150
              @saved.y = 250
              @saved.z = 900
              @saved.width = 350
              loop do
                @saved.update
                Graphics.update
                Input.update
                @counter += 1
                case @counter
                when 7
                  @saved.set_text(@first_text)
                  when 65
                    @saved.set_text(@second_text)
                    when 150
                      @saved.set_text(@third_text)
                      when 195
                        break
                      end
                    end
                    @name_window.default_name = @actor.name
                    if @saved != nil
                      @saved.dispose
                    end
              when 1
                @command.active = false
                @content.active = true
                when 2
                    $game_system.se_play($data_system.cancel_se)
                      $scene = Scene_Map.new
                end
              end
              if Input.trigger?(Input::B)
                $game_system.se_play($data_system.cancel_se)
                @choice.active = true
                @command.active = false
                return
              end
            end
         
            def update_content
              if Input.trigger?(Input::C)
                @compare = @name_window.string.split("")
                if @compare.size - 1 == @name_window.max_char - 1
                  $game_system.se_play($data_system.buzzer_se)
                  return
                else
                $game_system.se_play($data_system.decision_se)
                  case @content.index
                  when 0...27
                    @name_window.add_char(@content.collect_char(@content.index))
                  when 27...44
                    @current = @content.index + 1
                    @name_window.add_char(@content.collect_char(@current))
                  end
                end
                @name_window.refresh
              end
           
              if Input.trigger?(Input::B)
                $game_system.se_play($data_system.cancel_se)
                @content.active = false
                @command.active = true
                return
              end
           
              if Input.trigger?(Input::X)
                @compare = @name_window.string.split("")
                if @compare.size <= 0
                  $game_system.se_play($data_system.buzzer_se)
                  return
                else
                $game_system.se_play($data_system.decision_se)
                @name_window.remove
                @name_window.refresh
              end
            end
          end
        end#end of class

Pour ouvrir la fenêtre, il faut taper ce code dans la commande "Inserer un script" :

Code:

$scene = Scene_Namer.new(x, y, z)

1.Remplacer x par l'id du héros, en commençant par 0 (si c'est le héros n°1, mettez 0)

2.Remplacez y par le nombre de lettres maximum (de 1 à 9)

3. Remplacez z par le sexe du héros (1 pour garçon, 2 pour fille et 3 pour inconnu)


Dans le script, vous pouvez modifier les prénoms choisis au hasard aux lignes 228 pour les garçons, 230 pour les filles et 232 pour les inconnus.

Dans le dossier Graphics > Characters > Faces qui doit faire 96*96px et porter le même nom que l'image de votre battlers.

Voici une petite image pour vous montrer le résultat :

[SCRIPT] Menu "Entrer un nom" amélioré 0803240714202732035

Voila, c'est fini cactus smile

____________
[SCRIPT] Menu "Entrer un nom" amélioré Deathnotehautoq8

Ķ!ЯΔ V$ Ł
Revenir en haut Aller en bas
Invité
Invité
Anonymous



[SCRIPT] Menu "Entrer un nom" amélioré Empty
MessageSujet: Re: [SCRIPT] Menu "Entrer un nom" amélioré   [SCRIPT] Menu "Entrer un nom" amélioré Icon_minitimeLun 24 Mar 2008, 20:15

Un longue liste tout pour un enter Name hero! Wow!

Sinon, si j'ai bien compris, y'a juste le fait qu'on sache le sexe du héros et le rajout des lettres à Accent qui est nouveau?
Revenir en haut Aller en bas
 
[SCRIPT] Menu "Entrer un nom" amélioré
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» [Résolu] Script: Comment combiner ces deux scripts de menu?
» "This is good level design" : Super Mario Land
» [Résolu] Raccourcis pour "animer" les dialogues.
» Questions en vrac sur XP
» Règles pour la section "Entre-aide"

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
E-magination :: ~ Forums d'enrichissement ~ :: Apprentissage et partage :: RPG Maker XP :: Tutoriels / Scripts-
Sauter vers: