Compressing/scrolling text for item descriptions?

● ARCHIVED · READ-ONLY
Started by Silencher 9 posts View original ↗
  1. Is there a script or way to make it so that the item 'descriptions from the database are a bit longer, or compressed into a smaller font? I'm finding a lot of my item descriptions are being cut off. I realize I could just shorter the descriptions, which I will do if I have to, but that's a last resort at this point.

    I'm hoping to find a way to either have the window auto-decrease the font size to accommodate the extra text, or have the text scroll through the whole description. Is there a script like that, or a setting perhaps?
  2. I'm not too sure if you can scroll the text in the item description box, however, I think that the amount of space your text takes up depends on your chosen font, and font size. After using Yanfly's Core Engine, I was able to see more of the item description box; most likely because I made the font smaller, though I'm not 100% certain because I use a fair few of Yanfly's scripts which alter various scenes.

    You could always give it a try.
  3. This is semi-off topic but not really. Where can you alter the default font and font size?
  4. I changed my default font and font size using the information in this post from Lunarea. The "Main" referred to is at the end of the list when you open the Script Editor (F11).
  5. in theory this should work... i just edited BigEd's script but pactically just 2 lines. works like a charm but the special stuff like "\c[x]" doesn't work and when you press enter or make a line break in the description in the database the scripts makes some weird symbol <- does anyone have any idea how to fix this?

    i hope im not volating anything by posting this. hope this helps even a little bit silencher :|

    Spoiler
    Code:
    class Sprite
    def draw_icon(icon_index, x, y, enabled = true)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
    endend
    class Window_Help < Window_Base @@SCROLL_DELAY = 1 # seconds
    @@SCROLL_SPEED = 2 # pixels / frame (60 frames / sec)
    @@SHOW_ICONS = false # display icons for items and skills?
    alias :scroll_init :initialize
    def initialize(*args)
    scroll_init(*args)
    @internal_frame_count = 0
    @text_is_long = false
    @icon_sprite = Sprite.new
    @icon_sprite.x = self.x + 16
    @icon_sprite.y = self.y + 16
    @icon_sprite.z = self.z + 1
    @icon_sprite.bitmap = Bitmap.new(32, 32)
    self.windowskin = get_altered_skin
    end def get_altered_skin
    default = Cache.system('Window')
    window = Bitmap.new(default.width, default.height)
    window.blt(0, 0, default, default.rect)
    window.fill_rect(80, 16, 32, 32, Color.new(0,0,0,0))
    return window
    end
    
    def set_text(text, align = 0)
    unless (text == @text) && (align == @align)
    @internal_frame_count = 0
    txt_width = self.contents.text_size(text).width
    @text_is_long = txt_width > (self.width - 32)
    self.contents.dispose
    w = @text_is_long ? (txt_width + self.width - 32) : self.width - 32
    self.contents = Bitmap.new(w, self.height - 32)
    self.contents.clear
    self.ox = 0
    self.contents.font.color = normal_color
    i = get_icon_index(text)
    unless i.nil?
    draw_sprite(i, 0, 0)
    self.contents.draw_text(32, 0, self.contents.width, fitting_height(1), text, align)
    else
    @icon_sprite.bitmap.clear
    self.contents.draw_text(4, 0, self.contents.width, fitting_height(1), text, align)
    end
    @text = text
    @align = align
    end
    end
    
    def draw_sprite(icon_index, x, y)
    @icon_sprite.bitmap.clear
    # get the background image at 'rect'
    # so that text does not appear under the icon
    bitmap = Graphics.snap_to_bitmap
    rect = Rect.new(@icon_sprite.x, @icon_sprite.x,
    @icon_sprite.bitmap.width, @icon_sprite.bitmap.height)
    @icon_sprite.bitmap.blt(x, y, bitmap, rect)
    @icon_sprite.draw_icon(icon_index, x, y)
    end
    def get_icon_index(desc)
    return nil unless @@SHOW_ICONS
    $data_items.each do |item|
    return item.icon_index if !item.nil? && item.description == desc
    end
    $data_weapons.each do |weapon|
    return weapon.icon_index if !weapon.nil? && weapon.description == desc
    end
    $data_armors.each do |armor|
    return armor.icon_index if !armor.nil? && armor.description == desc
    end
    $data_skills.each do |skill|
    return skill.icon_index if !skill.nil? && skill.description == desc
    end
    return nil
    end
    
    def update
    super
    @internal_frame_count += 1
    if ((@internal_frame_count > @@SCROLL_DELAY * 60) && @text_is_long)
    if self.ox >= (self.contents.width - self.width + 48)
    self.ox = 0
    @internal_frame_count = 0
    else
    self.ox += @@SCROLL_SPEED
    end
    end
    end def dispose
    super
    @icon_sprite.dispose
    end
    end
  6. @ shyguy0214:

    have you found a solution for your strange symbol problem?

    (since i have the same problem)
  7. This wasn't working for me, all the text was compressed and superposed in a single line. Fixed it by putting a refresh in set_text function.

    Haven't encountered that symbol problem yet. So no idea about that.

    Code
    Ruby:
    class Sprite
      # For icons only
      def draw_icon(icon_index, x, y, enabled = true)
        bitmap = Cache.system("Iconset")
        rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
        self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
      end
    end
    
    class Window_Help < Window_Base 
      @@SCROLL_DELAY = 1 # seconds
      @@SCROLL_SPEED = 2 # pixels / frame (60 frames / sec)
      @@SHOW_ICONS = false # display icons for items and skills?
      alias :scroll_init :initialize
    
      def initialize(*args)
        scroll_init(*args)
        @internal_frame_count = 0
        @text_is_long = false
        @icon_sprite = Sprite.new
        @icon_sprite.x = self.x + 16
        @icon_sprite.y = self.y + 16
        @icon_sprite.z = self.z + 1
        @icon_sprite.bitmap = Bitmap.new(32, 32)
        self.windowskin = get_altered_skin
      end 
    
      def get_altered_skin
        default = Cache.system('Window')
        window = Bitmap.new(default.width, default.height)
        window.blt(0, 0, default, default.rect)
        window.fill_rect(80, 16, 32, 32, Color.new(0,0,0,0))
        return window
      end
    
      def set_text(text, align = 0)
        unless (text == @text) && (align == @align)
          @internal_frame_count = 0
          txt_width = self.contents.text_size(text).width
          @text_is_long = txt_width > (self.width - 32)
          self.contents.dispose
          w = @text_is_long ? (txt_width + self.width - 32) : self.width - 32
          self.contents = Bitmap.new(w, self.height - 32)
          self.contents.clear
          self.ox = 0
          self.contents.font.color = normal_color
          i = get_icon_index(text)
        
          unless i.nil?
            draw_sprite(i, 0, 0)
            self.contents.draw_text(32, 0, self.contents.width, fitting_height(1), text, align)
          else
            @icon_sprite.bitmap.clear
            self.contents.draw_text(4, 0, self.contents.width, fitting_height(1), text, align)
          end
        
          @text = text
          @align = align
          refresh
        end
      end
    
      # For icons only
      def draw_sprite(icon_index, x, y)
        @icon_sprite.bitmap.clear
        # get the background image at 'rect'
        # so that text does not appear under the icon
        bitmap = Graphics.snap_to_bitmap
        rect = Rect.new(@icon_sprite.x, @icon_sprite.x,
        @icon_sprite.bitmap.width, @icon_sprite.bitmap.height)
        @icon_sprite.bitmap.blt(x, y, bitmap, rect)
        @icon_sprite.draw_icon(icon_index, x, y)
      end
      
      # For icons only
      def get_icon_index(desc)
        return nil unless @@SHOW_ICONS
        
        $data_items.each do |item|
          return item.icon_index if !item.nil? && item.description == desc
        end
        
        $data_weapons.each do |weapon|
          return weapon.icon_index if !weapon.nil? && weapon.description == desc
        end
    
        $data_armors.each do |armor|
          return armor.icon_index if !armor.nil? && armor.description == desc
        end
    
        $data_skills.each do |skill|
          return skill.icon_index if !skill.nil? && skill.description == desc
        end
        return nil
      end
    
      def update
        super
        @internal_frame_count += 1
        
        if ((@internal_frame_count > @@SCROLL_DELAY * 60) && @text_is_long)
          if self.ox >= (self.contents.width - self.width + 48)
            self.ox = 0
            @internal_frame_count = 0
          else
            self.ox += @@SCROLL_SPEED
          end
        end
      end 
      
      def dispose
        super
        @icon_sprite.dispose
      end
    end