Midstream on #8 : Grid drawing works as expected now, but the TilesetPropertiesChangedEvent is not bubbling up like it should, so the grid can't change
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
require "tailor/version"
|
||||
require "tailor/GUI"
|
||||
|
||||
class SuperProxy
|
||||
def initialize(obj)
|
||||
@obj = obj
|
||||
end
|
||||
|
||||
def method_missing(meth, *args, &blk)
|
||||
@obj.class.superclass.instance_method(meth).bind(@obj).call(*args, &blk)
|
||||
end
|
||||
end
|
||||
|
||||
class Object
|
||||
private
|
||||
def _super
|
||||
SuperProxy.new(self)
|
||||
end
|
||||
end
|
||||
|
||||
module Tailor
|
||||
# Your code goes here...
|
||||
end
|
||||
|
||||
@@ -7,12 +7,22 @@ module Tailor
|
||||
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
@imageGrid = nil
|
||||
@padX = 0
|
||||
@padY = 0
|
||||
@pitchX = 0
|
||||
@pitchY = 0
|
||||
@gridX = 0
|
||||
@gridY = 0
|
||||
@gridX = 32
|
||||
@gridY = 32
|
||||
end
|
||||
|
||||
def set_image(image)
|
||||
_super.set_image(image)
|
||||
@imageGrid = Wx::Bitmap.new(@image.get_width(),
|
||||
@image.get_height(),
|
||||
32
|
||||
)
|
||||
set_grid(@padX, @padY, @pitchX, @pitchY, @gridX, @gridY)
|
||||
end
|
||||
|
||||
def set_grid(padX, padY, pitchX, pitchY, gridX, gridY)
|
||||
@@ -22,25 +32,41 @@ module Tailor
|
||||
@pitchY = pitchY
|
||||
@gridX = gridX
|
||||
@gridY = gridY
|
||||
end
|
||||
|
||||
def on_draw(dc)
|
||||
super.on_draw(dc)
|
||||
dc.set_pen(Wx::BLACK_DASHED_PEN)
|
||||
rows = ( (@image.height - @padY) / (@gridY + @pitchY) )
|
||||
columns = ( (@image.width - @padX) / (@gridX + @pitchX) )
|
||||
@imageGrid.draw() { |dc|
|
||||
dc.draw_bitmap(@image, 0, 0, true)
|
||||
stepx = @gridX + @pitchX
|
||||
stepx = 1 unless stepx != 0
|
||||
stepy = @gridY + @pitchY
|
||||
stepy = 1 unless stepy != 0
|
||||
rows = ( (@image.height - @padY) / stepy )
|
||||
columns = ( (@image.width - @padX) / stepx )
|
||||
points = []
|
||||
curX = @padX
|
||||
curY = @padY
|
||||
|
||||
dc.set_brush(Wx::TRANSPARENT_BRUSH)
|
||||
dc.set_pen(Wx::RED_PEN)
|
||||
|
||||
for row in 0..rows
|
||||
for column in 0..columns
|
||||
dc.draw_rectangle(curX, curY, @gridX, @gridY)
|
||||
curX += (@gridX + @pitchX)
|
||||
curX += stepx
|
||||
end
|
||||
curX = @padX
|
||||
curY += (@gridY + @pitchY)
|
||||
curY += stepy
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def on_draw(dc)
|
||||
_super.on_draw(dc)
|
||||
tmp=@image
|
||||
@image=@imageGrid
|
||||
_super.on_draw(dc)
|
||||
@image=tmp
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ module Tailor
|
||||
attr_accessor :gridY
|
||||
|
||||
def initialize(*args)
|
||||
super(*args)
|
||||
super(args[0])
|
||||
@padX = args[2]['padX']
|
||||
@padY = args[2]['padY']
|
||||
@pitchX = args[2]['pitchX']
|
||||
|
||||
Reference in New Issue
Block a user