Midstream on #8 : Added grid darkening when you click on a cell and the tile name edit box.

This commit is contained in:
2014-05-22 21:53:59 -07:00
parent 1bd207adc4
commit 057a456820
2 changed files with 35 additions and 6 deletions

View File

@@ -8,7 +8,11 @@ module Tailor
def initialize(*args) def initialize(*args)
super(*args) super(*args)
@imageGrid = nil @imageGrid = nil
@darkenCell = nil
@pristineImage = nil @pristineImage = nil
@darken_x = 0
@darken_y = 0
@rectlist = []
end end
def set_image(image) def set_image(image)
@@ -21,6 +25,17 @@ module Tailor
@pristineImage.get_height(), @pristineImage.get_height(),
@pristineImage.get_depth() @pristineImage.get_depth()
) )
tmpImage = Wx::Image.new(gridX, gridY)
tmpImage.init_alpha
(0..gridX).each do |x|
(0..gridY).each do |y|
tmpImage.set_rgb(x, y, 0, 0, 0)
tmpImage.set_alpha(x, y, 150)
end
end
@darkenCell = tmpImage.to_bitmap
evt_left_up() { |event| on_gridClicked(event) }
@imageGrid.draw() { |dc| @imageGrid.draw() { |dc|
dc.clear dc.clear
dc.draw_bitmap(@pristineImage, 0, 0, true) dc.draw_bitmap(@pristineImage, 0, 0, true)
@@ -30,7 +45,6 @@ module Tailor
stepy = 1 unless stepy != 0 stepy = 1 unless stepy != 0
rows = ( (@pristineImage.height - padY) / stepy ) rows = ( (@pristineImage.height - padY) / stepy )
columns = ( (@pristineImage.width - padX) / stepx ) columns = ( (@pristineImage.width - padX) / stepx )
puts "Grid will be #{rows} tall and #{columns} wide"
curX = padX curX = padX
curY = padY curY = padY
@@ -42,7 +56,7 @@ module Tailor
next if ((curX + stepx + padX) > @imageGrid.get_width) next if ((curX + stepx + padX) > @imageGrid.get_width)
next if ((curY + stepy + padY) > @imageGrid.get_height) next if ((curY + stepy + padY) > @imageGrid.get_height)
dc.draw_rectangle(curX, curY, gridX, gridY) dc.draw_rectangle(curX, curY, gridX, gridY)
puts "Drew (#{curX}, #{curY}, #{gridX}, #{gridY})" @rectlist << Wx::Rect.new(curX, curY, gridX, gridY)
curX += stepx curX += stepx
end end
curX = padX curX = padX
@@ -53,10 +67,21 @@ module Tailor
end end
def on_draw(dc) def on_draw(dc)
dc.set_background Wx::WHITE_BRUSH dc.set_background Wx::WHITE_BRUSH
dc.clear dc.clear
return if @imageGrid == nil return if @imageGrid == nil
dc.draw_bitmap(@imageGrid, 0, 0, true) dc.draw_bitmap(@imageGrid, 0, 0, true)
return if @darkenCell == nil
dc.draw_bitmap(@darkenCell, @darken_x, @darken_y, true)
end
def on_gridClicked(event)
@rectlist.each do |rect|
next unless rect.contains(event.get_x, event.get_y)
@darken_x = rect.get_x
@darken_y = rect.get_y
end
refresh
end end
end end

View File

@@ -50,6 +50,10 @@ module Tailor
Wx::ID_ANY, Wx::ID_ANY,
"Tileset Name") "Tileset Name")
tmpversizer.add(@tilesetNameCtrl, 0, flag = Wx::EXPAND|Wx::ALIGN_TOP) tmpversizer.add(@tilesetNameCtrl, 0, flag = Wx::EXPAND|Wx::ALIGN_TOP)
@tileNameCtrl = Wx::TextCtrl.new(@panel,
Wx::ID_ANY,
"Tile Name")
tmpversizer.add(@tileNameCtrl, 0, flag = Wx::EXPAND|Wx::ALIGN_TOP)
@tilesetNotesCtrl = Wx::TextCtrl.new(@panel, @tilesetNotesCtrl = Wx::TextCtrl.new(@panel,
Wx::ID_ANY, Wx::ID_ANY,
"Notes about this tileset", "Notes about this tileset",