+2006-07-30
+ * improved down-scaling of images for better level and preview graphics
+
2006-07-26
* improved level number selection in main menu and player selection in
setup menu (input devices section) by using standard button gadgets
-#define COMPILE_DATE_STRING "[2006-07-27 11:23]"
+#define COMPILE_DATE_STRING "[2006-07-30 12:51]"
}
/* do not use scroll wheel button events for anything other than gadgets */
- if (button_nr > 3)
+ if (IS_WHEEL_BUTTON(button_nr))
return;
switch (game_status)
struct GadgetInfo *gi;
/* first check for scrollbars in case of mouse scroll wheel button events */
- if (button == 4 || button == 5)
+ if (IS_WHEEL_BUTTON(button))
{
- boolean check_horizontal = (GetKeyModState() & KMOD_Control);
+ /* real horizontal wheel or vertical wheel with modifier key pressed */
+ boolean check_horizontal = (IS_WHEEL_BUTTON_HORIZONTAL(button) ||
+ GetKeyModState() & KMOD_Shift);
/* check for the first active scrollbar with matching mouse wheel area */
for (gi = gadget_list_first_entry; gi != NULL; gi = gi->next)
{
int mpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? mx : my);
int gpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? gi->x : gi->y);
+ int slider_start = gpos + gi->scrollbar.position;
+ int slider_end = gpos + gi->scrollbar.position + gi->scrollbar.size - 1;
+ boolean inside_slider = (mpos >= slider_start && mpos <= slider_end);
- if (button > 3 ||
- mpos < gpos + gi->scrollbar.position ||
- mpos >= gpos + gi->scrollbar.position + gi->scrollbar.size)
+ if (IS_WHEEL_BUTTON(button) || !inside_slider)
{
/* click scrollbar one scrollbar length up/left or down/right */
int item_steps = gs->items_visible - 1;
int item_direction = (mpos < gpos + gi->scrollbar.position ? -1 : +1);
- if (button > 3)
+ if (IS_WHEEL_BUTTON(button))
{
- item_steps = 3;
- item_direction = (button == 4 ? -1 : +1);
+ boolean scroll_single_step = (GetKeyModState() & KMOD_Alt);
+
+ item_steps = (scroll_single_step ? 1 : DEFAULT_WHEEL_STEPS);
+ item_direction = (button == MB_WHEEL_UP ||
+ button == MB_WHEEL_LEFT ? -1 : +1);
}
changed_position = FALSE;
{
int mpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? mx : my);
int gpos = (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL ? gi->x : gi->y);
+ int slider_start = gpos + gi->scrollbar.position;
+ int slider_end = gpos + gi->scrollbar.position + gi->scrollbar.size - 1;
+ boolean inside_slider = (mpos >= slider_start && mpos <= slider_end);
- if (button >= 1 && button <= 3 &&
- mpos >= gpos + gi->scrollbar.position &&
- mpos < gpos + gi->scrollbar.position + gi->scrollbar.size)
+ if (!IS_WHEEL_BUTTON(button) && inside_slider)
{
/* start dragging scrollbar */
gi->scrollbar.drag_position =
Uint8 a;
} tColorRGBA;
+int zoomSurfaceRGBA_scaleDownBy2(SDL_Surface *src, SDL_Surface *dst)
+{
+ int x, y;
+ tColorRGBA *sp, *csp, *dp;
+ int sgap, dgap;
+
+ /* pointer setup */
+ sp = csp = (tColorRGBA *) src->pixels;
+ dp = (tColorRGBA *) dst->pixels;
+ sgap = src->pitch - src->w * 4;
+ dgap = dst->pitch - dst->w * 4;
+
+ for (y = 0; y < dst->h; y++)
+ {
+ sp = csp;
+
+ for (x = 0; x < dst->w; x++)
+ {
+ tColorRGBA *sp0 = sp;
+ tColorRGBA *sp1 = (tColorRGBA *) ((Uint8 *) sp + src->pitch);
+ tColorRGBA *sp00 = &sp0[0];
+ tColorRGBA *sp01 = &sp0[1];
+ tColorRGBA *sp10 = &sp1[0];
+ tColorRGBA *sp11 = &sp1[1];
+ tColorRGBA new;
+
+ /* create new color pixel from all four source color pixels */
+ new.r = (sp00->r + sp01->r + sp10->r + sp11->r) / 4;
+ new.g = (sp00->g + sp01->g + sp10->g + sp11->g) / 4;
+ new.b = (sp00->b + sp01->b + sp10->b + sp11->b) / 4;
+ new.a = (sp00->a + sp01->a + sp10->a + sp11->a) / 4;
+
+ /* draw */
+ *dp = new;
+
+ /* advance source pointers */
+ sp += 2;
+
+ /* advance destination pointer */
+ dp++;
+ }
+
+ /* advance source pointer */
+ csp = (tColorRGBA *) ((Uint8 *) csp + 2 * src->pitch);
+
+ /* advance destination pointers */
+ dp = (tColorRGBA *) ((Uint8 *) dp + dgap);
+ }
+
+ return 0;
+}
+
int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst)
{
int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy;
tColorRGBA *sp, *csp, *dp;
int sgap, dgap;
+ /* use specialized zoom function when scaling down to exactly half size */
+ if (src->w == 2 * dst->w &&
+ src->h == 2 * dst->h)
+ return zoomSurfaceRGBA_scaleDownBy2(src, dst);
+
/* variable setup */
sx = (int) (65536.0 * (float) src->w / (float) dst->w);
sy = (int) (65536.0 * (float) src->h / (float) dst->h);
boolean create_small_bitmaps)
{
Bitmap swap_bitmap;
- Bitmap *new_bitmap, *tmp_bitmap_1, *tmp_bitmap_2, *tmp_bitmap_8;
- int width_1, height_1, width_2, height_2, width_8, height_8;
+ Bitmap *new_bitmap, *tmp_bitmap_1, *tmp_bitmap_2, *tmp_bitmap_4,*tmp_bitmap_8;
+ int width_1, height_1, width_2, height_2, width_4, height_4, width_8,height_8;
int new_width, new_height;
/* calculate new image dimensions for normal sized image */
tmp_bitmap_1 = old_bitmap;
/* this is only needed to make compilers happy */
- tmp_bitmap_2 = tmp_bitmap_8 = NULL;
+ tmp_bitmap_2 = tmp_bitmap_4 = tmp_bitmap_8 = NULL;
if (create_small_bitmaps)
{
/* calculate new image dimensions for small images */
width_2 = width_1 / 2;
height_2 = height_1 / 2;
+ width_4 = width_1 / 4;
+ height_4 = height_1 / 4;
width_8 = width_1 / 8;
height_8 = height_1 / 8;
else
tmp_bitmap_2 = old_bitmap;
+ /* get image with 1/4 of normal size (for use in the level editor) */
+ if (zoom_factor != 4)
+ tmp_bitmap_4 = ZoomBitmap(tmp_bitmap_2, width_2 / 2, height_2 / 2);
+ else
+ tmp_bitmap_4 = old_bitmap;
+
/* get image with 1/8 of normal size (for use on the preview screen) */
if (zoom_factor != 8)
- tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_1, width_1 / 8, height_1 / 8);
+ tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_4, width_4 / 2, height_4 / 2);
else
tmp_bitmap_8 = old_bitmap;
}
BlitBitmap(tmp_bitmap_1, new_bitmap, 0, 0, width_1, height_1, 0, 0);
BlitBitmap(tmp_bitmap_2, new_bitmap, 0, 0, width_1 / 2, height_1 / 2,
0, height_1);
+ BlitBitmap(tmp_bitmap_4, new_bitmap, 0, 0, width_1 / 4, height_1 / 4,
+ width_1 / 2, height_1);
BlitBitmap(tmp_bitmap_8, new_bitmap, 0, 0, width_1 / 8, height_1 / 8,
3 * width_1 / 4, height_1);
}
if (zoom_factor != 2)
FreeBitmap(tmp_bitmap_2);
+ if (zoom_factor != 4)
+ FreeBitmap(tmp_bitmap_4);
+
if (zoom_factor != 8)
FreeBitmap(tmp_bitmap_8);
}
- /* replace image with extended image (containing normal, 1/2 and 1/8 size) */
+ /* replace image with extended image (containing 1/1, 1/2, 1/4, 1/8 size) */
#if defined(TARGET_SDL)
swap_bitmap.surface = old_bitmap->surface;
old_bitmap->surface = new_bitmap->surface;
#define MB_LEFTBUTTON 1
#define MB_MIDDLEBUTTON 2
#define MB_RIGHTBUTTON 3
-
+#define MB_WHEEL_UP 4
+#define MB_WHEEL_DOWN 5
+#define MB_WHEEL_LEFT 6
+#define MB_WHEEL_RIGHT 7
+#define IS_WHEEL_BUTTON_VERTICAL(b) ((b) >= MB_WHEEL_UP && \
+ (b) <= MB_WHEEL_DOWN)
+#define IS_WHEEL_BUTTON_HORIZONTAL(b) ((b) >= MB_WHEEL_LEFT && \
+ (b) <= MB_WHEEL_RIGHT)
+#define IS_WHEEL_BUTTON(b) ((b) >= MB_WHEEL_UP && \
+ (b) <= MB_WHEEL_DOWN)
+#define DEFAULT_WHEEL_STEPS 3
/* values for move directions */
#define MV_BIT_LEFT 0