deprecate gfxedit2
This commit is contained in:
parent
e6eee86a91
commit
7b6893d6e3
|
@ -1,6 +1,5 @@
|
|||
(local util (require :lib.util))
|
||||
(local {: defmulti : defmethod} (util.require :lib.multimethod))
|
||||
(local {: textfield} (util.require :editor.imstate))
|
||||
|
||||
(local actions (util.hot-table ...))
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
(local tiledraw (require :editor.tiledraw))
|
||||
(local util (require :lib.util))
|
||||
(local files (require :game.files))
|
||||
(local {: attach-imstate : mouse-inside : activate : active? : button} (util.require :editor.imstate))
|
||||
(local {: attach-imstate : button : reform : horiz-wrapper : group-wrapper} (util.require :editor.imgui))
|
||||
|
||||
(local GraphicsEditView (View:extend))
|
||||
|
||||
|
@ -37,26 +37,28 @@
|
|||
(let [sprite (self.tilecache:sprite itile ?key)]
|
||||
(when sprite
|
||||
(love.graphics.setColor 1 1 1)
|
||||
(love.graphics.draw sprite x y 0 self.sprite-scale self.sprite-scale))))
|
||||
(love.graphics.draw sprite x y 0 self.sprite-scale self.sprite-scale)
|
||||
(values (* (sprite:getWidth) self.sprite-scale) (* (sprite:getHeight) self.sprite-scale)))))
|
||||
|
||||
(fn GraphicsEditView.draw-tile-selector [self x y w ?key]
|
||||
(var tilex x)
|
||||
(var tiley y)
|
||||
(var (pixw pixh) (self:tilesize))
|
||||
(when (= files.game.platform :ii) (set pixw (* (/ pixw 8) 7)))
|
||||
(local tilew (* self.sprite-scale pixw))
|
||||
(local tileh (* self.sprite-scale pixh))
|
||||
(for [itile 1 (length self.tilecache.tiles)]
|
||||
(self:draw-sprite tilex tiley itile ?key)
|
||||
(when (and (= itile self.itile) (= ?key self.tilekey))
|
||||
(love.graphics.rectangle :line (- tilex 2) (- tiley 2) (+ tilew 4) (+ tileh 4)))
|
||||
(when (button self [:tile itile] tilex tiley tilew tileh)
|
||||
(set self.itile itile)
|
||||
(set self.tilekey ?key))
|
||||
(set tilex (+ tilex tilew 4))
|
||||
(when (>= (+ tilex tilew) (+ x w))
|
||||
(set tilex x)
|
||||
(set tiley (+ tiley tileh 4))))
|
||||
(+ tiley tileh (- y)))
|
||||
(fn tile-selector [{: view &as form} selected-itile ?key]
|
||||
(var selected-itile selected-itile)
|
||||
(let [g (group-wrapper form)
|
||||
wrap (horiz-wrapper form)]
|
||||
(for [itile 1 (length view.tilecache.tiles)]
|
||||
(let [{: x : y} form
|
||||
(w h) (view:draw-sprite x y itile ?key)]
|
||||
(when (and w h)
|
||||
(when (= itile selected-itile)
|
||||
(love.graphics.rectangle :line (- x 2) (- y 2) (+ w 4) (+ h 4)))
|
||||
(when (g button (reform form {:tag [:tile itile] : w : h}))
|
||||
(set selected-itile itile))
|
||||
(wrap form))))
|
||||
(g)
|
||||
selected-itile))
|
||||
|
||||
(fn GraphicsEditView.draw-tile-selector [self form ?key]
|
||||
(match (tile-selector (reform form {:scale self.sprite-scale :w form.w}) (when (= self.tilekey ?key) self.itile) ?key)
|
||||
selected-itile (do (set self.itile selected-itile)
|
||||
(set self.tilekey ?key))))
|
||||
|
||||
GraphicsEditView
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
(local View (require :core.view))
|
||||
(local tiles (require :game.tiles))
|
||||
(local tiledraw (require :editor.tiledraw))
|
||||
(local util (require :lib.util))
|
||||
(local files (require :game.files))
|
||||
(local {: attach-imstate : button : reform : horiz-wrapper : group-wrapper} (util.require :editor.imgui))
|
||||
|
||||
(local GraphicsEditView (View:extend))
|
||||
|
||||
(local sprite-scale 4)
|
||||
(set GraphicsEditView.sprite-scale sprite-scale)
|
||||
|
||||
(fn GraphicsEditView.new [self]
|
||||
(GraphicsEditView.super.new self)
|
||||
(self:set-style (self:initial-style))
|
||||
(set self.scrollheight math.huge)
|
||||
(set self.scrollable true)
|
||||
(attach-imstate self))
|
||||
(fn GraphicsEditView.get_scrollable_size [self] self.scrollheight)
|
||||
(fn GraphicsEditView.initial-style [self] :tiles)
|
||||
(fn GraphicsEditView.tilesize [self]
|
||||
(let [style (tiles.style self.style)]
|
||||
(values (or style.editw style.tilew) (or style.edith style.tileh))))
|
||||
(fn GraphicsEditView.set-style [self key]
|
||||
(set self.style key)
|
||||
(set self.tilecache (files.cache key))
|
||||
(set self.itile 1))
|
||||
(fn GraphicsEditView.reload [self] (files.reload))
|
||||
(fn GraphicsEditView.save [self] (files.save))
|
||||
|
||||
(fn GraphicsEditView.select-rel [self ditile]
|
||||
(when self.itile
|
||||
(local itile (+ self.itile ditile))
|
||||
(when (>= itile 1) (set self.itile itile))))
|
||||
|
||||
(fn GraphicsEditView.draw-sprite [self x y itile ?key]
|
||||
(let [sprite (self.tilecache:sprite itile ?key)]
|
||||
(when sprite
|
||||
(love.graphics.setColor 1 1 1)
|
||||
(love.graphics.draw sprite x y 0 self.sprite-scale self.sprite-scale)
|
||||
(values (* (sprite:getWidth) self.sprite-scale) (* (sprite:getHeight) self.sprite-scale)))))
|
||||
|
||||
(fn tile-selector [{: view &as form} selected-itile ?key]
|
||||
(var selected-itile selected-itile)
|
||||
(let [g (group-wrapper form)
|
||||
wrap (horiz-wrapper form)]
|
||||
(for [itile 1 (length view.tilecache.tiles)]
|
||||
(let [{: x : y} form
|
||||
(w h) (view:draw-sprite x y itile ?key)]
|
||||
(when (and w h)
|
||||
(when (= itile selected-itile)
|
||||
(love.graphics.rectangle :line (- x 2) (- y 2) (+ w 4) (+ h 4)))
|
||||
(when (g button (reform form {:tag [:tile itile] : w : h}))
|
||||
(set selected-itile itile))
|
||||
(wrap form))))
|
||||
(g)
|
||||
selected-itile))
|
||||
|
||||
(fn GraphicsEditView.draw-tile-selector [self form ?key]
|
||||
(match (tile-selector (reform form {:scale self.sprite-scale :w form.w}) (when (= self.tilekey ?key) self.itile) ?key)
|
||||
selected-itile (do (set self.itile selected-itile)
|
||||
(set self.tilekey ?key))))
|
||||
|
||||
GraphicsEditView
|
|
@ -43,12 +43,6 @@
|
|||
"graphics-editor:next-tile" #(core.active_view:select-rel 1)
|
||||
"graphics-editor:previous-tile" #(core.active_view:select-rel -1)
|
||||
})
|
||||
(command.add (cmd-predicate :editor.gfxedit2) {
|
||||
"graphics-editor:save" (fn [] (core.active_view:save) (core.log "Saved"))
|
||||
"graphics-editor:reload" (fn [] (core.active_view:reload) (core.log "Reloaded"))
|
||||
"graphics-editor:next-tile" #(core.active_view:select-rel 1)
|
||||
"graphics-editor:previous-tile" #(core.active_view:select-rel -1)
|
||||
})
|
||||
|
||||
(command.add (cmd-predicate :editor.tileedit) {
|
||||
"tileedit:copy"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(local GraphicsEditView (require :editor.gfxedit2))
|
||||
(local GraphicsEditView (require :editor.gfxedit))
|
||||
(local style (require :core.style))
|
||||
(local util (require :lib.util))
|
||||
(local lume (require :lib.lume))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
(local TileView (require :editor.tileedit))
|
||||
(local tiledraw (require :editor.tiledraw))
|
||||
(local tiles (require :game.tiles))
|
||||
(local {: textfield} (util.require :editor.imstate))
|
||||
(local {: textfield} (util.require :editor.imgui))
|
||||
|
||||
(local PortraitView (TileView:extend))
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
|||
(local tiley (% y 16))
|
||||
(local (ibyte ibit) (PortraitView.super.map-bitxy self tilex tiley))
|
||||
(values (+ ibyte (* quadrant 32)) ibit))
|
||||
(fn PortraitView.draw-tile-flags [self x y]
|
||||
(fn PortraitView.draw-tile-flags [self form]
|
||||
(local tile (-?> self.tilecache.tiles (. self.itile)))
|
||||
(when tile
|
||||
(set tile.label (textfield self "Label" tile.label x (+ y 4) 100 200))))
|
||||
(set tile.label (textfield form "Label" tile.label))))
|
||||
|
||||
(fn PortraitView.get_name [self] "Portrait Editor")
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(local GraphicsEditView (require :editor.gfxedit2))
|
||||
(local GraphicsEditView (require :editor.gfxedit))
|
||||
(local style (require :core.style))
|
||||
(local tiles (require :game.tiles))
|
||||
(local files (require :game.files))
|
||||
|
|
Loading…
Reference in a new issue