Advertisement
DrDhoom

[RGSS3] DYK Marquee v1.1

Mar 22nd, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.75 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # • Dhoom DYK Marquee v1.1
  4. # -- Last Updated: 2014.10.09
  5. # -- Level: Easy
  6. # -- Requires: None
  7. #
  8. #==============================================================================
  9.  
  10. module Dhoom
  11.   module DYKMarquee
  12.     TEXTS = [
  13.     #Put additional "\" before escape character
  14.     "You can escape most battles by holding down the \\I[116] and \\I[117] keys.",
  15.     "You can play Final Fantasy Discovery with a gamepad, and customize button input and other game options by pressing the \\I[124] key.",
  16.     "You can dash by holding down the \\I[118] key while moving.",
  17.     "Development on \\C[4]Final Fantasy Discovery\\C[0] began on May 1st, 2011.",
  18.     "There is no word for \"kupo\" in Al Bhed.",
  19.     "When starting a \\C[4]New Game Plus\\C[0] file, you'll retain most of your items, including any Al Bhed Primers you've collected.",
  20.     "It is literally impossible to defeat an Ivalician Judge. Seriously, don't try.",
  21.     "The Gold Saucer is the headquarters of the \\C[4]Gold Saucer Syndicate\\C[0], Gaia's largest private army.",
  22.     "You can follow \\C[4]Final Fantasy Discovery\\C[0] on \\I[300]\\I[301]\\I[302]! Follow \\C[4]@FFDiscovery\\C[0]!",
  23.     "Along with the development team, the RPG Maker community at large had a huge hand in developing \\C[4]Final Fantasy Discovery\\C[0].",
  24.     "William Couillard and Paul Cheung co-developed \\C[4]Final Fantasy Discovery\\C[0] from opposite ends of the United States (New York and California)!",
  25.     "Characters from Daniel Babineau's \\C[4]Final Fantasy Blackmoon Prophecy\\C[0] have a chance of appearing as opponents in the Gold Saucer's Battle Arena.",
  26.     "The Al Bhed are all born with green eyes and blonde hair.",
  27.     "Moogles and Chocobos are somehow able to verbally communicate with each other.",
  28.     "Male moogles cannot sustain flight for longer than a few seconds, whereas a female moogle's bigger wings allow for longer periods of air travel.",
  29.     "\\C[4]Final Fantasy Discovery\\C[0] has a soundtrack composed of over 100 remixed and arranged tracks, all made by fans.",
  30.     "The first public build of \\C[4]Final Fantasy Discovery\\C[0] was released on October 28th, 2012.",
  31.     "The second public build of \\C[4]Final Fantasy Discovery\\C[0] was released on May 4th, 2013 as part of RMN's \"Release Something Weekend\" community event.",
  32.     "Counting all previous versions, \\C[4]Final Fantasy Discovery\\C[0] has been downloaded over 9,000 times.",
  33.     "The \\C[4]Ogir-Yensa Sandsea\\C[0] is home to Gaia's reclusive Cactuar population.",
  34.     "\\C[4]Fisherman's Horizon\\C[0] boasts the largest population of Al Bhed on Gaia.",
  35.     "The \\C[4]Mt. Bervenia\\C[0] volcano has been dormant for the last fifty years.",
  36.     "Rumors tell of a gifted sculptress who can make her creations come to life.",
  37.     ]
  38.    
  39.     #Text scroll direction, 0 = Right to Left, 1 = Left to Right
  40.     DIRECTION = 0
  41.     #Scroll speed, higher numbers = faster scrolling
  42.     SPEED = 2
  43.     #0 = Normal Window, 1 = Dim Background, 2 = Transparent, 3 = Custom Image
  44.     BACKGROUND = 1
  45.     #Custom image filename, put it in Graphics/System folder
  46.     IMAGE_FILENAME = "DYK Backdrop"
  47.     #Dim background colors
  48.     DIM_COLOR = [[0,0,0],[0,0,0,160]]
  49.     #Window position [X,Y]
  50.     POSITION = [0,360]
  51.     #Window size [width, height]
  52.     SIZE = [640,48]
  53.     #Text font
  54.     TEXT_FONT = "Prototype"
  55.     #Text size
  56.     TEXT_SIZE = 20
  57.   end
  58. end
  59.  
  60. $imported = {} if $imported.nil?
  61. $imported["DHDYKMarquee"] = true
  62.  
  63. class Window_Marquee < Window_Base
  64.   include Dhoom::DYKMarquee
  65.   attr_accessor :background
  66.   def initialize(x, y, width, height)
  67.     super(x, y, width, height)
  68.     @background = BACKGROUND
  69.     self.arrows_visible = false
  70.     self.opacity = 0 if @background != 0
  71.     refresh
  72.   end
  73.  
  74.   def refresh
  75.     create_back_bitmap
  76.     create_back_sprite
  77.     draw_dyk_text
  78.   end
  79.  
  80.   def create_back_bitmap
  81.     if @background == 3
  82.       @back_bitmap = Cache.system(IMAGE_FILENAME)
  83.     else
  84.       @back_bitmap = Bitmap.new(width, height)
  85.       rect1 = Rect.new(0, 0, width, 12)
  86.       rect2 = Rect.new(0, 12, width, height - 24)
  87.       rect3 = Rect.new(0, height - 12, width, 12)    
  88.       back_color1 = Color.new(DIM_COLOR[0][0],DIM_COLOR[0][1],DIM_COLOR[0][2],!DIM_COLOR[0][3].nil? ? DIM_COLOR[0][3] : 255)
  89.       back_color2 = Color.new(DIM_COLOR[1][0],DIM_COLOR[1][1],DIM_COLOR[1][2],!DIM_COLOR[1][3].nil? ? DIM_COLOR[1][3] : 255)
  90.       @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
  91.       @back_bitmap.fill_rect(rect2, back_color1)
  92.       @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  93.     end
  94.   end
  95.  
  96.   def create_back_sprite
  97.     @back_sprite = Sprite.new
  98.     @back_sprite.bitmap = @back_bitmap
  99.     update_back_sprite
  100.   end
  101.  
  102.   def draw_dyk_text
  103.     random = rand(TEXTS.size)
  104.     text = convert_escape_characters(TEXTS[random])
  105.     dyk_reset_font_settings
  106.     w = contents.text_size(text)
  107.     create_contents([w.width, contents_height])
  108.     dyk_reset_font_settings
  109.     draw_text_ex(0, 0, TEXTS[random])
  110.     self.ox =  -(self.width - contents.width) if DIRECTION == 0
  111.   end
  112.  
  113.   def create_contents(rect = [])    
  114.     contents.dispose
  115.     if rect.empty?
  116.       if contents_width > 0 && contents_height > 0
  117.         self.contents = Bitmap.new(contents_width, contents_height)
  118.       else
  119.         self.contents = Bitmap.new(1, 1)
  120.       end
  121.     else
  122.       self.contents = Bitmap.new(rect[0], rect[1])
  123.     end
  124.     contents.sfont = $sfont[0] if $imported[:ve_sfonts] && VE_ALL_SFONT
  125.   end
  126.  
  127.   def dyk_reset_font_settings
  128.     change_color(normal_color)
  129.     contents.font = Font.new(TEXT_FONT)
  130.     contents.font.size = TEXT_SIZE
  131.     contents.font.bold = Font.default_bold
  132.     contents.font.italic = Font.default_italic
  133.   end
  134.  
  135.   def process_draw_icon(icon_index, pos)
  136.     draw_icon(icon_index, pos[:x], pos[:y]+(contents.font.size-24)/2)
  137.     pos[:x] += 24
  138.   end
  139.  
  140.   def update
  141.     super
  142.     update_back_sprite
  143.     update_scroll
  144.   end
  145.  
  146.   def update_back_sprite
  147.     @back_sprite.visible = [1,3].include?(@background)
  148.     @back_sprite.z = z - 1
  149.     @back_sprite.x = x
  150.     @back_sprite.y = y
  151.   end
  152.  
  153.   def update_scroll
  154.     if DIRECTION == 0
  155.       self.ox += SPEED
  156.       if self.ox >= contents.width
  157.         self.ox = -self.width
  158.       end
  159.     else      
  160.       self.ox -= SPEED
  161.       if self.ox <= -self.width
  162.         self.ox = contents.width
  163.       end
  164.     end
  165.   end
  166.  
  167.   def dispose
  168.     super
  169.     @back_sprite.dispose
  170.   end
  171. end
  172.  
  173. class Scene_Title < Scene_Base
  174.   include Dhoom::DYKMarquee
  175.   alias dhoom_marquee_scntitle_start start
  176.   def start
  177.     dhoom_marquee_scntitle_start
  178.     @marquee_window = Window_Marquee.new(POSITION[0], POSITION[1], SIZE[0], SIZE[1])
  179.   end
  180. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement