Aldeia RPG

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Suporte ao desenvolvimento de jogos


2 participantes

    Botão com estilo do windows

    Paulo Soreto
    Paulo Soreto
    Lenda
    Lenda


    Mensagens : 1980
    Créditos : 367

    Ficha do personagem
    Nível: 1
    Experiência:
    Botão com estilo do windows Left_bar_bleue0/0Botão com estilo do windows Empty_bar_bleue  (0/0)
    Vida:
    Botão com estilo do windows Left_bar_bleue30/30Botão com estilo do windows Empty_bar_bleue  (30/30)

    Botão com estilo do windows Empty Botão com estilo do windows

    Mensagem por Paulo Soreto Qua Fev 06, 2013 12:08 pm

    Fiz uma modificação meio inútil aqui e resolvi postar pois ela pode ser modificada para aceitar outras imagens e tal.
    Screen:
    Spoiler:
    Code:
    Código:
    #==============================================================================
    # ** Button - This class is used to create buttons.
    #------------------------------------------------------------------------------
    # Author    Trebor777
    # Modified  Valentine
    # Version  2.0
    #==============================================================================
    class Button < Widget
      attr_accessor :mask
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize(win,x,y,text,id=0,widgetid=0,chatid=0,&block)
        super(win,x,y)
        @text = text
        @block = block
        @chatid = chatid
        @id = id
        @widgetid = widgetid
        refresh
      end
      #--------------------------------------------------------------------------
      # Draw the button text, and create the mask.
      #--------------------------------------------------------------------------
      def refresh
        b = Bitmap.new(4,4)
        if not @id == 2
          b.font.size = 16
          if @id == 3
            cx = 54
          else
            cx = b.text_size(@text).width
          end
        else
          cx = 104
        end
        b.dispose
        s.bitmap = Bitmap.new(cx+10, 20)
        s.bitmap.font.color = Color.new(0,0,0,255)
        s.bitmap.font.size = 16 if not @id == 2
        @mask = Sprite.new(win.viewport)
        @mask.x=s.x
        @mask.y=s.y
        if @chatid == $chat_id
          @mask.visible=true
        else
          @mask.visible=false
        end
        @mask.z = 5000
        @mask.bitmap=Bitmap.new(s.bitmap.width,s.bitmap.height)
        #@mask.bitmap.fill_rect(0, 0, @s.bitmap.width, @s.bitmap.height, Window_Edits::Button_ColorSkin_Start)
        mask = RPG::Cache.picture('mask4')
        rect3 = Rect.new(0, 0, s.bitmap.width - 4, mask.height)
        @mask.bitmap.blt(0, 0, mask, rect3)
        rect4 = Rect.new(mask.width - 4, 0, 4, mask.height)
        @mask.bitmap.blt(s.bitmap.width - 4, 0, mask, rect4)
        @mask.bitmap.draw_text(0, 0, @s.bitmap.width, s.bitmap.height, @text, 1)
        @mask.opacity = 120
        s.bitmap.clear
        back = RPG::Cache.picture('button4')
        rect = Rect.new(0, 0, s.bitmap.width - 4, back.height)
        s.bitmap.blt(0, 0, back, rect)
        rect2 = Rect.new(back.width - 4, 0, 4, back.height)
        s.bitmap.blt(s.bitmap.width - 4, 0, back, rect2)
        s.bitmap.font.color = Color.new(0, 0, 0)
        #s.bitmap.font.color = Color.new(168, 168,  168)
        s.bitmap.font.size = 13
        s.bitmap.draw_text(0, 0, @s.bitmap.width, s.bitmap.height, @text, 1)
      end
      #--------------------------------------------------------------------------
      # Dispose the mask, and itself
      #--------------------------------------------------------------------------
      def dispose
        @mask.dispose
        super
      end
      #--------------------------------------------------------------------------
      # Frame update, check the mask status, and active status
      #--------------------------------------------------------------------------
      def update
        @mask.visible= false if @mask.visible and !visible
        if visible
          @mask.x=s.x if @mask.x != s.x
          @mask.y=s.y if @mask.y != s.y
          @mask.update
          if in_area? or @chatid == $chat_id
            @mask.visible=true
          else
            @mask.visible=false
          end
          self.active=false if self.active
          s.opacity = Window_Edits::Button_Active_Opacity  if s.opacity<Window_Edits::Button_Active_Opacity
        end
        if win!=nil
          x= s.x
          y= s.y
          s.visible = win.visible
        end
        if (Input.pressed(Input::Mouse_Left) and in_area? and s.visible and @widgetid == 1) or (Input.trigger(Input::Mouse_Left) and in_area? and s.visible and @widgetid != 1)
          @active=true
          win.active = true
          clicked
          return
        elsif Input.trigger(Input::Mouse_Left) and !in_area? and s.visible
          @active=false
          outclick
          return
        end
        #super
      end
      #--------------------------------------------------------------------------
      # Change the button opacity when clicked
      #--------------------------------------------------------------------------
      def clicked
        #$game_system.se_play($data_system.decision_se)
        s.opacity -= Window_Edits::Button_Not_Active_Opacity if s.opacity==Window_Edits::Button_Active_Opacity
        if @block != nil
          @block.call
        else
        self.active = true
        end
      end
      #--------------------------------------------------------------------------
      # Visible
      #--------------------------------------------------------------------------
      def visible=(v)
        @mask.visible=v if @mask != nil
        s.visible = v if s != nil
      end
    end

    Imagens necessárias:
    https://imgur.com/QCF4w1V,qcbNeoX


    _________________
    Botão com estilo do windows FwYnoXI
    Komuro Takashi
    Komuro Takashi
    Colaborador
    Colaborador


    Mensagens : 1047
    Créditos : 130

    Botão com estilo do windows Empty Re: Botão com estilo do windows

    Mensagem por Komuro Takashi Qua Fev 06, 2013 12:13 pm

    Interessante obrigado por compartilhar Very Happy +1 Credit.


    _________________
    Botão com estilo do windows Takashi_komuro_by_minato8-d51g9o4

    Paga um café? Patreon

      Data/hora atual: Qui Mar 28, 2024 10:52 am