From: Holger Schemel Date: Sun, 24 Jan 1999 22:03:38 +0000 (+0100) Subject: rnd-19990124-2 X-Git-Tag: 1.3.0^2~17 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f941ccddee3065d7531298e37ad4dcfcd892c1f8;p=rocksndiamonds.git rnd-19990124-2 --- diff --git a/src/buttons.c b/src/buttons.c index 721a8335..a55f38d9 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1658,33 +1658,7 @@ static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my) if (gi->mapped && mx >= gi->x && mx < gi->x + gi->width && my >= gi->y && my < gi->y + gi->height) - { - -#if 0 - if (gi->type & GD_TYPE_SCROLLBAR) - { - int mpos, gpos; - - if (gi->type == GD_TYPE_SCROLLBAR_HORIZONTAL) - { - mpos = mx; - gpos = gi->x; - } - else - { - mpos = my; - gpos = gi->y; - } - - if (mpos >= gpos + gi->scrollbar.position && - mpos < gpos + gi->scrollbar.position + gi->scrollbar.size) - break; - } - else -#endif - break; - } gi = gi->next; } @@ -1847,6 +1821,27 @@ struct GadgetInfo *CreateGadget(int first_tag, ...) new_gadget->design_border = va_arg(ap, int); break; + case GDI_DECORATION_DESIGN: + new_gadget->deco.design.pixmap = va_arg(ap, Pixmap); + new_gadget->deco.design.x = va_arg(ap, int); + new_gadget->deco.design.y = va_arg(ap, int); + break; + + case GDI_DECORATION_POSITION: + new_gadget->deco.x = va_arg(ap, int); + new_gadget->deco.y = va_arg(ap, int); + break; + + case GDI_DECORATION_SIZE: + new_gadget->deco.width = va_arg(ap, int); + new_gadget->deco.height = va_arg(ap, int); + break; + + case GDI_DECORATION_SHIFTING: + new_gadget->deco.xshift = va_arg(ap, int); + new_gadget->deco.yshift = va_arg(ap, int); + break; + case GDI_EVENT_MASK: new_gadget->event_mask = va_arg(ap, unsigned long); break; @@ -2025,6 +2020,12 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) case GD_TYPE_RADIO_BUTTON: XCopyArea(display, gd->pixmap, drawto, gc, gd->x, gd->y, gi->width, gi->height, gi->x, gi->y); + if (gi->deco.design.pixmap) + XCopyArea(display, gi->deco.design.pixmap, drawto, gc, + gi->deco.design.x, gi->deco.design.y, + gi->deco.width, gi->deco.height, + gi->x + gi->deco.x + (pressed ? gi->deco.xshift : 0), + gi->y + gi->deco.y + (pressed ? gi->deco.yshift : 0)); break; case GD_TYPE_TEXTINPUT_ALPHANUMERIC: diff --git a/src/buttons.h b/src/buttons.h index afbcfe8c..abaa5262 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -330,16 +330,20 @@ int CheckCountButtons(int, int, int); #define GDI_ALT_DESIGN_UNPRESSED 17 #define GDI_ALT_DESIGN_PRESSED 18 #define GDI_DESIGN_BORDER 19 -#define GDI_EVENT_MASK 20 -#define GDI_EVENT 21 -#define GDI_CALLBACK_INFO 22 -#define GDI_CALLBACK_ACTION 23 -#define GDI_AREA_SIZE 24 -#define GDI_ITEM_SIZE 25 -#define GDI_SCROLLBAR_ITEMS_MAX 26 -#define GDI_SCROLLBAR_ITEMS_VISIBLE 27 -#define GDI_SCROLLBAR_ITEM_POSITION 28 -#define GDI_INFO_TEXT 29 +#define GDI_DECORATION_DESIGN 20 +#define GDI_DECORATION_POSITION 22 +#define GDI_DECORATION_SIZE 21 +#define GDI_DECORATION_SHIFTING 23 +#define GDI_EVENT_MASK 24 +#define GDI_EVENT 25 +#define GDI_CALLBACK_INFO 26 +#define GDI_CALLBACK_ACTION 27 +#define GDI_AREA_SIZE 28 +#define GDI_ITEM_SIZE 29 +#define GDI_SCROLLBAR_ITEMS_MAX 30 +#define GDI_SCROLLBAR_ITEMS_VISIBLE 31 +#define GDI_SCROLLBAR_ITEM_POSITION 32 +#define GDI_INFO_TEXT 33 typedef void (*gadget_function)(void *); @@ -349,6 +353,14 @@ struct GadgetDesign int x, y; /* position of rectangle in Pixmap */ }; +struct GadgetDecoration +{ + struct GadgetDesign design; /* decoration design structure */ + int x, y; /* position of deco on the gadget */ + int width, height; /* width and height of decoration */ + int xshift, yshift; /* deco shifting when gadget pressed */ +}; + struct GadgetEvent { unsigned long type; /* event type */ @@ -400,6 +412,7 @@ struct GadgetInfo boolean mapped; /* gadget is active */ 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 */ diff --git a/src/editor.c b/src/editor.c index f15d4016..64e96e24 100644 --- a/src/editor.c +++ b/src/editor.c @@ -79,6 +79,25 @@ #define ED_NUM_CTRL2_BUTTONS (ED_CTRL2_BUTTONS_HORIZ * ED_CTRL2_BUTTONS_VERT) #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_YPOS 30 +#define ED_ELEMENTLIST_ALT_YPOS 190 +#define ED_ELEMENTLIST_XSIZE 22 +#define ED_ELEMENTLIST_YSIZE 22 +#define ED_ELEMENTLIST_BUTTONS_HORIZ 4 +#define ED_ELEMENTLIST_BUTTONS_VERT 10 +#define ED_NUM_ELEMENTLIST_BUTTONS (ED_ELEMENTLIST_BUTTONS_HORIZ * \ + ED_ELEMENTLIST_BUTTONS_VERT) + /* values for element properties window */ #define ED_PROPERTIES_XPOS (TILEX - MINI_TILEX/2) @@ -207,7 +226,15 @@ #define ED_CTRL_ID_SCROLL_VERTICAL 62 #define ED_CTRL_ID_SCROLL_HORIZONTAL 63 -#define ED_NUM_GADGETS 64 +/* gadgets for scrolling element list */ +#define ED_CTRL_ID_ELEMENTLIST_UP 64 +#define ED_CTRL_ID_ELEMENTLIST_DOWN 65 + +/* gadgets for buttons in element list */ +#define ED_CTRL_ID_ELEMENTLIST_FIRST 66 +#define ED_CTRL_ID_ELEMENTLIST_LAST 105 + +#define ED_NUM_GADGETS 106 /* values for counter gadgets */ #define ED_COUNTER_ID_ELEM_SCORE 0 @@ -224,7 +251,7 @@ #define ED_TEXTINPUT_ID_LEVEL_AUTHOR 1 #define ED_NUM_COUNTERBUTTONS 8 -#define ED_NUM_SCROLLBUTTONS 4 +#define ED_NUM_SCROLLBUTTONS 6 #define ED_NUM_SCROLLBARS 2 #define ED_NUM_TEXTINPUT 2 @@ -387,23 +414,39 @@ static struct { { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 0 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, ED_CTRL_ID_SCROLL_UP, + ED_SCROLL_UP_XPOS, ED_SCROLL_UP_YPOS, + ED_CTRL_ID_SCROLL_UP, "scroll level editing area up" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 1 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, ED_CTRL_ID_SCROLL_DOWN, + ED_SCROLL_DOWN_XPOS, ED_SCROLL_DOWN_YPOS, + ED_CTRL_ID_SCROLL_DOWN, "scroll level editing area down" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 2 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, ED_CTRL_ID_SCROLL_LEFT, + ED_SCROLL_LEFT_XPOS, ED_SCROLL_LEFT_YPOS, + ED_CTRL_ID_SCROLL_LEFT, "scroll level editing area left" }, { ED_SCROLLBUTTON_XPOS, ED_SCROLLBUTTON_YPOS + 3 * ED_SCROLLBUTTON_YSIZE, - ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, ED_CTRL_ID_SCROLL_RIGHT, + ED_SCROLL_RIGHT_XPOS, ED_SCROLL_RIGHT_YPOS, + ED_CTRL_ID_SCROLL_RIGHT, "scroll level editing area right" + }, + { + ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_ALT_YPOS, + ED_ELEMENTLIST_UP_XPOS, ED_ELEMENTLIST_UP_YPOS, + ED_CTRL_ID_ELEMENTLIST_UP, + "scroll element list up" + }, + { + ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_ALT_YPOS, + ED_ELEMENTLIST_DOWN_XPOS, ED_ELEMENTLIST_DOWN_YPOS, + ED_CTRL_ID_ELEMENTLIST_DOWN, + "scroll element list down" } }; @@ -973,28 +1016,101 @@ static void CreateControlButtons() level_editor_gadget[id] = gi; } - /* create buttons for scrolling of drawing area */ + /* create buttons for scrolling of drawing area and element list */ for (i=0; ix < DX) + UnmapGadget(level_editor_gadget[i]); } void UnmapLevelEditorGadgets() @@ -1780,6 +1899,9 @@ void LevelEd(int mx, int my, int button) } else /********** EDIT/CTRL-FENSTER **********/ { + + +#if 0 static unsigned long choice_delay = 0; int choice = CheckElemButtons(mx,my,button); int elem_pos = choice-ED_BUTTON_ELEM; @@ -1792,14 +1914,8 @@ void LevelEd(int mx, int my, int button) int step = (button == 1 ? 1 : button == 2 ? 5 : 10); int i; -#if 0 - step = (button==1 ? MAX_ELEM_X : button==2 ? 5*MAX_ELEM_X : - elements_in_list); - element_shift += (choice==ED_BUTTON_EUP ? -step : step); -#else step = step * MAX_ELEM_X * (choice == ED_BUTTON_EUP ? -1 : +1); element_shift += step; -#endif if (element_shift<0) element_shift = 0; @@ -1829,6 +1945,9 @@ void LevelEd(int mx, int my, int button) DrawPropertiesWindow(); } } +#endif + + if (edit_mode == ED_MODE_DRAWING) /********** EDIT-FENSTER **********/ { @@ -3678,7 +3797,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) int new_element; int player_present = FALSE; int level_changed = FALSE; - int x, y; + int i, x, y; new_element = (button == 1 ? new_element1 : button == 2 ? new_element2 : @@ -3794,6 +3913,29 @@ static void HandleControlButtons(struct GadgetInfo *gi) DrawMiniLevel(level_xpos, level_ypos); break; + case ED_CTRL_ID_ELEMENTLIST_UP: + case ED_CTRL_ID_ELEMENTLIST_DOWN: + step *= (id == ED_CTRL_ID_ELEMENTLIST_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; + + for (i=0; ideco.design; + + UnmapGadget(gi); + getMiniGraphicSource(el2gfx(editor_element[element_shift + i]), + &design->pixmap, &design->x, &design->y); + MapGadget(gi); + } + break; + case ED_CTRL_ID_WRAP_LEFT: WrapLevel(-step, 0); break; diff --git a/src/game.c b/src/game.c index 73cab116..c1691e61 100644 --- a/src/game.c +++ b/src/game.c @@ -4887,18 +4887,18 @@ static struct void CreateGameButtons() { - Pixmap gd_pixmap = pix[PIX_DOOR]; - struct GadgetInfo *gi; - unsigned long event_mask; int i; for (i=0; i= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) + { + graphic -= GFX_START_ROCKSSCREEN; + *pixmap = pix[PIX_BACK]; + *x = MINI_GFX_STARTX + (graphic % MINI_GFX_PER_LINE) * MINI_TILEX; + *y = MINI_GFX_STARTY + (graphic / MINI_GFX_PER_LINE) * MINI_TILEY; + } + else if (graphic >= GFX_START_ROCKSMORE && graphic <= GFX_END_ROCKSMORE) + { + graphic -= GFX_START_ROCKSMORE; + *pixmap = pix[PIX_MORE]; + *x = MINI_MORE_STARTX + (graphic % MINI_MORE_PER_LINE) * MINI_TILEX; + *y = MINI_MORE_STARTY + (graphic / MINI_MORE_PER_LINE) * MINI_TILEY; + } + else if (graphic >= GFX_START_ROCKSFONT && graphic <= GFX_END_ROCKSFONT) + { + graphic -= GFX_START_ROCKSFONT; + *pixmap = pix[PIX_SMALLFONT]; + *x = (graphic % FONT_CHARS_PER_LINE) * FONT4_XSIZE; + *y = ((graphic / FONT_CHARS_PER_LINE) * FONT4_YSIZE + + FC_SPECIAL2 * FONT2_YSIZE * FONT_LINES_PER_FONT); + } + else + { + *pixmap = pix[PIX_MORE]; + *x = MINI_MORE_STARTX; + *y = MINI_MORE_STARTY; + } +} + void DrawMiniGraphicExt(Drawable d, GC gc, int x, int y, int graphic) { if (graphic >= GFX_START_ROCKSSCREEN && graphic <= GFX_END_ROCKSSCREEN) diff --git a/src/tools.h b/src/tools.h index e83ebfa9..1ec4c65d 100644 --- a/src/tools.h +++ b/src/tools.h @@ -77,6 +77,7 @@ void DrawGraphicExt(Drawable, GC, int, int, int); void DrawGraphicThruMask(int, int, int); void DrawGraphicThruMaskExt(Drawable, int, int, int); void DrawMiniGraphic(int, int, int); +void getMiniGraphicSource(int, Pixmap *, int *, int *); void DrawMiniGraphicExt(Drawable, GC, int, int, int); void DrawGraphicShifted(int, int, int, int, int, int, int); void DrawGraphicShiftedThruMask(int, int, int, int, int, int);