From: Holger Schemel Date: Sat, 20 Feb 1999 01:03:28 +0000 (+0100) Subject: rnd-19990220-1-src X-Git-Tag: 1.4.0^2~36 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=20e58eb6573a45a41c25958e17e8d9c20f738edc;p=rocksndiamonds.git rnd-19990220-1-src --- diff --git a/src/buttons.c b/src/buttons.c index c24981f3..78e28d16 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -899,7 +899,8 @@ static void MultiMapGadgets(int mode) { if ((mode & MULTIMAP_PLAYFIELD && gi->x < SX + SXSIZE) || (mode & MULTIMAP_DOOR_1 && gi->x >= DX && gi->y < DY + DYSIZE) || - (mode & MULTIMAP_DOOR_1 && gi->x >= DX && gi->y > DY + DYSIZE)) + (mode & MULTIMAP_DOOR_2 && gi->x >= DX && gi->y > DY + DYSIZE) || + (mode & MULTIMAP_ALL) == MULTIMAP_ALL) { if (mode & MULTIMAP_UNMAP) { @@ -1183,6 +1184,8 @@ void HandleGadgets(int mx, int my, int button) if (gadget_pressed_repeated) { + gi->event.type = GD_EVENT_PRESSED; + if (gi->event_mask & GD_EVENT_REPEATED && DelayReached(&pressed_delay, GADGET_FRAME_DELAY)) gi->callback_action(gi); diff --git a/src/editor.c b/src/editor.c index ee201420..d5233e26 100644 --- a/src/editor.c +++ b/src/editor.c @@ -221,51 +221,54 @@ #define GADGET_ID_LEVEL_TIMESCORE_DOWN 43 #define GADGET_ID_LEVEL_TIMESCORE_TEXT 44 #define GADGET_ID_LEVEL_TIMESCORE_UP 45 +#define GADGET_ID_SELECT_LEVEL_DOWN 46 +#define GADGET_ID_SELECT_LEVEL_TEXT 47 +#define GADGET_ID_SELECT_LEVEL_UP 48 /* drawing area identifiers */ -#define GADGET_ID_DRAWING_LEVEL 46 -#define GADGET_ID_ELEM_CONTENT_0 47 -#define GADGET_ID_ELEM_CONTENT_1 48 -#define GADGET_ID_ELEM_CONTENT_2 49 -#define GADGET_ID_ELEM_CONTENT_3 50 -#define GADGET_ID_ELEM_CONTENT_4 51 -#define GADGET_ID_ELEM_CONTENT_5 52 -#define GADGET_ID_ELEM_CONTENT_6 53 -#define GADGET_ID_ELEM_CONTENT_7 54 -#define GADGET_ID_AMOEBA_CONTENT 55 +#define GADGET_ID_DRAWING_LEVEL 49 +#define GADGET_ID_ELEM_CONTENT_0 50 +#define GADGET_ID_ELEM_CONTENT_1 51 +#define GADGET_ID_ELEM_CONTENT_2 52 +#define GADGET_ID_ELEM_CONTENT_3 53 +#define GADGET_ID_ELEM_CONTENT_4 54 +#define GADGET_ID_ELEM_CONTENT_5 55 +#define GADGET_ID_ELEM_CONTENT_6 56 +#define GADGET_ID_ELEM_CONTENT_7 57 +#define GADGET_ID_AMOEBA_CONTENT 58 /* text input identifiers */ -#define GADGET_ID_LEVEL_NAME 56 -#define GADGET_ID_LEVEL_AUTHOR 57 +#define GADGET_ID_LEVEL_NAME 59 +#define GADGET_ID_LEVEL_AUTHOR 60 /* gadgets for scrolling of drawing area */ -#define GADGET_ID_SCROLL_UP 58 -#define GADGET_ID_SCROLL_DOWN 59 -#define GADGET_ID_SCROLL_LEFT 60 -#define GADGET_ID_SCROLL_RIGHT 61 -#define GADGET_ID_SCROLL_HORIZONTAL 62 -#define GADGET_ID_SCROLL_VERTICAL 63 +#define GADGET_ID_SCROLL_UP 61 +#define GADGET_ID_SCROLL_DOWN 62 +#define GADGET_ID_SCROLL_LEFT 63 +#define GADGET_ID_SCROLL_RIGHT 64 +#define GADGET_ID_SCROLL_HORIZONTAL 65 +#define GADGET_ID_SCROLL_VERTICAL 66 /* gadgets for scrolling element list */ -#define GADGET_ID_ELEMENTLIST_UP 64 -#define GADGET_ID_ELEMENTLIST_DOWN 65 +#define GADGET_ID_ELEMENTLIST_UP 67 +#define GADGET_ID_ELEMENTLIST_DOWN 68 /* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST 66 -#define GADGET_ID_ELEMENTLIST_LAST 105 +#define GADGET_ID_ELEMENTLIST_FIRST 69 +#define GADGET_ID_ELEMENTLIST_LAST 108 /* buttons for level settings */ -#define GADGET_ID_RANDOM_PERCENTAGE 106 -#define GADGET_ID_RANDOM_QUANTITY 107 -#define GADGET_ID_RANDOM_RESTRICTED 108 -#define GADGET_ID_DOUBLE_SPEED 109 -#define GADGET_ID_GRAVITY 110 -#define GADGET_ID_STICK_ELEMENT 111 +#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 /* another drawing area for random placement */ -#define GADGET_ID_RANDOM_BACKGROUND 112 +#define GADGET_ID_RANDOM_BACKGROUND 115 -#define NUM_EDITOR_GADGETS 113 +#define NUM_EDITOR_GADGETS 116 /* radio button numbers */ #define RADIO_NR_NONE 0 @@ -281,8 +284,9 @@ #define ED_COUNTER_ID_LEVEL_TIMELIMIT 5 #define ED_COUNTER_ID_LEVEL_TIMESCORE 6 #define ED_COUNTER_ID_LEVEL_RANDOM 7 +#define ED_COUNTER_ID_SELECT_LEVEL 8 -#define ED_NUM_COUNTERBUTTONS 8 +#define ED_NUM_COUNTERBUTTONS 9 #define ED_COUNTER_ID_LEVEL_FIRST ED_COUNTER_ID_LEVEL_XSIZE #define ED_COUNTER_ID_LEVEL_LAST ED_COUNTER_ID_LEVEL_RANDOM @@ -459,6 +463,14 @@ static struct GADGET_ID_LEVEL_RANDOM_TEXT, &random_placement_value, "random element placement", "in" + }, + { + DX - SX - 1, 0 - SY + 31, + 1, 100, + GADGET_ID_SELECT_LEVEL_DOWN, GADGET_ID_SELECT_LEVEL_UP, + GADGET_ID_SELECT_LEVEL_TEXT, + &level_nr, + NULL, NULL } }; @@ -644,6 +656,8 @@ static int new_element3 = EL_ERDREICH; #define BUTTON_STEPSIZE(button) (button == 1 ? 1 : button == 2 ? 5 : 10) /* forward declaration for internal use */ +static void ModifyEditorCounter(int, int); +static void ModifyEditorCounterLimits(int, int, int); static void DrawDrawingWindow(); static void DrawLevelInfoWindow(); static void DrawPropertiesWindow(); @@ -1318,15 +1332,39 @@ static void CreateCounterButtons() counterbutton_info[i].gadget_id_up); int gd_xoffset; int gd_x, gd_x1, gd_x2, gd_y; + int x_size, y_size; unsigned long event_mask; char infotext[MAX_INFOTEXT_LEN + 1]; event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; - gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS); - gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset; - gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset; - gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS; + if (i == ED_COUNTER_ID_SELECT_LEVEL) + { + int sid = (j == 0 ? + ED_SCROLLBUTTON_ID_AREA_LEFT : + ED_SCROLLBUTTON_ID_AREA_RIGHT); + + event_mask |= GD_EVENT_RELEASED; + + if (j == 1) + xpos += ED_GADGET_DISTANCE; + ypos += ED_GADGET_DISTANCE; + + gd_x1 = DOOR_GFX_PAGEX8 + scrollbutton_info[sid].xpos; + gd_x2 = gd_x1 - ED_SCROLLBUTTON_XSIZE; + gd_y = DOOR_GFX_PAGEY1 + scrollbutton_info[sid].ypos; + x_size = ED_SCROLLBUTTON_XSIZE; + y_size = ED_SCROLLBUTTON_YSIZE; + } + else + { + gd_xoffset = (j == 0 ? ED_BUTTON_MINUS_XPOS : ED_BUTTON_PLUS_XPOS); + gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset; + gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset; + gd_y = DOOR_GFX_PAGEY1 + ED_BUTTON_COUNT_YPOS; + x_size = ED_BUTTON_COUNT_XSIZE; + y_size = ED_BUTTON_COUNT_YSIZE; + } sprintf(infotext, "%s counter value by 1, 5 or 10", (j == 0 ? "decrease" : "increase")); @@ -1336,8 +1374,8 @@ static void CreateCounterButtons() GDI_INFO_TEXT, infotext, GDI_X, xpos, GDI_Y, ypos, - GDI_WIDTH, ED_BUTTON_COUNT_XSIZE, - GDI_HEIGHT, ED_BUTTON_COUNT_YSIZE, + GDI_WIDTH, x_size, + GDI_HEIGHT, y_size, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, GDI_STATE, GD_BUTTON_UNPRESSED, GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y, @@ -1357,8 +1395,19 @@ static void CreateCounterButtons() id = counterbutton_info[i].gadget_id_text; event_mask = GD_EVENT_TEXT_RETURN | GD_EVENT_TEXT_LEAVING; - gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS; - gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS; + if (i == ED_COUNTER_ID_SELECT_LEVEL) + { + xpos += 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; + } + else + { + gd_x = DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS; + gd_y = DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS; + } gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_CUSTOM_TYPE_ID, i, @@ -1675,23 +1724,35 @@ void CreateLevelEditorGadgets() CreateCheckbuttonGadgets(); } +static void MapCounterButtons(int id) +{ + MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_down]); + MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_text]); + MapGadget(level_editor_gadget[counterbutton_info[id].gadget_id_up]); +} + static void MapControlButtons() { + int counter_id; int i; + /* map toolbox buttons */ for (i=0; ix < DX) + if (level_editor_gadget[i]->x < SX + SXSIZE) UnmapGadget(level_editor_gadget[i]); } @@ -1767,10 +1828,53 @@ void UnmapLevelEditorGadgets() UnmapGadget(level_editor_gadget[i]); } -void DrawLevelEd() +static void ResetUndoBuffer() +{ + undo_buffer_position = -1; + undo_buffer_steps = -1; + CopyLevelToUndoBuffer(UNDO_IMMEDIATE); +} + +static void DrawEditModeWindow() +{ + if (edit_mode == ED_MODE_INFO) + DrawLevelInfoWindow(); + else if (edit_mode == ED_MODE_PROPERTIES) + DrawPropertiesWindow(); + else /* edit_mode == ED_MODE_DRAWING */ + DrawDrawingWindow(); +} + +static boolean LevelChanged() { - edit_mode = ED_MODE_DRAWING; + boolean level_changed = FALSE; + int x, y; + + for(y=0; ycustom_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; @@ -1985,6 +2129,14 @@ static void ModifyEditorCounter(int counter_id, int new_value) *counter_value = gi->text.number_value; } +static void ModifyEditorCounterLimits(int counter_id, int min, int max) +{ + int gadget_id = counterbutton_info[counter_id].gadget_id_text; + struct GadgetInfo *gi = level_editor_gadget[gadget_id]; + + ModifyGadget(gi, GDI_NUMBER_MIN, min, GDI_NUMBER_MAX, max, GDI_END); +} + static void PickDrawingElement(int button, int element) { if (button < 1 || button > 3) @@ -2962,7 +3114,7 @@ static void CopyLevelToUndoBuffer(int mode) for(y=0; ytext.number_value; else @@ -3323,8 +3481,6 @@ static void HandleControlButtons(struct GadgetInfo *gi) int button = gi->event.button; int step = BUTTON_STEPSIZE(button); int new_element = BUTTON_ELEMENT(button); - int player_present = FALSE; - int level_changed = FALSE; int i, x, y; if (edit_mode == ED_MODE_DRAWING && drawing_function == GADGET_ID_TEXT) @@ -3552,19 +3708,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) break; } - for(y=0; ygems_still_needed,3), FS_SMALL, FC_YELLOW); DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, diff --git a/src/main.h b/src/main.h index 59f504f3..5f0a813a 100644 --- a/src/main.h +++ b/src/main.h @@ -544,6 +544,8 @@ extern char *element_info[]; #define FONT3_YSIZE 14 #define FONT4_XSIZE 16 #define FONT4_YSIZE 16 +#define FONT5_XSIZE 10 +#define FONT5_YSIZE 12 #define GFX_STARTX SX #define GFX_STARTY SY @@ -1294,6 +1296,7 @@ extern char *element_info[]; #define FC_YELLOW 3 #define FC_SPECIAL1 4 #define FC_SPECIAL2 5 +#define FC_SPECIAL3 6 /* values for game_status */ #define EXITGAME 0 diff --git a/src/screens.c b/src/screens.c index 3bf0c300..d494e99a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -70,6 +70,9 @@ void DrawMainMenu() return; } + /* needed if last screen was the editor screen */ + UndrawSpecialEditorDoor(); + /* map gadgets for main menu screen */ MapTapeButtons(); @@ -130,7 +133,10 @@ void DrawMainMenu() OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); +#if 0 ClearEventQueue(); +#endif + } void HandleMainMenu(int mx, int my, int dx, int dy, int button) diff --git a/src/tools.c b/src/tools.c index 49e65e5c..39e327cc 100644 --- a/src/tools.c +++ b/src/tools.c @@ -316,12 +316,14 @@ void ClearWindow() void DrawTextFCentered(int y, int font_type, char *format, ...) { - char buffer[FULL_SXSIZE / FONT3_XSIZE + 10]; + char buffer[FULL_SXSIZE / FONT5_XSIZE + 10]; int font_xsize; va_list ap; font_xsize = (font_type < FC_SPECIAL1 ? FONT2_XSIZE : - font_type < FC_SPECIAL2 ? FONT3_XSIZE : FONT4_XSIZE); + font_type < FC_SPECIAL2 ? FONT3_XSIZE : + font_type < FC_SPECIAL3 ? FONT4_XSIZE : + FONT5_XSIZE); va_start(ap, format); vsprintf(buffer, format, ap); @@ -333,7 +335,7 @@ void DrawTextFCentered(int y, int font_type, char *format, ...) void DrawTextF(int x, int y, int font_type, char *format, ...) { - char buffer[FULL_SXSIZE / FONT3_XSIZE + 10]; + char buffer[FULL_SXSIZE / FONT5_XSIZE + 10]; va_list ap; va_start(ap, format); @@ -362,18 +364,26 @@ void DrawTextExt(Drawable d, GC gc, int x, int y, if (font_size != FS_SMALL && font_size != FS_BIG) font_size = FS_SMALL; - if (font_type < FC_RED || font_type > FC_SPECIAL2) + 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 : FONT4_XSIZE); - font_height = (font_size == FS_BIG ? FONT1_XSIZE : - font_type < FC_SPECIAL2 ? FONT2_XSIZE : FONT4_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_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; + while (*text) { char c = *text++; @@ -1513,9 +1523,6 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) { int x, y; - /* determine border element for this level */ - SetBorderElement(); - XFillRectangle(display, drawto, gc, xpos, ypos, MICROLEV_XSIZE, MICROLEV_YSIZE); @@ -1742,7 +1749,10 @@ boolean Request(char *text, unsigned int req_state) DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); OpenDoor(DOOR_OPEN_1); + +#if 0 ClearEventQueue(); +#endif if (!(req_state & REQUEST_WAIT_FOR)) return(FALSE); @@ -2071,7 +2081,33 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state & DOOR_ACTION_2) door2 = door_state & DOOR_ACTION_2; - return(door1 | door2); + return (door1 | door2); +} + +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); + + redraw_mask |= REDRAW_ALL; +} + +void UndrawSpecialEditorDoor() +{ + /* draw normal tape recorder window */ + 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; } int ReadPixel(Drawable d, int x, int y) @@ -2188,6 +2224,11 @@ static struct } }; +static void DoNotDisplayInfoText(void *ptr) +{ + return; +} + void CreateToolButtons() { int i; @@ -2235,6 +2276,7 @@ void CreateToolButtons() GDI_DECORATION_SHIFTING, 1, 1, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleToolButtons, + GDI_CALLBACK_INFO, DoNotDisplayInfoText, GDI_END); if (gi == NULL) diff --git a/src/tools.h b/src/tools.h index 7878a283..9ec88df2 100644 --- a/src/tools.h +++ b/src/tools.h @@ -105,6 +105,8 @@ unsigned int OpenDoor(unsigned int); unsigned int CloseDoor(unsigned int); unsigned int GetDoorState(void); unsigned int MoveDoor(unsigned int); +void DrawSpecialEditorDoor(); +void UndrawSpecialEditorDoor(); int ReadPixel(Drawable, int, int); void CreateToolButtons();