From: Holger Schemel Date: Sun, 21 Feb 1999 23:56:34 +0000 (+0100) Subject: rnd-19990222-1-src X-Git-Tag: 1.4.0^2~35 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4c8c9d74169f09d9b21e3ea0d826b60cda37caaa;p=rocksndiamonds.git rnd-19990222-1-src --- diff --git a/src/buttons.c b/src/buttons.c index 78e28d16..4844f2fe 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -362,8 +362,9 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) char cursor_letter; char cursor_string[3]; char text[MAX_GADGET_TEXTSIZE + 1]; - int font_color = FC_YELLOW; - int border = gi->design_border; + int font_type = gi->text.font_type; + int font_width = getFontWidth(FS_SMALL, font_type); + int border = gi->border.size; strcpy(text, gi->text.value); strcat(text, " "); @@ -374,16 +375,16 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) /* middle part of gadget */ for (i=0; i<=gi->text.size; i++) XCopyArea(display, gd->pixmap, drawto, gc, - gd->x + border, gd->y, FONT2_XSIZE, gi->height, - gi->x + border + i * FONT2_XSIZE, gi->y); + gd->x + border, gd->y, font_width, gi->height, + gi->x + border + i * font_width, gi->y); /* right part of gadget */ XCopyArea(display, gd->pixmap, drawto, gc, - gd->x + ED_WIN_COUNT_XSIZE - border, gd->y, + gd->x + gi->border.width - border, gd->y, border, gi->height, gi->x + gi->width - border, gi->y); /* gadget text value */ - DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_color); + DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_type); cursor_letter = gi->text.value[gi->text.cursor_position]; cursor_string[0] = '~'; @@ -392,8 +393,8 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) /* draw cursor, if active */ if (pressed) - DrawText(gi->x + border + gi->text.cursor_position * FONT2_XSIZE, - gi->y + border, cursor_string, FS_SMALL, font_color); + DrawText(gi->x + border + gi->text.cursor_position * font_width, + gi->y + border, cursor_string, FS_SMALL, font_type); } break; @@ -403,9 +404,9 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) int xpos = gi->x; int ypos = gi->y + gi->scrollbar.position; int design_full = gi->width; - int design_body = design_full - 2 * gi->design_border; + int design_body = design_full - 2 * gi->border.size; int size_full = gi->scrollbar.size; - int size_body = size_full - 2 * gi->design_border; + int size_body = size_full - 2 * gi->border.size; int num_steps = size_body / design_body; int step_size_remain = size_body - num_steps * design_body; @@ -416,28 +417,28 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) /* upper part of gadget */ XCopyArea(display, gd->pixmap, drawto, gc, gd->x, gd->y, - gi->width, gi->design_border, + gi->width, gi->border.size, xpos, ypos); /* middle part of gadget */ for (i=0; ipixmap, drawto, gc, - gd->x, gd->y + gi->design_border, + gd->x, gd->y + gi->border.size, gi->width, design_body, - xpos, ypos + gi->design_border + i * design_body); + xpos, ypos + gi->border.size + i * design_body); /* remaining middle part of gadget */ if (step_size_remain > 0) XCopyArea(display, gd->pixmap, drawto, gc, - gd->x, gd->y + gi->design_border, + gd->x, gd->y + gi->border.size, gi->width, step_size_remain, - xpos, ypos + gi->design_border + num_steps * design_body); + xpos, ypos + gi->border.size + num_steps * design_body); /* lower part of gadget */ XCopyArea(display, gd->pixmap, drawto, gc, - gd->x, gd->y + design_full - gi->design_border, - gi->width, gi->design_border, - xpos, ypos + size_full - gi->design_border); + gd->x, gd->y + design_full - gi->border.size, + gi->width, gi->border.size, + xpos, ypos + size_full - gi->border.size); } break; @@ -447,9 +448,9 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) int xpos = gi->x + gi->scrollbar.position; int ypos = gi->y; int design_full = gi->height; - int design_body = design_full - 2 * gi->design_border; + int design_body = design_full - 2 * gi->border.size; int size_full = gi->scrollbar.size; - int size_body = size_full - 2 * gi->design_border; + int size_body = size_full - 2 * gi->border.size; int num_steps = size_body / design_body; int step_size_remain = size_body - num_steps * design_body; @@ -460,28 +461,28 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) /* left part of gadget */ XCopyArea(display, gd->pixmap, drawto, gc, gd->x, gd->y, - gi->design_border, gi->height, + gi->border.size, gi->height, xpos, ypos); /* middle part of gadget */ for (i=0; ipixmap, drawto, gc, - gd->x + gi->design_border, gd->y, + gd->x + gi->border.size, gd->y, design_body, gi->height, - xpos + gi->design_border + i * design_body, ypos); + xpos + gi->border.size + i * design_body, ypos); /* remaining middle part of gadget */ if (step_size_remain > 0) XCopyArea(display, gd->pixmap, drawto, gc, - gd->x + gi->design_border, gd->y, + gd->x + gi->border.size, gd->y, step_size_remain, gi->height, - xpos + gi->design_border + num_steps * design_body, ypos); + xpos + gi->border.size + num_steps * design_body, ypos); /* right part of gadget */ XCopyArea(display, gd->pixmap, drawto, gc, - gd->x + design_full - gi->design_border, gd->y, - gi->design_border, gi->height, - xpos + size_full - gi->design_border, ypos); + gd->x + design_full - gi->border.size, gd->y, + gi->border.size, gi->height, + xpos + size_full - gi->border.size, ypos); } break; @@ -599,15 +600,13 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->text.size = max_textsize; gi->text.value[max_textsize] = '\0'; - - if (gi->width == 0 && gi->height == 0) - { - gi->width = (gi->text.size + 1) * FONT2_XSIZE + 6; - gi->height = ED_WIN_COUNT_YSIZE; - } } break; + case GDI_TEXT_FONT: + gi->text.font_type = va_arg(ap, int); + break; + case GDI_DESIGN_UNPRESSED: gi->design[GD_BUTTON_UNPRESSED].pixmap = va_arg(ap, Pixmap); gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int); @@ -632,8 +631,12 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gi->alt_design[GD_BUTTON_PRESSED].y = va_arg(ap, int); break; - case GDI_DESIGN_BORDER: - gi->design_border = va_arg(ap, int); + case GDI_BORDER_SIZE: + gi->border.size = va_arg(ap, int); + break; + + case GDI_TEXTINPUT_DESIGN_WIDTH: + gi->border.width = va_arg(ap, int); break; case GDI_DECORATION_DESIGN: @@ -734,6 +737,15 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) /* adjust gadget values in relation to other gadget values */ + if (gi->type & GD_TYPE_TEXTINPUT) + { + int font_width = getFontWidth(FS_SMALL, gi->text.font_type); + int font_height = getFontHeight(FS_SMALL, gi->text.font_type); + + gi->width = 2 * gi->border.size + (gi->text.size + 1) * font_width; + gi->height = 2 * gi->border.size + font_height; + } + if (gi->type & GD_TYPE_TEXTINPUT_NUMERIC) { struct GadgetTextInput *text = &gi->text; @@ -760,6 +772,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) gs->size = gs->size_max * gs->items_visible / gs->items_max; gs->position = gs->size_max * gs->item_position / gs->items_max; gs->position_max = gs->size_max - gs->size; + gs->correction = gs->size_max / gs->items_max / 2; /* finetuning for maximal right/bottom position */ if (gs->item_position == gs->items_max - gs->items_visible) @@ -992,7 +1005,9 @@ void HandleGadgets(int mx, int my, int button) if (new_gi == last_gi) { /* if mouse button pressed inside activated text gadget, set cursor */ - gi->text.cursor_position = (mx - gi->x) / FONT2_XSIZE; + gi->text.cursor_position = + (mx - gi->x - gi->border.size) / + getFontWidth(FS_SMALL, gi->text.font_type); if (gi->text.cursor_position < 0) gi->text.cursor_position = 0; @@ -1007,6 +1022,8 @@ void HandleGadgets(int mx, int my, int button) CheckRangeOfNumericInputGadget(gi); DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + gi->event.type = GD_EVENT_TEXT_LEAVING; + if (gi->event_mask & GD_EVENT_TEXT_LEAVING) gi->callback_action(gi); @@ -1213,7 +1230,13 @@ void HandleGadgets(int mx, int my, int button) if (gs->position > gs->position_max) gs->position = gs->position_max; - gs->item_position = gs->items_max * gs->position / gs->size_max; + gs->item_position = + gs->items_max * (gs->position + gs->correction) / gs->size_max; + + if (gs->item_position < 0) + gs->item_position = 0; + if (gs->item_position > gs->items_max - 1) + gs->item_position = gs->items_max - 1; if (old_item_position != gs->item_position) { @@ -1314,6 +1337,8 @@ void HandleGadgetsKeyInput(KeySym key) CheckRangeOfNumericInputGadget(gi); DrawGadget(gi, DG_UNPRESSED, DG_DIRECT); + gi->event.type = GD_EVENT_TEXT_RETURN; + if (gi->event_mask & GD_EVENT_TEXT_RETURN) gi->callback_action(gi); diff --git a/src/buttons.h b/src/buttons.h index cd8db0ef..f3d93c89 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -83,15 +83,6 @@ void DrawCompleteVideoDisplay(void); /* NEW GADGET STUFF -------------------------------------------------------- */ -/* some values for gadget graphics (also used by editor.c) */ -#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 - /* gadget types */ #define GD_TYPE_NORMAL_BUTTON (1 << 0) #define GD_TYPE_CHECK_BUTTON (1 << 1) @@ -144,28 +135,36 @@ void DrawCompleteVideoDisplay(void); #define GDI_NUMBER_MAX 13 #define GDI_TEXT_VALUE 14 #define GDI_TEXT_SIZE 15 -#define GDI_DESIGN_UNPRESSED 16 -#define GDI_DESIGN_PRESSED 17 -#define GDI_ALT_DESIGN_UNPRESSED 18 -#define GDI_ALT_DESIGN_PRESSED 19 -#define GDI_DESIGN_BORDER 20 -#define GDI_DECORATION_DESIGN 21 -#define GDI_DECORATION_POSITION 22 -#define GDI_DECORATION_SIZE 23 -#define GDI_DECORATION_SHIFTING 24 -#define GDI_EVENT_MASK 25 -#define GDI_EVENT 26 -#define GDI_CALLBACK_INFO 27 -#define GDI_CALLBACK_ACTION 28 -#define GDI_AREA_SIZE 29 -#define GDI_ITEM_SIZE 30 -#define GDI_SCROLLBAR_ITEMS_MAX 31 -#define GDI_SCROLLBAR_ITEMS_VISIBLE 32 -#define GDI_SCROLLBAR_ITEM_POSITION 33 -#define GDI_INFO_TEXT 34 +#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 typedef void (*gadget_function)(void *); +struct GadgetBorder +{ + int size; /* size of gadget border */ + int width; /* for text input gadgets */ +}; + struct GadgetDesign { Pixmap pixmap; /* Pixmap with gadget surface */ @@ -203,6 +202,7 @@ struct GadgetTextInput int number_max; /* maximal allowed numeric value */ int size; /* maximal size of input text */ int cursor_position; /* actual cursor position */ + int font_type; /* font to use for text input */ }; struct GadgetScrollbar @@ -215,6 +215,7 @@ struct GadgetScrollbar int position; /* scrollbar position on screen */ int position_max; /* bottom/right scrollbar position */ int drag_position; /* drag position on scrollbar */ + int correction; /* scrollbar position correction */ }; struct GadgetInfo @@ -230,10 +231,10 @@ struct GadgetInfo boolean checked; /* check/radio button state */ int radio_nr; /* number of radio button series */ boolean mapped; /* gadget is active */ + struct GadgetBorder border; /* gadget border design */ struct GadgetDesign design[2]; /* 0: normal; 1: pressed */ struct GadgetDesign alt_design[2]; /* alternative design */ struct GadgetDecoration deco; /* decoration on top of gadget */ - int design_border; /* border size of gadget decoration */ unsigned long event_mask; /* possible events for this gadget */ struct GadgetEvent event; /* actual gadget event */ gadget_function callback_info; /* function for pop-up info text */ diff --git a/src/editor.c b/src/editor.c index d5233e26..fd269219 100644 --- a/src/editor.c +++ b/src/editor.c @@ -23,14 +23,12 @@ #include "tape.h" /* positions in the level editor */ -#define ED_WIN_MB_LEFT_XPOS 7 -#define ED_WIN_MB_LEFT_YPOS 6 -#define ED_WIN_LEVELNR_XPOS 77 -#define ED_WIN_LEVELNR_YPOS 7 -#define ED_WIN_MB_MIDDLE_XPOS 7 -#define ED_WIN_MB_MIDDLE_YPOS 258 -#define ED_WIN_MB_RIGHT_XPOS 77 -#define ED_WIN_MB_RIGHT_YPOS 258 +#define ED_WIN_MB_LEFT_XPOS 6 +#define ED_WIN_MB_LEFT_YPOS 258 +#define ED_WIN_MB_MIDDLE_XPOS 42 +#define ED_WIN_MB_MIDDLE_YPOS ED_WIN_MB_LEFT_YPOS +#define ED_WIN_MB_RIGHT_XPOS 78 +#define ED_WIN_MB_RIGHT_YPOS ED_WIN_MB_LEFT_YPOS /* other constants for the editor */ #define ED_SCROLL_NO 0 @@ -72,21 +70,12 @@ #define ED_NUM_CTRL_BUTTONS (ED_NUM_CTRL1_BUTTONS + ED_NUM_CTRL2_BUTTONS) /* values for the element list */ -#define ED_ELEMENTLIST_UP_XPOS 35 -#define ED_ELEMENTLIST_UP_YPOS 5 -#define ED_ELEMENTLIST_UP_ALT_YPOS 140 -#define ED_ELEMENTLIST_DOWN_XPOS 35 -#define ED_ELEMENTLIST_DOWN_YPOS 250 -#define ED_ELEMENTLIST_DOWN_ALT_YPOS 165 -#define ED_ELEMENTLIST_UPDOWN_XSIZE 30 -#define ED_ELEMENTLIST_UPDOWN_YSIZE 25 -#define ED_ELEMENTLIST_XPOS 6 +#define ED_ELEMENTLIST_XPOS 5 #define ED_ELEMENTLIST_YPOS 30 -#define ED_ELEMENTLIST_ALT_YPOS 190 -#define ED_ELEMENTLIST_XSIZE 22 -#define ED_ELEMENTLIST_YSIZE 22 +#define ED_ELEMENTLIST_XSIZE 20 +#define ED_ELEMENTLIST_YSIZE 20 #define ED_ELEMENTLIST_BUTTONS_HORIZ 4 -#define ED_ELEMENTLIST_BUTTONS_VERT 10 +#define ED_ELEMENTLIST_BUTTONS_VERT 11 #define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \ ED_ELEMENTLIST_BUTTONS_VERT) @@ -120,7 +109,7 @@ #define ED_AREA_RANDOM_BACKGROUND_XPOS (29 * MINI_TILEX) #define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY) -/* values for scrolling gadgets */ +/* values for scrolling gadgets for drawing area */ #define ED_SCROLLBUTTON_XPOS 24 #define ED_SCROLLBUTTON_YPOS 0 #define ED_SCROLLBAR_XPOS 24 @@ -146,13 +135,38 @@ #define ED_SCROLL_VERTICAL_XSIZE ED_SCROLLBUTTON_XSIZE #define ED_SCROLL_VERTICAL_YSIZE (SYSIZE - 4 * ED_SCROLLBUTTON_YSIZE) +/* values for scrolling gadgets for element list */ +#define ED_SCROLLBUTTON2_XPOS 50 +#define ED_SCROLLBUTTON2_YPOS 0 +#define ED_SCROLLBAR2_XPOS 50 +#define ED_SCROLLBAR2_YPOS 20 + +#define ED_SCROLLBUTTON2_XSIZE 10 +#define ED_SCROLLBUTTON2_YSIZE 10 + +#define ED_SCROLL2_UP_XPOS 85 +#define ED_SCROLL2_UP_YPOS 30 +#define ED_SCROLL2_DOWN_XPOS ED_SCROLL2_UP_XPOS +#define ED_SCROLL2_DOWN_YPOS (ED_SCROLL2_UP_YPOS + \ + ED_ELEMENTLIST_BUTTONS_VERT * \ + ED_ELEMENTLIST_YSIZE - \ + ED_SCROLLBUTTON2_YSIZE) +#define ED_SCROLL2_VERTICAL_XPOS ED_SCROLL2_UP_XPOS +#define ED_SCROLL2_VERTICAL_YPOS (ED_SCROLL2_UP_YPOS + \ + ED_SCROLLBUTTON2_YSIZE) +#define ED_SCROLL2_VERTICAL_XSIZE ED_SCROLLBUTTON2_XSIZE +#define ED_SCROLL2_VERTICAL_YSIZE (ED_ELEMENTLIST_BUTTONS_VERT * \ + ED_ELEMENTLIST_YSIZE - \ + 2 * ED_SCROLLBUTTON2_YSIZE) + /* values for checkbutton gadgets */ #define ED_CHECKBUTTON_XSIZE ED_BUTTON_COUNT_XSIZE #define ED_CHECKBUTTON_YSIZE ED_BUTTON_COUNT_YSIZE #define ED_CHECKBUTTON_UNCHECKED_XPOS ED_BUTTON_MINUS_XPOS #define ED_CHECKBUTTON_CHECKED_XPOS ED_BUTTON_PLUS_XPOS #define ED_CHECKBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 22) -#define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 88) +#define ED_RADIOBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 44) +#define ED_STICKYBUTTON_YPOS (ED_BUTTON_MINUS_YPOS + 66) /* some positions in the editor control window */ #define ED_BUTTON_ELEM_XPOS 6 @@ -160,6 +174,19 @@ #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 @@ -250,25 +277,26 @@ #define GADGET_ID_SCROLL_VERTICAL 66 /* gadgets for scrolling element list */ -#define GADGET_ID_ELEMENTLIST_UP 67 -#define GADGET_ID_ELEMENTLIST_DOWN 68 - -/* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST 69 -#define GADGET_ID_ELEMENTLIST_LAST 108 +#define GADGET_ID_SCROLL_LIST_UP 67 +#define GADGET_ID_SCROLL_LIST_DOWN 68 +#define GADGET_ID_SCROLL_LIST_VERTICAL 69 /* buttons for level settings */ -#define GADGET_ID_RANDOM_PERCENTAGE 109 -#define GADGET_ID_RANDOM_QUANTITY 110 -#define GADGET_ID_RANDOM_RESTRICTED 111 -#define GADGET_ID_DOUBLE_SPEED 112 -#define GADGET_ID_GRAVITY 113 -#define GADGET_ID_STICK_ELEMENT 114 +#define GADGET_ID_RANDOM_PERCENTAGE 70 +#define GADGET_ID_RANDOM_QUANTITY 71 +#define GADGET_ID_RANDOM_RESTRICTED 72 +#define GADGET_ID_DOUBLE_SPEED 73 +#define GADGET_ID_GRAVITY 74 +#define GADGET_ID_STICK_ELEMENT 75 /* another drawing area for random placement */ -#define GADGET_ID_RANDOM_BACKGROUND 115 +#define GADGET_ID_RANDOM_BACKGROUND 76 + +/* gadgets for buttons in element list */ +#define GADGET_ID_ELEMENTLIST_FIRST 77 +#define GADGET_ID_ELEMENTLIST_LAST (77 + ED_NUM_ELEMENTLIST_BUTTONS - 1) -#define NUM_EDITOR_GADGETS 116 +#define NUM_EDITOR_GADGETS (GADGET_ID_ELEMENTLIST_LAST + 1) /* radio button numbers */ #define RADIO_NR_NONE 0 @@ -305,10 +333,14 @@ #define ED_SCROLLBUTTON_ID_AREA_LAST ED_SCROLLBUTTON_ID_AREA_RIGHT /* values for scrollbar gadgets */ -#define ED_SCROLLBAR_ID_HORIZONTAL 0 -#define ED_SCROLLBAR_ID_VERTICAL 1 +#define ED_SCROLLBAR_ID_AREA_HORIZONTAL 0 +#define ED_SCROLLBAR_ID_AREA_VERTICAL 1 +#define ED_SCROLLBAR_ID_LIST_VERTICAL 2 -#define ED_NUM_SCROLLBARS 2 +#define ED_NUM_SCROLLBARS 3 + +#define ED_SCROLLBAR_ID_AREA_FIRST ED_SCROLLBAR_ID_AREA_HORIZONTAL +#define ED_SCROLLBAR_ID_AREA_LAST ED_SCROLLBAR_ID_AREA_VERTICAL /* values for text input gadgets */ #define ED_TEXTINPUT_ID_LEVEL_NAME 0 @@ -465,7 +497,7 @@ static struct "random element placement", "in" }, { - DX - SX - 1, 0 - SY + 31, + DX + 5 - SX, DY + 3 - SY, 1, 100, GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP, GADGET_ID_SELECT_LEVEL_TEXT, @@ -532,15 +564,15 @@ static struct "scroll level editing area right" }, { - ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_ALT_YPOS, - ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_YPOS, - GADGET_ID_ELEMENTLIST_UP, + ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 0 * ED_SCROLLBUTTON2_YSIZE, + ED_SCROLL2_UP_XPOS, ED_SCROLL2_UP_YPOS, + GADGET_ID_SCROLL_LIST_UP, "scroll element list up ('Page Up')" }, { - ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_ALT_YPOS, - ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_YPOS, - GADGET_ID_ELEMENTLIST_DOWN, + ED_SCROLLBUTTON2_XPOS, ED_SCROLLBUTTON2_YPOS + 1 * ED_SCROLLBUTTON2_YSIZE, + ED_SCROLL2_DOWN_XPOS, ED_SCROLL2_DOWN_YPOS, + GADGET_ID_SCROLL_LIST_DOWN, "scroll element list down ('Page Down')" } }; @@ -556,20 +588,28 @@ static struct } scrollbar_info[ED_NUM_SCROLLBARS] = { { - ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, - ED_SCROLL_HORIZONTAL_XPOS, ED_SCROLL_HORIZONTAL_YPOS, - ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, + ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, + SX + ED_SCROLL_HORIZONTAL_XPOS, SY + ED_SCROLL_HORIZONTAL_YPOS, + ED_SCROLL_HORIZONTAL_XSIZE, ED_SCROLL_HORIZONTAL_YSIZE, GD_TYPE_SCROLLBAR_HORIZONTAL, GADGET_ID_SCROLL_HORIZONTAL, "scroll level editing area horizontally" }, { - ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, - ED_SCROLL_VERTICAL_XPOS, ED_SCROLL_VERTICAL_YPOS, - ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, + ED_SCROLLBAR_XPOS, ED_SCROLLBAR_YPOS, + SX + ED_SCROLL_VERTICAL_XPOS, SY + ED_SCROLL_VERTICAL_YPOS, + ED_SCROLL_VERTICAL_XSIZE, ED_SCROLL_VERTICAL_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, GADGET_ID_SCROLL_VERTICAL, "scroll level editing area vertically" + }, + { + ED_SCROLLBAR2_XPOS, ED_SCROLLBAR2_YPOS, + DX + ED_SCROLL2_VERTICAL_XPOS, DY + ED_SCROLL2_VERTICAL_YPOS, + ED_SCROLL2_VERTICAL_XSIZE, ED_SCROLL2_VERTICAL_YSIZE, + GD_TYPE_SCROLLBAR_VERTICAL, + GADGET_ID_SCROLL_LIST_VERTICAL, + "scroll element list vertically" } }; @@ -1217,17 +1257,17 @@ static void CreateControlButtons() event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; - if (id == GADGET_ID_ELEMENTLIST_UP || - id == GADGET_ID_ELEMENTLIST_DOWN) + if (id == GADGET_ID_SCROLL_LIST_UP || + id == GADGET_ID_SCROLL_LIST_DOWN) { x += DX; y += DY; - width = ED_ELEMENTLIST_UPDOWN_XSIZE; - height = ED_ELEMENTLIST_UPDOWN_YSIZE; - gd_x1 = DOOR_GFX_PAGEX6 + scrollbutton_info[i].xpos; - gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].y; - gd_x2 = gd_x1; - gd_y2 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos; + width = ED_SCROLLBUTTON2_XSIZE; + height = ED_SCROLLBUTTON2_YSIZE; + gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[i].xpos; + gd_y1 = DOOR_GFX_PAGEY1 + scrollbutton_info[i].ypos; + gd_x2 = gd_x1 - ED_SCROLLBUTTON2_XSIZE; + gd_y2 = gd_y1; } else { @@ -1268,7 +1308,7 @@ static void CreateControlButtons() Pixmap deco_pixmap; int deco_x, deco_y, deco_xpos, deco_ypos; int gd_xoffset, gd_yoffset; - int gd_x, gd_y1, gd_y2; + int gd_x1, gd_x2, gd_y; int x = i % ED_ELEMENTLIST_BUTTONS_HORIZ; int y = i / ED_ELEMENTLIST_BUTTONS_HORIZ; int id = GADGET_ID_ELEMENTLIST_FIRST + i; @@ -1278,9 +1318,9 @@ static void CreateControlButtons() gd_xoffset = ED_ELEMENTLIST_XPOS + x * ED_ELEMENTLIST_XSIZE; gd_yoffset = ED_ELEMENTLIST_YPOS + y * ED_ELEMENTLIST_YSIZE; - gd_x = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS; - gd_y1 = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS; - gd_y2 = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_ALT_YPOS; + gd_x1 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS + ED_ELEMENTLIST_XSIZE; + gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS; + gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS; getMiniGraphicSource(el2gfx(editor_element[i]), &deco_pixmap, &deco_x, &deco_y); @@ -1296,8 +1336,8 @@ static void CreateControlButtons() GDI_HEIGHT, ED_ELEMENTLIST_YSIZE, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, GDI_STATE, GD_BUTTON_UNPRESSED, - GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y1, - GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y2, + GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y, + GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y, GDI_DECORATION_DESIGN, deco_pixmap, deco_x, deco_y, GDI_DECORATION_POSITION, deco_xpos, deco_ypos, GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY, @@ -1347,7 +1387,7 @@ static void CreateCounterButtons() event_mask |= GD_EVENT_RELEASED; if (j == 1) - xpos += ED_GADGET_DISTANCE; + xpos += 2 * ED_GADGET_DISTANCE; ypos += ED_GADGET_DISTANCE; gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].xpos; @@ -1392,16 +1432,22 @@ static void CreateCounterButtons() if (j == 0) { + int font_type = FC_YELLOW; + int gd_width = ED_WIN_COUNT_XSIZE; + id = counterbutton_info[i].gadget_id_text; event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING; if (i == ED_COUNTER_ID_SELECT_LEVEL) { - xpos += ED_GADGET_DISTANCE; + font_type = FC_SPECIAL3; + + xpos += 2 * ED_GADGET_DISTANCE; ypos -= ED_GADGET_DISTANCE; - gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS; - gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS; + gd_x = DOOR_GFX_PAGEX6 + ED_WIN_COUNT2_XPOS; + gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT2_YPOS; + gd_width = ED_WIN_COUNT2_XSIZE; } else { @@ -1419,9 +1465,11 @@ static void CreateCounterButtons() GDI_NUMBER_MIN, counterbutton_info[i].min_value, GDI_NUMBER_MAX, counterbutton_info[i].max_value, GDI_TEXT_SIZE, 3, + GDI_TEXT_FONT, font_type, GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y, GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y, - GDI_DESIGN_BORDER, ED_BORDER_SIZE, + GDI_BORDER_SIZE, ED_BORDER_SIZE, + GDI_TEXTINPUT_DESIGN_WIDTH, gd_width, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleCounterButtons, GDI_END); @@ -1560,9 +1608,11 @@ static void CreateTextInputGadgets() GDI_TYPE, GD_TYPE_TEXTINPUT_ALPHANUMERIC, GDI_TEXT_VALUE, textinput_info[i].value, GDI_TEXT_SIZE, textinput_info[i].size, + GDI_TEXT_FONT, FC_YELLOW, GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x, gd_y, GDI_DESIGN_PRESSED, gd_pixmap, gd_x, gd_y, - GDI_DESIGN_BORDER, ED_BORDER_SIZE, + GDI_BORDER_SIZE, ED_BORDER_SIZE, + GDI_TEXTINPUT_DESIGN_WIDTH, ED_WIN_COUNT_XSIZE, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleTextInputGadgets, GDI_END); @@ -1587,31 +1637,41 @@ static void CreateScrollbarGadgets() int items_max, items_visible, item_position; unsigned long event_mask; - if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL) + if (i == ED_SCROLLBAR_ID_LIST_VERTICAL) { - items_max = MAX(lev_fieldx + 2, ed_fieldx); - items_visible = ed_fieldx; + items_max = elements_in_list / ED_ELEMENTLIST_BUTTONS_HORIZ; + items_visible = ED_ELEMENTLIST_BUTTONS_VERT; item_position = 0; } - else + else /* drawing area scrollbars */ { - items_max = MAX(lev_fieldy + 2, ed_fieldy); - items_visible = ed_fieldy; - item_position = 0; + if (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL) + { + items_max = MAX(lev_fieldx + 2, ed_fieldx); + items_visible = ed_fieldx; + item_position = 0; + } + else + { + items_max = MAX(lev_fieldy + 2, ed_fieldy); + items_visible = ed_fieldy; + item_position = 0; + } } event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS; gd_x1 = DOOR_GFX_PAGEX8 + scrollbar_info[i].xpos; - gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE; + gd_x2 = (gd_x1 - (scrollbar_info[i].type == GD_TYPE_SCROLLBAR_HORIZONTAL ? + scrollbar_info[i].height : scrollbar_info[i].width)); gd_y1 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; gd_y2 = DOOR_GFX_PAGEY1 + scrollbar_info[i].ypos; gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, scrollbar_info[i].infotext, - GDI_X, SX + scrollbar_info[i].x, - GDI_Y, SY + scrollbar_info[i].y, + GDI_X, scrollbar_info[i].x, + GDI_Y, scrollbar_info[i].y, GDI_WIDTH, scrollbar_info[i].width, GDI_HEIGHT, scrollbar_info[i].height, GDI_TYPE, scrollbar_info[i].type, @@ -1621,7 +1681,7 @@ static void CreateScrollbarGadgets() GDI_STATE, GD_BUTTON_UNPRESSED, GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2, - GDI_DESIGN_BORDER, ED_BORDER_SIZE, + GDI_BORDER_SIZE, ED_BORDER_SIZE, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleControlButtons, GDI_END); @@ -1648,7 +1708,7 @@ static void CreateCheckbuttonGadgets() gd_x2 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_UNCHECKED_XPOS; gd_x3 = DOOR_GFX_PAGEX4 + ED_CHECKBUTTON_CHECKED_XPOS; gd_x4 = DOOR_GFX_PAGEX3 + ED_CHECKBUTTON_CHECKED_XPOS; - gd_y = DOOR_GFX_PAGEY1 + ED_CHECKBUTTON_YPOS; + gd_y = DOOR_GFX_PAGEY1 + ED_RADIOBUTTON_YPOS; for (i=0; icustom_id; - int counter_id = gi->custom_type_id; - int button = gi->event.button; - int *counter_value = counterbutton_info[counter_id].value; - int step = BUTTON_STEPSIZE(button) * - (gadget_id == counterbutton_info[counter_id].gadget_id_down ? -1 : +1); - int old_counter_value = *counter_value; - boolean released = (gi->event.type == GD_EVENT_RELEASED); - - if (LevelChanged()) - { - if (gi->event.type == GD_EVENT_PRESSED) - return; - - if (!Request("Level has changed! Discard changes ?", REQ_ASK)) - { - ModifyEditorCounter(counter_id, old_counter_value); - return; - } - } - else if (released) - return; - - if (gadget_id == counterbutton_info[counter_id].gadget_id_text) - *counter_value = gi->text.number_value; - else - ModifyEditorCounter(counter_id, *counter_value + step); - - LoadLevel(level_nr); - ResetUndoBuffer(); - DrawEditModeWindow(); -} - static void AdjustDrawingAreaGadgets() { int ed_xsize = lev_fieldx + 2; @@ -2054,8 +2057,8 @@ static void AdjustDrawingAreaGadgets() ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_RIGHT], GDI_X, x, GDI_END); ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_DOWN], GDI_Y, y, GDI_END); - width = scrollbar_info[ED_SCROLLBAR_ID_HORIZONTAL].width + xoffset; - height = scrollbar_info[ED_SCROLLBAR_ID_VERTICAL].height + yoffset; + width = scrollbar_info[ED_SCROLLBAR_ID_AREA_HORIZONTAL].width + xoffset; + height = scrollbar_info[ED_SCROLLBAR_ID_AREA_VERTICAL].height + yoffset; ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL], GDI_WIDTH, width, @@ -2146,24 +2149,21 @@ static void PickDrawingElement(int button, int element) { new_element1 = element; DrawMiniGraphicExt(drawto, gc, - DX + ED_WIN_MB_LEFT_XPOS, - DY + ED_WIN_MB_LEFT_YPOS, + DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS, el2gfx(new_element1)); } else if (button == 2) { new_element2 = element; DrawMiniGraphicExt(drawto, gc, - DX + ED_WIN_MB_MIDDLE_XPOS, - DY + ED_WIN_MB_MIDDLE_YPOS, + DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS, el2gfx(new_element2)); } else { new_element3 = element; DrawMiniGraphicExt(drawto, gc, - DX + ED_WIN_MB_RIGHT_XPOS, - DY + ED_WIN_MB_RIGHT_YPOS, + DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS, el2gfx(new_element3)); } @@ -3442,8 +3442,20 @@ static void HandleCounterButtons(struct GadgetInfo *gi) if (counter_id == ED_COUNTER_ID_SELECT_LEVEL) { - SelectNewLevelToEdit(gi); - return; + boolean pressed = (gi->event.type == GD_EVENT_PRESSED); + boolean released = (gi->event.type == GD_EVENT_RELEASED); + boolean level_changed = LevelChanged(); + + if ((level_changed && pressed) || (!level_changed && released)) + return; + + if (level_changed && !Request("Level has changed! Discard changes ?", + REQ_ASK)) + { + if (gadget_id == counterbutton_info[counter_id].gadget_id_text) + ModifyEditorCounter(counter_id, *counter_value); + return; + } } if (gadget_id == counterbutton_info[counter_id].gadget_id_text) @@ -3451,12 +3463,27 @@ static void HandleCounterButtons(struct GadgetInfo *gi) else ModifyEditorCounter(counter_id, *counter_value + step); - if (counter_id == ED_COUNTER_ID_ELEM_CONTENT) - DrawElementContentAreas(); - else if (counter_id == ED_COUNTER_ID_LEVEL_XSIZE) - lev_fieldx = level.fieldx; - else if (counter_id == ED_COUNTER_ID_LEVEL_YSIZE) - lev_fieldy = level.fieldy; + switch (counter_id) + { + case ED_COUNTER_ID_ELEM_CONTENT: + DrawElementContentAreas(); + break; + + case ED_COUNTER_ID_LEVEL_XSIZE: + case ED_COUNTER_ID_LEVEL_YSIZE: + lev_fieldx = level.fieldx; + lev_fieldy = level.fieldy; + break; + + case ED_COUNTER_ID_SELECT_LEVEL: + LoadLevel(level_nr); + ResetUndoBuffer(); + DrawEditModeWindow(); + break; + + default: + break; + } } static void HandleTextInputGadgets(struct GadgetInfo *gi) @@ -3498,9 +3525,6 @@ static void HandleControlButtons(struct GadgetInfo *gi) case GADGET_ID_SCROLL_LEFT: if (level_xpos >= 0) { - int gadget_id = GADGET_ID_SCROLL_HORIZONTAL; - struct GadgetInfo *gi = level_editor_gadget[gadget_id]; - if (lev_fieldx < ed_fieldx - 2) break; @@ -3512,16 +3536,14 @@ static void HandleControlButtons(struct GadgetInfo *gi) else DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos); - ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END); + ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL], + GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END); } break; case GADGET_ID_SCROLL_RIGHT: if (level_xpos <= lev_fieldx - ed_fieldx) { - int gadget_id = GADGET_ID_SCROLL_HORIZONTAL; - struct GadgetInfo *gi = level_editor_gadget[gadget_id]; - if (lev_fieldx < ed_fieldx - 2) break; @@ -3533,16 +3555,14 @@ static void HandleControlButtons(struct GadgetInfo *gi) else DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos); - ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END); + ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_HORIZONTAL], + GDI_SCROLLBAR_ITEM_POSITION, level_xpos + 1, GDI_END); } break; case GADGET_ID_SCROLL_UP: if (level_ypos >= 0) { - int gadget_id = GADGET_ID_SCROLL_VERTICAL; - struct GadgetInfo *gi = level_editor_gadget[gadget_id]; - if (lev_fieldy < ed_fieldy - 2) break; @@ -3554,16 +3574,14 @@ static void HandleControlButtons(struct GadgetInfo *gi) else DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos); - ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END); + ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL], + GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END); } break; case GADGET_ID_SCROLL_DOWN: if (level_ypos <= lev_fieldy - ed_fieldy) { - int gadget_id = GADGET_ID_SCROLL_VERTICAL; - struct GadgetInfo *gi = level_editor_gadget[gadget_id]; - if (lev_fieldy < ed_fieldy - 2) break; @@ -3575,7 +3593,8 @@ static void HandleControlButtons(struct GadgetInfo *gi) else DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos); - ModifyGadget(gi, GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END); + ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_VERTICAL], + GDI_SCROLLBAR_ITEM_POSITION, level_ypos + 1, GDI_END); } break; @@ -3589,15 +3608,25 @@ static void HandleControlButtons(struct GadgetInfo *gi) DrawMiniLevel(ed_fieldx, ed_fieldy, level_xpos, level_ypos); break; - case GADGET_ID_ELEMENTLIST_UP: - case GADGET_ID_ELEMENTLIST_DOWN: - step *= (id == GADGET_ID_ELEMENTLIST_UP ? -1 : +1); - element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ; + case GADGET_ID_SCROLL_LIST_UP: + case GADGET_ID_SCROLL_LIST_DOWN: + case GADGET_ID_SCROLL_LIST_VERTICAL: + if (id == GADGET_ID_SCROLL_LIST_VERTICAL) + element_shift = gi->event.item_position * ED_ELEMENTLIST_BUTTONS_HORIZ; + else + { + step *= (id == GADGET_ID_SCROLL_LIST_UP ? -1 : +1); + element_shift += step * ED_ELEMENTLIST_BUTTONS_HORIZ; - if (element_shift < 0) - element_shift = 0; - if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS) - element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS; + if (element_shift < 0) + element_shift = 0; + if (element_shift > elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS) + element_shift = elements_in_list - ED_NUM_ELEMENTLIST_BUTTONS; + + ModifyGadget(level_editor_gadget[GADGET_ID_SCROLL_LIST_VERTICAL], + GDI_SCROLLBAR_ITEM_POSITION, + element_shift / ED_ELEMENTLIST_BUTTONS_HORIZ, GDI_END); + } for (i=0; igems_still_needed,3), FS_SMALL, FC_YELLOW); + int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); DrawText(DX + XX_SCORE, DY + YY_SCORE, diff --git a/src/main.h b/src/main.h index 5f0a813a..0a52d8f5 100644 --- a/src/main.h +++ b/src/main.h @@ -545,7 +545,7 @@ extern char *element_info[]; #define FONT4_XSIZE 16 #define FONT4_YSIZE 16 #define FONT5_XSIZE 10 -#define FONT5_YSIZE 12 +#define FONT5_YSIZE 14 #define GFX_STARTX SX #define GFX_STARTY SY diff --git a/src/tools.c b/src/tools.c index 39e327cc..4412ad1f 100644 --- a/src/tools.c +++ b/src/tools.c @@ -314,22 +314,35 @@ void ClearWindow() redraw_mask |= REDRAW_FIELD; } +int getFontWidth(int font_size, int font_type) +{ + return (font_size == FS_BIG ? FONT1_XSIZE : + font_type == FC_SPECIAL1 ? FONT3_XSIZE : + font_type == FC_SPECIAL2 ? FONT4_XSIZE : + font_type == FC_SPECIAL3 ? FONT5_XSIZE : + FONT2_XSIZE); +} + +int getFontHeight(int font_size, int font_type) +{ + return (font_size == FS_BIG ? FONT1_YSIZE : + font_type == FC_SPECIAL1 ? FONT3_YSIZE : + font_type == FC_SPECIAL2 ? FONT4_YSIZE : + font_type == FC_SPECIAL3 ? FONT5_YSIZE : + FONT2_YSIZE); +} + void DrawTextFCentered(int y, int font_type, char *format, ...) { char buffer[FULL_SXSIZE / FONT5_XSIZE + 10]; - int font_xsize; + int font_width = getFontWidth(FS_SMALL, font_type); va_list ap; - font_xsize = (font_type < FC_SPECIAL1 ? FONT2_XSIZE : - font_type < FC_SPECIAL2 ? FONT3_XSIZE : - font_type < FC_SPECIAL3 ? FONT4_XSIZE : - FONT5_XSIZE); - va_start(ap, format); vsprintf(buffer, format, ap); va_end(ap); - DrawText(SX + (SXSIZE - strlen(buffer) * font_xsize) / 2, SY + y, + DrawText(SX + (SXSIZE - strlen(buffer) * font_width) / 2, SY + y, buffer, FS_SMALL, font_type); } @@ -367,28 +380,21 @@ void DrawTextExt(Drawable d, GC gc, int x, int y, if (font_type < FC_RED || font_type > FC_SPECIAL3) font_type = FC_RED; - font_width = (font_size == FS_BIG ? FONT1_XSIZE : - font_type < FC_SPECIAL1 ? FONT2_XSIZE : - font_type < FC_SPECIAL2 ? FONT3_XSIZE : - font_type < FC_SPECIAL3 ? FONT4_XSIZE : - FONT5_XSIZE); - font_height = (font_size == FS_BIG ? FONT1_YSIZE : - font_type < FC_SPECIAL1 ? FONT2_YSIZE : - font_type < FC_SPECIAL2 ? FONT3_YSIZE : - font_type < FC_SPECIAL3 ? FONT4_YSIZE : - FONT5_YSIZE); + font_width = getFontWidth(font_size, font_type); + font_height = getFontHeight(font_size, font_type); + font_pixmap = (font_size == FS_BIG ? PIX_BIGFONT : PIX_SMALLFONT); font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE : FONT2_YSIZE) * FONT_LINES_PER_FONT); if (font_type == FC_SPECIAL3) - font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT + 3; + font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT; while (*text) { char c = *text++; - if (c == '~' && font_size == FS_SMALL && font_type <= FC_YELLOW) + if (c == '~' && font_size == FS_SMALL) { print_inverse = TRUE; continue; @@ -1491,21 +1497,7 @@ void DrawLevel() for(y=BY1; y<=BY2; y++) DrawScreenField(x, y); - -#if 1 - redraw_mask |= REDRAW_FIELD; - -#else - - if (setup.soft_scrolling) - XCopyArea(display, fieldbuffer, backbuffer, gc, - FX, FY, SXSIZE, SYSIZE, SX, SY); - - redraw_mask |= (REDRAW_FIELD | REDRAW_FROM_BACKBUFFER); - -#endif - } void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y) @@ -2088,11 +2080,7 @@ void DrawSpecialEditorDoor() { /* draw bigger toolbox window */ XCopyArea(display, pix[PIX_DOOR], drawto, gc, - DOOR_GFX_PAGEX7, 60, 108, 56, EX - 4, EY - 12); - - /* draw background for level selection gadgets */ - XCopyArea(display, pix[PIX_DOOR], drawto, gc, - DOOR_GFX_PAGEX7, 0, 108, 60, EX - 4, 0); + DOOR_GFX_PAGEX7, 0, 108, 56, EX - 4, EY - 12); redraw_mask |= REDRAW_ALL; } @@ -2103,10 +2091,6 @@ void UndrawSpecialEditorDoor() XCopyArea(display, pix[PIX_BACK], drawto, gc, 562, 344, 108, 56, EX - 4, EY - 12); - /* draw game title */ - XCopyArea(display, pix[PIX_BACK], drawto, gc, - 562, 0, 108, 60, EX - 4, 0); - redraw_mask |= REDRAW_ALL; } diff --git a/src/tools.h b/src/tools.h index 9ec88df2..6eaf88c2 100644 --- a/src/tools.h +++ b/src/tools.h @@ -62,6 +62,8 @@ void SetDrawtoField(int); void BackToFront(); void FadeToFront(); void ClearWindow(); +int getFontWidth(int, int); +int getFontHeight(int, int); void DrawTextF(int, int, int, char *, ...); void DrawTextFCentered(int, int, char *, ...); void DrawText(int, int, char *, int, int);