O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Items & Skills Catalogue

Iniciado por LoboShow, 02/02/2013 às 20:55

02/02/2013 às 20:55 Última edição: 04/02/2013 às 16:02 por lobozero
Items & Skills Catalogue

Compativel com: RMVX
Compatibilidade: ?
Facilidade de uso: ?
Lag gerado: ?

[box class=titlebg]
Para que serve o script
[/box]
Cria catálogos para descrever itens, armas, acessórios e magias.  :wow:

[box class=titlebg]
Instruções
[/box]
Copie e cole os três scripts acima do main. Para usar o catálogo, crie um evento e use um dos códigos a seguir:

.$scene = Scene_Catalogue.new (0) - Para visualizar a descrição dos itens;
.$scene = Scene_Catalogue.new (1) - Para visualizar a descrição das armas;
.$scene = Scene_Catalogue.new (2) - Para visualizar a descrição das armaduras e escudos;
.$scene = Scene_Catalogue.new (3) - Para visualizar a descrição das magias e habilidades;
.$scene = Scene_Catalogue.new (4) - Para visualizar a descrição dos itens, armas e armaduras, todos juntos;
.$scene = Scene_Catalogue.new (5) - Para visualizar a descrição das armas e armaduras;

[box class=titlebg]
Imagens
[/box]
Spoiler
[close]

[box class=titlebg]
Scripts
[/box]
Script 1:
#==============================================================================
#    Catalogue Base
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: August 15, 2009
#                                                                              
#  Description:
#  
#    This script acts as a base script for my catalogue scripts, and it is
#   required for each of those scripts. It has a number of shared classes and
#   methods that thereby reduce unnecessary coding for those scripts.
#
#    It is, however, strictly a support script. It has no useful purpose on
#   its own.
#==============================================================================

#==============================================================================
# ** Data Catalogues
#                                                                              
#  This class handles catalogues. It's a wrapper for the built-in class Array
#==============================================================================

class Data_Catalogues
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize
    @data = []
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Catalogue
  #     catalogue_id : ID of the catalogue
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def [](catalogue_id)
    if @data[catalogue_id] == nil
      return Catalogue_Base.new
    else
      return @data[catalogue_id]
    end
  end
end

#==============================================================================
# ** Catalogue_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  This is the base to all Catalogue Groups.
#==============================================================================

class Catalogue_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :name
  attr_reader   :objects
  attr_accessor :visible_objects
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (name = 'Catalogue', objects = [], show_all = false)
    # Set variables
    @name = name
    @objects = objects
    @visible_objects = []
    @show_all = show_all
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Card
  #``````````````````````````````````````````````````````````````````````````
  #  This method returns the Card Window for a Catalogue, and should be
  # overwritten by any subclasses
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def card
    return Window_CatalogueCard
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Include?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def include? (index)
    return true
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Enable?
  #    index : the index of object in objects array
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def enable? (index)
    return true
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object (index)
    return @objects[index]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Icon
  #     index : The index of the object in objects array
  #``````````````````````````````````````````````````````````````````````````
  #  This returns an icon to show in Window_CatalogueCommand. By default, it
  # will return the output of the object method icon_index. It must be
  # overwritten if the object class has no icon_index method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object_icon (index)
    return index < @objects.size ? object (index).icon_index : 0
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Name
  #     index : The index of the object in objects array
  #``````````````````````````````````````````````````````````````````````````
  #  This returns a name to show in Window_CatalogueCommand. By default, it
  # will return the output of the object method name. It must be overwritten
  # if the object class has no name method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object_name (index)
    return index < @objects.size ? object (index).name : ''
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def object_help_text (index)
    return ''
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * C Disabled?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def c_disabled
    return true
  end
end

#==============================================================================
# ** Window Base
#                                                                              
#  Summary of Changes:
#    new method - cb_outline_rect
#==============================================================================

class Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Outline_Rect
  #    x, y, width, height : rect to outline around
  #    colour              : the colour object for this box
  #    t                   : thickness of the edges
  #    type                : 0 => rounded rectangle; 1 => rectangle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def cb_outline_rect (x, y, width, height, colour = system_color, t = 2, type = 0)
    # If fill round, check if possible
    if type == 0
      if !contents.methods.include? ("fill_rounded_rect")
        type = 1
      else
        contents.fill_rounded_rect (Rect.new (x, y, width, height), colour)
        rect = Rect.new (x   t, y   t, width - (2*t), height - (2*t))
        contents.fill_rounded_rect (rect, Color.new (0,0,0,0))
      end
    end
    # Otherwise, draw rectangle
    if type == 1
      # Draw Horizontal
      contents.fill_rect (x, y, width, t, colour)
      contents.fill_rect (x, y   height - t, width, t, colour)
      # Draw Vertical
      contents.fill_rect (x, y   t, t, height - (2*t), colour)
      contents.fill_rect (x   width - t, y   t, t, height - (2*t), colour)
    end
  end
