• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Making Certain Text Scroll in the Jukebox

  • 10
    Posts
    6
    Years
    So, I haven't found anything regarding to scrolling text in Essentials. Honestly, I'm kind of picky when it comes to certain things, and for some reason, this is one of them.

    [PokeCommunity.com] Making Certain Text Scroll in the Jukebox


    This is the Jukebox from inside the Pokégear. I don't like the text squished together, so I was thinking if it was somehow possible to maybe make the text scroll from one side to another, and repeat in order prevent the text from being squished together or having longer names be cut off. Now, I could make the names shorter, but I really don't want to, but if I can't I guess I will.

    Any help would be appreciated! Thanks!



    Nevermind, I figured it out. Among various minor changes in PScreen_Jukebox, Vendily and I ended up adding some code to SpriteWindow_text.

    Code:
    class Window_CommandPokemonScroll < Window_CommandPokemon
      attr_accessor(:offset)
      def drawItem(index,count,rect)
        pbSetSystemFont(self.contents) if @starting
        rect=drawCursor(index,rect)
        if self.index==index && self.offset
          pbDrawShadowText(self.contents,rect.x-self.offset,rect.y,rect.width,rect.height,
             @commands[index],self.baseColor,self.shadowColor)
        else
          pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,
             @commands[index],self.baseColor,self.shadowColor)
        end
      end
    
      def index=(value)
        self.offset=0 # reset when index changes
        super # call the normal code
      end
      
      def update
        self.offset ||= 0 # Initialize to 0 if not set.
        tmpbitmap=BitmapWrapper.new(1,1)
        pbSetSystemFont(tmpbitmap)
        txtwidth=tmpbitmap.text_size(@commands[self.index]).width # how big of a line is it?
        self.offset += (txtwidth>=475) ? 4:0
        self.offset=0 if self.offset>txtwidth # reset when it gets to the end
        refresh2 # new refresh method
        super
      end
      
      def drawCursor(index,rect)
          return Rect.new(rect.x+16,rect.y,rect.width-16,rect.height)
      end
      
    def refresh2
        @item_max = itemCount()
        dwidth  = self.width-self.borderX
        dheight = self.height-self.borderY
        self.contents = pbDoEnsureBitmap(self.contents,dwidth,dheight)
        self.contents.fill_rect(itemRect(self.index),Color.new(50,50,255)) # Change the color to the way it was in drawCursor
        drawItem(self.index,@item_max,itemRect(self.index))
      end
    end

    The end result turned out to be...

    [PokeCommunity.com] Making Certain Text Scroll in the Jukebox


    Thanks for those that viewed, and another thanks to Vendily for helping me over at the Discord.
     
    Last edited:
    Back
    Top