summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordmonty2 <dmonty@sd73.bc.ca>2014-03-16 22:25:18 -0700
committerdmonty2 <dmonty@sd73.bc.ca>2014-03-16 22:25:18 -0700
commit5e5810800664a1e5698b6f6dd0de7b033c09014e (patch)
tree14cb629a0592f65316ced7bcfb82fa23a08d2600
parent039f49f408e58d5698daf64ecdd40b7af711b0d4 (diff)
1.0
-rwxr-xr-xgenerate_previews.sh48
-rw-r--r--modpack.txt0
-rwxr-xr-xset_meta.sh59
-rwxr-xr-xupdate_from_db.py46
-rwxr-xr-xupdate_from_db2.py45
5 files changed, 198 insertions, 0 deletions
diff --git a/generate_previews.sh b/generate_previews.sh
new file mode 100755
index 0000000..22c978c
--- /dev/null
+++ b/generate_previews.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+# This script is used to generate the previews needed by the mod
+# It requires blender with the latest python API (2.6x is tested)
+# A script that works with older blenders and, maybe, without python, is available in older commits.
+# This script can also use pngcrush and imagemagick to reduce output size,
+# please enable them if you want to push to the git repository of the mod.
+# Pngcrush output will be written to .previews/pngcrush_output
+# Warning: any file in .previews/ and u_skins/textures might be deleted without asking.
+PNGCRUSH=true
+IMAGEMAGICK=true
+cd .previews
+rm ../u_skins/textures/*_preview*.png # Remove all previous previews
+blender -b skin_previews.blend --python-text "Generate previews" > /dev/null
+if $IMAGEMAGICK
+ then echo "Stripping metadata from generated files..."
+ else echo "Moving files..."
+fi
+rm -rf output # remove my output
+mkdir -p output
+for i in blender_out/character_*_00.png;
+do
+ out_name=$(basename $i | sed -e 's/_00.png//g')
+ out_file=output/"$out_name"_preview.png
+ if $IMAGEMAGICK
+ then
+ convert -strip $i $out_file
+ else
+ mv $i $out_file
+ fi
+done
+for i in blender_out/character_*_01.png;
+do
+ out_name=$(basename $i | sed -e 's/_01.png//g')
+ out_file=output/"$out_name"_preview_back.png
+ if $IMAGEMAGICK
+ then
+ convert -strip $i $out_file
+ else
+ mv $i $out_file
+ fi
+done
+if $PNGCRUSH
+ then
+ echo "Running pngcrush..."
+ pngcrush -d ../u_skins/textures/ output/*_preview*.png 2> pngcrush_output
+ else mv output/*_preview*.png ../u_skins/textures/
+fi
+echo "Done !"
diff --git a/modpack.txt b/modpack.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/modpack.txt
diff --git a/set_meta.sh b/set_meta.sh
new file mode 100755
index 0000000..1db43cd
--- /dev/null
+++ b/set_meta.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+SPRITES=$(find -regextype sed -regex '.*/player_[0-9]\{1,\}.png' | sort -V)
+MODELS=$(find -regextype sed -regex '.*/character_[0-9]\{1,\}.png' | sort -V)
+function ask_for_meta {
+ convert $2 -scale 100x200 /tmp/skins_set_meta
+ SNAME=$(basename $1)
+ SNAME=${SNAME%.*}
+ METAFILE=u_skins/meta/$SNAME.txt
+ FORCE=$3
+ if $FORCE || ! [ -f $METAFILE ]
+ then
+ echo $METAFILE
+ YADOUT=$(yad --form --image=/tmp/skins_set_meta --field $SNAME:LBL --field=Name --field=Author --field=Description --field=Comment)
+ if [ -z "$YADOUT" ]; then exit; fi # canceled
+ OIFS="$IFS"
+ IFS='|'
+ read -a VALUES <<< "$YADOUT"
+ IFS="$OIFS"
+ NAME=${VALUES[1]}
+ AUTHOR=${VALUES[2]}
+ DESCRIPTION=${VALUES[3]}
+ COMMENT=${VALUES[4]}
+ if [ -n "$NAME" ] && [ -n "$AUTHOR" ]
+ then
+ echo -n > $METAFILE # clear it
+ echo 'name = "'$NAME'",' >> $METAFILE
+ echo 'author = "'$AUTHOR'",' >> $METAFILE
+ # only write description and comment if they are specified
+ if [ -n "$DESCRIPTION" ]
+ then
+ echo 'description = "'$DESCRIPTION'",' >> $METAFILE
+ fi
+ if [ -n "$COMMENT" ]
+ then
+ echo 'comment = "'$COMMENT'",' >> $METAFILE
+ fi
+ echo "Saved !"
+ fi
+ fi
+}
+if [ -z $1 ]
+then
+ for i in $SPRITES
+ do
+ ask_for_meta $i $i false
+ done
+ for i in $MODELS
+ do
+ ask_for_meta $i ${i%.*}_preview.png false
+ done
+else
+ if [ -f ${1%.*}_preview.png ]
+ then
+ ask_for_meta $1 ${1%.*}_preview.png true
+ else
+ ask_for_meta $1 $1 true
+ fi
+fi
+rm /tmp/skins_set_meta
diff --git a/update_from_db.py b/update_from_db.py
new file mode 100755
index 0000000..193c87d
--- /dev/null
+++ b/update_from_db.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python3
+from http.client import HTTPConnection
+import json
+import base64
+
+server = "minetest.fensta.bplaced.net"
+skinsdir = "u_skins/textures/"
+metadir = "u_skins/meta/"
+i = 1
+pages = 0
+
+c = HTTPConnection(server)
+def addpage(page):
+ global i, pages
+ print( "Page: "+str(page))
+ try:
+ c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
+ r = c.getresponse()
+ except StandardError:
+ c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
+ r = c.getresponse()
+ if r.status != 200:
+ print("Error", r.status)
+ exit(r.status)
+ data = r.read().decode()
+ l = json.loads(data)
+ if not l["success"]:
+ print("Success != True")
+ exit(1)
+ pages = int(l["pages"])
+ for s in l["skins"]:
+ f = open(skinsdir+"character_"+str(i)+".png",'wb')
+ f.write(base64.b64decode(s["img"]))
+ f.close()
+ f = open(metadir+"character_"+str(i)+".txt",'w')
+ f.write('name = "'+s["name"]+'",\n')
+ f.write('author = "'+s["author"]+'",\n')
+ f.write('comment = "'+s["license"]+'",\n')
+ f.close()
+ i = i + 1
+addpage(1)
+if pages > 1:
+ for p in range(pages-1):
+ addpage(p+2)
+print("Skins have been updated. Please run ./generate_previews.sh")
+
diff --git a/update_from_db2.py b/update_from_db2.py
new file mode 100755
index 0000000..0afe1c9
--- /dev/null
+++ b/update_from_db2.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+#from http.client import HTTPConnection
+import json
+import base64
+import requests
+
+server = "minetest.fensta.bplaced.net"
+skinsdir = "u_skins/textures/"
+metadir = "u_skins/meta/"
+i = 1
+pages = 0
+
+#c = HTTPConnection(server)
+def addpage(page):
+ global i, pages
+ print( "Page: "+str(page))
+ try:
+ #c.request("GET","/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
+ #r = c.getresponse()
+ r = requests.get("http://"+str(server)+"/api/get.json.php?getlist&page="+str(page)+"&outformat=base64")
+ except StandardError:
+ print("Error", r.status)
+ exit(r.status)
+ data = r.text
+ l = json.loads(data)
+ if not l["success"]:
+ print("Success != True")
+ exit(1)
+ pages = int(l["pages"])
+ for s in l["skins"]:
+ f = open(skinsdir+"character_"+str(i)+".png",'wb')
+ f.write(base64.b64decode(s["img"]))
+ f.close()
+ f = open(metadir+"character_"+str(i)+".txt",'w')
+ f.write('name = "'+s["name"]+'",\n')
+ f.write('author = "'+s["author"]+'",\n')
+ f.write('comment = "'+s["license"]+'",\n')
+ f.close()
+ i = i + 1
+addpage(1)
+if pages > 1:
+ for p in range(pages-1):
+ addpage(p+2)
+print("Skins have been updated. Please run ./generate_previews.sh")
+