$: << './lib/';require 'singleton.rb'
module Graphics;class << self;alias m_bb update end;def self.update;self.m_bb; M.bb
end;end;module M;class A;def A.e_c(b);if b.is_a?(Bitmap);c = b;elsif b.is_a?(File)
c = Bitmap.new(b.path);elsif b.is_a?(String);if File.exists?(b)
c = Bitmap.new(b);else;c = Bitmap.new(32,32);end;else;c = Bitmap.new(32,32)
end;return c;rescue StandardError => err;return Bitmap.new(32,32);end
def A.e_d_b(d_id, f = false);if d_id.is_a?(Integer);if f;d = $data_enemies[d_id]
else;d = $game_actors[d_id];end;c = RPG::Cache.dacter(d.character_name, d.character_hue) :mad:
else;c = RPG::Cache.dacter(d_id.character_name, d_id.character_hue);end
raise "No dacter c error" if !c.is_a?(Bitmap);return c;rescue StandardError => err
return Bitmap.new(32,32);end;end;class << self;def bb;G.bb;end;def q(*mm, &block)
G.q(*mm, &block);end;end;class G;@@next_auto_nb = 0;include Singleton
ICM =["bb", "remove_all", "non", "q", "qPair", "qDefault", "qnb","e_object","m"]
ICM.each {|val|eval("def self.#{val}(*mm, &block) instance.#{val}(*mm,&block); end")}
def initialize;@l_h = [];@l_i = [];@l_j = [];@l_k = [];@o = Graphics.frame_count
@m = N.new;end;def q(*mm, &block);aa = nil;if block.is_a?(Proc);aa = block.call
end;aa.downcase! if aa.is_a?(String);case aa;when 'par' then qPair(*mm)
when 'nb' then qnb(*mm);else qDefault(*mm);end;end;def qPair(*mm);mm.flatten!
return false if mm.size % 2 == 1;for i in mm.size / 2;qnb(mm[i*2], mm[i*2+1])
end;return true;end;def qDefault(*mm);qnb(@@next_auto_nb, *mm);@@next_auto_nb += 1
return @@next_auto_nb - 1;end;def qnb(nb, *mm);mm.flatten!;for ml in mm
if ml.is_a?(Ab);q_object(ml,'Ab',nb);elsif ml.is_a?(Ag)
q_object(ml,'Ag',nb);elsif ml.is_a?(Af);q_object(ml,'Af',nb)
else;end;end;end;def q_object(object, type, nb = nil)
unless object.is_a?(eval(type.capitalize));return false;end;
unless eval("@nb_#{type.downcase}s.is_a?(Hash)");eval("@nb_#{type.downcase}s = {}")
mn = eval("@nb_#{type.downcase}s");mn[nb] = object;return true;end
mn =eval("@nb_#{type.downcase}s");if mn[nb].is_a?(Array);
return false if mn[nb].include?(object);mn[nb] << object;return true
end;mn[nb] = [mn[nb], object];return true;end;def e_object(type, nb)
unless eval("@nb_#{type.downcase}s.is_a?(Hash)");return nil;end
return eval("@nb_#{type.downcase}s[nb]");end;def m;return @m;end;def bb
fc = Graphics.frame_count;return if fc < @o + 1;@o = fc;@m.bb;@l_j.each {|x| x.bb}
end;def reset;initialize;for variable in instance_variables
unless (variable =~ /@nb_.*s/).nil?;remove_instance_variable variable;end;end
end;def remove_all;@l_j.each {|af| af.dispose};@l_i.each {|ag| ag.dispose}
@l_h.each {|ab| ab.dispose};@m.clear;reset;end;def non(obj)
if obj.is_a?(Ab);@l_h << obj unless @l_h.include?(obj);elsif obj.is_a?(Ag)
@l_i << obj unless @l_i.include?(obj);elsif obj.is_a?(Af);@l_j << obj unless @l_j.include?(obj)
elsif obj.is_a?(Ao);@l_k << obj unless @l_k.include?(obj);end;end;end;class N
attr_reader :bfs, :tps;def initialize;@tps = 40;@last_bf = 0.0;@m = {}
@bfs = 0;@vv = [];end;def tps=(number);return false unless number.is_a?(Numeric)
@tps = number;return true;end;def q(ag, pos=0);return false unless ag.is_a?(Ag)
s_bf = 1;s_bf += pos if pos.is_a?(Numeric);return q_ag(ag, @bfs+s_bf)
end;def q_ag(ag, s_bf);s_bf = @bfs if s_bf.nil?;return false unless ag.is_a?(Ag) &&
s_bf.is_a?(Numeric);start_bf = s_bf;@m[start_bf] = [] if @m[start_bf].nil?
@m[start_bf] << ag;if start_bf <= @bfs;ag.trigger(@bfs-start_bf+1)
if ag.is_finished?;@m[start_bf].pop;else;@vv << ag;end;end;return true
end;def bb;frame_rate = Graphics.frame_rate;@last_bf += @tps.to_f / frame_rate.to_f
full_bfs = @last_bf.floor;@last_bf -= full_bfs;bf(full_bfs);end;def bf(bfs = 1)
@bfs += bfs;for nn in @vv;nn.trigger(bfs);@vv.delete(nn) if nn.is_finished?;end
for i in 0...bfs;return if @m[@bfs+i].nil?;for ag in @m[@bfs+i];ag.trigger(bfs-i)
@vv << ag if !ag.is_finished?;end;end;end;def clear;initialize;end;end;class Ab
def initialize;G.non(self);@c = Bitmap.new(2,2);@ae = Viewport.new(@c.rect)
@bb_c = true;end;def ae;return @ae unless @ae.nil?;if !@c.nil?;@ae = Viewport.new(@c.rect)
return @ae;end;@ae = Viewport.new(Rect.new(0,0,32,32));return @ae;end;def rect
return ae.rect;end;def rect=(*mm);mm.flatten!;if mm.size == 1;nm = mm[0]
if nm.is_a?(Rect);ae.rect = nm;return true;end;elsif mm.size == 4
mm.each {|nm| return false unless nm.is_a?(Numeric)};ae.rect = Rect.new(*mm)
return true;end;return false;end;def ox() return ae.ox; end;def oy() return ae.oy
end;def width() return rect.width; end;def height() return rect.height; end
def ox=(val) ae.ox=val if val.is_a?(Numeric); end;def oy=(val) ae.oy=val if val.is_a?(Numeric)
end; def width=(val) rect.width=val if val.is_a?(Numeric) && val >= 1; end
def height=(val) rect.height=val if val.is_a?(Numeric) && val >= 1; end
def x(); return rect.x; end;def x=(val); rect.x=val if val.is_a?(Integer); end
def y(); return rect.y; end;def y=(val); rect.y=val if val.is_a?(Integer); end
def opacity;@opacity = 255 if @opacity.nil?;return @opacity;end;def opacity=(val)
return false unless val.is_a?(Numeric) && val >= 0 && val <= 255;@opacity = val
return true;end;def bitmap;bb if @bb_c && n_u;return @c;end;def bbs?
return @bb_c && n_u;end;def bb_c;return @bb_c;end;def bb_c=(bool)
if bool.is_a?(TrueClass) | bool.is_a?(FalseClass);@bb_c = bool;return true
end;return false;end;def n_u;return true;end;def bb;end;def dispose
@c.dispose unless @c.disposed?;end;end;class Af;attr_accessor :x, :y, :opacity
def initialize(ab);G.non(self);@ab = ab;@opacity = 255;end;def bd() return @bd
end;def bb;unless @bd.is_a?(Sprite) && !@ab.nil?;@bd = Sprite.new(@ab.ae);end
unless @bd.disposed?;return if @ab.nil?;@bd.bitmap = @ab.bitmap;@bd.opacity = @ab.opacity
@bd.update;end;end;def dispose;@bd.dispose unless @bd.nil?;end;end;class Ag
attr_reader :bfs;def initialize;G.non(self);@m = {};@bfs = 0;@length = 1
@tk = false;@vv = [];end;def q_ao(ao, s_bf, length=1);return false unless ao.is_a?(Ao) &&
s_bf.is_a?(Numeric) && length.is_a?(Numeric);start_bf = s_bf;end_bf = length-1 + s_bf
if end_bf > @length-1;@length = end_bf;end;end_bf = start_bf if start_bf > end_bf
@m[start_bf] = [] if @m[start_bf].nil?;@m[start_bf] << [ao, end_bf]
if start_bf <= @bfs and end_bf > @bfs;@vv << [ao, end_bf];end;return true;end
def tk;return @tk unless @tk.nil?;return false;end;def tk=(val)
return false unless val.is_a?(FalseClass) || val.is_a?(TrueClass);@tk = val
return true;end;def length;return @length;end;def length=(number)
return false unless number.is_a?(Numeric);@length = number;return true;end
def trigger(n=1);until n < 1;n -= 1;bf;end;end;def bf;if @bfs >= @length
return unless tk;@bfs = 0;@vv.clear;end;@bfs += 1;for i in 0...@vv.size
nn = @vv[i];unless nn.nil?;nn[0].trigger;@vv.delete_at(i) if nn[1] <= @bfs
end;end;return if @m[@bfs].nil?;for ao in @m[@bfs];ao[0].trigger
@vv << ao if ao[1] > @bfs;end;end;def is_finished?;return true if !tk && @bfs >= @length
return false;end;def dispose;end;end;class Ao;def initialize;G.non(self);end
def trigger;end;end;class Aj < Af;def initialize(window);G.non(self);@window = window
end;def bb;@window.bb;end;def dispose;@window.dispose;end;end;class Ahf < Af
def initialize(ab);super;@window = Window_Base.new(0,0,100,54);@window.width = ab.width + 32
@window.visible = true;end;def bd() return nil; end;def bb;unless @window.disposed?
@window.contents = @ab.bitmap;@window.width = @ab.width + 32;@window.x = @x unless @x.nil?
@window.y = @y unless @y.nil?;end;end;def dispose;@window.dispose unless @window.nil?
end;end;class AkAb < Ab;attr_reader :string, :font;def initialize(string="")
super();self.string = string;@line_distance = 4;@font = @c.font;qq;end;def string=(string)
if string.is_a?(String);@string = string;else;begin;@string = string.to_s;rescue
@string = "Error: Can't convert the nmument to string";end;end;end;def qq;return if @string.nil?
ary = @string.split(/\n/);return if ary.size == 0;ld = 0;ld = @line_distance unless ary.size == 1
width = 0;height = 0;for string in ary;rect = @c.text_size(string);curr_height = rect.height
height = curr_height if curr_height > height;width = rect.width if rect.width > width
end;width + 4;@c = Bitmap.new(width,(height+ld)*ary.size);self.rect.width = @c.width
self.rect.height = @c.height;@c.font = @font;for i in 0...ary.size
@c.draw_text(0,i*(height+@line_distance),width,height,ary[i]);end;end;end
class BAb < Ab;def initialize(b=nil);super();new_b(b);end;def new_b(b=nil)
@c = A.e_c(b);self.width = @c.rect.width - self.x;self.height = @c.rect.height - self.y
end;end;class Am < Ab;def initialize(*mm);super();@changed = false
@ni = true;@h = [];q(*mm);bb;calc_ac;qq;end;def q(*mm);return false if @frozen
mm.flatten!;for ab in mm;if ab.is_a?(Ab);@changed = true;@h << ab;end;end;end
def bb;bc = false;for ab in @h;if ab.bbs?;ab.bb;bc = true;end;end;qq if bc;end
def calc_ac;return false if @h.size == 0;ab = @h[0];width = ab.width + ab.x
height = ab.height + ab.y;for i in 1...@h.size;ab = @h[i];if ab.width + ab.x > width
width = ab.width + ab.x;end;if ab.height + ab.y > height;height = ab.height + ab.y
end;end;if rect.width == width && rect.heigth == height;return false;end
self.rect = rect.x, rect.y, width, height;return true;end;def qq
if self.rect.width == @c.rect.width && self.rect.height == @c.rect.height
@c.clear;else;@c = Bitmap.new(self.rect.width, self.rect.height);end;for ab in @h
rect = Rect.new(ab.ox, ab.oy, ab.width, ab.height);@c.blt(ab.x, ab.y, ab.bitmap, rect, opacity)
end;end;def dispose;if @ni;@h.each {|ab| ab.dispose};end;@c.clear;end;end
class AqAb < Ab;def initialize(number=0);super();self.number = number;@font = @c.font
bb;qq;end;def number;return 0 if @number.nil?;return @number;end;def number=(val)
if val.is_a?(Integer);@next_number = val;else;begin;@next_number = val.to_i
rescue;end;end;end;def bb;super;if @next_number != @number;@number = @next_number
qq;end;end;def qq;return if @number.nil?;rect = @c.text_size(@number.to_s)
@c = Bitmap.new(rect.width, rect.height);self.rect.width = @c.width;self.rect.height = @c.height
@c.font = @font;@c.draw_text(0,0,rect.width,rect.height,@number.to_s,2);end;end
class DacterAb < Ab;attr_writer :wait;def initialize(d_id, f = false);super()
@pos = 0;@aq = 0;@wait = 8;@d_id = d_id;@f = f;set_d(d_id, f);end;def set_d(d_id, f = false)
@c = A.e_d_b(d_id, f);self.width = @c.rect.width/4;self.height = @c.rect.height/4
end;def bb;@aq += 1;if @aq > @wait;@pos += 1;width = @c.width / 4 ;self.ox += width
if @pos >= 4;@pos = 0;self.ox -= @c.width;end;@aq = 0;end;end;def dispose;end
end;class AkAo < Ao;def initialize;G.non(self);end;def trigger;end;end;class BAo < Ao
def initialize(ab, new_b, new_b2);@ab = ab;@new_b = A.e_c(new_b);@new_b2 = A.e_c(new_b2)
@im = true;G.non(self);end;def trigger;if @im;@ab.new_b(@new_b);@im = false;else
@ab.new_b(@new_b2);@im = true;end;end;end;class AmAo < Ao;def initialize;G.non(self)
end;def trigger;end;end;class MAo < Ao;def initialize(object, x=0, y=0);super()
@object = object;@x = x;@y = y;end;def trigger;begin;@object.x += @x;@object.y += @y
rescue;end;end;end;class QAqAo < Ao;def initialize(ab, amount=1);super();@ab = ab
@amount = amount;end;def trigger;if @ab.is_a?(AqAb);if @amount.is_a?(Integer)
@ab.number += @amount;else;@ab.number += 1;end;end;end;end;class Stqo < Ao
def initialize(ag,cab,val);super();@ag = ag;@cab = cab;@val = val;end;def trigger
if @val - 1 <= @cab.number;@ag.tk = false;end;end;end;class GenDotAo < Ao;@@x = 0
@@y = 80;def initialize(x=0,y=80);super();@@x = x;@@y = y;end;def trigger
ig = BAb.new(RPG::Cache.picture("dot.png"));w = Af.new(ig);ao1 = MAo.new(ig,0,-2)
ao2 = MAo.new(ig,0,2);seq = Ag.new;seq.q_ao(ao1,1,5);seq.q_ao(ao2,6,5);seq.tk = true
G.m.q(seq);ig.x = @@x;ig.y = @@y;@@x += 20;@@y += 20 * (@@x / 640);@@x = @@x % 640
end;end;class DisposeAfAo < Ao;def initialize(af);super();@af = af;end;def trigger
@af.dispose;end;end;class AgAo < Ao;def initialize(ag);super();@ag = ag;end
def trigger;end;end;class ExitAo < Ao;def initialize;super();end;def trigger
p "string";exit;end;end;end