projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20140514-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
gadgets.c
diff --git
a/src/libgame/gadgets.c
b/src/libgame/gadgets.c
index 23c51d36f4a9a15ff0608a3a6f27a1c00ff0cca4..8b99078ebfd62d3963eaa65777eee631192b0ccc 100644
(file)
--- a/
src/libgame/gadgets.c
+++ b/
src/libgame/gadgets.c
@@
-26,6
+26,9
@@
#define DG_BUFFERED 0
#define DG_DIRECT 1
#define DG_BUFFERED 0
#define DG_DIRECT 1
+#define GADGET_DEACTIVATED(g) ((g)->x < 0 || (g)->y < 0)
+
+
static struct GadgetInfo *gadget_list_first_entry = NULL;
static struct GadgetInfo *gadget_list_last_entry = NULL;
static struct GadgetInfo *last_info_gi = NULL;
static struct GadgetInfo *gadget_list_first_entry = NULL;
static struct GadgetInfo *gadget_list_last_entry = NULL;
static struct GadgetInfo *last_info_gi = NULL;
@@
-381,10
+384,16
@@
static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
gi->height - 2 * border_y);
/* gadget text value */
gi->height - 2 * border_y);
/* gadget text value */
+#if 1
+ DrawTextBuffer(gi->x + border_x, gi->y + border_y, gi->textarea.value,
+ font_nr, gi->textarea.xsize, -1, gi->textarea.ysize, 0,
+ BLIT_ON_BACKGROUND, FALSE, FALSE, FALSE);
+#else
DrawTextToTextArea(gi->x + border_x, gi->y + border_y,
gi->textarea.value, font_nr, gi->textarea.xsize,
gi->textarea.xsize, gi->textarea.ysize,
BLIT_ON_BACKGROUND);
DrawTextToTextArea(gi->x + border_x, gi->y + border_y,
gi->textarea.value, font_nr, gi->textarea.xsize,
gi->textarea.xsize, gi->textarea.ysize,
BLIT_ON_BACKGROUND);
+#endif
cursor_letter = gi->textarea.value[gi->textarea.cursor_position];
cursor_string[0] = (cursor_letter != '\0' ? cursor_letter : ' ');
cursor_letter = gi->textarea.value[gi->textarea.cursor_position];
cursor_string[0] = (cursor_letter != '\0' ? cursor_letter : ' ');
@@
-700,9
+709,21
@@
static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
gi->selectbox.x, gi->selectbox.y);
}
else
gi->selectbox.x, gi->selectbox.y);
}
else
+ {
+#if 1
+ int x = gi->x;
+ int y = gi->y;
+
+ redraw_mask |= (IN_GFX_FIELD_FULL(x, y) ? REDRAW_FIELD :
+ IN_GFX_DOOR_1(x, y) ? REDRAW_DOOR_1 :
+ IN_GFX_DOOR_2(x, y) ? REDRAW_DOOR_2 :
+ IN_GFX_DOOR_3(x, y) ? REDRAW_DOOR_3 : REDRAW_ALL);
+#else
redraw_mask |= (gi->x < gfx.sx + gfx.sxsize ? REDRAW_FIELD :
gi->y < gfx.dy + gfx.dysize ? REDRAW_DOOR_1 :
gi->y > gfx.vy ? REDRAW_DOOR_2 : REDRAW_DOOR_3);
redraw_mask |= (gi->x < gfx.sx + gfx.sxsize ? REDRAW_FIELD :
gi->y < gfx.dy + gfx.dysize ? REDRAW_DOOR_1 :
gi->y > gfx.vy ? REDRAW_DOOR_2 : REDRAW_DOOR_3);
+#endif
+ }
}
static int get_minimal_size_for_numeric_input(int minmax_value)
}
static int get_minimal_size_for_numeric_input(int minmax_value)
@@
-1242,6
+1263,9
@@
void FreeGadget(struct GadgetInfo *gi)
{
struct GadgetInfo *gi_previous = gadget_list_first_entry;
{
struct GadgetInfo *gi_previous = gadget_list_first_entry;
+ if (gi == NULL)
+ return;
+
/* prevent "last_info_gi" from pointing to memory that will be freed */
if (last_info_gi == gi)
last_info_gi = NULL;
/* prevent "last_info_gi" from pointing to memory that will be freed */
if (last_info_gi == gi)
last_info_gi = NULL;
@@
-1286,7
+1310,7
@@
static struct GadgetInfo *last_gi = NULL;
static void MapGadgetExt(struct GadgetInfo *gi, boolean redraw)
{
static void MapGadgetExt(struct GadgetInfo *gi, boolean redraw)
{
- if (gi == NULL || gi->mapped)
+ if (gi == NULL || gi->mapped
|| GADGET_DEACTIVATED(gi)
)
return;
gi->mapped = TRUE;
return;
gi->mapped = TRUE;
@@
-1318,9
+1342,11
@@
void UnmapGadget(struct GadgetInfo *gi)
#define MULTIMAP_PLAYFIELD (1 << 3)
#define MULTIMAP_DOOR_1 (1 << 4)
#define MULTIMAP_DOOR_2 (1 << 5)
#define MULTIMAP_PLAYFIELD (1 << 3)
#define MULTIMAP_DOOR_1 (1 << 4)
#define MULTIMAP_DOOR_2 (1 << 5)
+#define MULTIMAP_DOOR_3 (1 << 6)
#define MULTIMAP_ALL (MULTIMAP_PLAYFIELD | \
#define MULTIMAP_ALL (MULTIMAP_PLAYFIELD | \
- MULTIMAP_DOOR_1 | \
- MULTIMAP_DOOR_2)
+ MULTIMAP_DOOR_1 | \
+ MULTIMAP_DOOR_2 | \
+ MULTIMAP_DOOR_3)
static void MultiMapGadgets(int mode)
{
static void MultiMapGadgets(int mode)
{
@@
-1330,6
+1356,16
@@
static void MultiMapGadgets(int mode)
while (gi != NULL)
{
while (gi != NULL)
{
+#if 1
+ int x = gi->x;
+ int y = gi->y;
+
+ if ((mode & MULTIMAP_PLAYFIELD && IN_GFX_FIELD_FULL(x, y)) ||
+ (mode & MULTIMAP_DOOR_1 && IN_GFX_DOOR_1(x, y)) ||
+ (mode & MULTIMAP_DOOR_2 && IN_GFX_DOOR_2(x, y)) ||
+ (mode & MULTIMAP_DOOR_3 && IN_GFX_DOOR_3(x, y)) ||
+ (mode & MULTIMAP_ALL) == MULTIMAP_ALL)
+#else
if ((mode & MULTIMAP_PLAYFIELD &&
gi->x < gfx.sx + gfx.sxsize) ||
(mode & MULTIMAP_DOOR_1 &&
if ((mode & MULTIMAP_PLAYFIELD &&
gi->x < gfx.sx + gfx.sxsize) ||
(mode & MULTIMAP_DOOR_1 &&
@@
-1337,6
+1373,7
@@
static void MultiMapGadgets(int mode)
(mode & MULTIMAP_DOOR_2 &&
gi->x >= gfx.dx && gi->y > gfx.dy + gfx.dysize) ||
(mode & MULTIMAP_ALL) == MULTIMAP_ALL)
(mode & MULTIMAP_DOOR_2 &&
gi->x >= gfx.dx && gi->y > gfx.dy + gfx.dysize) ||
(mode & MULTIMAP_ALL) == MULTIMAP_ALL)
+#endif
{
if (mode & MULTIMAP_UNMAP)
{
{
if (mode & MULTIMAP_UNMAP)
{
@@
-1393,18
+1430,18
@@
boolean anyTextGadgetActive()
static boolean insideSelectboxLine(struct GadgetInfo *gi, int mx, int my)
{
static boolean insideSelectboxLine(struct GadgetInfo *gi, int mx, int my)
{
- return(gi != NULL &&
- gi->type & GD_TYPE_SELECTBOX &&
- mx >= gi->x && mx < gi->x + gi->width &&
- my >= gi->y && my < gi->y + gi->height);
+ return
(gi != NULL &&
+
gi->type & GD_TYPE_SELECTBOX &&
+
mx >= gi->x && mx < gi->x + gi->width &&
+
my >= gi->y && my < gi->y + gi->height);
}
static boolean insideSelectboxArea(struct GadgetInfo *gi, int mx, int my)
{
}
static boolean insideSelectboxArea(struct GadgetInfo *gi, int mx, int my)
{
- return(gi != NULL &&
- gi->type & GD_TYPE_SELECTBOX &&
- mx >= gi->selectbox.x && mx < gi->selectbox.x + gi->selectbox.width &&
- my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height);
+ return
(gi != NULL &&
+
gi->type & GD_TYPE_SELECTBOX &&
+
mx >= gi->selectbox.x && mx < gi->selectbox.x + gi->selectbox.width &&
+
my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height);
}
void ClickOnGadget(struct GadgetInfo *gi, int button)
}
void ClickOnGadget(struct GadgetInfo *gi, int button)
@@
-1425,8
+1462,8
@@
void ClickOnGadget(struct GadgetInfo *gi, int button)
boolean HandleGadgets(int mx, int my, int button)
{
boolean HandleGadgets(int mx, int my, int button)
{
- static unsigned
long
pressed_delay = 0;
- static unsigned
long
pressed_delay_value = GADGET_FRAME_DELAY;
+ static unsigned
int
pressed_delay = 0;
+ static unsigned
int
pressed_delay_value = GADGET_FRAME_DELAY;
static int last_button = 0;
static int last_mx = 0, last_my = 0;
static int pressed_mx = 0, pressed_my = 0;
static int last_button = 0;
static int last_mx = 0, last_my = 0;
static int pressed_mx = 0, pressed_my = 0;
@@
-1452,7
+1489,9
@@
boolean HandleGadgets(int mx, int my, int button)
boolean gadget_dragging;
boolean gadget_released;
boolean gadget_released_inside;
boolean gadget_dragging;
boolean gadget_released;
boolean gadget_released_inside;
+#if 0
boolean gadget_released_inside_select_line;
boolean gadget_released_inside_select_line;
+#endif
boolean gadget_released_inside_select_area;
boolean gadget_released_off_borders;
boolean changed_position = FALSE;
boolean gadget_released_inside_select_area;
boolean gadget_released_off_borders;
boolean changed_position = FALSE;
@@
-1555,12
+1594,16
@@
boolean HandleGadgets(int mx, int my, int button)
/* when handling selectbox, set additional state values */
if (gadget_released_inside && (last_gi->type & GD_TYPE_SELECTBOX))
{
/* when handling selectbox, set additional state values */
if (gadget_released_inside && (last_gi->type & GD_TYPE_SELECTBOX))
{
+#if 0
gadget_released_inside_select_line = insideSelectboxLine(last_gi, mx, my);
gadget_released_inside_select_line = insideSelectboxLine(last_gi, mx, my);
+#endif
gadget_released_inside_select_area = insideSelectboxArea(last_gi, mx, my);
}
else
{
gadget_released_inside_select_area = insideSelectboxArea(last_gi, mx, my);
}
else
{
+#if 0
gadget_released_inside_select_line = FALSE;
gadget_released_inside_select_line = FALSE;
+#endif
gadget_released_inside_select_area = FALSE;
}
gadget_released_inside_select_area = FALSE;
}