5
Marshal.load(Marshal.dump(self))
14
def initialize # constructor
24
def control(type, name, opt = {})
25
@opt << {:class => type, :name => name, :x => @x, :y => @y,
26
:width => 1, :height => 1}.merge!(opt)
29
# some meta-programming :]
30
def self.create_functions(*arr)
33
def #{a.to_s}(name, text, opt = {})
34
if @labels; label text, opt; @x += 1; end
35
control "#{a.to_s}", name, opt
44
create_functions *[:edit, :intedit, :floatedit, :textbox,
45
:dropdown, :checkbox, :color, :coloralpha, :alpha ]
47
def no_labels; @labels = false; end
49
def label(text, opt = {})
50
control :label, text, opt.merge({:label => text})
53
def header(text, opt = {})
54
label text, opt.merge!({:width => 2})
58
def to_ary # conversion to array
64
# inserts lines with options into [Script Info] section
65
def write_options(subs, opt, sep = "~~")
69
value = opt.delete(l[:key])
70
l[:value] = value.instance_of?(Hash) ? value.to_a.flatten!.join(sep) : value.to_s if value
74
opt.each do |key, val|
75
r << {:class => :info, :key => key,
76
:value => value.instance_of?(Hash) ? value.to_a.flatten!.join(sep) : value.to_s,
77
:section => "[Script Info]"}
87
# returns a hash with options from [Script Info] section
88
def read_options(subs, name, sep = "~~")
90
subs.each { |l| opt[l[:key].to_sym] = l[:value] if l[:class] == :info }
92
if opt[n_sym] # parsing of script specific options
93
a = opt[n_sym].split(sep)
95
(a.size/2).times { |j| h[a[2*j].to_sym] = a[2*j+1] }
103
c.reverse_each {|v| res << "%02X" % v}
110
col.scan(/[0-9a-fA-F]{2}/) { res.unshift $1.to_i(16) }