Add support for 'alpha' option and change default
This commit is contained in:
@@ -212,6 +212,7 @@ class BiomeOverlay(Overlay):
|
|||||||
name = "overlay-biomes"
|
name = "overlay-biomes"
|
||||||
options = {
|
options = {
|
||||||
'biomes' : ('a list of (biome, (r, g, b)) tuples for coloring biomes', None),
|
'biomes' : ('a list of (biome, (r, g, b)) tuples for coloring biomes', None),
|
||||||
|
'alpha' : ('an integer value between 0 (transparent) and 255 (opaque)', None),
|
||||||
}
|
}
|
||||||
|
|
||||||
class Hide(RenderPrimitive):
|
class Hide(RenderPrimitive):
|
||||||
|
|||||||
@@ -84,9 +84,8 @@ static void get_color(void *data, RenderState *state,
|
|||||||
*g = biomes[i].g;
|
*g = biomes[i].g;
|
||||||
*b = biomes[i].b;
|
*b = biomes[i].b;
|
||||||
|
|
||||||
tmp = (128 - y_max + y) * 2 - 40;
|
*a = self->parent.color->a;
|
||||||
*a = MIN(MAX(0, tmp), 255);
|
|
||||||
|
|
||||||
max_i = i;
|
max_i = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -98,6 +97,7 @@ static int
|
|||||||
overlay_biomes_start(void *data, RenderState *state, PyObject *support) {
|
overlay_biomes_start(void *data, RenderState *state, PyObject *support) {
|
||||||
PyObject *opt;
|
PyObject *opt;
|
||||||
RenderPrimitiveBiomes* self;
|
RenderPrimitiveBiomes* self;
|
||||||
|
unsigned char alpha_tmp=0;
|
||||||
|
|
||||||
/* first, chain up */
|
/* first, chain up */
|
||||||
int ret = primitive_overlay.start(data, state, support);
|
int ret = primitive_overlay.start(data, state, support);
|
||||||
@@ -153,6 +153,14 @@ overlay_biomes_start(void *data, RenderState *state, PyObject *support) {
|
|||||||
self->biomes = default_biomes;
|
self->biomes = default_biomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!render_mode_parse_option(support, "alpha", "b", &(alpha_tmp))) {
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
PyErr_Clear();
|
||||||
|
alpha_tmp = 240;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->parent.color->a = alpha_tmp;
|
||||||
|
}
|
||||||
/* setup custom color */
|
/* setup custom color */
|
||||||
self->parent.get_color = get_color;
|
self->parent.get_color = get_color;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user