From: Holger Schemel Date: Thu, 3 Apr 2003 00:43:46 +0000 (+0200) Subject: rnd-20030403-1-src X-Git-Tag: 3.0.0^2~118 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=72657dfeee6b6c184a42e83ed923a63c1768100b;p=rocksndiamonds.git rnd-20030403-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 015efbb7..c71f530c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-04-02 01:57]" +#define COMPILE_DATE_STRING "[2003-04-03 02:41]" diff --git a/src/editor.c b/src/editor.c index be101165..00cda340 100644 --- a/src/editor.c +++ b/src/editor.c @@ -169,32 +169,39 @@ #define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66) /* some positions in the editor control window */ -#define ED_BUTTON_ELEM_XPOS 6 -#define ED_BUTTON_ELEM_YPOS 30 -#define ED_BUTTON_ELEM_XSIZE 22 -#define ED_BUTTON_ELEM_YSIZE 22 - -/* some values for text input and counter gadgets */ -#define ED_BUTTON_COUNT_YPOS 60 -#define ED_BUTTON_COUNT_XSIZE 20 -#define ED_BUTTON_COUNT_YSIZE 20 -#define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2) -#define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS -#define ED_WIN_COUNT_XSIZE 52 -#define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE -#define ED_WIN_COUNT2_XPOS 27 -#define ED_WIN_COUNT2_YPOS 3 -#define ED_WIN_COUNT2_XSIZE 46 -#define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE - -#define ED_BUTTON_MINUS_XPOS 2 -#define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS -#define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE -#define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE -#define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + ED_WIN_COUNT_XSIZE + 2) -#define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS -#define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE -#define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE +#define ED_BUTTON_ELEM_XPOS 6 +#define ED_BUTTON_ELEM_YPOS 30 +#define ED_BUTTON_ELEM_XSIZE 22 +#define ED_BUTTON_ELEM_YSIZE 22 + +/* some values for text input, selectbox and counter gadgets */ +#define ED_BUTTON_COUNT_YPOS 60 +#define ED_BUTTON_COUNT_XSIZE 20 +#define ED_BUTTON_COUNT_YSIZE 20 +#define ED_WIN_COUNT_XPOS (2 + ED_BUTTON_COUNT_XSIZE + 2) +#define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS +#define ED_WIN_COUNT_XSIZE 52 +#define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE +#define ED_WIN_COUNT2_XPOS 27 +#define ED_WIN_COUNT2_YPOS 3 +#define ED_WIN_COUNT2_XSIZE 46 +#define ED_WIN_COUNT2_YSIZE ED_BUTTON_COUNT_YSIZE + +#define ED_BUTTON_MINUS_XPOS 2 +#define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS +#define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE +#define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE +#define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS + \ + ED_WIN_COUNT_XSIZE + 2) +#define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS +#define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE +#define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE + +#define ED_SELECTBOX_XPOS ED_WIN_COUNT_XPOS +#define ED_SELECTBOX_YPOS (ED_WIN_COUNT_YPOS + 2 + \ + ED_WIN_COUNT_YSIZE) +#define ED_SELECTBOX_XSIZE ED_WIN_COUNT_XSIZE +#define ED_SELECTBOX_YSIZE ED_WIN_COUNT_YSIZE /* editor gadget identifiers */ @@ -269,35 +276,38 @@ #define GADGET_ID_LEVEL_NAME 60 #define GADGET_ID_LEVEL_AUTHOR 61 +/* selectbox identifiers */ +#define GADGET_ID_SELECTBOX_TEST 62 + /* gadgets for scrolling of drawing area */ -#define GADGET_ID_SCROLL_UP 62 -#define GADGET_ID_SCROLL_DOWN 63 -#define GADGET_ID_SCROLL_LEFT 64 -#define GADGET_ID_SCROLL_RIGHT 65 -#define GADGET_ID_SCROLL_HORIZONTAL 66 -#define GADGET_ID_SCROLL_VERTICAL 67 +#define GADGET_ID_SCROLL_UP 63 +#define GADGET_ID_SCROLL_DOWN 64 +#define GADGET_ID_SCROLL_LEFT 65 +#define GADGET_ID_SCROLL_RIGHT 66 +#define GADGET_ID_SCROLL_HORIZONTAL 67 +#define GADGET_ID_SCROLL_VERTICAL 68 /* gadgets for scrolling element list */ -#define GADGET_ID_SCROLL_LIST_UP 68 -#define GADGET_ID_SCROLL_LIST_DOWN 69 -#define GADGET_ID_SCROLL_LIST_VERTICAL 70 +#define GADGET_ID_SCROLL_LIST_UP 69 +#define GADGET_ID_SCROLL_LIST_DOWN 70 +#define GADGET_ID_SCROLL_LIST_VERTICAL 71 /* buttons for level/element properties */ -#define GADGET_ID_RANDOM_PERCENTAGE 71 -#define GADGET_ID_RANDOM_QUANTITY 72 -#define GADGET_ID_RANDOM_RESTRICTED 73 -#define GADGET_ID_DOUBLE_SPEED 74 -#define GADGET_ID_GRAVITY 75 -#define GADGET_ID_STICK_ELEMENT 76 -#define GADGET_ID_EM_SLIPPERY_GEMS 77 -#define GADGET_ID_CUSTOM_INDESTRUCTIBLE 78 -#define GADGET_ID_CUSTOM_CAN_FALL 79 -#define GADGET_ID_CUSTOM_CAN_SMASH 80 -#define GADGET_ID_CUSTOM_PUSHABLE 81 -#define GADGET_ID_CUSTOM_SLIPPERY 82 +#define GADGET_ID_RANDOM_PERCENTAGE 72 +#define GADGET_ID_RANDOM_QUANTITY 73 +#define GADGET_ID_RANDOM_RESTRICTED 74 +#define GADGET_ID_DOUBLE_SPEED 75 +#define GADGET_ID_GRAVITY 76 +#define GADGET_ID_STICK_ELEMENT 77 +#define GADGET_ID_EM_SLIPPERY_GEMS 78 +#define GADGET_ID_CUSTOM_INDESTRUCTIBLE 79 +#define GADGET_ID_CUSTOM_CAN_FALL 80 +#define GADGET_ID_CUSTOM_CAN_SMASH 81 +#define GADGET_ID_CUSTOM_PUSHABLE 82 +#define GADGET_ID_CUSTOM_SLIPPERY 83 /* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST 83 +#define GADGET_ID_ELEMENTLIST_FIRST 84 #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \ ED_NUM_ELEMENTLIST_BUTTONS - 1) @@ -356,6 +366,11 @@ #define ED_TEXTINPUT_ID_LEVEL_FIRST ED_TEXTINPUT_ID_LEVEL_NAME #define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR +/* values for selectbox gadgets */ +#define ED_SELECTBOX_ID_TEST 0 + +#define ED_NUM_SELECTBOX 1 + /* values for checkbutton gadgets */ #define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0 #define ED_CHECKBUTTON_ID_GRAVITY 1 @@ -553,6 +568,34 @@ static struct } }; +static char *test_values[] = +{ + "test 1", + "test 2", + "dieser test-text ist viel zu lang fuer die selectbox", + "letzter text" +}; +static int test_index = 0; + +static struct +{ + int x, y; + int gadget_id; + int size; + char **values; + int *index; + char *text, *infotext; +} selectbox_info[ED_NUM_SELECTBOX] = +{ + { + ED_SETTINGS_XPOS, ED_COUNTER_YPOS(3), + GADGET_ID_SELECTBOX_TEST, + MAX_PLAYER_NAME_LEN, + test_values, &test_index, + "test:", "test-selectbox entry" + }, +}; + static struct { int xpos, ypos; @@ -763,6 +806,7 @@ static void CopyLevelToUndoBuffer(int); static void HandleDrawingAreas(struct GadgetInfo *); static void HandleCounterButtons(struct GadgetInfo *); static void HandleTextInputGadgets(struct GadgetInfo *); +static void HandleSelectboxGadgets(struct GadgetInfo *); static void HandleRadiobuttons(struct GadgetInfo *); static void HandleCheckbuttons(struct GadgetInfo *); static void HandleControlButtons(struct GadgetInfo *); @@ -2158,6 +2202,55 @@ static void CreateTextInputGadgets() } } +static void CreateSelectboxGadgets() +{ + int max_infotext_len = getMaxInfoTextLength(); + int i; + + for (i=0; icustom_type_id].value, gi->text.value); } +static void HandleSelectboxGadgets(struct GadgetInfo *gi) +{ + *selectbox_info[gi->custom_type_id].index = gi->selectbox.index; + +#if 1 + printf("Selected text value: '%s'\n", + selectbox_info[gi->custom_type_id].values[gi->selectbox.index]); +#endif +} + static void HandleRadiobuttons(struct GadgetInfo *gi) { *radiobutton_info[gi->custom_type_id].value = diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 66a8e2b3..00f54c6f 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -147,14 +147,14 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) gd->x, gd->y, border, gi->height, gi->x, gi->y); /* middle part of gadget */ - for (i=0; i<=gi->text.size; i++) + for (i=0; i <= gi->text.size; i++) BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border, gd->y, font_width, gi->height, gi->x + border + i * font_width, gi->y); /* right part of gadget */ BlitBitmapOnBackground(gd->bitmap, drawto, - gd->x + gi->border.width -border, gd->y, border, + gd->x + gi->border.width - border, gd->y,border, gi->height, gi->x + gi->width - border, gi->y); /* gadget text value */ @@ -176,6 +176,48 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) } break; + case GD_TYPE_SELECTBOX: + { + int i; + char text[MAX_GADGET_TEXTSIZE + 1]; + int font_type = gi->selectbox.font_type; + int font_width = getFontWidth(font_type); + int border = gi->border.size; + int button = gi->border.size_selectbutton; + int width_inner = gi->border.width - button - 2 * border; + + strncpy(text, gi->selectbox.values[gi->selectbox.index], + MAX_GADGET_TEXTSIZE); + text[MAX_GADGET_TEXTSIZE] = '\0'; + + /* left part of gadget */ + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x, gd->y, border, gi->height, gi->x, gi->y); + + /* middle part of gadget */ + for (i=0; i <= gi->selectbox.size; i++) + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x + border, gd->y, font_width, gi->height, + gi->x + border + i * font_width, gi->y); + + /* button part of gadget */ + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x + border + width_inner, gd->y, + button, gi->height, + gi->x + gi->width - border - button, gi->y); + + /* right part of gadget */ + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x + gi->border.width - border, gd->y,border, + gi->height, gi->x + gi->width - border, gi->y); + + /* gadget text value */ + DrawTextExt(drawto, + gi->x + border, gi->y + border, text, + font_type, FONT_MASKED); + } + break; + case GD_TYPE_SCROLLBAR_VERTICAL: { int i; @@ -391,11 +433,25 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->text.size = max_textsize; gi->text.value[max_textsize] = '\0'; + + /* same tag also used for selectbox definition */ + gi->selectbox.size = gi->text.size; } break; case GDI_TEXT_FONT: gi->text.font_type = va_arg(ap, int); + + /* same tag also used for selectbox definition */ + gi->selectbox.font_type = gi->text.font_type; + break; + + case GDI_SELECTBOX_VALUES: + gi->selectbox.values = va_arg(ap, const char **); + break; + + case GDI_SELECTBOX_INDEX: + gi->selectbox.index = va_arg(ap, int); break; case GDI_DESIGN_UNPRESSED: @@ -426,6 +482,10 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->border.size = va_arg(ap, int); break; + case GDI_BORDER_SIZE_SELECTBUTTON: + gi->border.size_selectbutton = va_arg(ap, int); + break; + case GDI_TEXTINPUT_DESIGN_WIDTH: gi->border.width = va_arg(ap, int); break; @@ -520,7 +580,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) tag = va_arg(ap, int); /* read next tag */ } - /* check if gadget complete */ + /* check if gadget is complete */ if (gi->type != GD_TYPE_DRAWING_AREA && (!gi->design[GD_BUTTON_UNPRESSED].bitmap || !gi->design[GD_BUTTON_PRESSED].bitmap)) @@ -532,9 +592,21 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) { int font_width = getFontWidth(gi->text.font_type); int font_height = getFontHeight(gi->text.font_type); + int border_size = gi->border.size; + + gi->width = 2 * border_size + (gi->text.size + 1) * font_width; + gi->height = 2 * border_size + font_height; + } + + if (gi->type & GD_TYPE_SELECTBOX) + { + int font_width = getFontWidth(gi->selectbox.font_type); + int font_height = getFontHeight(gi->selectbox.font_type); + int border_size = gi->border.size; + int button_size = gi->border.size_selectbutton; - gi->width = 2 * gi->border.size + (gi->text.size + 1) * font_width; - gi->height = 2 * gi->border.size + font_height; + gi->width = 2 * border_size + gi->text.size * font_width + button_size; + gi->height = 2 * border_size + font_height; } if (gi->type & GD_TYPE_TEXTINPUT_NUMERIC) diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index 783e454f..e1208994 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -26,8 +26,9 @@ #define GD_TYPE_DRAWING_AREA (1 << 3) #define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 4) #define GD_TYPE_TEXTINPUT_NUMERIC (1 << 5) -#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 6) -#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 7) +#define GD_TYPE_SELECTBOX (1 << 6) +#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 7) +#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 8) #define GD_TYPE_BUTTON (GD_TYPE_NORMAL_BUTTON | \ GD_TYPE_CHECK_BUTTON | \ @@ -74,33 +75,37 @@ #define GDI_TEXT_VALUE 14 #define GDI_TEXT_SIZE 15 #define GDI_TEXT_FONT 16 -#define GDI_DESIGN_UNPRESSED 17 -#define GDI_DESIGN_PRESSED 18 -#define GDI_ALT_DESIGN_UNPRESSED 19 -#define GDI_ALT_DESIGN_PRESSED 20 -#define GDI_BORDER_SIZE 21 -#define GDI_TEXTINPUT_DESIGN_WIDTH 22 -#define GDI_DECORATION_DESIGN 23 -#define GDI_DECORATION_POSITION 24 -#define GDI_DECORATION_SIZE 25 -#define GDI_DECORATION_SHIFTING 26 -#define GDI_EVENT_MASK 27 -#define GDI_EVENT 28 -#define GDI_CALLBACK_INFO 29 -#define GDI_CALLBACK_ACTION 30 -#define GDI_AREA_SIZE 31 -#define GDI_ITEM_SIZE 32 -#define GDI_SCROLLBAR_ITEMS_MAX 33 -#define GDI_SCROLLBAR_ITEMS_VISIBLE 34 -#define GDI_SCROLLBAR_ITEM_POSITION 35 -#define GDI_INFO_TEXT 36 +#define GDI_SELECTBOX_VALUES 17 +#define GDI_SELECTBOX_INDEX 18 +#define GDI_DESIGN_UNPRESSED 19 +#define GDI_DESIGN_PRESSED 20 +#define GDI_ALT_DESIGN_UNPRESSED 21 +#define GDI_ALT_DESIGN_PRESSED 22 +#define GDI_BORDER_SIZE 23 +#define GDI_BORDER_SIZE_SELECTBUTTON 24 +#define GDI_TEXTINPUT_DESIGN_WIDTH 25 +#define GDI_DECORATION_DESIGN 26 +#define GDI_DECORATION_POSITION 27 +#define GDI_DECORATION_SIZE 28 +#define GDI_DECORATION_SHIFTING 29 +#define GDI_EVENT_MASK 30 +#define GDI_EVENT 31 +#define GDI_CALLBACK_INFO 32 +#define GDI_CALLBACK_ACTION 33 +#define GDI_AREA_SIZE 34 +#define GDI_ITEM_SIZE 35 +#define GDI_SCROLLBAR_ITEMS_MAX 36 +#define GDI_SCROLLBAR_ITEMS_VISIBLE 37 +#define GDI_SCROLLBAR_ITEM_POSITION 38 +#define GDI_INFO_TEXT 39 typedef void (*gadget_function)(void *); struct GadgetBorder { int size; /* size of gadget border */ - int width; /* for text input gadgets */ + int size_selectbutton; /* for selectbox gadgets */ + int width; /* for selectbox/text input gadgets */ }; struct GadgetDesign @@ -143,6 +148,14 @@ struct GadgetTextInput int font_type; /* font to use for text input */ }; +struct GadgetSelectbox +{ + const char **values; /* pointer to array of text strings */ + int index; /* index of actual text string */ + int size; /* maximal size of text strings */ + int font_type; /* font to use for text input */ +}; + struct GadgetScrollbar { int items_max; /* number of items to access */ @@ -179,6 +192,7 @@ struct GadgetInfo gadget_function callback_action; /* function for gadget action */ struct GadgetDrawingArea drawing; /* fields for drawing area gadget */ struct GadgetTextInput text; /* fields for text input gadget */ + struct GadgetSelectbox selectbox; /* fields for selectbox gadget */ struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */ struct GadgetInfo *next; /* next list entry */ };