Sujet n°7015
Posté par Mortenkein le 12 Juin - 02:26 (2010)
Titre : Le nom du lieu ne s'affiche pas en entier (menu perso)[OK]
Dans mon menu personnalisé (formé de bouts de code trouvés dans d'autres scripts et ensuite légèrement modifiés), le nom du lieu où se trouve le héros s'affiche dans une fenêtre. Quand le nom du lieu est court, il s'affiche intégralement, mais quand il est long, il s'affiche partiellement. Regardez la capture d'écran


Capture d'écran du problème

Spoiler



Le script

Spoiler
#==========================================================
# ■ Pokemon_Menu
# Pokemon Script Project - Krosk
# 18 juillet 2007
# 11 juin 2010 - Mortenkein
#-----------------------------------------------------------------------------
# Menu principal accessible par échap
#-----------------------------------------------------------------------------

module POKEMON_S
  class Pokemon_Menu

    def initialize (menu_index = 0)
      @menu_index = menu_index
    end
   
#--------------------------------------------------------------------------
#  Bloc principal
#--------------------------------------------------------------------------

    def main
      if $game_variables[5000]["menu_dp"]
        Graphics.freeze
        @z_level = 10000
        @background = Sprite.new
        @background.bitmap = RPG::Cache.picture("Menu.png")
        @background.x = 460-3
        @background.y = 11
        @background.z = @z_level    
        @spriteset = Spriteset_Map.new
        s1 = "       POKéDEX"
        s2 = "       POKéMON"
        s3 = "      "
        s4 = "       " + Player.name
        s5 = "      "
        s6 = "      "
        @command_window = Window_Command.new(180, )
        @command_window.index = @menu_index
        @command_window.x = 467 - 3
        @command_window.y = 5
        @command_window.z = @z_level + 2
        @command_window.opacity = 0
      else
        @spriteset = Spriteset_Map.new
        s1 = "POKéDEX"
        s2 = "POKéMON"
        s3 = "SAC"
        s4 = "---------"
        s5 = Player.name
        s6 = "SAUVER"
        s7 = "QUITTER"
        @command_window = Window_Command.new(160, )
        @command_window.index = @menu_index
        @command_window.x = 480 - 3
        @command_window.y = 3
      end
     
      # Désactive l'accès à Pokémon
      if $pokemon_party.size == 0
        @command_window.disable_item(1)
      end
     
      # Désactive l'accès à Pokédex si non possédé
      if not($data_pokedex[0])
         @command_window.disable_item(0)
       end
      
      # Désactive l'accès à Sauver
      if $game_system.save_disabled
        @command_window.disable_item(4)
      end
     
      @fenetre_jour = JourX.new
      @fenetre_jour.x = 480 - 3
      @fenetre_jour.y = 260
      @fenetre_jour.opacity = 255
     
      @fenetre_temps = TempsJeu.new
      @fenetre_temps.x = 480 - 3
      @fenetre_temps.y = 325
      @fenetre_temps.opacity = 255
     
      @fenetre_lieu = LieuX.new
      @fenetre_lieu.x = 3
      @fenetre_lieu.y = 3
      @fenetre_lieu.opacity = 255   
     
      @fenetre_argent = ArgentX.new
      @fenetre_argent.x = 480 - 3
      @fenetre_argent.y = 416
      @fenetre_argent.opacity = 255 
     
     
      Graphics.transition
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
      Graphics.freeze
      @background.dispose if $game_variables[5000]["menu_dp"]
      @command_window.dispose
      @spriteset.dispose
      @fenetre_jour.dispose
      @fenetre_temps.dispose
      @fenetre_lieu.dispose
      @fenetre_argent.dispose
    end

    #--------------------------------------------------------------------------
    #
    #--------------------------------------------------------------------------
    def update
      # ウィンドウを更新
      @command_window.update
      @spriteset.update
      @fenetre_jour.update
      @fenetre_temps.update
      @fenetre_argent.update
      # コマンドウィンドウがアクティブの場合: update_command を呼ぶ
      if @command_window.active
        update_command
        return
      end
    end
   
    #--------------------------------------------------------------------------
    # Affichage du jour de la semaine
    #--------------------------------------------------------------------------
   
  class JourX < Window_Base
 
    def initialize
      super(0, 0, 160, 64)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      refresh
    end
 
    def refresh
      self.contents.clear
     
      @jour_texte = Time.now

     jour = @jour_texte.strftime("%A")
      case @jour_texte.strftime("%A")
        when "Monday"
          jour = "Lundi"
        when "Tuesday"
          jour = "Mardi"
        when "Wednesday"
          jour = "Mercredi"
        when "Thursday"
          jour = "Jeudi"
        when "Friday"
          jour = "Vendredi"
        when "Saturday"
          jour = "Samedi"
        when "Sunday"
          jour = "Dimanche"
        end
      self.contents.font.size = 32
      self.contents.font.color = Color.new(0, 64, 246, 255)
      self.contents.draw_text(4, 0, 120, 32, jour, 1)
    end
   
    def update
      super
      refresh
    end
  end
    
    #--------------------------------------------------------------------------
    # Temps de jeu
    #--------------------------------------------------------------------------
 
  class TempsJeu < Window_Base
 
    def initialize
      super(0, 0, 160, 90)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      refresh
    end
 
    def refresh
      self.contents.clear
      self.contents.font.color = Color.new(0, 64, 246, 244)
      self.contents.draw_text(4, 0, 120, 32, "TEMPS DE JEU")
      @total_sec = Graphics.frame_count / Graphics.frame_rate
      heure = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      texte = sprintf("%02d:%02d:%02d", heure, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 32, 120, 32, texte, 2)
    end
 
    def update
      super
      if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
      end
    end
  end
 
    #--------------------------------------------------------------------------
    # Affichage du lieu où se trouve le héros
    #--------------------------------------------------------------------------
     
  class LieuX < Window_Base
 
    def initialize
      super(0, 0, 240, 64)
      self.contents = Bitmap.new(width - 32, height - 32)
      refresh
    end
 
    def refresh
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      self.contents.clear
      self.contents.font.color = system_color
      self.contents.font.color = Color.new(255, 0, 0, 255)
      $cartes = load_data("Data/MapInfos.rxdata")
      @carte_id = $game_map.map_id
      @carte_actuelle = $cartes[@carte_id].name
      self.contents.font.size = 32
      self.contents.draw_text(0, 0, 120, 32, @carte_actuelle, 2)
    end
  end
 
    #--------------------------------------------------------------------------
    # Argent du héros
    #--------------------------------------------------------------------------
 
  class ArgentX < Window_Base
 
    def initialize
      super(0, 0, 160, 60)
      self.contents = Bitmap.new(width - 32, height - 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      refresh
    end
 
    def refresh
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(0, 0, 100, 32,$pokemon_party.money.to_s + "$", 2)
    end
  end
   
    #--------------------------------------------------------------------------
    # Mise à jour des commandes
    #--------------------------------------------------------------------------
    def update_command
      # Si le joueur appuie sur B
      if Input.trigger?(Input::B)
        # Son d'annulation
        $game_system.se_play($data_system.cancel_se)
        # Retour à la carte où est le héros
        $scene = Scene_Map.new
        return
      end
      # Si le joueur appuie sur C
      if Input.trigger?(Input::C)
        # パーティ人数が 0 人で、セーブ、ゲーム終了以外のコマンドの場合
        if $game_party.actors.size == 0 and @command_window.index < 4
          # ブザー SE を演奏
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # コマンドウィンドウのカーソル位置で分岐
        case @command_window.index
        when 0 # Pokédex
          if not($data_pokedex[0])
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          $scene = POKEMON_S::Pokemon_Pokedex.new
        when 1 # Menu
          if $pokemon_party.size == 0
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          $scene = POKEMON_S::Pokemon_Party_Menu.new
        when 2 # Sac
          $game_system.se_play($data_system.decision_se)
          $scene = Pokemon_Item_Bag.new
        when 3 # ---------------- (test)
          $game_system.se_play($data_system.decision_se)
          $game_temp.common_event_id = 19
          $scene = Scene_Map.new
        when 4 # Carte dresseur
          $game_system.se_play($data_system.decision_se)
          $game_temp.common_event_id = 19
          $scene = Scene_Map.new
        when 5 # Sauvegarde
          if $game_system.save_disabled
            $game_system.se_play($data_system.buzzer_se)
            return
          end
          $game_system.se_play($data_system.decision_se)
          $scene = POKEMON_S::Pokemon_Save.new
        when 6 # Quitter le menu
          $game_system.se_play($data_system.decision_se)
          $scene = Scene_Map.new
        end
        return
      end
    end
  end
end



Par ailleurs, pourriez-vous m'expliquer pourquoi la balise code ne fonctionne pas chez moi? Quand je copie mon script dans la balise code, une tonne de texte inutile s'affiche quand je prévisualise mon message... :gloups:

Posté par FinalArt le 12 Juin - 13:49 (2010)
1 - Utilise PSP DS Clin d'œil foireux
2 - Le problème, oui c'est trop long. En gros ton message est trop long, donc la zone de texte qui est définit est trop petite, augmente là, et ça devrait aller/
3 - Peut être que ces balises ne s'affichent que en prévisualisation, essaye en in game

Posté par Mortenkein le 12 Juin - 14:12 (2010)
1 - Non, les graphismes visibles sur la capture d'écran sont ceux utilisés dans ma démo technique « Centre Pokémon - Animation de soin DPP ». J'utilise cette démo comme bac à sable. Pour mon projet, j'utilise mes tilesets RFVF.

2 - Justement, comment faire pour augmenter la zone de texte? Pourtant, la fenêtre dans laquelle s'affiche le lieu est suffisamment grande.

3 - La capture d'écran a été prise durant un test dans le jeu (F12) :gloups: .

Posté par Mack le 13 Juin - 13:28 (2010)
Dans ton Class_LieuX
A cette ligne :
 
Code:
self.contents.draw_text(0, 0, 120, 32, @carte_actuelle, 2) 


Il faut que tu changes le 120 pour que ça colle avec la largeur de ton texte.

Posté par Mortenkein le 13 Juin - 14:27 (2010)
Merci beaucoup Mack! J'ai écrit 200 au lieu de 120 et ça fonctionne  :D .