Isto é uma pré-visualização de um tema em Hitskin.com
Instalar o tema • Voltar para a ficha do tema
Botão com estilo do windows
2 participantes
Aldeia RPG :: RPG Maker :: Rpg Maker XP :: Netplays :: Scripts para netplays
Página 1 de 1
Botão com estilo do windows
Fiz uma modificação meio inútil aqui e resolvi postar pois ela pode ser modificada para aceitar outras imagens e tal.
Screen:
Imagens necessárias:
https://imgur.com/QCF4w1V,qcbNeoX
Screen:
- Spoiler:
- 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
_________________
Re: Botão com estilo do windows
Interessante obrigado por compartilhar +1 Credit.
_________________
Paga um café? Patreon
Komuro Takashi- Colaborador
- Mensagens : 1047
Créditos : 130
Aldeia RPG :: RPG Maker :: Rpg Maker XP :: Netplays :: Scripts para netplays
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos
|
|