Commits

Thomas Perl committed fd28161

Add support for optionally shrinking the data size

  • Participants
  • Parent commits 43c856e

Comments (0)

Files changed (2)

 convert:
 	python convert_sprites.py
 
+crunch-files:
+	# Make files smaller for distribution
+	# (don't commit the changes, though - use "undo-crunch")
+	(cd data/sprites/ && pngnq *.png)
+	(cd data/sprites/ && for file in *-nq8.png; do mv $$file $$(basename $$file -nq8.png).png; done)
+	(cd data/creatures/ && pngnq *.png)
+	(cd data/creatures/ && for file in *-nq8.png; do mv $$file $$(basename $$file -nq8.png).png; done)
+	(cd data/backgrounds/ && for file in *.jpg; do convert $$file -quality 70 $$file; done)
+	(cd data/sounds/ && oggenc -q0 *.wav && rm *.wav)
+
+
+undo-crunch:
+	# Undo "crunch-files" (after distribution package is built)
+	find data -name '*.orig' -exec rm '{}' +
+	hg revert data
+	rm -f data/sounds/*.ogg
+
 install:
 	mkdir -p $(DESTDIR)/opt/$(PACKAGE)/bin
 	install -m755 $(PACKAGE) $(DESTDIR)/opt/$(PACKAGE)/bin/
 clean:
 	find . -name '*.pyc' -exec rm '{}' +
 
-.PHONY: all convert install clean
+.PHONY: all convert crunch-files undo-crunch install clean
 .DEFAULT: all
 

File src/engine/resman.py

 
         import pygame.mixer as mixer
 
-        ## load sfx
-        for fn in glob.glob(self._path('sounds', "*.wav")):
-            bn, _ = os.path.splitext(os.path.basename(fn))
-            sound = mixer.Sound(fn)
-            self._sounds[bn] = sound
+        ## load sfx (wav and optionally ogg files if they exist)
+        for extension in ('*.wav', '*.ogg'):
+            for fn in glob.glob(self._path('sounds', extension)):
+                bn, _ = os.path.splitext(os.path.basename(fn))
+                sound = mixer.Sound(fn)
+                self._sounds[bn] = sound
 
         ## load fonts
         name, size = FONT_STD