IMG_FONT_TEXT_4_SCORES
},
{
- FONT_INPUT, -1,
- IMG_FONT_INPUT
+ FONT_INPUT_1, -1,
+ IMG_FONT_INPUT_1
},
{
- FONT_INPUT, GFX_SPECIAL_ARG_MAIN,
- IMG_FONT_INPUT_MAIN
+ FONT_INPUT_1, GFX_SPECIAL_ARG_MAIN,
+ IMG_FONT_INPUT_1_MAIN
},
{
- FONT_INPUT_ACTIVE, -1,
- IMG_FONT_INPUT_ACTIVE
+ FONT_INPUT_1_ACTIVE, -1,
+ IMG_FONT_INPUT_1_ACTIVE
},
{
- FONT_INPUT_ACTIVE, GFX_SPECIAL_ARG_MAIN,
- IMG_FONT_INPUT_ACTIVE_MAIN
+ FONT_INPUT_1_ACTIVE, GFX_SPECIAL_ARG_MAIN,
+ IMG_FONT_INPUT_1_ACTIVE_MAIN
},
{
- FONT_INPUT_ACTIVE, GFX_SPECIAL_ARG_SETUP,
- IMG_FONT_INPUT_ACTIVE_SETUP
+ FONT_INPUT_1_ACTIVE, GFX_SPECIAL_ARG_SETUP,
+ IMG_FONT_INPUT_1_ACTIVE_SETUP
+ },
+ {
+ FONT_INPUT_2, -1,
+ IMG_FONT_INPUT_2
+ },
+ {
+ FONT_INPUT_2_ACTIVE, -1,
+ IMG_FONT_INPUT_2_ACTIVE
},
{
FONT_OPTION_OFF, -1,
{ "font.text_4.SCORES.width", "16" },
{ "font.text_4.SCORES.height", "32" },
- { "font.input", "RocksFontSmall.pcx" },
- { "font.input.x", "0" },
- { "font.input.y", "210" },
- { "font.input.width", "14" },
- { "font.input.height", "14" },
- { "font.input.MAIN", "RocksFontBig.pcx" },
- { "font.input.MAIN.x", "0" },
- { "font.input.MAIN.y", "0" },
- { "font.input.MAIN.width", "32" },
- { "font.input.MAIN.height", "32" },
- { "font.input.active", "RocksFontSmall.pcx" },
- { "font.input.active.x", "0" },
- { "font.input.active.y", "0" },
- { "font.input.active.width", "14" },
- { "font.input.active.height", "14" },
- { "font.input.active.MAIN", "RocksFontBig.pcx" },
- { "font.input.active.MAIN.x", "0" },
- { "font.input.active.MAIN.y", "480" },
- { "font.input.active.MAIN.width", "32" },
- { "font.input.active.MAIN.height", "32" },
- { "font.input.active.SETUP", "RocksFontBig.pcx" },
- { "font.input.active.SETUP.x", "0" },
- { "font.input.active.SETUP.y", "0" },
- { "font.input.active.SETUP.width", "32" },
- { "font.input.active.SETUP.height", "32" },
+ { "font.input_1", "RocksFontSmall.pcx" },
+ { "font.input_1.x", "0" },
+ { "font.input_1.y", "210" },
+ { "font.input_1.width", "14" },
+ { "font.input_1.height", "14" },
+ { "font.input_1.MAIN", "RocksFontBig.pcx" },
+ { "font.input_1.MAIN.x", "0" },
+ { "font.input_1.MAIN.y", "0" },
+ { "font.input_1.MAIN.width", "32" },
+ { "font.input_1.MAIN.height", "32" },
+ { "font.input_1.active", "RocksFontSmall.pcx" },
+ { "font.input_1.active.x", "0" },
+ { "font.input_1.active.y", "210" },
+ { "font.input_1.active.width", "14" },
+ { "font.input_1.active.height", "14" },
+ { "font.input_1.active.MAIN", "RocksFontBig.pcx" },
+ { "font.input_1.active.MAIN.x", "0" },
+ { "font.input_1.active.MAIN.y", "480" },
+ { "font.input_1.active.MAIN.width", "32" },
+ { "font.input_1.active.MAIN.height", "32" },
+ { "font.input_1.active.SETUP", "RocksFontBig.pcx" },
+ { "font.input_1.active.SETUP.x", "0" },
+ { "font.input_1.active.SETUP.y", "0" },
+ { "font.input_1.active.SETUP.width", "32" },
+ { "font.input_1.active.SETUP.height", "32" },
+ { "font.input_2", "RocksFontSmall.pcx" },
+ { "font.input_2.x", "0" },
+ { "font.input_2.y", "210" },
+ { "font.input_2.width", "14" },
+ { "font.input_2.height", "14" },
+ { "font.input_2.active", "RocksFontSmall.pcx" },
+ { "font.input_2.active.x", "0" },
+ { "font.input_2.active.y", "210" },
+ { "font.input_2.active.width", "14" },
+ { "font.input_2.active.height", "14" },
{ "font.option_off", "RocksFontBig.pcx" },
{ "font.option_off.x", "0" },
#define IMG_FONT_TEXT_4 837
#define IMG_FONT_TEXT_4_LEVELS 838
#define IMG_FONT_TEXT_4_SCORES 839
-#define IMG_FONT_INPUT 840
-#define IMG_FONT_INPUT_MAIN 841
-#define IMG_FONT_INPUT_ACTIVE 842
-#define IMG_FONT_INPUT_ACTIVE_MAIN 843
-#define IMG_FONT_INPUT_ACTIVE_SETUP 844
-#define IMG_FONT_OPTION_OFF 845
-#define IMG_FONT_OPTION_ON 846
-#define IMG_FONT_VALUE_1 847
-#define IMG_FONT_VALUE_2 848
-#define IMG_FONT_VALUE_OLD 849
-#define IMG_FONT_LEVEL_NUMBER 850
-#define IMG_FONT_TAPE_RECORDER 851
-#define IMG_FONT_GAME_INFO 852
-#define IMG_GLOBAL_BORDER 853
-#define IMG_GLOBAL_DOOR 854
-#define IMG_EDITOR_ELEMENT_BORDER 855
-#define IMG_BACKGROUND 856
-#define IMG_BACKGROUND_MAIN 857
-#define IMG_BACKGROUND_LEVELS 858
-#define IMG_BACKGROUND_SCORES 859
-#define IMG_BACKGROUND_EDITOR 860
-#define IMG_BACKGROUND_INFO 861
-#define IMG_BACKGROUND_SETUP 862
-#define IMG_BACKGROUND_DOOR 863
+#define IMG_FONT_INPUT_1 840
+#define IMG_FONT_INPUT_1_MAIN 841
+#define IMG_FONT_INPUT_1_ACTIVE 842
+#define IMG_FONT_INPUT_1_ACTIVE_MAIN 843
+#define IMG_FONT_INPUT_1_ACTIVE_SETUP 844
+#define IMG_FONT_INPUT_2 845
+#define IMG_FONT_INPUT_2_ACTIVE 846
+#define IMG_FONT_OPTION_OFF 847
+#define IMG_FONT_OPTION_ON 848
+#define IMG_FONT_VALUE_1 849
+#define IMG_FONT_VALUE_2 850
+#define IMG_FONT_VALUE_OLD 851
+#define IMG_FONT_LEVEL_NUMBER 852
+#define IMG_FONT_TAPE_RECORDER 853
+#define IMG_FONT_GAME_INFO 854
+#define IMG_GLOBAL_BORDER 855
+#define IMG_GLOBAL_DOOR 856
+#define IMG_EDITOR_ELEMENT_BORDER 857
+#define IMG_BACKGROUND 858
+#define IMG_BACKGROUND_MAIN 859
+#define IMG_BACKGROUND_LEVELS 860
+#define IMG_BACKGROUND_SCORES 861
+#define IMG_BACKGROUND_EDITOR 862
+#define IMG_BACKGROUND_INFO 863
+#define IMG_BACKGROUND_SETUP 864
+#define IMG_BACKGROUND_DOOR 865
-#define NUM_IMAGE_FILES 864
+#define NUM_IMAGE_FILES 866
#endif /* CONF_GFX_H */
-#define COMPILE_DATE_STRING "[2003-04-09 23:02]"
+#define COMPILE_DATE_STRING "[2003-04-11 01:43]"
/* standard distances */
#define ED_BORDER_SIZE 3
+#define ED_BORDER2_SIZE 5
#define ED_GADGET_DISTANCE 2
/* values for element content drawing areas */
#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_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
+#define ED_TEXTBUTTON_XPOS ED_WIN_COUNT_XPOS
+#define ED_TEXTBUTTON_YPOS (ED_WIN_COUNT_YPOS + \
+ 2 * (2 + ED_WIN_COUNT_YSIZE))
+#define ED_TEXTBUTTON_INACTIVE_YPOS (ED_WIN_COUNT_YPOS + \
+ 3 * (2 + ED_WIN_COUNT_YSIZE))
+#define ED_TEXTBUTTON_XSIZE ED_WIN_COUNT_XSIZE
+#define ED_TEXTBUTTON_YSIZE ED_WIN_COUNT_YSIZE
+
/* editor gadget identifiers */
/* drawing toolbox buttons */
/* selectbox identifiers */
#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 2)
-#define GADGET_ID_SELECTBOX_TEST (GADGET_ID_SELECTBOX_FIRST + 0)
+#define GADGET_ID_CUSTOM_CHANGE_CAUSE (GADGET_ID_SELECTBOX_FIRST + 0)
+
+/* textbutton identifiers */
+#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 1)
+
+#define GADGET_ID_EDIT_PROPERTIES (GADGET_ID_TEXTBUTTON_FIRST + 0)
+#define GADGET_ID_SHOW_DESCRIPTION (GADGET_ID_TEXTBUTTON_FIRST + 1)
+#define GADGET_ID_EDIT_CUSTOM_CHANGE (GADGET_ID_TEXTBUTTON_FIRST + 2)
/* gadgets for scrolling of drawing area */
-#define GADGET_ID_SCROLLING_FIRST (GADGET_ID_SELECTBOX_FIRST + 1)
+#define GADGET_ID_SCROLLING_FIRST (GADGET_ID_TEXTBUTTON_FIRST + 3)
#define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0)
#define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1)
#define ED_TEXTINPUT_ID_LEVEL_LAST ED_TEXTINPUT_ID_LEVEL_AUTHOR
/* values for selectbox gadgets */
-#define ED_SELECTBOX_ID_TEST 0
+#define ED_SELECTBOX_ID_CUSTOM_CHANGE_CAUSE 0
-#define ED_NUM_SELECTBOX 1
+#define ED_NUM_SELECTBOX 1
+
+/* values for textbutton gadgets */
+#define ED_TEXTBUTTON_ID_EDIT_PROPERTIES 0
+#define ED_TEXTBUTTON_ID_SHOW_DESCRIPTION 1
+#define ED_TEXTBUTTON_ID_EDIT_CUSTOM_CHANGE 2
+
+#define ED_NUM_TEXTBUTTON 3
/* values for checkbutton gadgets */
#define ED_CHECKBUTTON_ID_DOUBLE_SPEED 0
}
};
-static char *test_values[] =
+static struct ValueTextInfo options_change_cause[] =
{
- "test 1",
- "test 2",
- "dieser test-text ist viel zu lang fuer die selectbox",
- "letzter text",
- NULL
+ { 1, "specified delay" },
+ { 2, "impact (active)" },
+ { 3, "impact (passive)" },
+ { 4, "touched by player" },
+ { 5, "pressed by player" },
+ { -1, NULL }
};
-static int test_index = 0;
+static int index_change_cause = 0;
static struct
{
int x, y;
int gadget_id;
int size;
- char **values;
+ struct ValueTextInfo *options;
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,
+ GADGET_ID_CUSTOM_CHANGE_CAUSE,
+ 17,
+ options_change_cause, &index_change_cause,
"test:", "test-selectbox entry"
},
};
+static struct
+{
+ int x, y;
+ int gadget_id;
+ int size;
+ char *value;
+ char *infotext;
+} textbutton_info[ED_NUM_TEXTBUTTON] =
+{
+ {
+ ED_SETTINGS_XPOS, ED_COUNTER_YPOS(1),
+ GADGET_ID_EDIT_PROPERTIES,
+ 11, "Properties",
+ "Edit element properties"
+ },
+ {
+ ED_SETTINGS_XPOS + 166, ED_COUNTER_YPOS(1),
+ GADGET_ID_SHOW_DESCRIPTION,
+ 11, "Description",
+ "Show element description"
+ },
+ {
+ ED_SETTINGS_XPOS + 332, ED_COUNTER_YPOS(1),
+ GADGET_ID_EDIT_CUSTOM_CHANGE,
+ 11, "Advanced",
+ "Advanced element features"
+ },
+};
+
static struct
{
int xpos, ypos;
static void HandleCounterButtons(struct GadgetInfo *);
static void HandleTextInputGadgets(struct GadgetInfo *);
static void HandleSelectboxGadgets(struct GadgetInfo *);
+static void HandleTextbuttonGadgets(struct GadgetInfo *);
static void HandleRadiobuttons(struct GadgetInfo *);
static void HandleCheckbuttons(struct GadgetInfo *);
static void HandleControlButtons(struct GadgetInfo *);
static int getCounterGadgetWidth()
{
- return (DXSIZE + getFontWidth(FONT_INPUT) - 2 * ED_GADGET_DISTANCE);
+ return (DXSIZE + getFontWidth(FONT_INPUT_1) - 2 * ED_GADGET_DISTANCE);
}
static int getMaxInfoTextLength()
if (j == 0)
{
- int font_type = FONT_INPUT;
+ int font_type = FONT_INPUT_1;
+ int font_type_active = FONT_INPUT_1_ACTIVE;
int gd_width = ED_WIN_COUNT_XSIZE;
id = counterbutton_info[i].gadget_id_text;
if (i == ED_COUNTER_ID_SELECT_LEVEL)
{
font_type = FONT_LEVEL_NUMBER;
+ font_type_active = FONT_LEVEL_NUMBER;
xpos += 2 * ED_GADGET_DISTANCE;
ypos -= ED_GADGET_DISTANCE;
GDI_NUMBER_MAX, counterbutton_info[i].max_value,
GDI_TEXT_SIZE, 3,
GDI_TEXT_FONT, font_type,
+ GDI_TEXT_FONT_ACTIVE, font_type_active,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
- GDI_TEXTINPUT_DESIGN_WIDTH, gd_width,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, gd_width,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleCounterButtons,
GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC,
GDI_TEXT_VALUE, textinput_info[i].value,
GDI_TEXT_SIZE, textinput_info[i].size,
- GDI_TEXT_FONT, FONT_INPUT,
+ GDI_TEXT_FONT, FONT_INPUT_1,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
- GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleTextInputGadgets,
GDI_X, SX + selectbox_info[i].x,
GDI_Y, SY + selectbox_info[i].y,
GDI_TYPE, GD_TYPE_SELECTBOX,
- GDI_SELECTBOX_VALUES, selectbox_info[i].values,
+ GDI_SELECTBOX_OPTIONS, selectbox_info[i].options,
GDI_SELECTBOX_INDEX, selectbox_info[i].index,
GDI_TEXT_SIZE, selectbox_info[i].size,
- GDI_TEXT_FONT, FONT_INPUT,
+ GDI_TEXT_FONT, FONT_INPUT_1,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_1_ACTIVE,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x, gd_y,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x, gd_y,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
- GDI_BORDER_SIZE_SELECTBUTTON, getFontHeight(FONT_INPUT),
- GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE_SELECTBUTTON, getFontWidth(FONT_INPUT_1),
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleSelectboxGadgets,
}
}
+static void CreateTextbuttonGadgets()
+{
+ int max_infotext_len = getMaxInfoTextLength();
+ int i;
+
+ for (i=0; i<ED_NUM_TEXTBUTTON; i++)
+ {
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
+ int gd_x1, gd_x2, gd_y1, gd_y2;
+ struct GadgetInfo *gi;
+ unsigned long event_mask;
+ char infotext[MAX_OUTPUT_LINESIZE + 1];
+ int id = textbutton_info[i].gadget_id;
+
+ event_mask = GD_EVENT_RELEASED;
+
+ gd_x1 = DOOR_GFX_PAGEX4 + ED_TEXTBUTTON_XPOS;
+ gd_x2 = DOOR_GFX_PAGEX3 + ED_TEXTBUTTON_XPOS;
+ gd_y1 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_YPOS;
+ gd_y2 = DOOR_GFX_PAGEY1 + ED_TEXTBUTTON_INACTIVE_YPOS;
+
+ sprintf(infotext, "%s", textbutton_info[i].infotext);
+ infotext[max_infotext_len] = '\0';
+
+ gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_CUSTOM_TYPE_ID, i,
+ GDI_INFO_TEXT, infotext,
+ GDI_X, SX + textbutton_info[i].x,
+ GDI_Y, SY + textbutton_info[i].y,
+ GDI_TYPE, GD_TYPE_TEXT_BUTTON,
+ GDI_TEXT_VALUE, textbutton_info[i].value,
+ GDI_TEXT_SIZE, textbutton_info[i].size,
+ GDI_TEXT_FONT, FONT_INPUT_2_ACTIVE,
+ GDI_TEXT_FONT_ACTIVE, FONT_INPUT_2,
+ GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
+ GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y1,
+ GDI_ALT_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y2,
+ GDI_BORDER_SIZE, ED_BORDER2_SIZE, ED_BORDER_SIZE,
+ GDI_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE,
+ GDI_DECORATION_SHIFTING, 1, 1,
+ GDI_EVENT_MASK, event_mask,
+ GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
+ GDI_CALLBACK_ACTION, HandleTextbuttonGadgets,
+ GDI_END);
+
+ if (gi == NULL)
+ Error(ERR_EXIT, "cannot create gadget");
+
+ level_editor_gadget[id] = gi;
+ }
+}
+
static void CreateScrollbarGadgets()
{
int i;
GDI_STATE, GD_BUTTON_UNPRESSED,
GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1,
GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2,
- GDI_BORDER_SIZE, ED_BORDER_SIZE,
+ GDI_BORDER_SIZE, ED_BORDER_SIZE, ED_BORDER_SIZE,
GDI_EVENT_MASK, event_mask,
GDI_CALLBACK_INFO, HandleEditorGadgetInfoText,
GDI_CALLBACK_ACTION, HandleControlButtons,
CreateDrawingAreas();
CreateTextInputGadgets();
CreateSelectboxGadgets();
+ CreateTextbuttonGadgets();
CreateScrollbarGadgets();
CreateCheckbuttonGadgets();
MapGadget(level_editor_gadget[selectbox_info[id].gadget_id]);
}
+static void MapTextbuttonGadget(int id)
+{
+ MapGadget(level_editor_gadget[textbutton_info[id].gadget_id]);
+}
+
static void MapRadiobuttonGadget(int id)
{
MapGadget(level_editor_gadget[radiobutton_info[id].gadget_id]);
MapCheckbuttonGadget(i);
/* draw selectbox gadget */
- i = ED_SELECTBOX_ID_TEST;
+ i = ED_SELECTBOX_ID_CUSTOM_CHANGE_CAUSE;
x = selectbox_info[i].x + xoffset_right2;
y = selectbox_info[i].y + yoffset_right2;
- selectbox_info[i].index = &test_index;
+ selectbox_info[i].index = &index_change_cause;
DrawTextF(x, y, FONT_TEXT_1, selectbox_info[i].text);
ModifyGadget(level_editor_gadget[selectbox_info[i].gadget_id],
GDI_SELECTBOX_INDEX, *selectbox_info[i].index, GDI_END);
MapSelectboxGadget(i);
}
+
+ /* draw textbutton gadget */
+ i = ED_TEXTBUTTON_ID_EDIT_PROPERTIES;
+ x = textbutton_info[i].x + xoffset_right2;
+ y = textbutton_info[i].y + yoffset_right2;
+
+ ModifyGadget(level_editor_gadget[textbutton_info[i].gadget_id],
+ GDI_ACTIVE, FALSE, GDI_END);
+ MapTextbuttonGadget(i);
+
+ /* draw textbutton gadget */
+ i = ED_TEXTBUTTON_ID_SHOW_DESCRIPTION;
+ x = textbutton_info[i].x + xoffset_right2;
+ y = textbutton_info[i].y + yoffset_right2;
+
+ ModifyGadget(level_editor_gadget[textbutton_info[i].gadget_id],
+ GDI_ACTIVE, TRUE, GDI_END);
+ MapTextbuttonGadget(i);
+
+ if (IS_CUSTOM_ELEMENT(properties_element))
+ {
+ /* draw textbutton gadget */
+ i = ED_TEXTBUTTON_ID_EDIT_CUSTOM_CHANGE;
+ x = textbutton_info[i].x + xoffset_right2;
+ y = textbutton_info[i].y + yoffset_right2;
+
+ ModifyGadget(level_editor_gadget[textbutton_info[i].gadget_id],
+ GDI_ACTIVE, TRUE, GDI_END);
+ MapTextbuttonGadget(i);
+ }
}
static void DrawLineElement(int sx, int sy, int element, boolean change_level)
static void HandleSelectboxGadgets(struct GadgetInfo *gi)
{
- *selectbox_info[gi->custom_type_id].index = gi->selectbox.index;
+ int type_id = gi->custom_type_id;
-#if 1
- printf("Selected text value: '%s'\n",
- selectbox_info[gi->custom_type_id].values[gi->selectbox.index]);
+ *selectbox_info[type_id].index = gi->selectbox.index;
+
+#if 0
+ printf("Selected text value: '%s' [%d]\n",
+ selectbox_info[type_id].options[gi->selectbox.index].text,
+ selectbox_info[type_id].options[gi->selectbox.index].value);
+#endif
+}
+
+static void HandleTextbuttonGadgets(struct GadgetInfo *gi)
+{
+ int i;
+
+ for (i=0; i<ED_NUM_TEXTBUTTON; i++)
+ {
+ struct GadgetInfo *gii = level_editor_gadget[textbutton_info[i].gadget_id];
+ boolean active = (gii->custom_type_id != gi->custom_type_id);
+
+ ModifyGadget(level_editor_gadget[textbutton_info[i].gadget_id],
+ GDI_ACTIVE, active, GDI_END);
+ }
+
+#if 0
+ printf("text button %d pressed\n", gi->custom_type_id);
#endif
}
int FilterMouseMotionEvents(const Event *event)
{
+ MotionEvent *motion;
+
/* non-motion events are directly passed to event handler functions */
if (event->type != EVENT_MOTIONNOTIFY)
return 1;
- if (game_status == PLAYING)
- {
- MotionEvent *motion = (MotionEvent *)event;
-
- cursor_inside_playfield =
- (motion->x >= SX && motion->x < SX + SXSIZE &&
- motion->y >= SY && motion->y < SY + SYSIZE);
+ motion = (MotionEvent *)event;
+ cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE &&
+ motion->y >= SY && motion->y < SY + SYSIZE);
- if (playfield_cursor_set)
- {
- SetMouseCursor(CURSOR_DEFAULT);
- DelayReached(&playfield_cursor_delay, 0);
- playfield_cursor_set = FALSE;
- }
+ if (game_status == PLAYING && playfield_cursor_set)
+ {
+ SetMouseCursor(CURSOR_DEFAULT);
+ playfield_cursor_set = FALSE;
+ DelayReached(&playfield_cursor_delay, 0);
}
/* skip mouse motion events without pressed button outside level editor */
else
{
/* when playing, display a special mouse pointer inside the playfield */
- if (game_status == PLAYING && cursor_inside_playfield &&
- DelayReached(&playfield_cursor_delay, 1000))
+ if (game_status == PLAYING)
+ {
+ if (!playfield_cursor_set && cursor_inside_playfield &&
+ DelayReached(&playfield_cursor_delay, 1000))
+ {
+ SetMouseCursor(CURSOR_PLAYFIELD);
+ playfield_cursor_set = TRUE;
+ }
+ }
+ else if (playfield_cursor_set)
{
- SetMouseCursor(CURSOR_PLAYFIELD);
- playfield_cursor_set = TRUE;
+ SetMouseCursor(CURSOR_DEFAULT);
+ playfield_cursor_set = FALSE;
}
HandleNoEvent();
PlayMusic(level_nr);
KeyboardAutoRepeatOff();
- SetMouseCursor(CURSOR_PLAYFIELD);
if (options.debug)
{
while (gi)
{
- if (gi->mapped &&
+ if (gi->mapped && gi->active &&
((mx >= gi->x && mx < gi->x + gi->width &&
my >= gi->y && my < gi->y + gi->height) ||
(gi->type & GD_TYPE_SELECTBOX && gi->selectbox.open &&
static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
{
int state = (pressed ? 1 : 0);
- struct GadgetDesign *gd = (gi->checked ?
- &gi->alt_design[state] :
+ struct GadgetDesign *gd = (!gi->active ? &gi->alt_design[0] :
+ gi->checked ? &gi->alt_design[state] :
&gi->design[state]);
boolean redraw_selectbox = FALSE;
gi->y + gi->deco.y + (pressed ? gi->deco.yshift : 0));
break;
+ case GD_TYPE_TEXT_BUTTON:
+ {
+ int i;
+ int font_nr = (gi->active ? gi->font_active : gi->font);
+ int font_width = getFontWidth(font_nr);
+ int border_x = gi->border.xsize;
+ int border_y = gi->border.ysize;
+ int text_size = strlen(gi->textbutton.value);
+ int text_start = (gi->width - text_size * font_width) / 2;
+
+ /* left part of gadget */
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y,
+ border_x, gi->height, gi->x, gi->y);
+
+ /* middle part of gadget */
+ for (i=0; i < gi->textbutton.size; i++)
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
+ font_width, gi->height,
+ gi->x + border_x + i * font_width, gi->y);
+
+ /* right part of gadget */
+ BlitBitmapOnBackground(gd->bitmap, drawto,
+ gd->x + gi->border.width - border_x, gd->y,
+ border_x, gi->height,
+ gi->x + gi->width - border_x, gi->y);
+
+ /* gadget text value */
+ DrawTextExt(drawto,
+ gi->x + text_start + (pressed ? gi->deco.xshift : 0),
+ gi->y + border_y + (pressed ? gi->deco.yshift : 0),
+ gi->textbutton.value, font_nr, BLIT_MASKED);
+ }
+ break;
+
case GD_TYPE_TEXTINPUT_ALPHANUMERIC:
case GD_TYPE_TEXTINPUT_NUMERIC:
{
char cursor_letter;
char cursor_string[2];
char text[MAX_GADGET_TEXTSIZE + 1];
- int font_type = gi->text.font_type;
- int font_width = getFontWidth(font_type);
- int border = gi->border.size;
+ int font_nr = (pressed ? gi->font_active : gi->font);
+ int font_width = getFontWidth(font_nr);
+ int border_x = gi->border.xsize;
+ int border_y = gi->border.ysize;
/* left part of gadget */
- BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x, gd->y, border, gi->height, gi->x, gi->y);
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y,
+ border_x, gi->height, gi->x, gi->y);
/* middle part of gadget */
for (i=0; i < gi->text.size + 1; i++)
- BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + border, gd->y, font_width, gi->height,
- gi->x + border + i * font_width, gi->y);
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
+ font_width, gi->height,
+ gi->x + border_x + i * font_width, 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);
+ gd->x + gi->border.width - border_x, gd->y,
+ border_x, gi->height,
+ gi->x + gi->width - border_x, gi->y);
/* set text value */
strcpy(text, gi->text.value);
/* gadget text value */
DrawTextExt(drawto,
- gi->x + border, gi->y + border, text,
- font_type, BLIT_MASKED);
+ gi->x + border_x, gi->y + border_y, text,
+ font_nr, BLIT_MASKED);
cursor_letter = gi->text.value[gi->text.cursor_position];
cursor_string[0] = (cursor_letter != '\0' ? cursor_letter : ' ');
cursor_string[1] = '\0';
- SetInverseTextColor(gi->text.inverse_color);
-
/* draw cursor, if active */
if (pressed)
DrawTextExt(drawto,
- gi->x + border + gi->text.cursor_position * font_width,
- gi->y + border, cursor_string,
- font_type, BLIT_INVERSE);
+ gi->x + border_x + gi->text.cursor_position * font_width,
+ gi->y + border_y, cursor_string,
+ font_nr, BLIT_INVERSE);
}
break;
{
int i;
char text[MAX_GADGET_TEXTSIZE + 1];
- int font_type = gi->selectbox.font_type;
- int font_width = getFontWidth(font_type);
- int font_height = getFontHeight(font_type);
- int border = gi->border.size;
- int button = gi->border.size_selectbutton;
- int width_inner = gi->border.width - button - 2 * border;
+ int font_nr = (pressed ? gi->font_active : gi->font);
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
+ int border_x = gi->border.xsize;
+ int border_y = gi->border.ysize;
+ int button = gi->border.xsize_selectbutton;
+ int width_inner = gi->border.width - button - 2 * border_x;
int box_width = gi->selectbox.width;
int box_height = gi->selectbox.height;
/* left part of gadget */
- BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x, gd->y, border, gi->height, gi->x, gi->y);
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y,
+ border_x, 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);
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
+ font_width, gi->height,
+ gi->x + border_x + i * font_width, gi->y);
/* button part of gadget */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + border + width_inner, gd->y,
+ gd->x + border_x + width_inner, gd->y,
button, gi->height,
- gi->x + gi->width - border - button, gi->y);
+ gi->x + gi->width - border_x - 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);
+ gd->x + gi->border.width - border_x, gd->y,
+ border_x, gi->height,
+ gi->x + gi->width - border_x, gi->y);
/* set text value */
- strncpy(text, gi->selectbox.values[gi->selectbox.index],
+ strncpy(text, gi->selectbox.options[gi->selectbox.index].text,
gi->selectbox.size);
text[gi->selectbox.size] = '\0';
/* gadget text value */
- DrawTextExt(drawto, gi->x + border, gi->y + border, text,
- font_type, BLIT_MASKED);
+ DrawTextExt(drawto, gi->x + border_x, gi->y + border_y, text,
+ font_nr, BLIT_MASKED);
if (pressed)
{
/* top left part of gadget border */
BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y,
- border, border,
+ border_x, border_y,
gi->selectbox.x, gi->selectbox.y);
/* top middle part of gadget border */
for (i=0; i < gi->selectbox.size; i++)
- BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border, gd->y,
- font_width, border,
- gi->selectbox.x + border + i * font_width,
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
+ font_width, border_y,
+ gi->selectbox.x + border_x + i * font_width,
gi->selectbox.y);
/* top button part of gadget border */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + border + width_inner, gd->y,
- button, border,
- gi->selectbox.x + box_width - border - button,
+ gd->x + border_x + width_inner, gd->y,
+ button, border_y,
+ gi->selectbox.x + box_width -border_x -button,
gi->selectbox.y);
/* top right part of gadget border */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + gi->border.width - border, gd->y,
- border, border,
- gi->selectbox.x + box_width - border,
+ gd->x + gi->border.width - border_x, gd->y,
+ border_x, border_y,
+ gi->selectbox.x + box_width - border_x,
gi->selectbox.y);
/* left and right part of gadget border for each row */
for (i=0; i < gi->selectbox.num_values; i++)
{
- BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y + border,
- border, font_height,
+ BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y + border_y,
+ border_x, font_height,
gi->selectbox.x,
- gi->selectbox.y + border + i * font_height);
+ gi->selectbox.y + border_y + i*font_height);
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + gi->border.width - border,
- gd->y + border,
- border, font_height,
- gi->selectbox.x + box_width - border,
- gi->selectbox.y + border + i * font_height);
+ gd->x + gi->border.width - border_x,
+ gd->y + border_y,
+ border_x, font_height,
+ gi->selectbox.x + box_width - border_x,
+ gi->selectbox.y + border_y + i*font_height);
}
/* bottom left part of gadget border */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x, gd->y + gi->height - border,
- border, border,
+ gd->x, gd->y + gi->height - border_y,
+ border_x, border_y,
gi->selectbox.x,
- gi->selectbox.y + box_height - border);
+ gi->selectbox.y + box_height - border_y);
/* bottom middle part of gadget border */
for (i=0; i < gi->selectbox.size; i++)
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + border, gd->y + gi->height - border,
- font_width, border,
- gi->selectbox.x + border + i * font_width,
- gi->selectbox.y + box_height - border);
+ gd->x + border_x,
+ gd->y + gi->height - border_y,
+ font_width, border_y,
+ gi->selectbox.x + border_x + i * font_width,
+ gi->selectbox.y + box_height - border_y);
/* bottom button part of gadget border */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + border + width_inner,
- gd->y + gi->height - border,
- button, border,
- gi->selectbox.x + box_width - border - button,
- gi->selectbox.y + box_height - border);
+ gd->x + border_x + width_inner,
+ gd->y + gi->height - border_y,
+ button, border_y,
+ gi->selectbox.x + box_width -border_x -button,
+ gi->selectbox.y + box_height - border_y);
/* bottom right part of gadget border */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + gi->border.width - border,
- gd->y + gi->height - border,
- border, border,
- gi->selectbox.x + box_width - border,
- gi->selectbox.y + box_height - border);
+ gd->x + gi->border.width - border_x,
+ gd->y + gi->height - border_y,
+ border_x, border_y,
+ gi->selectbox.x + box_width - border_x,
+ gi->selectbox.y + box_height - border_y);
ClearRectangleOnBackground(drawto,
- gi->selectbox.x + border,
- gi->selectbox.y + border,
- gi->selectbox.width - 2 * border,
- gi->selectbox.height - 2 * border);
+ gi->selectbox.x + border_x,
+ gi->selectbox.y + border_y,
+ gi->selectbox.width - 2 * border_x,
+ gi->selectbox.height - 2 * border_y);
/* selectbox text values */
for (i=0; i < gi->selectbox.num_values; i++)
if (i == gi->selectbox.current_index)
{
FillRectangle(drawto,
- gi->selectbox.x + border,
- gi->selectbox.y + border + i * font_height,
- gi->selectbox.width - 2 * border, font_height,
+ gi->selectbox.x + border_x,
+ gi->selectbox.y + border_y + i * font_height,
+ gi->selectbox.width - 2 * border_x, font_height,
gi->selectbox.inverse_color);
- strncpy(text, gi->selectbox.values[i], gi->selectbox.size);
+ strncpy(text, gi->selectbox.options[i].text, gi->selectbox.size);
text[1 + gi->selectbox.size] = '\0';
- SetInverseTextColor(gi->selectbox.inverse_color);
-
mask_mode = BLIT_INVERSE;
}
else
{
- strncpy(text, gi->selectbox.values[i], gi->selectbox.size);
+ strncpy(text, gi->selectbox.options[i].text, gi->selectbox.size);
text[gi->selectbox.size] = '\0';
mask_mode = BLIT_MASKED;
}
DrawTextExt(drawto,
- gi->selectbox.x + border,
- gi->selectbox.y + border + i * font_height, text,
- font_type, mask_mode);
+ gi->selectbox.x + border_x,
+ gi->selectbox.y + border_y + i * font_height, text,
+ font_nr, mask_mode);
}
redraw_selectbox = TRUE;
int xpos = gi->x;
int ypos = gi->y + gi->scrollbar.position;
int design_full = gi->width;
- int design_body = design_full - 2 * gi->border.size;
+ int design_body = design_full - 2 * gi->border.ysize;
int size_full = gi->scrollbar.size;
- int size_body = size_full - 2 * gi->border.size;
+ int size_body = size_full - 2 * gi->border.ysize;
int num_steps = size_body / design_body;
int step_size_remain = size_body - num_steps * design_body;
/* upper part of gadget */
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x, gd->y,
- gi->width, gi->border.size,
+ gi->width, gi->border.ysize,
xpos, ypos);
/* middle part of gadget */
for (i=0; i<num_steps; i++)
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x, gd->y + gi->border.size,
+ gd->x, gd->y + gi->border.ysize,
gi->width, design_body,
xpos,
- ypos + gi->border.size + i * design_body);
+ ypos + gi->border.ysize + i * design_body);
/* remaining middle part of gadget */
if (step_size_remain > 0)
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x, gd->y + gi->border.size,
+ gd->x, gd->y + gi->border.ysize,
gi->width, step_size_remain,
xpos,
- ypos + gi->border.size
+ ypos + gi->border.ysize
+ num_steps * design_body);
/* lower part of gadget */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x, gd->y + design_full - gi->border.size,
- gi->width, gi->border.size,
- xpos, ypos + size_full - gi->border.size);
+ gd->x, gd->y + design_full - gi->border.ysize,
+ gi->width, gi->border.ysize,
+ xpos, ypos + size_full - gi->border.ysize);
}
break;
int xpos = gi->x + gi->scrollbar.position;
int ypos = gi->y;
int design_full = gi->height;
- int design_body = design_full - 2 * gi->border.size;
+ int design_body = design_full - 2 * gi->border.xsize;
int size_full = gi->scrollbar.size;
- int size_body = size_full - 2 * gi->border.size;
+ int size_body = size_full - 2 * gi->border.xsize;
int num_steps = size_body / design_body;
int step_size_remain = size_body - num_steps * design_body;
/* left part of gadget */
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x, gd->y,
- gi->border.size, gi->height,
+ gi->border.xsize, gi->height,
xpos, ypos);
/* middle part of gadget */
for (i=0; i<num_steps; i++)
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + gi->border.size, gd->y,
+ gd->x + gi->border.xsize, gd->y,
design_body, gi->height,
- xpos + gi->border.size + i * design_body,
+ xpos + gi->border.xsize + i * design_body,
ypos);
/* remaining middle part of gadget */
if (step_size_remain > 0)
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + gi->border.size, gd->y,
+ gd->x + gi->border.xsize, gd->y,
step_size_remain, gi->height,
- xpos + gi->border.size
+ xpos + gi->border.xsize
+ num_steps * design_body,
ypos);
/* right part of gadget */
BlitBitmapOnBackground(gd->bitmap, drawto,
- gd->x + design_full - gi->border.size, gd->y,
- gi->border.size, gi->height,
- xpos + size_full - gi->border.size, ypos);
+ gd->x + design_full - gi->border.xsize, gd->y,
+ gi->border.xsize, gi->height,
+ xpos + size_full - gi->border.xsize, ypos);
}
break;
gi->state = va_arg(ap, unsigned long);
break;
+ case GDI_ACTIVE:
+ /* take care here: "boolean" is typedef'ed as "unsigned char",
+ which gets promoted to "int" */
+ gi->active = (boolean)va_arg(ap, int);
+ break;
+
case GDI_CHECKED:
/* take care here: "boolean" is typedef'ed as "unsigned char",
which gets promoted to "int" */
strncpy(gi->text.value, va_arg(ap, char *), max_textsize);
gi->text.value[max_textsize] = '\0';
gi->text.cursor_position = strlen(gi->text.value);
+
+ /* same tag also used for textbutton definition */
+ strcpy(gi->textbutton.value, gi->text.value);
}
break;
gi->text.size = max_textsize;
gi->text.value[max_textsize] = '\0';
- /* same tag also used for selectbox definition */
+ /* same tag also used for textbutton and selectbox definition */
+ strcpy(gi->textbutton.value, gi->text.value);
+ gi->textbutton.size = gi->text.size;
gi->selectbox.size = gi->text.size;
}
break;
case GDI_TEXT_FONT:
- gi->text.font_type = va_arg(ap, int);
+ gi->font = va_arg(ap, int);
+ if (gi->font_active == 0)
+ gi->font_active = gi->font;
+ break;
- /* same tag also used for selectbox definition */
- gi->selectbox.font_type = gi->text.font_type;
+ case GDI_TEXT_FONT_ACTIVE:
+ gi->font_active = va_arg(ap, int);
break;
- case GDI_SELECTBOX_VALUES:
- gi->selectbox.values = va_arg(ap, const char **);
+ case GDI_SELECTBOX_OPTIONS:
+ gi->selectbox.options = va_arg(ap, struct ValueTextInfo *);
break;
case GDI_SELECTBOX_INDEX:
break;
case GDI_BORDER_SIZE:
- gi->border.size = va_arg(ap, int);
+ gi->border.xsize = va_arg(ap, int);
+ gi->border.ysize = va_arg(ap, int);
break;
case GDI_BORDER_SIZE_SELECTBUTTON:
- gi->border.size_selectbutton = va_arg(ap, int);
+ gi->border.xsize_selectbutton = va_arg(ap, int);
break;
- case GDI_TEXTINPUT_DESIGN_WIDTH:
+ case GDI_DESIGN_WIDTH:
gi->border.width = va_arg(ap, int);
break;
if (gi->type & GD_TYPE_TEXTINPUT)
{
- int font_nr = gi->text.font_type;
+ int font_nr = gi->font_active;
int font_width = getFontWidth(font_nr);
int font_height = getFontHeight(font_nr);
- int border_size = gi->border.size;
- Bitmap *src_bitmap;
- int src_x, src_y;
-
- gi->width = 2 * border_size + (gi->text.size + 1) * font_width;
- gi->height = 2 * border_size + font_height;
+ int border_xsize = gi->border.xsize;
+ int border_ysize = gi->border.ysize;
- getFontCharSource(font_nr, FONT_ASCII_CURSOR, &src_bitmap, &src_x, &src_y);
- src_x += font_width / 2;
- src_y += font_height / 2;
- gi->text.inverse_color = GetPixel(src_bitmap, src_x, src_y);
+ gi->width = 2 * border_xsize + (gi->text.size + 1) * font_width;
+ gi->height = 2 * border_ysize + font_height;
}
if (gi->type & GD_TYPE_SELECTBOX)
{
- int font_nr = gi->selectbox.font_type;
+ int font_nr = gi->font_active;
int font_width = getFontWidth(font_nr);
int font_height = getFontHeight(font_nr);
- int border_size = gi->border.size;
- int button_size = gi->border.size_selectbutton;
+ int border_xsize = gi->border.xsize;
+ int border_ysize = gi->border.ysize;
+ int button_size = gi->border.xsize_selectbutton;
Bitmap *src_bitmap;
int src_x, src_y;
- gi->width = 2 * border_size + gi->text.size * font_width + button_size;
- gi->height = 2 * border_size + font_height;
+ gi->width = 2 * border_xsize + gi->text.size * font_width + button_size;
+ gi->height = 2 * border_ysize + font_height;
- if (gi->selectbox.values == NULL)
- Error(ERR_EXIT, "selectbox gadget incomplete (missing values array)");
+ if (gi->selectbox.options == NULL)
+ Error(ERR_EXIT, "selectbox gadget incomplete (missing options array)");
gi->selectbox.num_values = 0;
- while (gi->selectbox.values[gi->selectbox.num_values] != NULL)
+ while (gi->selectbox.options[gi->selectbox.num_values].text != NULL)
gi->selectbox.num_values++;
/* calculate values for open selectbox */
gi->selectbox.width = gi->width;
gi->selectbox.height =
- 2 * border_size + gi->selectbox.num_values * font_height;
+ 2 * border_ysize + gi->selectbox.num_values * font_height;
gi->selectbox.x = gi->x;
gi->selectbox.y = gi->y + gi->height;
sprintf(text->value, "%d", text->number_value);
}
+ if (gi->type & GD_TYPE_TEXT_BUTTON)
+ {
+ int font_nr = gi->font_active;
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
+ int border_xsize = gi->border.xsize;
+ int border_ysize = gi->border.ysize;
+
+ gi->width = 2 * border_xsize + gi->textbutton.size * font_width;
+ gi->height = 2 * border_ysize + font_height;
+ }
+
if (gi->type & GD_TYPE_SCROLLBAR)
{
struct GadgetScrollbar *gs = &gi->scrollbar;
new_gadget->id = getNewGadgetID();
new_gadget->callback_info = default_callback_info;
new_gadget->callback_action = default_callback_action;
+ new_gadget->active = TRUE;
new_gadget->next = NULL;
va_start(ap, first_tag);
/* if mouse button pressed inside activated text gadget, set cursor */
gi->text.cursor_position =
- (mx - gi->x - gi->border.size) / getFontWidth(gi->text.font_type);
+ (mx - gi->x - gi->border.xsize) / getFontWidth(gi->font);
if (gi->text.cursor_position < 0)
gi->text.cursor_position = 0;
/* if mouse button pressed inside activated selectbox, select value */
if (my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height)
gi->selectbox.current_index =
- (my - gi->selectbox.y - gi->border.size) /
- getFontWidth(gi->selectbox.font_type);
+ (my - gi->selectbox.y - gi->border.xsize) / getFontWidth(gi->font);
if (gi->selectbox.current_index < 0)
gi->selectbox.current_index = 0;
/* if mouse moving inside activated selectbox, select value */
if (my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height)
gi->selectbox.current_index =
- (my - gi->selectbox.y - gi->border.size) /
- getFontWidth(gi->selectbox.font_type);
+ (my - gi->selectbox.y - gi->border.xsize) / getFontWidth(gi->font);
if (gi->selectbox.current_index < 0)
gi->selectbox.current_index = 0;
/* if mouse moving inside activated selectbox, select value */
if (my >= gi->selectbox.y && my < gi->selectbox.y + gi->selectbox.height)
gi->selectbox.current_index =
- (my - gi->selectbox.y - gi->border.size) /
- getFontWidth(gi->selectbox.font_type);
+ (my - gi->selectbox.y - gi->border.xsize) / getFontWidth(gi->font);
if (gi->selectbox.current_index < 0)
gi->selectbox.current_index = 0;
/* gadget types */
#define GD_TYPE_NORMAL_BUTTON (1 << 0)
-#define GD_TYPE_CHECK_BUTTON (1 << 1)
-#define GD_TYPE_RADIO_BUTTON (1 << 2)
-#define GD_TYPE_DRAWING_AREA (1 << 3)
-#define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 4)
-#define GD_TYPE_TEXTINPUT_NUMERIC (1 << 5)
-#define GD_TYPE_SELECTBOX (1 << 6)
-#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 7)
-#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 8)
+#define GD_TYPE_TEXT_BUTTON (1 << 1)
+#define GD_TYPE_CHECK_BUTTON (1 << 2)
+#define GD_TYPE_RADIO_BUTTON (1 << 3)
+#define GD_TYPE_DRAWING_AREA (1 << 4)
+#define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 5)
+#define GD_TYPE_TEXTINPUT_NUMERIC (1 << 6)
+#define GD_TYPE_SELECTBOX (1 << 7)
+#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 8)
+#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 9)
#define GD_TYPE_BUTTON (GD_TYPE_NORMAL_BUTTON | \
+ GD_TYPE_TEXT_BUTTON | \
GD_TYPE_CHECK_BUTTON | \
GD_TYPE_RADIO_BUTTON)
#define GD_TYPE_SCROLLBAR (GD_TYPE_SCROLLBAR_VERTICAL | \
#define GDI_TEXT_VALUE 14
#define GDI_TEXT_SIZE 15
#define GDI_TEXT_FONT 16
-#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
+#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_INFO_TEXT 40
+#define GDI_ACTIVE 41
typedef void (*gadget_function)(void *);
struct GadgetBorder
{
- int size; /* size of gadget border */
- int size_selectbutton; /* for selectbox gadgets */
+ int xsize, ysize; /* size of gadget border */
+ int xsize_selectbutton; /* for selectbox gadgets */
int width; /* for selectbox/text input gadgets */
};
int item_xsize, item_ysize; /* size of each item in drawing area */
};
+struct GadgetTextButton
+{
+ char value[MAX_GADGET_TEXTSIZE]; /* text written on the button */
+ int size; /* maximal size of button text */
+};
+
struct GadgetTextInput
{
char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
+ int cursor_position; /* actual text cursor position */
int number_value; /* integer value, if numeric */
int number_min; /* minimal allowed numeric value */
int number_max; /* maximal allowed numeric value */
int size; /* maximal size of input text */
- int font_type; /* font to use for text input */
- int cursor_position; /* actual cursor position */
- Pixel inverse_color; /* color for highlighting */
};
struct GadgetSelectbox
{
- const char **values; /* pointer to array of text strings */
+ struct ValueTextInfo *options; /* pointer to text/value array */
int index; /* index of actual text string */
int size; /* maximal size of text strings */
- int font_type; /* font to use for text input */
/* automatically determined values */
int x, y; /* open selectbox position */
unsigned long state; /* state (pressed, released, ...) */
boolean checked; /* check/radio button state */
int radio_nr; /* number of radio button series */
- boolean mapped; /* gadget is active */
+ boolean mapped; /* gadget is mapped on the screen */
+ boolean active; /* gadget is active */
+ int font; /* font to use when inactive */
+ int font_active; /* font to use when active */
struct GadgetBorder border; /* gadget border design */
struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
struct GadgetDesign alt_design[2]; /* alternative design */
gadget_function callback_info; /* function for pop-up info text */
gadget_function callback_action; /* function for gadget action */
struct GadgetDrawingArea drawing; /* fields for drawing area gadget */
+ struct GadgetTextButton textbutton; /* fields for text button gadget */
struct GadgetTextInput text; /* fields for text input gadget */
struct GadgetSelectbox selectbox; /* fields for selectbox gadget */
struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */
}
#endif
-inline Pixel SDLGetPixel(Bitmap *dst_bitmap, int x, int y)
+inline Pixel SDLGetPixel(Bitmap *src_bitmap, int x, int y)
{
- SDL_Surface *surface = dst_bitmap->surface;
+ SDL_Surface *surface = src_bitmap->surface;
#ifdef FULLSCREEN_BUG
- if (dst_bitmap == backbuffer || dst_bitmap == window)
+ if (src_bitmap == backbuffer || src_bitmap == window)
{
x += video_xoffset;
y += video_yoffset;
sge_Line(Surface, x1, y1, x2, y2, SDL_MapRGB(Surface->format, R, G, B));
}
+inline void SDLPutPixel(Bitmap *dst_bitmap, int x, int y, Pixel pixel)
+{
+ sge_PutPixel(dst_bitmap->surface, x, y, pixel);
+}
+
/*
-----------------------------------------------------------------------------
inline void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y,
int width, int height, Uint32 color)
{
- SDL_Surface *surface = bitmap->surface;
int x, y;
for (y=src_y; y < src_y + height; y++)
{
Uint32 pixel = SDLGetPixel(bitmap, x, y);
- sge_PutPixel(surface, x, y, pixel == BLACK_PIXEL ? color : BLACK_PIXEL);
+ SDLPutPixel(bitmap, x, y, pixel == BLACK_PIXEL ? color : BLACK_PIXEL);
+ }
+ }
+}
+
+inline void SDLCopyInverseMasked(Bitmap *src_bitmap, Bitmap *dst_bitmap,
+ int src_x, int src_y, int width, int height,
+ int dst_x, int dst_y)
+{
+ int x, y;
+
+ for (y=0; y < height; y++)
+ {
+ for (x=0; x < width; x++)
+ {
+ Uint32 pixel = SDLGetPixel(src_bitmap, src_x + x, src_y + y);
+
+ if (pixel != BLACK_PIXEL)
+ SDLPutPixel(dst_bitmap, dst_x + x, dst_y + y, BLACK_PIXEL);
}
}
}
inline void SDLDrawSimpleLine(Bitmap *, int, int, int, int, Uint32);
inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32);
inline Pixel SDLGetPixel(Bitmap *, int, int);
+inline void SDLPutPixel(Bitmap *, int, int, Pixel);
inline void SDLInvertArea(Bitmap *, int, int, int, int, Uint32);
+inline void SDLCopyInverseMasked(Bitmap *, Bitmap *, int, int, int, int,
+ int, int);
void SDLZoomBitmap(Bitmap *, Bitmap *);
#define BLIT_OPAQUE 0
#define BLIT_MASKED 1
#define BLIT_INVERSE 2
+#define BLIT_ON_BACKGROUND 3
#define FULLSCREEN_NOT_AVAILABLE FALSE
#define FULLSCREEN_AVAILABLE TRUE
int num_fonts;
struct FontBitmapInfo *font_bitmap_info;
int (*select_font_function)(int);
- Pixel inverse_text_color;
int anim_random_frame;
};
char *mus_current_identifier;
};
+struct ValueTextInfo
+{
+ int value;
+ char *text;
+};
+
struct ConfigInfo
{
char *token;
gfx.num_fonts = num_fonts;
gfx.font_bitmap_info = font_bitmap_info;
gfx.select_font_function = select_font_function;
- gfx.inverse_text_color = WHITE_PIXEL;
#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
InitFontClipmasks();
#endif
}
-void SetInverseTextColor(Pixel inverse_text_color)
-{
- gfx.inverse_text_color = inverse_text_color;
-}
-
int getFontWidth(int font_nr)
{
int font_bitmap_id = gfx.select_font_function(font_nr);
int mask_mode = BLIT_OPAQUE;
if (DrawingOnBackground(x, y))
- mask_mode = BLIT_MASKED;
+ mask_mode = BLIT_ON_BACKGROUND;
DrawTextExt(drawto, x, y, text, font_nr, mask_mode);
if (mask_mode == BLIT_INVERSE) /* special mode for text gadgets */
{
-#if defined(TARGET_SDL)
- /* blit normally (non-masked) */
- BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y,
- font_width, font_height, dst_x, dst_y);
-
- /* invert character */
- SDLInvertArea(dst_bitmap, dst_x, dst_y, font_width, font_height,
- gfx.inverse_text_color);
-#else
/* first step: draw solid colored rectangle (use "cursor" character) */
if (strlen(text) == 1) /* only one char inverted => draw cursor */
{
font_width, font_height, dst_x, dst_y);
}
+#if defined(TARGET_SDL)
+ /* second step: draw masked inverted character */
+ SDLCopyInverseMasked(src_bitmap, dst_bitmap, src_x, src_y,
+ font_width, font_height, dst_x, dst_y);
+#else
/* second step: draw masked black rectangle (use "space" character) */
SetClipOrigin(src_bitmap, src_bitmap->stored_clip_gc,
dst_x - src_x, dst_y - src_y);
font_width, font_height, dst_x, dst_y);
#endif
}
- else if (mask_mode == BLIT_MASKED)
+ else if (mask_mode == BLIT_MASKED || mask_mode == BLIT_ON_BACKGROUND)
{
- /* clear font character background */
- ClearRectangleOnBackground(dst_bitmap, dst_x, dst_y,
- font_width, font_height);
+ if (mask_mode == BLIT_ON_BACKGROUND)
+ {
+ /* clear font character background */
+ ClearRectangleOnBackground(dst_bitmap, dst_x, dst_y,
+ font_width, font_height);
+ }
#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
/* use special font tile clipmasks */
/* font structure definitions */
void InitFontInfo(struct FontBitmapInfo *, int, int (*function)(int));
-void SetInverseTextColor(Pixel);
int getFontWidth(int);
int getFontHeight(int);
#define FONT_TEXT_2 9
#define FONT_TEXT_3 10
#define FONT_TEXT_4 11
-#define FONT_INPUT 12
-#define FONT_INPUT_ACTIVE 13
-#define FONT_OPTION_OFF 14
-#define FONT_OPTION_ON 15
-#define FONT_VALUE_1 16
-#define FONT_VALUE_2 17
-#define FONT_VALUE_OLD 18
-#define FONT_LEVEL_NUMBER 19
-#define FONT_TAPE_RECORDER 20
-#define FONT_GAME_INFO 21
-
-#define NUM_FONTS 22
+#define FONT_INPUT_1 12
+#define FONT_INPUT_1_ACTIVE 13
+#define FONT_INPUT_2 14
+#define FONT_INPUT_2_ACTIVE 15
+#define FONT_OPTION_OFF 16
+#define FONT_OPTION_ON 17
+#define FONT_VALUE_1 18
+#define FONT_VALUE_2 19
+#define FONT_VALUE_OLD 20
+#define FONT_LEVEL_NUMBER 21
+#define FONT_TAPE_RECORDER 22
+#define FONT_GAME_INFO 23
+
+#define NUM_FONTS 24
#define NUM_INITIAL_FONTS 4
/* values for game_status */
KeyboardAutoRepeatOn();
ActivateJoystick();
- SetMouseCursor(CURSOR_DEFAULT);
SetDrawDeactivationMask(REDRAW_NONE);
SetDrawBackgroundMask(REDRAW_FIELD);
DrawText(mSX + 32, mSY + 8*32, "Setup", FONT_MENU_1);
DrawText(mSX + 32, mSY + 9*32, "Quit", FONT_MENU_1);
- DrawText(mSX + 32 + name_width, mSY + 2*32, setup.player_name, FONT_INPUT);
+ DrawText(mSX + 32 + name_width, mSY + 2*32, setup.player_name, FONT_INPUT_1);
DrawText(mSX + level_width + 5 * 32, mSY + 3*32, int2str(level_nr,3),
FONT_VALUE_1);
void HandleTypeName(int newxpos, Key key)
{
static int xpos = 0, ypos = 2;
- int font_width = getFontWidth(FONT_INPUT_ACTIVE);
+ int font_width = getFontWidth(FONT_INPUT_1_ACTIVE);
int name_width = getFontWidth(FONT_MENU_1) * strlen("Name:");
int startx = mSX + 32 + name_width;
int starty = mSY + ypos * 32;
{
xpos = newxpos;
- DrawText(startx, starty, setup.player_name, FONT_INPUT_ACTIVE);
- DrawText(startx + xpos * font_width, starty, "_", FONT_INPUT_ACTIVE);
+ DrawText(startx, starty, setup.player_name, FONT_INPUT_1_ACTIVE);
+ DrawText(startx + xpos * font_width, starty, "_", FONT_INPUT_1_ACTIVE);
return;
}
setup.player_name[xpos + 1] = 0;
xpos++;
- DrawText(startx, starty, setup.player_name, FONT_INPUT_ACTIVE);
- DrawText(startx + xpos * font_width, starty, "_", FONT_INPUT_ACTIVE);
+ DrawText(startx, starty, setup.player_name, FONT_INPUT_1_ACTIVE);
+ DrawText(startx + xpos * font_width, starty, "_", FONT_INPUT_1_ACTIVE);
}
else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
{
xpos--;
setup.player_name[xpos] = 0;
- DrawText(startx + xpos * font_width, starty, "_ ", FONT_INPUT_ACTIVE);
+ DrawText(startx + xpos * font_width, starty, "_ ", FONT_INPUT_1_ACTIVE);
}
else if (key == KSYM_Return && xpos > 0)
{
- DrawText(startx, starty, setup.player_name, FONT_INPUT);
- DrawText(startx + xpos * font_width, starty, " ", FONT_INPUT_ACTIVE);
+ DrawText(startx, starty, setup.player_name, FONT_INPUT_1);
+ DrawText(startx + xpos * font_width, starty, " ", FONT_INPUT_1_ACTIVE);
SaveSetup();
game_status = MAINMENU;
if (setup_info[pos].type & TYPE_QUERY)
{
value_string = "<press key>";
- font_nr = FONT_INPUT_ACTIVE;
+ font_nr = FONT_INPUT_1_ACTIVE;
}
}
else if (setup_info[pos].type & TYPE_STRING)
custom_key = setup.input[player_nr].key;
- DrawText(mSX+11*32, mSY+2*32, int2str(player_nr + 1, 1), FONT_INPUT_ACTIVE);
+ DrawText(mSX+11*32, mSY+2*32, int2str(player_nr +1, 1), FONT_INPUT_1_ACTIVE);
#if 1
DrawGraphicThruMaskExt(drawto, mSX + 8 * TILEX, mSY + 2 * TILEY,
PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0);
step_nr = 0;
DrawText(mSX, mSY + (2+2*step_nr)*32,
- customize_step[step_nr].text, FONT_INPUT_ACTIVE);
+ customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
DrawText(mSX, mSY + (2+2*step_nr+1)*32,
- "Key:", FONT_INPUT_ACTIVE);
+ "Key:", FONT_INPUT_1_ACTIVE);
DrawText(mSX + 4*32, mSY + (2+2*step_nr+1)*32,
getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD);
/* query next key binding */
DrawText(mSX, mSY+(2+2*step_nr)*32,
- customize_step[step_nr].text, FONT_INPUT_ACTIVE);
+ customize_step[step_nr].text, FONT_INPUT_1_ACTIVE);
DrawText(mSX, mSY+(2+2*step_nr+1)*32,
- "Key:", FONT_INPUT_ACTIVE);
+ "Key:", FONT_INPUT_1_ACTIVE);
DrawText(mSX + 4*32, mSY+(2+2*step_nr+1)*32,
getKeyNameFromKey(*customize_step[step_nr].key),
FONT_VALUE_OLD);