Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- This little snippet will let you add images to any text which is processed with
- the draw_text_ex method in any windows (such as the description texts).
- To display an image, use this message code:
- \IMG[filename]
- Replace filename with the name of the image you want to display.
- The image must be in the project's "Graphics/Pictures/" folder!
- Additionally, you can use another message code to set the X position of the
- text manually. Whenever a new line starts in your text, it will start on this
- X position instead of starting from the top-left side like it does by default.
- The message code for this:
- \LX[value]
- Replace value with the line's starting X position in pixels.
- Made by: Sixth
- =end
- class Window_Base < Window
- alias add_iimgs8825 process_escape_character
- def process_escape_character(code, text, pos)
- case code.upcase
- when 'IMG'
- text.sub!(/\[(.*?)\]/i,"")
- draw_img($1,pos)
- when 'LX'
- text.sub!(/\[(.*?)\]/i,"")
- pos[:new_x] = $1.to_i
- else
- add_iimgs8825(code, text, pos)
- end
- end
- def draw_img(img,pos)
- bmp = Cache.picture(img)
- rct = Rect.new(0,0,bmp.width,bmp.height)
- contents.blt(pos[:x],pos[:y],bmp,rct,255)
- pos[:x] += bmp.width
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement