1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
Origin: upstream,https://github.com/OpenTTD/OpenGFX/commit/39c35c7678c0aa22d209e1eb4bb1d5f898c85f99
Origin: upstream,https://github.com/OpenTTD/OpenGFX/commit/a1f615152a01b58a4d1f6c915900ecd17a8fe628
Origin: upstream,https://github.com/OpenTTD/OpenGFX/commit/9b8a707ef4ebef14e3725e139b072a3d05deb074
Description: Fix build with gimp3
This backports three commits from upstream intended to work with gimp3,
which has made some backward-incompatible gimpscript changes and now
requires an explicit --batch-interpreter option. It also switches from
gimp to gimp-console, to work around a bug
https://gitlab.gnome.org/GNOME/gimp/-/issues/12042
This slightly modified the patches to backport them, since upstream
switched from "which" to "command", which was not done in this version
yet (so this sticks to "which").
This change should still be compatible with gimp2 as well.
Index: openttd-opengfx/Makefile
===================================================================
--- openttd-opengfx.orig/Makefile
+++ openttd-opengfx/Makefile
@@ -97,8 +97,14 @@ GREP ?= grep
PYTHON ?= python
# Graphics processing
-GIMP ?= $(shell which gimp)
-GIMP_FLAGS ?= -n -i
+GIMP ?= $(shell which gimp-console)
+GIMP_FLAGS ?= -n -i --batch-interpreter=plug-in-script-fu-eval
+
+ifneq ($(findstring GNU Image Manipulation Program version 2., $(shell $(GIMP) --version)),)
+GIMP_SCRIPT ?= $(SCRIPT_DIR)/gimpscript-v2
+else
+GIMP_SCRIPT ?= $(SCRIPT_DIR)/gimpscript
+endif
# NML
NML ?= nmlc
@@ -250,7 +256,7 @@ Makefile.gfx: $(GFX_SCRIPT_LIST_FILES) M
for i in `cat $$j | grep "\([pP][cCnN][xXgG]\)" | grep -v "^#" | cut -d\ -f1 | sed "s/\.\([pP][cCnN][xXgG]\)//"`; do\
echo "$$i.scm: $$j" >> $@;\
echo "GFX_FILES += $$i.png" >> $@;\
- cat $(SCRIPT_DIR)/gimpscript > $$i.scm.new;\
+ cat $(GIMP_SCRIPT) > $$i.scm.new;\
grep $$i.png $$j | sed -f $(SCRIPT_DIR)/gimp.sed >> $$i.scm.new;\
echo "(gimp-quit 0)" >> $$i.scm.new;\
cmp -s $$i.scm.new $$i.scm || cp $$i.scm.new $$i.scm;\
Index: openttd-opengfx/scripts/gimpscript
===================================================================
--- openttd-opengfx.orig/scripts/gimpscript
+++ openttd-opengfx/scripts/gimpscript
@@ -5,8 +5,8 @@
(define (script-fu-set-all-layers-invisible inImage inDrawable)
(let* (
(layers (gimp-image-get-layers inImage))
- (num-layers (car layers))
- (layer-array (cadr layers))
+ (layer-array (car layers))
+ (num-layers (vector-length layer-array))
(theLayer)
)
@@ -14,9 +14,9 @@
(while (> num-layers 0)
(set! num-layers (- num-layers 1))
- (set! theLayer (aref layer-array num-layers))
- (if (= (car (gimp-drawable-get-visible theLayer) ) TRUE)
- (gimp-drawable-set-visible theLayer FALSE)
+ (set! theLayer (vector-ref layer-array num-layers))
+ (if (= (car (gimp-item-get-visible theLayer) ) TRUE)
+ (gimp-item-set-visible theLayer FALSE)
)
)
@@ -46,10 +46,10 @@
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE inImageName inImageName)))
- (visibleStuff (car (gimp-image-get-active-layer image)))
+ (visibleStuff (vector-ref (car (gimp-image-get-selected-layers image)) 0))
(layers (gimp-image-get-layers image))
- (num-layers (car layers))
- (layer-array (cadr layers))
+ (layer-array (car layers))
+ (num-layers (vector-length layer-array))
(thisLayer -1)
(thisNumLayers 0)
(theseLayers layers)
@@ -66,8 +66,8 @@
; iterate through all layers of the image
(while (> num-layers 0)
(set! num-layers (- num-layers 1))
- (set! thisLayer (aref layer-array num-layers))
- (set! thisLayerName (car (gimp-drawable-get-name thisLayer)))
+ (set! thisLayer (vector-ref layer-array num-layers))
+ (set! thisLayerName (car (gimp-item-get-name thisLayer)))
; (gimp-message (string-append "Image Layer-Name: " thisLayerName))
; iterate through all layer Names we shall use
@@ -75,7 +75,7 @@
(while (not (null? layerNames))
; if layerName matches this user supplied layername: make it visible
(if (string=? (car layerNames) thisLayerName)
- (gimp-drawable-set-visible thisLayer TRUE)
+ (gimp-item-set-visible thisLayer TRUE)
)
(set! layerNames (cdr layerNames))
)
@@ -83,7 +83,7 @@
; Merge all visible layers into one layer which we then save to the given filename
(set! visibleStuff (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE)))
- (file-png-save RUN-NONINTERACTIVE image visibleStuff outImageName outImageName 0 9 0 0 0 0 0)
+ (file-png-export #:run-mode RUN-NONINTERACTIVE #:image image #:file outImageName #:interlaced FALSE #:compression 9 #:bkgd FALSE #:offs FALSE #:phys FALSE #:time FALSE #:save-transparent FALSE)
(gimp-image-delete image)
)
)
Index: openttd-opengfx/scripts/gimpscript-v2
===================================================================
--- /dev/null
+++ openttd-opengfx/scripts/gimpscript-v2
@@ -0,0 +1,97 @@
+;----------script-fu-set-all-layers-invisible----------
+;procedure by Hevan53
+;------------------------------------------------------
+
+(define (script-fu-set-all-layers-invisible inImage inDrawable)
+ (let* (
+ (layers (gimp-image-get-layers inImage))
+ (num-layers (car layers))
+ (layer-array (cadr layers))
+ (theLayer)
+ )
+
+ (gimp-image-undo-group-start inImage)
+
+ (while (> num-layers 0)
+ (set! num-layers (- num-layers 1))
+ (set! theLayer (aref layer-array num-layers))
+ (if (= (car (gimp-drawable-get-visible theLayer) ) TRUE)
+ (gimp-drawable-set-visible theLayer FALSE)
+ )
+ )
+
+ (gimp-image-undo-group-end inImage)
+ (gimp-displays-flush)
+
+ )
+)
+
+;--------------------save-layers-----------------------
+;procedure by planetmaker
+;
+; // List of source and target images followed by a list of layer names
+; // in the source image which will make up the target image.
+;
+; // Example:
+; // (save-layers "source-file-name" "target-file-name" '(layername1 layername2 layername3 ...))
+;------------------------------------------------------
+(define
+ (
+ save-layers
+
+ inImageName
+ outImageName
+ inLayerNames
+ )
+ (let*
+ (
+ (image (car (gimp-file-load RUN-NONINTERACTIVE inImageName inImageName)))
+ (visibleStuff (car (gimp-image-get-active-layer image)))
+ (layers (gimp-image-get-layers image))
+ (num-layers (car layers))
+ (layer-array (cadr layers))
+ (thisLayer -1)
+ (thisNumLayers 0)
+ (theseLayers layers)
+ (thisLayerName 0)
+
+ (layerNames inLayerNames)
+ )
+
+ ; First make everything invisble
+ (script-fu-set-all-layers-invisible image image)
+
+ ; Now make those layers visible which were asked to become visible
+
+ ; iterate through all layers of the image
+ (while (> num-layers 0)
+ (set! num-layers (- num-layers 1))
+ (set! thisLayer (aref layer-array num-layers))
+ (set! thisLayerName (car (gimp-drawable-get-name thisLayer)))
+ ; (gimp-message (string-append "Image Layer-Name: " thisLayerName))
+
+ ; iterate through all layer Names we shall use
+ (set! layerNames inLayerNames)
+ (while (not (null? layerNames))
+ ; if layerName matches this user supplied layername: make it visible
+ (if (string=? (car layerNames) thisLayerName)
+ (gimp-drawable-set-visible thisLayer TRUE)
+ )
+ (set! layerNames (cdr layerNames))
+ )
+ )
+
+ ; Merge all visible layers into one layer which we then save to the given filename
+ (set! visibleStuff (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE)))
+ (file-png-save RUN-NONINTERACTIVE image visibleStuff outImageName outImageName 0 9 0 0 0 0 0)
+ (gimp-image-delete image)
+ )
+)
+
+
+; // ===================================================================
+; // List of source and target images followed by a list of layer names
+; // in the source image which will make up the target image.
+; // Example:
+; // (save-layers "source-file-name" "target-file-name" '(layername1 layername2 layername3 ...))
+; // ===================================================================
|