Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- #
- # • Dhoom DYK Marquee v1.0
- # -- Last Updated: 2014.10.09
- # -- Level: Easy
- # -- Requires: None
- #
- #==============================================================================
- module Dhoom
- module DYKMarquee
- TEXTS = [
- #Put additional "\" before escape character
- "\\I[5] this is confusion icon",
- "\\N[1] is the \\C[2]first actor\\C[0] in database",
- ]
- #Text scroll direction, 0 = Right to Left, 1 = Left to Right
- DIRECTION = 0
- #Scroll speed
- SPEED = 1
- #0 = Normal Window, 1 = Dim Background, 2 = Transparent, 3 = Custom Image
- BACKGROUND = 0
- #Custom image filename, put it in Graphics/System folder
- IMAGE_FILENAME = "Window"
- #Dim background colors
- DIM_COLOR = [[0,0,0],[0,0,0,160]]
- #Window position [X,Y]
- POSITION = [0,0]
- #Window size [width, height]
- SIZE = [544,48]
- #Text font
- TEXT_FONT = "Comic Sans MS"
- #Text size
- TEXT_SIZE = 28
- end
- end
- $imported = {} if $imported.nil?
- $imported["DHDYKMarquee"] = true
- class Window_Marquee < Window_Base
- include Dhoom::DYKMarquee
- attr_accessor :background
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @background = BACKGROUND
- self.arrows_visible = false
- self.opacity = 0 if @background != 0
- refresh
- end
- def refresh
- create_back_bitmap
- create_back_sprite
- draw_dyk_text
- end
- def create_back_bitmap
- if @background == 3
- @back_bitmap = Cache.system(IMAGE_FILENAME)
- else
- @back_bitmap = Bitmap.new(width, height)
- rect1 = Rect.new(0, 0, width, 12)
- rect2 = Rect.new(0, 12, width, height - 24)
- rect3 = Rect.new(0, height - 12, width, 12)
- 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)
- 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)
- @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
- @back_bitmap.fill_rect(rect2, back_color1)
- @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
- end
- end
- def create_back_sprite
- @back_sprite = Sprite.new
- @back_sprite.bitmap = @back_bitmap
- update_back_sprite
- end
- def draw_dyk_text
- random = rand(TEXTS.size)
- text = convert_escape_characters(TEXTS[random])
- reset_font_settings
- w = contents.text_size(text)
- contents.dispose
- self.contents = Bitmap.new(w.width, contents_height)
- reset_font_settings
- draw_text_ex(0, 0, TEXTS[random])
- self.ox = -(self.width-contents.width) if DIRECTION == 0
- end
- def reset_font_settings
- change_color(normal_color)
- contents.font = Font.new(TEXT_FONT)
- contents.font.size = TEXT_SIZE
- contents.font.bold = Font.default_bold
- contents.font.italic = Font.default_italic
- end
- def process_draw_icon(icon_index, pos)
- draw_icon(icon_index, pos[:x], pos[:y]+(contents.font.size-24)/2)
- pos[:x] += 24
- end
- def update
- super
- update_back_sprite
- update_scroll
- end
- def update_back_sprite
- @back_sprite.visible = [1,3].include?(@background)
- @back_sprite.z = z - 1
- @back_sprite.x = x
- @back_sprite.y = y
- end
- def update_scroll
- if DIRECTION == 0
- self.ox += SPEED
- if self.ox >= contents.width
- self.ox = -self.width
- end
- else
- self.ox -= SPEED
- if self.ox <= -self.width
- self.ox = contents.width
- end
- end
- end
- def dispose
- super
- @back_sprite.dispose
- end
- end
- class Scene_Title < Scene_Base
- include Dhoom::DYKMarquee
- alias dhoom_marquee_scntitle_start start
- def start
- dhoom_marquee_scntitle_start
- @marquee_window = Window_Marquee.new(POSITION[0], POSITION[1], SIZE[0], SIZE[1])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement