Uma janela como videogames clássicos sim / não
Eu criei este roteiro há muito tempo para um dos meus menus e qualquer outro projeto. É muito flexível
e pode ser utilizado para uma série de coisas. Ele usa uma janela modificada + combinação de sprite
Porque eu acho que fica melhor, de qualquer forma, você pode modificá-lo ou fazer o que quiser.
-A dimensão e posição da janela é baseada no tamanho do texto.
-Autocenter na tela se nenhuma posição especificada.
-Todos os outros tamanhos ou posições são definidas automaticamente.
-Você pode definir o índice padrão utilizado e alguns outros valores.
-Ele tem métodos para automaticamente visíveis / invisíveis, dispor, esconder, etc, todos os sprites
e janelas.
-Você pode adicionar uma pergunta a ele. Com este uma versão modificada de um comando da janela
é ativado.
-Você pode alterar o texto, pergunte opção, X e Y, em cada chamada.
-Você pode usá-lo para fins múltiplos em uma cena signle. Por que você tem que
changue o valor que especifica message_type wich das formas de ser utilizada
é agora.
Screen:
- Spoiler:
- está em Espanhol porque foi um amigo Gringo meu que tirou a screen^^ e criou o script^^
- Código:
#==============================================================================
# Warning message
# By gerkrt/gerrtunk
# Version: 1.3
# License: MIT, credits
# Visit this for my other scripts and updates: [url]http://pastebin.com/u/gerkrt[/url]
#==============================================================================
=begin
Características:
Eu criei este roteiro há muito tempo para um dos meus menus e qualquer outro projeto. É muito flexível
e pode ser utilizado para uma série de coisas. Ele usa uma janela modificada + combinação de sprite
Porque eu acho que fica melhor, de qualquer forma, você pode modificá-lo ou fazer o que quiser.
-A dimensão e posição da janela é baseada no tamanho do texto.
-Autocenter na tela se nenhuma posição especificada.
-Todos os outros tamanhos ou posições são definidas automaticamente.
-Você pode definir o índice padrão utilizado e alguns outros valores.
-Ele tem métodos para automaticamente visíveis / invisíveis, dispor, esconder, etc, todos os sprites
e janelas.
-Você pode adicionar uma pergunta a ele. Com este uma versão modificada de um comando da janela
é ativado.
-Você pode alterar o texto, pergunte opção, X e Y, em cada chamada.
-Você pode usá-lo para fins múltiplos em uma única cena. Por que você tem que
changue the message_type value that specifies wich of the ways of being used
is now. For example:
@warning_message.refresh('Are you sure to exit?')
@warning_message.message_type = :asking_for exit.
Note that you can also pass that ass a extra parameter for the refresh method.
=end
class Warning_Message
@@default_x = 200
@@default_y = 200
@@default_z = 200
@@selection_options = ["Si", "No"]
@@default_option = 1
@@default_message_type = :normal
attr_accessor :message_type # Use isso para diferentes usos na mesma cena.
attr_accessor :active # Isto especifica se todos a janela está ativa ou não
def initialize()
@message_type = @@default_message_type # Default value for the basic option.
@active = false
# Default values when refreshing it
@default_x = 200
@default_y = 200
# Back text window. This is used only as a back window to simulate rpgmaker ones.
@text_window = Window_Base.new(120, 136, 400, 64)
@text_window.z = 252
@text_window.visible = false
# Text sprite. The text where is drawn the refreshed text.
@text_sprite = Sprite.new
@text_sprite.z = 254
@text_sprite.x = 120
@text_sprite.y = 136
@text_sprite.bitmap = Bitmap.new(400,64)
# Testing bitmap for size test
@testing_bitmap = Bitmap.new(1,1)
# Question window. A modified version of window command its wich have the
# yes/no options.
@question_window = Window_Selection.new(80, @@selection_options)
@question_window.x = 280
@question_window.y = 200
@question_window.z = 253
@question_window.index = @@default_option
@question_window.back_opacity = 0
@question_window.opacity = 0
@question_window.active = false
@question_window.visible = false
# Back question window. Used to simulate the rpgmaker back window.
@back_question_window = Window_Base.new(120, 136, 64, 64)
@back_question_window.x = 280
@back_question_window.y = 200
@back_question_window.z = 254
@back_question_window.visible = false
end
# Make all the sprites/windows visibles
def visible
@text_window.visible = true
@text_sprite.visible = true
# Question ones only if active
if @question_window.active
@question_window.visible = true
@back_question_window.visible = true
end
end
# Make all the sprites/windows invisibles
def no_visible
@text_window.visible = false
@text_sprite.visible = false
@question_window.visible = false
@back_question_window.visible = false
end
# Is question window active?. Only works for the yes/no option.
def question_active
return @question_window.active
end
# Set question window active. Only works for the yes/no option.
def question_active=(value)
@question_window.active = value
end
# Update all the sprites/windows visibles
def update
@text_window.update
@text_sprite.update
@back_question_window.update
@question_window.update
end
# Get if yes or no when using two options
def is_Yes?
if @question_window.index == 0
true
else
false
end
end
# Get question index
def index
@question_window.index
end
# Set question index
def index=(value)
@question_window.index = value
end
# Desenhe a mensagem de aviso. Você tem que usar esse método para mostrar a janela
# mensagem de mudança de cada vez. Note que você pode alterar as opções padrão e
# também especificar diretamente o tipo de mensagem diretamente aqui.
# pergunta: chamado para adicionar um sim / não janela.
def refresh(message, question=true, message_type=@@default_message_type, x=@default_x,
y=@default_y)
# Basic position settings
@text_window.y = y
@text_window.x = x
@text_sprite.x = x
@text_sprite.y = y
rect = @testing_bitmap.text_size(message)
@active = true
# With question window or not. All the positions auto-setting are done here.
if question
@question_window.active = true
@text_window.width = rect.width+26+40
#@question_window.visible = true
@question_window.active = true
@question_window.index == @@default_option
#@back_question_window.visible = true
@question_window.x = @text_window.x+rect.width+4+6
@question_window.y = @text_window.y - 16
@back_question_window.x = @text_window.x+rect.width+4+16
@back_question_window.y = @text_window.y
else
@text_window.width = rect.width+26
end
@message_type = message_type
visible
# First update the back window
@text_window.update
@text_sprite.bitmap.clear
# Draw text
@text_sprite.bitmap.draw_text(0+10,0,400,64,message, 0)
@text_sprite.update
end
# Hide window and make inactive all. Use this to stop using the message each
# time
def hide
no_visible
@active = false
@question_window.active = false
end
# Dispose all the sprites/windows visibles
def dispose
@text_window.dispose
@text_sprite.dispose
@question_window.dispose
@back_question_window.dispose
end
end
# Modified to shown horizontal.
class Window_Selection < Window_Command
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
# If cursor position is less than 0
if @index < 0
self.cursor_rect.empty
return
end
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = (self.width / @column_max - 32)+11
# Calculate cursor coordinates
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 32 - self.oy
# Update cursor rectangle
self.cursor_rect.set(x-4, y, cursor_width, 32)
end
end
Créditos:
Gerkrkt- Por Criar
Leandro(Eu) - Por traduzir o tópico+script e disponibilizar para vcs^^