0

Make the defaults actually work properly.

This commit is contained in:
Richard Pastrick
2012-06-08 14:39:21 -07:00
parent 28099deaf6
commit dc7a32d66d
4 changed files with 25 additions and 13 deletions

View File

@@ -66,8 +66,6 @@ static int is_slime(long map_seed, long chunkx, long chunkz) {
return (random_next_int(&seed, 10) == 0);
}
static OverlayColor default_color[] = { 40, 230, 40, 240 };
static void get_color(void *data, RenderState *state,
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
RenderPrimitiveSlime *self = (RenderPrimitiveSlime *)data;
@@ -76,7 +74,7 @@ static void get_color(void *data, RenderState *state,
*r = self->parent.color->r;
*g = self->parent.color->g;
*b = self->parent.color->b;
/* default to no overlay, until told otherwise */
*a = 0;
@@ -100,6 +98,11 @@ overlay_slime_start(void *data, RenderState *state, PyObject *support) {
self = (RenderPrimitiveSlime *)data;
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");
if (!pyseed)
return 1;

View File

@@ -23,8 +23,6 @@ typedef struct {
RenderPrimitiveOverlay parent;
} RenderPrimitiveSpawn;
static OverlayColor default_color[] = { 229, 36, 38, 0 };
static void get_color(void *data, RenderState *state,
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
RenderPrimitiveSpawn* self = (RenderPrimitiveSpawn *)data;
@@ -70,6 +68,11 @@ overlay_spawn_start(void *data, RenderState *state, PyObject *support) {
self = (RenderPrimitiveSpawn *)data;
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;
}

View File

@@ -17,8 +17,6 @@
#include "overlay.h"
static OverlayColor default_color[] = { 200, 200, 255, 155 };
static void get_color(void *data, RenderState *state,
unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a) {
RenderPrimitiveOverlay* self = (RenderPrimitiveOverlay *)data;
@@ -44,22 +42,26 @@ overlay_start(void *data, RenderState *state, PyObject *support) {
if (color == NULL) {
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(PyErr_Occurred())
if(PyErr_Occurred())
PyErr_Clear();
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
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(opt && opt != Py_None) {
return 1;
}
} else {
return 1;
}
}
return 0;
}
@@ -67,7 +69,7 @@ static void
overlay_finish(void *data, RenderState *state) {
RenderPrimitiveOverlay *self = (RenderPrimitiveOverlay *)data;
if (self->color && self->color != default_color) {
if (self->color && self->color != &self->default_color) {
free(self->color);
}

View File

@@ -24,7 +24,11 @@ typedef struct {
typedef struct {
/* top facemask and white color image, for drawing overlays */
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 default_color;
/* can be overridden in derived classes to control
overlay alpha and color
last four vars are r, g, b, a out */