This is all I have to say:
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#==============================================================================
# Frame
#------------------------------------------------------------------------------
# Represents an advanced sprite class. It is lighter than a window and avoids
# usage of window specific additions that cannot be turned off. This class is
# abstract and should not be instanciated as such.
#==============================================================================
class Frame < Sprite
# constants
BORDER_COLOR = Color.new(255, 255, 255, 160)
BACK_COLOR = Color.new(0, 0, 0, 160)
# setting all accessible variables
attr_accessor :active
attr_reader :width
attr_reader :height
#----------------------------------------------------------------------------
# Initialization.
# x - x coordinate
# y - y coordinate
# width - width of the sprite
# height - height of the sprite
#----------------------------------------------------------------------------
def initialize(x, y, width, height)
# create the actual sprite
super()
# set dimensions
@width = width
@height = height
# create background sprite
create_background_sprite
# set position
self.x, self.y, self.z = x, y, 1000
# store variables
@active = true
end
#----------------------------------------------------------------------------
# Creates a background sprite.
#----------------------------------------------------------------------------
def create_background_sprite
# create background sprite
@background = Sprite.new
create_background_bitmap
end
#----------------------------------------------------------------------------
# Creates the background bitmap.
#----------------------------------------------------------------------------
def create_background_bitmap
@background.bitmap = Bitmap.new(@width, @height)
@background.bitmap.fill_rect(0, 0, @width, @height, BORDER_COLOR)
@background.bitmap.fill_rect(1, 1, @width - 2, @height - 2, BACK_COLOR)
end
#----------------------------------------------------------------------------
# Updates the background sprite.
#----------------------------------------------------------------------------
def update_background
@background.x, @background.y, @background.z = self.x, self.y, self.z - 100
end
#----------------------------------------------------------------------------
# Changes the sprite width.
# value - new width
#----------------------------------------------------------------------------
def width=(value)
# if width had changed
if @width != value
# delete old bitmap
@background.bitmap.dispose if @background.bitmap != nil
@width = value
# create new background bitmap
create_background_bitmap
end
end
#----------------------------------------------------------------------------
# Changes the sprite height.
# value - new height
#----------------------------------------------------------------------------
def height=(value)
# if width had changed
if @height != value
# delete old bitmap
@background.bitmap.dispose if @background.bitmap != nil
@height = value
# create new background bitmap
create_background_bitmap
end
end
#----------------------------------------------------------------------------
# Changes sprite x.
# value - new x coordinate
#----------------------------------------------------------------------------
def x=(value)
super
update_background
end
#----------------------------------------------------------------------------
# Changes sprite y.
# value - new y coordinate
#----------------------------------------------------------------------------
def y=(value)
super
update_background
end
#----------------------------------------------------------------------------
# Changes sprite z.
# value - new z coordinate
#----------------------------------------------------------------------------
def z=(value)
super
update_background
end
#----------------------------------------------------------------------------
# Refreshes the display. Abstract method.
#----------------------------------------------------------------------------
def refresh
end
#----------------------------------------------------------------------------
# Disposes the additional background sprite.
#----------------------------------------------------------------------------
def dispose
@background.dispose
super
end
end
#==============================================================================
# Frame
#------------------------------------------------------------------------------
# Represents an advanced sprite class. It is lighter than a window and avoids
# usage of window specific additions that cannot be turned off. This class is
# abstract and should not be instanciated as such.
#==============================================================================
class Frame < Sprite
attr_reader :viewport
# mod to add viewport handeling
alias viewport_addition_init initialize
def initialize(x, y, width, height, viewport = nil)
# create the actual sprite
if viewport.is_a?(Viewport)
super(viewport)
@viewport = viewport
@width = width
@height = height
# create background sprite
create_background_sprite
# set position
self.x, self.y, self.z = x, y, 1000
# store variables
else
viewport_addition_init(x, y, width, height)
end
end
alias viewport_addition_cbs create_background_sprite
def create_background_sprite
# create background sprite
if @viewport.is_a?(Viewport)
@background = Sprite.new(@viewport)
create_background_bitmap
else
viewport_addition_cbs
end
end
def visable=(value)
super
@background.visable = value if @background != nil && !@background.disposed?
end
end
if vertical
y_off = 0
text.each_char do |c|
rect = text_size(c)
rect.x = x
rect.y = y + y_off
draw_text(rect, c, align)
y_off += rect.height
end
end
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Bitmap
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Bitmap
def gradient_fill_rect(*args)
if args[0].is_a?(Rect)
x, y, width, height = args[0].x, args[0].y, args[0].width, args[0].height
color1 = args[1].dup
color2 = args[2]
vertical = args[3]
else
x, y, width, height = args[0..3]
color1 = args[4].dup
color2 = args[5]
vertical = args[6]
end
dr = color2.red - color1.red
dg = color2.green - color1.green
db = color2.blue - color1.blue
da = color2.alpha - color1.alpha
start_rgba = [color1.red, color1.green, color1.blue, color1.alpha]
if vertical
dr, dg, db, da = dr / height, dg / height, db / height, da / height
(y...(y + height)).each do |i|
fill_rect(x, i, width, 1, color1)
start_rgba[0] = [start_rgba[0] + dr, 0].max
start_rgba[1] = [start_rgba[1] + dg, 0].max
start_rgba[2] = [start_rgba[2] + db, 0].max
start_rgba[3] = [start_rgba[3] + da, 0].max
color1.set(*start_rgba)
end
else
dr, dg, db, da = dr / width, dg / width, db / width, da / width
(x...(x + width)).each do |i|
fill_rect(i, y, 1, height, color1)
start_rgba[0] = [start_rgba[0] + dr, 0].max
start_rgba[1] = [start_rgba[1] + dg, 0].max
start_rgba[2] = [start_rgba[2] + db, 0].max
start_rgba[3] = [start_rgba[3] + da, 0].max
color1.set(*start_rgba)
end
end
end
def gradient_draw_text(*args)
is_rect = args[0].is_a?(Rect)
x = is_rect ? args[0].x : args[0]
y = is_rect ? args[0].y : args[1]
w = is_rect ? args[0].width : args[2]
h = is_rect ? args[0].height : args[3]
text = is_rect ? args[1].to_s : args[4].to_s
color1 = is_rect ? args[2] : args[5]
color2 = is_rect ? args[3] : args[6]
align = is_rect ? args[4] : args[7]
vertical = is_rect ? args[5] : args[8]
align = 0 if !align
vertical = false if !vertical
text_bmp = Bitmap.new(w, h)
text_bmp.font.name = font.name
text_bmp.font.size = font.size
text_bmp.font.bold = font.bold
text_bmp.font.italic = font.italic
text_bmp.font.outline = font.outline
text_bmp.font.shadow = font.shadow
text_bmp.font.out_color = font.out_color
text_bmp.draw_text(0, 0, w, h, text, align)
gradient_bmp = Bitmap.new(w, h)
gradient_bmp.gradient_fill_rect(0, 0, w, h, color1, color2, vertical)
w.times do |x2|
h.times do |y2|
alpha_txt = text_bmp.get_pixel(x2, y2).alpha
if alpha_txt > 0
c = gradient_bmp.get_pixel(x2, y2)
c.alpha = alpha_txt
text_bmp.set_pixel(x2, y2, c)
end
end
end
draw_text(x, y, w, h, text.to_s, align)
blt(x, y, text_bmp, Rect.new(0, 0, w, h))
end
end
QuoteOur client is looking for a well-rounded Quality Assurance Automation Engineer that is familiar with the growing technology landscape and desires to contribute in a fast-paced, web-oriented environment. This position requires a strong analytical sense combined with a dynamic, creative approach. You will be responsible for creating and executing plans and procedures used to ensure high levels of quality for complex, consumer-oriented, web-based applications.
Quote from: Heretic86 on October 09, 2013, 06:55:36 pm
Doesnt matter if God is real or not, the very core of Religion is for People to control Other People. Views expressed by Men do not necessarily reflect the opinion of God, and we all know how much Men like to lie to achieve what they want.
Quote from: KK20 on October 04, 2013, 12:30:29 am
Precisely. I'm guessing you thought @data would be an array of Symbols, and, each time you pushed a new Sprite_TitleCommand in (which would call an update method to change its position), you thought the array's size would increase by one, effectively putting each new sprite below the previous.
class Scene_Title < Scene_Base
def create_command_sprites
@commands = []; index = 0
WarriorManager::TITLE_COMMANDS.each do |command|
case command
when :new_game, :continue, :manual, :website, :shutdown
when :new_game_plus then next unless new_game_plus?
else next
end
@commands << Sprite_TitleCommand.new(nil, command, index)
index += 1
end
end
end
class Sprite_TitleCommand < Sprite_CommandBase
def initialize(viewport, data, index)
@item_draw_index = index
...
super(viewport, data)
end
...
def update_position
@org_pos = [Graphics.width / 2, (26 * @item_draw_index) + 200]
...
end
end
Quote from: KK20 on May 17, 2013, 02:18:25 pm
Not to mention, the method 'max_by' doesn't even exist in Ruby 1.8.1, which I believe is the version RMXP uses.