Make the defaults actually work properly.
This commit is contained in:
@@ -66,8 +66,6 @@ static int is_slime(long map_seed, long chunkx, long chunkz) {
|
|||||||
return (random_next_int(&seed, 10) == 0);
|
return (random_next_int(&seed, 10) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OverlayColor default_color[] = { 40, 230, 40, 240 };
|
|
||||||
|
|
||||||
static void get_color(void *data, RenderState *state,
|
static void get_color(void *data, RenderState *state,
|
||||||
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
||||||
RenderPrimitiveSlime *self = (RenderPrimitiveSlime *)data;
|
RenderPrimitiveSlime *self = (RenderPrimitiveSlime *)data;
|
||||||
@@ -100,6 +98,11 @@ overlay_slime_start(void *data, RenderState *state, PyObject *support) {
|
|||||||
self = (RenderPrimitiveSlime *)data;
|
self = (RenderPrimitiveSlime *)data;
|
||||||
self->parent.get_color = get_color;
|
self->parent.get_color = get_color;
|
||||||
|
|
||||||
|
self->parent.default_color.r = 40;
|
||||||
|
self->parent.default_color.g = 230;
|
||||||
|
self->parent.default_color.b = 40;
|
||||||
|
self->parent.default_color.a = 240;
|
||||||
|
|
||||||
pyseed = PyObject_GetAttrString(state->world, "seed");
|
pyseed = PyObject_GetAttrString(state->world, "seed");
|
||||||
if (!pyseed)
|
if (!pyseed)
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ typedef struct {
|
|||||||
RenderPrimitiveOverlay parent;
|
RenderPrimitiveOverlay parent;
|
||||||
} RenderPrimitiveSpawn;
|
} RenderPrimitiveSpawn;
|
||||||
|
|
||||||
static OverlayColor default_color[] = { 229, 36, 38, 0 };
|
|
||||||
|
|
||||||
static void get_color(void *data, RenderState *state,
|
static void get_color(void *data, RenderState *state,
|
||||||
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
||||||
RenderPrimitiveSpawn* self = (RenderPrimitiveSpawn *)data;
|
RenderPrimitiveSpawn* self = (RenderPrimitiveSpawn *)data;
|
||||||
@@ -70,6 +68,11 @@ overlay_spawn_start(void *data, RenderState *state, PyObject *support) {
|
|||||||
self = (RenderPrimitiveSpawn *)data;
|
self = (RenderPrimitiveSpawn *)data;
|
||||||
self->parent.get_color = get_color;
|
self->parent.get_color = get_color;
|
||||||
|
|
||||||
|
self->parent.default_color.r = 229;
|
||||||
|
self->parent.default_color.g = 36;
|
||||||
|
self->parent.default_color.b = 38;
|
||||||
|
self->parent.default_color.a = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
#include "overlay.h"
|
#include "overlay.h"
|
||||||
|
|
||||||
static OverlayColor default_color[] = { 200, 200, 255, 155 };
|
|
||||||
|
|
||||||
static void get_color(void *data, RenderState *state,
|
static void get_color(void *data, RenderState *state,
|
||||||
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
|
||||||
RenderPrimitiveOverlay* self = (RenderPrimitiveOverlay *)data;
|
RenderPrimitiveOverlay* self = (RenderPrimitiveOverlay *)data;
|
||||||
@@ -45,21 +43,25 @@ overlay_start(void *data, RenderState *state, PyObject *support) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self->default_color.r = 200;
|
||||||
|
self->default_color.g = 200;
|
||||||
|
self->default_color.b = 255;
|
||||||
|
self->default_color.a = 155;
|
||||||
|
|
||||||
if(!render_mode_parse_option(support, "overlay_color", "bbbb", &(color->r), &(color->g), &(color->b), &(color->a))) {
|
if(!render_mode_parse_option(support, "overlay_color", "bbbb", &(color->r), &(color->g), &(color->b), &(color->a))) {
|
||||||
if(PyErr_Occurred())
|
if(PyErr_Occurred())
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
free(color);
|
free(color);
|
||||||
self->color = default_color;
|
self->color = &self->default_color;
|
||||||
// Check if it is None, if it is, continue and use the default, if it isn't, return an error
|
// Check if it is None, if it is, continue and use the default, if it isn't, return an error
|
||||||
if(render_mode_parse_option(support, "overlay_color", "O", &(opt))) {
|
if(render_mode_parse_option(support, "overlay_color", "O", &(opt))) {
|
||||||
// If it is an object, check to see if it is None, if it is, use the default.
|
// If it is an object, check to see if it is None, if it is, use the default.
|
||||||
if(opt && opt != Py_None) {
|
if(opt && opt != Py_None) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ static void
|
|||||||
overlay_finish(void *data, RenderState *state) {
|
overlay_finish(void *data, RenderState *state) {
|
||||||
RenderPrimitiveOverlay *self = (RenderPrimitiveOverlay *)data;
|
RenderPrimitiveOverlay *self = (RenderPrimitiveOverlay *)data;
|
||||||
|
|
||||||
if (self->color && self->color != default_color) {
|
if (self->color && self->color != &self->default_color) {
|
||||||
free(self->color);
|
free(self->color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,11 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
/* top facemask and white color image, for drawing overlays */
|
/* top facemask and white color image, for drawing overlays */
|
||||||
PyObject *facemask_top, *white_color;
|
PyObject *facemask_top, *white_color;
|
||||||
|
/* color will be a pointer to either the default_color object below or
|
||||||
|
to a specially allocated color object that is instantiated from the
|
||||||
|
settings file */
|
||||||
OverlayColor *color;
|
OverlayColor *color;
|
||||||
|
OverlayColor default_color;
|
||||||
/* can be overridden in derived classes to control
|
/* can be overridden in derived classes to control
|
||||||
overlay alpha and color
|
overlay alpha and color
|
||||||
last four vars are r, g, b, a out */
|
last four vars are r, g, b, a out */
|
||||||
|
|||||||
Reference in New Issue
Block a user