From: Holger Schemel Date: Thu, 25 Mar 2010 18:59:04 +0000 (+0100) Subject: rnd-20100325-1-src X-Git-Tag: 3.3.0.0^2~18 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=328e3b0f53ca41e626fda33427f5c51325bc700b;p=rocksndiamonds.git rnd-20100325-1-src --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 4c924e42..913a3728 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -67,6 +67,8 @@ struct ConfigTypeInfo image_config_suffix[] = { ".align", ARG_UNDEFINED, TYPE_INTEGER }, { ".valign", ARG_UNDEFINED, TYPE_INTEGER }, { ".sort_priority", ARG_UNDEFINED, TYPE_INTEGER }, + { ".class", ARG_UNDEFINED, TYPE_STRING }, + { ".style", ARG_UNDEFINED, TYPE_STRING }, { NULL, NULL, 0 } }; diff --git a/src/conftime.h b/src/conftime.h index 38aa374c..441d133f 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-17 00:53" +#define COMPILE_DATE_STRING "2010-03-25 19:57" diff --git a/src/init.c b/src/init.c index abef35e1..4596e839 100644 --- a/src/init.c +++ b/src/init.c @@ -1306,6 +1306,8 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->align = ALIGN_CENTER; /* default for title screens */ g->valign = VALIGN_MIDDLE; /* default for title screens */ g->sort_priority = 0; /* default for title screens */ + g->class = 0; + g->style = STYLE_DEFAULT; g->bitmap = src_bitmap; @@ -1506,6 +1508,11 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->valign = parameter[GFX_ARG_VALIGN]; if (parameter[GFX_ARG_SORT_PRIORITY] != ARG_UNDEFINED_VALUE) g->sort_priority = parameter[GFX_ARG_SORT_PRIORITY]; + + if (parameter[GFX_ARG_CLASS] != ARG_UNDEFINED_VALUE) + g->class = parameter[GFX_ARG_CLASS]; + if (parameter[GFX_ARG_STYLE] != ARG_UNDEFINED_VALUE) + g->style = parameter[GFX_ARG_STYLE]; } static void set_graphic_parameters(int graphic) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 27cf37c6..35b9c5ab 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1969,6 +1969,20 @@ int get_parameter_value(char *value_raw, char *suffix, int type) if (string_has_parameter(value, "static_panel")) result |= ANIM_STATIC_PANEL; } + else if (strEqual(suffix, ".class")) + { + result = get_hash_from_key(value); + } + else if (strEqual(suffix, ".style")) + { + result = STYLE_DEFAULT; + + if (string_has_parameter(value, "accurate_borders")) + result |= STYLE_ACCURATE_BORDERS; + + if (string_has_parameter(value, "with_inner_corners")) + result |= STYLE_WITH_INNER_CORNERS; + } else if (strEqual(suffix, ".fade_mode")) { result = (string_has_parameter(value, "none") ? FADE_MODE_NONE : diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 62ba9fc5..52aa7a13 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1642,7 +1642,7 @@ DEFINE_HASHTABLE_REMOVE(remove_hash_entry, char, char); #define remove_hash_entry hashtable_remove #endif -static unsigned int get_hash_from_key(void *key) +unsigned int get_hash_from_key(void *key) { /* djb2 diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 414cf74e..b0b6a8d2 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -306,6 +306,8 @@ void setSetupInfo(struct TokenInfo *, int, char *); char *getSetupValue(int, void *); char *getSetupLine(struct TokenInfo *, char *, int); +unsigned int get_hash_from_key(void *); + boolean AdjustGraphicsForEMC(); void LoadLevelInfo(void); diff --git a/src/libgame/system.h b/src/libgame/system.h index 3d011718..ea4dbd17 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -207,6 +207,13 @@ #define ANIM_DEFAULT ANIM_LOOP +/* values for special drawing styles (currently only for crumbled graphics) */ +#define STYLE_NONE 0 +#define STYLE_ACCURATE_BORDERS (1 << 0) +#define STYLE_WITH_INNER_CORNERS (1 << 1) + +#define STYLE_DEFAULT STYLE_NONE + /* values for fade mode */ #define FADE_TYPE_NONE 0 #define FADE_TYPE_FADE_IN (1 << 0) diff --git a/src/main.h b/src/main.h index 739d5be2..640a4fc9 100644 --- a/src/main.h +++ b/src/main.h @@ -1906,8 +1906,10 @@ #define GFX_ARG_ALIGN 43 #define GFX_ARG_VALIGN 44 #define GFX_ARG_SORT_PRIORITY 45 +#define GFX_ARG_CLASS 46 +#define GFX_ARG_STYLE 47 -#define NUM_GFX_ARGS 46 +#define NUM_GFX_ARGS 48 /* values for sound configuration suffixes */ @@ -2697,6 +2699,9 @@ struct GraphicInfo int align, valign; /* optional setting for drawing title screens */ int sort_priority; /* optional setting for drawing title screens */ + int class; + int style; + boolean use_image_size; /* use image size as default width and height */ #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) diff --git a/src/tools.c b/src/tools.c index 42e82254..5dd62923 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1442,14 +1442,111 @@ void DrawLevelFieldThruMask(int x, int y) (e) == EL_QUICKSAND_EMPTYING || \ (e) == EL_QUICKSAND_FAST_EMPTYING)) -static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) +inline static void DrawLevelFieldCrumbledSandExtBlit(int x, int y, + int graphic, int frame, + int dir) { Bitmap *src_bitmap; int src_x, src_y; + int width, height, bx, by, cx, cy; int sx = SCREENX(x), sy = SCREENY(y); - int element; - int width, height, cx, cy, i; int crumbled_border_size = graphic_info[graphic].border_size; + int i; + + getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); + + /* draw simple, sloppy, non-corner-accurate crumbled border */ + + if (dir == 1 || dir == 2) /* left or right crumbled border */ + { + width = crumbled_border_size; + height = TILEY; + cx = (dir == 2 ? TILEX - crumbled_border_size : 0); + cy = 0; + } + else /* top or bottom crumbled border */ + { + width = TILEX; + height = crumbled_border_size; + cx = 0; + cy = (dir == 3 ? TILEY - crumbled_border_size : 0); + } + + BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, + width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); + + /* (remaining middle border part must be at least as big as corner part) */ + if (!(graphic_info[graphic].style & STYLE_ACCURATE_BORDERS) || + crumbled_border_size >= TILESIZE / 3) + return; + + /* correct corners of crumbled border, if needed */ + + if (dir == 1 || dir == 2) /* left or right crumbled border */ + { + for (i = -1; i <= 1; i+=2) + { + int xx = x; + int yy = y + i; + int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) : + BorderElement); + + /* check if neighbour field is of same crumble type */ + if (IS_CRUMBLED_TILE(xx, yy, element) && + graphic_info[graphic].class == + graphic_info[el_act2crm(element, ACTION_DEFAULT)].class) + { + /* no crumbled corner, but continued crumbled border */ + + width = crumbled_border_size; + height = crumbled_border_size; + cx = (dir == 2 ? TILEX - crumbled_border_size : 0); + cy = (i == 1 ? TILEX - crumbled_border_size : 0); + bx = cx; + by = (i == 1 ? crumbled_border_size : + TILEY - 2 * crumbled_border_size); + + BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by, + width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); + } + } + } + else /* top or bottom crumbled border */ + { + for (i = -1; i <= 1; i+=2) + { + int xx = x + i; + int yy = y; + int element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) : + BorderElement); + + /* check if neighbour field is of same crumble type */ + if (IS_CRUMBLED_TILE(xx, yy, element) && + graphic_info[graphic].class == + graphic_info[el_act2crm(element, ACTION_DEFAULT)].class) + { + /* no crumbled corner, but continued crumbled border */ + + width = crumbled_border_size; + height = crumbled_border_size; + cx = (i == 1 ? TILEX - crumbled_border_size : 0); + cy = (dir == 3 ? TILEY - crumbled_border_size : 0); + bx = (i == 1 ? crumbled_border_size : + TILEY - 2 * crumbled_border_size); + by = cy; + + BlitBitmap(src_bitmap, drawto_field, src_x + bx, src_y + by, + width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); + } + } + } +} + +static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) +{ + int sx = SCREENX(x), sy = SCREENY(y); + int element; + int i; static int xy[4][2] = { { 0, -1 }, @@ -1464,17 +1561,11 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) element = TILE_GFX_ELEMENT(x, y); /* crumble field itself */ -#if 1 if (IS_CRUMBLED_TILE(x, y, element)) -#else - if (GFX_CRUMBLED(element) && !IS_MOVING(x, y)) -#endif { if (!IN_SCR_FIELD(sx, sy)) return; - getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); - for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; @@ -1483,37 +1574,23 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) element = (IN_LEV_FIELD(xx, yy) ? TILE_GFX_ELEMENT(xx, yy) : BorderElement); - /* check if neighbour field is of same type */ + /* check if neighbour field is of same crumble type */ #if 1 - if (IS_CRUMBLED_TILE(xx, yy, element)) + if (IS_CRUMBLED_TILE(xx, yy, element) && + graphic_info[graphic].class == + graphic_info[el_act2crm(element, ACTION_DEFAULT)].class) continue; #else - if (GFX_CRUMBLED(element) && !IS_MOVING(xx, yy)) + if (IS_CRUMBLED_TILE(xx, yy, element)) continue; #endif - if (i == 1 || i == 2) - { - width = crumbled_border_size; - height = TILEY; - cx = (i == 2 ? TILEX - crumbled_border_size : 0); - cy = 0; - } - else - { - width = TILEX; - height = crumbled_border_size; - cx = 0; - cy = (i == 3 ? TILEY - crumbled_border_size : 0); - } - - BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, - width, height, FX + sx * TILEX + cx, FY + sy * TILEY + cy); + DrawLevelFieldCrumbledSandExtBlit(x, y, graphic, frame, i); } MarkTileDirty(sx, sy); } - else /* crumble neighbour fields */ + else /* center field not crumbled -- crumble neighbour fields */ { for (i = 0; i < 4; i++) { @@ -1522,52 +1599,21 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) int sxx = sx + xy[i][0]; int syy = sy + xy[i][1]; -#if 1 if (!IN_LEV_FIELD(xx, yy) || !IN_SCR_FIELD(sxx, syy)) continue; -#else - if (!IN_LEV_FIELD(xx, yy) || - !IN_SCR_FIELD(sxx, syy) || - IS_MOVING(xx, yy)) - continue; -#endif if (Feld[xx][yy] == EL_ELEMENT_SNAPPING) continue; element = TILE_GFX_ELEMENT(xx, yy); -#if 1 if (!IS_CRUMBLED_TILE(xx, yy, element)) continue; -#else - if (!GFX_CRUMBLED(element)) - continue; -#endif graphic = el_act2crm(element, ACTION_DEFAULT); - crumbled_border_size = graphic_info[graphic].border_size; - - getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); - - if (i == 1 || i == 2) - { - width = crumbled_border_size; - height = TILEY; - cx = (i == 1 ? TILEX - crumbled_border_size : 0); - cy = 0; - } - else - { - width = TILEX; - height = crumbled_border_size; - cx = 0; - cy = (i == 0 ? TILEY - crumbled_border_size : 0); - } - BlitBitmap(src_bitmap, drawto_field, src_x + cx, src_y + cy, - width, height, FX + sxx * TILEX + cx, FY + syy * TILEY + cy); + DrawLevelFieldCrumbledSandExtBlit(xx, yy, graphic, 0, 3 - i); MarkTileDirty(sxx, syy); }