highlight active layer when mousing over map, fix layout
This commit is contained in:
parent
2c06782600
commit
b0db9a10a1
|
@ -13,7 +13,9 @@
|
|||
(local sprite-scale 3)
|
||||
|
||||
(fn platform [?key] (let [p (dimensions)] (if ?key (. p ?key) p)))
|
||||
(fn MapEditView.layer-type [self ?ilayer] (or (?. (platform :layers) (or ?ilayer self.ilayer)) :tiles))
|
||||
(fn MapEditView.layer [self ?ilayer] (or (?. (platform :layers) (or ?ilayer self.ilayer)) {:style :tiles}))
|
||||
(fn MapEditView.layer-type [self ?ilayer] (. (self:layer ?ilayer) :style))
|
||||
(fn MapEditView.layer-offset [self ?ilayer] (let [{: x : y} (self:layer ?ilayer)] [(* sprite-scale (or x 0)) (* sprite-scale (or y 0))]))
|
||||
(fn MapEditView.dimensions [self ?ilayer] (or (platform (self:layer-type ?ilayer)) (platform)))
|
||||
(fn MapEditView.scaled-dimensions [self ?ilayer]
|
||||
(let [dim (lume.clone (self:dimensions ?ilayer))]
|
||||
|
@ -129,7 +131,7 @@
|
|||
(if (= self.imstate.left :released) (set self.iobject-linking nil)
|
||||
(self:draw-link-line x y self.iobject-linking [0 1 0] true))))
|
||||
|
||||
(fn MapEditView.draw-tilestrip [self x y my ?ilayer]
|
||||
(fn MapEditView.draw-tilestrip [self x y my ?ilayer translucent?]
|
||||
; stripcache leaks but honestly who cares
|
||||
(local tilestrip [])
|
||||
(var stripid (tostring ?ilayer))
|
||||
|
@ -142,6 +144,7 @@
|
|||
(when (= sprite nil)
|
||||
(set sprite (tilestrip-to-sprite tilestrip (self:layer-type ?ilayer)))
|
||||
(tset self.stripcache stripid sprite))
|
||||
(love.graphics.setColor 1 1 1 (if translucent? 0.4 1))
|
||||
(love.graphics.draw sprite x y 0 self.sprite-scale self.sprite-scale))
|
||||
|
||||
(fn MapEditView.mapsize [self ilayer]
|
||||
|
@ -196,15 +199,16 @@
|
|||
(fn MapEditView.draw-map-layer [self {: x : y &as form} ilayer live]
|
||||
(love.graphics.setColor 1 1 1 1)
|
||||
(local {: mapw : maph : tilew : tileh : xstagger : ystagger} (self:scaled-dimensions ilayer))
|
||||
(local [xoffset-layer yoffset-layer] (self:layer-offset ilayer))
|
||||
(local intileh (or ystagger tileh))
|
||||
(let [[w h] (self:mapsize ilayer)] (lume.extend form {: w : h :tag [:map ilayer]}))
|
||||
(when live (activate form))
|
||||
(var iobject-over nil)
|
||||
(for [my 1 maph]
|
||||
(local tiley (+ y (* (- my 1) (or ystagger tileh))))
|
||||
(local tiley (+ y yoffset-layer (* (- my 1) (or ystagger tileh))))
|
||||
(local intiley (+ tiley (- tileh intileh)))
|
||||
(local xoff (if (and xstagger (= (% my 2) 0)) xstagger 0))
|
||||
(self:draw-tilestrip (+ x xoff) tiley my ilayer)
|
||||
(local xoff (+ xoffset-layer (if (and xstagger (= (% my 2) 0)) xstagger 0)))
|
||||
(self:draw-tilestrip (+ x xoff) tiley my ilayer (and (mouse-inside x y form.w form.h) (not live)))
|
||||
(when live
|
||||
(for [mx 1 mapw]
|
||||
(local tilex (+ x (* (- mx 1) tilew) xoff))
|
||||
|
@ -225,6 +229,9 @@
|
|||
(let [g (group-wrapper form)]
|
||||
(each [ilayer (ipairs (platform :layers))]
|
||||
(self:draw-map-layer (g) ilayer (= ilayer self.ilayer)))
|
||||
(let [{: x : y : w : h} (g)]
|
||||
(when (mouse-inside x y w h)
|
||||
(self:draw-map-layer form self.ilayer true)))
|
||||
(g)))
|
||||
|
||||
(fn condition-label [flag]
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
:brushes {:tilew 7 :editw 8 :tileh 8}
|
||||
:portraits {:tilew 28 :editw 32 :tileh 32}}
|
||||
:iigs {:mapw 26 :maph 16 :tilew 12 :tileh 12
|
||||
:layers [:tiles :iso :iso]
|
||||
:layers [{:style :tiles} {:style :iso :x 6 :y 6} {:style :iso :x 6}]
|
||||
:yoffsets [0 6 0]
|
||||
:iso {:mapw 12 :maph 28 :tilew 24 :tileh 32 :xstagger 12 :ystagger 6}
|
||||
:font {:tilew 8 :tileh 8}
|
||||
|
|
Loading…
Reference in a new issue