end

#==============================================================================
# ** Window_CatalogueCard
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  This window display information on objects in the catalogue
#==============================================================================

class Window_CatalogueCard < Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize
  #    catalogue : the catalogue information this card shows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (catalogue)
    super (224, 0, Graphics.width - 224, Graphics.height - 32 - WLH)
    @catalogue = catalogue
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh (index)
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh (index = nil)
    contents.clear
    return false if index == nil
    @object = @catalogue.object (index)
  end
end

#==============================================================================
# ** Window Catalogue Label
#                                                                              
#  This window displays the name of the Catalogue
#==============================================================================

class Window_CatalogueLabel < Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (name)
    height = (Graphics.height - 96 - 2*WLH) % WLH
    height  = 32   WLH
    super (0, 0, 224, height)
    contents.font.color = system_color
    contents.draw_text (0, 0, contents.width, contents.height, name, 1)
  end
end

#==============================================================================
# ** Window Catalogue Command
#                                                                              
#  This window lists all available objects from the catalogue
#==============================================================================

class Window_CatalogueCommand < Window_Command
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (width, catalogue, *args)
    @catalogue = catalogue
    super (width, Array.new (@catalogue.visible_objects.size), 1)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Item
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def draw_item (window_index)
    # Get real object Index
    cat_index = @catalogue.visible_objects[window_index]
    enabled = @catalogue.enable? (cat_index)
    rect = item_rect(window_index)
    self.contents.clear_rect(rect)
    # Draw Icon
    draw_icon (@catalogue.object_icon (cat_index), rect.x, rect.y, enabled)
    rect.x  = 28
    rect.width -= 28
    self.contents.font.color = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @catalogue.object_name (cat_index))
  end
end

#==============================================================================
# ** Scene Title
#                                                                              
#  Summary of Changes:
#    aliased methods - load_database; load_bt_database
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdnabalg_ctlge_base_lddata_5hv9 load_database
  def load_database (*args)
    mdnabalg_ctlge_base_lddata_5hv9 (*args) # Run Original Method
    $data_catalogues = Data_Catalogues.new
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Battle Test Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias algebramodern_catalogues_btdatabselod_3hb7 load_bt_database
  def load_bt_database (*args)
    algebramodern_catalogues_btdatabselod_3hb7 (*args) # Run Original Method
    $data_catalogues = Data_Catalogues.new
  end
end

#==============================================================================
# ** Scene Catalogue
#                                                                              
#  This scene handles processing for a catalogue scene
#==============================================================================

