From 05e0bf5b30720cfad42013383a8798cda220ea49 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 3 Sep 2016 16:56:10 +0200 Subject: [PATCH] new command to retrieve the water colour getwatercolour Returns a string with the four components of the water colour, red, green, blue and alpha. Example: echo (getwatercolor) --> 20 25 20 178 setwatercolour what value Allows setting the components of the water colour independently. "what" is either a keyword "red|green|blue|alpha" or the index number 0..3 and determines, which component is set to "value". Example: watercolour 0 0 0 sets all colour components to zero setwatercolour red 200 sets the red component to 200 DOCREF getwatercolour setwatercolour --- source/src/water.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/src/water.cpp b/source/src/water.cpp index 98dacf45..129da005 100644 --- a/source/src/water.cpp +++ b/source/src/water.cpp @@ -36,6 +36,26 @@ void setwatercolor(const char *r, const char *g, const char *b, const char *a) COMMANDN(watercolour, setwatercolor, "ssss"); FVAR(waveheight, 0, 0.3f, 1.0f); +void getwatercolour() +{ + defformatstring(res)("%d %d %d %d", hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], hdr.watercolor[3]); + result(res); +} +COMMAND(getwatercolour, ""); + +const char *componentnames[] = { "red", "green", "blue", "alpha", "" }; + +void setwatercolour(char *what, int *v) +{ + int t = getlistindex(what, componentnames, true, -1); + if(t >= 0 && t < 4) + { + hdr.watercolor[t] = *v; + if(editmode) unsavededits++; + } +} +COMMAND(setwatercolour, "si"); + // renders water for bounding rect area that contains water... simple but very inefficient #define VERTW(vertw, defbody, body) \