From: Holger Schemel Date: Wed, 8 Oct 2014 23:58:07 +0000 (+0200) Subject: added handling of unselectable selectbox options X-Git-Tag: 4.0.0.0-rc1~337 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8a69c2a5a6c025385142696ac5bb9ab92e2b0dbc;p=rocksndiamonds.git added handling of unselectable selectbox options --- diff --git a/ChangeLog b/ChangeLog index 34e424d0..95f6b453 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-10-08 + * added handling of unselectable selectbox options and option headlines + 2014-10-07 * fixed bug when changing between graphic sets with different tile size * cleanup of handling the various graphic sizes for different purposes diff --git a/src/conftime.h b/src/conftime.h index 4ee3b39c..d765e447 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-10-08 00:24" +#define COMPILE_DATE_STRING "2014-10-09 01:55" diff --git a/src/editor.c b/src/editor.c index e8bc4e20..206d1c1d 100644 --- a/src/editor.c +++ b/src/editor.c @@ -5786,9 +5786,11 @@ static void CreateSelectboxGadgets() GDI_Y, y, GDI_TYPE, GD_TYPE_SELECTBOX, GDI_SELECTBOX_OPTIONS, selectbox_info[i].options, + GDI_SELECTBOX_CHAR_UNSELECTABLE, '[', GDI_TEXT_SIZE, selectbox_info[i].size, GDI_TEXT_FONT, FONT_INPUT_1, GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE, + GDI_TEXT_FONT_UNSELECTABLE, FONT_TEXT_1, GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y, GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y, GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE, diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 9c974b87..1c52ec5d 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -26,6 +26,13 @@ #define GADGET_DEACTIVATED(g) ((g)->x < 0 || (g)->y < 0) +#define OPTION_TEXT_SELECTABLE(g, t) \ + (t[0] != g->selectbox.char_unselectable && \ + t[0] != '\0' && \ + !strEqual(t, " ")) +#define CURRENT_OPTION_SELECTABLE(g) \ + OPTION_TEXT_SELECTABLE(g, g->selectbox.options[g->selectbox.current_index].text) + static struct GadgetInfo *gadget_list_first_entry = NULL; static struct GadgetInfo *gadget_list_last_entry = NULL; @@ -404,7 +411,8 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) { int i; char text[MAX_GADGET_TEXTSIZE + 1]; - int font_nr = (pressed ? gi->font_active : gi->font); + int font_nr_default = (pressed ? gi->font_active : gi->font); + int font_nr = font_nr_default; int font_width = getFontWidth(font_nr); int font_height = getFontHeight(font_nr); int border_x = gi->border.xsize; @@ -441,6 +449,10 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) gi->selectbox.size); text[gi->selectbox.size] = '\0'; + /* set font value */ + font_nr = (OPTION_TEXT_SELECTABLE(gi, text) ? font_nr_default : + gi->font_unselectable); + /* gadget text value */ DrawTextExt(drawto, gi->x + border_x, gi->y + border_y, text, font_nr, BLIT_MASKED); @@ -549,7 +561,11 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) strncpy(text, gi->selectbox.options[i].text, gi->selectbox.size); text[gi->selectbox.size] = '\0'; - if (i == gi->selectbox.current_index) + font_nr = (OPTION_TEXT_SELECTABLE(gi, text) ? font_nr_default : + gi->font_unselectable); + + if (i == gi->selectbox.current_index && + OPTION_TEXT_SELECTABLE(gi, text)) { FillRectangle(drawto, gi->selectbox.x + border_x, @@ -873,12 +889,18 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->font = va_arg(ap, int); if (gi->font_active == 0) gi->font_active = gi->font; + if (gi->font_unselectable == 0) + gi->font_unselectable = gi->font; break; case GDI_TEXT_FONT_ACTIVE: gi->font_active = va_arg(ap, int); break; + case GDI_TEXT_FONT_UNSELECTABLE: + gi->font_unselectable = va_arg(ap, int); + break; + case GDI_SELECTBOX_OPTIONS: gi->selectbox.options = va_arg(ap, struct ValueTextInfo *); break; @@ -887,6 +909,10 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->selectbox.index = va_arg(ap, int); break; + case GDI_SELECTBOX_CHAR_UNSELECTABLE: + gi->selectbox.char_unselectable = (char)va_arg(ap, int); + break; + case GDI_DESIGN_UNPRESSED: gi->design[GD_BUTTON_UNPRESSED].bitmap = va_arg(ap, Bitmap *); gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int); @@ -1591,7 +1617,8 @@ boolean HandleGadgets(int mx, int my, int button) if (gi->type & GD_TYPE_SELECTBOX && (keep_selectbox_open || mouse_released_where_pressed || - !gadget_released_inside_select_area)) /* selectbox stays open */ + !gadget_released_inside_select_area || + !CURRENT_OPTION_SELECTABLE(gi))) /* selectbox stays open */ { gi->selectbox.stay_open = TRUE; pressed_mx = 0; @@ -1949,7 +1976,8 @@ boolean HandleGadgets(int mx, int my, int button) { if (keep_selectbox_open || mouse_released_where_pressed || - !gadget_released_inside_select_area) /* selectbox stays open */ + !gadget_released_inside_select_area || + !CURRENT_OPTION_SELECTABLE(gi)) /* selectbox stays open */ { deactivate_gadget = FALSE; gadget_changed = FALSE; diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index 47de5776..5b41ba47 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -78,35 +78,37 @@ #define GDI_TEXT_SIZE 15 #define GDI_TEXT_FONT 16 #define GDI_TEXT_FONT_ACTIVE 17 -#define GDI_SELECTBOX_OPTIONS 18 -#define GDI_SELECTBOX_INDEX 19 -#define GDI_DESIGN_UNPRESSED 20 -#define GDI_DESIGN_PRESSED 21 -#define GDI_ALT_DESIGN_UNPRESSED 22 -#define GDI_ALT_DESIGN_PRESSED 23 -#define GDI_BORDER_SIZE 24 -#define GDI_BORDER_SIZE_SELECTBUTTON 25 -#define GDI_DESIGN_WIDTH 26 -#define GDI_DECORATION_DESIGN 27 -#define GDI_DECORATION_POSITION 28 -#define GDI_DECORATION_SIZE 29 -#define GDI_DECORATION_SHIFTING 30 -#define GDI_EVENT_MASK 31 -#define GDI_EVENT 32 -#define GDI_CALLBACK_INFO 33 -#define GDI_CALLBACK_ACTION 34 -#define GDI_AREA_SIZE 35 -#define GDI_ITEM_SIZE 36 -#define GDI_SCROLLBAR_ITEMS_MAX 37 -#define GDI_SCROLLBAR_ITEMS_VISIBLE 38 -#define GDI_SCROLLBAR_ITEM_POSITION 39 -#define GDI_WHEEL_AREA_X 40 -#define GDI_WHEEL_AREA_Y 41 -#define GDI_WHEEL_AREA_WIDTH 42 -#define GDI_WHEEL_AREA_HEIGHT 43 -#define GDI_INFO_TEXT 44 -#define GDI_ACTIVE 45 -#define GDI_DIRECT_DRAW 46 +#define GDI_TEXT_FONT_UNSELECTABLE 18 +#define GDI_SELECTBOX_OPTIONS 19 +#define GDI_SELECTBOX_INDEX 20 +#define GDI_SELECTBOX_CHAR_UNSELECTABLE 21 +#define GDI_DESIGN_UNPRESSED 22 +#define GDI_DESIGN_PRESSED 23 +#define GDI_ALT_DESIGN_UNPRESSED 24 +#define GDI_ALT_DESIGN_PRESSED 25 +#define GDI_BORDER_SIZE 26 +#define GDI_BORDER_SIZE_SELECTBUTTON 27 +#define GDI_DESIGN_WIDTH 28 +#define GDI_DECORATION_DESIGN 29 +#define GDI_DECORATION_POSITION 30 +#define GDI_DECORATION_SIZE 31 +#define GDI_DECORATION_SHIFTING 32 +#define GDI_EVENT_MASK 33 +#define GDI_EVENT 34 +#define GDI_CALLBACK_INFO 35 +#define GDI_CALLBACK_ACTION 36 +#define GDI_AREA_SIZE 37 +#define GDI_ITEM_SIZE 38 +#define GDI_SCROLLBAR_ITEMS_MAX 39 +#define GDI_SCROLLBAR_ITEMS_VISIBLE 40 +#define GDI_SCROLLBAR_ITEM_POSITION 41 +#define GDI_WHEEL_AREA_X 42 +#define GDI_WHEEL_AREA_Y 43 +#define GDI_WHEEL_AREA_WIDTH 44 +#define GDI_WHEEL_AREA_HEIGHT 45 +#define GDI_INFO_TEXT 46 +#define GDI_ACTIVE 47 +#define GDI_DIRECT_DRAW 48 /* gadget deactivation hack */ #define GDI_ACTIVE_POS(a) ((a) < 0 ? POS_OFFSCREEN : (a)) @@ -184,6 +186,7 @@ struct GadgetSelectbox struct ValueTextInfo *options; /* pointer to text/value array */ int index; /* index of actual text string */ int size; /* maximal size of text strings */ + char char_unselectable; /* first char of unselectable options */ /* automatically determined values */ int x, y; /* open selectbox position */ @@ -235,6 +238,7 @@ struct GadgetInfo boolean direct_draw; /* directly draw to frontbuffer */ int font; /* font to use when inactive */ int font_active; /* font to use when active */ + int font_unselectable; /* font to use when unselectable */ struct GadgetBorder border; /* gadget border design */ struct GadgetDesign design[2]; /* 0: normal; 1: pressed */ struct GadgetDesign alt_design[2]; /* alternative design */