class Scene_Catalogue < Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #    catalogue_id : the ID of the catalogue to be opened
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize(catalogue_id)
    @catalogue = $data_catalogues[catalogue_id]
    # Get all included and visible objects
    for i in 0...@catalogue.objects.size
      if @catalogue.include? (i)
        @catalogue.visible_objects.push (i)
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def start
    super
    wlh = Window_Base::WLH
    # Create Label
    @label_window = Window_CatalogueLabel.new (@catalogue.name)
    # Create Command Window
    @command_window = Window_CatalogueCommand.new (224, @catalogue)
    @command_window.height = Graphics.height - @label_window.height - 32 - wlh
    @command_window.y = @label_window.height
    @card_window = @catalogue.card.new (@catalogue)
    cat_index = @catalogue.visible_objects[0]
    @card_window.refresh (cat_index)
    @help_window = Window_Help.new
    @help_window.y = Graphics.height - 32 - wlh
    @help_window.set_text (@catalogue.object_help_text (cat_index))
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Terminate Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def terminate
    super
    @catalogue.visible_objects.clear
    # Dispose all windows
    @label_window.dispose
    @command_window.dispose
    @card_window.dispose
    @help_window.dispose
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    super
    if @command_window.active
      update_command
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Command Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update_command
    old_index = @command_window.index
    @command_window.update
    # Get catalogue index for selected object
    cat_index = @catalogue.visible_objects[@command_window.index]
    # If cursor has moved
    if old_index != @command_window.index
      # Update Card Window
      @card_window.refresh (cat_index)
      @help_window.set_text (@catalogue.object_help_text (cat_index))
    end
    if Input.trigger? (Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger? (Input::C)
      if @catalogue.c_disabled || !@catalogue.enable? (cat_index)
        Sound.play_buzzer
      else
        process_button_c
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Processing if Button C is pressed and valid
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def process_button_c
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Return Scene
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def return_scene
    $scene = Scene_Map.new
  end
end


Script 2
#==============================================================================
#  Bitmap Addons
#  Version: 1.0
#  Author: modern algebra (rmrk.net)
#  Date: February 19, 2009
#                                                                              
#  Description:
#    This is a simple scripter's tool with methods added into Bitmap for drawing
#   ellipses, as well as one for drawing a straight line. The methods it adds
#   are:
#     outline_ellipse
#     fill_ellipse
#     fill_rounded_rect
#     draw_line
#                                                                              
#  Instructions:
#    To use this, simply put it above main. For some of these, it is necessary
#   to create an ellipse object and pass it as an argument. You can create an
#   ellipse with the code:
#
#     Ellipse.new (x, y, a, b)
#       x : the top left x position
#       y : the top left y position
#       a : the width of oval from origin to the side
#       b : the height of oval from origin. If nil, then a is radius of circle
#
#   There are four new methods added to bitmap that can be used:
#
#      outline_ellipse (ellipse[, colour, width, steps])
#        ellipse : the ellipse object being drawn
#        colour  : the colour of the outline. Assumed font colour if not specified
#        width   : the thickness of the line. Assumed 1 if not specified
#        steps   : can set a number of steps for increased accuracy. If not
#                  specified, it will estimate the number of steps
#
#      fill_ellipse (ellipse[, colour, steps])
#        ellipse : the ellipse object being drawn
#        colour  : the colour of the ellipse. Assumed font colour if not specified
#        steps   : can set a number of steps for increased accuracy. If not
#                  specified, it will estimate the number of steps
#
#      fill_rounded_rect (ellipse[, colour, w)
#        ellipse : the ellipse object being drawn
#        colour  : the colour of the outline. Assumed font colour if not specified
#        w       : the number of pixels at which to round the edge.
#
#      draw_line
#        x0      : the initial x coordinate
#        y0      : the initial y coordinate
#        x1      : the end x coordinate
#        y1      : the end y coordinate
#        colour  : the colour of the outline. Assumed font colour if not specified
#==============================================================================
# ** Ellipse
#                                                                              
#  Stores an ellipse object.
#==============================================================================

class Ellipse < Rect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :h # The x position of the origin
  attr_reader   :k # The y position of the origin
  alias a width
  alias b height
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #     x : the top left x position
  #     y : the top left y position
  #     a : the width of oval from origin to the side
  #     b : the height of oval from origin. If nil, then a is radius of circle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize (x, y, a, b = nil)
    b = a if b.nil?
    super (x, y, a, b)
    @h = x   a
    @k = y   b
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Within?
  #    x : the x coordinate being tested
  #    y : the y coordinate being tested
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def within? (x, y)
    x_square = ((x - @h)*(x - @h)).to_f / (a*a)
    y_square = ((y - @k)*(y - @k)).to_f / (b*b)
    # If "radius" <= 1, then it must be within the ellipse
    return (x_square   y_square) <= 1
  end
end

#==============================================================================
# ** Bitmap
#                                                                              
#  Summary of Changes:
#    new methods - fill_ellipse, outline_ellipse, and fill_rounded_rect
#==============================================================================

class Bitmap
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Outline Ellipse
  #    ellipse : the ellipse being drawn
  #    colour  : the colour of the outline
  #    width   : the width of the bar
  #    steps   : can set a number of steps for increased or decreased accuracy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def outline_ellipse (ellipse, colour = font.color, width = 1, steps = 0)
    # For neatness, define local variables a and b to the ellipse variables
    a, b = ellipse.a, ellipse.b
    # Use Ramanujan's approximation of the Circumference of an ellipse
    steps = Math::PI*(3*(a   b) - Math.sqrt((3*a   b)*(a   3*b))) if steps == 0
    radian_modifier = (2*Math::PI) / steps
    for i in 0...steps
      t = (radian_modifier*i) % (2*Math::PI)
      # Expressed parametrically:
      #   x = h   acos(t), y = k   bsin(t) : where t ranges from 0 to 2pi
      x = (ellipse.h   (a*Math.cos(t)))
      y = (ellipse.k   (b*Math.sin(t)))
      set_pixel (x, y, colour)
    end
    # Thicken the line
    if width > 1
      ellipse = Ellipse.new (ellipse.x   1, ellipse.y   1, ellipse.a - 1, ellipse.b - 1)
      outline_ellipse (ellipse, colour, width - 1, steps)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Fill Ellipse
  #    ellipse : the ellipse being drawn
  #    colour  : the colour of the outline
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def fill_ellipse (ellipse, colour = font.color, steps = 0)
    # For neatness, define local variables a and b to the ellipse variables
    a, b = ellipse.a, ellipse.b
    # Use Ramanujan's approximation of the Circumference of an ellipse
    steps = Math::PI*(3*(a   b) - Math.sqrt((3*a   b)*(a   3*b))) if steps == 0
    radian_modifier = (2*Math::PI) / steps
    for i in 0...(steps / 2)
      t = (radian_modifier*i)
      # Expressed parametrically:
      #   x = h   acos(t), y = k   bsin(t) : where t ranges from 0 to 2pi
      x = ellipse.h   (a*Math.cos(t))
      y = ellipse.k - (b*Math.sin(t))
      fill_rect (x, y, 1, 2*(ellipse.k - y), colour)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Fill Rounded Rectangle
  #    rect    : the rectangle being drawn
  #    colour  : the colour of the outline
  #    w       : the number of pixels to cover by rounding
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  Used to fill a rectangle with rounded corners
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def fill_rounded_rect (rect, colour = font.color, w = 8)
    # Draw Body of the rectangle
    fill_rect (rect.x   w, rect.y, rect.width - 2*w, rect.height, colour)
    # Draw Left Vertical Rect
    fill_rect (rect.x, rect.y   w, w, rect.height - 2*w, colour)
    # Draw Right Vertical Rect
    x = rect.x   rect.width - w
    fill_rect (x, rect.y   w, w, rect.height - 2*w, colour)
    # Make a circle
    circle = Ellipse.new (0, 0, w)
    for i in 0...w
      for j in 0...w
        # Upper Left Corner
        set_pixel (rect.x   i, rect.y   j, colour) if circle.within? (i, j)
        # Upper Right Corner
        set_pixel (rect.x   rect.width - w   i, rect.y   j, colour) if circle.within? (i   w, j)
        # Bottom Left Corner
        set_pixel (rect.x   i, rect.y   rect.height - w   j, colour) if circle.within? (i, j   w)
        # Bottom Right Corner
        set_pixel (rect.x   rect.width - w   i, rect.y   rect.height - w   j, colour) if circle.within? (i   w, j   w)
      end
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Line
  #    x0, y0 : the coordinates of the start of the line.
  #    x1, y1 : the coordinates of the end of the line.
  #``````````````````````````````````````````````````````````````````````````
  #  This uses Bresenham's algorithm to draw a line
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def draw_line (x0, y0, x1, y1, colour = font.color)
    # Set boolean for steep lines
    steep = (y1 - y0).abs > (x1 - x0).abs
    if steep
      # Reflect across y=x
      tmp = x0
      x0, y0 = y0, tmp
      tmp = x1
      x1, y1 = y1, tmp
    end
    # If in negative direction
    if x0 > x1
      # Swap initial points
      tmp = x0
      x0, x1 = x1, tmp
      tmp = y0
      y0, y1 = y1, tmp
    end
    ystep = y0 < y1 ? 1 : -1
    deltax = x1 - x0
    deltay = (y1 - y0).abs
    error = deltax / 2
    y = y0
    # Advance by Rows
    for x in x0.to_i...x1.to_i
      steep ? set_pixel (y, x, colour) : set_pixel (x, y, colour)
      error -= deltay
      if error < 0
        y  = ystep
        error  = deltax
      end
    end
  end
end


Script 3
Aqui: http://pastebin.com/NXT60H4W

Ficou bonito nas imagens

repare o tópico
o Script 3 ficou fora da caixa de código

Realmente, pelas imagens aparenta ser bem bacana,
além de muito útil, claro. Só deve dar um trabalho bom
para configurar isso tudo hein, mas par quem busca
algo bom e não visa a dificuldade, é uma boa...


OFF

Eu coloquei o 3º script dentro da caixa "code", porém acho que
o tópico atingiu o número máximo de caracteres, daí o final do
script está imcompleto (antes também estava).
Aconselho que poste ele em algum site, como esse.

Tenta arrumar aí moço.
[close]

Spoiler
Citação de: King Gerar online 04/02/2013 às 10:17
Aconselho que poste ele em algum site, como esse.

Tenta arrumar aí moço.[/size]

[close]

Tópico arrumado. ;D