ФИО студента: Elf De
ad
79
Билет № ███
Вопросы:
1. Нужен скрипт на пароли?
2. Есть скрипт квеста и нужно превратить его в скрипт почты и/или сделать второй скрипт на его основе и назвать его "Почта"?
3. "Почта" должна быть привязана к разным компьютерам разная? Хм... На манер дата-кубов, что ли?...
Решения:
1. Можно спросить у дарчана:
вот он, у него в
проекте было что-то подобное.
2. Вопрос: зачем? Можно, конечно, но решение третьего вопроса может показаться более интересным.
3. Почему бы не использовать специальное окошко, которое будет читать текст, допустим, из файла и показывать его?
Вот пример (на ХП, но на эйсе тоже может пойти):
#===============================================================================
# * Window Browser
# * by DeadElf79
#-------------------------------------------------------------------------------
# Version: 1.1
# Last change data: 24.01.2013
# Read *.txt file and view in window
# Useful for menu as like 'Authors' or 'About'
# Text file MUST be saved as UTF-8 format
=begin
Version history:
1.1 - Features - can analys text from file
and turn on parametrs like a Window_Message!
1.0 - start release. Features - can view text from file
=end
#===============================================================================
#-------------------------------------------------------------------------------
# Begin Window_Browser
#-------------------------------------------------------------------------------
class Window_Browser <Window_Base
attr_reader :scroll
attr_accessor :line
attr_reader :array
def initialize(filename,system=100)
super(0,64,640,480-64)
self.contents=Bitmap.new(width - 32, height - 32)
self.back_opacity=128
self.contents.font.name='Archangelsk'
@filename=filename
@line=0
@scroll=Sprite.new
@scroll.bitmap=Bitmap.new(32,96)
@scroll.visible=false
@scroll.z=self.z+1
@scroll.x=640-64
@scroll.oy=48
@scroll.y=224
case system
when "Ogle.net", "Ogle", 0
@dir="Ogle.net"
when "Rune", "Rune Society", 1
@dir="Rune"
when "Andex", 2
@dir="Andex"
else
@dir=""
end
read_file
refresh
end
def read_file
if @dir!=nil
if FileTest.exist?("Data/"+@dir+"/"+@filename)==nil
p "File Data/"+@dir+"/"+@filename+" doesn't exist!"
else
@file=File.open("Data/"+@dir+"/"+@filename)
end
else
if FileTest.exist?(@filename)==nil
p "File "+@filename+" doesn't exist!"
else
@file=File.open(@filename)
end
end
@array=[]
@array=@file.readlines
if @array.size*20>self.height
set_scroll_gfx
@scroll.visible=true
end
end
alias bro_dispose dispose
def dispose
@scroll.bitmap.dispose
@scroll.dispose
bro_dispose
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
read_file
if @filename[/\\system/]!=nil
#Если использована специальная возможность открытия нестандартного
#текстового файла, то включаем режим работы с системой
#К сожалению, я пока не умею этого делать
else
#ВАА! Теперь есть анализ строк из стандартной системы
#сообщений! Это дает такой простор оформления!
for i in @line..@line+self.max_lines
if @array[i]!=nil then
analysis(@array[i],i-@line)
else
break
end
end
#Еще добавим небольшую фичу - просмотр, сколько строк уже прочитано
self.contents.font.color=Color.new(128,128,128,255)
if @scroll.visible==true
a=@line
b=@array.size+1-self.max_lines
self.contents.draw_text(self.width-100,self.height-96,64,64,a.to_s+"/"+b.to_s)
end
end
end
def analysis(mystring,line)
x = 0
y=line
@cursor_width = 0
text = mystring.clone
# Control text processing
begin
last_text = text.clone
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until text == last_text
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
# Change "\\\\" to "\000" for convenience
text.gsub!(/\\\\/) { "\000" }
# Change "\\C" to "\001" and "\\G" to "\002"
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
text.gsub!(/\\[Gg]/) { "\002" }
# Get 1 text character in c (loop until unable to get text)
while ((c = text.slice!(/./m)) != nil)
# If \\
if c == "\000"
# Return to original text
c = "\\"
end
# If \C[n]
if c == "\001"
# Change text color
text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
# go to next text
next
end
self.contents.draw_text(x, 32 * y, 40, 32, c)
# Add x to drawn text width
x += self.contents.text_size(c).width
end
end
def max_lines
return self.height/32
end
def set_scroll_gfx
@temp1=Sprite.new
@temp1.bitmap=Bitmap.new("Graphics/Pictures/button_Up")
@scroll.snapshot(@temp1.bitmap,Rect.new(0,0,32,32),Rect.new(0,0,32,32))
@temp1.bitmap.dispose
@temp1.dispose
@temp1=Sprite.new
@temp1.bitmap=Bitmap.new("Graphics/Pictures/button_Down")
@scroll.snapshot(@temp1.bitmap,Rect.new(0,0,32,32),Rect.new(0,64,32,32))
@temp1.bitmap.dispose
@temp1.dispose
end
end
#-------------------------------------------------------------------------------
# End Window_Browser
#-------------------------------------------------------------------------------
Вызов получается такой:
@gamehelp_view=Window_Browser.new("Help/datacube_#{$game_variables[12]}.txt")
Оформление текстового файла получается точно такое же, как в сообщениях, те же теги.
Еще где-то там в меню есть вызов скролла:
#Положение скролла
if @gamehelp_view.scroll.y>224
@gamehelp_view.scroll.y-=2
elsif @gamehelp_view.scroll.y<224
@gamehelp_view.scroll.y+=2
end
#Прокрутка вниз
if Input.repeat?(Input::DOWN)
if @gamehelp_view.scroll.visible
@line=@gamehelp_view.line
@max_line=@gamehelp_view.array.size+1
if @line+@gamehelp_view.max_lines<@max_line then
@gamehelp_view.scroll.y=224+12
@line+=1
end
@gamehelp_view.line=@line
end
@gamehelp_view.refresh
return
end
#Прокрутка вверх
if Input.repeat?(Input::UP)
if @gamehelp_view.scroll.visible
@line=@gamehelp_view.line
if @line>0 then
@gamehelp_view.scroll.y=224-12
@line-=1
end
@gamehelp_view.line=@line
end
@gamehelp_view.refresh
return
end
Честно говоря, я так давно возился с этим скриптом (
в феврале), что не смогу
просто взять и написать полностью необходимое меню.
Прошу учесть: данный код я взял из своих старых исходников и прошу, при использовании, указать меня хотя бы в титрах.