Fix tile editor for neut tower
This commit is contained in:
parent
10b29177a3
commit
4024abd074
|
@ -1,6 +1,7 @@
|
|||
(local GraphicsEditView (require :editor.gfxedit))
|
||||
(local style (require :core.style))
|
||||
(local tiles (require :game.tiles))
|
||||
(local files (require :game.files))
|
||||
(local tiledraw (require :editor.tiledraw))
|
||||
(local util (require :lib.util))
|
||||
(local {: mouse-inside : activate : active? : checkbox : textfield} (util.require :editor.imstate))
|
||||
|
@ -20,7 +21,9 @@
|
|||
(values ibyte ibit)))
|
||||
|
||||
(fn TileView.tilesize [self] (values 16 16))
|
||||
(fn TileView.tilekeys [self] [:gfx])
|
||||
(fn TileView.tilekeys [self]
|
||||
(if files.game.tilesets (icollect [_ key (pairs files.game.tilesets)] key)
|
||||
[:gfx]))
|
||||
|
||||
(fn get-byte [tile ibyte]
|
||||
(: (tile:sub (+ ibyte 1) (+ ibyte 1)) :byte))
|
||||
|
|
|
@ -12,27 +12,30 @@
|
|||
(when oldval
|
||||
(tset tile field (: oldval method)))
|
||||
tile)
|
||||
(fn convert-all [tile method]
|
||||
(fn convert-all [tile method root]
|
||||
(let [encoded-tile-fields [:mask]]
|
||||
(each [_ key (pairs (or root.tilesets {:tileset :gfx}))]
|
||||
(table.insert encoded-tile-fields key))
|
||||
(each [_ field (ipairs encoded-tile-fields)]
|
||||
(convert tile field method))
|
||||
tile)
|
||||
tile))
|
||||
|
||||
(fn tile-deserialize [tile]
|
||||
(fn tile-deserialize [tile root]
|
||||
(match (type tile)
|
||||
:string {:gfx (tile:fromhex) :flags {}}
|
||||
:table (convert-all tile :fromhex)))
|
||||
:table (convert-all tile :fromhex root)))
|
||||
|
||||
(fn tile-serialize [tile] (convert-all (lume.clone tile) :tohex))
|
||||
(fn tile-serialize [tile root] (convert-all (lume.clone tile) :tohex root))
|
||||
|
||||
(fn deserialize [key value]
|
||||
(fn deserialize [key value root]
|
||||
(match key
|
||||
(where (or :tiles :portraits :font)) (tile-deserialize value)
|
||||
(where (or :tiles :portraits :font)) (tile-deserialize value root)
|
||||
:levels (do (set value.map (value.map:fromhex)) value)
|
||||
_ value))
|
||||
|
||||
(fn serialize [key value]
|
||||
(fn serialize [key value root]
|
||||
(match key
|
||||
(where (or :tiles :portraits :font)) (tile-serialize value)
|
||||
(where (or :tiles :portraits :font)) (tile-serialize value root)
|
||||
:levels (do (set value.map (value.map:tohex)) value)
|
||||
_ value))
|
||||
|
||||
|
@ -48,7 +51,7 @@
|
|||
(if (util.file-exists (filename))
|
||||
(let [game (util.readjson (filename))]
|
||||
(each [k v (pairs game)]
|
||||
(tset game k (lume.map v #(deserialize k (clone $1)))))
|
||||
(tset game k (lume.map v #(deserialize k (clone $1) game))))
|
||||
game)
|
||||
{:tiles [] :portraits [] :font [] :levels []}))
|
||||
files.game)
|
||||
|
@ -57,7 +60,7 @@
|
|||
(when ?filename (set files.filename ?filename))
|
||||
(let [game {}]
|
||||
(each [k v (pairs files.game)]
|
||||
(tset game k (lume.map v #(serialize k (clone $1)))))
|
||||
(tset game k (lume.map v #(serialize k (clone $1) files.game))))
|
||||
(util.writejson (filename) game)))
|
||||
|
||||
(fn new-cache [game key]
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
(fn appendtiles [org]
|
||||
(local tiles files.game.tiles)
|
||||
(local flag-lookup (flag-to-bit))
|
||||
(org:append [:align 0x100] :tileset)
|
||||
(appendgfx org tiles)
|
||||
(each [tileset key (pairs (or files.game.tilesets {:tileset :gfx}))]
|
||||
(org:append [:align 0x100] tileset)
|
||||
(appendgfx org tiles key (if (= key :gfx) nil (.. key :-))))
|
||||
(appendgfx org files.game.portraits nil :portrait-)
|
||||
(org:append :tileflags)
|
||||
(each [_ tile (ipairs tiles)]
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -60,6 +60,7 @@
|
|||
" * Hot code reload"
|
||||
"* Tape upload"
|
||||
"* ProDOS disk image generation"]
|
||||
;; DEMO before tech dive
|
||||
[h "Assembler"
|
||||
** "Represent instructions using Fennel data literals"
|
||||
" [:lda 0xff]"
|
||||
|
|
Loading…
Reference in a new issue