Sujet n°10882
Posté par Oshidawa le 25 Jan - 18:30 (2012)
Titre : [Demande de suppresion]
[Demande de suppresion]

Posté par Arc-Arceus le 26 Jan - 10:49 (2012)
Je ne peux pas t'aider pour l'instant, je n'ai pas le script sous les yeux. Mais il te faut modifier le script Pokemon_shop, aux endroits où il est question d'afficher le texte incluant le nom des objets disponibles (je crois qu'il s'agit d'un objet list...?) et rajouter une autre liste avec le prix correspondant. Tu peux déjà explorer le script en essayant de débusquer ces lignes.

Posté par Oshidawa le 26 Jan - 18:21 (2012)
Voici le code officiel :

Je n'ai aucune base de Ruby

Code:
#==============================================================================
# ■ Pokemon_Shop
# Pokemon Script Project - Krosk
# 23/08/07
#-----------------------------------------------------------------------------
# Scène à ne pas modifier de préférence
#-----------------------------------------------------------------------------
# Interface d'un magasin
#-----------------------------------------------------------------------------

module POKEMON_S
  class Pokemon_Shop
    def initialize(shop_list)
      @shop_list = shop_list
      shop_list_conversion
    end
   
    def shop_list_conversion
      for i in 0.. @shop_list.length-1
        if @shop_list[i].type == String
          @shop_list[i] = Item.id(@shop_list[i])
        end
      end
    end
   
    def main
      @spriteset = Spriteset_Map.new
      @interface = Interface_Echap.new
     
      @text_window = Window_Base.new(0, 132, 250, 100)
      @text_window.contents = Bitmap.new(608, 112)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsize
      @text_window.contents.font.color = @text_window.normal_color
      @text_window.opacity = 0
      @text_window.visible = false
      @text_window.z = 300
     
      @dummy = Sprite.new
      @dummy.bitmap = RPG::Cache.picture($options[5])
      @dummy.x = 15
      @dummy.y = 158
      @dummy.visible = false
      @dummy.z = 290
     
      @command_window = Window_Command.new(90, ["ACHETER", "VENDRE", "QUITTER"])
      @command_window.active = false
      @command_window.visible = false
      @command_window.x = 16
      @command_window.y = 16
      @command_window.z = 5
     
      Graphics.transition     
      draw_text("En quoi puis-je vous aider ?")
      @command_window.active = true
      @command_window.visible = true
     
      loop do
        Graphics.update
        Input.update
        update
        if $scene != self
          break
        end
      end
      Graphics.freeze
      @command_window.dispose
      @spriteset.dispose
      @interface.dispose
      @dummy.dispose     
      @text_window.dispose
    end

    def update
      @command_window.update
     
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        case @command_window.index
        when 0
          @command_window.visible = false
          draw_text("")
          scene = Pokemon_Shop_Buy.new(@shop_list)
          scene.main
          @command_window.visible = true
          draw_text("Que puis-je faire d'autre", "pour vous ?")
          Graphics.transition
          return
        when 1
          draw_text("")
          scene = Pokemon_Item_Bag.new($pokemon_party.bag_index, 100, "sell")
          scene.main
          draw_text("Que puis-je faire d'autre", "pour vous ?")
          Graphics.transition
          return
        when 2
          draw_text("")
          $scene = Scene_Map.new
          return
        end
      end
     
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
        return
      end
    end
   
    def call_item_amount(data, mode = nil, z_level = 200)
      @counter = Window_Base.new(161,108,106,44)
      @counter.contents = Bitmap.new(@counter.width - 32, @counter.height - 32)
      @counter.contents.font.name = $fontface
      @counter.contents.font.size = $fontsize
      @counter.contents.font.color = @counter.normal_color
      @counter.visible = false
      @counter.active = false
      @counter.z = z_level + 5
     
      @money_window = Window_Base.new(15,15,100,48)
      @money_window.contents = Bitmap.new(147-32,64-32)
      @money_window.contents.font.name = $fontface
      @money_window.contents.font.size = $fontsize
      @money_window.contents.font.color = @money_window.normal_color
      @money_window.contents.draw_text(-50,-10, 147-32, 64-32, $pokemon_party.money.to_s + "$", 2)
      #@money_window.contents.font.color = @money_window.normal_color
      @money_window.visible = false
      @money_window.z = z_level + 5
     
      @text_window.z = z_level + 10
      @dummy.z = z_level + 8
      @z_level = z_level
      @mode = mode
      @data = data
     
      @amount = 1
     
      if @mode == "sell"
        draw_text(Item.name(@data[0]) + " ?", "Combien voulez-vous en vendre ?")
        wait_hit
      end
      if @mode == "buy"
        draw_text(Item.name(@data[0]) + " ? Bien sûr.", "Combien en voulez-vous ?")
        wait_hit
      end
     
      refresh_counter
      @counter.visible = true
      @counter.active = true
      @money_window.visible = true
      loop do
        Input.update
        Graphics.update
        if @counter.visible
          update_counter
        end
        if @counter_done
          draw_text("")
          break
        end
      end
      @counter_done = false
      @counter.dispose
      @money_window.dispose
    end
     
    def wait_hit
      Graphics.update
      Input.update
      until Input.trigger?(Input::C)
        Input.update
        Graphics.update
      end
    end
   
    def update_counter
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @counter_done = true
        return
      end
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        @counter.visible = false
        confirm_call
        return
      end
      if Input.repeat?(Input::UP)
        @amount += 1
        if @mode == "sell" and @amount > @data[1]
          @amount = @data[1]
        end
        if @mode == "buy"
          until @amount*Item.price(@data[0]) <= $pokemon_party.money
            @amount -= 1
          end
        end
        if @amount > 99
          @amount = 99
        end       
        refresh_counter
        return
      end
      if Input.repeat?(Input::DOWN)
        @amount -= 1
        if @amount < 1
          @amount = 1
        end
        refresh_counter
        return
      end
      if Input.repeat?(Input::LEFT)
        @amount -= 10
        if @amount < 1
          @amount = 1
        end
        refresh_counter
        return
      end
      if Input.repeat?(Input::RIGHT)
        @amount += 10
        if @amount > 99
          @amount = 99
        end
        refresh_counter
        return
      end   
    end
   
    def confirm_call
      if @mode == "sell"
        draw_text("Je peux vous en donner ", (Item.price(@data[0])*@amount/2).to_s + "$, ça vous va ?")
        if decision
          $pokemon_party.sell_item(@data[0],@amount)
          refresh_money
          draw_text("Obtenu " + (Item.price(@data[0])*@amount/2).to_s + "$", "pour cette vente.")
          wait_hit
          @counter_done = true
        else
          @counter_done = true
        end
      end
      if @mode == "buy"
        draw_text(Item.name(@data[0]) + " ? Vous en voulez " + @amount.to_s + " ?",
          "Ca fera " + (@amount*Item.price(@data[0])).to_s + "$.")
        if decision
          $pokemon_party.buy_item(@data[0], @amount)
          refresh_money         
          draw_text("Vous avez acheté " + @amount.to_s + " " + Item.name(@data[0]),
            "pour " + (@amount*Item.price(@data[0])).to_s + "$." )
          wait_hit             
          if Item.name(@data[0]) == "Poké Ball" and @amount >= 10           
            draw_text("Vous recevez une Honor Ball","en cadeau.")
            $pokemon_party.add_item(10, 1)           
            wait_hit           
          end         
          @counter_done = true         
        else
          @counter_done = true
        end
      end
    end
   
    def decision
      @command = Window_Command.new(120, ["OUI", "NON"], $fontsize)
      @command.x = 159
      @command.y = 294 - @command.height
      @command.z = @z_level + 30
      loop do
        Graphics.update
        Input.update
        @command.update
        if Input.trigger?(Input::C) and @command.index == 0
          @command.dispose
          @command = nil
          return true
        end
        if (Input.trigger?(Input::C) and @command.index == 1) or Input.trigger?(Input::B)
          @command.dispose
          @command = nil
          return false
        end
      end
    end
   
    def refresh_counter
      @counter.contents.clear
      @counter.contents.draw_text(0,0,75,16,"x " + @amount.to_s, 0)
      if @mode == "buy"
        @counter.contents.draw_text(0,0,75,16,(Item.price(@data[0])*@amount).to_s + "$", 2)
      elsif @mode == "sell"
        @counter.contents.draw_text(0,0,75,16,(Item.price(@data[0])*@amount/2).to_s + "$", 2)
      end
    end
   
    def refresh_money
      @money_window.contents.clear
      @money_window.contents.draw_text(-35,-10,100, 32, $pokemon_party.money.to_s + "$", 2)
    end
   
   
    def draw_text(string = "", string2 = "")
      if string == ""
        @text_window.contents.clear
        @dummy.visible = false
        @text_window.visible = false
      else
        @text_window.contents.clear
        @text_window.visible = true
        @dummy.visible = true
        @text_window.draw_text(13, 8, 212, 32, string)
        @text_window.draw_text(13, 24, 212, 32, string2)
      end
    end
   
  end
 
#-----------------------------------------------------------------------------
# Interface du Sac
#----------------------------------------------------------------------------- 
  class Pokemon_Shop_Buy
    def initialize(shop_list)
      @shop_list = shop_list
      @z_level = 100
    end
     
    def main
      Graphics.freeze     
     
      @background = Sprite.new
      @background.bitmap = RPG::Cache.picture("shopfond.png")
      @background.x = @background.y = 13
      @background.z = @z_level + 1
     
      @item_list = POKEMON_S::Pokemon_Shop_List.new(@shop_list)
      @item_list.opacity = 0
      @item_list.z = @z_level + 10
      @item_list.active = true
      @item_list.visible = true
     
      @item_icon = Sprite.new
      @item_icon.z = @z_level + 2
      @item_icon.x = 18
      @item_icon.y = 382   
      @item_icon.bitmap = RPG::Cache.icon(item_icon)
     
      @money_window = Window_Base.new(3,3,147,64)
      @money_window.contents = Bitmap.new(147-32,64-32)
      @money_window.contents.font.name = $fontface
      @money_window.contents.font.size = $fontsize
      @money_window.contents.font.color = Color.new(107,107,107)
      @money_window.contents.draw_text(-39,-6, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.contents.draw_text(-40,-5, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.contents.draw_text(-39,-5, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.contents.font.color = Color.new(255,255,255)
      @money_window.contents.draw_text(-40,-6, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.z = @z_level + 5
      @money_window.opacity = 0
     
     
      @text_window = Window_Base.new(88-123, 103-20+214+1, 645, 220)
      @text_window.opacity = 0
      @text_window.contents = Bitmap.new(645, 200)
      @text_window.contents.font.name = $fontface
      @text_window.contents.font.size = $fontsizebig
      @text_window.contents.font.color = Color.new(255,255,255,255)
      @text_window.z = @z_level + 1
     
      refresh
     
      Graphics.transition
     
      loop do
        Input.update
        Graphics.update
        @item_list.update
        update
        if @done
          break
        end
      end
      Graphics.freeze
      @item_icon.dispose
      @item_list.dispose
      @text_window.dispose
      @background.dispose
      @money_window.dispose
    end
   
    def update
      if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
        refresh_nolist
      end
     
      if Input.trigger?(Input::C)
        $game_system.se_play($data_system.decision_se)
        if @item_list.index == @item_list.size
          @done = true
          return
        end
        id_item = @shop_list[@item_list.index]
        if $pokemon_party.money < Item.price(id_item)
          $scene.draw_text("Vous n'avez pas assez d'argent", "pour acheter cela.")
          $scene.wait_hit
          $scene.draw_text("")
          return
        end
        $scene.call_item_amount([id_item], "buy", @z_level + 100)
        refresh_money
        return
      end
     
      if Input.trigger?(Input::B)
        $game_system.se_play($data_system.cancel_se)
        @done = true
        return
      end
    end
   
    def refresh
      @item_list.refresh
      refresh_nolist
    end
   
    def refresh_nolist
      # Tracage de l'icone objet
      @item_icon.bitmap = RPG::Cache.icon(item_icon)
      # Texte de description
      text_window_draw(string_builder(item_descr, 42))
    end
   
    def refresh_money
      @money_window.contents.clear
      @money_window.contents.font.color = Color.new(107,107,107)
      @money_window.contents.draw_text(-39,-6, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.contents.draw_text(-40,-5, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.contents.draw_text(-39,-5, 100, 64-32, $pokemon_party.money.to_s + "$", 2)
      @money_window.contents.font.color = Color.new(255,255,255)
      @money_window.contents.draw_text(-40,-6,100, 32, $pokemon_party.money.to_s + "$", 2)
    end
   
    def text_window_draw(list)
      @text_window.contents.clear
      for i in 0..list.length-1         
        @text_window.contents.font.color = Color.new(40,48,40,255)
        @text_window.contents.draw_text(72+1, 16*i+58, 241, $fhb, list[i])
        @text_window.contents.draw_text(72, 1+16*i+58, 241, $fhb, list[i])
        @text_window.contents.draw_text(72+1, 1+16*i+58, 241, $fhb, list[i])
        @text_window.contents.font.color = Color.new(248,248,248,255)
        @text_window.contents.draw_text(72, 16*i+58, 241, $fhb, list[i])
      end
    end
   
    def item_icon
      if @item_list.index == @item_list.size
        return "return.png"
      else
        return Item.icon(item_id)
      end
    end
   
    def item_descr
      if @item_list.index == @item_list.size
        return "Retourner au magasin."
      else
        return Item.descr(item_id)
      end
    end
   
    def item_id
      return @shop_list[@item_list.index]
    end
   
    def string_builder(text, limit)
        length = text.length
        full1 = false
        full2 = false
        full3 = false       
        string1 = ""
        string2 = ""
        string3 = ""       
        word = ""
        for i in 0..length
          letter = text[i..i]
          if letter != " " and i != length
            word += letter.to_s
          else
            word = word + " "
            if (string1 + word).length < limit and not(full1)
              string1 += word
              word = ""
            else
              full1 = true
            end
           
            if (string2 + word).length < limit and not(full2)
              string2 += word
              word = ""
            else
              full2 = true
            end
           
            if (string3 + word).length < limit and not(full3)
              string3 += word
              word = ""
            else
              full3 = true
            end       
           
          end
        end
        if string3.length > 1
          string3 = string3[0..string3.length-2]
        end
        return [string1, string2, string3]
      end
    end
 
#-----------------------------------------------------------------------------
# Interface de la liste
#----------------------------------------------------------------------------- 
  class Pokemon_Shop_List < Window_Selectable
    def initialize(shop_list)
      super(272-155-52, 17+214+6, 356, 125, $fn)
      self.contents = Bitmap.new(324, 384)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsizebig
      self.contents.font.color = platine
      @shop_list = shop_list
      @item_max = size + 1
      self.index = 0     
    end
   
    def refresh
      color_sac = Color.new(16,24,32,255)
      ombre_sac = Color.new(168,184,184,255)
      self.contents.clear
      self.contents = Bitmap.new(356, $fhb*(size+1)+2)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsizebig
      self.contents.font.color = normal_color
      hl = $fn
      i = 0
      for id in @shop_list
        self.contents.font.color = ombre_sac
        self.contents.draw_text(6, 1+hl*i, 304, hl, Item.name(id))
        self.contents.draw_text(5, 1+hl*i, 304, hl, Item.name(id))
        self.contents.font.color = color_sac
        self.contents.draw_text(5, hl*i, 304, hl, Item.name(id))   
        string = (Item.price(id).to_s)
        self.contents.draw_text(14, hl*i, 304, hl, string + "$", 2)
        i += 1
      end
      self.contents.font.color = ombre_sac
      self.contents.draw_text(6, 1+hl*i, 310, hl, "FERMER")
      self.contents.draw_text(5, 1+hl*i, 310, hl, "FERMER")
      self.contents.font.color = color_sac
      self.contents.draw_text(5, hl*i, 310, hl, "FERMER")
    end
   
    def size
      return @shop_list.length
    end
  end
end

Posté par Nuri Yuri le 26 Jan - 19:00 (2012)
Le prix est déjà affiché XD
Remplace : self.contents.draw_text(14, hl*i, 304, hl, string + "$", 2) par : self.contents.draw_text(14, hl*i, 120, hl, string + "$", 2)

Posté par Oshidawa le 26 Jan - 22:10 (2012)
Merci , et petite question est-ce qu'il est possible de rajouter l'information visuel APTE ou NON quand on apprends une CS à un pokémon ?

Posté par Arc-Arceus le 27 Jan - 08:52 (2012)
"Tout est possible, tout est réalisable." 42
Mais c'est pas la matmut qui assure, c'est toi. =p

Posté par Oshidawa le 27 Jan - 11:23 (2012)
Merci Arc-Arceus, bon ben va falloir se mettre au ruby , sauf si une âme charitable se présente =) !