#24 Assets Import-export fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-01-29 23:21:00 +01:00
parent 8a6214e893
commit 3dc28849c4

View File

@@ -58,25 +58,36 @@ watch:
make build
fswatch -o $(SRC_DIR) $(ORDER) assets | while read; do make build; done
import_assets:
@for t in $(ASSET_TYPES); do \
import_assets: $(OUTPUT)
@TIC_CMD="load $(OUTPUT) &"; \
for t in $(ASSET_TYPES); do \
for f in $(ASSETS_DIR)/$$t/*.png; do \
[ -e "$$f" ] || continue; \
echo "==> Importing $$f as $$t..."; \
tic80 --cli --skip --fs=. --cmd="import $$t $$f & exit"; \
TIC_CMD="$${TIC_CMD} & import $$t $$f"; \
done; \
done
done; \
TIC_CMD="$$TIC_CMD save & exit"; \
echo $$TIC_CMD; \
tic80 --cli --skip --fs=. --cmd="$$TIC_CMD"
export_assets: build
# export helper function
define f_export_asset_awk
cat $(2) | awk '/-- <$(1)>/,/<\/$(1)>/' >> $(3)
endef
export_assets:
# $(OUTPUT) would be a circular dependency
@test -e $(OUTPUT)
@echo "==> Exporting TIC-80 asset sections"
@mkdir -p inc/meta
@sed -n '/^-- <PALETTE>/,/^-- <\/PALETTE>/p;\
/^-- <TILES>/,/^-- <\/TILES>/p;\
/^-- <SPRITES>/,/^-- <\/SPRITES>/p;\
/^-- <MAP>/,/^-- <\/MAP>/p;\
/^-- <SFX>/,/^-- <\/SFX>/p;\
/^-- <MUSIC>/,/^-- <\/MUSIC>/p' \
$(OUTPUT) > $(ASSETS_LUA)
@echo -n '' > $(ASSETS_LUA)
@$(call f_export_asset_awk,PALETTE,$(OUTPUT),$(ASSETS_LUA))
@$(call f_export_asset_awk,TILES,$(OUTPUT),$(ASSETS_LUA))
@$(call f_export_asset_awk,SPRITES,$(OUTPUT),$(ASSETS_LUA))
@$(call f_export_asset_awk,MAP,$(OUTPUT),$(ASSETS_LUA))
@$(call f_export_asset_awk,SFX,$(OUTPUT),$(ASSETS_LUA))
@$(call f_export_asset_awk,WAVES,$(OUTPUT),$(ASSETS_LUA))
clean:
@rm -f $(PROJECT)-*.tic $(PROJECT)-*.html.zip $(OUTPUT)
@@ -115,3 +126,10 @@ ci-update:
.PHONY: all build export watch import_assets export_assets clean ci-version ci-export ci-upload ci-update
#-- <WAVES>
#-- 000:224578acdeeeeddcba95434567653100
#-- </WAVES>
#
#-- <SFX>
#-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000500000000000
#-- </SFX>