outline tile that will be changed when editing, fix tile list

This commit is contained in:
Jeremy Penner 2021-12-29 17:15:37 -06:00
parent b0db9a10a1
commit 3a4d6ff460
3 changed files with 26 additions and 17 deletions

View file

@ -158,12 +158,17 @@
{:x mx :y my} (renderer.draw_text style.font player x y style.text))) {:x mx :y my} (renderer.draw_text style.font player x y style.text)))
(love.graphics.setColor 1 1 1)) (love.graphics.setColor 1 1 1))
(fn MapEditView.draw-object-box [self iobject x y w h] (fn MapEditView.draw-box [self x y w h color thickness]
(when (not= iobject nil) (love.graphics.setColor (table.unpack color))
(love.graphics.setColor 1 0 (if (and (= self.itile nil) (= iobject self.iobject)) 1 0)) (love.graphics.setLineWidth thickness)
(love.graphics.setLineWidth 3)
(love.graphics.rectangle :line x y w h) (love.graphics.rectangle :line x y w h)
(love.graphics.setColor 1 1 1))) (love.graphics.setColor 1 1 1))
(fn MapEditView.draw-object-box [self x y w h iobject]
(when iobject
(let [color [1 0 (if (and (= self.itile nil) (= iobject self.iobject)) 1 0) 1]]
(self:draw-object-box x y w h color 3))))
(fn MapEditView.handle-mouseedits-object [self mx my x y w h ilayer] (fn MapEditView.handle-mouseedits-object [self mx my x y w h ilayer]
(when (and (active? self [:map ilayer]) (mouse-inside x y w h)) (when (and (active? self [:map ilayer]) (mouse-inside x y w h))
@ -196,7 +201,7 @@
(renderer.draw_text style.font (string.format "%x" (encode-yx {:x mx :y my})) (+ x 20) labely style.text) (renderer.draw_text style.font (string.format "%x" (encode-yx {:x mx :y my})) (+ x 20) labely style.text)
(love.graphics.setColor 1 1 1)) (love.graphics.setColor 1 1 1))
(fn MapEditView.draw-map-layer [self {: x : y &as form} ilayer live] (fn MapEditView.draw-map-layer [self {: x : y &as form} live ilayer]
(love.graphics.setColor 1 1 1 1) (love.graphics.setColor 1 1 1 1)
(local {: mapw : maph : tilew : tileh : xstagger : ystagger} (self:scaled-dimensions ilayer)) (local {: mapw : maph : tilew : tileh : xstagger : ystagger} (self:scaled-dimensions ilayer))
(local [xoffset-layer yoffset-layer] (self:layer-offset ilayer)) (local [xoffset-layer yoffset-layer] (self:layer-offset ilayer))
@ -215,23 +220,27 @@
(local iobject (self:iobject-from-xy mx my)) (local iobject (self:iobject-from-xy mx my))
(when (= self.itile nil) (when (= self.itile nil)
(self:draw-player mx my tilex intiley) (self:draw-player mx my tilex intiley)
(self:draw-object-box iobject tilex intiley tilew intileh)) (self:draw-object-box tilex intiley tilew intileh iobject))
(if self.itile (if self.itile
(self:handle-mouseedits-tile mx my tilex intiley tilew intileh ilayer) (self:handle-mouseedits-tile mx my tilex intiley tilew intileh ilayer)
(self:handle-mouseedits-object mx my tilex intiley tilew intileh ilayer)) (self:handle-mouseedits-object mx my tilex intiley tilew intileh ilayer))
(when (mouse-inside tilex intiley tilew intileh) (when (mouse-inside tilex intiley tilew intileh)
(when (not= iobject nil) (set iobject-over iobject)) (when (not= iobject nil) (set iobject-over iobject))
(self:draw-tile-xy-label mx my tilex intiley tileh ystagger))))) (self:draw-tile-xy-label mx my tilex intiley tileh ystagger)
(self:draw-box tilex intiley tilew intileh [1 1 1 0.5] 1)))))
(when (and live (= self.itile nil)) (when (and live (= self.itile nil))
(self:draw-link-lines form iobject-over))) (self:draw-link-lines form iobject-over)))
(fn MapEditView.draw-map-editor [self form] (fn MapEditView.draw-map-editor [self form]
(let [g (group-wrapper form)] (let [g (group-wrapper form)
(each [ilayer (ipairs (platform :layers))] layers (platform :layers)]
(self:draw-map-layer (g) ilayer (= ilayer self.ilayer))) (if layers
(do (each [ilayer (ipairs (platform :layers))]
(self:draw-map-layer (g) (= ilayer self.ilayer) ilayer))
(let [{: x : y : w : h} (g)] (let [{: x : y : w : h} (g)]
(when (mouse-inside x y w h) (when (mouse-inside x y w h)
(self:draw-map-layer form self.ilayer true))) (self:draw-map-layer form true self.ilayer))))
(self:draw-map-layer form true))
(g))) (g)))
(fn condition-label [flag] (fn condition-label [flag]

View file

@ -21,7 +21,7 @@
(fn tile-styles [include-details] (fn tile-styles [include-details]
(let [dim (dimensions) (let [dim (dimensions)
styles {:tiles dim}] styles {:tiles dim}]
(each [_ layer (ipairs (or dim.layers []))] (each [_ {:style layer} (ipairs (or dim.layers []))]
(when (not= layer :tiles) (tset styles layer (. dim layer)))) (when (not= layer :tiles) (tset styles layer (. dim layer))))
(if include-details styles (lume.keys styles)))) (if include-details styles (lume.keys styles))))

File diff suppressed because one or more lines are too long